Skip to contentSkip to conversation

mac802154: atomic_dec_and_test() fixes

PATCH In review Alexander Aring 3 participants 8 messages Jun 13, 2022 – Jun 15, 2022

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

v2 cover mac802154: atomic_dec_and_test() fixes

Hi,

I was wondering why nothing worked anymore. I found it...

changes since v2:

- fix fixes tags in mac802154: util: fix release queue handling
- add patch mac802154: fix atomic_dec_and_test checks got somehow confused 2 patch same issue

Alexander Aring (2):
mac802154: util: fix release queue handling
mac802154: fix atomic_dec_and_test checks

 net/mac802154/tx.c   | 4 ++--
 net/mac802154/util.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/2 mac802154: util: fix release queue handling

The semantic of atomic_dec_and_test() is to return true if zero is reached and we need call ieee802154_wake_queue() when zero is reached.

Fixes 20a19d1df3e4 ("net: mac802154: Bring the ability to hold the transmit queue")
---
 net/mac802154/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac802154/util.c +1 -1
index 60eb7bd3bfc1..60f6c0f10641 100644
@@ -79,7 +79,7 @@ void ieee802154_release_queue(struct ieee802154_local *local)
 	unsigned long flags;
 
 	spin_lock_irqsave(&local->phy->queue_lock, flags);
-	if (!atomic_dec_and_test(&local->phy->hold_txs))
+	if (atomic_dec_and_test(&local->phy->hold_txs))
 		ieee802154_wake_queue(&local->hw);
 	spin_unlock_irqrestore(&local->phy->queue_lock, flags);
 }
Signature · 1 line
2.31.1
#2 lore raw

PATCH v2 2/2 mac802154: fix atomic_dec_and_test checks

In reply to Alexander Aring

We need to call wake_up() when hold_txs reaches zero. The semantic of atomic_dec_and_test() is that it returns true when it's zero.

Fixes f0feb3490473 ("net: mac802154: Introduce a tx queue flushing mechanism")
---
 net/mac802154/tx.c   | 4 ++--
 net/mac802154/util.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
net/mac802154/tx.c +2 -2
index 5b471e932271..8ddcd2e841ca 100644
@@ -44,7 +44,7 @@ void ieee802154_xmit_sync_worker(struct work_struct *work)
 err_tx:
 	/* Restart the netif queue on each sub_if_data object. */
 	ieee802154_release_queue(local);
-	if (!atomic_dec_and_test(&local->phy->ongoing_txs))
+	if (atomic_dec_and_test(&local->phy->ongoing_txs))
 		wake_up(&local->phy->sync_txq);
 	kfree_skb(skb);
 	netdev_dbg(dev, "transmission failed\n");
@@ -101,7 +101,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
 
 err_wake_netif_queue:
 	ieee802154_release_queue(local);
-	if (!atomic_dec_and_test(&local->phy->ongoing_txs))
+	if (atomic_dec_and_test(&local->phy->ongoing_txs))
 		wake_up(&local->phy->sync_txq);
 err_free_skb:
 	kfree_skb(skb);
net/mac802154/util.c +2 -2
index 60f6c0f10641..f08605f59b60 100644
@@ -141,7 +141,7 @@ void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
 	}
 
 	dev_consume_skb_any(skb);
-	if (!atomic_dec_and_test(&hw->phy->ongoing_txs))
+	if (atomic_dec_and_test(&hw->phy->ongoing_txs))
 		wake_up(&hw->phy->sync_txq);
 }
 EXPORT_SYMBOL(ieee802154_xmit_complete);
@@ -154,7 +154,7 @@ void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb,
 	local->tx_result = reason;
 	ieee802154_release_queue(local);
 	dev_kfree_skb_any(skb);
-	if (!atomic_dec_and_test(&hw->phy->ongoing_txs))
+	if (atomic_dec_and_test(&hw->phy->ongoing_txs))
 		wake_up(&hw->phy->sync_txq);
 }
 EXPORT_SYMBOL(ieee802154_xmit_error);
Signature · 1 line
2.31.1
maintainer Reviewed-by on the v2 series
#3 lore raw
In reply to Alexander Aring

Hi Alex,

[email protected] wrote on Mon, 13 Jun 2022 00:37:33 -0400:

Quoted 9 lines

Hi,

I was wondering why nothing worked anymore. I found it...

changes since v2:

- fix fixes tags in mac802154: util: fix release queue handling
- add patch mac802154: fix atomic_dec_and_test checks got somehow confused 2 patch same issue

I've got initially confused with your patchset but yes indeed the API works the opposite way compared to my gut understanding.

We bought hardware and I am currently setting up a real network to hopefully track these regressions myself in the future.

For these two patches:

Quoted 9 lines

Alexander Aring (2):
mac802154: util: fix release queue handling
mac802154: fix atomic_dec_and_test checks

 net/mac802154/tx.c   | 4 ++--
 net/mac802154/util.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

Thanks,
Miquèl

#4 lore raw

Hi,

Quoted 9 lines · Miquel Raynal

Hi Alex,

[email protected] wrote on Mon, 13 Jun 2022 00:37:33 -0400:

Quoted 4 lines

Hi,

I was wondering why nothing worked anymore. I found it...

Quoted 9 lines
Quoted 5 lines

changes since v2:

- fix fixes tags in mac802154: util: fix release queue handling
- add patch mac802154: fix atomic_dec_and_test checks got somehow confused 2 patch same issue

I've got initially confused with your patchset but yes indeed the API works the opposite way compared to my gut understanding.

not the first time I am seeing this, I fixed similar issues already at other places.

