brcmfmac: USB change series
v3 cover brcmfmac: USB change series
USB runtime PM and console print support added, alone with several of bug fixes for usb devices.
Changes in V3:
- Fix build failure in patch 05.
Changes in V2:
- Clarify "SVT" meaning in patch 03 commit message.
- Add explanation for wowl usage in patch 05 commit message.
Madhan Mohan R (1):
brcmfmac: increase max hanger slots from 1K to 3K in fws layer
Raveendran Somu (4):
brcmfmac: Fix driver crash on USB control transfer timeout
brcmfmac: Fix double freeing in the fmac usb data path
brcmfmac: fix the incorrect return value in brcmf_inform_single_bss().
brcmfmac: To support printing USB console messages
Wright Feng (1):
brcmfmac: add USB autosuspend feature support
.../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 1 + .../broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +- .../wireless/broadcom/brcm80211/brcmfmac/core.c | 8 ++ .../wireless/broadcom/brcm80211/brcmfmac/debug.c | 82 ++++++++++++ .../wireless/broadcom/brcm80211/brcmfmac/debug.h | 24 ++++ .../broadcom/brcm80211/brcmfmac/fwsignal.c | 5 +- .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 141 +++++++++++++-------- 7 files changed, 207 insertions(+), 56 deletions(-)
Signature · 1 line
2.1.0
PATCH v3 1/6 brcmfmac: Fix driver crash on USB control transfer timeout
From: Raveendran Somu <[email protected]>
When the control transfer gets timed out, the error status was returned without killing that urb, this leads to using the same urb. This issue causes the kernel crash as the same urb is sumbitted multiple times. The fix is to kill the urb for timeout transfer before returning error
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +4 -2
@@ -328,11 +328,12 @@ static int brcmf_usb_tx_ctlpkt(struct device *dev, u8 *buf, u32 len)return err; } timeout =brcmf_usb_ioctl_resp_wait (devinfo); -clear_bit (0 , &devinfo->ctl_op);if (!timeout) {brcmf_err ("Txctl wait timed out\n" ); +usb_kill_urb (devinfo->ctl_urb); err = -EIO ; } +clear_bit (0 , &devinfo->ctl_op);return err; }
@@ -358,11 +359,12 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len) } timeout =brcmf_usb_ioctl_resp_wait (devinfo); err = devinfo->ctl_urb_status; -clear_bit (0 , &devinfo->ctl_op);if (!timeout) {brcmf_err ("rxctl wait timed out\n" ); +usb_kill_urb (devinfo->ctl_urb); err = -EIO ; } +clear_bit (0 , &devinfo->ctl_op);if (!err)return devinfo->ctl_urb_actual_length;else
Signature · 1 line
2.1.0
Re: [PATCH V3 1/6] brcmfmac: Fix driver crash on USB control transfer timeout
Quoted 10 lines · Chi-Hsien Lin
From: Raveendran Somu <[email protected]>
When the control transfer gets timed out, the error status was returned without killing that urb, this leads to using the same urb. This issue causes the kernel crash as the same urb is sumbitted multiple times. The fix is to kill the urb for timeout transfer before returning error
Signed-off-by Raveendran Somu <[email protected]>Signed-off-by Chi-hsien Lin <[email protected]>
5 patches applied to wireless-drivers-next.git, thanks.
93a5bfbc7cad brcmfmac: Fix driver crash on USB control transfer timeout 78179869dc3f brcmfmac: Fix double freeing in the fmac usb data path bd9944918ceb brcmfmac: fix the incorrect return value in brcmf_inform_single_bss(). 2bc50d8828ad brcmfmac: increase max hanger slots from 1K to 3K in fws layer 7f1d42304d93 brcmfmac: add USB autosuspend feature support
Signature · 3 lines
https://patchwork.kernel.org/patch/11457137/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH v3 2/6 brcmfmac: Fix double freeing in the fmac usb data path
In reply to Chi-Hsien LinFrom: Raveendran Somu <[email protected]>
When the brcmf_fws_process_skb() fails to get hanger slot for queuing the skb, it tries to free the skb.
But the caller brcmf_netdev_start_xmit() of that funciton frees the packet on error return value.
This causes the double freeing and which caused the kernel crash.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c +1 -2
@@ -2145,8 +2145,7 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)brcmf_fws_enq (fws,BRCMF_FWS_SKBSTATE_DELAYED , fifo, skb);brcmf_fws_schedule_deq (fws); }else { -bphy_err (drvr,"drop skb: no hanger slot\n" ); -brcmf_txfinalize (ifp, skb, false); +bphy_err (drvr,"no hanger slot available\n" ); rc = -ENOMEM ; }brcmf_fws_unlock (fws);
Signature · 1 line
2.1.0
PATCH v3 3/6 brcmfmac: fix the incorrect return value in brcmf_inform_single_bss().
In reply to Chi-Hsien LinFrom: Raveendran Somu <[email protected]>
The function brcmf_inform_single_bss returns the value as success, even when the length exceeds the maximum value.
The fix is to send appropriate code on this error.
This issue is observed when Cypress test group reported random fmac crashes when running their tests and the path was identified from the crash logs. With this fix the random failure issue in Cypress test group was resolved.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +1 -1
@@ -2953,7 +2953,7 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,if (le32_to_cpu (bi->length) >WL_BSS_INFO_MAX ) {bphy_err (drvr,"Bss info is larger than buffer. Discarding\n" ); -return 0 ; +return -EINVAL ; }if (!bi->ctl_ch) {
Signature · 1 line
2.1.0
PATCH v3 4/6 brcmfmac: increase max hanger slots from 1K to 3K in fws layer
In reply to Chi-Hsien LinFrom: Madhan Mohan R <[email protected]>
Will enable FMAC to push more packets to bus tx queue and help improve throughput when fws queuing is enabled. This change is required to tune the throughput for passing WMM CERT tests.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c +1 -1
@@ -404,7 +404,7 @@ struct brcmf_fws_mac_descriptor {u8 traffic_lastreported_bmp; }; -#define BRCMF_FWS_HANGER_MAXITEMS 1024 +#define BRCMF_FWS_HANGER_MAXITEMS 3072/** * enum brcmf_fws_hanger_item_state - state of hanger item.
Signature · 1 line
2.1.0
PATCH v3 5/6 brcmfmac: add USB autosuspend feature support
In reply to Chi-Hsien LinFrom: Wright Feng <[email protected]>
We add enable dynamic suspend (autosuspend) support in host driver, and it can let platform cut down idle power consumption.
To support autosuspend feature in host driver, kernel need to be built with CONFIG_USB_SUSPEND and autosuspend need to be turn on. And we also replace wowl feature with adding "needs_remote_wakeup", so that host still can be waken by wireless device.
--- .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 121 ++++++++++++--------- 1 file changed, 71 insertions(+), 50 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +71 -50
@@ -164,7 +164,6 @@ struct brcmf_usbdev_info {struct urb *bulk_urb;/* used for FW download */ -bool wowl_enabled;struct brcmf_mp_device *settings; };
@@ -312,28 +311,43 @@ static int brcmf_usb_tx_ctlpkt(struct device *dev, u8 *buf, u32 len)int err =0 ;int timeout =0 ;struct brcmf_usbdev_info *devinfo =brcmf_usb_get_businfo (dev); +struct usb_interface *intf =to_usb_interface (dev);brcmf_dbg (USB ,"Enter\n" ); -if (devinfo->bus_pub.state !=BRCMFMAC_USB_STATE_UP ) -return -EIO ; -if (test_and_set_bit (0 , &devinfo->ctl_op)) -return -EIO ; + err =usb_autopm_get_interface (intf); +if (err) + goto out; + +if (devinfo->bus_pub.state !=BRCMFMAC_USB_STATE_UP ) { + err = -EIO ; + goto fail; + } + +if (test_and_set_bit (0 , &devinfo->ctl_op)) { + err = -EIO ; + goto fail; + } devinfo->ctl_completed = false; err =brcmf_usb_send_ctl (devinfo, buf, len);if (err) {brcmf_err ("fail %d bytes: %d\n" , err, len);clear_bit (0 , &devinfo->ctl_op); -return err; + goto fail; } timeout =brcmf_usb_ioctl_resp_wait (devinfo);if (!timeout) {brcmf_err ("Txctl wait timed out\n" );usb_kill_urb (devinfo->ctl_urb); err = -EIO ; + goto fail; }clear_bit (0 , &devinfo->ctl_op); + +fail: +usb_autopm_put_interface (intf); +out:return err; }
@@ -342,20 +356,30 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len)int err =0 ;int timeout =0 ;struct brcmf_usbdev_info *devinfo =brcmf_usb_get_businfo (dev); +struct usb_interface *intf =to_usb_interface (dev);brcmf_dbg (USB ,"Enter\n" ); -if (devinfo->bus_pub.state !=BRCMFMAC_USB_STATE_UP ) -return -EIO ; -if (test_and_set_bit (0 , &devinfo->ctl_op)) -return -EIO ; + err =usb_autopm_get_interface (intf); +if (err) + goto out; + +if (devinfo->bus_pub.state !=BRCMFMAC_USB_STATE_UP ) { + err = -EIO ; + goto fail; + } + +if (test_and_set_bit (0 , &devinfo->ctl_op)) { + err = -EIO ; + goto fail; + } devinfo->ctl_completed = false; err =brcmf_usb_recv_ctl (devinfo, buf, len);if (err) {brcmf_err ("fail %d bytes: %d\n" , err, len);clear_bit (0 , &devinfo->ctl_op); -return err; + goto fail; } timeout =brcmf_usb_ioctl_resp_wait (devinfo); err = devinfo->ctl_urb_status;
@@ -363,12 +387,15 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len)brcmf_err ("rxctl wait timed out\n" );usb_kill_urb (devinfo->ctl_urb); err = -EIO ; + goto fail; }clear_bit (0 , &devinfo->ctl_op); +fail: +usb_autopm_put_interface (intf);if (!err)return devinfo->ctl_urb_actual_length; -else -return err; +out: +return err; } static struct brcmf_usbreq *brcmf_usb_deq(struct brcmf_usbdev_info *devinfo,
@@ -502,10 +529,12 @@ static void brcmf_usb_rx_complete(struct urb *urb)return ; } -if (devinfo->bus_pub.state ==BRCMFMAC_USB_STATE_UP ) { +if (devinfo->bus_pub.state ==BRCMFMAC_USB_STATE_UP || + devinfo->bus_pub.state ==BRCMFMAC_USB_STATE_SLEEP ) {skb_put (skb, urb->actual_length);brcmf_rx_frame (devinfo->dev, skb, true);brcmf_usb_rx_refill (devinfo, req); +usb_mark_last_busy (urb->dev); }else {brcmu_pkt_buf_free_skb (skb);brcmf_usb_enq (devinfo, &devinfo->rx_freeq, req,NULL );
@@ -589,6 +618,11 @@ static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb)struct brcmf_usbreq *req;int ret;unsigned long flags; +struct usb_interface *intf =to_usb_interface (dev); + + ret =usb_autopm_get_interface (intf); +if (ret) + goto out;brcmf_dbg (USB ,"Enter, skb=%p\n" , skb);if (devinfo->bus_pub.state !=BRCMFMAC_USB_STATE_UP ) {
@@ -627,9 +661,10 @@ static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb) devinfo->tx_flowblock = true; }spin_unlock_irqrestore (&devinfo->tx_flowblock_lock, flags); -return 0 ; fail: +usb_autopm_put_interface (intf); +out:return ret; }
@@ -993,20 +1028,32 @@ static int brcmf_usb_fw_download(struct brcmf_usbdev_info *devinfo) {int err; +struct usb_interface *intf;brcmf_dbg (USB ,"Enter\n" ); -if (devinfo ==NULL ) -return -ENODEV ; +if (!devinfo) { + err = -ENODEV ; + goto out; + }if (!devinfo->image) {brcmf_err ("No firmware!\n" ); -return -ENOENT ; + err = -ENOENT ; + goto out; } + intf =to_usb_interface (devinfo->dev); + err =usb_autopm_get_interface (intf); +if (err) + goto out; + err =brcmf_usb_dlstart (devinfo, (u8 *)devinfo->image, devinfo->image_len);if (err ==0 ) err =brcmf_usb_dlrun (devinfo); + +usb_autopm_put_interface (intf); +out:return err; }
@@ -1107,18 +1154,6 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo,return NULL ; } -static void brcmf_usb_wowl_config (struct device *dev,bool enabled) -{ -struct brcmf_usbdev_info *devinfo =brcmf_usb_get_businfo (dev); - -brcmf_dbg (USB ,"Configuring WOWL, enabled=%d\n" , enabled); - devinfo->wowl_enabled = enabled; -if (enabled) -device_set_wakeup_enable (devinfo->dev, true); -else -device_set_wakeup_enable (devinfo->dev, false); -} -static int brcmf_usb_get_fwname (struct device *dev,const char *ext,u8 *fw_name) {
@@ -1145,7 +1180,6 @@ static const struct brcmf_bus_ops brcmf_usb_bus_ops = { .txdata = brcmf_usb_tx, .txctl = brcmf_usb_tx_ctlpkt, .rxctl = brcmf_usb_rx_ctlpkt, - .wowl_config = brcmf_usb_wowl_config, .get_fwname = brcmf_usb_get_fwname, };
@@ -1334,6 +1368,8 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)usb_set_intfdata (intf, devinfo); + intf->needs_remote_wakeup =1 ; +/* Check that the device supports only one configuration */ if (usb->descriptor.bNumConfigurations !=1 ) { brcmf_err("Number of configurations: %d not supported\n",
@@ -1447,12 +1483,8 @@ static int brcmf_usb_suspend(struct usb_interface *intf, pm_message_t state)brcmf_dbg (USB ,"Enter\n" ); devinfo->bus_pub.state =BRCMFMAC_USB_STATE_SLEEP ; -if (devinfo->wowl_enabled) { -brcmf_cancel_all_urbs (devinfo); - }else { -brcmf_detach (&usb->dev); -brcmf_free (&usb->dev); - } +brcmf_cancel_all_urbs (devinfo); +device_set_wakeup_enable (devinfo->dev, true);return 0 ; }
@@ -1465,22 +1497,10 @@ static int brcmf_usb_resume(struct usb_interface *intf)struct brcmf_usbdev_info *devinfo =brcmf_usb_get_businfo (&usb->dev);brcmf_dbg (USB ,"Enter\n" ); -if (!devinfo->wowl_enabled) { -int err; - - err =brcmf_alloc (&usb->dev, devinfo->settings); -if (err) -return err; - - err =brcmf_attach (devinfo->dev); -if (err) { -brcmf_free (devinfo->dev); -return err; - } - } devinfo->bus_pub.state =BRCMFMAC_USB_STATE_UP ;brcmf_usb_rx_fill_all (devinfo); +device_set_wakeup_enable (devinfo->dev, false);return 0 ; }
@@ -1537,6 +1557,7 @@ static struct usb_driver brcmf_usbdrvr = { .suspend = brcmf_usb_suspend, .resume = brcmf_usb_resume, .reset_resume = brcmf_usb_reset_resume, + .supports_autosuspend = true, .disable_hub_initiated_lpm = 1, };
Signature · 1 line
2.1.0
PATCH v3 6/6 brcmfmac: To support printing USB console messages
In reply to Chi-Hsien LinFrom: Raveendran Somu <[email protected]>
This change is to add support for printing the firmware console messges of a USB interface chip to the host. To enable this feature, build option '-msgtrace' should be enabled in the firmware. And in the host, debug=0x100000 should be provided as a module parameter.
--- .../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 1 + .../wireless/broadcom/brcm80211/brcmfmac/core.c | 8 +++ .../wireless/broadcom/brcm80211/brcmfmac/debug.c | 82 ++++++++++++++++++++++ .../wireless/broadcom/brcm80211/brcmfmac/debug.h | 24 +++++++ .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 14 ++++ 5 files changed, 129 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h +1 -0
@@ -271,6 +271,7 @@ void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);s32 brcmf_iovar_data_set (struct device *dev,char *name,void *data,u32 len);void brcmf_bus_add_txhdrlen (struct device *dev,uint len); +int brcmf_fwlog_attach (struct device *dev);#ifdef CONFIG_BRCMFMAC_SDIO void brcmf_sdio_exit (void );
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +8 -0
@@ -1117,6 +1117,14 @@ static int brcmf_inet6addr_changed(struct notifier_block *nb, }#endif +int brcmf_fwlog_attach (struct device *dev) +{ +struct brcmf_bus *bus_if =dev_get_drvdata (dev); +struct brcmf_pub *drvr = bus_if->drvr; + +return brcmf_debug_fwlog_init (drvr); +} +static int brcmf_revinfo_read (struct seq_file *s,void *data) {struct brcmf_bus *bus_if =dev_get_drvdata (s->private);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c +82 -0
94 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h +24 -0
@@ -103,6 +103,10 @@ do { \#endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */ +#define MSGTRACE_VERSION 1 +#define MSGTRACE_HDR_TYPE_MSG 0 +#define MSGTRACE_HDR_TYPE_LOG 1 +#define brcmf_dbg_hex_dump (test, data, len, fmt, ...) \ do { \ trace_brcmf_hexdump((void *)data, len); \
@@ -120,6 +124,7 @@ int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn, int (*read_fn)(struct seq_file *seq, void *data));int brcmf_debug_create_memdump (struct brcmf_bus *bus,const void *data,size_t len); +int brcmf_debug_fwlog_init (struct brcmf_pub *drvr);#else static inline struct dentry *brcmf_debugfs_get_devdir (struct brcmf_pub *drvr) {
@@ -137,6 +142,25 @@ int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, {return 0 ; } + +static inline +int brcmf_debug_fwlog_init (struct brcmf_pub *drvr) +{ +return 0 ; +}#endif +/* Message trace header */ +struct msgtrace_hdr { +u8 version; +u8 trace_type; +u16 len;/* Len of the trace */ +u32 seqnum;/* Sequence number of message */ +/* Number of discarded bytes because of trace overflow */ +u32 discarded_bytes; +/* Number of discarded printf because of trace overflow */ +u32 discarded_printf; +}; + +#define MSGTRACE_HDRLEN sizeof(struct msgtrace_hdr)#endif /* BRCMFMAC_DEBUG_H */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +14 -0
@@ -1219,6 +1219,12 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,if (ret) goto error; +if (BRCMF_FWCON_ON ()) { + ret =brcmf_fwlog_attach (devinfo->dev); +if (ret) + goto error; + } +/* Attach to the common driver interface */ ret =brcmf_attach (devinfo->dev);if (ret)
@@ -1295,9 +1301,17 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) ret =brcmf_alloc (devinfo->dev, devinfo->settings);if (ret) goto fail; + +if (BRCMF_FWCON_ON ()) { + ret =brcmf_fwlog_attach (devinfo->dev); +if (ret) + goto fail; + } + ret =brcmf_attach (devinfo->dev);if (ret) goto fail; +/* we are done */ complete (&devinfo->dev_init_done);return 0 ;
Signature · 1 line
2.1.0
Arend Van Spriel
maintainerRe: [PATCH V3 6/6] brcmfmac: To support printing USB console messages
Quoted 5 lines · Chi-Hsien Lin
From: Raveendran Somu <[email protected]>
This change is to add support for printing the firmware console messges of a USB interface chip to the host. To enable this feature, build option '-msgtrace' should be
Given this description I expected a feature flag would be added in the driver. Can we detect it on driver side?
Regards,
Arend