2024-04-14 11:57:30

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v1 0/2] QCA6390 enable failure debugging changes

This patch series are to debug below QCA6390 issue:
QCA6390 bluetooth doesn't work after warm boot or disable/reenable
https://lore.kernel.org/linux-bluetooth/[email protected]

Zijun Hu (2):
Bluetooth: qca: Dump more config info for debugging
Bluetooth: qca: Fix QCA6390 enable failure after reboot or disable

drivers/bluetooth/hci_qca.c | 78 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 72 insertions(+), 6 deletions(-)

--
2.7.4



2024-04-14 11:57:33

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v1 2/2] Bluetooth: qca: Fix QCA6390 enable failure after reboot or disable

Fix QCA6390 enable failure after reboot or disable.

Signed-off-by: Zijun Hu <[email protected]>
---
drivers/bluetooth/hci_qca.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index b61ca9828284..d390d68a831a 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -2499,14 +2499,19 @@ static void qca_serdev_shutdown(struct device *dev)
struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
struct hci_uart *hu = &qcadev->serdev_hu;
struct hci_dev *hdev = hu->hdev;
- struct qca_data *qca = hu->priv;
const u8 ibs_wake_cmd[] = { 0xFD };
const u8 edl_reset_soc_cmd[] = { 0x01, 0x00, 0xFC, 0x01, 0x05 };

if (qcadev->btsoc_type == QCA_QCA6390) {
- if (test_bit(QCA_BT_OFF, &qca->flags) ||
- !test_bit(HCI_RUNNING, &hdev->flags))
+ if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
+ BT_INFO("%s: Don't need to send EDL_RESET_REQ", __func__);
return;
+ }
+
+ if (hci_dev_test_flag(hdev, HCI_SETUP)) {
+ BT_INFO("%s: Don't send EDL_RESET_REQ due to NOT setup ", __func__);
+ return;
+ }

BT_INFO("%s: Start to send EDL_RESET_REQ", __func__);
serdev_device_write_flush(serdev);
--
2.7.4


2024-04-14 11:57:33

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v1 1/2] Bluetooth: qca: Dump more config info for debugging

Dump more config info for debugging.

Signed-off-by: Zijun Hu <[email protected]>
---
drivers/bluetooth/hci_qca.c | 67 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 64 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index ecbc52eaf101..b61ca9828284 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1883,8 +1883,12 @@ static int qca_setup(struct hci_uart *hu)
soc_name = "wcn7850";
break;

+ case QCA_QCA6390:
+ soc_name = "QCA6390";
+ break;
+
default:
- soc_name = "ROME/QCA6390";
+ soc_name = "ROME";
}
bt_dev_info(hdev, "setting up %s", soc_name);

@@ -2281,18 +2285,33 @@ static int qca_serdev_probe(struct serdev_device *serdev)
if (!qcadev)
return -ENOMEM;

+#ifdef CONFIG_GPIOLIB
+ BT_INFO("%s: CONFIG_GPIOLIB is defined", __func__);
+#else
+ BT_INFO("%s: CONFIG_GPIOLIB is Undefined", __func__);
+#endif
+
qcadev->serdev_hu.serdev = serdev;
data = device_get_match_data(&serdev->dev);
serdev_device_set_drvdata(serdev, qcadev);
device_property_read_string(&serdev->dev, "firmware-name",
&qcadev->firmware_name);
+ if (qcadev->firmware_name)
+ BT_INFO("%s: firmware-name is \"%s\"", __func__, qcadev->firmware_name);
+
device_property_read_u32(&serdev->dev, "max-speed",
&qcadev->oper_speed);
+ BT_INFO("%s: max-speed(%d)", __func__, qcadev->oper_speed);
if (!qcadev->oper_speed)
BT_DBG("UART will pick default operating speed");

qcadev->bdaddr_property_broken = device_property_read_bool(&serdev->dev,
"qcom,local-bd-address-broken");
+ BT_INFO("%s: bdaddr_property_broken(%d)", __func__, (int)qcadev->bdaddr_property_broken);
+ if (data) {
+ BT_INFO("%s: soc_type(%d)", __func__, (int)data->soc_type);
+ BT_INFO("%s: capabilities(%#x)", __func__, data->capabilities);
+ }

