diff mbox series

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

Message ID 1713449192-25926-2-git-send-email-quic_zijuhu@quicinc.com (mailing list archive)
State Superseded
Headers show
Series Fix two regression issues for QCA controllers | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report #116: Reported-by: Wren Turkal <wt@penguintechs.org> 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.
tedd_an/GitLint fail 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/ea20bb9b-6b60-47fc-ae42-5eed918ad7b4@quicinc.com/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f"
tedd_an/SubjectPrefix success Gitlint PASS
tedd_an/BuildKernel success BuildKernel PASS
tedd_an/CheckAllWarning success CheckAllWarning PASS
tedd_an/CheckSparse success CheckSparse PASS
tedd_an/CheckSmatch fail CheckSparse: FAIL: 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
tedd_an/BuildKernel32 success BuildKernel32 PASS
tedd_an/TestRunnerSetup success TestRunnerSetup PASS
tedd_an/TestRunner_l2cap-tester success TestRunner PASS
tedd_an/TestRunner_iso-tester success TestRunner PASS
tedd_an/TestRunner_bnep-tester success TestRunner PASS
tedd_an/TestRunner_mgmt-tester fail TestRunner_mgmt-tester: Total: 492, Passed: 489 (99.4%), Failed: 1, Not Run: 2
tedd_an/TestRunner_rfcomm-tester success TestRunner PASS
tedd_an/TestRunner_sco-tester success TestRunner PASS
tedd_an/TestRunner_ioctl-tester success TestRunner PASS
tedd_an/TestRunner_mesh-tester success TestRunner PASS
tedd_an/TestRunner_smp-tester success TestRunner PASS
tedd_an/TestRunner_userchan-tester success TestRunner PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

quic_zijuhu April 18, 2024, 2:06 p.m. UTC
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 <wt@penguintechs.org>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
Link: https://lore.kernel.org/linux-bluetooth/ea20bb9b-6b60-47fc-ae42-5eed918ad7b4@quicinc.com/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Tested-by: Wren Turkal <wt@penguintechs.org>
---
 drivers/bluetooth/hci_qca.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

