* [PATCH v1] Bluetooth: btintel_pcie: Reject user coredump until firmware is operational
@ 2026-11-18 23:20 Kiran K
2026-11-19 0:59 ` [v1] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Kiran K @ 2026-11-18 23:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: chethan.tumkur.narayan, chandrashekar.devegowda, Kiran K
A user can request a device coredump through the PCI coredump sysfs
attribute at any time, including while firmware is being downloaded
from btintel_pcie_setup(). The request then rings the DBGC flush
doorbell on bootloader firmware that does not service it, or, if the
core halted, reads debug regions under MAC access while the setup
retry path is resetting and re-enabling the device.
The same applies once recovery has been requested. The sysfs callback
runs synchronously and can ring the doorbell while
btintel_pcie_reset_work() is quiescing the device or while the ACPI
_PRR reset runs. A flag check in the callback alone cannot close this,
as recovery can be requested right after the check.
Make the callback only check that the firmware is operational and
queue a work item on dump_workqueue, so all device access happens in
that worker. The worker rechecks the state and is drained by
btintel_pcie_reset_work() before the device is quiesced, and by
remove(), probe cleanup and suspend, so the doorbell can no longer race
with reset.
The firmware is considered operational once BTINTEL_PCIE_SETUP_DONE is
set and until BTINTEL_PCIE_RECOVERY_IN_PROGRESS is set. Neither flag is
cleared for the lifetime of the driver data, as recovery re-probes the
device. Firmware-initiated dumps are not affected.
Fixes: 07e6bddb54b4 ("Bluetooth: btintel_pcie: Add support for device coredump")
Assisted-by: Copilot:claude-opus-5.5
Signed-off-by: Kiran K <kiran.k@intel.com>
---
drivers/bluetooth/btintel_pcie.c | 60 ++++++++++++++++++++++++++------
drivers/bluetooth/btintel_pcie.h | 1 +
2 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 382e02851758..12a2cca09d7d 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -658,6 +658,7 @@ static inline void btintel_pcie_dump_debug_registers(struct hci_dev *hdev)
}
static inline bool btintel_pcie_in_d3(struct btintel_pcie_data *data);
+static void btintel_pcie_user_dump_req_worker(struct work_struct *work);
static int btintel_pcie_send_sync(struct btintel_pcie_data *data,
struct sk_buff *skb, u32 pkt_type, u16 opcode)
@@ -4116,6 +4117,7 @@ static void btintel_pcie_probe_cleanup(struct btintel_pcie_data *data)
btintel_pcie_disable_interrupts(data);
btintel_pcie_synchronize_irqs(data);
+ disable_work_sync(&data->user_dump_req_work);
disable_work_sync(&data->coredump_work);
disable_work_sync(&data->hwexp_work);
disable_work_sync(&data->fwtrigger_work);
@@ -4596,6 +4598,8 @@ static void btintel_pcie_reset_work(struct work_struct *wk)
if (!data)
goto out;
+ disable_work_sync(&data->user_dump_req_work);
+
btintel_pcie_mask_hw_rfkill(data);
btintel_pcie_synchronize_irqs(data);
disable_delayed_work_sync(&data->hw_rfkill_work);
@@ -4632,6 +4636,7 @@ static void btintel_pcie_reset_work(struct work_struct *wk)
}
if (btintel_pcie_perform_flr(data)) {
+ enable_work(&data->user_dump_req_work);
enable_work(&data->coredump_work);
enable_work(&data->hwexp_work);
enable_work(&data->fwtrigger_work);
@@ -4947,6 +4952,7 @@ static int btintel_pcie_probe(struct pci_dev *pdev,
INIT_WORK(&data->fwtrigger_work, btintel_pcie_fwtrigger_worker);
INIT_WORK(&data->mbox_work, btintel_pcie_mbox_worker);
INIT_DELAYED_WORK(&data->user_dump_work, btintel_pcie_user_dump_worker);
+ INIT_WORK(&data->user_dump_req_work, btintel_pcie_user_dump_req_worker);
data->boot_stage_cache = 0x00;
data->img_resp_cache = 0x00;
@@ -5039,6 +5045,7 @@ static void btintel_pcie_remove(struct pci_dev *pdev)
* the disable counters stay >= 1 even after reset_work()'s
* balanced enable_work() (counter 2 -> 1, never reaching 0).
*/
+ disable_work_sync(&data->user_dump_req_work);
disable_work_sync(&data->coredump_work);
disable_work_sync(&data->hwexp_work);
disable_work_sync(&data->fwtrigger_work);
@@ -5088,7 +5095,6 @@ static void btintel_pcie_remove(struct pci_dev *pdev)
pci_set_drvdata(pdev, NULL);
}
-#ifdef CONFIG_DEV_COREDUMP
static u32 btintel_pcie_ipc_ctrl_toggle(struct btintel_pcie_data *data, u32 bits)
{
unsigned long flags;
@@ -5115,13 +5121,26 @@ static void btintel_pcie_trigger_fw_dump_collect(struct btintel_pcie_data *data)
"IPC doorbell sent to FW for DBGC flush (IPC_CTRL=0x%08x)", reg);
}
-static void btintel_pcie_coredump(struct device *dev)
+static bool btintel_pcie_fw_operational(struct btintel_pcie_data *data)
{
- struct pci_dev *pdev = to_pci_dev(dev);
- struct btintel_pcie_data *data = pci_get_drvdata(pdev);
+ return test_bit(BTINTEL_PCIE_SETUP_DONE, &data->flags) &&
+ !test_bit(BTINTEL_PCIE_RECOVERY_IN_PROGRESS, &data->flags);
+}
- if (!data)
+/* Drained by reset_work() before the device is quiesced */
+static void btintel_pcie_user_dump_req_worker(struct work_struct *work)
+{
+ struct btintel_pcie_data *data = container_of(work,
+ struct btintel_pcie_data, user_dump_req_work);
+
+ if (!data->hdev)
+ return;
+
+ if (!btintel_pcie_fw_operational(data)) {
+ bt_dev_warn(data->hdev,
+ "coredump rejected: firmware not operational");
return;
+ }
if (test_bit(BTINTEL_PCIE_COREDUMP_INPROGRESS, &data->flags) ||
test_bit(BTINTEL_PCIE_FWTRIGGER_DUMP_INPROGRESS, &data->flags)) {
@@ -5143,9 +5162,8 @@ static void btintel_pcie_coredump(struct device *dev)
return;
}
- /* Only a halted core cannot answer the doorbell. FW services it
- * regardless of host setup or recovery state, so no other state
- * needs to be excluded; collect directly here.
+ /* Only a halted core cannot answer the doorbell; collect directly
+ * here.
*/
if (test_bit(BTINTEL_PCIE_CORE_HALTED, &data->flags)) {
btintel_pcie_queue_coredump(data,
@@ -5163,9 +5181,8 @@ static void btintel_pcie_coredump(struct device *dev)
* runs with the flag clear and leaves it set without a timer.
*
* The flag/arm/doorbell sequence is not atomic against the interrupt
- * handler or reset. A firmware trigger while the request is pending
- * may take the user-dump reason, and a reset in it may leave the flag
- * set until the next reset. Both are rare and do not affect the dump
+ * handler. A firmware trigger while the request is pending may take
+ * the user-dump reason. This is rare and does not affect the dump
* contents.
*/
set_bit(BTINTEL_PCIE_USER_TRIGGERED_DUMP, &data->flags);
@@ -5179,6 +5196,26 @@ static void btintel_pcie_coredump(struct device *dev)
btintel_pcie_trigger_fw_dump_collect(data);
}
+
+#ifdef CONFIG_DEV_COREDUMP
+static void btintel_pcie_coredump(struct device *dev)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ struct btintel_pcie_data *data = pci_get_drvdata(pdev);
+
+ if (!data)
+ return;
+
+ if (!btintel_pcie_fw_operational(data)) {
+ bt_dev_warn(data->hdev,
+ "coredump rejected: firmware not operational");
+ return;
+ }
+
+ if (!queue_work(data->dump_workqueue, &data->user_dump_req_work))
+ bt_dev_warn(data->hdev,
+ "coredump rejected: request pending or workqueue disabled");
+}
#endif
static int btintel_pcie_set_dxstate(struct btintel_pcie_data *data, u32 dxstate)
@@ -5290,6 +5327,7 @@ static int btintel_pcie_suspend_late(struct device *dev, pm_message_t mesg)
* request, then let an in-flight timeout worker and any queued dump
* finish before the device enters D3.
*/
+ cancel_work_sync(&data->user_dump_req_work);
clear_bit(BTINTEL_PCIE_USER_TRIGGERED_DUMP, &data->flags);
cancel_delayed_work_sync(&data->user_dump_work);
flush_work(&data->fwtrigger_work);
diff --git a/drivers/bluetooth/btintel_pcie.h b/drivers/bluetooth/btintel_pcie.h
index b60e24ca558d..28acc20eefdf 100644
--- a/drivers/bluetooth/btintel_pcie.h
+++ b/drivers/bluetooth/btintel_pcie.h
@@ -818,6 +818,7 @@ struct btintel_pcie_data {
struct work_struct fwtrigger_work;
struct work_struct mbox_work;
struct delayed_work user_dump_work;
+ struct work_struct user_dump_req_work;
struct dma_pool *dma_pool;
dma_addr_t dma_p_addr;
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* RE: [v1] Bluetooth: btintel_pcie: Reject user coredump until firmware is operational
2026-11-18 23:20 [PATCH v1] Bluetooth: btintel_pcie: Reject user coredump until firmware is operational Kiran K
@ 2026-11-19 0:59 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-11-19 0:59 UTC (permalink / raw)
To: linux-bluetooth, kiran.k
[-- Attachment #1: Type: text/plain, Size: 1875 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/1215474/
---Test result---
Test Summary:
CheckPatch FAIL 0.86 seconds
VerifyFixes PASS 0.11 seconds
VerifySignedoff PASS 0.11 seconds
GitLint PASS 0.28 seconds
SubjectPrefix PASS 0.11 seconds
BuildKernel PASS 24.72 seconds
CheckAllWarning PASS 29.37 seconds
CheckSparse PASS 30.34 seconds
BuildKernel32 PASS 25.09 seconds
CheckKernelLLVM PASS 27.35 seconds
TestRunnerSetup PASS 585.68 seconds
IncrementalBuild PASS 24.25 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v1] Bluetooth: btintel_pcie: Reject user coredump until firmware is operational
WARNING: Non-standard signature: Assisted-by:
#122:
Assisted-by: Copilot:claude-opus-5.5
ERROR: Unrecognized email address: 'Copilot:claude-opus-5.5'
#122:
Assisted-by: Copilot:claude-opus-5.5
total: 1 errors, 1 warnings, 142 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/home/runner/work/bluetooth-next/bluetooth-next/src/patch/14999107.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
https://github.com/bluez/bluetooth-next/pull/1154
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 0:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 23:20 [PATCH v1] Bluetooth: btintel_pcie: Reject user coredump until firmware is operational Kiran K
2026-11-19 0:59 ` [v1] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox