linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4] Fix SSR(SubSystem Restart) issues caused by BT_EN being pulled up by hardware
@ 2025-08-14 12:47 Shuai Zhang
  2025-08-14 12:47 ` [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw Shuai Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Shuai Zhang @ 2025-08-14 12:47 UTC (permalink / raw)
  To: linux-bluetooth, linux-arm-msm; +Cc: quic_bt, Shuai Zhang, linux-kernel

This patch series addresses issues encountered during SSR when
the BT_EN pin is pulled up by hardware. The main issues fixed are:

1. Timeout when sending reset command.
2. IBS state of host and controller not being synchronized.
3. Multiple triggers of SSR generating only one coredump file.
4. SSR process failed due to tx_idle_timer timeout

Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
---
To: Marcel Holtmann <marcel@holtmann.org>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: quic_bt@quicinc.com

---
Changes in v4:
- Update commit messages.
- Link to v3: https://lore.kernel.org/all/20250813033505.3868781-1-quic_shuaz@quicinc.com/
---

Shuai Zhang (4):
  driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw
  driver: bluetooth: hci_qca: fix host IBS state after SSR
  driver: bluetooth: hci_qca: Multiple triggers of SSR only generate one
    coredump file
  driver: bluetooth: hci_qca: SSR(SubSystem Restart)process failed due
    to tx_idle_timer timeout

 drivers/bluetooth/hci_qca.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw
  2025-08-14 12:47 [PATCH v4 0/4] Fix SSR(SubSystem Restart) issues caused by BT_EN being pulled up by hardware Shuai Zhang
@ 2025-08-14 12:47 ` Shuai Zhang
  2025-08-15 18:48   ` kernel test robot
  2025-08-15 21:48   ` Dmitry Baryshkov
  2025-08-14 12:47 ` [PATCH v4 2/4] driver: bluetooth: hci_qca: fix host IBS state after SSR Shuai Zhang
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Shuai Zhang @ 2025-08-14 12:47 UTC (permalink / raw)
  To: linux-bluetooth, linux-arm-msm; +Cc: quic_bt, Shuai Zhang

When the host actively triggers SSR and collects coredump data,
the Bluetooth stack sends a reset command to the controller. However,due
to the inability to clear the QCA_SSR_TRIGGERED and QCA_IBS_DISABLED bits,
the reset command times out.

For the purpose of HCI_QUIRK_NON_PERSISTENT_SETUP, please refer to
commit: 740011cfe94859df8d05f5400d589a8693b095e7.

The change is placed under if (!HCI_QUIRK_NON_PERSISTENT_SETUP)
because this quirk is associated with BT_EN, and can be used to
determine whether BT_EN is present in the device tree (DTS).

Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
---
 drivers/bluetooth/hci_qca.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 4e56782b0..91009c6a7 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1653,6 +1653,20 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code)
 		skb_queue_purge(&qca->rx_memdump_q);
 	}
 
+	/*
+	 * If the BT chip's bt_en pin is connected to a 3.3V power supply via
+	 * hardware and always stays high, driver cannot control the bt_en pin.
+	 * As a result, during SSR(SubSystem Restart), QCA_SSR_TRIGGERED and
+	 * QCA_IBS_DISABLED flags cannot be cleared, which leads to a reset
+	 * command timeout.
+	 * Add an msleep delay to ensure controller completes the SSR process.
+	 */
+	if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
+		clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
+		clear_bit(QCA_IBS_DISABLED, &qca->flags);
+		msleep(50);
+	}
+
 	clear_bit(QCA_HW_ERROR_EVENT, &qca->flags);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 2/4] driver: bluetooth: hci_qca: fix host IBS state after SSR
  2025-08-14 12:47 [PATCH v4 0/4] Fix SSR(SubSystem Restart) issues caused by BT_EN being pulled up by hardware Shuai Zhang
  2025-08-14 12:47 ` [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw Shuai Zhang
@ 2025-08-14 12:47 ` Shuai Zhang
  2025-08-15 21:50   ` Dmitry Baryshkov
  2025-08-14 12:47 ` [PATCH v4 3/4] driver: bluetooth: hci_qca: Multiple triggers of SSR only generate one coredump file Shuai Zhang
  2025-08-14 12:47 ` [PATCH v4 4/4] driver: bluetooth: hci_qca: SSR(SubSystem Restart)process failed due to tx_idle_timer timeout Shuai Zhang
  3 siblings, 1 reply; 11+ messages in thread
From: Shuai Zhang @ 2025-08-14 12:47 UTC (permalink / raw)
  To: linux-bluetooth, linux-arm-msm; +Cc: quic_bt, Shuai Zhang

After SSR, host will not download the firmware, causing
controller to remain in the IBS_WAKE state. Host needs
to synchronize with the controller to maintain proper operation.

Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
---
 drivers/bluetooth/hci_qca.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 91009c6a7..d37cd2368 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1660,10 +1660,14 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code)
 	 * QCA_IBS_DISABLED flags cannot be cleared, which leads to a reset
 	 * command timeout.
 	 * Add an msleep delay to ensure controller completes the SSR process.
