Skip to content

Commit

Permalink
pinctrl: cherryview: Serialize register access in suspend/resume
Browse files Browse the repository at this point in the history
If async suspend is enabled, the driver may access registers concurrently
with another instance which may fail because of the bug in Cherryview GPIO
hardware. Prevent this by taking the shared lock while accessing the
hardware in suspend and resume hooks.

Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
westeri authored and linusw committed Nov 4, 2016
1 parent 9999fe5 commit 5621112
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/pinctrl/intel/pinctrl-cherryview.c
Original file line number Diff line number Diff line change
Expand Up @@ -1656,8 +1656,11 @@ static int chv_pinctrl_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct chv_pinctrl *pctrl = platform_get_drvdata(pdev);
unsigned long flags;
int i;

raw_spin_lock_irqsave(&chv_lock, flags);

pctrl->saved_intmask = readl(pctrl->regs + CHV_INTMASK);

for (i = 0; i < pctrl->community->npins; i++) {
Expand All @@ -1678,15 +1681,20 @@ static int chv_pinctrl_suspend(struct device *dev)
ctx->padctrl1 = readl(reg);
}

raw_spin_unlock_irqrestore(&chv_lock, flags);

return 0;
}

static int chv_pinctrl_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct chv_pinctrl *pctrl = platform_get_drvdata(pdev);
unsigned long flags;
int i;

raw_spin_lock_irqsave(&chv_lock, flags);

/*
* Mask all interrupts before restoring per-pin configuration
* registers because we don't know in which state BIOS left them
Expand Down Expand Up @@ -1731,6 +1739,8 @@ static int chv_pinctrl_resume(struct device *dev)
chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
chv_writel(pctrl->saved_intmask, pctrl->regs + CHV_INTMASK);

raw_spin_unlock_irqrestore(&chv_lock, flags);

return 0;
}
#endif
Expand Down

0 comments on commit 5621112

Please sign in to comment.