2024-04-18 14:07:54

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.

Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
with gpiod_get_optional()") will cause serious regression issue for
several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
QCA_QCA6390 and QCA_QCA2066, the regression issue is that BT can't be
enabled any more once BT is disabled if BT reset pin is not configured
by DT or ACPI.

if BT reset pin is not configured, devm_gpiod_get_optional() will return
NULL, and we should NOT set quirk HCI_QUIRK_NON_PERSISTENT_SETUP, but the
reverted commit SET the quirk since NULL is not a error case, and cause
qca_setup() call failure triggered by the 2nd and later BT enable
operations since there are no available BT reset pin to clear BT firmware
downloaded by the 1st enable operation, fixed by reverting the commit.

Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
Reported-by: Wren Turkal <[email protected]>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
Link: https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
Signed-off-by: Zijun Hu <[email protected]>
Tested-by: Wren Turkal <[email protected]>
---
drivers/bluetooth/hci_qca.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 92fa20f5ac7d..160175a23a49 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -2323,7 +2323,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)

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) &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_WCN6855)) {
dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
@@ -2332,7 +2332,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)

qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
GPIOD_IN);
- 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))
@@ -2354,7 +2354,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)) {
dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
power_ctrl_enabled = false;
}
--
2.7.4



2024-04-18 14:57:39

by bluez.test.bot

[permalink] [raw]
Subject: RE: Fix two regression issues for QCA controllers

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

---Test result---

Test Summary:
CheckPatch FAIL 1.62 seconds
GitLint FAIL 0.85 seconds
SubjectPrefix PASS 0.22 seconds
BuildKernel PASS 32.12 seconds
CheckAllWarning PASS 34.76 seconds
CheckSparse PASS 40.27 seconds
CheckSmatch FAIL 36.68 seconds
BuildKernel32 PASS 30.14 seconds
TestRunnerSetup PASS 524.15 seconds
TestRunner_l2cap-tester PASS 18.69 seconds
TestRunner_iso-tester PASS 33.55 seconds
TestRunner_bnep-tester PASS 4.80 seconds
TestRunner_mgmt-tester FAIL 110.36 seconds
TestRunner_rfcomm-tester PASS 7.27 seconds
TestRunner_sco-tester PASS 14.96 seconds
TestRunner_ioctl-tester PASS 7.61 seconds
TestRunner_mesh-tester PASS 5.76 seconds
TestRunner_smp-tester PASS 7.22 seconds
TestRunner_userchan-tester PASS 4.91 seconds
IncrementalBuild PASS 33.90 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v1,1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"
WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report
#116:
Reported-by: Wren Turkal <[email protected]>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726

total: 0 errors, 1 warnings, 24 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13634834.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[v1,1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
1: T1 Title exceeds max length (90>80): "[v1,1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()""
21: B1 Line exceeds max length (139>80): "Link: https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f"
[v1,2/2] Bluetooth: qca: Fix BT enable failure for QCA_QCA6390 after disable then warm reboot

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
1: T1 Title exceeds max length (93>80): "[v1,2/2] Bluetooth: qca: Fix BT enable failure for QCA_QCA6390 after disable then warm reboot"
##############################
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
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 492, Passed: 489 (99.4%), Failed: 1, Not Run: 2

Failed Test Cases
LL Privacy - Add Device 7 (AL is full) Failed 0.189 seconds


---
Regards,
Linux Bluetooth

2024-04-18 16:54:02

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 18/04/2024 16:06, Zijun Hu wrote:
> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>
> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
> with gpiod_get_optional()") will cause serious regression issue for
> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,

The pin is required on 6750, 6855 and maybe others. You cannot not have
the GPIO.

This is no correct fix. You provide wrong DTS and, instead fixing it,
try to revert kernel code.

No, fix your DTS first.

Best regards,
Krzysztof


2024-04-18 17:01:58

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On Thu, 18 Apr 2024 at 16:06, Zijun Hu <[email protected]> wrote:
>
> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>
> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
> with gpiod_get_optional()") will cause serious regression issue for
> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
> QCA_QCA6390 and QCA_QCA2066, the regression issue is that BT can't be
> enabled any more once BT is disabled if BT reset pin is not configured
> by DT or ACPI.
>
> if BT reset pin is not configured, devm_gpiod_get_optional() will return
> NULL, and we should NOT set quirk HCI_QUIRK_NON_PERSISTENT_SETUP, but the
> reverted commit SET the quirk since NULL is not a error case, and cause
> qca_setup() call failure triggered by the 2nd and later BT enable
> operations since there are no available BT reset pin to clear BT firmware
> downloaded by the 1st enable operation, fixed by reverting the commit.
>
> Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
> Reported-by: Wren Turkal <[email protected]>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
> Link: https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
> Signed-off-by: Zijun Hu <[email protected]>
> Tested-by: Wren Turkal <[email protected]>
> ---
> drivers/bluetooth/hci_qca.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 92fa20f5ac7d..160175a23a49 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -2323,7 +2323,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>
> 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) &&
> (data->soc_type == QCA_WCN6750 ||
> data->soc_type == QCA_WCN6855)) {
> dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
> @@ -2332,7 +2332,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>
> qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
> GPIOD_IN);
> - 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))
> @@ -2354,7 +2354,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)) {
> dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
> power_ctrl_enabled = false;
> }
> --
> 2.7.4
>

I told you under your yesterday's submission that you should instead
consider bailing out from probe() if gpiod_get_optional() returns an
error as right now if it returns EPROBE_DEFER (enable-gpios is there
but the controller is not up yet), you will act like the GPIO was not
even specified.

gpiod_get_optional() returns NULL if the GPIO property is not there or
an error if anything else goes wrong. In the latter case, you should
abort probe.

Bart

2024-04-18 21:17:24

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/19/2024 12:52 AM, Krzysztof Kozlowski wrote:
> On 18/04/2024 16:06, Zijun Hu wrote:
>> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>>
>> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
>> with gpiod_get_optional()") will cause serious regression issue for
>> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
>
> The pin is required on 6750, 6855 and maybe others. You cannot not have
> the GPIO.
>
> This is no correct fix. You provide wrong DTS and, instead fixing it,
> try to revert kernel code.
>
> No, fix your DTS first.
>
no. your point is not right.