if (data)
qcadev->btsoc_type = data->soc_type;
@@ -2320,11 +2339,29 @@ static int qca_serdev_probe(struct serdev_device *serdev)
BT_ERR("Failed to init regulators:%d", err);
return err;
}
+ {
+ int i;
+
+ BT_INFO("%s: num_vregs(%d)", __func__, (int)data->num_vregs);
+ for (i = 0; i < data->num_vregs; i++)
+ BT_INFO("%s: %d regulator %s I(%duA) is %p",
+ __func__, i,
+ qcadev->bt_power->vreg_bulk[i].supply,
+ data->vregs[i].load_uA,
+ qcadev->bt_power->vreg_bulk[i].consumer);
+ }
+

qcadev->bt_power->vregs_on = false;

qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
GPIOD_OUT_LOW);
+ if (IS_ERR(qcadev->bt_en))
+ BT_ERR("%s: Get enable gpio ERROR", __func__);
+ else if (qcadev->bt_en)
+ BT_INFO("%s: Got enable gpio(%d) ", __func__, desc_to_gpio(qcadev->bt_en));
+ else
+ BT_INFO("%s: qcadev->bt_en(nullptr)", __func__);
if (IS_ERR(qcadev->bt_en) &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_WCN6855)) {
@@ -2333,7 +2370,14 @@ static int qca_serdev_probe(struct serdev_device *serdev)
}

qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
- GPIOD_IN);
+ GPIOD_IN);
+ if (IS_ERR(qcadev->sw_ctrl))
+ BT_ERR("%s: Get sw_ctrl gpio ERROR", __func__);
+ else if (qcadev->sw_ctrl)
+ BT_INFO("%s: Got sw_ctrl gpio(%d) ", __func__,
+ desc_to_gpio(qcadev->sw_ctrl));
+ else
+ BT_INFO("%s: qcadev->sw_ctrl(nullptr)", __func__);
if (IS_ERR(qcadev->sw_ctrl) &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_WCN6855 ||
@@ -2341,6 +2385,10 @@ static int qca_serdev_probe(struct serdev_device *serdev)
dev_warn(&serdev->dev, "failed to acquire SW_CTRL gpio\n");

qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
+ if (IS_ERR(qcadev->susclk))
+ BT_ERR("%s: Get clock ERROR", __func__);
+ else
+ BT_INFO("%s: susclk(%p)", __func__, qcadev->susclk);
if (IS_ERR(qcadev->susclk)) {
dev_err(&serdev->dev, "failed to acquire clk\n");
return PTR_ERR(qcadev->susclk);
@@ -2355,13 +2403,24 @@ static int qca_serdev_probe(struct serdev_device *serdev)

default:
qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
- GPIOD_OUT_LOW);
+ GPIOD_OUT_LOW);
+ if (IS_ERR(qcadev->bt_en))
+ BT_ERR("%s: default Get enable gpio ERROR", __func__);
+ else if (qcadev->bt_en)
+ BT_INFO("%s: default Got enable gpio(%d) ",
+ __func__, desc_to_gpio(qcadev->bt_en));
+ else
+ BT_INFO("%s: default qcadev->bt_en(nullptr)", __func__);
if (IS_ERR(qcadev->bt_en)) {
dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
power_ctrl_enabled = false;
}

qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
+ if (IS_ERR(qcadev->susclk))
+ BT_ERR("%s: default Get clock ERROR", __func__);
+ else
+ BT_INFO("%s: default susclk(%p)", __func__, qcadev->susclk);
if (IS_ERR(qcadev->susclk)) {
dev_warn(&serdev->dev, "failed to acquire clk\n");
return PTR_ERR(qcadev->susclk);
@@ -2384,6 +2443,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)

hdev = qcadev->serdev_hu.hdev;

+ BT_INFO("%s: power_ctrl_enabled(%d)", __func__, (int)power_ctrl_enabled);
if (power_ctrl_enabled) {
set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
hdev->shutdown = qca_power_off;
@@ -2448,6 +2508,7 @@ static void qca_serdev_shutdown(struct device *dev)
!test_bit(HCI_RUNNING, &hdev->flags))
return;

