mac802154: fix atomic_dec_and_test checks
authorAlexander Aring <aahringo@redhat.com>
Mon, 13 Jun 2022 04:37:35 +0000 (00:37 -0400)
committerStefan Schmidt <stefan@datenfreihafen.org>
Tue, 14 Jun 2022 08:23:51 +0000 (10:23 +0200)
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")
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20220613043735.1039895-3-aahringo@redhat.com
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
net/mac802154/tx.c
net/mac802154/util.c

index 5b471e9322713c02c0b2c2f621fbe2e88a323a07..8ddcd2e841cabe145794e026b09aaf34d269f0e8 100644 (file)
@@ -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);
index 60f6c0f10641bb65ff5023a7922af9b94be349ad..f08605f59b609a548512cabaf6b845f86235bd8d 100644 (file)
@@ -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);