* [PATCH v1 1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate)
@ 2025-10-15 9:39 Ravindra
2025-10-15 9:39 ` [PATCH v1 2/2] Bluetooth: btintel_pcie: Suspend/Resume: Controller doorbell interrupt handling Ravindra
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ravindra @ 2025-10-15 9:39 UTC (permalink / raw)
To: linux-bluetooth
Cc: ravishankar.srivatsa, chethan.tumkur.narayan, Ravindra, Kiran K
During S4 (hibernate), the Bluetooth device loses power. Upon resume,
the driver performs the following actions:
1. Unregisters hdev
2. Calls function level reset
3. Registers hdev
Test case:
- run command sudo rtcwake -m disk -s 60
Signed-off-by: Ravindra <ravindra@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
---
drivers/bluetooth/btintel_pcie.c | 41 ++++++++++++++++++++++++++++++++
drivers/bluetooth/btintel_pcie.h | 2 ++
2 files changed, 43 insertions(+)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 6d3963bd56a9..2f4517d3fe13 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -825,6 +825,11 @@ static inline bool btintel_pcie_in_d0(struct btintel_pcie_data *data)
return !(data->boot_stage_cache & BTINTEL_PCIE_CSR_BOOT_STAGE_D3_STATE_READY);
}
+static inline bool btintel_pcie_in_device_halt(struct btintel_pcie_data *data)
+{
+ return data->boot_stage_cache & BTINTEL_PCIE_CSR_BOOT_STAGE_DEVICE_HALTED;
+}
+
static void btintel_pcie_wr_sleep_cntrl(struct btintel_pcie_data *data,
u32 dxstate)
{
@@ -2531,6 +2536,8 @@ static int btintel_pcie_suspend_late(struct device *dev, pm_message_t mesg)
dxstate = (mesg.event == PM_EVENT_SUSPEND ?
BTINTEL_PCIE_STATE_D3_HOT : BTINTEL_PCIE_STATE_D3_COLD);
+ data->pm_sx_event = mesg.event;
+
data->gp0_received = false;
start = ktime_get();
@@ -2580,6 +2587,20 @@ static int btintel_pcie_resume(struct device *dev)
start = ktime_get();
+ /* When the system enters S4 (hibernate) mode, bluetooth device loses
+ * power, which results in the erasure of its loaded firmware.
+ * Consequently, function level reset (flr) is required on system
+ * resume to bring the controller back into an operational state by
+ * initiating a new firmware download.
+ */
+
+ if (data->pm_sx_event == PM_EVENT_FREEZE ||
+ data->pm_sx_event == PM_EVENT_HIBERNATE) {
+ set_bit(BTINTEL_PCIE_CORE_HALTED, &data->flags);
+ btintel_pcie_reset(data->hdev);
+ return 0;
+ }
+
/* Refer: 6.4.11.7 -> Platform power management */
btintel_pcie_wr_sleep_cntrl(data, BTINTEL_PCIE_STATE_D0);
err = wait_event_timeout(data->gp0_wait_q, data->gp0_received,
@@ -2588,6 +2609,26 @@ static int btintel_pcie_resume(struct device *dev)
bt_dev_err(data->hdev,
"Timeout (%u ms) on alive interrupt for D0 entry",
BTINTEL_DEFAULT_INTR_TIMEOUT_MS);
+
+ /* Trigger function level reset if the controller is in error
+ * state during resume() to bring back the controller to
+ * operational mode
+ */
+
+ data->boot_stage_cache = btintel_pcie_rd_reg32(data,
+ BTINTEL_PCIE_CSR_BOOT_STAGE_REG);
+ if (btintel_pcie_in_error(data) ||
+ btintel_pcie_in_device_halt(data)) {
+ bt_dev_err(data->hdev, "Controller in error state for D0 entry");
+ if (!test_and_set_bit(BTINTEL_PCIE_COREDUMP_INPROGRESS,
+ &data->flags)) {
+ data->dmp_hdr.trigger_reason =
+ BTINTEL_PCIE_TRIGGER_REASON_FW_ASSERT;
+ queue_work(data->workqueue, &data->rx_work);
+ }
+ set_bit(BTINTEL_PCIE_CORE_HALTED, &data->flags);
+ btintel_pcie_reset(data->hdev);
+ }
return -EBUSY;
}
diff --git a/drivers/bluetooth/btintel_pcie.h b/drivers/bluetooth/btintel_pcie.h
index 04b21f968ad3..48e1ae1793e5 100644
--- a/drivers/bluetooth/btintel_pcie.h
+++ b/drivers/bluetooth/btintel_pcie.h
@@ -464,6 +464,7 @@ struct btintel_pcie_dump_header {
* @txq: TX Queue struct
* @rxq: RX Queue struct
* @alive_intr_ctxt: Alive interrupt context
+ * @pm_sx_event: PM event on which system got suspended
*/
struct btintel_pcie_data {
struct pci_dev *pdev;
@@ -513,6 +514,7 @@ struct btintel_pcie_data {
u32 alive_intr_ctxt;
struct btintel_pcie_dbgc dbgc;
struct btintel_pcie_dump_header dmp_hdr;
+ u8 pm_sx_event;
};
static inline u32 btintel_pcie_rd_reg32(struct btintel_pcie_data *data,
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] Bluetooth: btintel_pcie: Suspend/Resume: Controller doorbell interrupt handling
2025-10-15 9:39 [PATCH v1 1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate) Ravindra
@ 2025-10-15 9:39 ` Ravindra
2025-10-15 10:00 ` [v1,1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate) bluez.test.bot
2025-10-22 13:50 ` [PATCH v1 1/2] " patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Ravindra @ 2025-10-15 9:39 UTC (permalink / raw)
To: linux-bluetooth
Cc: ravishankar.srivatsa, chethan.tumkur.narayan, Ravindra, Kiran K
Due to a hardware bug during suspend/resume, the controller may miss a
doorbell interrupt. To address this, a retry mechanism has been added to
inform the controller before reporting a failure.
Test case:
- run suspend and resume cycles.
Signed-off-by: Ravindra <ravindra@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
---
drivers/bluetooth/btintel_pcie.c | 113 +++++++++++++++++++------------
drivers/bluetooth/btintel_pcie.h | 2 +
2 files changed, 73 insertions(+), 42 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 2f4517d3fe13..fbb4cc29138c 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -2523,6 +2523,48 @@ static void btintel_pcie_coredump(struct device *dev)
}
#endif
+static int btintel_pcie_set_dxstate(struct btintel_pcie_data *data, u32 dxstate)
+{
+ int retry = 0, status;
+ u32 dx_intr_timeout_ms = 200;
+
+ do {
+ data->gp0_received = false;
+
+ btintel_pcie_wr_sleep_cntrl(data, dxstate);
+
+ status = wait_event_timeout(data->gp0_wait_q, data->gp0_received,
+ msecs_to_jiffies(dx_intr_timeout_ms));
+
+ if (status)
+ return 0;
+
+ bt_dev_warn(data->hdev,
+ "Timeout (%u ms) on alive interrupt for D%d entry, retry count %d",
+ dx_intr_timeout_ms, dxstate, retry);
+
+ /* clear gp0 cause */
+ btintel_pcie_clr_reg_bits(data,
+ BTINTEL_PCIE_CSR_MSIX_HW_INT_CAUSES,
+ BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0);
+
+ /* A hardware bug may cause the alive interrupt to be missed.
+ * Check if the controller reached the expected state and retry
+ * the operation only if it hasn't.
+ */
+ if (dxstate == BTINTEL_PCIE_STATE_D0) {
+ if (btintel_pcie_in_d0(data))
+ return 0;
+ } else {
+ if (btintel_pcie_in_d3(data))
+ return 0;
+ }
+
+ } while (++retry < BTINTEL_PCIE_DX_TRANSITION_MAX_RETRIES);
+
+ return -EBUSY;
+}
+
static int btintel_pcie_suspend_late(struct device *dev, pm_message_t mesg)
{
struct pci_dev *pdev = to_pci_dev(dev);
@@ -2538,26 +2580,18 @@ static int btintel_pcie_suspend_late(struct device *dev, pm_message_t mesg)
data->pm_sx_event = mesg.event;
- data->gp0_received = false;
-
start = ktime_get();
/* Refer: 6.4.11.7 -> Platform power management */
- btintel_pcie_wr_sleep_cntrl(data, dxstate);
- err = wait_event_timeout(data->gp0_wait_q, data->gp0_received,
- msecs_to_jiffies(BTINTEL_DEFAULT_INTR_TIMEOUT_MS));
- if (err == 0) {
- bt_dev_err(data->hdev,
- "Timeout (%u ms) on alive interrupt for D3 entry",
- BTINTEL_DEFAULT_INTR_TIMEOUT_MS);
- return -EBUSY;
- }
+ err = btintel_pcie_set_dxstate(data, dxstate);
+
+ if (err)
+ return err;
bt_dev_dbg(data->hdev,
"device entered into d3 state from d0 in %lld us",
ktime_to_us(ktime_get() - start));
-
- return 0;
+ return err;
}
static int btintel_pcie_suspend(struct device *dev)
@@ -2602,40 +2636,35 @@ static int btintel_pcie_resume(struct device *dev)
}
/* Refer: 6.4.11.7 -> Platform power management */
- btintel_pcie_wr_sleep_cntrl(data, BTINTEL_PCIE_STATE_D0);
- err = wait_event_timeout(data->gp0_wait_q, data->gp0_received,
- msecs_to_jiffies(BTINTEL_DEFAULT_INTR_TIMEOUT_MS));
+ err = btintel_pcie_set_dxstate(data, BTINTEL_PCIE_STATE_D0);
+
if (err == 0) {
- bt_dev_err(data->hdev,
- "Timeout (%u ms) on alive interrupt for D0 entry",
- BTINTEL_DEFAULT_INTR_TIMEOUT_MS);
+ bt_dev_dbg(data->hdev,
+ "device entered into d0 state from d3 in %lld us",
+ ktime_to_us(ktime_get() - start));
+ return err;
+ }
- /* Trigger function level reset if the controller is in error
- * state during resume() to bring back the controller to
- * operational mode
- */
+ /* Trigger function level reset if the controller is in error
+ * state during resume() to bring back the controller to
+ * operational mode
+ */
- data->boot_stage_cache = btintel_pcie_rd_reg32(data,
- BTINTEL_PCIE_CSR_BOOT_STAGE_REG);
- if (btintel_pcie_in_error(data) ||
- btintel_pcie_in_device_halt(data)) {
- bt_dev_err(data->hdev, "Controller in error state for D0 entry");
- if (!test_and_set_bit(BTINTEL_PCIE_COREDUMP_INPROGRESS,
- &data->flags)) {
- data->dmp_hdr.trigger_reason =
- BTINTEL_PCIE_TRIGGER_REASON_FW_ASSERT;
- queue_work(data->workqueue, &data->rx_work);
- }
- set_bit(BTINTEL_PCIE_CORE_HALTED, &data->flags);
- btintel_pcie_reset(data->hdev);
+ data->boot_stage_cache = btintel_pcie_rd_reg32(data,
+ BTINTEL_PCIE_CSR_BOOT_STAGE_REG);
+ if (btintel_pcie_in_error(data) ||
+ btintel_pcie_in_device_halt(data)) {
+ bt_dev_err(data->hdev, "Controller in error state for D0 entry");
+ if (!test_and_set_bit(BTINTEL_PCIE_COREDUMP_INPROGRESS,
+ &data->flags)) {
+ data->dmp_hdr.trigger_reason =
+ BTINTEL_PCIE_TRIGGER_REASON_FW_ASSERT;
+ queue_work(data->workqueue, &data->rx_work);
}
- return -EBUSY;
+ set_bit(BTINTEL_PCIE_CORE_HALTED, &data->flags);
+ btintel_pcie_reset(data->hdev);
}
-
- bt_dev_dbg(data->hdev,
- "device entered into d0 state from d3 in %lld us",
- ktime_to_us(ktime_get() - start));
- return 0;
+ return err;
}
static const struct dev_pm_ops btintel_pcie_pm_ops = {
diff --git a/drivers/bluetooth/btintel_pcie.h b/drivers/bluetooth/btintel_pcie.h
index 48e1ae1793e5..e3d941ffef4a 100644
--- a/drivers/bluetooth/btintel_pcie.h
+++ b/drivers/bluetooth/btintel_pcie.h
@@ -158,6 +158,8 @@ enum msix_mbox_int_causes {
/* Default interrupt timeout in msec */
#define BTINTEL_DEFAULT_INTR_TIMEOUT_MS 3000
+#define BTINTEL_PCIE_DX_TRANSITION_MAX_RETRIES 3
+
/* The number of descriptors in TX queues */
#define BTINTEL_PCIE_TX_DESCS_COUNT 32
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [v1,1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate)
2025-10-15 9:39 [PATCH v1 1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate) Ravindra
2025-10-15 9:39 ` [PATCH v1 2/2] Bluetooth: btintel_pcie: Suspend/Resume: Controller doorbell interrupt handling Ravindra
@ 2025-10-15 10:00 ` bluez.test.bot
2025-10-22 13:50 ` [PATCH v1 1/2] " patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-10-15 10:00 UTC (permalink / raw)
To: linux-bluetooth, ravindra
[-- Attachment #1: Type: text/plain, Size: 3090 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/project/bluetooth/list/?series=1011778
---Test result---
Test Summary:
CheckPatch PENDING 0.35 seconds
GitLint PENDING 0.46 seconds
SubjectPrefix PASS 0.23 seconds
BuildKernel PASS 25.34 seconds
CheckAllWarning PASS 28.15 seconds
CheckSparse PASS 31.67 seconds
BuildKernel32 PASS 25.61 seconds
TestRunnerSetup PASS 496.68 seconds
TestRunner_l2cap-tester PASS 24.29 seconds
TestRunner_iso-tester FAIL 29.76 seconds
TestRunner_bnep-tester PASS 6.32 seconds
TestRunner_mgmt-tester FAIL 125.60 seconds
TestRunner_rfcomm-tester PASS 9.46 seconds
TestRunner_sco-tester PASS 14.51 seconds
TestRunner_ioctl-tester FAIL 10.38 seconds
TestRunner_mesh-tester FAIL 12.39 seconds
TestRunner_smp-tester PASS 8.67 seconds
TestRunner_userchan-tester PASS 6.63 seconds
IncrementalBuild PENDING 1.02 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
BUG: KASAN: slab-use-after-free in iso_conn_hold_unless_zero+0x76/0x1c0
No test result found
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 482 (98.4%), Failed: 4, Not Run: 4
Failed Test Cases
Pair Device - Legacy Success 1 Failed 0.202 seconds
Pair Device - Sec Mode 3 Success 1 Failed 0.190 seconds
Pair Device - Legacy Reject 2 Failed 0.165 seconds
Read Exp Feature - Success Failed 0.106 seconds
##############################
Test: TestRunner_ioctl-tester - FAIL
Desc: Run ioctl-tester with test-runner
Output:
Total: 28, Passed: 26 (92.9%), Failed: 2, Not Run: 0
Failed Test Cases
Connection List Failed 1.059 seconds
Connection Info Failed 0.143 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.776 seconds
Mesh - Send cancel - 2 Timed out 1.999 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate)
2025-10-15 9:39 [PATCH v1 1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate) Ravindra
2025-10-15 9:39 ` [PATCH v1 2/2] Bluetooth: btintel_pcie: Suspend/Resume: Controller doorbell interrupt handling Ravindra
2025-10-15 10:00 ` [v1,1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate) bluez.test.bot
@ 2025-10-22 13:50 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-10-22 13:50 UTC (permalink / raw)
To: Ravindra
Cc: linux-bluetooth, ravishankar.srivatsa, chethan.tumkur.narayan,
kiran.k
Hello:
This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 15 Oct 2025 15:09:02 +0530 you wrote:
> During S4 (hibernate), the Bluetooth device loses power. Upon resume,
> the driver performs the following actions:
>
> 1. Unregisters hdev
> 2. Calls function level reset
> 3. Registers hdev
>
> [...]
Here is the summary with links:
- [v1,1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate)
https://git.kernel.org/bluetooth/bluetooth-next/c/af904d7aca72
- [v1,2/2] Bluetooth: btintel_pcie: Suspend/Resume: Controller doorbell interrupt handling
https://git.kernel.org/bluetooth/bluetooth-next/c/fc7c3c61efe4
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] 4+ messages in thread
end of thread, other threads:[~2025-10-22 13:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 9:39 [PATCH v1 1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate) Ravindra
2025-10-15 9:39 ` [PATCH v1 2/2] Bluetooth: btintel_pcie: Suspend/Resume: Controller doorbell interrupt handling Ravindra
2025-10-15 10:00 ` [v1,1/2] Bluetooth: btintel_pcie: Support for S4 (Hibernate) bluez.test.bot
2025-10-22 13:50 ` [PATCH v1 1/2] " 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;
as well as URLs for NNTP newsgroup(s).