1) do you have any evidence that the hci_qca driver must use reset GPIO?
2) why does original design do error return when get GPIO error if GPIO is mandatory?
3) i meet many customer cases that BT are working fine without hci_qca operating the GPIO,
there is why HCI_QUIRK_NON_PERSISTENT_SETUP are introduced.
4) does the reverted change solve the issue your mentioned ?
> Best regards,
> Krzysztof
>


2024-04-18 21:44:00

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/19/2024 1:00 AM, Bartosz Golaszewski wrote:
> On Thu, 18 Apr 2024 at 16:06, Zijun Hu <[email protected]> wrote:
>>
>> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>>
>> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
>> with gpiod_get_optional()") will cause serious regression issue for
>> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
>> QCA_QCA6390 and QCA_QCA2066, the regression issue is that BT can't be
>> enabled any more once BT is disabled if BT reset pin is not configured
>> by DT or ACPI.
>>
>> if BT reset pin is not configured, devm_gpiod_get_optional() will return
>> NULL, and we should NOT set quirk HCI_QUIRK_NON_PERSISTENT_SETUP, but the
>> reverted commit SET the quirk since NULL is not a error case, and cause
>> qca_setup() call failure triggered by the 2nd and later BT enable
>> operations since there are no available BT reset pin to clear BT firmware
>> downloaded by the 1st enable operation, fixed by reverting the commit.
>>
>> Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
>> Reported-by: Wren Turkal <[email protected]>
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
>> Link: https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
>> Signed-off-by: Zijun Hu <[email protected]>
>> Tested-by: Wren Turkal <[email protected]>
>> ---
>> drivers/bluetooth/hci_qca.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>> index 92fa20f5ac7d..160175a23a49 100644
>> --- a/drivers/bluetooth/hci_qca.c
>> +++ b/drivers/bluetooth/hci_qca.c
>> @@ -2323,7 +2323,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>>
>> 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) &&
>> (data->soc_type == QCA_WCN6750 ||
>> data->soc_type == QCA_WCN6855)) {
>> dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
>> @@ -2332,7 +2332,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>>
>> qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
>> GPIOD_IN);
>> - 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))
>> @@ -2354,7 +2354,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)) {
>> dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
>> power_ctrl_enabled = false;
>> }
>> --
>> 2.7.4
>>
>
> I told you under your yesterday's submission that you should instead
> consider bailing out from probe() if gpiod_get_optional() returns an
> error as right now if it returns EPROBE_DEFER (enable-gpios is there
> but the controller is not up yet), you will act like the GPIO was not
> even specified.
>
> gpiod_get_optional() returns NULL if the GPIO property is not there or
> an error if anything else goes wrong. In the latter case, you should
> abort probe.
>

1) do you meet the case that EPROBE_DEFER is returned ?

2) does the reverted change solve above issue you mentioned?

3) does the reverted change solve any functionality issue you actually meet ?

4) BT still is able to work fine by clearing the quirk even if getting preferred H/W reset way failure, why do we need to bail-out and return dev_err_probe() ?

we will fix it by right way if EPROBE_DEFER is reported.

this change is to solve the issue mentioned by commit message regardless other issues.
it is not possible for every commit to fix any other potential issues as long as the fix
doesn't introduce new issue.

right ?
> Bart


2024-04-18 22:37:25

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 18/04/2024 23:16, quic_zijuhu wrote:
> On 4/19/2024 12:52 AM, Krzysztof Kozlowski wrote:
>> On 18/04/2024 16:06, Zijun Hu wrote:
>>> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>>>
>>> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
>>> with gpiod_get_optional()") will cause serious regression issue for
>>> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
>>
>> The pin is required on 6750, 6855 and maybe others. You cannot not have
>> the GPIO.
>>
>> This is no correct fix. You provide wrong DTS and, instead fixing it,
>> try to revert kernel code.
>>
>> No, fix your DTS first.
>>
> no. your point is not right.
>
> 1) do you have any evidence that the hci_qca driver must use reset GPIO?

I think we talk here about enable-gpios, right? Then the evidence are
bindings.

> 2) why does original design do error return when get GPIO error if GPIO is mandatory?

If GPIO is mandatory, then it is expected to return error. What is the
problem here?


> 3) i meet many customer cases that BT are working fine without hci_qca operating the GPIO,
> there is why HCI_QUIRK_NON_PERSISTENT_SETUP are introduced.

Bindings tell different story and nothing in the commit msg explained
this. You did not correct bindings either.


> 4) does the reverted change solve the issue your mentioned ?

??? I did not mention any issue. I am saying that your rationale is
either not complete or not correct.

Specifically, the enable-gpios ARE currently required, so whatever you
claim here is not correct till they are required. Make them optional and
then your arguments could have sense.

Best regards,
Krzysztof


