Skip to contentSkip to conversation

brcmfmac: fix usb device reset and debugging functions

PATCH In review Arend van Spriel 1 participant 7 messages Feb 8, 2013 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

cover brcmfmac: fix usb device reset and debugging functions

Fixing a problem found in usb device reset that could result in a null pointer access. The debugging functions in sdio driver had a locking issue and on some devices needed a backplane clock running to function properly.

Hante Meuleman (2):
brcmfmac: use brcmf_if::bssidx as index in interface list
brcmfmac: Check null pointer on brcmf_dev_reset.

Piotr Haber (3):
brcmfmac: fix mmc host locking issue
brcmfmac: turn clocks on when reading shared info
brcmfmac: remove unnecessary locking in trap info processing

 drivers/net/wireless/brcm80211/brcmfmac/dhd.h      |   10 +--
 drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c  |    8 +++
 .../net/wireless/brcm80211/brcmfmac/dhd_linux.c    |   75 ++++++++++----------
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |    7 +-
 drivers/net/wireless/brcm80211/brcmfmac/fweh.c     |    9 ++-
 drivers/net/wireless/brcm80211/brcmfmac/fwil.c     |    5 +-
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    2 +
 7 files changed, 61 insertions(+), 55 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/5 brcmfmac: use brcmf_if::bssidx as index in interface list

From: Hante Meuleman <[email protected]>

Upon receiving an IF event from the firmware the interface was created and stored on a list using the interface index. With upcoming P2P feature the firmware will send a IF event in which two interfaces have the same interface index. To uniquely locate them on the list the bss index is now used.

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd.h      |   10 +--
 drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c  |    8 +++
 .../net/wireless/brcm80211/brcmfmac/dhd_linux.c    |   72 ++++++++++----------
 drivers/net/wireless/brcm80211/brcmfmac/fweh.c     |    9 ++-
 drivers/net/wireless/brcm80211/brcmfmac/fwil.c     |    5 +-
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    2 +
 6 files changed, 57 insertions(+), 49 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd.h +5 -5
index e17f68a..7c78131 100644
@@ -512,7 +512,7 @@ struct brcmf_cfg80211_vif;
  * @vif: points to cfg80211 specific interface information.
  * @ndev: associated network device.
  * @stats: interface specific network statistics.
- * @idx: interface index in device firmware.
+ * @ifidx: interface index in device firmware.
  * @bssidx: index of bss associated with this interface.
  * @mac_addr: assigned mac address.
  * @pend_8021x_cnt: tracks outstanding number of 802.1x frames.
@@ -525,7 +525,7 @@ struct brcmf_if {
 	struct net_device_stats stats;
 	struct work_struct setmacaddr_work;
 	struct work_struct multicast_work;
-	int idx;
+	int ifidx;
 	s32 bssidx;
 	u8 mac_addr[ETH_ALEN];
 	atomic_t pend_8021x_cnt;
@@ -549,9 +549,9 @@ extern int brcmf_proto_hdrpull(struct brcmf_pub *drvr, u8 *ifidx,
 			       struct sk_buff *rxp);
 
 extern int brcmf_net_attach(struct brcmf_if *ifp);
-extern struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, int ifidx,
-				     s32 bssidx, char *name, u8 *mac_addr);
-extern void brcmf_del_if(struct brcmf_pub *drvr, int ifidx);
+extern struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx,
+				     s32 ifidx, char *name, u8 *mac_addr);
+extern void brcmf_del_if(struct brcmf_pub *drvr, s32 bssidx);
 extern u32 brcmf_get_chip_info(struct brcmf_if *ifp);
 
 #endif				/* _BRCMF_H_ */
drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c +8 -0
index bb454cd..a2354d9 100644
@@ -303,6 +303,14 @@ int brcmf_proto_hdrpull(struct brcmf_pub *drvr, u8 *ifidx,
 		brcmf_err("rx data ifnum out of range (%d)\n", *ifidx);
 		return -EBADE;
 	}
