All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: watchdog: hold device global xmit lock during tx disable
@ 2021-02-06  1:37 Edwin Peer
  2021-02-08 20:01 ` Jakub Kicinski
  2021-02-09  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Edwin Peer @ 2021-02-06  1:37 UTC (permalink / raw)
  To: netdev
  Cc: Edwin Peer, David S . Miller, Jakub Kicinski, Andrew Gospodarek,
	Michael Chan

[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]

Prevent netif_tx_disable() running concurrently with dev_watchdog() by
taking the device global xmit lock. Otherwise, the recommended:

	netif_carrier_off(dev);
	netif_tx_disable(dev);

driver shutdown sequence can happen after the watchdog has already
checked carrier, resulting in possible false alarms. This is because
netif_tx_lock() only sets the frozen bit without maintaining the locks
on the individual queues.

Fixes: c3f26a269c24 ("netdev: Fix lockdep warnings in multiqueue configurations.")
Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>
---
 include/linux/netdevice.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 259be67644e3..5ff27c12ce68 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4352,6 +4352,7 @@ static inline void netif_tx_disable(struct net_device *dev)
 
 	local_bh_disable();
 	cpu = smp_processor_id();
+	spin_lock(&dev->tx_global_lock);
 	for (i = 0; i < dev->num_tx_queues; i++) {
 		struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
 
@@ -4359,6 +4360,7 @@ static inline void netif_tx_disable(struct net_device *dev)
 		netif_tx_stop_queue(txq);
 		__netif_tx_unlock(txq);
 	}
+	spin_unlock(&dev->tx_global_lock);
 	local_bh_enable();
 }
 
-- 
2.30.0


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4160 bytes --]

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

* Re: [PATCH net] net: watchdog: hold device global xmit lock during tx disable
  2021-02-06  1:37 [PATCH net] net: watchdog: hold device global xmit lock during tx disable Edwin Peer
@ 2021-02-08 20:01 ` Jakub Kicinski
  2021-02-09  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2021-02-08 20:01 UTC (permalink / raw)
  To: Edwin Peer; +Cc: netdev, David S . Miller, Andrew Gospodarek, Michael Chan

On Fri,  5 Feb 2021 17:37:32 -0800 Edwin Peer wrote:
> Prevent netif_tx_disable() running concurrently with dev_watchdog() by
> taking the device global xmit lock. Otherwise, the recommended:
> 
> 	netif_carrier_off(dev);
> 	netif_tx_disable(dev);
> 
> driver shutdown sequence can happen after the watchdog has already
> checked carrier, resulting in possible false alarms. This is because
> netif_tx_lock() only sets the frozen bit without maintaining the locks
> on the individual queues.
> 
> Fixes: c3f26a269c24 ("netdev: Fix lockdep warnings in multiqueue configurations.")
> Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>

Reviewed-by: Jakub Kicinski <kuba@kernel.org>

Even though using the dev->tx_global_lock as a barrier is not very
clean in itself the thinking is that this restores previous semantics
with deeper changes.

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

* Re: [PATCH net] net: watchdog: hold device global xmit lock during tx disable
  2021-02-06  1:37 [PATCH net] net: watchdog: hold device global xmit lock during tx disable Edwin Peer
  2021-02-08 20:01 ` Jakub Kicinski
@ 2021-02-09  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-02-09  0:30 UTC (permalink / raw)
  To: Edwin Peer; +Cc: netdev, davem, kuba, andrew.gospodarek, michael.chan

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Fri,  5 Feb 2021 17:37:32 -0800 you wrote:
> Prevent netif_tx_disable() running concurrently with dev_watchdog() by
> taking the device global xmit lock. Otherwise, the recommended:
> 
> 	netif_carrier_off(dev);
> 	netif_tx_disable(dev);
> 
> driver shutdown sequence can happen after the watchdog has already
> checked carrier, resulting in possible false alarms. This is because
> netif_tx_lock() only sets the frozen bit without maintaining the locks
> on the individual queues.
> 
> [...]

Here is the summary with links:
  - [net] net: watchdog: hold device global xmit lock during tx disable
    https://git.kernel.org/netdev/net/c/3aa6bce9af0e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-02-09  0:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06  1:37 [PATCH net] net: watchdog: hold device global xmit lock during tx disable Edwin Peer
2021-02-08 20:01 ` Jakub Kicinski
2021-02-09  0:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.