2024-04-18 22:42:32

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On Thu, 18 Apr 2024 at 23:43, quic_zijuhu <[email protected]> wrote:
>
> On 4/19/2024 1:00 AM, Bartosz Golaszewski wrote:
> > On Thu, 18 Apr 2024 at 16:06, Zijun Hu <[email protected]> wrote:
> >>
> >> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
> >>
> >> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
> >> with gpiod_get_optional()") will cause serious regression issue for
> >> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
> >> QCA_QCA6390 and QCA_QCA2066, the regression issue is that BT can't be
> >> enabled any more once BT is disabled if BT reset pin is not configured
> >> by DT or ACPI.
> >>
> >> if BT reset pin is not configured, devm_gpiod_get_optional() will return
> >> NULL, and we should NOT set quirk HCI_QUIRK_NON_PERSISTENT_SETUP, but the
> >> reverted commit SET the quirk since NULL is not a error case, and cause
> >> qca_setup() call failure triggered by the 2nd and later BT enable
> >> operations since there are no available BT reset pin to clear BT firmware
> >> downloaded by the 1st enable operation, fixed by reverting the commit.
> >>
> >> Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
> >> Reported-by: Wren Turkal <[email protected]>
> >> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
> >> Link: https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
> >> Signed-off-by: Zijun Hu <[email protected]>
> >> Tested-by: Wren Turkal <[email protected]>
> >> ---
> >> drivers/bluetooth/hci_qca.c | 6 +++---
> >> 1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> >> index 92fa20f5ac7d..160175a23a49 100644
> >> --- a/drivers/bluetooth/hci_qca.c
> >> +++ b/drivers/bluetooth/hci_qca.c
> >> @@ -2323,7 +2323,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
> >>
> >> 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) &&
> >> (data->soc_type == QCA_WCN6750 ||
> >> data->soc_type == QCA_WCN6855)) {
> >> dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
> >> @@ -2332,7 +2332,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
> >>
> >> qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
> >> GPIOD_IN);
> >> - 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))
> >> @@ -2354,7 +2354,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)) {
> >> dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
> >> power_ctrl_enabled = false;
> >> }
> >> --
> >> 2.7.4
> >>
> >
> > I told you under your yesterday's submission that you should instead
> > consider bailing out from probe() if gpiod_get_optional() returns an
> > error as right now if it returns EPROBE_DEFER (enable-gpios is there
> > but the controller is not up yet), you will act like the GPIO was not
> > even specified.
> >
> > gpiod_get_optional() returns NULL if the GPIO property is not there or
> > an error if anything else goes wrong. In the latter case, you should
> > abort probe.
> >
>
> 1) do you meet the case that EPROBE_DEFER is returned ?
>

It doesn't matter. It's about correct usage of a programming interface.

> 2) does the reverted change solve above issue you mentioned?
>

What?

> 3) does the reverted change solve any functionality issue you actually meet ?
>

What?

> 4) BT still is able to work fine by clearing the quirk even if getting preferred H/W reset way failure, why do we need to bail-out and return dev_err_probe() ?
>

The only acceptable "failure" for gpiod_get_optional() is when it
returns NULL. I should have fixed it when I sent the patch you're
reverting but I didn't spot it right away. Proceeding on any other
error makes no sense and will result in inconsistent behavior.

> we will fix it by right way if EPROBE_DEFER is reported.
>

What?

> this change is to solve the issue mentioned by commit message regardless other issues.
> it is not possible for every commit to fix any other potential issues as long as the fix
> doesn't introduce new issue.
>

What I mean is: don't revert a logically sound commit. Instead:
improve the situation on top of it. In this case: bail out on error.
And like Krzysztof said: right now the GPIO is required according to
bindings so using gpiod_get_optional() doesn't even make sense as far
as bindings go.

Bart

2024-04-18 23:18:03

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/19/2024 6:37 AM, Krzysztof Kozlowski wrote:
> On 18/04/2024 23:16, quic_zijuhu wrote:
>> On 4/19/2024 12:52 AM, Krzysztof Kozlowski wrote:
>>> On 18/04/2024 16:06, Zijun Hu wrote:
>>>> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>>>>
>>>> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
>>>> with gpiod_get_optional()") will cause serious regression issue for
>>>> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
>>>
>>> The pin is required on 6750, 6855 and maybe others. You cannot not have
>>> the GPIO.
>>>
>>> This is no correct fix. You provide wrong DTS and, instead fixing it,
>>> try to revert kernel code.
>>>
>>> No, fix your DTS first.
>>>
>> no. your point is not right.
>>
>> 1) do you have any evidence that the hci_qca driver must use reset GPIO?
>
> I think we talk here about enable-gpios, right? Then the evidence are
> bindings.
>
yes. properties within bindings only means driver supporting it, don't means user must
config it. the gpio is got by devm_gpiod_get_optional() variant. that means it is optional
about if user need to config it.
>> 2) why does original design do error return when get GPIO error if GPIO is mandatory?
>
> If GPIO is mandatory, then it is expected to return error. What is the
> problem here?
>
sorry, i miss a NOT for my question. my question is that
2) why does original design NOT do error return when get GPIO error if GPIO is mandatory?
>
>> 3) i meet many customer cases that BT are working fine without hci_qca operating the GPIO,
>> there is why HCI_QUIRK_NON_PERSISTENT_SETUP are introduced.
>
> Bindings tell different story and nothing in the commit msg explained
> this. You did not correct bindings either.
>
don't need to correct bindings. i believe bindings does not say enable gpio
must be configured.
>
>> 4) does the reverted change solve the issue your mentioned ?
>
> ??? I did not mention any issue. I am saying that your rationale is
> either not complete or not correct.
>
do you suggest about how to make it complete?

> Specifically, the enable-gpios ARE currently required, so whatever you
> claim here is not correct till they are required. Make them optional and
> then your arguments could have sense.
>
> Best regards,
> Krzysztof
>


