Commit 56211121 authored by Mika Westerberg's avatar Mika Westerberg Committed by Linus Walleij

pinctrl: cherryview: Serialize register access in suspend/resume

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: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 9999fe5d
...@@ -1656,8 +1656,11 @@ static int chv_pinctrl_suspend(struct device *dev) ...@@ -1656,8 +1656,11 @@ static int chv_pinctrl_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct chv_pinctrl *pctrl = platform_get_drvdata(pdev); struct chv_pinctrl *pctrl = platform_get_drvdata(pdev);
unsigned long flags;
int i; int i;
raw_spin_lock_irqsave(&chv_lock, flags);
pctrl->saved_intmask = readl(pctrl->regs + CHV_INTMASK); pctrl->saved_intmask = readl(pctrl->regs + CHV_INTMASK);
for (i = 0; i < pctrl->community->npins; i++) { for (i = 0; i < pctrl->community->npins; i++) {
...@@ -1678,6 +1681,8 @@ static int chv_pinctrl_suspend(struct device *dev) ...@@ -1678,6 +1681,8 @@ static int chv_pinctrl_suspend(struct device *dev)
ctx->padctrl1 = readl(reg); ctx->padctrl1 = readl(reg);
} }
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
...@@ -1685,8 +1690,11 @@ static int chv_pinctrl_resume(struct device *dev) ...@@ -1685,8 +1690,11 @@ static int chv_pinctrl_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct chv_pinctrl *pctrl = platform_get_drvdata(pdev); struct chv_pinctrl *pctrl = platform_get_drvdata(pdev);
unsigned long flags;
int i; int i;
raw_spin_lock_irqsave(&chv_lock, flags);
/* /*
* Mask all interrupts before restoring per-pin configuration * Mask all interrupts before restoring per-pin configuration
* registers because we don't know in which state BIOS left them * registers because we don't know in which state BIOS left them
...@@ -1731,6 +1739,8 @@ static int chv_pinctrl_resume(struct device *dev) ...@@ -1731,6 +1739,8 @@ static int chv_pinctrl_resume(struct device *dev)
chv_writel(0xffff, pctrl->regs + CHV_INTSTAT); chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
chv_writel(pctrl->saved_intmask, pctrl->regs + CHV_INTMASK); chv_writel(pctrl->saved_intmask, pctrl->regs + CHV_INTMASK);
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment