Skip to contentSkip to conversation

bnxt_en: fix module unload sequence

PATCH Applied Vadim Fedorenko 5 participants 5 messages Apr 30, 2025 – May 1, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bnxt_en: fix module unload sequence

Recent updates to the PTP part of bnxt changed the way PTP FIFO is cleared, skbs waiting for TX timestamps are now cleared during ndo_close() call. To do clearing procedure, the ptp structure must exist and point to a valid address. Module destroy sequence had ptp clear code running before netdev close causing invalid memory access and kernel crash. Change the sequence to destroy ptp structure after device close.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
index 78e496b0ec26..86a5de44b6f3 100644
@@ -16006,8 +16006,8 @@ static void bnxt_remove_one(struct pci_dev *pdev)
 
 	bnxt_rdma_aux_device_del(bp);
 
-	bnxt_ptp_clear(bp);
 	unregister_netdev(dev);
+	bnxt_ptp_clear(bp);
 
 	bnxt_rdma_aux_device_uninit(bp);
 
Signature · 1 line
2.47.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines

-----Original Message-----
From: Vadim Fedorenko <[email protected]>
Sent: Wednesday, April 30, 2025 10:04 AM
To: Vadim Fedorenko <[email protected]>; Michael Chan <[email protected]>; Pavan Chebbi <[email protected]>; Jakub Kicinski <[email protected]>
Cc: Richard Cochran <[email protected]>; Taehee Yoo <[email protected]>; [email protected]
Subject: [PATCH net] bnxt_en: fix module unload sequence

Recent updates to the PTP part of bnxt changed the way PTP FIFO is cleared, skbs waiting for TX timestamps are now cleared during ndo_close() call. To do clearing procedure, the ptp structure must exist and point to a valid address. Module destroy sequence had ptp clear code running before netdev close causing invalid memory access and kernel crash. Change the sequence to destroy ptp structure after device close.

Quoted 6 lines
Fixes 8f7ae5a85137 ("bnxt_en: improve TX timestamping FIFO configuration")

[email protected]/

---

Quoted 21 lines
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -2
index 78e496b0ec26..86a5de44b6f3 100644
@@ -16006,8 +16006,8 @@ static void bnxt_remove_one(struct pci_dev *pdev)
 
 	bnxt_rdma_aux_device_del(bp);
 
-	bnxt_ptp_clear(bp);
 	unregister_netdev(dev);
+	bnxt_ptp_clear(bp);
 
 	bnxt_rdma_aux_device_uninit(bp);
 
--

2.47.1

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Vadim Fedorenko
Quoted 9 lines · Vadim Fedorenko

Recent updates to the PTP part of bnxt changed the way PTP FIFO is cleared, skbs waiting for TX timestamps are now cleared during ndo_close() call. To do clearing procedure, the ptp structure must exist and point to a valid address. Module destroy sequence had ptp clear code running before netdev close causing invalid memory access and kernel crash. Change the sequence to destroy ptp structure after device close.

Quoted 4 lines

The PTP destroy sequence is now consistent with bnxt_shutdown() and bnxt_suspend(). Thanks.

Tested-by on v1 1/1
#3 lore raw
In reply to Vadim Fedorenko
Quoted 9 lines · Vadim Fedorenko

Recent updates to the PTP part of bnxt changed the way PTP FIFO is cleared, skbs waiting for TX timestamps are now cleared during ndo_close() call. To do clearing procedure, the ptp structure must exist and point to a valid address. Module destroy sequence had ptp clear code running before netdev close causing invalid memory access and kernel crash. Change the sequence to destroy ptp structure after device close.

Quoted 4 lines
Quoted 21 lines
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -2
index 78e496b0ec26..86a5de44b6f3 100644
@@ -16006,8 +16006,8 @@ static void bnxt_remove_one(struct pci_dev *pdev)
 
        bnxt_rdma_aux_device_del(bp);
 
-       bnxt_ptp_clear(bp);
        unregister_netdev(dev);
+       bnxt_ptp_clear(bp);
 
        bnxt_rdma_aux_device_uninit(bp);
 
--

2.47.1

#4 lore raw
In reply to Vadim Fedorenko
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 30 Apr 2025 10:03:43 -0700 you wrote:

Recent updates to the PTP part of bnxt changed the way PTP FIFO is cleared, skbs waiting for TX timestamps are now cleared during ndo_close() call. To do clearing procedure, the ptp structure must exist and point to a valid address. Module destroy sequence had ptp clear code running before netdev close causing invalid memory access and kernel crash. Change the sequence to destroy ptp structure after device close.

[...]

Here is the summary with links:
- [net] bnxt_en: fix module unload sequence

    https://git.kernel.org/netdev/net/c/927069d5c40c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html