2024-04-18 23:42:14

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/19/2024 6:42 AM, Bartosz Golaszewski wrote:
> On Thu, 18 Apr 2024 at 23:43, quic_zijuhu <[email protected]> wrote:
>>
>> On 4/19/2024 1:00 AM, Bartosz Golaszewski wrote:
>>> On Thu, 18 Apr 2024 at 16:06, Zijun Hu <[email protected]> wrote:
>>>>
>>>> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>>>>
>>>> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
>>>> with gpiod_get_optional()") will cause serious regression issue for
>>>> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
>>>> QCA_QCA6390 and QCA_QCA2066, the regression issue is that BT can't be
>>>> enabled any more once BT is disabled if BT reset pin is not configured
>>>> by DT or ACPI.
>>>>
>>>> if BT reset pin is not configured, devm_gpiod_get_optional() will return
>>>> NULL, and we should NOT set quirk HCI_QUIRK_NON_PERSISTENT_SETUP, but the
>>>> reverted commit SET the quirk since NULL is not a error case, and cause
>>>> qca_setup() call failure triggered by the 2nd and later BT enable
>>>> operations since there are no available BT reset pin to clear BT firmware
>>>> downloaded by the 1st enable operation, fixed by reverting the commit.
>>>>
>>>> Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
>>>> Reported-by: Wren Turkal <[email protected]>
>>>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
>>>> Link: https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
>>>> Signed-off-by: Zijun Hu <[email protected]>
>>>> Tested-by: Wren Turkal <[email protected]>
>>>> ---
>>>> drivers/bluetooth/hci_qca.c | 6 +++---
>>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>>>> index 92fa20f5ac7d..160175a23a49 100644
>>>> --- a/drivers/bluetooth/hci_qca.c
>>>> +++ b/drivers/bluetooth/hci_qca.c
>>>> @@ -2323,7 +2323,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>>>>
>>>> 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) &&
>>>> (data->soc_type == QCA_WCN6750 ||
>>>> data->soc_type == QCA_WCN6855)) {
>>>> dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
>>>> @@ -2332,7 +2332,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>>>>
>>>> qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
>>>> GPIOD_IN);
>>>> - 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))
>>>> @@ -2354,7 +2354,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)) {
>>>> dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
>>>> power_ctrl_enabled = false;
>>>> }
>>>> --
>>>> 2.7.4
>>>>
>>>
>>> I told you under your yesterday's submission that you should instead
>>> consider bailing out from probe() if gpiod_get_optional() returns an
>>> error as right now if it returns EPROBE_DEFER (enable-gpios is there
>>> but the controller is not up yet), you will act like the GPIO was not
>>> even specified.
>>>
>>> gpiod_get_optional() returns NULL if the GPIO property is not there or
>>> an error if anything else goes wrong. In the latter case, you should
>>> abort probe.
>>>
>>
>> 1) do you meet the case that EPROBE_DEFER is returned ?
>>
>
> It doesn't matter. It's about correct usage of a programming interface.
>
>> 2) does the reverted change solve above issue you mentioned?
>>
>
> What?
>
the revert change means below change.
Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")

>> 3) does the reverted change solve any functionality issue you actually meet ?
>>
>
> What?
>
see above.
>> 4) BT still is able to work fine by clearing the quirk even if getting preferred H/W reset way failure, why do we need to bail-out and return dev_err_probe() ?
>>
>
> The only acceptable "failure" for gpiod_get_optional() is when it
> returns NULL. I should have fixed it when I sent the patch you're
> reverting but I didn't spot it right away. Proceeding on any other
> error makes no sense and will result in inconsistent behavior.
>
as i ever explained. we need to treat NULL returning and error returning equivalently.

>> we will fix it by right way if EPROBE_DEFER is reported.
>>
>
> What?
>
will fix the issue if anyone meet and report they meet the error that EPROBE_DEFER is reported.
>> this change is to solve the issue mentioned by commit message regardless other issues.
>> it is not possible for every commit to fix any other potential issues as long as the fix
>> doesn't introduce new issue.
>>
>
> What I mean is: don't revert a logically sound commit. Instead:
> improve the situation on top of it. In this case: bail out on error.
> And like Krzysztof said: right now the GPIO is required according to
> bindings so using gpiod_get_optional() doesn't even make sense as far
> as bindings go.
>
my point is that it is not logically sound commit.
> Bart


2024-04-19 13:49:51

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 19/04/2024 01:17, quic_zijuhu wrote:
> On 4/19/2024 6:37 AM, Krzysztof Kozlowski wrote:
>> On 18/04/2024 23:16, quic_zijuhu wrote:
>>> On 4/19/2024 12:52 AM, Krzysztof Kozlowski wrote:
>>>> On 18/04/2024 16:06, Zijun Hu wrote:
>>>>> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>>>>>
>>>>> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
>>>>> with gpiod_get_optional()") will cause serious regression issue for
>>>>> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
>>>>
>>>> The pin is required on 6750, 6855 and maybe others. You cannot not have
>>>> the GPIO.
>>>>
>>>> This is no correct fix. You provide wrong DTS and, instead fixing it,
>>>> try to revert kernel code.
>>>>
>>>> No, fix your DTS first.
>>>>
>>> no. your point is not right.
>>>
>>> 1) do you have any evidence that the hci_qca driver must use reset GPIO?
>>
>> I think we talk here about enable-gpios, right? Then the evidence are
>> bindings.
>>
> yes. properties within bindings only means driver supporting it, don't means user must
> config it. the gpio is got by devm_gpiod_get_optional() variant. that means it is optional
> about if user need to config it.

No. Read writing bindings and other presentations explaining what are
Devicetree bindings.

You miss entirely the point and use downstream narrative. This won't
work and it was told so many times, that I expect you to do the homework
first.

Use "go/upstream" before posting more on this topic.


>>> 2) why does original design do error return when get GPIO error if GPIO is mandatory?
>>
>> If GPIO is mandatory, then it is expected to return error. What is the
>> problem here?
>>
> sorry, i miss a NOT for my question. my question is that
> 2) why does original design NOT do error return when get GPIO error if GPIO is mandatory?
>>
>>> 3) i meet many customer cases that BT are working fine without hci_qca operating the GPIO,
>>> there is why HCI_QUIRK_NON_PERSISTENT_SETUP are introduced.
>>
>> Bindings tell different story and nothing in the commit msg explained
>> this. You did not correct bindings either.
>>
> don't need to correct bindings. i believe bindings does not say enable gpio
> must be configured.

They say. Read the bindings. Test your DTS. Or better: upstream your DTS
and prove to us that dtbs_check allows lack of enable-gpios.


>>
>>> 4) does the reverted change solve the issue your mentioned ?
>>
>> ??? I did not mention any issue. I am saying that your rationale is
>> either not complete or not correct.
>>
> do you suggest about how to make it complete?

Yes, read what are bindings and then describe your change including
that: what is the issue, how it can be reproduced, what is the hardware,
why the bindings are not correct (if they are not correct) etc.


Best regards,
Krzysztof


2024-04-19 21:27:19

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On Fri, 19 Apr 2024 at 01:36, quic_zijuhu <[email protected]> wrote:
>
> On 4/19/2024 6:42 AM, Bartosz Golaszewski wrote:
> > On Thu, 18 Apr 2024 at 23:43, quic_zijuhu <[email protected]> wrote:
>
> >> we will fix it by right way if EPROBE_DEFER is reported.
> >>
> >
> > What?
> >
> will fix the issue if anyone meet and report they meet the error that EPROBE_DEFER is reported.