+ BT_INFO("%s: Start to send EDL_RESET_REQ", __func__);
serdev_device_write_flush(serdev);
ret = serdev_device_write_buf(serdev, ibs_wake_cmd,
sizeof(ibs_wake_cmd));
--
2.7.4


2024-04-14 14:48:24

by bluez.test.bot

[permalink] [raw]
Subject: RE: QCA6390 enable failure debugging changes

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=844357

---Test result---

Test Summary:
CheckPatch PASS 0.96 seconds
GitLint PASS 0.37 seconds
SubjectPrefix PASS 0.16 seconds
BuildKernel PASS 29.31 seconds
CheckAllWarning PASS 31.69 seconds
CheckSparse PASS 36.62 seconds
CheckSmatch FAIL 33.23 seconds
BuildKernel32 PASS 27.34 seconds
TestRunnerSetup PASS 495.97 seconds
TestRunner_l2cap-tester PASS 20.09 seconds
TestRunner_iso-tester PASS 31.99 seconds
TestRunner_bnep-tester PASS 4.53 seconds
TestRunner_mgmt-tester PASS 108.20 seconds
TestRunner_rfcomm-tester PASS 7.09 seconds
TestRunner_sco-tester PASS 14.63 seconds
TestRunner_ioctl-tester PASS 7.30 seconds
TestRunner_mesh-tester PASS 5.56 seconds
TestRunner_smp-tester PASS 6.53 seconds
TestRunner_userchan-tester PASS 4.77 seconds
IncrementalBuild PASS 31.05 seconds

Details
##############################
Test: CheckSmatch - FAIL
Desc: Run smatch tool with source
Output:

Segmentation fault (core dumped)
make[4]: *** [scripts/Makefile.build:244: net/bluetooth/hci_core.o] Error 139
make[4]: *** Deleting file 'net/bluetooth/hci_core.o'
make[3]: *** [scripts/Makefile.build:485: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:485: net] Error 2
make[2]: *** Waiting for unfinished jobs....
Segmentation fault (core dumped)
make[4]: *** [scripts/Makefile.build:244: drivers/bluetooth/bcm203x.o] Error 139
make[4]: *** Deleting file 'drivers/bluetooth/bcm203x.o'
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:485: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:485: drivers] Error 2
make[1]: *** [/github/workspace/src/src/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2


---
Regards,
Linux Bluetooth

2024-04-15 10:12:25

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v2] Bluetooth: qca: Fix QCA6390 enable failure after reboot or disable

Fix QCA6390 enable failure after reboot or disable.

Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
Signed-off-by: Zijun Hu <[email protected]>
---
Changes v1 -> v2
Revert commit 56d074d26c58