+	 *
+	 * Host will not download the firmware after SSR, controller to remain
+	 * in the IBS_WAKE state, and the host needs to synchronize with it
 	 */
 	if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
 		clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
 		clear_bit(QCA_IBS_DISABLED, &qca->flags);
+		qca->tx_ibs_state = HCI_IBS_TX_AWAKE;
 		msleep(50);
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 3/4] driver: bluetooth: hci_qca: Multiple triggers of SSR only generate one coredump file
  2025-08-14 12:47 [PATCH v4 0/4] Fix SSR(SubSystem Restart) issues caused by BT_EN being pulled up by hardware Shuai Zhang
  2025-08-14 12:47 ` [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw Shuai Zhang
  2025-08-14 12:47 ` [PATCH v4 2/4] driver: bluetooth: hci_qca: fix host IBS state after SSR Shuai Zhang
@ 2025-08-14 12:47 ` Shuai Zhang
  2025-08-14 12:47 ` [PATCH v4 4/4] driver: bluetooth: hci_qca: SSR(SubSystem Restart)process failed due to tx_idle_timer timeout Shuai Zhang
  3 siblings, 0 replies; 11+ messages in thread
From: Shuai Zhang @ 2025-08-14 12:47 UTC (permalink / raw)
  To: linux-bluetooth, linux-arm-msm; +Cc: quic_bt, Shuai Zhang

Multiple triggers of SSR only first generate coredump file,
duo to memcoredump_flag no clear.

add clear coredump flag when ssr completed.

Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
---
 drivers/bluetooth/hci_qca.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index d37cd2368..1f7c1d621 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1663,11 +1663,14 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code)
 	 *
 	 * Host will not download the firmware after SSR, controller to remain
 	 * in the IBS_WAKE state, and the host needs to synchronize with it
+	 *
+	 * Since the bluetooth chip has been reset, clear the memdump state.
 	 */
 	if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
 		clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
 		clear_bit(QCA_IBS_DISABLED, &qca->flags);
 		qca->tx_ibs_state = HCI_IBS_TX_AWAKE;
+		qca->memdump_state = QCA_MEMDUMP_IDLE;
 		msleep(50);
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 4/4] driver: bluetooth: hci_qca: SSR(SubSystem Restart)process failed due to tx_idle_timer timeout
  2025-08-14 12:47 [PATCH v4 0/4] Fix SSR(SubSystem Restart) issues caused by BT_EN being pulled up by hardware Shuai Zhang
                   ` (2 preceding siblings ...)
  2025-08-14 12:47 ` [PATCH v4 3/4] driver: bluetooth: hci_qca: Multiple triggers of SSR only generate one coredump file Shuai Zhang
