From: Kiran K <kiran.k@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: chethan.tumkur.narayan@intel.com,
chandrashekar.devegowda@intel.com, ravindra@intel.com,
Kiran K <kiran.k@intel.com>
Subject: [PATCH v1 3/3] Bluetooth: btintel_pcie: Serialize MAC access requests
Date: Mon, 23 Nov 2026 12:25:23 +0530 [thread overview]
Message-ID: <20261123065523.2769017-3-kiran.k@intel.com> (raw)
In-Reply-To: <20261123065523.2769017-1-kiran.k@intel.com>
MAC_ACCESS_REQ is requested and released with an unlocked
read-modify-write of FUNC_CTRL. The YoYo config set path and the dump
workqueue (device memory read and trace dump) can run it concurrently.
One path can then release MAC_ACCESS_REQ while another is still
accessing the target, or their FUNC_CTRL updates can overwrite each
other.
Hold a new mac_access_lock across the whole request, access and release
sequence in these users. Also release MAC_ACCESS_REQ when the request
fails, so a timed-out request is not left set.
Fixes: 68e0925f16c0 ("Bluetooth: btintel_pcie: Add yoyo support for config set TLV")
Assisted-by: Copilot:claude-sonnet-5.5
Signed-off-by: Kiran K <kiran.k@intel.com>
---
drivers/bluetooth/btintel_pcie.c | 15 ++++++++++++++-
drivers/bluetooth/btintel_pcie.h | 4 ++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 75f1724336ae..3b2c8bbb36e9 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -1035,6 +1035,7 @@ btintel_pcie_apply_yoyo_config_sets(struct btintel_pcie_data *data,
if (config_set->config_set_type == BTINTEL_PCIE_CFGSET_PERIPH_MAC ||
config_set->config_set_type == BTINTEL_PCIE_CFGSET_DEVICE_MEM) {
+ mutex_lock(&data->mac_access_lock);
ret = btintel_pcie_get_mac_access(data);
if (ret) {
BT_WARN("YoYo: MAC access failed for config set (%d), skipping",
@@ -1044,6 +1045,7 @@ btintel_pcie_apply_yoyo_config_sets(struct btintel_pcie_data *data,
* request bit is not leaked.
*/
btintel_pcie_release_mac_access(data);
+ mutex_unlock(&data->mac_access_lock);
continue;
}
}
@@ -1104,8 +1106,10 @@ btintel_pcie_apply_yoyo_config_sets(struct btintel_pcie_data *data,
}
if (config_set->config_set_type == BTINTEL_PCIE_CFGSET_PERIPH_MAC ||
- config_set->config_set_type == BTINTEL_PCIE_CFGSET_DEVICE_MEM)
+ config_set->config_set_type == BTINTEL_PCIE_CFGSET_DEVICE_MEM) {
btintel_pcie_release_mac_access(data);
+ mutex_unlock(&data->mac_access_lock);
+ }
}
}
@@ -1752,15 +1756,19 @@ static void btintel_pcie_dump_traces(struct hci_dev *hdev)
struct btintel_pcie_data *data = hci_get_drvdata(hdev);
int ret;
+ mutex_lock(&data->mac_access_lock);
ret = btintel_pcie_get_mac_access(data);
if (ret) {
bt_dev_err(hdev, "Failed to get mac access: (%d)", ret);
+ btintel_pcie_release_mac_access(data);
+ mutex_unlock(&data->mac_access_lock);
return;
}
ret = btintel_pcie_read_debug_regions(data);
btintel_pcie_release_mac_access(data);
+ mutex_unlock(&data->mac_access_lock);
if (ret)
bt_dev_err(hdev, "Failed to dump traces: (%d)", ret);
@@ -1884,9 +1892,12 @@ static int btintel_pcie_read_device_mem(struct btintel_pcie_data *data,
u32 *val = buf;
/* Get device mac access */
+ mutex_lock(&data->mac_access_lock);
err = btintel_pcie_get_mac_access(data);
if (err) {
bt_dev_err(data->hdev, "Failed to get mac access %d", err);
+ btintel_pcie_release_mac_access(data);
+ mutex_unlock(&data->mac_access_lock);
return err;
}
@@ -1899,6 +1910,7 @@ static int btintel_pcie_read_device_mem(struct btintel_pcie_data *data,
*val = btintel_pcie_rd_dev_mem(data, dev_addr);
btintel_pcie_release_mac_access(data);
+ mutex_unlock(&data->mac_access_lock);
return 0;
}
@@ -4863,6 +4875,7 @@ static int btintel_pcie_probe(struct pci_dev *pdev,
spin_lock_init(&data->hci_rx_lock);
spin_lock_init(&data->ipc_lock);
spin_lock_init(&data->dev_mem_lock);
+ mutex_init(&data->mac_access_lock);
mutex_init(&data->rfkill_doorbell_lock);
init_waitqueue_head(&data->gp0_wait_q);
diff --git a/drivers/bluetooth/btintel_pcie.h b/drivers/bluetooth/btintel_pcie.h
index 124e837da94b..97267a7e9762 100644
--- a/drivers/bluetooth/btintel_pcie.h
+++ b/drivers/bluetooth/btintel_pcie.h
@@ -773,6 +773,10 @@ struct btintel_pcie_data {
* PRPH_DEV_RD target access register pair. Never sleep while held.
*/
spinlock_t dev_mem_lock;
+ /* lock to serialize the MAC_ACCESS_REQ get/release sequence together
+ * with the target accesses done under it. Held across sleeping calls.
+ */
+ struct mutex mac_access_lock;
void __iomem *base_addr;
--
2.54.0
next prev parent reply other threads:[~2026-11-23 6:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 6:55 [PATCH v1 1/3] Revert "Bluetooth: btintel_pcie: sync mbox tlv parsing with GP0 alive interrupt" Kiran K
2026-11-23 6:55 ` [PATCH v1 2/3] Bluetooth: btintel_pcie: Serialize doorbell writes and target reads Kiran K
2026-11-23 6:55 ` Kiran K [this message]
2026-11-23 20:44 ` [PATCH v1 3/3] Bluetooth: btintel_pcie: Serialize MAC access requests kernel test robot
2026-11-23 11:56 ` [v1,1/3] Revert "Bluetooth: btintel_pcie: sync mbox tlv parsing with GP0 alive interrupt" bluez.test.bot
2026-11-23 19:40 ` [PATCH v1 1/3] " patchwork-bot+bluetooth
2026-11-24 22:42 ` Nathan Chancellor
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=20261123065523.2769017-3-kiran.k@intel.com \
--to=kiran.k@intel.com \
--cc=chandrashekar.devegowda@intel.com \
--cc=chethan.tumkur.narayan@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=ravindra@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.