No, this is wrong. Anything other than NULL or a valid descriptor
pointer returned from gpiod_get_optional() means: an error has
occurred and should be handled accordingly. Please improve the driver
by bailing out in this case. Or wait until next week and I'll send a
follow-up to my patch myself.

Bart

2024-04-20 05:25:52

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/19/2024 9:49 PM, Krzysztof Kozlowski wrote:

Hi Krzysztof,bartosz,

let me summarize our discussion here in order to reduce unneccessary
disagreements here.

1) i only revert your change IS_ERR() to my change IS_ERR_OR_NULL.

2) your change will cause serious regression issues for many lunched
products

3) we only need to discuss how to handle devm_gpiod_get_optional(...,
"enable", ...) returning NULL since this is only difference between your
change and mine.

4) your change doesn't solve any actual issue and the reason you
submitted is that "The optional variants for the gpiod_get() family of
functions return NULL if the GPIO in question is not associated with
this device, and should not treat it as error".

code applet of your merged change is shown by below link
https://patchwork.kernel.org/project/bluetooth/patch/[email protected]/#25705104

qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
GPIOD_OUT_LOW);
- if (IS_ERR_OR_NULL(qcadev->bt_en)) {
+ if (IS_ERR(qcadev->bt_en)) {
dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
power_ctrl_enabled = false;
}

5) Original BT driver design agree with your point mentioned at 4), so
for case "qcadev->bt_en == nullptr", qca_serdev_probe() don't do error
return for this scenario and use dev_warn() instead of dev_err() to give
user prompt.

6) your wrong fix changes flag power_ctrl_enabled set logic and will
cause serious BT regression issue, hope you will realize this point.


i would like to give below extra comments even if these comments are
irrelevant to the critical point of this issue mentioned at above 3)

A) you need to investigate it is a) the prompting approach or message
error or b) the if condition error even if if dev_err() is used to give
prompt instead of dev_warn() in above 4).

B) don't talk about how about devm_gpiod_get_optional() returning error
case since it is meaningless as explained by above 3). also don't
require a fix to fix another unreported issue. a fix is a good fix
if it fix the issue in question and don't introduce new issue.

C) per DTS property enable-gpios of BT, different soc types have
different requirements, many are required and another many are NOT
mandatory as shown be below link.
https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml.

for a soc type which are attached to 3rd platform, customer doesn't
would like to or are not able to congfig BT reset pin within DTS for QCA
driver even if QC strongly suggest customer config it and also be marked
as required within above DTS bindings spec link. i often meet this
scenario. there are many of such lunched products.

i will try to fix this issue due your change product by product in new
patch thread based on this DTS comment.

D) you maybe ping me offline about this issue if you are a member of QC
since you known "go/upstream"

> On 19/04/2024 01:17, quic_zijuhu wrote:
>> On 4/19/2024 6:37 AM, Krzysztof Kozlowski wrote:
>>> On 18/04/2024 23:16, quic_zijuhu wrote:
>>>> On 4/19/2024 12:52 AM, Krzysztof Kozlowski wrote:
>>>>> On 18/04/2024 16:06, Zijun Hu wrote:
>>>>>> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>>>>>>
>>>>>> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
>>>>>> with gpiod_get_optional()") will cause serious regression issue for
>>>>>> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
>>>>>
>>>>> The pin is required on 6750, 6855 and maybe others. You cannot not have
>>>>> the GPIO.
>>>>>
>>>>> This is no correct fix. You provide wrong DTS and, instead fixing it,
>>>>> try to revert kernel code.
>>>>>
>>>>> No, fix your DTS first.
>>>>>
>>>> no. your point is not right.
>>>>
>>>> 1) do you have any evidence that the hci_qca driver must use reset GPIO?
>>>
>>> I think we talk here about enable-gpios, right? Then the evidence are
>>> bindings.
>>>
>> yes. properties within bindings only means driver supporting it, don't means user must
>> config it. the gpio is got by devm_gpiod_get_optional() variant. that means it is optional
>> about if user need to config it.
>
> No. Read writing bindings and other presentations explaining what are
> Devicetree bindings.
>
> You miss entirely the point and use downstream narrative. This won't
> work and it was told so many times, that I expect you to do the homework
> first.
>
> Use "go/upstream" before posting more on this topic.
>
>
>>>> 2) why does original design do error return when get GPIO error if GPIO is mandatory?
>>>
>>> If GPIO is mandatory, then it is expected to return error. What is the
>>> problem here?
>>>
>> sorry, i miss a NOT for my question. my question is that
>> 2) why does original design NOT do error return when get GPIO error if GPIO is mandatory?
>>>
>>>> 3) i meet many customer cases that BT are working fine without hci_qca operating the GPIO,
>>>> there is why HCI_QUIRK_NON_PERSISTENT_SETUP are introduced.
>>>
>>> Bindings tell different story and nothing in the commit msg explained
>>> this. You did not correct bindings either.
>>>
>> don't need to correct bindings. i believe bindings does not say enable gpio
>> must be configured.
>
> They say. Read the bindings. Test your DTS. Or better: upstream your DTS
> and prove to us that dtbs_check allows lack of enable-gpios.
>
>
>>>
>>>> 4) does the reverted change solve the issue your mentioned ?
>>>
>>> ??? I did not mention any issue. I am saying that your rationale is
>>> either not complete or not correct.
>>>
>> do you suggest about how to make it complete?
>
> Yes, read what are bindings and then describe your change including
> that: what is the issue, how it can be reproduced, what is the hardware,
> why the bindings are not correct (if they are not correct) etc.
>
>
> Best regards,
> Krzysztof
>