@ 2025-08-14 12:47 ` Shuai Zhang
  3 siblings, 0 replies; 11+ messages in thread
From: Shuai Zhang @ 2025-08-14 12:47 UTC (permalink / raw)
  To: linux-bluetooth, linux-arm-msm; +Cc: quic_bt, Shuai Zhang

When the SSR (Sub-System Restart) duration exceeds 2 seconds, it triggers
host tx_idle_timeout, which sets host TX state to sleep. due to the
hardware pulling up bt_en, the firmware is not downloaded after the SSR.
As a result, the controller does not enter sleep mode. Consequently,
when the host sends a command afterward, it sends 0xFD to the controller,
but the controller does not respond, leading to a command timeout.

So reset tx_idle_timer after SSR to prevent host enter TX IBS_Sloeep mode.

Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
---
 drivers/bluetooth/hci_qca.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 1f7c1d621..660be5e11 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1669,6 +1669,15 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code)
 	if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
 		clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
 		clear_bit(QCA_IBS_DISABLED, &qca->flags);
+		/*
+		 * When the SSR (Sub-System Restart) duration exceeds 2 seconds,
+		 * it triggers host tx_idle_delay, which sets host TX state
+		 * to sleep. Reset tx_idle_timer after SSR to prevent
+		 * host enter TX IBS_Sloeep mode.
+		 */
+		mod_timer(&qca->tx_idle_timer, jiffies +
+				  msecs_to_jiffies(qca->tx_idle_delay));
+
 		qca->tx_ibs_state = HCI_IBS_TX_AWAKE;
 		qca->memdump_state = QCA_MEMDUMP_IDLE;
 		msleep(50);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw
  2025-08-14 12:47 ` [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw Shuai Zhang
@ 2025-08-15 18:48   ` kernel test robot
  2025-08-15 21:48   ` Dmitry Baryshkov
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2025-08-15 18:48 UTC (permalink / raw)
  To: Shuai Zhang, linux-bluetooth, linux-arm-msm
  Cc: oe-kbuild-all, quic_bt, Shuai Zhang

Hi Shuai,

kernel test robot noticed the following build errors:

[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on bluetooth/master linus/master v6.17-rc1 next-20250815]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shuai-Zhang/driver-bluetooth-hci_qca-fix-ssr-fail-when-BT_EN-is-pulled-up-by-hw/20250814-205127
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
patch link:    https://lore.kernel.org/r/20250814124704.2531811-2-quic_shuaz%40quicinc.com
patch subject: [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw
config: arc-allmodconfig (https://download.01.org/0day-ci/archive/20250816/202508160256.bnZz7iPY-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/202508160256.bnZz7iPY-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508160256.bnZz7iPY-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/kernel.h:23,
                    from drivers/bluetooth/hci_qca.c:18:
   drivers/bluetooth/hci_qca.c: In function 'qca_hw_error':
>> drivers/bluetooth/hci_qca.c:1664:60: error: 'struct hci_dev' has no member named 'quirks'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |                                                            ^~
   include/linux/bitops.h:44:44: note: in definition of macro 'bitop'
      44 |           __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \
         |                                            ^~~~
   drivers/bluetooth/hci_qca.c:1664:14: note: in expansion of macro 'test_bit'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |              ^~~~~~~~
>> drivers/bluetooth/hci_qca.c:1664:60: error: 'struct hci_dev' has no member named 'quirks'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |                                                            ^~
   include/linux/bitops.h:45:23: note: in definition of macro 'bitop'
      45 |           (uintptr_t)(addr) != (uintptr_t)NULL &&                       \
         |                       ^~~~
   drivers/bluetooth/hci_qca.c:1664:14: note: in expansion of macro 'test_bit'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |              ^~~~~~~~
>> drivers/bluetooth/hci_qca.c:1664:60: error: 'struct hci_dev' has no member named 'quirks'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |                                                            ^~
   include/linux/bitops.h:46:57: note: in definition of macro 'bitop'
      46 |           __builtin_constant_p(*(const unsigned long *)(addr))) ?       \
         |                                                         ^~~~
   drivers/bluetooth/hci_qca.c:1664:14: note: in expansion of macro 'test_bit'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |              ^~~~~~~~
>> drivers/bluetooth/hci_qca.c:1664:60: error: 'struct hci_dev' has no member named 'quirks'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |                                                            ^~
   include/linux/bitops.h:47:24: note: in definition of macro 'bitop'
      47 |          const##op(nr, addr) : op(nr, addr))
         |                        ^~~~
   drivers/bluetooth/hci_qca.c:1664:14: note: in expansion of macro 'test_bit'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |              ^~~~~~~~
>> drivers/bluetooth/hci_qca.c:1664:60: error: 'struct hci_dev' has no member named 'quirks'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |                                                            ^~
   include/linux/bitops.h:47:39: note: in definition of macro 'bitop'
      47 |          const##op(nr, addr) : op(nr, addr))
         |                                       ^~~~
   drivers/bluetooth/hci_qca.c:1664:14: note: in expansion of macro 'test_bit'
    1664 |         if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
         |              ^~~~~~~~


vim +1664 drivers/bluetooth/hci_qca.c

  1609	
  1610	static void qca_hw_error(struct hci_dev *hdev, u8 code)
  1611	{
  1612		struct hci_uart *hu = hci_get_drvdata(hdev);
  1613		struct qca_data *qca = hu->priv;
  1614	
  1615		set_bit(QCA_SSR_TRIGGERED, &qca->flags);
  1616		set_bit(QCA_HW_ERROR_EVENT, &qca->flags);
  1617		bt_dev_info(hdev, "mem_dump_status: %d", qca->memdump_state);
  1618	
  1619		if (qca->memdump_state == QCA_MEMDUMP_IDLE) {
  1620			/* If hardware error event received for other than QCA
  1621			 * soc memory dump event, then we need to crash the SOC
  1622			 * and wait here for 8 seconds to get the dump packets.
  1623			 * This will block main thread to be on hold until we
  1624			 * collect dump.
  1625			 */
  1626			set_bit(QCA_MEMDUMP_COLLECTION, &qca->flags);
  1627			qca_send_crashbuffer(hu);
  1628			qca_wait_for_dump_collection(hdev);
  1629		} else if (qca->memdump_state == QCA_MEMDUMP_COLLECTING) {
  1630			/* Let us wait here until memory dump collected or
  1631			 * memory dump timer expired.
  1632			 */
  1633			bt_dev_info(hdev, "waiting for dump to complete");
  1634			qca_wait_for_dump_collection(hdev);
  1635		}
  1636	
  1637		mutex_lock(&qca->hci_memdump_lock);
  1638		if (qca->memdump_state != QCA_MEMDUMP_COLLECTED) {
  1639			bt_dev_err(hu->hdev, "clearing allocated memory due to memdump timeout");
  1640			hci_devcd_abort(hu->hdev);
  1641			if (qca->qca_memdump) {
  1642				kfree(qca->qca_memdump);
  1643				qca->qca_memdump = NULL;
  1644			}
  1645			qca->memdump_state = QCA_MEMDUMP_TIMEOUT;
  1646			cancel_delayed_work(&qca->ctrl_memdump_timeout);
  1647		}
  1648		mutex_unlock(&qca->hci_memdump_lock);
  1649	
  1650		if (qca->memdump_state == QCA_MEMDUMP_TIMEOUT ||
  1651		    qca->memdump_state == QCA_MEMDUMP_COLLECTED) {
  1652			cancel_work_sync(&qca->ctrl_memdump_evt);
  1653			skb_queue_purge(&qca->rx_memdump_q);
  1654		}
  1655	
  1656		/*
  1657		 * If the BT chip's bt_en pin is connected to a 3.3V power supply via
  1658		 * hardware and always stays high, driver cannot control the bt_en pin.
  1659		 * As a result, during SSR(SubSystem Restart), QCA_SSR_TRIGGERED and
  1660		 * QCA_IBS_DISABLED flags cannot be cleared, which leads to a reset
  1661		 * command timeout.
  1662		 * Add an msleep delay to ensure controller completes the SSR process.
  1663		 */
> 1664		if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
  1665			clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
  1666			clear_bit(QCA_IBS_DISABLED, &qca->flags);
  1667			msleep(50);
  1668		}
  1669	
  1670		clear_bit(QCA_HW_ERROR_EVENT, &qca->flags);
  1671	}
  1672	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw
  2025-08-14 12:47 ` [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw Shuai Zhang
  2025-08-15 18:48   ` kernel test robot
@ 2025-08-15 21:48   ` Dmitry Baryshkov
  2025-08-19  3:34     ` Shuai Zhang
  1 sibling, 1 reply; 11+ messages in thread
From: Dmitry Baryshkov @ 2025-08-15 21:48 UTC (permalink / raw)
  To: Shuai Zhang; +Cc: linux-bluetooth, linux-arm-msm, quic_bt

On Thu, Aug 14, 2025 at 08:47:01PM +0800, Shuai Zhang wrote:

I wonder what does it make to notice the part of the BT test report:

SubjectPrefix                 FAIL      0.66 seconds

and update log messages according to the custom of the BT subsystem?

Please use 'git log drivers/bluetooth/hci_qca.c' if you are unsure.

> When the host actively triggers SSR and collects coredump data,
> the Bluetooth stack sends a reset command to the controller. However,due
> to the inability to clear the QCA_SSR_TRIGGERED and QCA_IBS_DISABLED bits,
> the reset command times out.
> 
> For the purpose of HCI_QUIRK_NON_PERSISTENT_SETUP, please refer to
> commit: 740011cfe94859df8d05f5400d589a8693b095e7.

commit 740011cfe948 ("Bluetooth: Add new quirk for non-persistent setup
settings")

> 
> The change is placed under if (!HCI_QUIRK_NON_PERSISTENT_SETUP)

Which change? You've described the issue, but you didn't describe what
is to be done.

> because this quirk is associated with BT_EN, and can be used to
> determine whether BT_EN is present in the device tree (DTS).

What can be 'used to determine....' ?

> 
> Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
> ---
>  drivers/bluetooth/hci_qca.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 4e56782b0..91009c6a7 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1653,6 +1653,20 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code)
>  		skb_queue_purge(&qca->rx_memdump_q);
>  	}
>  
> +	/*
> +	 * If the BT chip's bt_en pin is connected to a 3.3V power supply via
> +	 * hardware and always stays high, driver cannot control the bt_en pin.
> +	 * As a result, during SSR(SubSystem Restart), QCA_SSR_TRIGGERED and
> +	 * QCA_IBS_DISABLED flags cannot be cleared, which leads to a reset
> +	 * command timeout.
> +	 * Add an msleep delay to ensure controller completes the SSR process.
> +	 */
> +	if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
> +		clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
> +		clear_bit(QCA_IBS_DISABLED, &qca->flags);
> +		msleep(50);

