mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net: macb: detach netdev before closing on shutdown
@ 2026-09-01 14:25 Vineeth Karumanchi
  2026-09-05  1:44 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Vineeth Karumanchi @ 2026-09-01 14:25 UTC (permalink / raw)
  To: theo.lebrun, conor.dooley, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: vineeth.karumanchi, git, netdev, linux-kernel

macb_shutdown() calls netif_device_detach() after dev_close().
netif_device_detach() only stops the TX queues when the device is
still running:

	if (test_and_clear_bit(__LINK_STATE_PRESENT, &dev->state) &&
	    netif_running(dev))
		netif_tx_stop_all_queues(dev);

By that point dev_close() has already cleared the running state, so the
detach only clears __LINK_STATE_PRESENT and the netif_tx_stop_all_queues()
step is skipped.

Reorder so the device is detached while still running, letting
netif_device_detach() mark it absent and stop the TX queues as intended,
before dev_close() tears the interface down.

This is a cleanup with no functional change: dev_close() stops the queues
and quiesces the DMA/HW via macb_close() regardless of ordering, so the
reboot/kexec safety path is unaffected.

Signed-off-by: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 76ee4f506033..21ebaee00f9e 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -6246,12 +6246,11 @@ static void macb_shutdown(struct platform_device *pdev)
 	struct net_device *netdev = platform_get_drvdata(pdev);
 
 	rtnl_lock();
+	netif_device_detach(netdev);
 
 	if (netif_running(netdev))
 		dev_close(netdev);
 
-	netif_device_detach(netdev);
-
 	rtnl_unlock();
 }
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: macb: detach netdev before closing on shutdown
  2026-09-01 14:25 [PATCH net-next] net: macb: detach netdev before closing on shutdown Vineeth Karumanchi
@ 2026-09-05  1:44 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-09-05  1:44 UTC (permalink / raw)
  To: Vineeth Karumanchi
  Cc: theo.lebrun, conor.dooley, andrew+netdev, davem, edumazet,
	pabeni, git, netdev, linux-kernel

On Tue, 1 Sep 2026 19:55:40 +0530 Vineeth Karumanchi wrote:
> macb_shutdown() calls netif_device_detach() after dev_close().
> netif_device_detach() only stops the TX queues when the device is
> still running:
> 
> 	if (test_and_clear_bit(__LINK_STATE_PRESENT, &dev->state) &&
> 	    netif_running(dev))
> 		netif_tx_stop_all_queues(dev);
> 
> By that point dev_close() has already cleared the running state, so the
> detach only clears __LINK_STATE_PRESENT and the netif_tx_stop_all_queues()
> step is skipped.
> 
> Reorder so the device is detached while still running, letting
> netif_device_detach() mark it absent and stop the TX queues as intended,
> before dev_close() tears the interface down.
> 
> This is a cleanup with no functional change: dev_close() stops the queues
> and quiesces the DMA/HW via macb_close() regardless of ordering, so the
> reboot/kexec safety path is unaffected.

I'd guess the driver is trying to clear PRESENT so that the device
can't be opened again. It's not about stopping queues.
The patches doesn't make sense to me as is. You say yourself that
the move is a nop.

> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 76ee4f506033..21ebaee00f9e 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -6246,12 +6246,11 @@ static void macb_shutdown(struct platform_device *pdev)
>  	struct net_device *netdev = platform_get_drvdata(pdev);
>  
>  	rtnl_lock();
> +	netif_device_detach(netdev);
>  
>  	if (netif_running(netdev))
>  		dev_close(netdev);
>  
> -	netif_device_detach(netdev);
> -
>  	rtnl_unlock();
>  }
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-05  1:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-01 14:25 [PATCH net-next] net: macb: detach netdev before closing on shutdown Vineeth Karumanchi
2026-09-05  1:44 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®