Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v2] Bluetooth: btmtk: remove redundant memory barrier with helper
@ 2026-10-23  9:36 Arnaud Bonnet
  2026-10-23 12:56 ` [v2] " bluez.test.bot
  2026-10-23 21:00 ` [PATCH v2] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ 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] 3+ messages in thread

* RE: [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 12:56 ` bluez.test.bot
  2026-10-23 21:00 ` [PATCH v2] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-10-23 12:56 UTC (permalink / raw)
  To: linux-bluetooth, abo

[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ 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 12:56 ` [v2] " bluez.test.bot
@ 2026-10-23 21:00 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2026-10-23 21:00 UTC | newest]

Thread overview: 3+ 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 12:56 ` [v2] " bluez.test.bot
2026-10-23 21:00 ` [PATCH v2] " 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