btw I told you the right semantic at [0] ....

Quoted 3 lines

We bought hardware and I am currently setting up a real network to hopefully track these regressions myself in the future.

I wonder why you don't use hwsim... and you already mentioned hwsim to me. You can simply make a 6lowpan interface on it and ping it - no hardware needed and this would already show issues... Now you can say, why I do not test it... maybe I do next time but review takes longer then.

- Alex

[0] https://lore.kernel.org/linux-wpan/CAK-6q+jCYDQ-rtyawz1m2Yt+ti=3d6PrhZebB=-PjcX-6L-Kdg@mail.gmail.com/

maintainer
#5 lore raw

Hi Alex,

[email protected] wrote on Tue, 14 Jun 2022 22:53:19 -0400:

Quoted 19 lines

Hi,

Quoted 15 lines · Miquel Raynal

Hi Alex,

[email protected] wrote on Mon, 13 Jun 2022 00:37:33 -0400:

Quoted 9 lines

Hi,

I was wondering why nothing worked anymore. I found it...

changes since v2:

- fix fixes tags in mac802154: util: fix release queue handling
- add patch mac802154: fix atomic_dec_and_test checks got somehow confused 2 patch same issue

Quoted 8 lines
Quoted 3 lines

I've got initially confused with your patchset but yes indeed the API works the opposite way compared to my gut understanding.

not the first time I am seeing this, I fixed similar issues already at other places.

btw I told you the right semantic at [0] ....

I focused on the if statement more than the actual syntax...

Quoted 7 lines
Quoted 4 lines

We bought hardware and I am currently setting up a real network to hopefully track these regressions myself in the future.

I wonder why you don't use hwsim... and you already mentioned hwsim to me.

I do use hwsim but I was exclusively testing the mlme ops with it.

Quoted 2 lines

You can simply make a 6lowpan interface on it and ping it - no hardware needed and this would already show issues...

Actually I just learnt about how to create 6lowpan interfaces and do basic data exchanges, it's rather easy and straightforward, but I must admit I was not familiar at all with this area and thought it would be more complex... Indeed, hwsim would work just fine for this purpose, I will add this to my checklist.

Quoted 3 lines

Now you can say,
why I do not test it... maybe I do next time but review takes longer then.

I'm not saying this at all :) It is my duty, not yours, reviews and feedback are more than enough.

Quoted 4 lines

- Alex

[0] https://lore.kernel.org/linux-wpan/CAK-6q+jCYDQ-rtyawz1m2Yt+ti=3d6PrhZebB=-PjcX-6L-Kdg@mail.gmail.com/

Thanks,
Miquèl

maintainer
#6 lore raw

[email protected] wrote on Wed, 15 Jun 2022 09:25:58 +0200:

Quoted 53 lines

Hi Alex,

[email protected] wrote on Tue, 14 Jun 2022 22:53:19 -0400:

Quoted 19 lines

Hi,

Quoted 15 lines · Miquel Raynal

Hi Alex,

[email protected] wrote on Mon, 13 Jun 2022 00:37:33 -0400:

Quoted 9 lines

Hi,

I was wondering why nothing worked anymore. I found it...

changes since v2:

- fix fixes tags in mac802154: util: fix release queue handling
- add patch mac802154: fix atomic_dec_and_test checks got somehow confused 2 patch same issue

Quoted 8 lines
Quoted 3 lines

I've got initially confused with your patchset but yes indeed the API works the opposite way compared to my gut understanding.

not the first time I am seeing this, I fixed similar issues already at other places.

btw I told you the right semantic at [0] ....

I focused on the if statement more than the actual syntax...

Quoted 7 lines
Quoted 4 lines

We bought hardware and I am currently setting up a real network to hopefully track these regressions myself in the future.

I wonder why you don't use hwsim... and you already mentioned hwsim to me.

I do use hwsim but I was exclusively testing the mlme ops with it.

Quoted 2 lines

You can simply make a 6lowpan interface on it and ping it - no hardware needed and this would already show issues...

Actually I just learnt about how to create 6lowpan interfaces and do basic data exchanges, it's rather easy and straightforward, but I must admit I was not familiar at all with this area and thought it would be more complex... Indeed, hwsim would work just fine for this purpose, I will add this to my checklist.

Quoted 6 lines
Quoted 3 lines

Now you can say,
why I do not test it... maybe I do next time but review takes longer then.

I'm not saying this at all :) It is my duty, not yours, reviews and feedback are more than enough.

Ok 6lowpan is _really_ well integrated, apologies for not taking the time to use it before.

BTW I see all around the internet that ping6 produces this warning:

ping6: Warning: source address might be selected on device other than: lowpan0

At a first glance I could not find an explanation, do you also have it on your side? Do you know what it means?

Thanks,
Miquèl

maintainer
#7 lore raw
In reply to Alexander Aring

Hello.

Quoted 10 lines · Alexander Aring

Hi,

I was wondering why nothing worked anymore. I found it...

changes since v2:

- fix fixes tags in mac802154: util: fix release queue handling
- add patch mac802154: fix atomic_dec_and_test checks got somehow confused 2 patch same issue

Quoted 7 lines

Alexander Aring (2):
mac802154: util: fix release queue handling
mac802154: fix atomic_dec_and_test checks

  net/mac802154/tx.c   | 4 ++--
  net/mac802154/util.c | 6 +++---
  2 files changed, 5 insertions(+), 5 deletions(-)

These patches have been applied to the wpan-next tree and will be part of the next pull request to net-next. Thanks!

regards
Stefan Schmidt