diff mbox

[1/3] pinctrl: cherryview: Serialize register access in suspend and resume hooks

Message ID 20161031145734.193016-1-mika.westerberg@linux.intel.com
State New
Headers show

Commit Message

Mika Westerberg Oct. 31, 2016, 2:57 p.m. UTC
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.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Linus Walleij Nov. 4, 2016, 3:12 p.m. UTC | #1
On Mon, Oct 31, 2016 at 3:57 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:

> 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.
>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Patch applied.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Nov. 4, 2016, 3:15 p.m. UTC | #2
On Fri, Nov 4, 2016 at 4:12 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Mon, Oct 31, 2016 at 3:57 PM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
>
>> 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.
>>
>> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> Patch applied.

Mika should this and patch 2/3 be tagged for stable?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mika Westerberg Nov. 4, 2016, 3:28 p.m. UTC | #3
On Fri, Nov 04, 2016 at 04:15:59PM +0100, Linus Walleij wrote:
> On Fri, Nov 4, 2016 at 4:12 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> > On Mon, Oct 31, 2016 at 3:57 PM, Mika Westerberg
> > <mika.westerberg@linux.intel.com> wrote:
> >
> >> 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.
> >>
> >> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> >
> > Patch applied.
> 
> Mika should this and patch 2/3 be tagged for stable?

Yes, I think they should.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index 30389f4ccab4..097d835b3a50 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -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++) {
@@ -1678,6 +1681,8 @@  static int chv_pinctrl_suspend(struct device *dev)
 		ctx->padctrl1 = readl(reg);
 	}
 
+	raw_spin_unlock_irqrestore(&chv_lock, flags);
+
 	return 0;
 }
 
@@ -1685,8 +1690,11 @@  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
@@ -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