linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] pinctrl: cherryview: Serialize register access in suspend and resume hooks
@ 2016-10-31 14:57 Mika Westerberg
  2016-10-31 14:57 ` [PATCH 2/3] pinctrl: cherryview: Prevent possible interrupt storm on resume Mika Westerberg
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mika Westerberg @ 2016-10-31 14:57 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Christian Steiner, Heikki Krogerus, Mika Westerberg, linux-gpio,
	linux-kernel

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(+)

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
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-04 15:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-31 14:57 [PATCH 1/3] pinctrl: cherryview: Serialize register access in suspend and resume hooks Mika Westerberg
2016-10-31 14:57 ` [PATCH 2/3] pinctrl: cherryview: Prevent possible interrupt storm on resume Mika Westerberg
2016-11-04 15:14   ` Linus Walleij
2016-10-31 14:57 ` [PATCH 3/3] pinctrl: cherryview: Drop ctrlX prefix from the pin debugfs output Mika Westerberg
2016-11-04 15:15   ` Linus Walleij
2016-11-04 15:12 ` [PATCH 1/3] pinctrl: cherryview: Serialize register access in suspend and resume hooks Linus Walleij
2016-11-04 15:15   ` Linus Walleij
2016-11-04 15:28     ` Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).