* [PATCH v1 1/3] Bluetooth: btnxpuart: Add correct bootloader error codes
@ 2025-03-05 13:45 Neeraj Sanjay Kale
2025-03-05 13:45 ` [PATCH v1 2/3] Bluetooth: btnxpuart: Handle bootloader error during change baudrate Neeraj Sanjay Kale
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Neeraj Sanjay Kale @ 2025-03-05 13:45 UTC (permalink / raw)
To: marcel, luiz.dentz
Cc: linux-bluetooth, linux-kernel, amitkumar.karwar,
neeraj.sanjaykale
This corrects the bootloader error codes for NXP chipsets.
Since we have a common handling for all error codes, there is no backward
compatibility issue.
Added error handling for CRC error code in V3 bootloader signature.
Fixes: 27489364299a ("Bluetooth: btnxpuart: Add handling for boot-signature timeout errors")
Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
---
drivers/bluetooth/btnxpuart.c | 57 +++++++++++++++++++++--------------
1 file changed, 35 insertions(+), 22 deletions(-)
diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index 021983686cb3..b8a00bf062e2 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -204,10 +204,11 @@ struct btnxpuart_dev {
#define NXP_NAK_V3 0x7b
#define NXP_CRC_ERROR_V3 0x7c
-/* Bootloader signature error codes */
-#define NXP_ACK_RX_TIMEOUT 0x0002 /* ACK not received from host */
-#define NXP_HDR_RX_TIMEOUT 0x0003 /* FW Header chunk not received */
-#define NXP_DATA_RX_TIMEOUT 0x0004 /* FW Data chunk not received */
+/* Bootloader signature error codes: Refer AN12820 from nxp.com */
+#define NXP_CRC_RX_ERROR BIT(0) /* CRC error in previous packet */
+#define NXP_ACK_RX_TIMEOUT BIT(2) /* ACK not received from host */
+#define NXP_HDR_RX_TIMEOUT BIT(3) /* FW Header chunk not received */
+#define NXP_DATA_RX_TIMEOUT BIT(4) /* FW Data chunk not received */
#define HDR_LEN 16
@@ -310,6 +311,16 @@ union nxp_v3_rx_timeout_nak_u {
u8 buf[6];
};
+struct nxp_v3_crc_nak {
+ u8 nak;
+ u8 crc;
+} __packed;
+
+union nxp_v3_crc_nak_u {
+ struct nxp_v3_crc_nak pkt;
+ u8 buf[2];
+};
+
static u8 crc8_table[CRC8_TABLE_SIZE];
/* Default configurations */
@@ -1059,25 +1070,27 @@ static void nxp_handle_fw_download_error(struct hci_dev *hdev, struct v3_data_re
struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev);
__u32 offset = __le32_to_cpu(req->offset);
__u16 err = __le16_to_cpu(req->error);
- union nxp_v3_rx_timeout_nak_u nak_tx_buf;
-
- switch (err) {
- case NXP_ACK_RX_TIMEOUT:
- case NXP_HDR_RX_TIMEOUT:
- case NXP_DATA_RX_TIMEOUT:
- nak_tx_buf.pkt.nak = NXP_NAK_V3;
- nak_tx_buf.pkt.offset = __cpu_to_le32(offset);
- nak_tx_buf.pkt.crc = crc8(crc8_table, nak_tx_buf.buf,
- sizeof(nak_tx_buf) - 1, 0xff);
- serdev_device_write_buf(nxpdev->serdev, nak_tx_buf.buf,
- sizeof(nak_tx_buf));
- break;
- default:
- bt_dev_dbg(hdev, "Unknown bootloader error code: %d", err);
- break;
-
+ union nxp_v3_rx_timeout_nak_u timeout_nak_buf;
+ union nxp_v3_crc_nak_u crc_nak_buf;
+
+ if (err & NXP_CRC_RX_ERROR) {
+ crc_nak_buf.pkt.nak = NXP_CRC_ERROR_V3;
+ crc_nak_buf.pkt.crc = crc8(crc8_table, crc_nak_buf.buf,
+ sizeof(crc_nak_buf) - 1, 0xff);
+ serdev_device_write_buf(nxpdev->serdev, crc_nak_buf.buf,
+ sizeof(crc_nak_buf));
+ } else if (err & NXP_ACK_RX_TIMEOUT ||
+ err & NXP_HDR_RX_TIMEOUT ||
+ err & NXP_DATA_RX_TIMEOUT) {
+ timeout_nak_buf.pkt.nak = NXP_NAK_V3;
+ timeout_nak_buf.pkt.offset = __cpu_to_le32(offset);
+ timeout_nak_buf.pkt.crc = crc8(crc8_table, timeout_nak_buf.buf,
+ sizeof(timeout_nak_buf) - 1, 0xff);
+ serdev_device_write_buf(nxpdev->serdev, timeout_nak_buf.buf,
+ sizeof(timeout_nak_buf));
+ } else {
+ bt_dev_err(hdev, "Unknown bootloader error code: %d", err);
}
-
}
static int nxp_recv_fw_req_v3(struct hci_dev *hdev, struct sk_buff *skb)
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v1 2/3] Bluetooth: btnxpuart: Handle bootloader error during change baudrate
2025-03-05 13:45 [PATCH v1 1/3] Bluetooth: btnxpuart: Add correct bootloader error codes Neeraj Sanjay Kale
@ 2025-03-05 13:45 ` Neeraj Sanjay Kale
2025-03-06 16:36 ` kernel test robot
2025-03-05 13:45 ` [PATCH v1 3/3] Bluetooth: btnxpuart: Fix kernel panic during FW release Neeraj Sanjay Kale
2025-03-05 14:32 ` [v1,1/3] Bluetooth: btnxpuart: Add correct bootloader error codes bluez.test.bot
2 siblings, 1 reply; 5+ messages in thread
From: Neeraj Sanjay Kale @ 2025-03-05 13:45 UTC (permalink / raw)
To: marcel, luiz.dentz
Cc: linux-bluetooth, linux-kernel, amitkumar.karwar,
neeraj.sanjaykale
This handles the scenario where the driver receives an error code after
sending cmd5 or cmd7 in the bootloader signature during FW download.
The bootloader error code is handled by the driver and FW offset is
corrected accordingly, and the cmd5 or cmd7 is re-sent to the controller.
Fixes: 689ca16e5232 ("Bluetooth: NXP: Add protocol support for NXP Bluetooth chipsets")
Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
---
drivers/bluetooth/btnxpuart.c | 55 +++++++++++++++++++++++++----------
1 file changed, 39 insertions(+), 16 deletions(-)
diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index b8a00bf062e2..4367d59b4653 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -162,6 +162,12 @@ struct btnxpuart_data {
const char *fw_name_old;
};
+enum bootloader_param_change {
+ not_changed,
+ cmd_sent,
+ changed
+};
+
struct btnxpuart_dev {
struct hci_dev *hdev;
struct serdev_device *serdev;
@@ -177,6 +183,7 @@ struct btnxpuart_dev {
u32 fw_v1_sent_bytes;
u32 fw_dnld_v3_offset;
u32 fw_v3_offset_correction;
+ u32 fw_v3_prev_sent;
u32 fw_v1_expected_len;
u32 boot_reg_offset;
wait_queue_head_t fw_dnld_done_wait_q;
@@ -185,8 +192,8 @@ struct btnxpuart_dev {
u32 new_baudrate;
u32 current_baudrate;
u32 fw_init_baudrate;
- bool timeout_changed;
- bool baudrate_changed;
+ enum bootloader_param_change timeout_changed;
+ enum bootloader_param_change baudrate_changed;
bool helper_downloaded;
struct ps_data psdata;
@@ -660,8 +667,8 @@ static int nxp_download_firmware(struct hci_dev *hdev)
nxpdev->boot_reg_offset = 0;
nxpdev->fw_dnld_v3_offset = 0;
nxpdev->fw_v3_offset_correction = 0;
- nxpdev->baudrate_changed = false;
- nxpdev->timeout_changed = false;
+ nxpdev->baudrate_changed = not_changed;
+ nxpdev->timeout_changed = not_changed;
nxpdev->helper_downloaded = false;
serdev_device_set_baudrate(nxpdev->serdev, HCI_NXP_PRI_BAUDRATE);
@@ -883,15 +890,14 @@ static int nxp_recv_fw_req_v1(struct hci_dev *hdev, struct sk_buff *skb)
len = __le16_to_cpu(req->len);
if (!nxp_data->helper_fw_name) {
- if (!nxpdev->timeout_changed) {
- nxpdev->timeout_changed = nxp_fw_change_timeout(hdev,
- len);
+ if (nxpdev->timeout_changed != changed) {
+ nxp_fw_change_timeout(hdev, len);
+ nxpdev->timeout_changed = changed;
goto free_skb;
}
- if (!nxpdev->baudrate_changed) {
- nxpdev->baudrate_changed = nxp_fw_change_baudrate(hdev,
- len);
- if (nxpdev->baudrate_changed) {
+ if (nxpdev->baudrate_changed != changed) {
+ if (nxp_fw_change_baudrate(hdev, len)) {
+ nxpdev->baudrate_changed = changed;
serdev_device_set_baudrate(nxpdev->serdev,
HCI_NXP_SEC_BAUDRATE);
serdev_device_set_flow_control(nxpdev->serdev, true);
@@ -1109,21 +1115,37 @@ static int nxp_recv_fw_req_v3(struct hci_dev *hdev, struct sk_buff *skb)
if (!req->error) {
nxp_send_ack(NXP_ACK_V3, hdev);
+ if (nxpdev->timeout_changed == cmd_sent)
+ nxpdev->timeout_changed = changed;
+ if (nxpdev->baudrate_changed == cmd_sent)
+ nxpdev->baudrate_changed = changed;
} else {
nxp_handle_fw_download_error(hdev, req);
+ if (nxpdev->timeout_changed == cmd_sent &&
+ req->error == NXP_CRC_RX_ERROR) {
+ nxpdev->fw_v3_offset_correction -= nxpdev->fw_v3_prev_sent;
+ nxpdev->timeout_changed = not_changed;
+ }
+ /* After baudrate change, it is normal to get ACK Timeout error */
+ if (nxpdev->baudrate_changed == cmd_sent &&
+ req->error == NXP_CRC_RX_ERROR) {
+ nxpdev->fw_v3_offset_correction -= nxpdev->fw_v3_prev_sent;
+ nxpdev->baudrate_changed = not_changed;
+ }
goto free_skb;
}
len = __le16_to_cpu(req->len);
- if (!nxpdev->timeout_changed) {
- nxpdev->timeout_changed = nxp_fw_change_timeout(hdev, len);
+ if (nxpdev->timeout_changed != changed) {
+ nxp_fw_change_timeout(hdev, len);
+ nxpdev->timeout_changed = cmd_sent;
goto free_skb;
}
- if (!nxpdev->baudrate_changed) {
- nxpdev->baudrate_changed = nxp_fw_change_baudrate(hdev, len);
- if (nxpdev->baudrate_changed) {
+ if (nxpdev->baudrate_changed != changed) {
+ if (nxp_fw_change_baudrate(hdev, len)) {
+ nxpdev->baudrate_changed = cmd_sent;
serdev_device_set_baudrate(nxpdev->serdev,
HCI_NXP_SEC_BAUDRATE);
serdev_device_set_flow_control(nxpdev->serdev, true);
@@ -1155,6 +1177,7 @@ static int nxp_recv_fw_req_v3(struct hci_dev *hdev, struct sk_buff *skb)
nxpdev->fw_dnld_v3_offset, len);
free_skb:
+ nxpdev->fw_v3_prev_sent = len;
kfree_skb(skb);
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v1 2/3] Bluetooth: btnxpuart: Handle bootloader error during change baudrate
2025-03-05 13:45 ` [PATCH v1 2/3] Bluetooth: btnxpuart: Handle bootloader error during change baudrate Neeraj Sanjay Kale
@ 2025-03-06 16:36 ` kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-03-06 16:36 UTC (permalink / raw)
To: Neeraj Sanjay Kale, marcel, luiz.dentz
Cc: llvm, oe-kbuild-all, linux-bluetooth, linux-kernel,
amitkumar.karwar, neeraj.sanjaykale
Hi Neeraj,
kernel test robot noticed the following build warnings:
[auto build test WARNING on bluetooth/master]
[also build test WARNING on bluetooth-next/master linus/master v6.14-rc5 next-20250306]
[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/Neeraj-Sanjay-Kale/Bluetooth-btnxpuart-Handle-bootloader-error-during-change-baudrate/20250305-214856
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
patch link: https://lore.kernel.org/r/20250305134523.40111-2-neeraj.sanjaykale%40nxp.com
patch subject: [PATCH v1 2/3] Bluetooth: btnxpuart: Handle bootloader error during change baudrate
config: i386-buildonly-randconfig-001-20250306 (https://download.01.org/0day-ci/archive/20250307/202503070049.8e6dNvjC-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250307/202503070049.8e6dNvjC-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/202503070049.8e6dNvjC-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/bluetooth/btnxpuart.c:1104:6: warning: variable 'len' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
1104 | if (!req->error) {
| ^~~~~~~~~~~
drivers/bluetooth/btnxpuart.c:1168:28: note: uninitialized use occurs here
1168 | nxpdev->fw_v3_prev_sent = len;
| ^~~
drivers/bluetooth/btnxpuart.c:1104:2: note: remove the 'if' if its condition is always true
1104 | if (!req->error) {
| ^~~~~~~~~~~~~~~~
1105 | nxp_send_ack(NXP_ACK_V3, hdev);
1106 | if (nxpdev->timeout_changed == cmd_sent)
1107 | nxpdev->timeout_changed = changed;
1108 | if (nxpdev->baudrate_changed == cmd_sent)
1109 | nxpdev->baudrate_changed = changed;
1110 | } else {
| ~~~~~~
1111 | nxp_handle_fw_download_error(hdev, req);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1112 | if (nxpdev->timeout_changed == cmd_sent &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1113 | req->error == NXP_CRC_RX_ERROR) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1114 | nxpdev->fw_v3_offset_correction -= nxpdev->fw_v3_prev_sent;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1115 | nxpdev->timeout_changed = not_changed;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1116 | }
| ~
1117 | /* After baudrate change, it is normal to get ACK Timeout error */
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1118 | if (nxpdev->baudrate_changed == cmd_sent &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1119 | req->error == NXP_CRC_RX_ERROR) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/bluetooth/btnxpuart.c:1101:6: warning: variable 'len' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
1101 | if (!req || !nxpdev->fw)
| ^~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btnxpuart.c:1168:28: note: uninitialized use occurs here
1168 | nxpdev->fw_v3_prev_sent = len;
| ^~~
drivers/bluetooth/btnxpuart.c:1101:2: note: remove the 'if' if its condition is always false
1101 | if (!req || !nxpdev->fw)
| ^~~~~~~~~~~~~~~~~~~~~~~~
1102 | goto free_skb;
| ~~~~~~~~~~~~~
>> drivers/bluetooth/btnxpuart.c:1101:6: warning: variable 'len' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
1101 | if (!req || !nxpdev->fw)
| ^~~~
drivers/bluetooth/btnxpuart.c:1168:28: note: uninitialized use occurs here
1168 | nxpdev->fw_v3_prev_sent = len;
| ^~~
drivers/bluetooth/btnxpuart.c:1101:6: note: remove the '||' if its condition is always false
1101 | if (!req || !nxpdev->fw)
| ^~~~~~~
drivers/bluetooth/btnxpuart.c:1097:6: warning: variable 'len' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
1097 | if (!process_boot_signature(nxpdev))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btnxpuart.c:1168:28: note: uninitialized use occurs here
1168 | nxpdev->fw_v3_prev_sent = len;
| ^~~
drivers/bluetooth/btnxpuart.c:1097:2: note: remove the 'if' if its condition is always false
1097 | if (!process_boot_signature(nxpdev))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1098 | goto free_skb;
| ~~~~~~~~~~~~~
drivers/bluetooth/btnxpuart.c:1094:11: note: initialize the variable 'len' to silence this warning
1094 | __u16 len;
| ^
| = 0
4 warnings generated.
vim +1104 drivers/bluetooth/btnxpuart.c
27489364299a2d Neeraj Sanjay Kale 2024-06-14 1089
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1090 static int nxp_recv_fw_req_v3(struct hci_dev *hdev, struct sk_buff *skb)
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1091 {
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1092 struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev);
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1093 struct v3_data_req *req;
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1094 __u16 len;
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1095 __u32 offset;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1096
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1097 if (!process_boot_signature(nxpdev))
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1098 goto free_skb;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1099
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1100 req = skb_pull_data(skb, sizeof(*req));
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 @1101 if (!req || !nxpdev->fw)
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1102 goto free_skb;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1103
27489364299a2d Neeraj Sanjay Kale 2024-06-14 @1104 if (!req->error) {
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1105 nxp_send_ack(NXP_ACK_V3, hdev);
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1106 if (nxpdev->timeout_changed == cmd_sent)
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1107 nxpdev->timeout_changed = changed;
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1108 if (nxpdev->baudrate_changed == cmd_sent)
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1109 nxpdev->baudrate_changed = changed;
27489364299a2d Neeraj Sanjay Kale 2024-06-14 1110 } else {
27489364299a2d Neeraj Sanjay Kale 2024-06-14 1111 nxp_handle_fw_download_error(hdev, req);
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1112 if (nxpdev->timeout_changed == cmd_sent &&
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1113 req->error == NXP_CRC_RX_ERROR) {
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1114 nxpdev->fw_v3_offset_correction -= nxpdev->fw_v3_prev_sent;
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1115 nxpdev->timeout_changed = not_changed;
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1116 }
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1117 /* After baudrate change, it is normal to get ACK Timeout error */
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1118 if (nxpdev->baudrate_changed == cmd_sent &&
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1119 req->error == NXP_CRC_RX_ERROR) {
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1120 nxpdev->fw_v3_offset_correction -= nxpdev->fw_v3_prev_sent;
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1121 nxpdev->baudrate_changed = not_changed;
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1122 }
27489364299a2d Neeraj Sanjay Kale 2024-06-14 1123 goto free_skb;
27489364299a2d Neeraj Sanjay Kale 2024-06-14 1124 }
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1125
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1126 len = __le16_to_cpu(req->len);
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1127
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1128 if (nxpdev->timeout_changed != changed) {
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1129 nxp_fw_change_timeout(hdev, len);
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1130 nxpdev->timeout_changed = cmd_sent;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1131 goto free_skb;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1132 }
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1133
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1134 if (nxpdev->baudrate_changed != changed) {
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1135 if (nxp_fw_change_baudrate(hdev, len)) {
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1136 nxpdev->baudrate_changed = cmd_sent;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1137 serdev_device_set_baudrate(nxpdev->serdev,
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1138 HCI_NXP_SEC_BAUDRATE);
b0310d6ed684b8 Neeraj Sanjay Kale 2023-04-19 1139 serdev_device_set_flow_control(nxpdev->serdev, true);
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1140 nxpdev->current_baudrate = HCI_NXP_SEC_BAUDRATE;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1141 }
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1142 goto free_skb;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1143 }
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1144
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1145 if (req->len == 0) {
2684dd614ccf08 Neeraj Sanjay Kale 2024-05-15 1146 bt_dev_info(hdev, "FW Download Complete: %zu bytes",
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1147 nxpdev->fw->size);
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1148 clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state);
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1149 wake_up_interruptible(&nxpdev->fw_dnld_done_wait_q);
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1150 goto free_skb;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1151 }
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1152
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1153 offset = __le32_to_cpu(req->offset);
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1154 if (offset < nxpdev->fw_v3_offset_correction) {
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1155 /* This scenario should ideally never occur. But if it ever does,
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1156 * FW is out of sync and needs a power cycle.
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1157 */
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1158 bt_dev_err(hdev, "Something went wrong during FW download");
9e080b53dafae5 Luiz Augusto von Dentz 2023-04-17 1159 bt_dev_err(hdev, "Please power cycle and try again");
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1160 goto free_skb;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1161 }
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1162
e3c4891098c875 Neeraj Sanjay Kale 2024-05-15 1163 nxpdev->fw_dnld_v3_offset = offset - nxpdev->fw_v3_offset_correction;
e3c4891098c875 Neeraj Sanjay Kale 2024-05-15 1164 serdev_device_write_buf(nxpdev->serdev, nxpdev->fw->data +
e3c4891098c875 Neeraj Sanjay Kale 2024-05-15 1165 nxpdev->fw_dnld_v3_offset, len);
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1166
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1167 free_skb:
5bf71799df5728 Neeraj Sanjay Kale 2025-03-05 1168 nxpdev->fw_v3_prev_sent = len;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1169 kfree_skb(skb);
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1170 return 0;
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1171 }
689ca16e523278 Neeraj Sanjay Kale 2023-03-16 1172
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 3/3] Bluetooth: btnxpuart: Fix kernel panic during FW release
2025-03-05 13:45 [PATCH v1 1/3] Bluetooth: btnxpuart: Add correct bootloader error codes Neeraj Sanjay Kale
2025-03-05 13:45 ` [PATCH v1 2/3] Bluetooth: btnxpuart: Handle bootloader error during change baudrate Neeraj Sanjay Kale
@ 2025-03-05 13:45 ` Neeraj Sanjay Kale
2025-03-05 14:32 ` [v1,1/3] Bluetooth: btnxpuart: Add correct bootloader error codes bluez.test.bot
2 siblings, 0 replies; 5+ messages in thread
From: Neeraj Sanjay Kale @ 2025-03-05 13:45 UTC (permalink / raw)
To: marcel, luiz.dentz
Cc: linux-bluetooth, linux-kernel, amitkumar.karwar,
neeraj.sanjaykale
This fixes a kernel panic seen during release FW in a stress test
scenario where WLAN and BT FW download occurs simultaneously, and due to
a HW bug, chip sends out only 1 bootloader signatures.
When driver receives the bootloader signature, it enters FW download
mode, but since no consequtive bootloader signatures seen, FW file is
not requested.
After 60 seconds, when FW download times out, release_firmware causes a
kernel panic.
[ 2601.949184] Unable to handle kernel paging request at virtual address 0000312e6f006573
[ 2601.992076] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000111802000
[ 2601.992080] [0000312e6f006573] pgd=0000000000000000, p4d=0000000000000000
[ 2601.992087] Internal error: Oops: 0000000096000021 [#1] PREEMPT SMP
[ 2601.992091] Modules linked in: algif_hash algif_skcipher af_alg btnxpuart(O) pciexxx(O) mlan(O) overlay fsl_jr_uio caam_jr caamkeyblob_desc caamhash_desc caamalg_desc crypto_engine authenc libdes crct10dif_ce polyval_ce snd_soc_fsl_easrc snd_soc_fsl_asoc_card imx8_media_dev(C) snd_soc_fsl_micfil polyval_generic snd_soc_fsl_xcvr snd_soc_fsl_sai snd_soc_imx_audmux snd_soc_fsl_asrc snd_soc_imx_card snd_soc_imx_hdmi snd_soc_fsl_aud2htx snd_soc_fsl_utils imx_pcm_dma dw_hdmi_cec flexcan can_dev
[ 2602.001825] CPU: 2 PID: 20060 Comm: hciconfig Tainted: G C O 6.6.23-lts-next-06236-gb586a521770e #1
[ 2602.010182] Hardware name: NXP i.MX8MPlus EVK board (DT)
[ 2602.010185] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 2602.010191] pc : _raw_spin_lock+0x34/0x68
[ 2602.010201] lr : free_fw_priv+0x20/0xfc
[ 2602.020561] sp : ffff800089363b30
[ 2602.020563] x29: ffff800089363b30 x28: ffff0000d0eb5880 x27: 0000000000000000
[ 2602.020570] x26: 0000000000000000 x25: ffff0000d728b330 x24: 0000000000000000
[ 2602.020577] x23: ffff0000dc856f38
[ 2602.033797] x22: ffff800089363b70 x21: ffff0000dc856000
[ 2602.033802] x20: ff00312e6f006573 x19: ffff0000d0d9ea80 x18: 0000000000000000
[ 2602.033809] x17: 0000000000000000 x16: 0000000000000000 x15: 0000aaaad80dd480
[ 2602.083320] x14: 0000000000000000 x13: 00000000000001b9 x12: 0000000000000002
[ 2602.083326] x11: 0000000000000000 x10: 0000000000000a60 x9 : ffff800089363a30
[ 2602.083333] x8 : ffff0001793d75c0 x7 : ffff0000d6dbc400 x6 : 0000000000000000
[ 2602.083339] x5 : 00000000410fd030 x4 : 0000000000000000 x3 : 0000000000000001
[ 2602.083346] x2 : 0000000000000000 x1 : 0000000000000001 x0 : ff00312e6f006573
[ 2602.083354] Call trace:
[ 2602.083356] _raw_spin_lock+0x34/0x68
[ 2602.083364] release_firmware+0x48/0x6c
[ 2602.083370] nxp_setup+0x3c4/0x540 [btnxpuart]
[ 2602.083383] hci_dev_open_sync+0xf0/0xa34
[ 2602.083391] hci_dev_open+0xd8/0x178
[ 2602.083399] hci_sock_ioctl+0x3b0/0x590
[ 2602.083405] sock_do_ioctl+0x60/0x118
[ 2602.083413] sock_ioctl+0x2f4/0x374
[ 2602.091430] __arm64_sys_ioctl+0xac/0xf0
[ 2602.091437] invoke_syscall+0x48/0x110
[ 2602.091445] el0_svc_common.constprop.0+0xc0/0xe0
[ 2602.091452] do_el0_svc+0x1c/0x28
[ 2602.091457] el0_svc+0x40/0xe4
[ 2602.091465] el0t_64_sync_handler+0x120/0x12c
[ 2602.091470] el0t_64_sync+0x190/0x194
Fixes: e3c4891098c8 ("Bluetooth: btnxpuart: Handle FW Download Abort scenario")
Fixes: 689ca16e5232 ("Bluetooth: NXP: Add protocol support for NXP Bluetooth chipsets")
Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
---
drivers/bluetooth/btnxpuart.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index 4367d59b4653..ac8dbdc82255 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -681,8 +681,10 @@ static int nxp_download_firmware(struct hci_dev *hdev)
&nxpdev->tx_state),
msecs_to_jiffies(60000));
- release_firmware(nxpdev->fw);
- memset(nxpdev->fw_name, 0, sizeof(nxpdev->fw_name));
+ if (nxpdev->fw && strlen(nxpdev->fw_name)) {
+ release_firmware(nxpdev->fw);
+ memset(nxpdev->fw_name, 0, sizeof(nxpdev->fw_name));
+ }
if (err == 0) {
bt_dev_err(hdev, "FW Download Timeout. offset: %d",
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* RE: [v1,1/3] Bluetooth: btnxpuart: Add correct bootloader error codes
2025-03-05 13:45 [PATCH v1 1/3] Bluetooth: btnxpuart: Add correct bootloader error codes Neeraj Sanjay Kale
2025-03-05 13:45 ` [PATCH v1 2/3] Bluetooth: btnxpuart: Handle bootloader error during change baudrate Neeraj Sanjay Kale
2025-03-05 13:45 ` [PATCH v1 3/3] Bluetooth: btnxpuart: Fix kernel panic during FW release Neeraj Sanjay Kale
@ 2025-03-05 14:32 ` bluez.test.bot
2 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-03-05 14:32 UTC (permalink / raw)
To: linux-bluetooth, neeraj.sanjaykale
[-- Attachment #1: Type: text/plain, Size: 1950 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=940577
---Test result---
Test Summary:
CheckPatch PENDING 0.34 seconds
GitLint PENDING 0.22 seconds
SubjectPrefix PASS 0.37 seconds
BuildKernel PASS 24.33 seconds
CheckAllWarning PASS 27.34 seconds
CheckSparse PASS 31.42 seconds
BuildKernel32 PASS 25.00 seconds
TestRunnerSetup PASS 439.62 seconds
TestRunner_l2cap-tester PASS 24.90 seconds
TestRunner_iso-tester PASS 31.96 seconds
TestRunner_bnep-tester PASS 4.75 seconds
TestRunner_mgmt-tester FAIL 120.83 seconds
TestRunner_rfcomm-tester PASS 7.88 seconds
TestRunner_sco-tester PASS 11.66 seconds
TestRunner_ioctl-tester PASS 10.71 seconds
TestRunner_mesh-tester PASS 6.13 seconds
TestRunner_smp-tester PASS 7.20 seconds
TestRunner_userchan-tester PASS 5.06 seconds
IncrementalBuild PENDING 0.94 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
LL Privacy - Add Device 3 (AL is full) Failed 0.197 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-06 16:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 13:45 [PATCH v1 1/3] Bluetooth: btnxpuart: Add correct bootloader error codes Neeraj Sanjay Kale
2025-03-05 13:45 ` [PATCH v1 2/3] Bluetooth: btnxpuart: Handle bootloader error during change baudrate Neeraj Sanjay Kale
2025-03-06 16:36 ` kernel test robot
2025-03-05 13:45 ` [PATCH v1 3/3] Bluetooth: btnxpuart: Fix kernel panic during FW release Neeraj Sanjay Kale
2025-03-05 14:32 ` [v1,1/3] Bluetooth: btnxpuart: Add correct bootloader error codes bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox