arm-sdk

os build toolkit for various embedded devices
git clone https://git.parazyd.org/arm-sdk
Log | Files | Refs | Submodules | README | LICENSE

0002-fix-brcmfmac-oops-and-race-condition.patch (3100B)


      1 From 6dc781566c97f06b5c0d491f34c9b23e72cb74be Mon Sep 17 00:00:00 2001
      2 From: Kevin Mihelich <kevin@archlinuxarm.org>
      3 Date: Thu, 2 Jul 2015 17:48:41 -0600
      4 Subject: [PATCH 4/4] fix brcmfmac oops and race condition
      5 
      6 This fixes a potential null pointer dereference by checking if null before
      7 freeing the vif struct.
      8 
      9 Also works around a race condition between brcm_patchram_plus loading the BT
     10 firmware, which exposes the wireless device, and the kernel loading bcrmfmac.
     11 100ms delay loops up to 1s are added around the first three initialization
     12 functions to hold off a failure until the device is actually ready. This is a
     13 hack.
     14 
     15 Signed-off-by: Kevin Mihelich <kevin@archlinuxarm.org>
     16 Edited by: parazyd <parazyd@dyne.org>
     17 	* Removed dhd_linux.c part of the patch since it is failing
     18 ---
     19  .../wireless-3.8/brcm80211/brcmfmac/dhd_common.c   | 47 ++++++++++++++--------
     20  .../wireless-3.8/brcm80211/brcmfmac/dhd_linux.c    |  4 +-
     21  2 files changed, 32 insertions(+), 19 deletions(-)
     22 
     23 diff --git a/drivers/net/wireless-3.8/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless-3.8/brcm80211/brcmfmac/dhd_common.c
     24 index 05d4042..7006d19 100644
     25 --- a/drivers/net/wireless-3.8/brcm80211/brcmfmac/dhd_common.c
     26 +++ b/drivers/net/wireless-3.8/brcm80211/brcmfmac/dhd_common.c
     27 @@ -252,25 +252,34 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
     28  	struct brcmf_join_pref_params join_pref_params[2];
     29  	char *ptr;
     30  	s32 err;
     31 +	int i;
     32  
     33  	/* retreive mac address */
     34 -	err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr,
     35 -				       sizeof(ifp->mac_addr));
     36 -	if (err < 0) {
     37 -		brcmf_err("Retreiving cur_etheraddr failed, %d\n",
     38 -			  err);
     39 -		goto done;
     40 +	for (i = 0; i < 9; i++) {
     41 +		err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr,
     42 +					       sizeof(ifp->mac_addr));
     43 +		if (err < 0 && i == 9) {
     44 +			brcmf_err("Retreiving cur_etheraddr failed, %d\n",
     45 +				  err);
     46 +			goto done;
     47 +		} else {
     48 +			msleep(100);
     49 +		}
     50  	}
     51  	memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
     52  
     53  	/* query for 'ver' to get version info from firmware */
     54 -	memset(buf, 0, sizeof(buf));
     55 -	strcpy(buf, "ver");
     56 -	err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf));
     57 -	if (err < 0) {
     58 -		brcmf_err("Retreiving version information failed, %d\n",
     59 -			  err);
     60 -		goto done;
     61 +	for (i = 0; i < 10; i++) {
     62 +		memset(buf, 0, sizeof(buf));
     63 +		strcpy(buf, "ver");
     64 +		err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf));
     65 +		if (err < 0 && i == 9) {
     66 +			brcmf_err("Retreiving version information failed, %d\n",
     67 +				  err);
     68 +			goto done;
     69 +		} else {
     70 +			msleep(100);
     71 +		}
     72  	}
     73  	ptr = (char *)buf;
     74  	strsep(&ptr, "\n");
     75 @@ -283,10 +292,14 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
     76  	strlcpy(ifp->drvr->fwver, ptr, sizeof(ifp->drvr->fwver));
     77  
     78  	/* set mpc */
     79 -	err = brcmf_fil_iovar_int_set(ifp, "mpc", 1);
     80 -	if (err) {
     81 -		brcmf_err("failed setting mpc\n");
     82 -		goto done;
     83 +	for (i = 0; i < 10; i++) {
     84 +		err = brcmf_fil_iovar_int_set(ifp, "mpc", 1);
     85 +		if (err && i == 9) {
     86 +			brcmf_err("failed setting mpc\n");
     87 +			goto done;
     88 +		} else {
     89 +			msleep(100);
     90 +		}
     91  	}
     92  
     93  	/*
     94 2.4.4
     95