It should be done other way around: first sleep, then clear bits.
Otherwise userspace might start sending SKBs while the BT is still
recovering.

> +	}
> +
>  	clear_bit(QCA_HW_ERROR_EVENT, &qca->flags);
>  }
-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4 2/4] driver: bluetooth: hci_qca: fix host IBS state after SSR
  2025-08-14 12:47 ` [PATCH v4 2/4] driver: bluetooth: hci_qca: fix host IBS state after SSR Shuai Zhang
@ 2025-08-15 21:50   ` Dmitry Baryshkov
  2025-08-19  3:38     ` Shuai Zhang
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Baryshkov @ 2025-08-15 21:50 UTC (permalink / raw)
  To: Shuai Zhang; +Cc: linux-bluetooth, linux-arm-msm, quic_bt

On Thu, Aug 14, 2025 at 08:47:02PM +0800, Shuai Zhang wrote:
> After SSR, host will not download the firmware, causing
> controller to remain in the IBS_WAKE state. Host needs
> to synchronize with the controller to maintain proper operation.

It totally feels like all these patches fix the same issue and should be
squashed together. Please also add a sensible Fixes: tag. Possibly
add cc:stable too.

> 
> Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
> ---
>  drivers/bluetooth/hci_qca.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 91009c6a7..d37cd2368 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1660,10 +1660,14 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code)
>  	 * QCA_IBS_DISABLED flags cannot be cleared, which leads to a reset
>  	 * command timeout.
>  	 * Add an msleep delay to ensure controller completes the SSR process.
> +	 *
> +	 * Host will not download the firmware after SSR, controller to remain
> +	 * in the IBS_WAKE state, and the host needs to synchronize with it
>  	 */
>  	if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
>  		clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
>  		clear_bit(QCA_IBS_DISABLED, &qca->flags);
> +		qca->tx_ibs_state = HCI_IBS_TX_AWAKE;
>  		msleep(50);
>  	}
>  
> -- 
> 2.34.1
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw
  2025-08-15 21:48   ` Dmitry Baryshkov
