2018-01-12 07:43:28

by Wright Feng

[permalink] [raw]
Subject: [PATCH v2] brcmfmac: fix CLM load error for legacy chips when user helper is enabled

For legacy chips without CLM blob files, kernel with user helper function
returns -EAGAIN when we request_firmware() for blob file. In this case,
brcmf_bus_started gets error and failed to bring up legacy chips.
Because of that, we should continue with CLM data currently present in
firmware if getting -EAGAIN when doing request_firmware().

Signed-off-by: Wright Feng <[email protected]>
---
v2: remove retry from patch v1
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 6a59d06..0baab4c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -182,7 +182,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)

err = request_firmware(&clm, clm_name, dev);
if (err) {
- if (err == -ENOENT) {
+ if (err == -ENOENT || err == -EAGAIN) {
brcmf_dbg(INFO, "continue with CLM data currently present in firmware\n");
return 0;
}
--
1.9.1


2018-01-15 19:54:43

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH v2] brcmfmac: fix CLM load error for legacy chips when user helper is enabled

On 1/15/2018 11:09 AM, Wright Feng wrote:
>

[...]

> ---
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 12
> ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> index 6a59d06..aaab0e6 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> @@ -182,12 +182,12 @@ static int brcmf_c_process_clm_blob(struct
> brcmf_if *ifp)
>
> err = request_firmware(&clm, clm_name, dev);
> if (err) {
> - if (err == -ENOENT) {
> - brcmf_dbg(INFO, "continue with CLM data currently present
> in firmware\n");
> - return 0;
> - }
> - brcmf_err("request CLM blob file failed (%d)\n", err);
> - return err;
> + if (err == -ENOENT || err == -EAGAIN)
> + brcmf_info("continue with CLM data in FW\n");
> + else
> + brcmf_err("request clm_blob failed(%d) continue with CLM
> data in FW\n",
> + err);

Don't see much value in doing it this way. Either way we need to inform
the user about the consequence of this, ie.:

brcmf_info("no clm_blob available (%d). device may have limited
channels available\n", err);
> + return 0;
> }

Regards,
Arend

2018-01-12 11:16:37

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2] brcmfmac: fix CLM load error for legacy chips when user helper is enabled

Arend van Spriel <[email protected]> writes:

> On 1/12/2018 8:44 AM, Wright Feng wrote:
>> For legacy chips without CLM blob files, kernel with user helper function
>> returns -EAGAIN when we request_firmware() for blob file.

_Why_ is the -EAGAIN returned? Is it because of user space, due to
timing when loading the brcmfmac module or what? You should explain the
problem in detail in the commit log and why this is the right approach
to fix the problem.

Based on the commit log to me this still looks like a random attempt to
workaround a bug, not a proper fix.

>> In this case, brcmf_bus_started gets error and failed to bring up
>> legacy chips. Because of that, we should continue with CLM data
>> currently present in firmware if getting -EAGAIN when doing
>> request_firmware().
>>
>> Signed-off-by: Wright Feng <[email protected]>
>> ---
>> v2: remove retry from patch v1
>> ---
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>> index 6a59d06..0baab4c 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>> @@ -182,7 +182,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
>>
>> err = request_firmware(&clm, clm_name, dev);
>> if (err) {
>> - if (err == -ENOENT) {
>> + if (err == -ENOENT || err == -EAGAIN) {
>> brcmf_dbg(INFO, "continue with CLM data currently present in firmware\n");
>> return 0;
>> }
>
> Why don't we just fall-back to "CLM in firmware" regardless of the
> error code?

Indeed, I was thinking the same.

--
Kalle Valo

2018-01-15 10:10:02

by Wright Feng

[permalink] [raw]
Subject: Re: [PATCH v2] brcmfmac: fix CLM load error for legacy chips when user helper is enabled



On 2018/1/12 下午 07:16, Kalle Valo wrote:
> Arend van Spriel <[email protected]> writes:
>
>> On 1/12/2018 8:44 AM, Wright Feng wrote:
>>> For legacy chips without CLM blob files, kernel with user helper function
>>> returns -EAGAIN when we request_firmware() for blob file.
>
> _Why_ is the -EAGAIN returned? Is it because of user space, due to
> timing when loading the brcmfmac module or what? You should explain the
> problem in detail in the commit log and why this is the right approach
> to fix the problem.
>
> Based on the commit log to me this still looks like a random attempt to
> workaround a bug, not a proper fix.
>

It is not about the timing issue, it is about "the clm blob is not
existence in firmware path for legacy firmware with CLM data built-in"
and the -ENOENT error is transferred to -EAGAIN in firmware_class.c.

Here is explanation of -EAGAIN returned in detail.
In drivers/base/firmware_class.c:__fw_state_wait_common, it returns
-ENOENT to indicate the clm_blob file is not found via user helper.
However, in drivers/base/firmware_class.c:_request_firmware_load, all
errors with fw status aborted are transferred to:

1. -ERESTARTSYS: The signal is pending and the task is interruptible.
Before 76098b36b5db ("firmware: send -EINTR on signal abort on fallback
mechanism"), all errors with fw status aborted are transferred to
-EAGAIN.

2. -EAGAIN: All others fw status aborted(include -ENOENT) except for
-ERESTARTSYS.

And that's why I handle -EAGAIN error to let driver using CLM data in
firmware.

>>> In this case, brcmf_bus_started gets error and failed to bring up
>>> legacy chips. Because of that, we should continue with CLM data
>>> currently present in firmware if getting -EAGAIN when doing
>>> request_firmware().
>>>
>>> Signed-off-by: Wright Feng <[email protected]>
>>> ---
>>> v2: remove retry from patch v1
>>> ---
>>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>>> index 6a59d06..0baab4c 100644
>>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>>> @@ -182,7 +182,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
>>>
>>> err = request_firmware(&clm, clm_name, dev);
>>> if (err) {
>>> - if (err == -ENOENT) {
>>> + if (err == -ENOENT || err == -EAGAIN) {
>>> brcmf_dbg(INFO, "continue with CLM data currently present in firmware\n");
>>> return 0;
>>> }
>>
>> Why don't we just fall-back to "CLM in firmware" regardless of the
>> error code?
>
> Indeed, I was thinking the same.
>
For the firmwares with CLM data built-in, it is okay to continue the
bringing-up flow.
But when users put clm_blob file to firmware path, the corresponding
firmware may not have CLM data built-in. If we fall-back to use empty
CLM data in firmware when hitting other errors like "-ENOMEM" or
"-EINTR", the country code revision will be null and users will meet
error when trying to connect to access point.
It is fine to fall-back to "CLM in firmware" regardless of the error
code, but it would be better to print error log to indicate the error if
the returned error codes are not what we expected.


Please let me know your opinion of below commit log and diff, if it is
okay to you, I will post Patch v3 later.



For legacy chips without CLM blob files, kernel with user helper
function returns -EAGAIN when we request_firmware() for blob file. So,
it got failed when bring up legacy chips. We expect the CLM blob files
is not existence in firmware path, however the -ENOENT error is
transferred to -EAGAIN in firmware_class.c.
Because of that, we continue with CLM data currently present in
firmware if getting error in doing request_firmware().

---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 12
++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 6a59d06..aaab0e6 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -182,12 +182,12 @@ static int brcmf_c_process_clm_blob(struct
brcmf_if *ifp)

err = request_firmware(&clm, clm_name, dev);
if (err) {
- if (err == -ENOENT) {
- brcmf_dbg(INFO, "continue with CLM data currently present in
firmware\n");
- return 0;
- }
- brcmf_err("request CLM blob file failed (%d)\n", err);
- return err;
+ if (err == -ENOENT || err == -EAGAIN)
+ brcmf_info("continue with CLM data in FW\n");
+ else
+ brcmf_err("request clm_blob failed(%d) continue with CLM data in FW\n",
+ err);
+ return 0;
}

chunk_buf = kzalloc(sizeof(*chunk_buf) + MAX_CHUNK_LEN - 1, GFP_KERNEL);
--

2018-01-12 10:55:39

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH v2] brcmfmac: fix CLM load error for legacy chips when user helper is enabled

On 1/12/2018 8:44 AM, Wright Feng wrote:
> For legacy chips without CLM blob files, kernel with user helper function
> returns -EAGAIN when we request_firmware() for blob file. In this case,
> brcmf_bus_started gets error and failed to bring up legacy chips.
> Because of that, we should continue with CLM data currently present in
> firmware if getting -EAGAIN when doing request_firmware().
>
> Signed-off-by: Wright Feng <[email protected]>
> ---
> v2: remove retry from patch v1
> ---
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> index 6a59d06..0baab4c 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
> @@ -182,7 +182,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
>
> err = request_firmware(&clm, clm_name, dev);
> if (err) {
> - if (err == -ENOENT) {
> + if (err == -ENOENT || err == -EAGAIN) {
> brcmf_dbg(INFO, "continue with CLM data currently present in firmware\n");
> return 0;
> }

Hi Wright,

Why don't we just fall-back to "CLM in firmware" regardless of the error
code? Also it might be better to use brcmf_info() instead of
brcmf_dbg(INFO, ..).

Regards,
Arend

2018-01-16 01:52:39

by Wright Feng

[permalink] [raw]
Subject: Re: [PATCH v2] brcmfmac: fix CLM load error for legacy chips when user helper is enabled



On 2018/1/16 上午 03:54, Arend van Spriel wrote:
> On 1/15/2018 11:09 AM, Wright Feng wrote:
>>
>
> [...]
>
>> ---
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 12
>> ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>> index 6a59d06..aaab0e6 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
>> @@ -182,12 +182,12 @@ static int brcmf_c_process_clm_blob(struct
>> brcmf_if *ifp)
>>
>> err = request_firmware(&clm, clm_name, dev);
>> if (err) {
>> - if (err == -ENOENT) {
>> - brcmf_dbg(INFO, "continue with CLM data currently present
>> in firmware\n");
>> - return 0;
>> - }
>> - brcmf_err("request CLM blob file failed (%d)\n", err);
>> - return err;
>> + if (err == -ENOENT || err == -EAGAIN)
>> + brcmf_info("continue with CLM data in FW\n");
>> + else
>> + brcmf_err("request clm_blob failed(%d) continue with CLM
>> data in FW\n",
>> + err);
>
> Don't see much value in doing it this way. Either way we need to inform
> the user about the consequence of this, ie.:
>
> brcmf_info("no clm_blob available (%d). device may have limited
> channels available\n", err);
>> + return 0;
>> }
>
> Regards,
> Arend
Thanks for the comment, I will post patch v3 with your suggestion later.
The patch will include one brcmf_info print and returning 0 regardless
of errors from request_firmware.

Regards,
Wright