Subject: AW: [PATCH net] dpaa2-eth: unregister the netdev before disconnecting from the PHY

From: "Richter, Rafael" <[email-masked]>
Date: Wed, 9 Feb 2022 18:43:45 +0000

Hi Ioana!

I've been testing this patch. However, I'm still facing the same kernel panic during shutdown if a SGMII interface was activated before.

Here is the stack trace:

[   96.923647] systemd-shutdown[1]: Rebooting.
[   97.461827] fsl-mc dpbp.9: Removing from iommu group 7
[   97.838899] fsl-mc dpbp.8: Removing from iommu group 7
[   98.206385] fsl-mc dpbp.7: Removing from iommu group 7
[   98.554855] fsl-mc dpbp.6: Removing from iommu group 7
[   98.815498] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
[   98.816624] Mem abort info:
[   98.816981]   ESR = 0x86000004
[   98.817371]   EC = 0x21: IABT (current EL), IL = 32 bits
[   98.818046]   SET = 0, FnV = 0
[   98.818436]   EA = 0, S1PTW = 0
[   98.818837]   FSC = 0x04: level 0 translation fault
[   98.819456] user pgtable: 4k pages, 48-bit VAs, pgdp=00000020835d7000
[   98.820273] [0000000000000000] pgd=0000000000000000, p4d=0000000000000000
[   98.821140] Internal error: Oops: 86000004 [#1] PREEMPT SMP
[   98.821848] Modules linked in:
[   98.822241] CPU: 15 PID: 0 Comm: swapper/15 Not tainted 5.17.0-rc2-00212-g3bed06e36994-dirty #1
[   98.823345] Hardware name: mpxlx2160a-gl6 (DT)
[   98.823909] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   98.824794] pc : 0x0
[   98.825077] lr : call_timer_fn.constprop.0+0x20/0x80
[   98.825717] sp : ffff80000943ba40
[   98.826139] x29: ffff80000943ba40 x28: 0000000000000000 x27: ffff80000943bad0
[   98.827052] x26: ffff0020002ff140 x25: ffff800008ee6980 x24: ffff00267c19fd28
[   98.827963] x23: ffff80000943bad0 x22: 0000000000000000 x21: 0000000000000101
[   98.828873] x20: ffff0020002ff140 x19: 0000000000000000 x18: fffffc0080035a48
[   98.829783] x17: ffff8026733ae000 x16: ffff80000807c000 x15: 0000000000004000
[   98.830693] x14: 00000000000003d0 x13: 0000000000000000 x12: 00000000000001e2
[   98.831602] x11: 00000000000003a6 x10: ffff8026733ae000 x9 : ffff00267c19fd70
[   98.832511] x8 : 0000000000000001 x7 : ffffffffffffffff x6 : 0000000000000000
[   98.833420] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000200
[   98.834329] x2 : 0000000000000200 x1 : 0000000000000000 x0 : ffff0020030872b0
[   98.835239] Call trace:
[   98.835552]  0x0
[   98.835790]  __run_timers.part.0+0x1e8/0x220
[   98.836338]  run_timer_softirq+0x38/0x70
[   98.836840]  _stext+0x124/0x29c
[   98.837244]  __irq_exit_rcu+0xdc/0xfc
[   98.837716]  irq_exit_rcu+0xc/0x14
[   98.838153]  el1_interrupt+0x34/0x80
[   98.838617]  el1h_64_irq_handler+0x14/0x1c
[   98.839140]  el1h_64_irq+0x78/0x7c
[   98.839575]  cpuidle_enter_state+0x12c/0x314
[   98.840121]  cpuidle_enter+0x34/0x4c
[   98.840577]  do_idle+0x1f0/0x254
[   98.840994]  cpu_startup_entry+0x20/0x70
[   98.841497]  secondary_start_kernel+0x13c/0x160
[   98.842076]  __secondary_switched+0x54/0x58
[   98.842618] Code: bad PC value
[   98.843010] ---[ end trace 0000000000000000 ]---
[   98.843597] Kernel panic - not syncing: Oops: Fatal exception in interrupt
[   98.844479] Kernel Offset: disabled
[   98.844922] CPU features: 0x10,00000042,40000842
[   98.845510] Memory Limit: none
[   98.845901] ---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]---

BR,

Rafael Richter
________________________________________
Von: Ioana Ciornei <[email-masked]>
Gesendet: Mittwoch, 9. Februar 2022 16:57
An: [email-masked]; [email-masked]; [email-masked]
Cc: Richter, Rafael; Klauer, Daniel; Robert-Ionut Alexa; Ioana Ciornei
Betreff: [PATCH net] dpaa2-eth: unregister the netdev before disconnecting from the PHY

From: Robert-Ionut Alexa <[email-masked]>

The netdev should be unregistered before we are disconnecting from the
MAC/PHY so that the dev_close callback is called and the PHY and the
phylink workqueues are actually stopped before we are disconnecting and
destroying the phylink instance.

Fixes: 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")
Signed-off-by: Robert-Ionut Alexa <[email-masked]>
Signed-off-by: Ioana Ciornei <[email-masked]>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index e985ae008a97..dd9385d15f6b 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -4523,12 +4523,12 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
 #ifdef CONFIG_DEBUG_FS
        dpaa2_dbg_remove(priv);
 #endif
+
+       unregister_netdev(net_dev);
        rtnl_lock();
        dpaa2_eth_disconnect_mac(priv);
        rtnl_unlock();

-       unregister_netdev(net_dev);
-
        dpaa2_eth_dl_port_del(priv);
        dpaa2_eth_dl_traps_unregister(priv);
        dpaa2_eth_dl_free(priv);
--
2.33.1