brcmfmac: async firmware loading and USB3.0 detection
cover brcmfmac: async firmware loading and USB3.0 detection
This series mainly changes the driver to use the asynchronous firmware request API. Hante also made couple of fixes that are needed to properly detect USB3.0 devices. Remaining patches are small fixes in scanning and connecting.
These patches are intended for v3.16 and apply to the master branch of the wireless-next repository.
Arend van Spriel (13):
brcmfmac: reduce log level for invalid scheduled scan request
brcmfmac: restore mpc before passing scan status to cfg80211
brcmfmac: make chandef_to_chanspec() function static
brcmfmac: remove .init() callback for internal bus interface
brcmfmac: rename nvram.[ch] for upcoming firmware handling functions
brcmfmac: call brcmf_detach() unconditional in sdio .remove()
callback
brcmfmac: rework usb callback operations
brcmfmac: introduce asynchronous firmware loading
brcmfmac: use asynchronous firmware request in SDIO
brcmfmac: use asynchronous firmware request in USB
brcmfmac: make brcmf_fw_nvram_strip() static
brcmutil: assure unused bits are cleared in 11n chanspec
brcmfmac: remove firmware list from USB driver
Daniel Kim (1):
brcmfmac: Increase max buffer size for receiving control message from
dongle
Hante Meuleman (2):
brcmfmac: Add log of superspeed device detection to USB probe.
brcmfmac: Remove interrupt endpoint usage from USB driver.
drivers/net/wireless/brcm80211/brcmfmac/Makefile | 2 +-
drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 6 -
.../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 7 -
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 283 +++++++++-----------
.../brcm80211/brcmfmac/{nvram.c => firmware.c} | 113 +++++++-
.../brcm80211/brcmfmac/{nvram.h => firmware.h} | 24 +-
drivers/net/wireless/brcm80211/brcmfmac/usb.c | 269 ++++++-------------
.../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 11 +-
drivers/net/wireless/brcm80211/brcmutil/d11.c | 2 +-
9 files changed, 352 insertions(+), 365 deletions(-)
rename drivers/net/wireless/brcm80211/brcmfmac/{nvram.c => firmware.c} (65%)
rename drivers/net/wireless/brcm80211/brcmfmac/{nvram.h => firmware.h} (52%)Signature · 1 line
1.7.9.5
PATCH 1/16 brcmfmac: reduce log level for invalid scheduled scan request
When a regular scan does not return any networks user-space does request a scheduled scan without any matchset or ssid. This can not be handled by the firmware so we return -EINVAL. However, as this request is done let us not add an error message to the log.
--- .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +1 -1
@@ -3178,7 +3178,7 @@ brcmf_cfg80211_sched_scan_start(struct wiphy *wiphy, }if (!request->n_ssids || !request->n_match_sets) { -brcmf_err ("Invalid sched scan req!! n_ssids:%d\n" , +brcmf_dbg (SCAN ,"Invalid sched scan req!! n_ssids:%d\n" , request->n_ssids);return -EINVAL ; }
Signature · 1 line
1.7.9.5
PATCH 2/16 brcmfmac: restore mpc before passing scan status to cfg80211
In reply to Arend van SprielBefore informing cfg80211 about the scan status the device should be put back in mpc state. If done after user-space may initiate another (scheduled) scan and fail because scan is still busy as shown in logging below:
[ 3301.367376] brcmfmac: brcmf_fweh_event_worker event ESCAN_RESULT (69) [ 3301.377305] brcmfmac: brcmf_fweh_event_worker version 2 flags 0 status 0 [ 3301.384993] brcmutil: event payload, len=12 [ 3301.389208] 00000000: 0c 00 00 00 6d 00 00 00 34 12 00 00 [ 3301.389214] brcmfmac: brcmf_sdio_kso_control Enter: on=0 [ 3301.402196] brcmfmac: brcmf_inform_bss scanned AP count (0) [ 3301.407808] brcmfmac: brcmf_notify_escan_complete Enter [ 3301.413064] brcmfmac: brcmf_notify_escan_complete ESCAN Completed scan: Done [ 3301.420137] brcmfmac: brcmf_sdio_bus_txctl Enter [ 3301.420368] brcmfmac: brcmf_cfg80211_sched_scan_start Enter [ 3301.420370] brcmfmac: brcmf_cfg80211_sched_scan_start: Scanning already: status (1) [ 3301.440190] brcmfmac: brcmf_sdio_kso_control Enter: on=1 [ 3301.448695] brcmfmac: brcmf_sdio_tx_ctrlframe Enter [ 3301.453662] brcmfmac: brcmf_sdio_bus_rxctl Enter [ 3301.458326] brcmfmac: brcmf_sdio_isr Enter [ 3301.462523] brcmfmac: brcmf_sdio_dpc Enter [ 3301.466632] brcmfmac: brcmf_sdio_readframes Enter [ 3301.471431] brcmfmac: brcmf_sdio_read_control Enter [ 3301.476340] brcmfmac: brcmf_set_mpc MPC : 1
--- .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +3 -2
@@ -640,6 +640,9 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,if (err)brcmf_err ("Scan abort failed\n" ); } + +brcmf_set_mpc (ifp,1 ); +/* * e-scan can be initiated by scheduled scan * which takes precedence.
@@ -649,12 +652,10 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg, cfg->sched_escan = false;if (!aborted)cfg80211_sched_scan_results (cfg_to_wiphy (cfg)); -brcmf_set_mpc (ifp,1 ); }else if (scan_request) {brcmf_dbg (SCAN ,"ESCAN Completed scan: %s\n" , aborted ?"Aborted" :"Done" );cfg80211_scan_done (scan_request, aborted); -brcmf_set_mpc (ifp,1 ); }if (!test_and_clear_bit (BRCMF_SCAN_STATUS_BUSY , &cfg->scan_status))brcmf_dbg (SCAN ,"Scan complete, probably P2P scan\n" );
Signature · 1 line
1.7.9.5
PATCH 3/16 brcmfmac: make chandef_to_chanspec() function static
In reply to Arend van SprielThe function chandef_to_chanspec() was added by
brcmfmac: determine chanspec from struct cfg80211_chan_def info
The struct cfg80211_chan_def contains additional info to derive the bandwidth and side-band information of the chanspec. This patch adds chandef_to_chanspec() function used in IBSS join and starting AP operation.
However, it introduced a sparse warning because the function is only called from within the source file wl_cfg80211.c.
--- .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +2 -2
@@ -341,8 +341,8 @@ static u8 brcmf_mw_to_qdbm(u16 mw)return qdbm; } -u16 chandef_to_chanspec (struct brcmu_d11inf *d11inf, -struct cfg80211_chan_def *ch) +static u16 chandef_to_chanspec (struct brcmu_d11inf *d11inf, +struct cfg80211_chan_def *ch) {struct brcmu_chan ch_inf;s32 primary_offset;
Signature · 1 line
1.7.9.5
PATCH 4/16 brcmfmac: remove .init() callback for internal bus interface
In reply to Arend van SprielThe .init() callback was the first function called by the common bus function brcmf_bus_start(). Given that it is not really necessary and the bus layer can call it before calling the brcmf_bus_start() function.
--- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 6 ------ .../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 7 ------- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 5 ++++- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 7 ++++++- 4 files changed, 10 insertions(+), 15 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +0 -6
@@ -63,7 +63,6 @@ struct brcmf_bus_dcmd {*/ struct brcmf_bus_ops {int (*preinit)(struct device *dev); -int (*init)(struct device *dev);void (*stop)(struct device *dev);int (*txdata)(struct device *dev,struct sk_buff *skb);int (*txctl)(struct device *dev,unsigned char *msg,uint len);
@@ -114,11 +113,6 @@ static inline int brcmf_bus_preinit(struct brcmf_bus *bus)return bus->ops->preinit (bus->dev); } -static inline int brcmf_bus_init (struct brcmf_bus *bus) -{ -return bus->ops->init (bus->dev); -} -static inline void brcmf_bus_stop (struct brcmf_bus *bus) { bus->ops->stop (bus->dev);
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +0 -7
@@ -916,13 +916,6 @@ int brcmf_bus_start(struct device *dev)brcmf_dbg (TRACE ,"\n" ); -/* Bring up the bus */ - ret =brcmf_bus_init (bus_if); -if (ret !=0 ) { -brcmf_err ("brcmf_sdbrcm_bus_init failed %d\n" , ret); -return ret; - } -/* add primary networking interface */ ifp =brcmf_add_if (drvr,0 ,0 ,"wlan%d" ,NULL );if (IS_ERR (ifp))
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +4 -1
@@ -4020,7 +4020,6 @@ brcmf_sdio_watchdog(unsigned long data)static struct brcmf_bus_ops brcmf_sdio_bus_ops = { .stop = brcmf_sdio_bus_stop, .preinit = brcmf_sdio_bus_preinit, - .init = brcmf_sdio_bus_init, .txdata = brcmf_sdio_bus_txdata, .txctl = brcmf_sdio_bus_txctl, .rxctl = brcmf_sdio_bus_rxctl,
@@ -4150,6 +4149,10 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)brcmf_sdio_debugfs_create (bus);brcmf_dbg (INFO ,"completed!!\n" ); + ret =brcmf_sdio_bus_init (sdiodev->dev); +if (ret) + goto fail; +/* if firmware path present try to download and bring up bus */ ret =brcmf_bus_start (bus->sdiodev->dev);if (ret !=0 ) {
drivers/net/wireless/brcm80211/brcmfmac/usb.c +6 -1
@@ -1222,7 +1222,6 @@ error:static struct brcmf_bus_ops brcmf_usb_bus_ops = { .txdata = brcmf_usb_tx, - .init = brcmf_usb_up, .stop = brcmf_usb_down, .txctl = brcmf_usb_tx_ctlpkt, .rxctl = brcmf_usb_rx_ctlpkt,
@@ -1263,6 +1262,12 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) goto fail; } + ret =brcmf_usb_up (dev); +if (ret) { +brcmf_detach (dev); + goto fail; + } + ret =brcmf_bus_start (dev);if (ret) {brcmf_err ("dongle is not responding\n" );
Signature · 1 line
1.7.9.5
PATCH 5/16 brcmfmac: rename nvram.[ch] for upcoming firmware handling functions
In reply to Arend van SprielThe firmware processing will be modified to use asynchronous request firmware api. In preparation this patch is simple rename of source and header file to which the functionality will be added.
---
drivers/net/wireless/brcm80211/brcmfmac/Makefile | 2 +-
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 6 +++---
.../brcm80211/brcmfmac/{nvram.c => firmware.c} | 6 +++---
.../brcm80211/brcmfmac/{nvram.h => firmware.h} | 10 +++++-----
4 files changed, 12 insertions(+), 12 deletions(-)
rename drivers/net/wireless/brcm80211/brcmfmac/{nvram.c => firmware.c} (97%)
rename drivers/net/wireless/brcm80211/brcmfmac/{nvram.h => firmware.h} (79%)drivers/net/wireless/brcm80211/brcmfmac/Makefile +1 -1
@@ -33,7 +33,7 @@ brcmfmac-objs += \ bcdc.o \ dhd_common.o \ dhd_linux.o \ - nvram.o \ + firmware.o \ btcoex.o brcmfmac-$(CONFIG_BRCMFMAC_SDIO) += \ dhd_sdio.o \
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +3 -3
@@ -42,7 +42,7 @@#include <soc.h> #include "sdio_host.h" #include "chip.h" -#include "nvram.h" +#include "firmware.h" #define DCMD_RESP_TIMEOUT 2000/* In milli second */
@@ -3287,7 +3287,7 @@ static int brcmf_sdio_download_nvram(struct brcmf_sdio *bus,brcmf_dbg (TRACE ,"Enter\n" ); - vars =brcmf_nvram_strip (nv, &varsz); + vars =brcmf_fw_nvram_strip (nv, &varsz);if (vars ==NULL )return -EINVAL ;
@@ -3300,7 +3300,7 @@ static int brcmf_sdio_download_nvram(struct brcmf_sdio *bus,else if (!brcmf_sdio_verifymemory (bus->sdiodev, address, vars, varsz)) err = -EIO ; -brcmf_nvram_free (vars); +brcmf_fw_nvram_free (vars);return err; }
drivers/net/wireless/brcm80211/brcmfmac/firmware.c renamed from drivers/net/wireless/brcm80211/brcmfmac/nvram.c +3 -3
@@ -19,7 +19,7 @@#include <linux/firmware.h> #include "dhd_dbg.h" -#include "nvram.h" +#include "firmware.h" enum nvram_parser_state {IDLE ,
@@ -187,7 +187,7 @@ static int brcmf_init_nvram_parser(struct nvram_parser *nvp,* and converts newlines to NULs. Shortens buffer as needed and pads with NULs. * End of buffer is completed with token identifying length of buffer. */ -void *brcmf_nvram_strip (const struct firmware *nv,u32 *new_length) +void *brcmf_fw_nvram_strip (const struct firmware *nv,u32 *new_length) {struct nvram_parser nvp;u32 pad;
@@ -219,7 +219,7 @@ void *brcmf_nvram_strip(const struct firmware *nv, u32 *new_length)return nvp.nvram; } -void brcmf_nvram_free (void *nvram) +void brcmf_fw_nvram_free (void *nvram) {kfree (nvram); }
drivers/net/wireless/brcm80211/brcmfmac/firmware.h renamed from drivers/net/wireless/brcm80211/brcmfmac/nvram.h +5 -5
@@ -13,12 +13,12 @@* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef BRCMFMAC_NVRAM_H -#define BRCMFMAC_NVRAM_H +#ifndef BRCMFMAC_FIRMWARE_H +#define BRCMFMAC_FIRMWARE_H -void *brcmf_nvram_strip (const struct firmware *nv,u32 *new_length); -void brcmf_nvram_free (void *nvram); +void *brcmf_fw_nvram_strip (const struct firmware *nv,u32 *new_length); +void brcmf_fw_nvram_free (void *nvram); -#endif /* BRCMFMAC_NVRAM_H */ +#endif /* BRCMFMAC_FIRMWARE_H */
Signature · 1 line
1.7.9.5
PATCH 6/16 brcmfmac: call brcmf_detach() unconditional in sdio .remove() callback
In reply to Arend van SprielThe function brcmf_detach() checks whether it needs to do his stuff or can return immediately. No need to have the same check in the calling code.
--- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +1 -3
@@ -4176,9 +4176,7 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)/* De-register interrupt handler */ brcmf_sdiod_intr_unregister (bus->sdiodev); -if (bus->sdiodev->bus_if->drvr) { -brcmf_detach (bus->sdiodev->dev); - } +brcmf_detach (bus->sdiodev->dev);cancel_work_sync (&bus->datawork);if (bus->brcmf_wq)
Signature · 1 line
1.7.9.5
PATCH 7/16 brcmfmac: rework usb callback operations
In reply to Arend van SprielThe resume callbacks do partly the same a the probe callback so put common code in separate function for use in the callbacks. This also fixes suspend/resume regression introduced by
brcmfmac: remove .init() callback for internal bus interface
The .init() callback was the first function called by the common bus function brcmf_bus_start(). Given that it is not really necessary and the bus layer can call it before calling the brcmf_bus_start() function.
--- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 48 ++++++++++++++----------- 1 file changed, 28 insertions(+), 20 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/usb.c +28 -20
@@ -1227,6 +1227,31 @@ static struct brcmf_bus_ops brcmf_usb_bus_ops = { .rxctl = brcmf_usb_rx_ctlpkt, }; +static int brcmf_usb_bus_setup (struct brcmf_usbdev_info *devinfo) +{ +int ret; + +/* Attach to the common driver interface */ + ret =brcmf_attach (devinfo->dev); +if (ret) { +brcmf_err ("brcmf_attach failed\n" ); +return ret; + } + + ret =brcmf_usb_up (devinfo->dev); +if (ret) + goto fail; + + ret =brcmf_bus_start (devinfo->dev); +if (ret) + goto fail; + +return 0 ; +fail: +brcmf_detach (devinfo->dev); +return ret; +} +static int brcmf_usb_probe_cb (struct brcmf_usbdev_info *devinfo) {struct brcmf_bus *bus =NULL ;
@@ -1255,23 +1280,9 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) bus->proto_type =BRCMF_PROTO_BCDC ; bus->always_use_fws_queue = true; -/* Attach to the common driver interface */ - ret =brcmf_attach (dev); -if (ret) { -brcmf_err ("brcmf_attach failed\n" ); - goto fail; - } - - ret =brcmf_usb_up (dev); -if (ret) { -brcmf_detach (dev); - goto fail; - } - - ret =brcmf_bus_start (dev); + ret =brcmf_usb_bus_setup (devinfo);if (ret) {brcmf_err ("dongle is not responding\n" ); -brcmf_detach (dev); goto fail; }
@@ -1461,10 +1472,7 @@ 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 (!brcmf_attach (devinfo->dev)) -return brcmf_bus_start (&usb->dev); - -return 0 ; +return brcmf_usb_bus_setup (devinfo); }static int brcmf_usb_reset_resume (struct usb_interface *intf)
@@ -1475,7 +1483,7 @@ static int brcmf_usb_reset_resume(struct usb_interface *intf)brcmf_dbg (USB ,"Enter\n" );if (!brcmf_usb_fw_download (devinfo)) -return brcmf_usb_resume (intf); +return brcmf_usb_bus_setup (devinfo);return -EIO ; }
Signature · 1 line
1.7.9.5
PATCH 8/16 brcmfmac: Add log of superspeed device detection to USB probe.
In reply to Arend van SprielFrom: Hante Meuleman <[email protected]>
--- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/usb.c +3 -1
@@ -1417,7 +1417,9 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) devinfo->interval =IFEPDESC (usb,CONTROL_IF ,0 ).bInterval; -if (usb->speed ==USB_SPEED_HIGH ) +if (usb->speed ==USB_SPEED_SUPER ) +brcmf_dbg (USB ,"Broadcom super speed USB wireless device detected\n" ); +else if (usb->speed ==USB_SPEED_HIGH )brcmf_dbg (USB ,"Broadcom high speed USB wireless device detected\n" );else brcmf_dbg (USB ,"Broadcom full speed USB wireless device detected\n" );
Signature · 1 line
1.7.9.5
PATCH 9/16 brcmfmac: introduce asynchronous firmware loading
In reply to Arend van SprielThe driver needs firmware to be loaded to the device, which is done through the firmware class API. The synchronous call request_firmware() need root filesystem to be mounted and/or user-mode helper. These may not be avaliable on the moment it is called. Instead use request_firmware_nowait().
--- drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 107 ++++++++++++++++++++ drivers/net/wireless/brcm80211/brcmfmac/firmware.h | 15 ++- 2 files changed, 121 insertions(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/firmware.c +107 -0
@@ -16,6 +16,7 @@#include <linux/kernel.h> #include <linux/slab.h> +#include <linux/device.h> #include <linux/firmware.h> #include "dhd_dbg.h"
@@ -224,3 +225,109 @@ void brcmf_fw_nvram_free(void *nvram)kfree (nvram); } +struct brcmf_fw { +struct device *dev; +u16 flags; +const struct firmware *code; +const char *nvram_name; +void (*done)(struct device *dev,const struct firmware *fw, +void *nvram_image,u32 nvram_len); +}; + +static void brcmf_fw_request_nvram_done (const struct firmware *fw,void *ctx) +{ +struct brcmf_fw *fwctx = ctx; +u32 nvram_length =0 ; +void *nvram =NULL ; + +brcmf_dbg (TRACE ,"enter: dev=%s\n" ,dev_name (fwctx->dev)); +if (!fw && !(fwctx->flags &BRCMF_FW_REQ_NV_OPTIONAL )) + goto fail; + +if (fw) { + nvram =brcmf_fw_nvram_strip (fw, &nvram_length); +release_firmware (fw); +if (!nvram && !(fwctx->flags &BRCMF_FW_REQ_NV_OPTIONAL )) + goto fail; + } + + fwctx->done (fwctx->dev, fwctx->code, nvram, nvram_length); +kfree (fwctx); +return ; + +fail: +brcmf_dbg (TRACE ,"failed: dev=%s\n" ,dev_name (fwctx->dev)); +if (fwctx->code) +release_firmware (fwctx->code); +device_release_driver (fwctx->dev); +kfree (fwctx); +} + +static void brcmf_fw_request_code_done (const struct firmware *fw,void *ctx) +{ +struct brcmf_fw *fwctx = ctx; +int ret; + +brcmf_dbg (TRACE ,"enter: dev=%s\n" ,dev_name (fwctx->dev)); +if (!fw) + goto fail; + +/* only requested code so done here */ +if (!(fwctx->flags &BRCMF_FW_REQUEST_NVRAM )) { + fwctx->done (fwctx->dev, fw,NULL ,0 ); +kfree (fwctx); +return ; + } + fwctx->code = fw; + ret =request_firmware_nowait (THIS_MODULE , true, fwctx->nvram_name, + fwctx->dev,GFP_KERNEL , fwctx, + brcmf_fw_request_nvram_done); + +if (!ret) +return ; + +/* when nvram is optional call .done() callback here */ +if (fwctx->flags &BRCMF_FW_REQ_NV_OPTIONAL ) { + fwctx->done (fwctx->dev, fw,NULL ,0 ); +kfree (fwctx); +return ; + } + +/* failed nvram request */ +release_firmware (fw); +fail: +brcmf_dbg (TRACE ,"failed: dev=%s\n" ,dev_name (fwctx->dev)); +device_release_driver (fwctx->dev); +kfree (fwctx); +} + +int brcmf_fw_get_firmwares (struct device *dev,u16 flags, +const char *code,const char *nvram, +void (*fw_cb)(struct device *dev, +const struct firmware *fw, +void *nvram_image,u32 nvram_len)) +{ +struct brcmf_fw *fwctx; + +brcmf_dbg (TRACE ,"enter: dev=%s\n" ,dev_name (dev)); +if (!fw_cb || !code) +return -EINVAL ; + +if ((flags &BRCMF_FW_REQUEST_NVRAM ) && !nvram) +return -EINVAL ; + + fwctx =kzalloc (sizeof (*fwctx),GFP_KERNEL ); +if (!fwctx) +return -ENOMEM ; + + fwctx->dev = dev; + fwctx->flags = flags; + fwctx->done = fw_cb; +if (flags &BRCMF_FW_REQUEST_NVRAM ) + fwctx->nvram_name = nvram; + +return request_firmware_nowait (THIS_MODULE , true, code, dev, +GFP_KERNEL , fwctx, + brcmf_fw_request_code_done); +} +
drivers/net/wireless/brcm80211/brcmfmac/firmware.h +14 -1
@@ -16,9 +16,22 @@#ifndef BRCMFMAC_FIRMWARE_H #define BRCMFMAC_FIRMWARE_H +#define BRCMF_FW_REQUEST 0x000F +#define BRCMF_FW_REQUEST_NVRAM 0x0001 +#define BRCMF_FW_REQ_FLAGS 0x00F0 +#define BRCMF_FW_REQ_NV_OPTIONAL 0x0010void *brcmf_fw_nvram_strip (const struct firmware *nv,u32 *new_length);void brcmf_fw_nvram_free (void *nvram); - +/* +* Request firmware(s) asynchronously. When the asynchronous request +* fails it will not use the callback, but call device_release_driver() +* instead which will call the driver .remove() callback. +*/ +int brcmf_fw_get_firmwares (struct device *dev,u16 flags, +const char *code,const char *nvram, +void (*fw_cb)(struct device *dev, +const struct firmware *fw, +void *nvram_image,u32 nvram_len));#endif /* BRCMFMAC_FIRMWARE_H */
Signature · 1 line
1.7.9.5
PATCH 10/16 brcmfmac: use asynchronous firmware request in SDIO
In reply to Arend van SprielThis patch adds use of asynchronous firmware request to the driver SDIO layer.
--- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 271 +++++++++----------- 1 file changed, 124 insertions(+), 147 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +124 -147
@@ -632,43 +632,28 @@ static const struct brcmf_firmware_names brcmf_fwname_data[] = { { BCM4354_CHIP_ID, 0xFFFFFFFF, BRCMF_FIRMWARE_NVRAM(BCM4354) } }; - -static const struct firmware *brcmf_sdio_get_fw (struct brcmf_sdio *bus, -enum brcmf_firmware_type type) +static const char *brcmf_sdio_get_fwname (struct brcmf_chip *ci, +enum brcmf_firmware_type type) { -const struct firmware *fw; -const char *name; -int err, i; +int i;for (i =0 ; i <ARRAY_SIZE (brcmf_fwname_data); i++) { -if (brcmf_fwname_data[i].chipid == bus->ci->chip && - brcmf_fwname_data[i].revmsk &BIT (bus->ci->chiprev)) { +if (brcmf_fwname_data[i].chipid == ci->chip && + brcmf_fwname_data[i].revmsk &BIT (ci->chiprev)) {switch (type) {case BRCMF_FIRMWARE_BIN : - name = brcmf_fwname_data[i].bin; -break ; +return brcmf_fwname_data[i].bin;case BRCMF_FIRMWARE_NVRAM : - name = brcmf_fwname_data[i].nv; -break ; +return brcmf_fwname_data[i].nv;default :brcmf_err ("invalid firmware type (%d)\n" , type);return NULL ; } - goto found; } }brcmf_err ("Unknown chipid %d [%d]\n" , - bus->ci->chip, bus->ci->chiprev); + ci->chip, ci->chiprev);return NULL ; - -found: - err =request_firmware (&fw, name, &bus->sdiodev->func[2 ]->dev); -if ((err) || (!fw)) { -brcmf_err ("fail to request firmware %s (%d)\n" , name, err); -return NULL ; - } - -return fw; }static void pkt_align (struct sk_buff *p,int len,int align)
@@ -3278,20 +3263,13 @@ static int brcmf_sdio_download_code_file(struct brcmf_sdio *bus, }static int brcmf_sdio_download_nvram (struct brcmf_sdio *bus, -const struct firmware *nv) +void *vars,u32 varsz) { -void *vars; -u32 varsz;int address;int err;brcmf_dbg (TRACE ,"Enter\n" ); - vars =brcmf_fw_nvram_strip (nv, &varsz); - -if (vars ==NULL ) -return -EINVAL ; - address = bus->ci->ramsize - varsz + bus->ci->rambase; err =brcmf_sdiod_ramrw (bus->sdiodev, true, address, vars, varsz);if (err)
@@ -3300,15 +3278,14 @@ static int brcmf_sdio_download_nvram(struct brcmf_sdio *bus,else if (!brcmf_sdio_verifymemory (bus->sdiodev, address, vars, varsz)) err = -EIO ; -brcmf_fw_nvram_free (vars); -return err; } -static int brcmf_sdio_download_firmware (struct brcmf_sdio *bus) +static int brcmf_sdio_download_firmware (struct brcmf_sdio *bus, +const struct firmware *fw, +void *nvram,u32 nvlen) {int bcmerror = -EFAULT ; -const struct firmware *fw;u32 rstvec;sdio_claim_host (bus->sdiodev->func[1 ]);
@@ -3317,12 +3294,6 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus)/* Keep arm in reset */ brcmf_chip_enter_download (bus->ci); - fw =brcmf_sdio_get_fw (bus,BRCMF_FIRMWARE_BIN ); -if (fw ==NULL ) { - bcmerror = -ENOENT ; - goto err; - } - rstvec =get_unaligned_le32 (fw->data);brcmf_dbg (SDIO ,"firmware rstvec: %x\n" , rstvec);
@@ -3330,17 +3301,12 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus)release_firmware (fw);if (bcmerror) {brcmf_err ("dongle image file download failed\n" ); +brcmf_fw_nvram_free (nvram); goto err; } - fw =brcmf_sdio_get_fw (bus,BRCMF_FIRMWARE_NVRAM ); -if (fw ==NULL ) { - bcmerror = -ENOENT ; - goto err; - } - - bcmerror =brcmf_sdio_download_nvram (bus, fw); -release_firmware (fw); + bcmerror =brcmf_sdio_download_nvram (bus, nvram, nvlen); +brcmf_fw_nvram_free (nvram);if (bcmerror) {brcmf_err ("dongle nvram file download failed\n" ); goto err;
@@ -3490,97 +3456,6 @@ done:return err; } -static int brcmf_sdio_bus_init (struct device *dev) -{ -struct brcmf_bus *bus_if =dev_get_drvdata (dev); -struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; -struct brcmf_sdio *bus = sdiodev->bus; -int err, ret =0 ; -u8 saveclk; - -brcmf_dbg (TRACE ,"Enter\n" ); - -/* try to download image and nvram to the dongle */ -if (bus_if->state ==BRCMF_BUS_DOWN ) { - bus->alp_only = true; - err =brcmf_sdio_download_firmware (bus); -if (err) -return err; - bus->alp_only = false; - } - -if (!bus->sdiodev->bus_if->drvr) -return 0 ; - -/* Start the watchdog timer */ - bus->sdcnt.tickcnt =0 ; -brcmf_sdio_wd_timer (bus,BRCMF_WD_POLL_MS ); - -sdio_claim_host (bus->sdiodev->func[1 ]); - -/* Make sure backplane clock is on, needed to generate F2 interrupt */ -brcmf_sdio_clkctl (bus,CLK_AVAIL , false); -if (bus->clkstate !=CLK_AVAIL ) - goto exit; - -/* Force clocks on backplane to be sure F2 interrupt propagates */ - saveclk =brcmf_sdiod_regrb (bus->sdiodev, -SBSDIO_FUNC1_CHIPCLKCSR , &err); -if (!err) { -brcmf_sdiod_regwb (bus->sdiodev,SBSDIO_FUNC1_CHIPCLKCSR , - (saveclk |SBSDIO_FORCE_HT ), &err); - } -if (err) { -brcmf_err ("Failed to force clock for F2: err %d\n" , err); - goto exit; - } - -/* Enable function 2 (frame transfers) */ -w_sdreg32 (bus,SDPCM_PROT_VERSION <<SMB_DATA_VERSION_SHIFT , - offsetof(struct sdpcmd_regs , tosbmailboxdata)); - err =sdio_enable_func (bus->sdiodev->func[SDIO_FUNC_2 ]); - - -brcmf_dbg (INFO ,"enable F2: err=%d\n" , err); - -/* If F2 successfully enabled, set core and enable interrupts */ -if (!err) { -/* Set up the interrupt mask and enable interrupts */ - bus->hostintmask =HOSTINTMASK ; -w_sdreg32 (bus, bus->hostintmask, - offsetof(struct sdpcmd_regs , hostintmask)); - -brcmf_sdiod_regwb (bus->sdiodev,SBSDIO_WATERMARK ,8 , &err); - }else { -/* Disable F2 again */ -sdio_disable_func (bus->sdiodev->func[SDIO_FUNC_2 ]); - ret = -ENODEV ; - } - -if (brcmf_chip_sr_capable (bus->ci)) { -brcmf_sdio_sr_init (bus); - }else { -/* Restore previous clock setting */ -brcmf_sdiod_regwb (bus->sdiodev,SBSDIO_FUNC1_CHIPCLKCSR , - saveclk, &err); - } - -if (ret ==0 ) { - ret =brcmf_sdiod_intr_register (bus->sdiodev); -if (ret !=0 ) -brcmf_err ("intr register failed:%d\n" , ret); - } - -/* If we didn't come up, turn off backplane clock */ -if (ret !=0 ) -brcmf_sdio_clkctl (bus,CLK_NONE , false); - -exit: -sdio_release_host (bus->sdiodev->func[1 ]); - -return ret; -} -void brcmf_sdio_isr (struct brcmf_sdio *bus) {brcmf_dbg (TRACE ,"Enter\n" );
@@ -4026,6 +3901,108 @@ static struct brcmf_bus_ops brcmf_sdio_bus_ops = { .gettxq = brcmf_sdio_bus_gettxq, }; +static void brcmf_sdio_firmware_callback (struct device *dev, +const struct firmware *code, +void *nvram,u32 nvram_len) +{ +struct brcmf_bus *bus_if =dev_get_drvdata (dev); +struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; +struct brcmf_sdio *bus = sdiodev->bus; +int err =0 ; +u8 saveclk; + +brcmf_dbg (TRACE ,"Enter: dev=%s\n" ,dev_name (dev)); + +/* try to download image and nvram to the dongle */ +if (bus_if->state ==BRCMF_BUS_DOWN ) { + bus->alp_only = true; + err =brcmf_sdio_download_firmware (bus, code, nvram, nvram_len); +if (err) + goto fail; + bus->alp_only = false; + } + +if (!bus_if->drvr) +return ; + +/* Start the watchdog timer */ + bus->sdcnt.tickcnt =0 ; +brcmf_sdio_wd_timer (bus,BRCMF_WD_POLL_MS ); + +sdio_claim_host (sdiodev->func[1 ]); + +/* Make sure backplane clock is on, needed to generate F2 interrupt */ +brcmf_sdio_clkctl (bus,CLK_AVAIL , false); +if (bus->clkstate !=CLK_AVAIL ) + goto release; + +/* Force clocks on backplane to be sure F2 interrupt propagates */ + saveclk =brcmf_sdiod_regrb (sdiodev,SBSDIO_FUNC1_CHIPCLKCSR , &err); +if (!err) { +brcmf_sdiod_regwb (sdiodev,SBSDIO_FUNC1_CHIPCLKCSR , + (saveclk |SBSDIO_FORCE_HT ), &err); + } +if (err) { +brcmf_err ("Failed to force clock for F2: err %d\n" , err); + goto release; + } + +/* Enable function 2 (frame transfers) */ +w_sdreg32 (bus,SDPCM_PROT_VERSION <<SMB_DATA_VERSION_SHIFT , + offsetof(struct sdpcmd_regs , tosbmailboxdata)); + err =sdio_enable_func (sdiodev->func[SDIO_FUNC_2 ]); + + +brcmf_dbg (INFO ,"enable F2: err=%d\n" , err); + +/* If F2 successfully enabled, set core and enable interrupts */ +if (!err) { +/* Set up the interrupt mask and enable interrupts */ + bus->hostintmask =HOSTINTMASK ; +w_sdreg32 (bus, bus->hostintmask, + offsetof(struct sdpcmd_regs , hostintmask)); + +brcmf_sdiod_regwb (sdiodev,SBSDIO_WATERMARK ,8 , &err); + }else { +/* Disable F2 again */ +sdio_disable_func (sdiodev->func[SDIO_FUNC_2 ]); + goto release; + } + +if (brcmf_chip_sr_capable (bus->ci)) { +brcmf_sdio_sr_init (bus); + }else { +/* Restore previous clock setting */ +brcmf_sdiod_regwb (sdiodev,SBSDIO_FUNC1_CHIPCLKCSR , + saveclk, &err); + } + +if (err ==0 ) { + err =brcmf_sdiod_intr_register (sdiodev); +if (err !=0 ) +brcmf_err ("intr register failed:%d\n" , err); + } + +/* If we didn't come up, turn off backplane clock */ +if (err !=0 ) +brcmf_sdio_clkctl (bus,CLK_NONE , false); + +sdio_release_host (sdiodev->func[1 ]); + + err =brcmf_bus_start (dev); +if (err !=0 ) { +brcmf_err ("dongle is not responding\n" ); + goto fail; + } +return ; + +release: +sdio_release_host (sdiodev->func[1 ]); +fail: +brcmf_dbg (TRACE ,"failed: dev=%s, err=%d\n" ,dev_name (dev), err); +device_release_driver (dev); +} +struct brcmf_sdio *brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev) {int ret;
@@ -4149,14 +4126,14 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)brcmf_sdio_debugfs_create (bus);brcmf_dbg (INFO ,"completed!!\n" ); - ret =brcmf_sdio_bus_init (sdiodev->dev); -if (ret) - goto fail; - -/* if firmware path present try to download and bring up bus */ - ret =brcmf_bus_start (bus->sdiodev->dev); + ret =brcmf_fw_get_firmwares (sdiodev->dev,BRCMF_FW_REQUEST_NVRAM , +brcmf_sdio_get_fwname (bus->ci, +BRCMF_FIRMWARE_BIN ), +brcmf_sdio_get_fwname (bus->ci, +BRCMF_FIRMWARE_NVRAM ), + brcmf_sdio_firmware_callback);if (ret !=0 ) { -brcmf_err ("dongle is not responding\n" ); +brcmf_err ("async firmware request failed: %d\n" , ret); goto fail; }
Signature · 1 line
1.7.9.5
PATCH 11/16 brcmfmac: use asynchronous firmware request in USB
In reply to Arend van SprielThis patch adds use of asynchronous firmware request to the driver USB layer.
--- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 98 +++++++++++++++++-------- 1 file changed, 68 insertions(+), 30 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/usb.c +68 -30
@@ -25,6 +25,7 @@#include <dhd_bus.h> #include <dhd_dbg.h> +#include "firmware.h" #include "usb_rdl.h" #include "usb.h"
@@ -87,7 +88,7 @@ struct brcmf_usbdev_info {struct brcmf_usbreq *tx_reqs;struct brcmf_usbreq *rx_reqs; -u8 *image;/* buffer for combine fw and nvram */ +const u8 *image;/* buffer for combine fw and nvram */ int image_len;struct usb_device *usbdev;
@@ -1021,7 +1022,7 @@ brcmf_usb_fw_download(struct brcmf_usbdev_info *devinfo) } err =brcmf_usb_dlstart (devinfo, - devinfo->image, devinfo->image_len); + (u8 *)devinfo->image, devinfo->image_len);if (err ==0 ) err =brcmf_usb_dlrun (devinfo);return err;
@@ -1080,7 +1081,22 @@ static int check_file(const u8 *headers)return -1 ; } -static int brcmf_usb_get_fw (struct brcmf_usbdev_info *devinfo) +static const char *brcmf_usb_get_fwname (struct brcmf_usbdev_info *devinfo) +{ +switch (devinfo->bus_pub.devid) { +case 43143 : +return BRCMF_USB_43143_FW_NAME ; +case 43235 : +case 43236 : +case 43238 : +return BRCMF_USB_43236_FW_NAME ; +case 43242 : +return BRCMF_USB_43242_FW_NAME ; +default : +return NULL ; + } +} +static __used int brcmf_usb_get_fw (struct brcmf_usbdev_info *devinfo) {s8 *fwname;const struct firmware *fw;
@@ -1202,16 +1218,6 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo, goto error; } -if (!brcmf_usb_dlneeded (devinfo)) -return &devinfo->bus_pub; - -brcmf_dbg (USB ,"Start fw downloading\n" ); -if (brcmf_usb_get_fw (devinfo)) - goto error; - -if (brcmf_usb_fw_download (devinfo)) - goto error; -return &devinfo->bus_pub; error:
@@ -1252,12 +1258,47 @@ fail:return ret; } +static void brcmf_usb_probe_phase2 (struct device *dev, +const struct firmware *fw, +void *nvram,u32 nvlen) +{ +struct brcmf_bus *bus =dev_get_drvdata (dev); +struct brcmf_usbdev_info *devinfo; +int ret; + +brcmf_dbg (USB ,"Start fw downloading\n" ); + ret =check_file (fw->data); +if (ret <0 ) { +brcmf_err ("invalid firmware\n" ); +release_firmware (fw); + goto error; + } + + devinfo = bus->bus_priv.usb->devinfo; + devinfo->image = fw->data; + devinfo->image_len = fw->size; + + ret =brcmf_usb_fw_download (devinfo); +release_firmware (fw); +if (ret) + goto error; + + ret =brcmf_usb_bus_setup (devinfo); +if (ret) + goto error; + +return ; +error: +brcmf_dbg (TRACE ,"failed: dev=%s, err=%d\n" ,dev_name (dev), ret); +device_release_driver (dev); +} +static int brcmf_usb_probe_cb (struct brcmf_usbdev_info *devinfo) {struct brcmf_bus *bus =NULL ;struct brcmf_usbdev *bus_pub =NULL ; -int ret;struct device *dev = devinfo->dev; +int ret;brcmf_dbg (USB ,"Enter\n" ); bus_pub =brcmf_usb_attach (devinfo,BRCMF_USB_NRXQ ,BRCMF_USB_NTXQ );
@@ -1280,13 +1321,16 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) bus->proto_type =BRCMF_PROTO_BCDC ; bus->always_use_fws_queue = true; - ret =brcmf_usb_bus_setup (devinfo); -if (ret) { -brcmf_err ("dongle is not responding\n" ); - goto fail; +if (!brcmf_usb_dlneeded (devinfo)) { + ret =brcmf_usb_bus_setup (devinfo); +if (ret) + goto fail; } - +/* request firmware here */ +brcmf_fw_get_firmwares (dev,0 ,brcmf_usb_get_fwname (devinfo),NULL , + brcmf_usb_probe_phase2);return 0 ; + fail:/* Release resources in reverse order */ kfree (bus);
@@ -1409,12 +1453,8 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) }/* Allocate interrupt URB and data buffer */ -/* RNDIS says 8-byte intr, our old drivers used 4-byte */ -if (IFEPDESC (usb,CONTROL_IF ,0 ).wMaxPacketSize ==cpu_to_le16 (16 )) - devinfo->intr_size =8 ; -else - devinfo->intr_size =4 ; - + devinfo->intr_size = +le16_to_cpu (IFEPDESC (usb,CONTROL_IF ,0 ).wMaxPacketSize); devinfo->interval =IFEPDESC (usb,CONTROL_IF ,0 ).bInterval;if (usb->speed ==USB_SPEED_SUPER )
@@ -1481,13 +1521,11 @@ static int brcmf_usb_reset_resume(struct usb_interface *intf) {struct usb_device *usb =interface_to_usbdev (intf);struct brcmf_usbdev_info *devinfo =brcmf_usb_get_businfo (&usb->dev); -brcmf_dbg (USB ,"Enter\n" ); -if (!brcmf_usb_fw_download (devinfo)) -return brcmf_usb_bus_setup (devinfo); - -return -EIO ; +return brcmf_fw_get_firmwares (&usb->dev,0 , +brcmf_usb_get_fwname (devinfo),NULL , + brcmf_usb_probe_phase2); }#define BRCMF_USB_VENDOR_ID_BROADCOM 0x0a5c
Signature · 1 line
1.7.9.5
PATCH 12/16 brcmfmac: make brcmf_fw_nvram_strip() static
In reply to Arend van SprielThe function brcmf_fw_nvram_strip() is no longer called so it does not need to be exposed.
--- drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 2 +- drivers/net/wireless/brcm80211/brcmfmac/firmware.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/firmware.c +1 -1
@@ -188,7 +188,7 @@ static int brcmf_init_nvram_parser(struct nvram_parser *nvp,* and converts newlines to NULs. Shortens buffer as needed and pads with NULs. * End of buffer is completed with token identifying length of buffer. */ -void *brcmf_fw_nvram_strip (const struct firmware *nv,u32 *new_length) +static void *brcmf_fw_nvram_strip (const struct firmware *nv,u32 *new_length) {struct nvram_parser nvp;u32 pad;
drivers/net/wireless/brcm80211/brcmfmac/firmware.h +0 -1
@@ -21,7 +21,6 @@#define BRCMF_FW_REQ_FLAGS 0x00F0#define BRCMF_FW_REQ_NV_OPTIONAL 0x0010 -void *brcmf_fw_nvram_strip (const struct firmware *nv,u32 *new_length);void brcmf_fw_nvram_free (void *nvram);/* * Request firmware(s) asynchronously. When the asynchronous request
Signature · 1 line
1.7.9.5
PATCH 13/16 brcmutil: assure unused bits are cleared in 11n chanspec
In reply to Arend van SprielThe firmware channel specification is a bitfield using a 16-bit integer, but only 14 lsb are used. Upon encoding this value assure all 16 bits are cleared.
--- drivers/net/wireless/brcm80211/brcmutil/d11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmutil/d11.c +1 -1
@@ -54,6 +54,7 @@ static void brcmu_d11n_encchspec(struct brcmu_chan *ch)if (ch->bw ==BRCMU_CHAN_BW_20 ) ch->sb =BRCMU_CHAN_SB_NONE ; + ch->chspec =0 ;brcmu_maskset16 (&ch->chspec,BRCMU_CHSPEC_CH_MASK ,BRCMU_CHSPEC_CH_SHIFT , ch->chnum); brcmu_maskset16(&ch->chspec, BRCMU_CHSPEC_D11N_SB_MASK,
@@ -61,7 +62,6 @@ static void brcmu_d11n_encchspec(struct brcmu_chan *ch)brcmu_maskset16 (&ch->chspec,BRCMU_CHSPEC_D11N_BW_MASK ,0 ,d11n_bw (ch->bw)); - ch->chspec &= ~BRCMU_CHSPEC_D11N_BND_MASK ;if (ch->chnum <=CH_MAX_2G_CHANNEL ) ch->chspec |=BRCMU_CHSPEC_D11N_BND_2G ;else
Signature · 1 line
1.7.9.5
PATCH 14/16 brcmfmac: Increase max buffer size for receiving control message from dongle
In reply to Arend van SprielFrom: Daniel Kim <[email protected]>
The max buffer size for receiving control message from dongle needs to be increased considering possible block padding. Otherwise some big control message can't be received due to buffer overrun check.
--- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +5 -4
@@ -4086,8 +4086,13 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) goto fail; } +/* Query the F2 block size, set roundup accordingly */ + bus->blocksize = bus->sdiodev->func[2 ]->cur_blksize; + bus->roundup =min (max_roundup, bus->blocksize); +/* Allocate buffers */ if (bus->sdiodev->bus_if->maxctl) { + bus->sdiodev->bus_if->maxctl += bus->roundup; bus->rxblen =roundup ((bus->sdiodev->bus_if->maxctl +SDPCM_HDRLEN ),ALIGNMENT ) + bus->head_align;
@@ -4115,10 +4120,6 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) bus->idletime =BRCMF_IDLE_INTERVAL ; bus->idleclock =BRCMF_IDLE_ACTIVE ; -/* Query the F2 block size, set roundup accordingly */ - bus->blocksize = bus->sdiodev->func[2 ]->cur_blksize; - bus->roundup =min (max_roundup, bus->blocksize); -/* SR state */ bus->sleeping = false; bus->sr_enabled = false;
Signature · 1 line
1.7.9.5
PATCH 15/16 brcmfmac: Remove interrupt endpoint usage from USB driver.
In reply to Arend van SprielFrom: Hante Meuleman <[email protected]>
The USB bus driver always configured an USB intr EP urb. The driver did not use the result at all and with newer firmware it is causing continues errors on this EP.
--- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 78 +------------------------ 1 file changed, 1 insertion(+), 77 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/usb.c +1 -77
@@ -64,11 +64,6 @@ struct brcmf_usb_image { };static struct list_head fw_image_list; -struct intr_transfer_buf { -u32 notification; -u32 reserved; -}; -struct brcmf_usbdev_info {struct brcmf_usbdev bus_pub;/* MUST BE FIRST */ spinlock_t qlock;
@@ -76,7 +71,7 @@ struct brcmf_usbdev_info {struct list_head rx_postq;struct list_head tx_freeq;struct list_head tx_postq; -uint rx_pipe, tx_pipe, intr_pipe, rx_pipe2; +uint rx_pipe, tx_pipe, rx_pipe2;int rx_low_watermark;int tx_low_watermark;
@@ -105,10 +100,6 @@ struct brcmf_usbdev_info {ulong ctl_op;struct urb *bulk_urb;/* used for FW download */ -struct urb *intr_urb;/* URB for interrupt endpoint */ -int intr_size;/* Size of interrupt message */ -int interval;/* Interrupt polling interval */ -struct intr_transfer_buf intr;/* Data buffer for interrupt endpoint */ }; static void brcmf_usb_rx_refill(struct brcmf_usbdev_info *devinfo,
@@ -532,39 +523,6 @@ brcmf_usb_state_change(struct brcmf_usbdev_info *devinfo, int state) } } -static void -brcmf_usb_intr_complete (struct urb *urb) -{ -struct brcmf_usbdev_info *devinfo = - (struct brcmf_usbdev_info *)urb->context; -int err; - -brcmf_dbg (USB ,"Enter, urb->status=%d\n" , urb->status); - -if (devinfo ==NULL ) -return ; - -if (unlikely (urb->status)) { -if (urb->status == -ENOENT || - urb->status == -ESHUTDOWN || - urb->status == -ENODEV ) { -brcmf_usb_state_change (devinfo, -BRCMFMAC_USB_STATE_DOWN ); - } - } - -if (devinfo->bus_pub.state ==BRCMFMAC_USB_STATE_DOWN ) { -brcmf_err ("intr cb when DBUS down, ignoring\n" ); -return ; - } - -if (devinfo->bus_pub.state ==BRCMFMAC_USB_STATE_UP ) { - err =usb_submit_urb (devinfo->intr_urb,GFP_ATOMIC ); -if (err) -brcmf_err ("usb_submit_urb, err=%d\n" , err); - } -} -static int brcmf_usb_tx (struct device *dev,struct sk_buff *skb) {struct brcmf_usbdev_info *devinfo =brcmf_usb_get_businfo (dev);
@@ -620,7 +578,6 @@ static int brcmf_usb_up(struct device *dev) {struct brcmf_usbdev_info *devinfo =brcmf_usb_get_businfo (dev);u16 ifnum; -int ret;brcmf_dbg (USB ,"Enter\n" );if (devinfo->bus_pub.state ==BRCMFMAC_USB_STATE_UP )
@@ -629,23 +586,6 @@ static int brcmf_usb_up(struct device *dev)/* Success, indicate devinfo is fully up */ brcmf_usb_state_change (devinfo,BRCMFMAC_USB_STATE_UP ); -if (devinfo->intr_urb) { -usb_fill_int_urb (devinfo->intr_urb, devinfo->usbdev, - devinfo->intr_pipe, - &devinfo->intr, - devinfo->intr_size, - (usb_complete_t )brcmf_usb_intr_complete, - devinfo, - devinfo->interval); - - ret =usb_submit_urb (devinfo->intr_urb,GFP_ATOMIC ); -if (ret) { -brcmf_err ("USB_SUBMIT_URB failed with status %d\n" , - ret); -return -EINVAL ; - } - } -if (devinfo->ctl_urb) { devinfo->ctl_in_pipe =usb_rcvctrlpipe (devinfo->usbdev,0 ); devinfo->ctl_out_pipe =usb_sndctrlpipe (devinfo->usbdev,0 );
@@ -682,8 +622,6 @@ static void brcmf_usb_down(struct device *dev)return ;brcmf_usb_state_change (devinfo,BRCMFMAC_USB_STATE_DOWN ); -if (devinfo->intr_urb) -usb_kill_urb (devinfo->intr_urb);if (devinfo->ctl_urb)usb_kill_urb (devinfo->ctl_urb);
@@ -1037,7 +975,6 @@ static void brcmf_usb_detach(struct brcmf_usbdev_info *devinfo)brcmf_usb_free_q (&devinfo->rx_freeq, false);brcmf_usb_free_q (&devinfo->tx_freeq, false); -usb_free_urb (devinfo->intr_urb);usb_free_urb (devinfo->ctl_urb);usb_free_urb (devinfo->bulk_urb);
@@ -1202,11 +1139,6 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo, goto error; devinfo->tx_freecount = ntxq; - devinfo->intr_urb =usb_alloc_urb (0 ,GFP_ATOMIC ); -if (!devinfo->intr_urb) { -brcmf_err ("usb_alloc_urb (intr) failed\n" ); - goto error; - } devinfo->ctl_urb =usb_alloc_urb (0 ,GFP_ATOMIC );if (!devinfo->ctl_urb) {brcmf_err ("usb_alloc_urb (ctl) failed\n" );
@@ -1418,9 +1350,6 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) goto fail; } - endpoint_num = endpoint->bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ; - devinfo->intr_pipe =usb_rcvintpipe (usb, endpoint_num); - devinfo->rx_pipe =0 ; devinfo->rx_pipe2 =0 ; devinfo->tx_pipe =0 ;
@@ -1452,11 +1381,6 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) } } -/* Allocate interrupt URB and data buffer */ - devinfo->intr_size = -le16_to_cpu (IFEPDESC (usb,CONTROL_IF ,0 ).wMaxPacketSize); - devinfo->interval =IFEPDESC (usb,CONTROL_IF ,0 ).bInterval; -if (usb->speed ==USB_SPEED_SUPER )brcmf_dbg (USB ,"Broadcom super speed USB wireless device detected\n" );else if (usb->speed ==USB_SPEED_HIGH )
Signature · 1 line
1.7.9.5
PATCH 16/16 brcmfmac: remove firmware list from USB driver
In reply to Arend van SprielThe USB driver was using a list for firmware info that was used in suspend/resume scenario. Now that brcmfmac is using the asynchronous firmware request this is no longer needed.
--- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 76 ------------------------- 1 file changed, 76 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/usb.c +0 -76
@@ -62,7 +62,6 @@ struct brcmf_usb_image {u8 *image;int image_len; }; -static struct list_head fw_image_list;struct brcmf_usbdev_info {struct brcmf_usbdev bus_pub;/* MUST BE FIRST */
@@ -1033,69 +1032,6 @@ static const char *brcmf_usb_get_fwname(struct brcmf_usbdev_info *devinfo)return NULL ; } } -static __used int brcmf_usb_get_fw (struct brcmf_usbdev_info *devinfo) -{ -s8 *fwname; -const struct firmware *fw; -struct brcmf_usb_image *fw_image; -int err; - -brcmf_dbg (USB ,"Enter\n" ); -switch (devinfo->bus_pub.devid) { -case 43143 : - fwname =BRCMF_USB_43143_FW_NAME ; -break ; -case 43235 : -case 43236 : -case 43238 : - fwname =BRCMF_USB_43236_FW_NAME ; -break ; -case 43242 : - fwname =BRCMF_USB_43242_FW_NAME ; -break ; -default : -return -EINVAL ; -break ; - } -brcmf_dbg (USB ,"Loading FW %s\n" , fwname); -list_for_each_entry (fw_image, &fw_image_list, list) { -if (fw_image->fwname == fwname) { - devinfo->image = fw_image->image; - devinfo->image_len = fw_image->image_len; -return 0 ; - } - } -/* fw image not yet loaded. Load it now and add to list */ - err =request_firmware (&fw, fwname, devinfo->dev); -if (!fw) { -brcmf_err ("fail to request firmware %s\n" , fwname); -return err; - } -if (check_file (fw->data) <0 ) { -brcmf_err ("invalid firmware %s\n" , fwname); -return -EINVAL ; - } - - fw_image =kzalloc (sizeof (*fw_image),GFP_ATOMIC ); -if (!fw_image) -return -ENOMEM ; -INIT_LIST_HEAD (&fw_image->list); -list_add_tail (&fw_image->list, &fw_image_list); - fw_image->fwname = fwname; - fw_image->image =vmalloc (fw->size); -if (!fw_image->image) -return -ENOMEM ; - -memcpy (fw_image->image, fw->data, fw->size); - fw_image->image_len = fw->size; - -release_firmware (fw); - - devinfo->image = fw_image->image; - devinfo->image_len = fw_image->image_len; - -return 0 ; -} static
@@ -1484,16 +1420,6 @@ static struct usb_driver brcmf_usbdrvr = { .disable_hub_initiated_lpm = 1, }; -static void brcmf_release_fw (struct list_head *q) -{ -struct brcmf_usb_image *fw_image, *next; - -list_for_each_entry_safe (fw_image, next, q, list) { -vfree (fw_image->image); -list_del_init (&fw_image->list); - } -} -static int brcmf_usb_reset_device (struct device *dev,void *notused) {/* device past is the usb interface so we
@@ -1512,12 +1438,10 @@ void brcmf_usb_exit(void) ret =driver_for_each_device (drv,NULL ,NULL , brcmf_usb_reset_device);usb_deregister (&brcmf_usbdrvr); -brcmf_release_fw (&fw_image_list); }void brcmf_usb_register (void ) {brcmf_dbg (USB ,"Enter\n" ); -INIT_LIST_HEAD (&fw_image_list);usb_register (&brcmf_usbdrvr); }
Signature · 1 line
1.7.9.5