All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] stmmac: fix sleep inside atomic
@ 2010-09-06  3:06 Giuseppe CAVALLARO
  2010-09-06 20:11 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Giuseppe CAVALLARO @ 2010-09-06  3:06 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro

We cannot use spinlock when kmalloc is invoked with
GFP_KERNEL flag because it can sleep.
So this patch reviews the usage of spinlock within the
stmmac_resume function avoing this bug.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/stmmac/stmmac_main.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index bbb7951..a9befd6 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1865,15 +1865,15 @@ static int stmmac_resume(struct platform_device *pdev)
 	if (!netif_running(dev))
 		return 0;
 
-	spin_lock(&priv->lock);
-
 	if (priv->shutdown) {
 		/* Re-open the interface and re-init the MAC/DMA
-		   and the rings. */
+		   and the rings (i.e. on hibernation stage) */
 		stmmac_open(dev);
-		goto out_resume;
+		return 0;
 	}
 
+	spin_lock(&priv->lock);
+
 	/* Power Down bit, into the PM register, is cleared
 	 * automatically as soon as a magic packet or a Wake-up frame
 	 * is received. Anyway, it's better to manually clear
@@ -1901,7 +1901,6 @@ static int stmmac_resume(struct platform_device *pdev)
 
 	netif_start_queue(dev);
 
-out_resume:
 	spin_unlock(&priv->lock);
 	return 0;
 }
-- 
1.5.5.6


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

* Re: [PATCH] stmmac: fix sleep inside atomic
  2010-09-06  3:06 [PATCH] stmmac: fix sleep inside atomic Giuseppe CAVALLARO
@ 2010-09-06 20:11 ` David Miller
  2010-09-07  5:55   ` Peppe CAVALLARO
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2010-09-06 20:11 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev

From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Date: Mon,  6 Sep 2010 05:06:19 +0200

> We cannot use spinlock when kmalloc is invoked with
> GFP_KERNEL flag because it can sleep.
> So this patch reviews the usage of spinlock within the
> stmmac_resume function avoing this bug.
> 
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Applied, but you are extremely guilty of the sin of omission
here.

Why in the world did you not at least CC: Jiri, the person
who reported this problem?  You should do that at a minimum
when someone reports a problem with code you are fixing.

And in this case he definitely deserves a

Reported-by:

tag in the commit message as well.

Please don't fail to acknowledge a reporter's efforts like
this ever again.

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

* Re: [PATCH] stmmac: fix sleep inside atomic
  2010-09-06 20:11 ` David Miller
@ 2010-09-07  5:55   ` Peppe CAVALLARO
  0 siblings, 0 replies; 3+ messages in thread
From: Peppe CAVALLARO @ 2010-09-07  5:55 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Jiri Slaby

[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]

 Hi David,
On 9/6/2010 10:11 PM, David Miller wrote:
>
> From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
> Date: Mon,  6 Sep 2010 05:06:19 +0200
>
> > We cannot use spinlock when kmalloc is invoked with
> > GFP_KERNEL flag because it can sleep.
> > So this patch reviews the usage of spinlock within the
> > stmmac_resume function avoing this bug.
> >
> > Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>
> Applied, but you are extremely guilty of the sin of omission
> here.
>
> Why in the world did you not at least CC: Jiri, the person
> who reported this problem?  You should do that at a minimum
> when someone reports a problem with code you are fixing.
>
You are right and I'm awfully sorry for this (sorry Jiri!).
>
> And in this case he definitely deserves a
>
> Reported-by:
>
> tag in the commit message as well.
>
> Please don't fail to acknowledge a reporter's efforts like
> this ever again.
>

This will never happen.
I've attached the patch reviewed as well.

I hope this has not hurt Jiri.

Regards,
Peppe

P.S. I'm waiting for my third baby so I'm quite stressed and busy in
these days.
I wanted fixed the issue spotted by Jiri but I was too fast to send the
patch.
I hope this can help to save me ;-)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-stmmac-fix-sleep-inside-atomic.patch --]
[-- Type: text/x-patch; name="0001-stmmac-fix-sleep-inside-atomic.patch", Size: 1583 bytes --]

From 88f4ac7e90bfe4c54316a7ac5e064264e1acf6a4 Mon Sep 17 00:00:00 2001
From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Date: Mon, 6 Sep 2010 05:02:11 +0200
Subject: [PATCH] stmmac: fix sleep inside atomic

We cannot use spinlock when kmalloc is invoked with
GFP_KERNEL flag because it can sleep.
So this patch reviews the usage of spinlock within the
stmmac_resume function avoing this bug.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Reported-by: Jiri Slaby <jirislaby@gmail.com>
---
 drivers/net/stmmac/stmmac_main.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index bbb7951..a9befd6 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1865,15 +1865,15 @@ static int stmmac_resume(struct platform_device *pdev)
 	if (!netif_running(dev))
 		return 0;
 
-	spin_lock(&priv->lock);
-
 	if (priv->shutdown) {
 		/* Re-open the interface and re-init the MAC/DMA
-		   and the rings. */
+		   and the rings (i.e. on hibernation stage) */
 		stmmac_open(dev);
-		goto out_resume;
+		return 0;
 	}
 
+	spin_lock(&priv->lock);
+
 	/* Power Down bit, into the PM register, is cleared
 	 * automatically as soon as a magic packet or a Wake-up frame
 	 * is received. Anyway, it's better to manually clear
@@ -1901,7 +1901,6 @@ static int stmmac_resume(struct platform_device *pdev)
 
 	netif_start_queue(dev);
 
-out_resume:
 	spin_unlock(&priv->lock);
 	return 0;
 }
-- 
1.5.5.6


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

end of thread, other threads:[~2010-09-07  5:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-06  3:06 [PATCH] stmmac: fix sleep inside atomic Giuseppe CAVALLARO
2010-09-06 20:11 ` David Miller
2010-09-07  5:55   ` Peppe CAVALLARO

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.