bluez.test.bot@gmail.com April 18, 2024, 2:31 p.m. UTC | #1
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 <wt@penguintechs.org>
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/ea20bb9b-6b60-47fc-ae42-5eed918ad7b4@quicinc.com/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
Krzysztof Kozlowski April 18, 2024, 4:52 p.m. UTC | #2
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
Bartosz Golaszewski April 18, 2024, 5 p.m. UTC | #3
On Thu, 18 Apr 2024 at 16:06, Zijun Hu <quic_zijuhu@quicinc.com> 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 <wt@penguintechs.org>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
> Link: https://lore.kernel.org/linux-bluetooth/ea20bb9b-6b60-47fc-ae42-5eed918ad7b4@quicinc.com/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> Tested-by: Wren Turkal <wt@penguintechs.org>
> ---
>  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
quic_zijuhu April 18, 2024, 9:16 p.m. UTC | #4
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
>
quic_zijuhu April 18, 2024, 9:43 p.m. UTC | #5
On 4/19/2024 1:00 AM, Bartosz Golaszewski wrote:
> On Thu, 18 Apr 2024 at 16:06, Zijun Hu <quic_zijuhu@quicinc.com> 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 <wt@penguintechs.org>
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
>> Link: https://lore.kernel.org/linux-bluetooth/ea20bb9b-6b60-47fc-ae42-5eed918ad7b4@quicinc.com/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
>> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
>> Tested-by: Wren Turkal <wt@penguintechs.org>
>> ---
>>  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
Krzysztof Kozlowski April 18, 2024, 10:37 p.m. UTC | #6
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
Bartosz Golaszewski April 18, 2024, 10:42 p.m. UTC | #7
On Thu, 18 Apr 2024 at 23:43, quic_zijuhu <quic_zijuhu@quicinc.com> wrote:
>
> On 4/19/2024 1:00 AM, Bartosz Golaszewski wrote:
> > On Thu, 18 Apr 2024 at 16:06, Zijun Hu <quic_zijuhu@quicinc.com> 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 <wt@penguintechs.org>
> >> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
> >> Link: https://lore.kernel.org/linux-bluetooth/ea20bb9b-6b60-47fc-ae42-5eed918ad7b4@quicinc.com/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
> >> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> >> Tested-by: Wren Turkal <wt@penguintechs.org>
> >> ---
> >>  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
quic_zijuhu April 18, 2024, 11:17 p.m. UTC | #8
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
>
quic_zijuhu April 18, 2024, 11:36 p.m. UTC | #9
On 4/19/2024 6:42 AM, Bartosz Golaszewski wrote:
> On Thu, 18 Apr 2024 at 23:43, quic_zijuhu <quic_zijuhu@quicinc.com> wrote:
>>
>> On 4/19/2024 1:00 AM, Bartosz Golaszewski wrote:
>>> On Thu, 18 Apr 2024 at 16:06, Zijun Hu <quic_zijuhu@quicinc.com> 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 <wt@penguintechs.org>
>>>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726
>>>> Link: https://lore.kernel.org/linux-bluetooth/ea20bb9b-6b60-47fc-ae42-5eed918ad7b4@quicinc.com/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f
>>>> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
>>>> Tested-by: Wren Turkal <wt@penguintechs.org>
>>>> ---
>>>>  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
Krzysztof Kozlowski April 19, 2024, 1:49 p.m. UTC | #10
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
Bartosz Golaszewski April 19, 2024, 9:27 p.m. UTC | #11
On Fri, 19 Apr 2024 at 01:36, quic_zijuhu <quic_zijuhu@quicinc.com> wrote:
>
> On 4/19/2024 6:42 AM, Bartosz Golaszewski wrote:
> > On Thu, 18 Apr 2024 at 23:43, quic_zijuhu <quic_zijuhu@quicinc.com> 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
quic_zijuhu April 20, 2024, 5:25 a.m. UTC | #12
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/20240208164017.26699-1-brgl@bgdev.pl/#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
>
quic_zijuhu April 20, 2024, 5:27 a.m. UTC | #13
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/20240208164017.26699-1-brgl@bgdev.pl/#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
>>
>
quic_zijuhu April 20, 2024, 5:39 a.m. UTC | #14
On 4/20/2024 5:27 AM, Bartosz Golaszewski wrote:
> On Fri, 19 Apr 2024 at 01:36, quic_zijuhu <quic_zijuhu@quicinc.com> wrote:
>>
>> On 4/19/2024 6:42 AM, Bartosz Golaszewski wrote:
>>> On Thu, 18 Apr 2024 at 23:43, quic_zijuhu <quic_zijuhu@quicinc.com> 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/01677a26-ea91-47cc-bdc4-283cf313d8e4@quicinc.com/
> Bart
Krzysztof Kozlowski April 20, 2024, 11:13 a.m. UTC | #15
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/20240208164017.26699-1-brgl@bgdev.pl/#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
quic_zijuhu April 20, 2024, 11:01 p.m. UTC | #16
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/1713650800-29741-2-git-send-email-quic_zijuhu@quicinc.com/

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/20240208164017.26699-1-brgl@bgdev.pl/#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
> 
>
Wren Turkal April 21, 2024, 7:14 a.m. UTC | #17
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
quic_zijuhu April 21, 2024, 9:40 a.m. UTC | #18
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/01677a26-ea91-47cc-bdc4-283cf313d8e4@quicinc.com/
Wren Turkal April 22, 2024, 5:26 a.m. UTC | #19
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/01677a26-ea91-47cc-bdc4-283cf313d8e4@quicinc.com/

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
diff mbox series

Patch

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;
 		}