brcmfmac: fix CLM load error for legacy chips when user helper is enabled
PATCH v2 1/1 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().
---
v2: remove retry from patch v1
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1 -1
@@ -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 ; }
Signature · 1 line
1.9.1
Arend van Spriel
maintainerQuoted 18 lines · Wright Feng
For legacy chips without CLM blob files, kernel with user helper function returns
-EAGAINwhen werequest_firmware()for blob file. In this case,brcmf_bus_startedgets error and failed to bring up legacy chips. Because of that, we should continue with CLM data currently present in firmware if getting-EAGAINwhen doingrequest_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(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +0
-0
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c static int brcmf_c_process_clm_blob(struct brcmf_if *ifp) · line 188
Quoted 8 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1
-1@@ -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
Quoted 3 lines · Arend van Spriel
Quoted 2 lines · Wright Feng
For legacy chips without CLM blob files, kernel with user helper function returns
-EAGAINwhen werequest_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.
Quoted 18 lines
Quoted 18 lines
In this case,
brcmf_bus_startedgets error and failed to bring up legacy chips. Because of that, we should continue with CLM data currently present in firmware if getting-EAGAINwhen doingrequest_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(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +0
-0@@ -182,7 +182,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
Quoted 10 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c static int brcmf_c_process_clm_blob(struct brcmf_if *ifp) · line 188
Quoted 7 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1
-1err =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.
Signature · 1 line
Kalle Valo
Quoted 6 lines · Kalle Valo
Quoted 3 lines · Arend van Spriel
Quoted 2 lines · Wright Feng
For legacy chips without CLM blob files, kernel with user helper function returns
-EAGAINwhen werequest_firmware()for blob file.
Quoted 8 lines
_Why_ is the
-EAGAINreturned? 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.
Quoted 29 lines
Quoted 18 lines
Quoted 18 lines
In this case,
brcmf_bus_startedgets error and failed to bring up legacy chips. Because of that, we should continue with CLM data currently present in firmware if getting-EAGAINwhen doingrequest_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(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +0
-0@@ -182,7 +182,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)Quoted 10 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c static int brcmf_c_process_clm_blob(struct brcmf_if *ifp) · line 188
Quoted 7 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1
-1err =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?
Quoted 2 lines
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(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +6 -6
@@ -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 );
Arend van Spriel
maintainerQuoted 1 line · Wright Feng
[...]
Quoted 18 lines
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +0
-2@@ -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");
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c static int brcmf_c_process_clm_blob(struct · line 192
Quoted 10 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +5
-4-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);
Quoted 2 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1
-0+return 0 ;}
Regards,
Arend
Quoted 36 lines · Arend van Spriel
Quoted 1 line · Wright Feng
[...]
Quoted 18 lines
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +0
-2@@ -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");drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c static int brcmf_c_process_clm_blob(struct · line 192
Quoted 10 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +5
-4-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.:
Quoted 7 lines
brcmf_info("no
clm_blobavailable (%d). device may have limited
channels available\n", err);Quoted 2 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1
-0+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