From nobody Fri Sep 25 19:16:06 2026 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27D14471271 for ; Wed, 9 Sep 2026 12:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788957279; cv=none; b=hBhtdGcnnEaEBVAWlHuDb9pTVzcfjaaMcdgzeCXp2ylAJGHrlV+uXP6fadzh8P/fv/fZt1xFZNgZqJ7P17TaNoaXkMXBsVY/446QqOTEjpN7JmHsmfmNudqpl9p+bIbkd9BjQ9fR51ESFh26v2fEI+jEwCdftGu+ZLEfjE9uIyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788957279; c=relaxed/simple; bh=//c8F1cx0k+bb8nyFj6lXf8mcRAemMwHlyURb9FV3bQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YMzqIjp0A47MLmom+BIMFDhCQLhVpppVheGpwc2ViIRDrkVjmD072SKBIctfO56mxFS9nojAYvWLy2V4ea7qTch00lLTcGQx7orm/jnAUC35OWU8Q55CuJL+fdDugpjrHD7nLM7cXToNtq9xZ1s/5AJhC2xCUK130hkFcgbLwvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=iKBWumfg; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="iKBWumfg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1788957275; x=1789216475; bh=J1O58uA+SipTQJzoHAqMs/spIqMX0Sd8gvJTBdtJ2u4=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=iKBWumfg1/VluBmSpmfniqn4HKS9r2arc/aoJ5BmEoP/0jvnV6GEgXkEbeXTdEJOk r+uHbTjXn4Ew+xGXOUvRACMP7MFvhq1id1yVWdEVUg7likIq+nKkHqufvU93lm+IBZ LRrQ1V5mjfzzFsFeADQZwsACwi8wNcll+VslkajcR8Bm/pphmED9LqJon9/RDAmzN0 AOfLcg/zSefqbnP+M6rpcl2yv9pMxK0gx8GRgQ9CSpi0B/MxAngsAoQ4SrTwVC9hG5 CXUR9xEGbTo5B+6NTbV/Ov9x/8rlztyIaoFqOBZGb7TwpxNbZhUwZNrvfZQ1uZYWA7 qA0cmydJZbrJA== Date: Wed, 09 Sep 2026 12:34:32 +0000 To: Marcel Holtmann , Luiz Augusto von Dentz , "Vladimir V . Kondratyev" , Ravindra From: Sergey Lebedev Cc: Ferenc Lengyel , Chethan Tumkur Narayan , Ravishankar Srivatsa , Paul Menzel , Kiran K , Chandrashekar Devegowda , Mahalingeshwara Chambarakatta , Arnd Bergmann , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: btintel_pcie: fix stale cache in set_dxstate fallback check Message-ID: <20260909123416.71919-2-lsa.uz@pm.me> In-Reply-To: <20260909123416.71919-1-lsa.uz@pm.me> References: <20260909123416.71919-1-lsa.uz@pm.me> Feedback-ID: 113843758:user:proton X-Pm-Message-ID: 45fb7b56740a1ee7d9aef5be86292eee2c212fea Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir V. Kondratyev btintel_pcie returns -16 (EBUSY) during suspend, causing the entire suspend operation to abort on Intel Lunar Lake hardware. The system immediately resumes after every suspend attempt: Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D2 entry, retry count 0 Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D2 entry, retry count 1 Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D2 entry, retry count 2 btintel_pcie 0000:00:14.7: PM: pci_pm_suspend(): btintel_pcie_suspend [btintel_pcie] returns -16 btintel_pcie 0000:00:14.7: PM: dpm_run_callback(): pci_pm_suspend returns -16 btintel_pcie 0000:00:14.7: PM: failed to suspend async: error -16 PM: Some devices failed to suspend, or early wake event detected btintel_pcie_set_dxstate() falls back to checking the controller state via btintel_pcie_in_d3/d0() when the alive interrupt is missed. However, these helpers read boot_stage_cache, which is only updated by the interrupt handler. As such, if the interrupt was missed, the cache is stale and the fallback check always fails, exhausting all retries and returning -EBUSY, causing suspend to abort. The fix involves re-reading the hardware register before the fallback state check, consistent with btintel_pcie_resume(). Fixes: e57362f4911b ("Bluetooth: btintel_pcie: Add support for _suspend() /= _resume()") Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D221481 Link: https://lore.kernel.org/linux-bluetooth/20260830151550.44687-1-lsa.uz= @pm.me/ Signed-off-by: Vladimir V. Kondratyev Tested-by: Sergey Lebedev Signed-off-by: Sergey Lebedev --- drivers/bluetooth/btintel_pcie.c | 8 +++++--- drivers/bluetooth/btintel_pcie.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_p= cie.c index 7a2139a04..361c550b5 100644 --- a/drivers/bluetooth/btintel_pcie.c +++ b/drivers/bluetooth/btintel_pcie.c @@ -4191,10 +4191,12 @@ static int btintel_pcie_set_dxstate(struct btintel_= pcie_data *data, u32 dxstate) BTINTEL_PCIE_CSR_MSIX_HW_INT_CAUSES, BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0); =20 - /* 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. + /* A hardware bug may cause the alive interrupt to be missed. Refresh + * boot_stage_cache from hardware, since only the interrupt handler + * updates it. Finally retry only if the state check still fails. */ + data->boot_stage_cache =3D btintel_pcie_rd_reg32(data, + BTINTEL_PCIE_CSR_BOOT_STAGE_REG); if (dxstate =3D=3D BTINTEL_PCIE_STATE_D0) { if (btintel_pcie_in_d0(data)) return 0; diff --git a/drivers/bluetooth/btintel_pcie.h b/drivers/bluetooth/btintel_p= cie.h index f35f80f80..016795fcb 100644 --- a/drivers/bluetooth/btintel_pcie.h +++ b/drivers/bluetooth/btintel_pcie.h @@ -51,6 +51,7 @@ #define BTINTEL_PCIE_CSR_BOOT_STAGE_DEVICE_HALTED (BIT(14)) #define BTINTEL_PCIE_CSR_BOOT_STAGE_MAC_ACCESS_ON (BIT(16)) #define BTINTEL_PCIE_CSR_BOOT_STAGE_ALIVE (BIT(23)) +/* Reflects live D-state. Updated by hardware on every D-state transition.= */ #define BTINTEL_PCIE_CSR_BOOT_STAGE_D3_STATE_READY (BIT(24)) =20 #define BTINTEL_PCIE_CSR_DOORBELL_MBOX_READ_CONFIRM (BIT(4)) --=20 2.50.1 (Apple Git-155) From nobody Fri Sep 25 19:16:06 2026 Received: from mail-43101.protonmail.ch (mail-43101.protonmail.ch [185.70.43.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0AC8492522 for ; Wed, 9 Sep 2026 12:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788957286; cv=none; b=N7bHKu24cTt5Q45DK9R6UjpqVuV9LtRg5zsVJFO5R6yJFqKjYBKDaauu5mcPd8gHaHliSspnfDKE+SOkwILb6ho0yocibDP2uupVb3TzAL0vCFsldqEsNXlKygJA+dN6wkRCiNzUcmgoQcPJ395bkMaFyQVas2QdWctFA+9Xu9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788957286; c=relaxed/simple; bh=HWglzUhp1hqB53Fe6berq28CaqEGFMOieXgG6YFOjIU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MQBdnKr94eVAQCnG1ZrDMDhLcLiMgtFBui/HFrTDwYm3s2P+SllPoWZXyMtwQd8mrkWqRNZ/DK2qKvkVQRUHmhEuGsc8YxqGB81xJZnajRxu3YsXpinRhRZHxWQKvres8Kix7N+ngTEhKsLkHMkeVGnnTYcRl2jj5X1ajLyrS/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=R/u44cMI; arc=none smtp.client-ip=185.70.43.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="R/u44cMI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1788957281; x=1789216481; bh=+D2le/KqWrhPdU1IuLBg0EWsxIbaA4h514MeEcI5EVU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=R/u44cMI15ax1c4ZhSxtUCHnukvo6B3Y4ZilaMNJ3VeZRpqsqDJkHTqUPEL1S2BfL nv5JNDvEc7U4e+blPEj5QUoT+49QzbXt4a5AzcRAyMuWQFunjHhUEZeLfv4WDJtDES cY9gCsG8RqPnH17zFkiqmIqkIJ33ihGnotYbcdwD81UuDlH55G2I741Tfz/hWC2QRB 2UZDkdPzdrVW+d+ozmipEkOK2E0fjpjPtngAk0nlA9PDlV1mk8TYHQklxSGYWtqszZ /5anZdkGT8+Ed30QKiLA5bli1Ejsa3jTIeBk7OzCuCg1gFKRHv7z91mZhCJBOZbzUV 0VO+3GU++k7MA== Date: Wed, 09 Sep 2026 12:34:38 +0000 To: Marcel Holtmann , Luiz Augusto von Dentz , "Vladimir V . Kondratyev" , Ravindra From: Sergey Lebedev Cc: Ferenc Lengyel , Chethan Tumkur Narayan , Ravishankar Srivatsa , Paul Menzel , Kiran K , Chandrashekar Devegowda , Mahalingeshwara Chambarakatta , Arnd Bergmann , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] Bluetooth: btintel_pcie: fix PM flow for S0ix, S3 and S4 Message-ID: <20260909123416.71919-3-lsa.uz@pm.me> In-Reply-To: <20260909123416.71919-1-lsa.uz@pm.me> References: <20260909123416.71919-1-lsa.uz@pm.me> Feedback-ID: 113843758:user:proton X-Pm-Message-ID: 011a6f2f9df594d6d4479e794f4155c996b35717 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ravindra Use pm_suspend_target_state to differentiate S0ix from S3/S4. Set the controller to D3_HOT for S0ix (PM_SUSPEND_TO_IDLE) and D3_COLD for S3/S4, freeze and hibernate to prevent post-resume instability. Register .freeze, .thaw, .poweroff and .restore callbacks for proper hibernation support. The freeze and poweroff (hibernate) paths set D3_COLD via btintel_pcie_suspend_late. The thaw path resumes with a normal D0 transition, while .restore forces FLR-based firmware recovery after S4 since power is lost. S3 (PM_SUSPEND_MEM) resume also triggers FLR. S0ix resumes via a normal D0 transition. Fixes: e57362f4911b ("Bluetooth: btintel_pcie: Add support for _suspend() /= _resume()") Assisted-by: GitHub-Copilot:GPT5 Signed-off-by: Ravindra Assisted-by: Claude:claude-opus-5 Tested-by: Ferenc Lengyel Signed-off-by: Sergey Lebedev --- drivers/bluetooth/btintel_pcie.c | 64 ++++++++++++++++++++++---------- drivers/bluetooth/btintel_pcie.h | 2 - 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_p= cie.c index 361c550b5..e37e710b9 100644 --- a/drivers/bluetooth/btintel_pcie.c +++ b/drivers/bluetooth/btintel_pcie.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #include #include @@ -4168,11 +4169,16 @@ static void btintel_pcie_coredump(struct device *de= v) =20 static int btintel_pcie_set_dxstate(struct btintel_pcie_data *data, u32 dx= state) { - int retry =3D 0, status; + int retry =3D 0; + long status; u32 dx_intr_timeout_ms =3D 200; =20 + /* Not reset per retry: dxstate is unchanged, so a late interrupt from + * an earlier attempt still confirms the target state. + */ + data->gp0_received =3D false; + do { - data->gp0_received =3D false; =20 btintel_pcie_wr_sleep_cntrl(data, dxstate); =20 @@ -4220,18 +4226,23 @@ static int btintel_pcie_suspend_late(struct device = *dev, pm_message_t mesg) =20 data =3D pci_get_drvdata(pdev); =20 - dxstate =3D (mesg.event =3D=3D PM_EVENT_SUSPEND ? - BTINTEL_PCIE_STATE_D3_HOT : BTINTEL_PCIE_STATE_D3_COLD); - - data->pm_sx_event =3D mesg.event; + /* S0ix (s2idle) uses D3_HOT; S3, freeze and hibernate use D3_COLD. */ + if (mesg.event =3D=3D PM_EVENT_SUSPEND && + pm_suspend_target_state =3D=3D PM_SUSPEND_TO_IDLE) + dxstate =3D BTINTEL_PCIE_STATE_D3_HOT; + else + dxstate =3D BTINTEL_PCIE_STATE_D3_COLD; =20 start =3D ktime_get(); =20 /* Refer: 6.4.11.7 -> Platform power management */ err =3D btintel_pcie_set_dxstate(data, dxstate); =20 - if (err) + if (err) { + bt_dev_err(data->hdev, "Failed to set dxstate:%u (%d)", + dxstate, err); return err; + } =20 bt_dev_dbg(data->hdev, "device entered into d3 state from d0 in %lld us", @@ -4254,7 +4265,7 @@ static int btintel_pcie_freeze(struct device *dev) return btintel_pcie_suspend_late(dev, PMSG_FREEZE); } =20 -static int btintel_pcie_resume(struct device *dev) +static int btintel_pcie_resume_event(struct device *dev, pm_message_t mesg) { struct pci_dev *pdev =3D to_pci_dev(dev); struct btintel_pcie_data *data; @@ -4262,19 +4273,15 @@ static int btintel_pcie_resume(struct device *dev) int err; =20 data =3D pci_get_drvdata(pdev); - data->gp0_received =3D false; =20 start =3D ktime_get(); =20 - /* 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. + /* S3 and S4 may cut power, erasing the firmware. Force FLR to recover + * instead of a normal D0 transition. */ - - if (data->pm_sx_event =3D=3D PM_EVENT_FREEZE || - data->pm_sx_event =3D=3D PM_EVENT_HIBERNATE) { + if (mesg.event =3D=3D PM_EVENT_RESTORE || + (mesg.event =3D=3D PM_EVENT_RESUME && + pm_suspend_target_state =3D=3D PM_SUSPEND_MEM)) { set_bit(BTINTEL_PCIE_CORE_HALTED, &data->flags); btintel_pcie_request_reset(data, BTINTEL_PCIE_IOSF_PRR_FLR); return 0; @@ -4283,7 +4290,9 @@ static int btintel_pcie_resume(struct device *dev) /* Refer: 6.4.11.7 -> Platform power management */ err =3D btintel_pcie_set_dxstate(data, BTINTEL_PCIE_STATE_D0); =20 - if (err =3D=3D 0) { + if (err) { + bt_dev_err(data->hdev, "Failed to set D0 state (%d)", err); + } else { bt_dev_dbg(data->hdev, "device entered into d0 state from d3 in %lld us", ktime_to_us(ktime_get() - start)); @@ -4308,13 +4317,28 @@ static int btintel_pcie_resume(struct device *dev) return err; } =20 +static int btintel_pcie_resume(struct device *dev) +{ + return btintel_pcie_resume_event(dev, PMSG_RESUME); +} + +static int btintel_pcie_restore(struct device *dev) +{ + return btintel_pcie_resume_event(dev, PMSG_RESTORE); +} + +static int btintel_pcie_thaw(struct device *dev) +{ + return btintel_pcie_resume_event(dev, PMSG_THAW); +} + static const struct dev_pm_ops btintel_pcie_pm_ops =3D { .suspend =3D btintel_pcie_suspend, .resume =3D btintel_pcie_resume, .freeze =3D btintel_pcie_freeze, - .thaw =3D btintel_pcie_resume, + .thaw =3D btintel_pcie_thaw, .poweroff =3D btintel_pcie_hibernate, - .restore =3D btintel_pcie_resume, + .restore =3D btintel_pcie_restore, }; =20 static struct pci_driver btintel_pcie_driver =3D { diff --git a/drivers/bluetooth/btintel_pcie.h b/drivers/bluetooth/btintel_p= cie.h index 016795fcb..3030b4e8b 100644 --- a/drivers/bluetooth/btintel_pcie.h +++ b/drivers/bluetooth/btintel_pcie.h @@ -713,7 +713,6 @@ struct btintel_pcie_ini_dump_info { * @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; @@ -773,7 +772,6 @@ struct btintel_pcie_data { struct btintel_pcie_dbgc dbgc; struct btintel_pcie_mdbgc mdbgc; struct btintel_pcie_dump_header dmp_hdr; - u8 pm_sx_event; u32 debug_evt_addr; u32 debug_evt_size; dma_addr_t debug_table_addr; --=20 2.50.1 (Apple Git-155)