@ 2025-08-19  3:34     ` Shuai Zhang
  0 siblings, 0 replies; 11+ messages in thread
From: Shuai Zhang @ 2025-08-19  3:34 UTC (permalink / raw)
  To: Dmitry Baryshkov; +Cc: linux-bluetooth, linux-arm-msm, quic_bt

Hi Dmitry 

On 8/16/2025 5:48 AM, Dmitry Baryshkov wrote:
> On Thu, Aug 14, 2025 at 08:47:01PM +0800, Shuai Zhang wrote:
> 
> I wonder what does it make to notice the part of the BT test report:
> 
> SubjectPrefix                 FAIL      0.66 seconds
> 
> and update log messages according to the custom of the BT subsystem?
> 
> Please use 'git log drivers/bluetooth/hci_qca.c' if you are unsure.
> 
>> When the host actively triggers SSR and collects coredump data,
>> the Bluetooth stack sends a reset command to the controller. However,due
>> to the inability to clear the QCA_SSR_TRIGGERED and QCA_IBS_DISABLED bits,
>> the reset command times out.
>>
>> For the purpose of HCI_QUIRK_NON_PERSISTENT_SETUP, please refer to
>> commit: 740011cfe94859df8d05f5400d589a8693b095e7.
> 
> commit 740011cfe948 ("Bluetooth: Add new quirk for non-persistent setup
> settings")
> 
>>
>> The change is placed under if (!HCI_QUIRK_NON_PERSISTENT_SETUP)
> 
> Which change? You've described the issue, but you didn't describe what
> is to be done.
> 
>> because this quirk is associated with BT_EN, and can be used to
>> determine whether BT_EN is present in the device tree (DTS).
> 
> What can be 'used to determine....' ?
> 
>>
>> Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
>> ---
>>  drivers/bluetooth/hci_qca.c | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>> index 4e56782b0..91009c6a7 100644
>> --- a/drivers/bluetooth/hci_qca.c
>> +++ b/drivers/bluetooth/hci_qca.c
>> @@ -1653,6 +1653,20 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code)
>>  		skb_queue_purge(&qca->rx_memdump_q);
>>  	}
>>  
>> +	/*
>> +	 * If the BT chip's bt_en pin is connected to a 3.3V power supply via
>> +	 * hardware and always stays high, driver cannot control the bt_en pin.
>> +	 * As a result, during SSR(SubSystem Restart), QCA_SSR_TRIGGERED and
>> +	 * QCA_IBS_DISABLED flags cannot be cleared, which leads to a reset
>> +	 * command timeout.
>> +	 * Add an msleep delay to ensure controller completes the SSR process.
>> +	 */
>> +	if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
>> +		clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
>> +		clear_bit(QCA_IBS_DISABLED, &qca->flags);
>> +		msleep(50);
> 
> It should be done other way around: first sleep, then clear bits.
> Otherwise userspace might start sending SKBs while the BT is still
> recovering.
> 
>> +	}
>> +
>>  	clear_bit(QCA_HW_ERROR_EVENT, &qca->flags);
>>  }

Thank you for your suggestion. I will update accordingly.

BR,
Shuai

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4 2/4] driver: bluetooth: hci_qca: fix host IBS state after SSR
  2025-08-15 21:50   ` Dmitry Baryshkov
