* [PATCH v2] Bluetooth: btmtk: remove redundant memory barrier with helper
@ 2026-10-23 9:36 Arnaud Bonnet
2026-10-23 21:00 ` patchwork-bot+bluetooth
0 siblings, 1 reply; 2+ messages in thread
From: Arnaud Bonnet @ 2026-10-23 9:36 UTC (permalink / raw)
To: marcel, luiz.dentz, matthias.bgg, angelogioacchino.delregno
Cc: linux-bluetooth, linux-mediatek, skhan, jkoolstra, Arnaud Bonnet
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Bluetooth: btmtk: remove redundant memory barrier with helper
2026-10-23 9:36 [PATCH v2] Bluetooth: btmtk: remove redundant memory barrier with helper Arnaud Bonnet
@ 2026-10-23 21:00 ` patchwork-bot+bluetooth
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2026-10-23 21:00 UTC (permalink / raw)
To: Arnaud Bonnet
Cc: marcel, luiz.dentz, matthias.bgg, angelogioacchino.delregno,
linux-bluetooth, linux-mediatek, skhan, jkoolstra
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Fri, 23 Oct 2026 11:36:45 +0200 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [v2] Bluetooth: btmtk: remove redundant memory barrier with helper
https://git.kernel.org/bluetooth/bluetooth-next/c/ebb8ee296578
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-23 21:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23 9:36 [PATCH v2] Bluetooth: btmtk: remove redundant memory barrier with helper Arnaud Bonnet
2026-10-23 21:00 ` patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox