linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sa1111: Prevent deadlock in resume path
@ 2010-05-26 19:11 Marek Vasut
  2010-05-26 19:14 ` Russell King - ARM Linux
  0 siblings, 1 reply; 15+ messages in thread
From: Marek Vasut @ 2010-05-26 19:11 UTC (permalink / raw)
  To: linux-arm-kernel

This patch reorganises the sa1111_resume() function in a manner the spinlock
happens after calling the sa1111_wake(). This fixes two bugs:

1) This function called sa1111_wake() which tried to claim the same spinlock
   the sa1111_resume() already claimed. This would result in certain deadlock.

   Original idea for this part: Russell King <linux@arm.linux.org.uk>

2) The function didn't unlock the spinlock in case the chip didn't report
   correct ID.

   Original idea for this part: Julia Lawall <julia@diku.dk>

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/common/sa1111.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index a52a27c..6f80665 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -951,8 +951,6 @@ static int sa1111_resume(struct platform_device *dev)
 	if (!save)
 		return 0;
 
-	spin_lock_irqsave(&sachip->lock, flags);
-
 	/*
 	 * Ensure that the SA1111 is still here.
 	 * FIXME: shouldn't do this here.
@@ -969,6 +967,13 @@ static int sa1111_resume(struct platform_device *dev)
 	 * First of all, wake up the chip.
 	 */
 	sa1111_wake(sachip);
+
+	/*
+	 * Only lock for write ops. Also, sa1111_wake must be called with
+	 * released spinlock!
+	 */
+	spin_lock_irqsave(&sachip->lock, flags);
+
 	sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0);
 	sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1);
 
-- 
1.7.0

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

end of thread, other threads:[~2010-06-12  5:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26 19:11 [PATCH] sa1111: Prevent deadlock in resume path Marek Vasut
2010-05-26 19:14 ` Russell King - ARM Linux
2010-05-26 19:15   ` Marek Vasut
2010-05-26 20:18     ` Russell King - ARM Linux
2010-05-26 21:33       ` Marek Vasut
2010-05-26 21:42         ` Russell King - ARM Linux
2010-05-26 21:52           ` Marek Vasut
2010-05-26 22:25             ` Russell King - ARM Linux
2010-05-26 22:35               ` Marek Vasut
2010-05-27  3:49                 ` Nicolas Pitre
2010-06-10 13:56       ` Pavel Machek
2010-06-10 21:49         ` Marek Vasut
2010-06-10 23:05           ` Russell King - ARM Linux
2010-06-11 12:22         ` Catalin Marinas
2010-06-12  5:36           ` Eric Miao

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).