@ 2025-08-19  3:38     ` Shuai Zhang
  2025-08-19  7:51       ` Dmitry Baryshkov
  0 siblings, 1 reply; 11+ messages in thread
From: Shuai Zhang @ 2025-08-19  3:38 UTC (permalink / raw)
  To: Dmitry Baryshkov; +Cc: linux-bluetooth, linux-arm-msm, quic_bt

Hi Dmitry 

On 8/16/2025 5:50 AM, Dmitry Baryshkov wrote:
> On Thu, Aug 14, 2025 at 08:47:02PM +0800, Shuai Zhang wrote:
>> After SSR, host will not download the firmware, causing
>> controller to remain in the IBS_WAKE state. Host needs
>> to synchronize with the controller to maintain proper operation.
> 
> It totally feels like all these patches fix the same issue and should be
> squashed together. Please also add a sensible Fixes: tag. Possibly
> add cc:stable too.

Although these issues are all related to SSR, the underlying causes of the
errors are different. Would it be appropriate to merge them into one patch?

> 
>>
>> Signed-off-by: Shuai Zhang <quic_shuaz@quicinc.com>
>> ---
>>  drivers/bluetooth/hci_qca.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>> index 91009c6a7..d37cd2368 100644
>> --- a/drivers/bluetooth/hci_qca.c
>> +++ b/drivers/bluetooth/hci_qca.c
>> @@ -1660,10 +1660,14 @@ static void qca_hw_error(struct hci_dev *hdev, u8 code)
>>  	 * QCA_IBS_DISABLED flags cannot be cleared, which leads to a reset
>>  	 * command timeout.
>>  	 * Add an msleep delay to ensure controller completes the SSR process.
>> +	 *
>> +	 * Host will not download the firmware after SSR, controller to remain
>> +	 * in the IBS_WAKE state, and the host needs to synchronize with it
>>  	 */
>>  	if (!test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
>>  		clear_bit(QCA_SSR_TRIGGERED, &qca->flags);
>>  		clear_bit(QCA_IBS_DISABLED, &qca->flags);
>> +		qca->tx_ibs_state = HCI_IBS_TX_AWAKE;
>>  		msleep(50);
>>  	}
>>  
>> -- 
>> 2.34.1
>>
> 

