Skip to contentSkip to conversation

bnxt_en: fix atomic counter for ptp packets

PATCH Applied Vadim Fedorenko 3 participants 3 messages Jun 4, 2024 – Jun 5, 2024

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

PATCH 1/1 bnxt_en: fix atomic counter for ptp packets

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")
---
 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 6d9faa78e391..7dc00c0d8992 100644
@@ -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;
 			}
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Vadim Fedorenko

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")
#2 lore raw
In reply to Vadim Fedorenko
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 10 lines · On Tue, 4 Jun 2024 02:19:39 -0700 you wrote:

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")

[...]

Here is the summary with links:
- [net-next] bnxt_en: fix atomic counter for ptp packets

    https://git.kernel.org/netdev/net-next/c/c790275b5edf

You are awesome, thank you!

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