All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: netdev_queue: netdev_txq_completed_mb(): fix wake condition
@ 2024-01-12 16:13 Marc Kleine-Budde
  2024-01-13  2:44 ` Jakub Kicinski
  2024-01-13 18:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2024-01-12 16:13 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Herbert Xu
  Cc: kernel, netdev, linux-kernel, Marc Kleine-Budde

netif_txq_try_stop() uses "get_desc >= start_thrs" as the check for
the call to netif_tx_start_queue().

Use ">=" i netdev_txq_completed_mb(), too.

Fixes: c91c46de6bbc ("net: provide macros for commonly copied lockless queue stop/wake code")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Hello,

I'm currently converting a networking driver with a TX-FIFO depth of
1 (CAN device with lots of errata :/) to the netdev_queue.h helpers
and stumbled over an off-by-one error on __netif_txq_completed_wake().

regards,
Marc
---
 include/net/netdev_queues.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index d68b0a483431..8b8ed4e13d74 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -128,7 +128,7 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
 		netdev_txq_completed_mb(txq, pkts, bytes);		\
 									\
 		_res = -1;						\
-		if (pkts && likely(get_desc > start_thrs)) {		\
+		if (pkts && likely(get_desc >= start_thrs)) {		\
 			_res = 1;					\
 			if (unlikely(netif_tx_queue_stopped(txq)) &&	\
 			    !(down_cond)) {				\

---
base-commit: 907ee6681788556b9ade3ad0a1f6f4aea192399c
change-id: 20240112-netdev_queue-e91686f5fece

Best regards,
-- 
Marc Kleine-Budde <mkl@pengutronix.de>



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

* Re: [PATCH] net: netdev_queue: netdev_txq_completed_mb(): fix wake condition
  2024-01-12 16:13 [PATCH] net: netdev_queue: netdev_txq_completed_mb(): fix wake condition Marc Kleine-Budde
@ 2024-01-13  2:44 ` Jakub Kicinski
  2024-01-13 18:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-01-13  2:44 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Herbert Xu, kernel,
	netdev, linux-kernel

On Fri, 12 Jan 2024 17:13:14 +0100 Marc Kleine-Budde wrote:
> netif_txq_try_stop() uses "get_desc >= start_thrs" as the check for
> the call to netif_tx_start_queue().
> 
> Use ">=" i netdev_txq_completed_mb(), too.
> 
> Fixes: c91c46de6bbc ("net: provide macros for commonly copied lockless queue stop/wake code")
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> I'm currently converting a networking driver with a TX-FIFO depth of
> 1 (CAN device with lots of errata :/) to the netdev_queue.h helpers
> and stumbled over an off-by-one error on __netif_txq_completed_wake().

Makes sense, could be copy'n'paste from one of the drivers this is
based on. A bit unsure if it deserves the Fixes tag and net as we don't
know of any current user that would be suffering. start_thrs == ring size
is a bit of an extreme use case indeed :) Either way:

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

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

* Re: [PATCH] net: netdev_queue: netdev_txq_completed_mb(): fix wake condition
  2024-01-12 16:13 [PATCH] net: netdev_queue: netdev_txq_completed_mb(): fix wake condition Marc Kleine-Budde
  2024-01-13  2:44 ` Jakub Kicinski
@ 2024-01-13 18:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-13 18:30 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: davem, edumazet, kuba, pabeni, herbert, kernel, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Fri, 12 Jan 2024 17:13:14 +0100 you wrote:
> netif_txq_try_stop() uses "get_desc >= start_thrs" as the check for
> the call to netif_tx_start_queue().
> 
> Use ">=" i netdev_txq_completed_mb(), too.
> 
> Fixes: c91c46de6bbc ("net: provide macros for commonly copied lockless queue stop/wake code")
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> [...]

Here is the summary with links:
  - net: netdev_queue: netdev_txq_completed_mb(): fix wake condition
    https://git.kernel.org/netdev/net/c/894d7508316e

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:[~2024-01-13 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12 16:13 [PATCH] net: netdev_queue: netdev_txq_completed_mb(): fix wake condition Marc Kleine-Budde
2024-01-13  2:44 ` Jakub Kicinski
2024-01-13 18: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.