2024-04-20 05:28:00

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/20/2024 1:25 PM, quic_zijuhu wrote:
> On 4/19/2024 9:49 PM, Krzysztof Kozlowski wrote:
>
> Hi Krzysztof,bartosz,
>
> let me summarize our discussion here in order to reduce unneccessary
> disagreements here.
>
> 1) i only revert your change IS_ERR() to my change IS_ERR_OR_NULL.
>
> 2) your change will cause serious regression issues for many lunched
> products
>
> 3) we only need to discuss how to handle devm_gpiod_get_optional(...,
> "enable", ...) returning NULL since this is only difference between your
> change and mine.
>
> 4) your change doesn't solve any actual issue and the reason you
> submitted is that "The optional variants for the gpiod_get() family of
> functions return NULL if the GPIO in question is not associated with
> this device, and should not treat it as error".
>
> code applet of your merged change is shown by below link
> https://patchwork.kernel.org/project/bluetooth/patch/[email protected]/#25705104
>
> qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
> GPIOD_OUT_LOW);
> - if (IS_ERR_OR_NULL(qcadev->bt_en)) {
> + if (IS_ERR(qcadev->bt_en)) {
> dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
> power_ctrl_enabled = false;
> }
>
> 5) Original BT driver design agree with your point mentioned at 4), so
> for case "qcadev->bt_en == nullptr", qca_serdev_probe() don't do error
> return for this scenario and use dev_warn() instead of dev_err() to give
> user prompt.
>
> 6) your wrong fix changes flag power_ctrl_enabled set logic and will
> cause serious BT regression issue, hope you will realize this point.
>
>
> i would like to give below extra comments even if these comments are
> irrelevant to the critical point of this issue mentioned at above 3)
>
> A) you need to investigate it is a) the prompting approach or message
> error or b) the if condition error even if if dev_err() is used to give
> prompt instead of dev_warn() in above 4).
>
> B) don't talk about how about devm_gpiod_get_optional() returning error
> case since it is meaningless as explained by above 3). also don't
> require a fix to fix another unreported issue. a fix is a good fix
> if it fix the issue in question and don't introduce new issue.
>
> C) per DTS property enable-gpios of BT, different soc types have
> different requirements, many are required and another many are NOT
> mandatory as shown be below link.
> https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml.
>
> for a soc type which are attached to 3rd platform, customer doesn't
> would like to or are not able to congfig BT reset pin within DTS for QCA
> driver even if QC strongly suggest customer config it and also be marked
> as required within above DTS bindings spec link. i often meet this
> scenario. there are many of such lunched products.
>
> i will try to fix this issue due your change product by product in new
> patch thread based on this DTS comment.
>
> D) you maybe ping me offline about this issue if you are a member of QC
> since you known "go/upstream"
>
>> On 19/04/2024 01:17, quic_zijuhu wrote:
>>> On 4/19/2024 6:37 AM, Krzysztof Kozlowski wrote:
>>>> On 18/04/2024 23:16, quic_zijuhu wrote:
>>>>> On 4/19/2024 12:52 AM, Krzysztof Kozlowski wrote:
>>>>>> On 18/04/2024 16:06, Zijun Hu wrote:
>>>>>>> This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8.
>>>>>>>
>>>>>>> Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL()
>>>>>>> with gpiod_get_optional()") will cause serious regression issue for
>>>>>>> several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME,
>>>>>>
>>>>>> The pin is required on 6750, 6855 and maybe others. You cannot not have
>>>>>> the GPIO.
>>>>>>
>>>>>> This is no correct fix. You provide wrong DTS and, instead fixing it,
>>>>>> try to revert kernel code.
>>>>>>
>>>>>> No, fix your DTS first.
>>>>>>
>>>>> no. your point is not right.
>>>>>
>>>>> 1) do you have any evidence that the hci_qca driver must use reset GPIO?
>>>>
>>>> I think we talk here about enable-gpios, right? Then the evidence are
>>>> bindings.
>>>>
>>> yes. properties within bindings only means driver supporting it, don't means user must
>>> config it. the gpio is got by devm_gpiod_get_optional() variant. that means it is optional
>>> about if user need to config it.
>>
>> No. Read writing bindings and other presentations explaining what are
>> Devicetree bindings.
>>
>> You miss entirely the point and use downstream narrative. This won't
>> work and it was told so many times, that I expect you to do the homework
>> first.
>>
>> Use "go/upstream" before posting more on this topic.
>>
>>
>>>>> 2) why does original design do error return when get GPIO error if GPIO is mandatory?
>>>>
>>>> If GPIO is mandatory, then it is expected to return error. What is the
>>>> problem here?
>>>>
>>> sorry, i miss a NOT for my question. my question is that
>>> 2) why does original design NOT do error return when get GPIO error if GPIO is mandatory?
>>>>
>>>>> 3) i meet many customer cases that BT are working fine without hci_qca operating the GPIO,
>>>>> there is why HCI_QUIRK_NON_PERSISTENT_SETUP are introduced.
>>>>
>>>> Bindings tell different story and nothing in the commit msg explained
>>>> this. You did not correct bindings either.
>>>>
>>> don't need to correct bindings. i believe bindings does not say enable gpio
>>> must be configured.
>>
>> They say. Read the bindings. Test your DTS. Or better: upstream your DTS
>> and prove to us that dtbs_check allows lack of enable-gpios.
>>
>>
>>>>
>>>>> 4) does the reverted change solve the issue your mentioned ?
>>>>
>>>> ??? I did not mention any issue. I am saying that your rationale is
>>>> either not complete or not correct.
>>>>
>>> do you suggest about how to make it complete?
>>
>> Yes, read what are bindings and then describe your change including
>> that: what is the issue, how it can be reproduced, what is the hardware,
>> why the bindings are not correct (if they are not correct) etc.
>>
>>
>> Best regards,
>> Krzysztof
>>
>


2024-04-20 05:39:33

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/20/2024 5:27 AM, Bartosz Golaszewski wrote:
> On Fri, 19 Apr 2024 at 01:36, quic_zijuhu <[email protected]> wrote:
>>
>> On 4/19/2024 6:42 AM, Bartosz Golaszewski wrote:
>>> On Thu, 18 Apr 2024 at 23:43, quic_zijuhu <[email protected]> wrote:
>>
>>>> we will fix it by right way if EPROBE_DEFER is reported.
>>>>
>>>
>>> What?
>>>
>> will fix the issue if anyone meet and report they meet the error that EPROBE_DEFER is reported.
>
> No, this is wrong. Anything other than NULL or a valid descriptor
> pointer returned from gpiod_get_optional() means: an error has
> occurred and should be handled accordingly. Please improve the driver
> by bailing out in this case. Or wait until next week and I'll send a
> follow-up to my patch myself.
>
i think we don't need to focus on this point as commented at below link
https://lore.kernel.org/all/[email protected]/
> Bart