BR,
Shuai

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4 2/4] driver: bluetooth: hci_qca: fix host IBS state after SSR
  2025-08-19  3:38     ` Shuai Zhang
@ 2025-08-19  7:51       ` Dmitry Baryshkov
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Baryshkov @ 2025-08-19  7:51 UTC (permalink / raw)
  To: Shuai Zhang; +Cc: linux-bluetooth, linux-arm-msm, quic_bt

On Tue, Aug 19, 2025 at 11:38:01AM +0800, Shuai Zhang wrote:
> Hi Dmitry 
> 
> On 8/16/2025 5:50 AM, Dmitry Baryshkov wrote:
> > On Thu, Aug 14, 2025 at 08:47:02PM +0800, Shuai Zhang wrote:
> >> After SSR, host will not download the firmware, causing
> >> controller to remain in the IBS_WAKE state. Host needs
> >> to synchronize with the controller to maintain proper operation.
> > 
> > It totally feels like all these patches fix the same issue and should be
> > squashed together. Please also add a sensible Fixes: tag. Possibly
> > add cc:stable too.
> 
> Although these issues are all related to SSR, the underlying causes of the
> errors are different. Would it be appropriate to merge them into one patch?
> 

I think so.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-08-19  7:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 12:47 [PATCH v4 0/4] Fix SSR(SubSystem Restart) issues caused by BT_EN being pulled up by hardware Shuai Zhang
2025-08-14 12:47 ` [PATCH v4 1/4] driver: bluetooth: hci_qca: fix ssr fail when BT_EN is pulled up by hw Shuai Zhang
2025-08-15 18:48   ` kernel test robot
2025-08-15 21:48   ` Dmitry Baryshkov
2025-08-19  3:34     ` Shuai Zhang
2025-08-14 12:47 ` [PATCH v4 2/4] driver: bluetooth: hci_qca: fix host IBS state after SSR Shuai Zhang
2025-08-15 21:50   ` Dmitry Baryshkov
2025-08-19  3:38     ` Shuai Zhang
2025-08-19  7:51       ` Dmitry Baryshkov
2025-08-14 12:47 ` [PATCH v4 3/4] driver: bluetooth: hci_qca: Multiple triggers of SSR only generate one coredump file Shuai Zhang
2025-08-14 12:47 ` [PATCH v4 4/4] driver: bluetooth: hci_qca: SSR(SubSystem Restart)process failed due to tx_idle_timer timeout Shuai Zhang

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).