Firmware raises an alive interrupt upon receiving the 0xfc01 (Intel
reset) command. This change fixes the driver to properly wait for the
alive interrupt.
Signed-off-by: Sai Teja Aluvala <redacted>
Signed-off-by: Kiran K <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
---
drivers/bluetooth/btintel_pcie.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
Firmware raises alive interrpt on sending 0xfc01 command. Alive context
maintained in driver needs to be updated before sending 0xfc01 (Intel
Reset) or 0x03c0 (HCI Reset) to avoid the potential race condition where
the context is also updated in threaded irq.
Signed-off-by: Kiran K <redacted>
Signed-off-by: Sai Teja Aluvala <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
---
drivers/bluetooth/btintel_pcie.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
From: Paul Menzel <hidden> Date: 2025-07-07 06:08:13
Dear Sai, dear Kiran,
Thank you for your patch.
Am 07.07.25 um 05:46 schrieb Kiran K:
Firmware raises an alive interrupt upon receiving the 0xfc01 (Intel
reset) command. This change fixes the driver to properly wait for the
alive interrupt.
What is the consequence of not waiting?
quoted hunk
Signed-off-by: Sai Teja Aluvala <redacted>
Signed-off-by: Kiran K <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
---
drivers/bluetooth/btintel_pcie.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
From: Paul Menzel <hidden> Date: 2025-07-07 06:15:57
Dear Kiran, dear Sai,
Thank you for the patch.
Am 07.07.25 um 05:46 schrieb Kiran K:
Firmware raises alive interrpt on sending 0xfc01 command. Alive context
interr*u*pt
(I would have hoped, two developers would spot such a typo, a spell checker also highlights.)
maintained in driver needs to be updated before sending 0xfc01 (Intel
Reset) or 0x03c0 (HCI Reset) to avoid the potential race condition where
the context is also updated in threaded irq.
Do you have a reproducer for the issue?
Signed-off-by: Kiran K <redacted>
Signed-off-by: Sai Teja Aluvala <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
I’d add the Fixes tag before the Signed-off-by lines.
Subject: Re: [PATCH v1 1/2] Bluetooth: btintel_pcie: Make driver wait for alive
interrupt
Dear Sai, dear Kiran,
Thank you for your patch.
Am 07.07.25 um 05:46 schrieb Kiran K:
quoted
Firmware raises an alive interrupt upon receiving the 0xfc01 (Intel
reset) command. This change fixes the driver to properly wait for the
alive interrupt.
What is the consequence of not waiting?
This is an alignment between driver and firmware. If driver doesn’t wait for alive interrupt, then there is chance of stack sending commands before the firmware is ready to accept.
quoted
Signed-off-by: Sai Teja Aluvala <redacted>
Signed-off-by: Kiran K <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between
driver and firmware")
---
drivers/bluetooth/btintel_pcie.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c
b/drivers/bluetooth/btintel_pcie.c
index 1113a6310bd0..f893ad6fc87a 100644
case BTINTEL_PCIE_INTEL_HCI_RESET1: if (btintel_pcie_in_op(data)) { submit_rx = true;+ signal_waitq = true; break; } if (btintel_pcie_in_iml(data)) { submit_rx = true;+ signal_waitq = true; data->alive_intr_ctxt = BTINTEL_PCIE_FW_DL; break; }
@@ -1985,8 +1987,9 @@ static int btintel_pcie_send_frame(struct hci_dev
*hdev,
quoted
if (opcode == 0xfc01)
btintel_pcie_inject_cmd_complete(hdev,
opcode);
quoted
}- /* Firmware raises alive interrupt on HCI_OP_RESET */- if (opcode == HCI_OP_RESET)++ /* Firmware raises alive interrupt on HCI_OP_RESET or
0xfc01*/
A space is missing before */.
Ack.
quoted
+ if (opcode == HCI_OP_RESET || opcode == 0xfc01)
Please define a macro for the magic number.
This is vendor specific opcode and is also shared across btintel.c, btusb.c and hci_intel.c. Would it be acceptable to submit a separate patch for this change alone?
quoted
data->gp0_received = false;
hdev->stat.cmd_tx++;
@@ -2025,17 +2028,15 @@ static int btintel_pcie_send_frame(struct hci_dev
+ if (!ret) {
+ hdev->stat.err_tx++;
+ bt_dev_err(hdev, "No alive interrupt received for %s",
+ btintel_pcie_alivectxt_state2str(data-
alive_intr_ctxt));
In a follow-up patch, the log message could be improved by also adding the
timeout value to it.
Subject: Re: [PATCH v1 2/2] Bluetooth: btintel_pcie: Fix alive context state
handling
Dear Kiran, dear Sai,
Thank you for the patch.
Am 07.07.25 um 05:46 schrieb Kiran K:
quoted
Firmware raises alive interrpt on sending 0xfc01 command. Alive
context
interr*u*pt
(I would have hoped, two developers would spot such a typo, a spell checker
also highlights.)
Ack. Unfortunately 'interrpt' was missing in my codespell dictionary. I have updated the same. Thanks.
quoted
maintained in driver needs to be updated before sending 0xfc01 (Intel
Reset) or 0x03c0 (HCI Reset) to avoid the potential race condition
where the context is also updated in threaded irq.
Do you have a reproducer for the issue?
Yes. Issue was reproduced in stress reboot scenario although reproduction rate is less - 1/25.
quoted
Signed-off-by: Kiran K <redacted>
Signed-off-by: Sai Teja Aluvala <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between
driver and firmware")
I’d add the Fixes tag before the Signed-off-by lines.
From: Paul Menzel <hidden> Date: 2025-07-08 18:27:35
Dear Kiran,
Am 08.07.25 um 14:23 schrieb K, Kiran:
quoted
Subject: Re: [PATCH v1 1/2] Bluetooth: btintel_pcie: Make driver wait for alive interrupt
quoted
Am 07.07.25 um 05:46 schrieb Kiran K:
quoted
Firmware raises an alive interrupt upon receiving the 0xfc01 (Intel
reset) command. This change fixes the driver to properly wait for the
alive interrupt.
What is the consequence of not waiting?
This is an alignment between driver and firmware. If driver doesn’t
wait for alive interrupt, then there is chance of stack sending
commands before the firmware is ready to accept.
Thank you for elaborating. It’d be great if you added it to the commit message, when you resend.
quoted
quoted
Signed-off-by: Sai Teja Aluvala <redacted>
Signed-off-by: Kiran K <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
I would also put the Fixes: tag above the Signed-off-by line.
@@ -1985,8 +1987,9 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,if(opcode==0xfc01)btintel_pcie_inject_cmd_complete(hdev,opcode);}-/* Firmware raises alive interrupt on HCI_OP_RESET */-if(opcode==HCI_OP_RESET)++/* Firmware raises alive interrupt on HCI_OP_RESET or 0xfc01*/
A space is missing before */.
Ack.
quoted
quoted
+ if (opcode == HCI_OP_RESET || opcode == 0xfc01)
Please define a macro for the magic number.
This is vendor specific opcode and is also shared across btintel.c,
btusb.c and hci_intel.c. Would it be acceptable to submit a separate
patch for this change alone?
Sure. Fine by me.
quoted
quoted
data->gp0_received = false;
hdev->stat.cmd_tx++;
@@ -2025,17 +2028,15 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev, bt_dev_dbg(data->hdev, "sent cmd: 0x%4.4x alive context changed: %s -> %s", opcode, btintel_pcie_alivectxt_state2str(old_ctxt), btintel_pcie_alivectxt_state2str(data - alive_intr_ctxt));- if (opcode == HCI_OP_RESET) {- ret = wait_event_timeout(data->gp0_wait_q,- data->gp0_received,- msecs_to_jiffies(BTINTEL_DEFAULT_INTR_TIMEOUT_MS));- if (!ret) {- hdev->stat.err_tx++;- bt_dev_err(hdev, "No alive interrupt received for %s",- btintel_pcie_alivectxt_state2str(data->alive_intr_ctxt));- ret = -ETIME;- goto exit_error;- }+ ret = wait_event_timeout(data->gp0_wait_q,+ data->gp0_received,+ msecs_to_jiffies(BTINTEL_DEFAULT_INTR_TIMEOUT_MS));+ if (!ret) {+ hdev->stat.err_tx++;+ bt_dev_err(hdev, "No alive interrupt received for %s",+ btintel_pcie_alivectxt_state2str(data->alive_intr_ctxt));
In a follow-up patch, the log message could be improved by also adding the
timeout value to it.
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: 2025-07-08 20:31:13
Hi Kiran,
On Sun, Jul 6, 2025 at 11:30 PM Kiran K [off-list ref] wrote:
Firmware raises alive interrpt on sending 0xfc01 command. Alive context
maintained in driver needs to be updated before sending 0xfc01 (Intel
Reset) or 0x03c0 (HCI Reset) to avoid the potential race condition where
the context is also updated in threaded irq.
This should be a little more specific, like explaining what is alive
interrupt supposed to mean or if we cannot do any communication wheel
these are pending?
quoted hunk
Signed-off-by: Kiran K <redacted>
Signed-off-by: Sai Teja Aluvala <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
---
drivers/bluetooth/btintel_pcie.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
@@ -1988,10 +1988,6 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,btintel_pcie_inject_cmd_complete(hdev,opcode);}-/* Firmware raises alive interrupt on HCI_OP_RESET or 0xfc01*/-if(opcode==HCI_OP_RESET||opcode==0xfc01)-data->gp0_received=false;-hdev->stat.cmd_tx++;break;caseHCI_ACLDATA_PKT:
@@ -2012,6 +2008,20 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,memcpy(skb_push(skb,BTINTEL_PCIE_HCI_TYPE_LEN),&type,BTINTEL_PCIE_HCI_TYPE_LEN);+if(type==BTINTEL_PCIE_HCI_CMD_PKT){+/* Firmware raises alive interrupt on HCI_OP_RESET or 0xfc01*/+if(opcode==HCI_OP_RESET||opcode==0xfc01){+data->gp0_received=false;
This type of flags should really be made into atomic flags so they can
be checked atomically, anyway this shouldn't block these fixes but
something I very much look forward to be changed.
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Date: 2025-07-08 20:51:26
Hi Kiran,
On Sun, Jul 6, 2025 at 11:30 PM Kiran K [off-list ref] wrote:
quoted hunk
Firmware raises an alive interrupt upon receiving the 0xfc01 (Intel
reset) command. This change fixes the driver to properly wait for the
alive interrupt.
Signed-off-by: Sai Teja Aluvala <redacted>
Signed-off-by: Kiran K <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
---
drivers/bluetooth/btintel_pcie.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
@@ -1985,8 +1987,9 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,if(opcode==0xfc01)btintel_pcie_inject_cmd_complete(hdev,opcode);}-/* Firmware raises alive interrupt on HCI_OP_RESET */-if(opcode==HCI_OP_RESET)++/* Firmware raises alive interrupt on HCI_OP_RESET or 0xfc01*/+if(opcode==HCI_OP_RESET||opcode==0xfc01)data->gp0_received=false;hdev->stat.cmd_tx++;
@@ -2025,17 +2028,15 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,bt_dev_dbg(data->hdev,"sent cmd: 0x%4.4x alive context changed: %s -> %s",opcode,btintel_pcie_alivectxt_state2str(old_ctxt),btintel_pcie_alivectxt_state2str(data->alive_intr_ctxt));-if(opcode==HCI_OP_RESET){-ret=wait_event_timeout(data->gp0_wait_q,-data->gp0_received,-msecs_to_jiffies(BTINTEL_DEFAULT_INTR_TIMEOUT_MS));-if(!ret){-hdev->stat.err_tx++;-bt_dev_err(hdev,"No alive interrupt received for %s",-btintel_pcie_alivectxt_state2str(data->alive_intr_ctxt));-ret=-ETIME;-gotoexit_error;-}+ret=wait_event_timeout(data->gp0_wait_q,+data->gp0_received,+msecs_to_jiffies(BTINTEL_DEFAULT_INTR_TIMEOUT_MS));+if(!ret){+hdev->stat.err_tx++;+bt_dev_err(hdev,"No alive interrupt received for %s",+btintel_pcie_alivectxt_state2str(data->alive_intr_ctxt));+ret=-ETIME;+gotoexit_error;
This should probably go into btintel_pcie_send_sync instead of doing a
post handling as above, also if I read this right then we have to wait
on 2 interrupts when it comes to HCI_Reset and 0xfc01?
btintel_pcie_send_sync already waits on URBD0 this also adds GP0,
having 2 interrupts means proper ordering needs to be enforced,
otherwise if GP0 happens before URBD0 this will probably timeout, if
this is done on purpose let document why we think it is ok to do it.
Firmware raises alive interrpt on sending 0xfc01 command. Alive context
interr*u*pt
(I would have hoped, two developers would spot such a typo, a spell checker
also highlights.)
Ack. Unfortunately 'interrpt' was missing in my codespell
dictionary. I have updated the same. Thanks.
hunspell or a/ispell should find it by defautl.
quoted
quoted
maintained in driver needs to be updated before sending 0xfc01 (Intel
Reset) or 0x03c0 (HCI Reset) to avoid the potential race condition
where the context is also updated in threaded irq.
Do you have a reproducer for the issue?
Yes. Issue was reproduced in stress reboot scenario although reproduction rate is less - 1/25.
It’d be great if you added that to the commit message, and what scripts/commands you run for this stress reboot scenario.
quoted
quoted
Signed-off-by: Kiran K <redacted>
Signed-off-by: Sai Teja Aluvala <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware")
I’d add the Fixes tag before the Signed-off-by lines.
Subject: Re: [PATCH v1 1/2] Bluetooth: btintel_pcie: Make driver wait for alive
interrupt
Dear Kiran,
Am 08.07.25 um 14:23 schrieb K, Kiran:
quoted
quoted
Subject: Re: [PATCH v1 1/2] Bluetooth: btintel_pcie: Make driver wait
for alive interrupt
quoted
quoted
Am 07.07.25 um 05:46 schrieb Kiran K:
quoted
Firmware raises an alive interrupt upon receiving the 0xfc01 (Intel
reset) command. This change fixes the driver to properly wait for
the alive interrupt.
What is the consequence of not waiting?
This is an alignment between driver and firmware. If driver doesn’t
wait for alive interrupt, then there is chance of stack sending
commands before the firmware is ready to accept.
Thank you for elaborating. It’d be great if you added it to the commit message,
when you resend.
Ack.
quoted
quoted
quoted
Signed-off-by: Sai Teja Aluvala <redacted>
Signed-off-by: Kiran K <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between
driver and firmware")
I would also put the Fixes: tag above the Signed-off-by line.
case BTINTEL_PCIE_INTEL_HCI_RESET1: if (btintel_pcie_in_op(data)) { submit_rx = true;+ signal_waitq = true; break; } if (btintel_pcie_in_iml(data)) { submit_rx = true;+ signal_waitq = true; data->alive_intr_ctxt = BTINTEL_PCIE_FW_DL; break; }
@@ -1985,8 +1987,9 @@ static int btintel_pcie_send_frame(struct hci_dev
*hdev,
quoted
quoted
quoted
if (opcode == 0xfc01)
btintel_pcie_inject_cmd_complete(hdev,
opcode);
quoted
quoted
quoted
}- /* Firmware raises alive interrupt on HCI_OP_RESET */- if (opcode == HCI_OP_RESET)++ /* Firmware raises alive interrupt on HCI_OP_RESET or
0xfc01*/
quoted
quoted
A space is missing before */.
Ack.
quoted
quoted
+ if (opcode == HCI_OP_RESET || opcode == 0xfc01)
Please define a macro for the magic number.
This is vendor specific opcode and is also shared across btintel.c,
btusb.c and hci_intel.c. Would it be acceptable to submit a separate
patch for this change alone?
Sure. Fine by me.
Thanks.
quoted
quoted
quoted
data->gp0_received = false;
hdev->stat.cmd_tx++;
@@ -2025,17 +2028,15 @@ static int btintel_pcie_send_frame(struct
Subject: Re: [PATCH v1 1/2] Bluetooth: btintel_pcie: Make driver wait for alive
interrupt
Hi Kiran,
On Sun, Jul 6, 2025 at 11:30 PM Kiran K [off-list ref] wrote:
quoted
Firmware raises an alive interrupt upon receiving the 0xfc01 (Intel
reset) command. This change fixes the driver to properly wait for the
alive interrupt.
Signed-off-by: Sai Teja Aluvala <redacted>
Signed-off-by: Kiran K <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between
driver and firmware")
---
drivers/bluetooth/btintel_pcie.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c
b/drivers/bluetooth/btintel_pcie.c
index 1113a6310bd0..f893ad6fc87a 100644
+ if (!ret) {+ hdev->stat.err_tx++;+ bt_dev_err(hdev, "No alive interrupt received for %s",+ btintel_pcie_alivectxt_state2str(data->alive_intr_ctxt));+ ret = -ETIME;+ goto exit_error;
This should probably go into btintel_pcie_send_sync instead of doing a post
handling as above, also if I read this right then we have to wait on 2 interrupts
when it comes to HCI_Reset and 0xfc01?
btintel_pcie_send_sync already waits on URBD0 this also adds GP0, having 2
interrupts means proper ordering needs to be enforced, otherwise if GP0
happens before URBD0 this will probably timeout, if this is done on purpose
let document why we think it is ok to do it.
The URBD0 interrupt is raised immediately after packet reception, while the Alive interrupt is triggered after the firmware initializes and enables the data path for receiving TX packets. This order is guaranteed by firmware.
Subject: Re: [PATCH v1 2/2] Bluetooth: btintel_pcie: Fix alive context state
handling
Hi Kiran,
On Sun, Jul 6, 2025 at 11:30 PM Kiran K [off-list ref] wrote:
quoted
Firmware raises alive interrpt on sending 0xfc01 command. Alive
context maintained in driver needs to be updated before sending 0xfc01
(Intel
Reset) or 0x03c0 (HCI Reset) to avoid the potential race condition
where the context is also updated in threaded irq.
This should be a little more specific, like explaining what is alive interrupt
supposed to mean or if we cannot do any communication wheel these are
pending?
Ack. I will update the commit message.
quoted
Signed-off-by: Kiran K <redacted>
Signed-off-by: Sai Teja Aluvala <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between
driver and firmware")
---
drivers/bluetooth/btintel_pcie.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c
b/drivers/bluetooth/btintel_pcie.c
index f893ad6fc87a..d29103b102e4 100644
@@ -1988,10 +1988,6 @@ static int btintel_pcie_send_frame(struct hci_dev
*hdev,
quoted
btintel_pcie_inject_cmd_complete(hdev, opcode); }- /* Firmware raises alive interrupt on HCI_OP_RESET or 0xfc01*/- if (opcode == HCI_OP_RESET || opcode == 0xfc01)- data->gp0_received = false;- hdev->stat.cmd_tx++; break; case HCI_ACLDATA_PKT:
@@ -2012,6 +2008,20 @@ static int btintel_pcie_send_frame(struct hci_dev
*hdev,
quoted
memcpy(skb_push(skb, BTINTEL_PCIE_HCI_TYPE_LEN), &type, BTINTEL_PCIE_HCI_TYPE_LEN);+ if (type == BTINTEL_PCIE_HCI_CMD_PKT) {+ /* Firmware raises alive interrupt on HCI_OP_RESET or 0xfc01*/+ if (opcode == HCI_OP_RESET || opcode == 0xfc01) {+ data->gp0_received = false;
This type of flags should really be made into atomic flags so they can be
checked atomically, anyway this shouldn't block these fixes but something I
very much look forward to be changed.
Subject: Re: [PATCH v1 2/2] Bluetooth: btintel_pcie: Fix alive context state
handling
Dear Kiran,
Thank you for your reply.
Am 08.07.25 um 14:30 schrieb K, Kiran:
Firmware raises alive interrpt on sending 0xfc01 command. Alive
context
interr*u*pt
(I would have hoped, two developers would spot such a typo, a spell
checker also highlights.)
Ack. Unfortunately 'interrpt' was missing in my codespell dictionary.
I have updated the same. Thanks.
hunspell or a/ispell should find it by defautl.
Ack.
quoted
quoted
quoted
maintained in driver needs to be updated before sending 0xfc01
(Intel
Reset) or 0x03c0 (HCI Reset) to avoid the potential race condition
where the context is also updated in threaded irq.
Do you have a reproducer for the issue?
Yes. Issue was reproduced in stress reboot scenario although reproduction
rate is less - 1/25.
It’d be great if you added that to the commit message, and what
scripts/commands you run for this stress reboot scenario.
Ack. I will update the commit message.
quoted
quoted
quoted
Signed-off-by: Kiran K <redacted>
Signed-off-by: Sai Teja Aluvala <redacted>
Fixes: 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between
driver and firmware")
I’d add the Fixes tag before the Signed-off-by lines.
Ack.
There is one more comment below.
Sorry. I missed this one. I will fix it in the v2 version of the patch.