Skip to content

Commit

Permalink
net: xilinx: axiethernet: Fix kernel bug in ndo_open
Browse files Browse the repository at this point in the history
In USXGMII configuration, if block lock/auto-negotiation is not completed
we return -ENODEV from ndo_open without proper cleanup. As a result napi
context is still enabled and on subsequent ifconfig up we hit napi_enable
BUG_ON condition. To fix it add proper cleanup.

[  769.771340] ------------[ cut here ]------------
[  769.775965] kernel BUG at /kernel-source//include/linux/netdevice.h:502!
[  769.782661] Internal error: Oops - BUG: 0 [#1] SMP
[  769.787440] Modules linked in: uio_pdrv_genirq
[  769.791880] CPU: 1 PID: 2212 Comm: ifconfig Not tainted 4.14.0-xilinx-v2018.3 #14
[  769.799351] Hardware name: xlnx,zynqmp (DT)
[  769.803525] task: ffffffc87b25e280 task.stack: ffffff800c0a0000
[  769.809444] PC is at axienet_open+0x164/0x6d0
[  769.813795] LR is at axienet_open+0x15c/0x6d0
[  769.818142] pc : [<ffffff8008636ff4>] lr : [<ffffff8008636fec>] pstate: 80000145
[  769.825530] sp : ffffff800c0a3bf0
[  769.828834] x29: ffffff800c0a3bf0 x28: ffffff800863a1e0
[  769.834139] x27: 0000000000000000 x26: ffffffc87b3d7538
[  769.839442] x25: 0000000000000043 x24: 0000000000000000
[  769.844746] x23: ffffffc87b3d7538 x22: ffffffc87b3d6830
[  769.850049] x21: ffffffc87b3d6ab0 x20: ffffffc87b3d6800
[  769.855353] x19: ffffffc87b3d6000 x18: ffffffc87ff92460
[  769.860656] x17: 0000007f9f71def0 x16: 0000000000000001
[  769.865960] x15: ffffff8008e18000 x14: 0000000000000000
[  769.871263] x13: ffffffc87ff92400 x12: 000000b339f1c013
[  769.876567] x11: 0000000000000003 x10: 0000000000000880
[  769.881871] x9 : ffffff800c0a3a50 x8 : ffffffc87b25eb60
[  769.887174] x7 : ffffff800b210000 x6 : 0000000000000032
[  769.892477] x5 : 0000000000000000 x4 : ffffff8008e5f930
[  769.897781] x3 : 00000000ffff3051 x2 : ffffffc87987e400
[  769.903084] x1 : ffffff800863a1e0 x0 : 0000000000000010
[  769.908389] Process ifconfig (pid: 2212, stack limit = 0xffffff800c0a0000)
[  769.915255] Call trace:
<snip>
[  770.007206] [<ffffff8008636ff4>] axienet_open+0x164/0x6d0
[  770.012598] [<ffffff8008832a80>] __dev_open+0xc8/0x140
[  770.017726] [<ffffff8008832e18>] __dev_change_flags+0x130/0x170
[  770.023637] [<ffffff8008832e78>] dev_change_flags+0x20/0x60
[  770.029203] [<ffffff80088aa2d0>] devinet_ioctl+0x748/0x810
[  770.034678] [<ffffff80088ac3e4>] inet_ioctl+0x104/0x118
[  770.039896] [<ffffff80088105c0>] sock_do_ioctl.constprop.18+0x20/0x60
[  770.046326] [<ffffff8008810db4>] sock_ioctl+0x1e4/0x348
[  770.051545] [<ffffff80081af764>] do_vfs_ioctl+0xa4/0x7d8
[  770.056846] [<ffffff80081afedc>] SyS_ioctl+0x44/0x80

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Acked-by: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
  • Loading branch information
radheyxilinx authored and Michal Simek committed Jul 30, 2019
1 parent 7e50ebf commit e7ac0a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/xilinx/xilinx_axienet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,8 @@ static int axienet_open(struct net_device *ndev)
if (err) {
netdev_err(ndev, "%s: USXGMII Block lock bit not set",
__func__);
return -ENODEV;
ret = -ENODEV;
goto err_eth_irq;
}

err = readl_poll_timeout(lp->regs + XXV_USXGMII_AN_STS_OFFSET,
Expand All @@ -1696,7 +1697,8 @@ static int axienet_open(struct net_device *ndev)
if (err) {
netdev_err(ndev, "%s: USXGMII AN not complete",
__func__);
return -ENODEV;
ret = -ENODEV;
goto err_eth_irq;
}

netdev_info(ndev, "USXGMII setup at %d\n", lp->usxgmii_rate);
Expand Down

0 comments on commit e7ac0a0

Please sign in to comment.