* [PATCH] sky2: initialize napi before registering device
@ 2014-01-25 10:34 Stanislaw Gruszka
2014-01-26 1:01 ` Stephen Hemminger
2014-01-28 0:40 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Stanislaw Gruszka @ 2014-01-25 10:34 UTC (permalink / raw)
To: netdev; +Cc: Mirko Lindner, Stephen Hemminger
There is race condition when call netif_napi_add() after
register_netdevice(), as ->open() can be called without napi initialized
and trigger BUG_ON() on napi_enable(), like on below messages:
[ 9.699863] sky2: driver version 1.30
[ 9.699960] sky2 0000:02:00.0: Yukon-2 EC Ultra chip revision 2
[ 9.700020] sky2 0000:02:00.0: irq 45 for MSI/MSI-X
[ 9.700498] ------------[ cut here ]------------
[ 9.703391] kernel BUG at include/linux/netdevice.h:501!
[ 9.703391] invalid opcode: 0000 [#1] PREEMPT SMP
<snip>
[ 9.830018] Call Trace:
[ 9.830018] [<fa996169>] sky2_open+0x309/0x360 [sky2]
[ 9.830018] [<c1007210>] ? via_no_dac+0x40/0x40
[ 9.830018] [<c1007210>] ? via_no_dac+0x40/0x40
[ 9.830018] [<c135ed4b>] __dev_open+0x9b/0x120
[ 9.830018] [<c1431cbe>] ? _raw_spin_unlock_bh+0x1e/0x20
[ 9.830018] [<c135efd9>] __dev_change_flags+0x89/0x150
[ 9.830018] [<c135f148>] dev_change_flags+0x18/0x50
[ 9.830018] [<c13bb8e0>] devinet_ioctl+0x5d0/0x6e0
[ 9.830018] [<c13bcced>] inet_ioctl+0x6d/0xa0
To fix the problem patch changes the order of initialization.
Bug report:
https://bugzilla.kernel.org/show_bug.cgi?id=67151
Reported-and-tested-by: ebrahim.azarisooreh@gmail.com
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
drivers/net/ethernet/marvell/sky2.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 43aa7acd..2564eda 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -5020,6 +5020,8 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
}
}
+ netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_WEIGHT);
+
err = register_netdev(dev);
if (err) {
dev_err(&pdev->dev, "cannot register net device\n");
@@ -5028,8 +5030,6 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netif_carrier_off(dev);
- netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_WEIGHT);
-
sky2_show_addr(dev);
if (hw->ports > 1) {
--
1.7.4.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] sky2: initialize napi before registering device
2014-01-25 10:34 [PATCH] sky2: initialize napi before registering device Stanislaw Gruszka
@ 2014-01-26 1:01 ` Stephen Hemminger
2014-01-27 11:53 ` Stanislaw Gruszka
2014-01-28 0:40 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2014-01-26 1:01 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: netdev, Mirko Lindner
On Sat, 25 Jan 2014 11:34:54 +0100
Stanislaw Gruszka <stf_xl@wp.pl> wrote:
> There is race condition when call netif_napi_add() after
> register_netdevice(), as ->open() can be called without napi initialized
> and trigger BUG_ON() on napi_enable(), like on below messages:
>
> [ 9.699863] sky2: driver version 1.30
> [ 9.699960] sky2 0000:02:00.0: Yukon-2 EC Ultra chip revision 2
> [ 9.700020] sky2 0000:02:00.0: irq 45 for MSI/MSI-X
> [ 9.700498] ------------[ cut here ]------------
> [ 9.703391] kernel BUG at include/linux/netdevice.h:501!
> [ 9.703391] invalid opcode: 0000 [#1] PREEMPT SMP
> <snip>
> [ 9.830018] Call Trace:
> [ 9.830018] [<fa996169>] sky2_open+0x309/0x360 [sky2]
> [ 9.830018] [<c1007210>] ? via_no_dac+0x40/0x40
> [ 9.830018] [<c1007210>] ? via_no_dac+0x40/0x40
> [ 9.830018] [<c135ed4b>] __dev_open+0x9b/0x120
> [ 9.830018] [<c1431cbe>] ? _raw_spin_unlock_bh+0x1e/0x20
> [ 9.830018] [<c135efd9>] __dev_change_flags+0x89/0x150
> [ 9.830018] [<c135f148>] dev_change_flags+0x18/0x50
> [ 9.830018] [<c13bb8e0>] devinet_ioctl+0x5d0/0x6e0
> [ 9.830018] [<c13bcced>] inet_ioctl+0x6d/0xa0
>
> To fix the problem patch changes the order of initialization.
>
> Bug report:
> https://bugzilla.kernel.org/show_bug.cgi?id=67151
>
> Reported-and-tested-by: ebrahim.azarisooreh@gmail.com
> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
That looks good, problem was introduced years ago.
I wonder if netif_napi_del() should be in unwind if registration
of either devices fails?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sky2: initialize napi before registering device
2014-01-26 1:01 ` Stephen Hemminger
@ 2014-01-27 11:53 ` Stanislaw Gruszka
0 siblings, 0 replies; 4+ messages in thread
From: Stanislaw Gruszka @ 2014-01-27 11:53 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Mirko Lindner
On Sat, Jan 25, 2014 at 05:01:20PM -0800, Stephen Hemminger wrote:
> On Sat, 25 Jan 2014 11:34:54 +0100
> Stanislaw Gruszka <stf_xl@wp.pl> wrote:
>
> > There is race condition when call netif_napi_add() after
> > register_netdevice(), as ->open() can be called without napi initialized
> > and trigger BUG_ON() on napi_enable(), like on below messages:
> >
> > [ 9.699863] sky2: driver version 1.30
> > [ 9.699960] sky2 0000:02:00.0: Yukon-2 EC Ultra chip revision 2
> > [ 9.700020] sky2 0000:02:00.0: irq 45 for MSI/MSI-X
> > [ 9.700498] ------------[ cut here ]------------
> > [ 9.703391] kernel BUG at include/linux/netdevice.h:501!
> > [ 9.703391] invalid opcode: 0000 [#1] PREEMPT SMP
> > <snip>
> > [ 9.830018] Call Trace:
> > [ 9.830018] [<fa996169>] sky2_open+0x309/0x360 [sky2]
> > [ 9.830018] [<c1007210>] ? via_no_dac+0x40/0x40
> > [ 9.830018] [<c1007210>] ? via_no_dac+0x40/0x40
> > [ 9.830018] [<c135ed4b>] __dev_open+0x9b/0x120
> > [ 9.830018] [<c1431cbe>] ? _raw_spin_unlock_bh+0x1e/0x20
> > [ 9.830018] [<c135efd9>] __dev_change_flags+0x89/0x150
> > [ 9.830018] [<c135f148>] dev_change_flags+0x18/0x50
> > [ 9.830018] [<c13bb8e0>] devinet_ioctl+0x5d0/0x6e0
> > [ 9.830018] [<c13bcced>] inet_ioctl+0x6d/0xa0
> >
> > To fix the problem patch changes the order of initialization.
> >
> > Bug report:
> > https://bugzilla.kernel.org/show_bug.cgi?id=67151
> >
> > Reported-and-tested-by: ebrahim.azarisooreh@gmail.com
> > Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>
> That looks good, problem was introduced years ago.
> I wonder if netif_napi_del() should be in unwind if registration
> of either devices fails?
napif_napi_del() is called internally by free_netdev(), so we are
fine regarding error unwind and driver remove.
Thanks
Stanislaw
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sky2: initialize napi before registering device
2014-01-25 10:34 [PATCH] sky2: initialize napi before registering device Stanislaw Gruszka
2014-01-26 1:01 ` Stephen Hemminger
@ 2014-01-28 0:40 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-01-28 0:40 UTC (permalink / raw)
To: stf_xl; +Cc: netdev, mlindner, stephen
From: Stanislaw Gruszka <stf_xl@wp.pl>
Date: Sat, 25 Jan 2014 11:34:54 +0100
> There is race condition when call netif_napi_add() after
> register_netdevice(), as ->open() can be called without napi initialized
> and trigger BUG_ON() on napi_enable(), like on below messages:
...
> To fix the problem patch changes the order of initialization.
>
> Bug report:
> https://bugzilla.kernel.org/show_bug.cgi?id=67151
>
> Reported-and-tested-by: ebrahim.azarisooreh@gmail.com
> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Applied, thanks a lot.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-28 0:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-25 10:34 [PATCH] sky2: initialize napi before registering device Stanislaw Gruszka
2014-01-26 1:01 ` Stephen Hemminger
2014-01-27 11:53 ` Stanislaw Gruszka
2014-01-28 0:40 ` David Miller
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).