2024-04-20 11:14:06

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 20/04/2024 07:25, quic_zijuhu wrote:
> On 4/19/2024 9:49 PM, Krzysztof Kozlowski wrote:
>
> Hi Krzysztof,bartosz,
>
> let me summarize our discussion here in order to reduce unneccessary
> disagreements here.
>
> 1) i only revert your change IS_ERR() to my change IS_ERR_OR_NULL.
>
> 2) your change will cause serious regression issues for many lunched
> products

Instead of repeating every time "serious regression" can you actually
explain the problem?
None of commit messages from v3 help there.

>
> 3) we only need to discuss how to handle devm_gpiod_get_optional(...,
> "enable", ...) returning NULL since this is only difference between your
> change and mine.
>
> 4) your change doesn't solve any actual issue and the reason you
> submitted is that "The optional variants for the gpiod_get() family of
> functions return NULL if the GPIO in question is not associated with
> this device, and should not treat it as error".
>
> code applet of your merged change is shown by below link
> https://patchwork.kernel.org/project/bluetooth/patch/[email protected]/#25705104
>
> qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
> GPIOD_OUT_LOW);
> - if (IS_ERR_OR_NULL(qcadev->bt_en)) {
> + if (IS_ERR(qcadev->bt_en)) {
> dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
> power_ctrl_enabled = false;
> }
>
> 5) Original BT driver design agree with your point mentioned at 4), so
> for case "qcadev->bt_en == nullptr", qca_serdev_probe() don't do error
> return for this scenario and use dev_warn() instead of dev_err() to give
> user prompt.
>
> 6) your wrong fix changes flag power_ctrl_enabled set logic and will
> cause serious BT regression issue, hope you will realize this point.

Sorry, not realized and you did not explain it. Neither above nor in
commit msg.

>
>
> i would like to give below extra comments even if these comments are
> irrelevant to the critical point of this issue mentioned at above 3)
>
> A) you need to investigate it is a) the prompting approach or message
> error or b) the if condition error even if if dev_err() is used to give
> prompt instead of dev_warn() in above 4).

What?

>
> B) don't talk about how about devm_gpiod_get_optional() returning error
> case since it is meaningless as explained by above 3). also don't
> require a fix to fix another unreported issue. a fix is a good fix
> if it fix the issue in question and don't introduce new issue.

What?

>
> C) per DTS property enable-gpios of BT, different soc types have
> different requirements, many are required and another many are NOT
> mandatory as shown be below link.
> https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml.
>
> for a soc type which are attached to 3rd platform, customer doesn't
> would like to or are not able to congfig BT reset pin within DTS for QCA
> driver even if QC strongly suggest customer config it and also be marked
> as required within above DTS bindings spec link. i often meet this
> scenario. there are many of such lunched products.

So where is it documented? Where is it explained? Which binding or which
commit msg?

>
> i will try to fix this issue due your change product by product in new
> patch thread based on this DTS comment.
>
> D) you maybe ping me offline about this issue if you are a member of QC
> since you known "go/upstream"

Please keep all discussions public, unless your customer requires some
sort of confidentiality. Although even then I would argue that you can
hide company secrets and discuss about hardware.

Best regards,
Krzysztof


2024-04-20 23:01:27

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/20/2024 7:13 PM, Krzysztof Kozlowski wrote:
> On 20/04/2024 07:25, quic_zijuhu wrote:
>> On 4/19/2024 9:49 PM, Krzysztof Kozlowski wrote:
>>
>> Hi Krzysztof,bartosz,
>>
>> let me summarize our discussion here in order to reduce unneccessary
>> disagreements here.
>>
>> 1) i only revert your change IS_ERR() to my change IS_ERR_OR_NULL.
>>
>> 2) your change will cause serious regression issues for many lunched
>> products
>
> Instead of repeating every time "serious regression" can you actually
> explain the problem?
> None of commit messages from v3 help there.
>
as shown by below link
https://lore.kernel.org/all/[email protected]/

there are no v3 patch for patch serial with this tile
the updated patch serial tile is "Fix two regression issues for QCA
controllers" shown by above mentioned link.

let us discuss it with the updated one.

v3 of the updated one has good commit message for this issue. you have
given reply with the v3 and it seems you understand what is the problem

>>
>> 3) we only need to discuss how to handle devm_gpiod_get_optional(...,
>> "enable", ...) returning NULL since this is only difference between your
>> change and mine.
>>
>> 4) your change doesn't solve any actual issue and the reason you
>> submitted is that "The optional variants for the gpiod_get() family of
>> functions return NULL if the GPIO in question is not associated with
>> this device, and should not treat it as error".
>>
>> code applet of your merged change is shown by below link
>> https://patchwork.kernel.org/project/bluetooth/patch/[email protected]/#25705104
>>
>> qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
>> GPIOD_OUT_LOW);
>> - if (IS_ERR_OR_NULL(qcadev->bt_en)) {
>> + if (IS_ERR(qcadev->bt_en)) {
>> dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
>> power_ctrl_enabled = false;
>> }
>>
>> 5) Original BT driver design agree with your point mentioned at 4), so
>> for case "qcadev->bt_en == nullptr", qca_serdev_probe() don't do error
>> return for this scenario and use dev_warn() instead of dev_err() to give
>> user prompt.
>>
>> 6) your wrong fix changes flag power_ctrl_enabled set logic and will
>> cause serious BT regression issue, hope you will realize this point.
>
> Sorry, not realized and you did not explain it. Neither above nor in
> commit msg.
>
now. you understood why your merged change as shown link of 4) have
problems and introduced our discussed issue, right?

