diff mbox

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

Message ID 713a8666-8b72-9198-03a3-a3656c5cb84d@cypress.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show

Commit Message

Wright Feng Jan. 15, 2018, 10:09 a.m. UTC
On 2018/1/12 下午 07:16, Kalle Valo wrote:
> Arend van Spriel <arend.vanspriel@broadcom.com> 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 <wright.feng@cypress.com>
>>> ---
>>> 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(-)


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

Comments

Arend van Spriel Jan. 15, 2018, 7:54 p.m. UTC | #1
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
Wright Feng Jan. 16, 2018, 1:52 a.m. UTC | #2
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
diff mbox

Patch

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