netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bnxt_en: fix atomic counter for ptp packets
@ 2024-06-04  9:19 Vadim Fedorenko
  2024-06-05 17:35 ` Simon Horman
  2024-06-05 21:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2024-06-04  9:19 UTC (permalink / raw)
  To: Vadim Fedorenko, Michael Chan, Jakub Kicinski
  Cc: David S. Miller, Paolo Abeni, Richard Cochran, netdev,
	Vadim Fedorenko, Simon Horman

atomic_dec_if_positive returns new value regardless if it is updated or
not. The commit in fixes changed the behavior of the condition to one
that differs from original code. Restore original condition to properly
maintain atomic counter.

Fixes: 165f87691a89 ("bnxt_en: add timestamping statistics support")
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 6d9faa78e391..7dc00c0d8992 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -513,7 +513,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
 		struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
 
 		if (ptp && ptp->tx_tstamp_en && !skb_is_gso(skb)) {
-			if (!atomic_dec_if_positive(&ptp->tx_avail)) {
+			if (atomic_dec_if_positive(&ptp->tx_avail) < 0) {
 				atomic64_inc(&ptp->stats.ts_err);
 				goto tx_no_ts;
 			}
-- 
2.43.0


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

end of thread, other threads:[~2024-06-05 21:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04  9:19 [PATCH net-next] bnxt_en: fix atomic counter for ptp packets Vadim Fedorenko
2024-06-05 17:35 ` Simon Horman
2024-06-05 21:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).