drivers/bluetooth/hci_qca.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index b61ca9828284..d8a6d6b1bbea 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -2362,7 +2362,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
BT_INFO("%s: Got enable gpio(%d) ", __func__, desc_to_gpio(qcadev->bt_en));
else
BT_INFO("%s: qcadev->bt_en(nullptr)", __func__);
- if (IS_ERR(qcadev->bt_en) &&
+ if (IS_ERR_OR_NULL(qcadev->bt_en) &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_WCN6855)) {
dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
@@ -2378,7 +2378,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
desc_to_gpio(qcadev->sw_ctrl));
else
BT_INFO("%s: qcadev->sw_ctrl(nullptr)", __func__);
- if (IS_ERR(qcadev->sw_ctrl) &&
+ if (IS_ERR_OR_NULL(qcadev->sw_ctrl) &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_WCN6855 ||
data->soc_type == QCA_WCN7850))
@@ -2404,7 +2404,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
default:
qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
GPIOD_OUT_LOW);
- if (IS_ERR(qcadev->bt_en))
+ if (IS_ERR_OR_NULL(qcadev->bt_en))
BT_ERR("%s: default Get enable gpio ERROR", __func__);
else if (qcadev->bt_en)
BT_INFO("%s: default Got enable gpio(%d) ",
@@ -2499,14 +2499,19 @@ static void qca_serdev_shutdown(struct device *dev)
struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
struct hci_uart *hu = &qcadev->serdev_hu;
struct hci_dev *hdev = hu->hdev;
- struct qca_data *qca = hu->priv;
const u8 ibs_wake_cmd[] = { 0xFD };
const u8 edl_reset_soc_cmd[] = { 0x01, 0x00, 0xFC, 0x01, 0x05 };

if (qcadev->btsoc_type == QCA_QCA6390) {
- if (test_bit(QCA_BT_OFF, &qca->flags) ||
- !test_bit(HCI_RUNNING, &hdev->flags))
+ if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
+ BT_INFO("%s: Don't need to send EDL_RESET_REQ", __func__);
+ return;
+ }
+
+ if (hci_dev_test_flag(hdev, HCI_SETUP)) {
+ BT_INFO("%s: Don't send EDL_RESET_REQ due to NOT setup ", __func__);
return;
+ }

BT_INFO("%s: Start to send EDL_RESET_REQ", __func__);
serdev_device_write_flush(serdev);
--
2.7.4


2024-04-15 10:37:46

by bluez.test.bot

[permalink] [raw]
Subject: RE: [v2] Bluetooth: qca: Fix QCA6390 enable failure after reboot or disable

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----

error: patch failed: drivers/bluetooth/hci_qca.c:2362
error: drivers/bluetooth/hci_qca.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch

Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2024-04-17 15:24:10

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v3] Bluetooth: qca: Fix QCA6390 enable failure after reboot or disable

Fix QCA6390 enable failure after reboot or disable.

it is a debugging change and don't merge.

Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
Signed-off-by: Zijun Hu <[email protected]>
---
Changes v2 -> v3
- Fix Reverting the 56d074d26c58 error
Changes v1 -> v2
- Revert part of 56d074d26c58

drivers/bluetooth/hci_qca.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index b61ca9828284..f58bce5448ee 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -2362,7 +2362,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
BT_INFO("%s: Got enable gpio(%d) ", __func__, desc_to_gpio(qcadev->bt_en));
else
BT_INFO("%s: qcadev->bt_en(nullptr)", __func__);
- if (IS_ERR(qcadev->bt_en) &&
+ if (IS_ERR_OR_NULL(qcadev->bt_en) &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_WCN6855)) {
dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
@@ -2378,7 +2378,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
desc_to_gpio(qcadev->sw_ctrl));
else
BT_INFO("%s: qcadev->sw_ctrl(nullptr)", __func__);
- if (IS_ERR(qcadev->sw_ctrl) &&
+ if (IS_ERR_OR_NULL(qcadev->sw_ctrl) &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_WCN6855 ||
data->soc_type == QCA_WCN7850))
@@ -2411,7 +2411,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
__func__, desc_to_gpio(qcadev->bt_en));
else
BT_INFO("%s: default qcadev->bt_en(nullptr)", __func__);
- if (IS_ERR(qcadev->bt_en)) {
+ if (IS_ERR_OR_NULL(qcadev->bt_en)) {
dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
power_ctrl_enabled = false;
}
@@ -2499,14 +2499,19 @@ static void qca_serdev_shutdown(struct device *dev)
struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
struct hci_uart *hu = &qcadev->serdev_hu;
struct hci_dev *hdev = hu->hdev;
- struct qca_data *qca = hu->priv;
const u8 ibs_wake_cmd[] = { 0xFD };
const u8 edl_reset_soc_cmd[] = { 0x01, 0x00, 0xFC, 0x01, 0x05 };

if (qcadev->btsoc_type == QCA_QCA6390) {
- if (test_bit(QCA_BT_OFF, &qca->flags) ||
- !test_bit(HCI_RUNNING, &hdev->flags))
+ if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
+ BT_INFO("%s: Don't need to send EDL_RESET_REQ", __func__);
return;
+ }
+
+ if (hci_dev_test_flag(hdev, HCI_SETUP)) {
+ BT_INFO("%s: Don't send EDL_RESET_REQ due to NOT setup ", __func__);
+ return;
+ }

BT_INFO("%s: Start to send EDL_RESET_REQ", __func__);
serdev_device_write_flush(serdev);
--
2.7.4