>>
>>
>> i would like to give below extra comments even if these comments are
>> irrelevant to the critical point of this issue mentioned at above 3)
>>
>> A) you need to investigate it is a) the prompting approach or message
>> error or b) the if condition error even if if dev_err() is used to give
>> prompt instead of dev_warn() in above 4).
>
> What?
>
>>
>> B) don't talk about how about devm_gpiod_get_optional() returning error
>> case since it is meaningless as explained by above 3). also don't
>> require a fix to fix another unreported issue. a fix is a good fix
>> if it fix the issue in question and don't introduce new issue.
>
> What?
>
>>
>> C) per DTS property enable-gpios of BT, different soc types have
>> different requirements, many are required and another many are NOT
>> mandatory as shown be below link.
>> https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml.
>>
>> for a soc type which are attached to 3rd platform, customer doesn't
>> would like to or are not able to congfig BT reset pin within DTS for QCA
>> driver even if QC strongly suggest customer config it and also be marked
>> as required within above DTS bindings spec link. i often meet this
>> scenario. there are many of such lunched products.
>
> So where is it documented? Where is it explained? Which binding or which
> commit msg?
>
>>
>> i will try to fix this issue due your change product by product in new
>> patch thread based on this DTS comment.
>>
>> D) you maybe ping me offline about this issue if you are a member of QC
>> since you known "go/upstream"
>
> Please keep all discussions public, unless your customer requires some
> sort of confidentiality. Although even then I would argue that you can
> hide company secrets and discuss about hardware.
>
> Best regards,
> Krzysztof
>
>


2024-04-21 07:14:38

by Wren Turkal

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/18/24 3:42 PM, Bartosz Golaszewski wrote:
>> 1) do you meet the case that EPROBE_DEFER is returned ?
>>
> It doesn't matter. It's about correct usage of a programming interface.

In case you are not aware, this apparent correct usage of the
programming interface breaks real hardware. As a kernel user with this
problem, I am just wondering if we expect a fix to land before v6.9 lands.

If we can't find the a fix that has "correct usage of the programming
interface" before 6.9 closes out, would we be able to revert this change
considering that it causes a real userspace regression in that the BT on
some laptops simply don't work now? I guess I am asking if this
theoretical correction more important than breaking actual currently
supported hardware?

Real users like me are hurt by this. In my case, I am using a laptop
that was shipped in 2020 with Linux by Dell that included working BT
support. I now have broken BT hardware that is barely usable at all.

And as a kernel user, I thought the kernel had a no regression policy.
Granted, I don't know the specific details of how it works. Does that
policy include support of widely deployed hardware?

Just so you know, I am just trying to understand what to expect.

Also, I want to offer help. Is there anything I can do to help y'all
reach a resolution?

Thanks,
wt
--
You're more amazing than you think!

2024-04-21 09:40:49

by Zijun Hu

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/21/2024 3:14 PM, Wren Turkal wrote:
> On 4/18/24 3:42 PM, Bartosz Golaszewski wrote:
>>> 1) do you meet the case that EPROBE_DEFER is returned ?
>>>
>> It doesn't matter. It's about correct usage of a programming interface.
>
> In case you are not aware, this apparent correct usage of the
> programming interface breaks real hardware. As a kernel user with this
> problem, I am just wondering if we expect a fix to land before v6.9 lands.
>
> If we can't find the a fix that has "correct usage of the programming
> interface" before 6.9 closes out, would we be able to revert this change
> considering that it causes a real userspace regression in that the BT on
> some laptops simply don't work now? I guess I am asking if this
> theoretical correction more important than breaking actual currently
> supported hardware?
>
> Real users like me are hurt by this. In my case, I am using a laptop
> that was shipped in 2020 with Linux by Dell that included working BT
> support. I now have broken BT hardware that is barely usable at all.
>
> And as a kernel user, I thought the kernel had a no regression policy.
> Granted, I don't know the specific details of how it works. Does that
> policy include support of widely deployed hardware?
>
> Just so you know, I am just trying to understand what to expect.
>
> Also, I want to offer help. Is there anything I can do to help y'all
> reach a resolution?
>
> Thanks,
> wt
per QCA6390. we have correct usage of a programming interface.

as my reply at below link, we don't need to take care bout
Bartosz's question since it is not relevant with this issue.

https://lore.kernel.org/all/[email protected]/

2024-04-22 05:27:20

by Wren Turkal

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()"

On 4/21/24 2:40 AM, quic_zijuhu wrote:
> On 4/21/2024 3:14 PM, Wren Turkal wrote:
>> On 4/18/24 3:42 PM, Bartosz Golaszewski wrote:
>>>> 1) do you meet the case that EPROBE_DEFER is returned ?
>>>>
>>> It doesn't matter. It's about correct usage of a programming interface.
>>
>> In case you are not aware, this apparent correct usage of the
>> programming interface breaks real hardware. As a kernel user with this
>> problem, I am just wondering if we expect a fix to land before v6.9 lands.
>>
>> If we can't find the a fix that has "correct usage of the programming
>> interface" before 6.9 closes out, would we be able to revert this change
>> considering that it causes a real userspace regression in that the BT on
>> some laptops simply don't work now? I guess I am asking if this
>> theoretical correction more important than breaking actual currently
>> supported hardware?
>>
>> Real users like me are hurt by this. In my case, I am using a laptop
>> that was shipped in 2020 with Linux by Dell that included working BT
>> support. I now have broken BT hardware that is barely usable at all.
>>
>> And as a kernel user, I thought the kernel had a no regression policy.
>> Granted, I don't know the specific details of how it works. Does that
>> policy include support of widely deployed hardware?
>>
>> Just so you know, I am just trying to understand what to expect.
>>
>> Also, I want to offer help. Is there anything I can do to help y'all
>> reach a resolution?
>>
>> Thanks,
>> wt
> per QCA6390. we have correct usage of a programming interface.
>
> as my reply at below link, we don't need to take care bout
> Bartosz's question since it is not relevant with this issue.
>
> https://lore.kernel.org/all/[email protected]/

Ack. Thx for the pointer.

I will admit, I am finding it a bit difficult to follow the discussion.
As such, I have no opinion on who's right. I just want to help reach a
conclusion that includes my hardware working.

wt
--
You're more amazing than you think!