b43: Load initial firmware file asynchronously
Recent versions of udev cause synchronous firmware loading from the probe routine to fail because the request to user space would time out. The original fix for b43 (commit 6b6fa58) moved the firmware from the probe routine to a work queue, but it still used synchronous firmware loading. This method is OK when b43 is built as a module; however, it fails when the driver is compiled into the kernel.
This version changes the code to load the initial firmware file using request_firmware_nowait(). A completion event is used to hold the work queue until that file is available. This driver reads several firmware files - the remainder can be read synchronously.
---
Felix,
Please test this with b43 built into the kernel.
Thanks,
Larry
---
drivers/net/wireless/b43/b43.h +5 -0
@@ -7,6 +7,7 @@#include <linux/hw_random.h> #include <linux/bcma/bcma.h> #include <linux/ssb/ssb.h> +#include <linux/completion.h> #include <net/mac80211.h> #include "debugfs.h"
@@ -722,6 +723,10 @@ enum b43_firmware_file_type {struct b43_request_fw_context {/* The device we are requesting the fw for. */ struct b43_wldev *dev; +/* a completion event structure needed if this call is asynchronous */ +struct completion fw_load_complete; +/* a pointer to the firmware object */ +const struct firmware *blob;/* The type of firmware to request. */ enum b43_firmware_file_type req_type;/* Error messages for each firmware type. */
drivers/net/wireless/b43/main.c +48 -23
128 lines not on this page · raw message
drivers/net/wireless/b43/main.h +2 -3
@@ -137,9 +137,8 @@ void b43_mac_phy_clock_set(struct b43_wlstruct b43_request_fw_context ; -int b43_do_request_fw (struct b43_request_fw_context *ctx, -const char *name, -struct b43_firmware_file *fw); +int b43_do_request_fw (struct b43_request_fw_context *ctx,const char *name, +struct b43_firmware_file *fw,bool async);void b43_do_release_fw (struct b43_firmware_file *fw);#endif /* B43_MAIN_H_ */
Quoted 7 lines · Larry Finger
Felix,
Please test this with b43 built into the kernel.
Thanks,
Larry
Thanks, for coming back to this.
It now gives me a kernel panic after 30 seconds.
I did some debugging using ssleep and printk. b43_fw_cb seems to be called several times and on the last time the "firmware" argument seems to be zero. The execution then returns to b43_do_request_fw, which tries to deference a zero pointer in the line
drivers/net/wireless/b43/main.c int b43_do_request_fw(struct b43_request · line 2172
Quoted 1 line
drivers/net/wireless/b43/main.c +1
-0+if (ctx->blob->size <sizeof (struct b43_fw_header ))
It is another machine then last time, has B4306 (rev 3) and a kernel without modules. The firmware is in /lib/firmware/b43, which is on the root partition. There is no udev installed.
Felix
Quoted 10 lines · Felix Janda
Thanks, for coming back to this.
It now gives me a kernel panic after 30 seconds.
I did some debugging using ssleep and printk.
b43_fw_cbseems to be called several times and on the last time the "firmware" argument seems to be zero. The execution then returns tob43_do_request_fw, which tries to deference a zero pointer in the line
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ if (ctx->blob->size < sizeof(struct b43_fw_header))It is another machine then last time, has B4306 (rev 3) and a kernel without modules. The firmware is in
/lib/firmware/b43, which is on the root partition. There is no udev installed.
Felix,
Curious. I would have expected a single call to b43_do_request_fw() with the async flag set, and thus a single call to the callback routine.
Attached is a new version of the patch. It will give us some instrumentation on the calls, and it should prevent the crash. I would like to see the dmesg output showing the info.
Thanks for testing,
Larry
-------------- next part --------------
Recent versions of udev cause synchronous firmware loading from the probe routine to fail because the request to user space would time out. The original fix for b43 (commit 6b6fa58) moved the firmware load from the probe routine to a work queue, but it still used synchronous firmware loading. This method is OK when b43 is built as a module; however, it fails when the driver is compiled into the kernel.
This version changes the code to load the initial firmware file using request_firmware_nowait(). A completion event is used to hold the work queue until that file is available. This driver reads several firmware files - the remainder can be read synchronourly.
---
drivers/net/wireless/b43/b43.h +5 -0
@@ -7,6 +7,7 @@#include <linux/hw_random.h> #include <linux/bcma/bcma.h> #include <linux/ssb/ssb.h> +#include <linux/completion.h> #include <net/mac80211.h> #include "debugfs.h"
@@ -722,6 +723,10 @@ enum b43_firmware_file_type {struct b43_request_fw_context {/* The device we are requesting the fw for. */ struct b43_wldev *dev; +/* a completion event structure needed if this call is asynchronous */ +struct completion fw_load_complete; +/* a pointer to the firmware object */ +const struct firmware *blob;/* The type of firmware to request. */ enum b43_firmware_file_type req_type;/* Error messages for each firmware type. */
drivers/net/wireless/b43/main.c +54 -23
134 lines not on this page · raw message
drivers/net/wireless/b43/main.h +2 -3
@@ -137,9 +137,8 @@ void b43_mac_phy_clock_set(struct b43_wlstruct b43_request_fw_context ; -int b43_do_request_fw (struct b43_request_fw_context *ctx, -const char *name, -struct b43_firmware_file *fw); +int b43_do_request_fw (struct b43_request_fw_context *ctx,const char *name, +struct b43_firmware_file *fw,bool async);void b43_do_release_fw (struct b43_firmware_file *fw);#endif /* B43_MAIN_H_ */
Quoted 23 lines · Larry Finger
Quoted 10 lines · Felix Janda
Thanks, for coming back to this.
It now gives me a kernel panic after 30 seconds.
I did some debugging using ssleep and printk.
b43_fw_cbseems to be called several times and on the last time the "firmware" argument seems to be zero. The execution then returns tob43_do_request_fw, which tries to deference a zero pointer in the lineQuoted 6 lines
drivers/net/wireless/b43/main.c int b43_do_request_fw(struct b43_request · line 2178
Quoted 1 line
drivers/net/wireless/b43/main.c +1
-0+if (ctx->blob->size <sizeof (struct b43_fw_header ))It is another machine then last time, has B4306 (rev 3) and a kernel without modules. The firmware is in
/lib/firmware/b43, which is on the root partition. There is no udev installed.Felix,
Curious. I would have expected a single call to
b43_do_request_fw()with the async flag set, and thus a single call to the callback routine.
Quoted 7 lines
Attached is a new version of the patch. It will give us some instrumentation on the calls, and it should prevent the crash. I would like to see the dmesg output showing the info.
Thanks for testing,
Larry
Sorry, I assumed that the callback routine was called several times only by looking at how much delay I was producing by putting ssleep(10) into it.
There's no more panic with the new version and the dmesg output looks interesting.
Am I missing some firmware? /lib/firmware/b43 contains:
a0g0bsinitvals5.fw a0g0initvals5.fw a0g1bsinitvals5.fw a0g1initvals5.fw b0g0bsinitvals5.fw b0g0initvals5.fw pcm5.fw ucode5.fw
Thanks for fixing this,
Felix
-------------- next part --------------
[ 0.502490] b43-phy0: Broadcom 4306 WLAN found (core revision 5) [ 0.543046] b43-phy0: Found PHY: Analog 2, Type 2 (G), Revision 2 [ 0.705141] async load of b43/ucode5.fw [ 0.738576] Broadcom 43xx driver loaded [ Features: PL ] [ 62.284701] In callback routine, firmware not available [ 62.284712] Pid: 643, comm: kworker/0:2 Not tainted 3.7.0-rc8 #20 [ 62.284715] Call Trace: [ 62.284734] [<c12eefaa>] b43_fw_cb+0x1a/0x30 [ 62.284746] [<c12b3c5b>] request_firmware_work_func+0x5b/0xb0 [ 62.284753] [<c104b540>] process_one_work+0x110/0x380 [ 62.284758] [<c12b3c00>] ? _request_firmware_prepare.isra.14+0x380/0x380 [ 62.284762] [<c104c2e9>] worker_thread+0x119/0x340 [ 62.284766] [<c104c1d0>] ? manage_workers+0x260/0x260 [ 62.284774] [<c1050abf>] kthread+0x8f/0xa0 [ 62.284783] [<c14dffb7>] ret_from_kernel_thread+0x1b/0x28 [ 62.284788] [<c1050a30>] ? __kthread_bind+0x30/0x30 [ 62.284793] Firmware not found [ 62.284799] async load of b43-open/ucode5.fw [ 62.323259] In callback routine, firmware not available [ 62.323267] Pid: 643, comm: kworker/0:2 Not tainted 3.7.0-rc8 #20 [ 62.323269] Call Trace: [ 62.323278] [<c12eefaa>] b43_fw_cb+0x1a/0x30 [ 62.323284] [<c12b3c5b>] request_firmware_work_func+0x5b/0xb0 [ 62.323289] [<c104b540>] process_one_work+0x110/0x380 [ 62.323295] [<c12b3c00>] ? _request_firmware_prepare.isra.14+0x380/0x380 [ 62.323298] [<c104c2e9>] worker_thread+0x119/0x340 [ 62.323302] [<c104c1d0>] ? manage_workers+0x260/0x260 [ 62.323308] [<c1050abf>] kthread+0x8f/0xa0 [ 62.323314] [<c14dffb7>] ret_from_kernel_thread+0x1b/0x28 [ 62.323318] [<c1050a30>] ? __kthread_bind+0x30/0x30 [ 62.323322] Firmware not found [ 62.323329] b43-phy0 ERROR: You must go to http://wireless.kernel.org/en/users/Drivers/b43#devicefirmware and download the correct firmware for this driver version. Please carefully read all instructions on this website.
Quoted 35 lines · Felix Janda
Quoted 23 lines · Larry Finger
Quoted 10 lines · Felix Janda
Thanks, for coming back to this.
It now gives me a kernel panic after 30 seconds.
I did some debugging using ssleep and printk.
b43_fw_cbseems to be called several times and on the last time the "firmware" argument seems to be zero. The execution then returns tob43_do_request_fw, which tries to deference a zero pointer in the lineQuoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ if (ctx->blob->size < sizeof(struct b43_fw_header))It is another machine then last time, has B4306 (rev 3) and a kernel without modules. The firmware is in
/lib/firmware/b43, which is on the root partition. There is no udev installed.Felix,
Curious. I would have expected a single call to
b43_do_request_fw()with the async flag set, and thus a single call to the callback routine.Quoted 7 lines
Attached is a new version of the patch. It will give us some instrumentation on the calls, and it should prevent the crash. I would like to see the dmesg output showing the info.
Thanks for testing,
Larry
Sorry, I assumed that the callback routine was called several times only by looking at how much delay I was producing by putting ssleep(10) into it.
Quoted 7 lines
There's no more panic with the new version and the dmesg output looks interesting.
Am I missing some firmware?
/lib/firmware/b43contains:a0g0bsinitvals5.fw a0g0initvals5.fw a0g1bsinitvals5.fw a0g1initvals5.fw b0g0bsinitvals5.fw b0g0initvals5.fw pcm5.fw ucode5.fw
You have the correct firmware. For some reason, it is failing to load ucode5.fw even though it is available:
[ 0.502490] b43-phy0: Broadcom 4306 WLAN found (core revision 5) [ 0.543046] b43-phy0: Found PHY: Analog 2, Type 2 (G), Revision 2 [ 0.705141] async load of b43/ucode5.fw [ 0.738576] Broadcom 43xx driver loaded [ Features: PL ] [ 62.284701] In callback routine, firmware not available
The 61.5 second delay is likely the wait while user-space is up and running. The second call happens because the driver will try the open-source firmware when the proprietary fw is not available.
The system does not need udev. It uses sysfs and hotplug to complete the operation. I am assuming that both are part of your system.
The attached patch first tries to load the ucode fw with an asynchronous call. If that fails, it then tries a synchronous read. By the time the first one returns, user space should be running and the sync call should be OK.
Larry
-------------- next part --------------
Recent versions of udev cause synchronous firmware loading from the probe routine to fail because the request to user space would time out. The original fix for b43 (commit 6b6fa58) moved the firmware load from the probe routine to a work queue, but it still used synchronous firmware loading. This method is OK when b43 is built as a module; however, it fails when the driver is compiled into the kernel.
This version changes the code to load the initial firmware file using request_firmware_nowait(). A completion event is used to hold the work queue until that file is available. This driver reads several firmware files - the remainder can be read synchronourly.
---
drivers/net/wireless/b43/b43.h +5 -0
@@ -7,6 +7,7 @@#include <linux/hw_random.h> #include <linux/bcma/bcma.h> #include <linux/ssb/ssb.h> +#include <linux/completion.h> #include <net/mac80211.h> #include "debugfs.h"
@@ -722,6 +723,10 @@ enum b43_firmware_file_type {struct b43_request_fw_context {/* The device we are requesting the fw for. */ struct b43_wldev *dev; +/* a completion event structure needed if this call is asynchronous */ +struct completion fw_load_complete; +/* a pointer to the firmware object */ +const struct firmware *blob;/* The type of firmware to request. */ enum b43_firmware_file_type req_type;/* Error messages for each firmware type. */
drivers/net/wireless/b43/main.c +46 -13
124 lines not on this page · raw message
drivers/net/wireless/b43/main.h +2 -3
@@ -137,9 +137,8 @@ void b43_mac_phy_clock_set(struct b43_wlstruct b43_request_fw_context ; -int b43_do_request_fw (struct b43_request_fw_context *ctx, -const char *name, -struct b43_firmware_file *fw); +int b43_do_request_fw (struct b43_request_fw_context *ctx,const char *name, +struct b43_firmware_file *fw,bool async);void b43_do_release_fw (struct b43_firmware_file *fw);#endif /* B43_MAIN_H_ */
A message that is not in the archive (sent off-list or not yet received): 20121208202435.GA14973@gauss
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Larry Finger
Quoted 2 lines · Felix Janda
Not much has changed. Say, if you want to have the complete dmesg output.
Yes, I messed that one up. Try this one - it is different in the error recovery.
Larry
Now I have a wlan0. Haven't tested it though yet. dmesg still prints some errors.
Felix
-------------- next part --------------
[ 0.504374] b43-phy0: Broadcom 4306 WLAN found (core revision 5) [ 0.545047] b43-phy0: Found PHY: Analog 2, Type 2 (G), Revision 2 [ 0.707107] async load of b43/ucode5.fw [ 0.740558] Broadcom 43xx driver loaded [ Features: PL ] [ 62.284907] In callback routine, firmware not available [ 62.284919] Pid: 632, comm: kworker/0:2 Not tainted 3.7.0-rc8 #22 [ 62.284921] Call Trace: [ 62.284941] [<c12eefaa>] b43_fw_cb+0x1a/0x30 [ 62.284953] [<c12b3c5b>] request_firmware_work_func+0x5b/0xb0 [ 62.284960] [<c104b540>] process_one_work+0x110/0x380 [ 62.284966] [<c12b3c00>] ? _request_firmware_prepare.isra.14+0x380/0x380 [ 62.284970] [<c104c2e9>] worker_thread+0x119/0x340 [ 62.284974] [<c104c1d0>] ? manage_workers+0x260/0x260 [ 62.284982] [<c1050abf>] kthread+0x8f/0xa0 [ 62.284992] [<c14dffb7>] ret_from_kernel_thread+0x1b/0x28 [ 62.284996] [<c1050a30>] ? __kthread_bind+0x30/0x30 [ 62.299141] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht' [ 62.300427] Registered led device: b43-phy0::tx [ 62.300690] Registered led device: b43-phy0::rx [ 62.300950] Registered led device: b43-phy0::radio
Quoted 10 lines · Felix Janda
Quoted 7 lines · Larry Finger
Quoted 2 lines · Felix Janda
Not much has changed. Say, if you want to have the complete dmesg output.
Yes, I messed that one up. Try this one - it is different in the error recovery.
Larry
Now I have a wlan0. Haven't tested it though yet. dmesg still prints some errors.
That is not an error - I just left a diagnostic in the code. Please let me know if it works. It should as we only touched the firmware loading.
Is it OK if I use a "Reported-and-Tested by: <you>?
Larry
Quoted 8 lines · Larry Finger
Quoted 1 line
Now I have a wlan0. Haven't tested it though yet. dmesg still prints some errors.
That is not an error - I just left a diagnostic in the code. Please let me know if it works. It should as we only touched the firmware loading.
Is it OK if I use a "Reported-and-Tested by: <you>?
Larry
It's OK. Over christmas I'll do some thoroughful testing.
The delay of 60 seconds will stay?
Felix
Quoted 6 lines · Felix Janda
Quoted 5 lines · Larry Finger
Quoted 1 line
Now I have a wlan0. Haven't tested it though yet. dmesg still prints some errors.
That is not an error - I just left a diagnostic in the code. Please let me know if it works. It should as we only touched the firmware loading.
Quoted 7 lines
Quoted 3 lines
Is it OK if I use a "Reported-and-Tested by: <you>?
Larry
It's OK. Over christmas I'll do some thoroughful testing.
The delay of 60 seconds will stay?
As this happens while user-space is getting started, there is little we can do. On my dual-core x86_64 system with each CPU running at 2 GHz, it takes 24 sec before the fw is loaded. At least other things happen in parallel.
Larry
Quoted 7 lines · Larry Finger
Quoted 1 line
The delay of 60 seconds will stay?
As this happens while user-space is getting started, there is little we can do. On my dual-core
x86_64system with each CPU running at 2 GHz, it takes 24 sec before the fw is loaded. At least other things happen in parallel.Larry
Ok. (The behavior is now the same as if the firmware was built into the kernel.)
So thanks again for the fix.
Felix