+	/* The ifidx is the idx to map to matching netdev/ifp. When receiving
+	 * events this is easy because it contains the bssidx which maps
+	 * 1-on-1 to the netdev/ifp. But for data frames the ifidx is rcvd.
+	 * bssidx 1 is used for p2p0 and no data can be received or
+	 * transmitted on it. Therefor bssidx is ifidx + 1 if ifidx > 0
+	 */
+	if (*ifidx)
+		(*ifidx)++;
 
 	if (((h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT) !=
 	    BDC_PROTO_VER) {
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +35 -37

218 lines not on this page · raw message

drivers/net/wireless/brcm80211/brcmfmac/fweh.c +4 -5
index ba0b225..1fd29b0 100644
@@ -189,12 +189,12 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
 		return;
 	}
 
-	ifp = drvr->iflist[ifevent->ifidx];
+	ifp = drvr->iflist[ifevent->bssidx];
 
 	if (ifevent->action == BRCMF_E_IF_ADD) {
 		brcmf_dbg(EVENT, "adding %s (%pM)\n", emsg->ifname,
 			  emsg->addr);
-		ifp = brcmf_add_if(drvr, ifevent->ifidx, ifevent->bssidx,
+		ifp = brcmf_add_if(drvr, ifevent->bssidx, ifevent->ifidx,
 				   emsg->ifname, emsg->addr);
 		if (IS_ERR(ifp))
 			return;
@@ -206,7 +206,7 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
 	err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data);
 
 	if (ifevent->action == BRCMF_E_IF_DEL)
-		brcmf_del_if(drvr, ifevent->ifidx);
+		brcmf_del_if(drvr, ifevent->bssidx);
 }
 
 /**
@@ -250,8 +250,6 @@ static void brcmf_fweh_event_worker(struct work_struct *work)
 	drvr = container_of(fweh, struct brcmf_pub, fweh);
 
 	while ((event = brcmf_fweh_dequeue_event(fweh))) {
-		ifp = drvr->iflist[event->ifidx];
-
 		brcmf_dbg(EVENT, "event %s (%u) ifidx %u bsscfg %u addr %pM\n",
 			  brcmf_fweh_event_name(event->code), event->code,
 			  event->emsg.ifidx, event->emsg.bsscfgidx,
@@ -283,6 +281,7 @@ static void brcmf_fweh_event_worker(struct work_struct *work)
 			goto event_free;
 		}
 
+		ifp = drvr->iflist[emsg.bsscfgidx];
 		err = brcmf_fweh_call_event_handler(ifp, event->code, &emsg,
 						    event->data);
 		if (err) {
drivers/net/wireless/brcm80211/brcmfmac/fwil.c +3 -2
index f6ffcf6..8d1def9 100644
@@ -45,9 +45,10 @@ brcmf_fil_cmd_data(struct brcmf_if *ifp, u32 cmd, void *data, u32 len, bool set)
 	if (data != NULL)
 		len = min_t(uint, len, BRCMF_DCMD_MAXLEN);
 	if (set)
-		err = brcmf_proto_cdc_set_dcmd(drvr, ifp->idx, cmd, data, len);
+		err = brcmf_proto_cdc_set_dcmd(drvr, ifp->ifidx, cmd, data,
+					       len);
 	else
-		err = brcmf_proto_cdc_query_dcmd(drvr, ifp->idx, cmd, data,
+		err = brcmf_proto_cdc_query_dcmd(drvr, ifp->ifidx, cmd, data,
 						 len);
 
 	if (err >= 0)
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +2 -0
index d47b274..d78f946 100644
@@ -3546,6 +3546,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,
 	if (err < 0) {
 		brcmf_err("BRCMF_C_UP error (%d)\n", err);
 		goto exit;
+		brcmf_fil_iovar_int_set(ifp, "apsta", 0);
 	}
 
 	memset(&join_params, 0, sizeof(join_params));
@@ -4242,6 +4243,7 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
 
 cfg80211_attach_out:
 	brcmf_free_vif(vif);
+	wiphy_free(wiphy);
 	return NULL;
 }
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/5 brcmfmac: Check null pointer on brcmf_dev_reset.

In reply to Arend van Spriel

From: Hante Meuleman <[email protected]>

When unloading it is possible that drvr is not null, but iflist[0] is. So check iflist[0] pointer before using it.

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +2 -1
index db03d30..f90db57 100644
@@ -842,7 +842,8 @@ void brcmf_dev_reset(struct device *dev)
 	if (drvr == NULL)
 		return;
 
-	brcmf_fil_cmd_int_set(drvr->iflist[0], BRCMF_C_TERMINATED, 1);
+	if (drvr->iflist[0])
+		brcmf_fil_cmd_int_set(drvr->iflist[0], BRCMF_C_TERMINATED, 1);
 }
 
 void brcmf_detach(struct device *dev)
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 3/5 brcmfmac: fix mmc host locking issue

In reply to Arend van Spriel

From: Piotr Haber <[email protected]>

fix wrong locking in crash info processing

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +1 -1
index 04680c5..9a1f823 100644
@@ -2701,7 +2701,7 @@ static int brcmf_sdio_readshared(struct brcmf_sdio *bus,
 	sdio_claim_host(bus->sdiodev->func[1]);
 	rv = brcmf_sdbrcm_membytes(bus, false, shaddr,
 				   (u8 *)&addr_le, 4);
-	sdio_claim_host(bus->sdiodev->func[1]);
+	sdio_release_host(bus->sdiodev->func[1]);
 	if (rv < 0)
 		return rv;
 
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 4/5 brcmfmac: turn clocks on when reading shared info

In reply to Arend van Spriel

From: Piotr Haber <[email protected]>

Make sure backplane clocks are on while reading crash data.

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +1 -0
index 9a1f823..97764b4 100644
@@ -2699,6 +2699,7 @@ static int brcmf_sdio_readshared(struct brcmf_sdio *bus,
 	 * address of sdpcm_shared structure
 	 */
 	sdio_claim_host(bus->sdiodev->func[1]);
+	brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false);
 	rv = brcmf_sdbrcm_membytes(bus, false, shaddr,
 				   (u8 *)&addr_le, 4);
 	sdio_release_host(bus->sdiodev->func[1]);
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH 5/5 brcmfmac: remove unnecessary locking in trap info processing

