Skip to content

Commit 2ea48d7

Browse files
kirankrishnappa-intelmehmetb0
authored andcommitted
Bluetooth: btintel_pcie: Fix a potential race condition
BugLink: https://bugs.launchpad.net/bugs/2104873 [ Upstream commit 872274b ] On HCI_OP_RESET command, firmware raises alive interrupt. Driver needs to wait for this before sending other command. This patch fixes the potential miss of alive interrupt due to which HCI_OP_RESET can timeout. Expected flow: If tx command is HCI_OP_RESET, 1. set data->gp0_received = false 2. send HCI_OP_RESET 3. wait for alive interrupt Actual flow having potential race: If tx command is HCI_OP_RESET, 1. send HCI_OP_RESET 1a. Firmware raises alive interrupt here and in ISR data->gp0_received is set to true 2. set data->gp0_received = false 3. wait for alive interrupt Signed-off-by: Kiran K <kiran.k@intel.com> Fixes: 05c200c ("Bluetooth: btintel_pcie: Add handshake between driver and firmware") Reported-by: Bjorn Helgaas <helgaas@kernel.org> Closes: https://patchwork.kernel.org/project/bluetooth/patch/20241001104451.626964-1-kiran.k@intel.com/ Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Noah Wager <noah.wager@canonical.com>
1 parent a49dec3 commit 2ea48d7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/bluetooth/btintel_pcie.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,10 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,
13141314
if (opcode == 0xfc01)
13151315
btintel_pcie_inject_cmd_complete(hdev, opcode);
13161316
}
1317+
/* Firmware raises alive interrupt on HCI_OP_RESET */
1318+
if (opcode == HCI_OP_RESET)
1319+
data->gp0_received = false;
1320+
13171321
hdev->stat.cmd_tx++;
13181322
break;
13191323
case HCI_ACLDATA_PKT:
@@ -1348,7 +1352,6 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,
13481352
opcode, btintel_pcie_alivectxt_state2str(old_ctxt),
13491353
btintel_pcie_alivectxt_state2str(data->alive_intr_ctxt));
13501354
if (opcode == HCI_OP_RESET) {
1351-
data->gp0_received = false;
13521355
ret = wait_event_timeout(data->gp0_wait_q,
13531356
data->gp0_received,
13541357
msecs_to_jiffies(BTINTEL_DEFAULT_INTR_TIMEOUT_MS));

0 commit comments

Comments
 (0)