netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peppe CAVALLARO <peppe.cavallaro@st.com>
To: David Miller <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Jiri Slaby <jirislaby@gmail.com>
Subject: Re: [PATCH] stmmac: fix sleep inside atomic
Date: Tue, 7 Sep 2010 07:55:55 +0200	[thread overview]
Message-ID: <4C85D3EB.7040208@st.com> (raw)
In-Reply-To: <20100906.131107.183045782.davem@davemloft.net>

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


      reply	other threads:[~2010-09-07  5:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C85D3EB.7040208@st.com \
    --to=peppe.cavallaro@st.com \
    --cc=davem@davemloft.net \
    --cc=jirislaby@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).