In reply to Arend van Spriel

From: Piotr Haber <[email protected]>

Locking host access in trap info processing is not needed as bus access functions do it on their own.

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |    4 ----
 1 file changed, 4 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +0 -4
index 97764b4..3581763 100644
@@ -2721,10 +2721,8 @@ static int brcmf_sdio_readshared(struct brcmf_sdio *bus,
 	}
 
 	/* Read hndrte_shared structure */
-	sdio_claim_host(bus->sdiodev->func[1]);
 	rv = brcmf_sdbrcm_membytes(bus, false, addr, (u8 *)&sh_le,
 				   sizeof(struct sdpcm_shared_le));
-	sdio_release_host(bus->sdiodev->func[1]);
 	if (rv < 0)
 		return rv;
 
@@ -2826,14 +2824,12 @@ static int brcmf_sdio_trap_info(struct brcmf_sdio *bus, struct sdpcm_shared *sh,
 	if ((sh->flags & SDPCM_SHARED_TRAP) == 0)
 		return 0;
 
-	sdio_claim_host(bus->sdiodev->func[1]);
 	error = brcmf_sdbrcm_membytes(bus, false, sh->trap_addr, (u8 *)&tr,
 				      sizeof(struct brcmf_trap_info));
 	if (error < 0)
 		return error;
 
 	nbytes = brcmf_sdio_dump_console(bus, sh, data, count);
-	sdio_release_host(bus->sdiodev->func[1]);
 	if (nbytes < 0)
 		return nbytes;
 
Signature · 1 line
1.7.10.4
#6 lore raw
In reply to Arend van Spriel
Quoted 4 lines · Arend van Spriel

Fixing a problem found in usb device reset that could result in a null pointer access. The debugging functions in sdio driver had a locking issue and on some devices needed a backplane clock running to function properly.

Forgot to mention it, but this series is intended for v3.9 and depends on the patch series sent couple of days ago identified by:

Message-ID: <[email protected]>

Regards,
Arend van Spriel

Quoted 18 lines

Hante Meuleman (2):
brcmfmac: use brcmf_if::bssidx as index in interface list
brcmfmac: Check null pointer on brcmf_dev_reset.

Piotr Haber (3):
brcmfmac: fix mmc host locking issue
brcmfmac: turn clocks on when reading shared info
brcmfmac: remove unnecessary locking in trap info processing

 drivers/net/wireless/brcm80211/brcmfmac/dhd.h      |   10 +--
 drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c  |    8 +++
 .../net/wireless/brcm80211/brcmfmac/dhd_linux.c    |   75 ++++++++++----------
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |    7 +-
 drivers/net/wireless/brcm80211/brcmfmac/fweh.c     |    9 ++-
 drivers/net/wireless/brcm80211/brcmfmac/fwil.c     |    5 +-
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |    2 +
 7 files changed, 61 insertions(+), 55 deletions(-)