Skip to contentSkip to conversation

Bluetooth: btmtk: remove redundant memory barrier with helper

PATCH Applied Arnaud Bonnet 3 participants 3 messages Oct 23

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

PATCH v2 1/1 Bluetooth: btmtk: remove redundant memory barrier with helper

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.

---
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(-)
drivers/bluetooth/btmtk.c +1 -7
index 75483d8230e1..a620e24b6c17 100644
@@ -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) {
drivers/bluetooth/btmtksdio.c +2 -6
index b9563df72983..b6e16716b169 100644
@@ -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;
drivers/bluetooth/btmtkuart.c +2 -6
index 4af6fbbbd302..744a87acaadc 100644
@@ -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;
Signature · 1 line
2.53.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1191995/

---Test result---

Test Summary:

CheckPatch                    PASS      1.16 seconds
VerifyFixes                   PASS      0.12 seconds
VerifySignedoff               PASS      0.12 seconds
GitLint                       FAIL      0.32 seconds
SubjectPrefix                 PASS      0.37 seconds
BuildKernel                   PASS      28.69 seconds
CheckAllWarning               PASS      32.80 seconds
CheckSparse                   PASS      35.70 seconds
BuildKernel32                 PASS      28.62 seconds
CheckKernelLLVM               PASS      32.40 seconds
TestRunnerSetup               PASS      664.85 seconds
IncrementalBuild              PASS      27.37 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[v2] Bluetooth: btmtk: remove redundant memory barrier with helper

18: B3 Line contains hard tab characters (\t): " * perform the cleanup in btmtksdio.c and btmtkuart.c as well"

https://github.com/bluez/bluetooth-next/pull/986

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Arnaud Bonnet
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 10 lines · 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!

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