From: Arnaud Bonnet <abo@medichon.fr>
To: marcel@holtmann.org, luiz.dentz@gmail.com,
matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com
Cc: linux-bluetooth@vger.kernel.org,
linux-mediatek@lists.infradead.org, skhan@linuxfoundation.org,
jkoolstra@xs4all.nl, Arnaud Bonnet <abo@medichon.fr>
Subject: [PATCH v2] Bluetooth: btmtk: remove redundant memory barrier with helper
Date: Fri, 23 Oct 2026 11:36:45 +0200 [thread overview]
Message-ID: <20261023093645.4669-1-abo@medichon.fr> (raw)
The test_and_clear_bit() call works as a full memory barrier, thus it is
not required to emit a barrier using smp_mb__after_atomic() before
wake_up_bit().
Replace the whole sequences with test_and_clear_wake_up_bit(), which was
introduced later in commit 52d633def56c ("sched: Add
test_and_clear_wake_up_bit() and atomic_dec_and_wake_up()") as a wrapper
for the correct sequence.
Signed-off-by: Arnaud Bonnet <abo@medichon.fr>
---
Tested by building and manually checking generated assembly on x86, arm64
and riscv64.
Changes since v1:
* perform the cleanup in btmtksdio.c and btmtkuart.c as well
drivers/bluetooth/btmtk.c | 8 +-------
drivers/bluetooth/btmtksdio.c | 8 ++------
drivers/bluetooth/btmtkuart.c | 8 ++------
3 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 75483d8230e1..a620e24b6c17 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -607,13 +607,7 @@ static void btmtk_usb_wmt_recv(struct urb *urb)
return;
}
- if (test_and_clear_bit(BTMTK_TX_WAIT_VND_EVT,
- &data->flags)) {
- /* Barrier to sync with other CPUs */
- smp_mb__after_atomic();
- wake_up_bit(&data->flags,
- BTMTK_TX_WAIT_VND_EVT);
- }
+ test_and_clear_wake_up_bit(BTMTK_TX_WAIT_VND_EVT, &data->flags);
kfree(urb->setup_packet);
return;
} else if (urb->status == -ENOENT) {
diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index b9563df72983..b6e16716b169 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -442,12 +442,8 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
goto err_free_skb;
if (evt == HCI_EV_WMT) {
- if (test_and_clear_bit(BTMTKSDIO_TX_WAIT_VND_EVT,
- &bdev->tx_state)) {
- /* Barrier to sync with other CPUs */
- smp_mb__after_atomic();
- wake_up_bit(&bdev->tx_state, BTMTKSDIO_TX_WAIT_VND_EVT);
- }
+ test_and_clear_wake_up_bit(BTMTKSDIO_TX_WAIT_VND_EVT,
+ &bdev->tx_state);
}
return 0;
diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c
index 4af6fbbbd302..744a87acaadc 100644
--- a/drivers/bluetooth/btmtkuart.c
+++ b/drivers/bluetooth/btmtkuart.c
@@ -229,12 +229,8 @@ static int btmtkuart_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
goto err_free_skb;
if (hdr->evt == HCI_EV_WMT) {
- if (test_and_clear_bit(BTMTKUART_TX_WAIT_VND_EVT,
- &bdev->tx_state)) {
- /* Barrier to sync with other CPUs */
- smp_mb__after_atomic();
- wake_up_bit(&bdev->tx_state, BTMTKUART_TX_WAIT_VND_EVT);
- }
+ test_and_clear_wake_up_bit(BTMTKUART_TX_WAIT_VND_EVT,
+ &bdev->tx_state);
}
return 0;
--
2.53.0
next reply other threads:[~2026-10-23 9:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 9:36 Arnaud Bonnet [this message]
2026-10-23 21:00 ` [PATCH v2] Bluetooth: btmtk: remove redundant memory barrier with helper patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261023093645.4669-1-abo@medichon.fr \
--to=abo@medichon.fr \
--cc=angelogioacchino.delregno@collabora.com \
--cc=jkoolstra@xs4all.nl \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=matthias.bgg@gmail.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox