brcmsmac fixes and driver cleanup
cover brcmsmac fixes and driver cleanup
With 3.1 kernel the crc8 and cordic library modules are available in the staging tree. The brcmsmac driver now uses them. Some small fixes have been made and the driver is made to work on the Sparc platform.
This series applies to staging-next and depends on the following patch set:
Message-ID: <[email protected]>
Arend van Spriel (4):
staging: brcm80211: make use of crc8 library function
staging: brcm80211: make use of cordic library function
staging: brcm80211: fix rtnl_lock issue when bringing down brcmfmac
staging: brcm80211: fill in proper rx rate in mac80211 rx status
Franky Lin (1):
staging: brcm80211: fix checkpatch warning in fullmac
Henry Ptasinski (1):
staging: brcm80211: only enable brcmsmac if bcma is not set
Roland Vossen (2):
staging: brcm80211: bugfix for exception on Sparc platforms
staging: brcm80211: bugfix for fifo problem on 64 bits platforms.
drivers/staging/brcm80211/Kconfig | 3 + drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 7 ++ drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h | 2 +- drivers/staging/brcm80211/brcmsmac/dma.c | 7 ++- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 9 ++- drivers/staging/brcm80211/brcmsmac/mac80211_if.h | 6 ++ drivers/staging/brcm80211/brcmsmac/main.c | 15 ++++- drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 62 ------------------- drivers/staging/brcm80211/brcmsmac/phy/phy_int.h | 1 - drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c | 7 +- drivers/staging/brcm80211/brcmsmac/phy/phy_n.c | 14 +++-- drivers/staging/brcm80211/brcmsmac/srom.c | 20 +++++- drivers/staging/brcm80211/brcmutil/utils.c | 69 ---------------------- drivers/staging/brcm80211/include/brcmu_utils.h | 5 -- 14 files changed, 71 insertions(+), 156 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/8 staging: brcm80211: only enable brcmsmac if bcma is not set
From: Henry Ptasinski <[email protected]>
brcmsmac doesn't yet use bcma, but both drivers attempt to claim the same device. For now, turn of brcmsmac if bcma is enabled.
--- drivers/staging/brcm80211/Kconfig | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/staging/brcm80211/Kconfig +1 -0
@@ -7,6 +7,7 @@ config BRCMSMAC default n depends on PCI depends on WLAN && MAC80211 + depends on BCMA=n select BRCMUTIL select FW_LOADER select CRC_CCITT
Signature · 1 line
1.7.4.1
PATCH 4/8 staging: brcm80211: fix checkpatch warning in fullmac
In reply to Arend van SprielFrom: Franky Lin <[email protected]>
Fix the __aligned checkpatch warning in wl_cfg80211.h
--- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +1 -1
@@ -317,7 +317,7 @@ struct brcmf_cfg80211_priv {u8 *ioctl_buf;/* ioctl buffer */ u8 *extra_buf;/* maily to grab assoc information */ struct dentry *debugfsdir; - u8 ci[0] __attribute__ ((__aligned__(NETDEV_ALIGN))); +u8 ci[0 ]__aligned(NETDEV_ALIGN) ; };#define cfg_to_wiphy (w) (w->wdev->wiphy)
Signature · 1 line
1.7.4.1
PATCH 5/8 staging: brcm80211: fix rtnl_lock issue when bringing down brcmfmac
In reply to Arend van SprielWhen bringing down the netdevice interface a deadlock occurred sporadically due to the rtnl_lock being held by a task that was waiting for another task trying to get the lock. This patch fixes that issue.
--- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +7 -0
@@ -3189,7 +3189,14 @@ static void brcmf_term_iscan(struct brcmf_cfg80211_priv *cfg_priv)if (cfg_priv->iscan_on && iscan->tsk) { iscan->state =WL_ISCAN_STATE_IDLE ;send_sig (SIGTERM , iscan->tsk,1 ); + +/* +* The iscan task may want to acquire the rtnl_lock +* so release it here upon stopping the task. +*/ +rtnl_unlock ();kthread_stop (iscan->tsk); +rtnl_lock (); iscan->tsk =NULL ;/* Abort iscan running in FW */
Signature · 1 line
1.7.4.1
PATCH 6/8 staging: brcm80211: bugfix for exception on Sparc platforms
In reply to Arend van SprielFrom: Roland Vossen <[email protected]>
Problem would pop up during driver load on a Sun Fire V120 and manifested itself as an exception. This was caused by int* pointers provided to memcpy() that were not aligned on an int boundary. The pointer type provided to memcpy() is used by the compiler for optimization purposes. Fix was to cast the int* pointers to void* pointers.
Bernhard R. Link and David S. Miller provided valuable feedback, thanks gents.
--- drivers/staging/brcm80211/brcmsmac/main.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/staging/brcm80211/brcmsmac/main.c +5 -2
@@ -6111,9 +6111,12 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len,/* default argument is generic integer */ pval = arg ? (int *)arg :NULL ; -/* This will prevent the misaligned access */ +/* +* This will prevent misaligned access. The (void *) cast prevents a +* memcpy alignment issue on e.g. Sparc64 platforms. +*/ if (pval && (u32 ) len >=sizeof (val)) -memcpy (&val, pval,sizeof (val)); +memcpy ((void *)&val, (void *)pval,sizeof (val));else val =0 ;
Signature · 1 line
1.7.4.1
PATCH 7/8 staging: brcm80211: bugfix for fifo problem on 64 bits platforms.
In reply to Arend van SprielFrom: Roland Vossen <[email protected]>
Message 'receive fifo overflow' appeared in the log. Root cause was an invalid physical address being programmed into the DMA engine. This was caused by an invalid pointer cast in the dma code. Issue was observed on a Sparc (Sun Fire V120) machine but could theoretically also pop up on other architectures.
Driver was tested to scan and ping on aforementioned machine.
--- drivers/staging/brcm80211/brcmsmac/dma.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/staging/brcm80211/brcmsmac/dma.c +6 -1
@@ -600,13 +600,18 @@ static bool _dma_alloc(struct dma_info *di, uint direction)void *dma_alloc_consistent (struct pci_dev *pdev,uint size,u16 align_bits,uint *alloced,unsigned long *pap) { +void *rc; +dma_addr_t dma_addr; +if (align_bits) {u16 align = (1 << align_bits);if (!IS_ALIGNED (PAGE_SIZE , align)) size += align; *alloced = size; } -return pci_alloc_consistent (pdev, size, (dma_addr_t *) pap); + rc =pci_alloc_consistent (pdev, size, &dma_addr); + *pap = dma_addr; +return rc; }/* !! may be called with core in reset */
Signature · 1 line
1.7.4.1
PATCH 2/8 staging: brcm80211: make use of crc8 library function
In reply to Arend van SprielThe crc8 function is now available as a library function provided by kernel module crc8.ko. The function has been removed from brcmutil module and srom.c now uses crc8 library function.
--- drivers/staging/brcm80211/Kconfig | 1 + drivers/staging/brcm80211/brcmsmac/srom.c | 20 +++++- drivers/staging/brcm80211/brcmutil/utils.c | 69 ----------------------- drivers/staging/brcm80211/include/brcmu_utils.h | 5 -- 4 files changed, 17 insertions(+), 78 deletions(-)
drivers/staging/brcm80211/Kconfig +1 -0
@@ -11,6 +11,7 @@ config BRCMSMAC select BRCMUTIL select FW_LOADER select CRC_CCITT + select CRC8 ---help--- This module adds support for PCIe wireless adapters based on Broadcom IEEE802.11n SoftMAC chipsets. If you choose to build a module, it'll
drivers/staging/brcm80211/brcmsmac/srom.c +16 -4
@@ -18,6 +18,7 @@#include <linux/string.h> #include <linux/io.h> #include <linux/etherdevice.h> +#include <linux/crc8.h> #include <stdarg.h> #include <chipcommon.h>
@@ -39,6 +40,13 @@#define WRITE_WORD_DELAY 20#endif +/* +* SROM CRC8 polynomial value: +* +* x^8 + x^7 +x^6 + x^4 + x^2 + 1 +*/ +#define SROM_CRC8_POLY 0xAB +/* Maximum srom: 6 Kilobits == 768 bytes */ #define SROM_MAX 768
@@ -782,6 +790,8 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { {NULL, 0, 0, 0, 0} }; +static u8 srom_crc8_table[CRC8_TABLE_SIZE ]; +static void _initvars_srom_pci (u8 sromrev,u16 *srom,uint off,struct brcms_varbuf *b); static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars,
@@ -919,8 +929,8 @@ sprom_read_pci(struct si_pub *sih, u16 *sprom, uint wordoff,/* fixup the endianness so crc8 will pass */ htol16_buf (buf, nwords *2 ); -if (brcmu_crc8 ((u8 *) buf, nwords *2 ,CRC8_INIT_VALUE ) != -CRC8_GOOD_VALUE ) +if (crc8 (srom_crc8_table, (u8 *) buf, nwords *2 , +CRC8_INIT_VALUE ) !=CRC8_GOOD_VALUE (srom_crc8_table))/* DBG only pci always read srom4 first, then srom8/9 */ err = -EIO ;
@@ -957,8 +967,8 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz)/* fixup the endianness so crc8 will pass */ htol16_buf (buf, bufsz); -if (brcmu_crc8 ((u8 *) buf,SROM4_WORDS *2 ,CRC8_INIT_VALUE ) != -CRC8_GOOD_VALUE ) +if (crc8 (srom_crc8_table, (u8 *) buf,SROM4_WORDS *2 , +CRC8_INIT_VALUE ) !=CRC8_GOOD_VALUE (srom_crc8_table)) err = -EIO ;/* now correct the endianness of the byte array */
@@ -1174,6 +1184,8 @@ static int initvars_srom_pci(struct si_pub *sih, void *curmap, char **vars,return -ENOMEM ; sromwindow = (u16 *)SROM_OFFSET (sih); + +crc8_populate_lsb (srom_crc8_table,SROM_CRC8_POLY );if (ai_is_sprom_available (sih)) { err =sprom_read_pci (sih, sromwindow,0 , srom,SROM_WORDS , true);
drivers/staging/brcm80211/brcmutil/utils.c +0 -69
75 lines not on this page · raw message
drivers/staging/brcm80211/include/brcmu_utils.h +0 -5
@@ -246,8 +246,6 @@ extern int brcmu_iovar_lencheck(const struct brcmu_iovar *table, void *arg,#define MODSUB_POW2 (x, y, bound) (((x) - (y)) & ((bound) - 1))/* crc defines */ -#define CRC8_INIT_VALUE 0xff/* Initial CRC8 checksum value */ -#define CRC8_GOOD_VALUE 0x9f/* Good final CRC8 checksum value */ #define CRC16_INIT_VALUE 0xffff/* Initial CRC16 checksum value */ #define CRC16_GOOD_VALUE 0xf0b8/* Good final CRC16 checksum value */
@@ -268,9 +266,6 @@ struct brcmu_tlv {#define ETHER_ADDR_STR_LEN 18/* externs */ -/* crc */ -extern u8 brcmu_crc8 (u8 *p,uint nbytes,u8 crc); -/* format/print */ #if defined(BCMDBG ) extern int brcmu_format_flags(const struct brcmu_bit_desc *bd, u32 flags,
Signature · 1 line
1.7.4.1
PATCH 3/8 staging: brcm80211: make use of cordic library function
In reply to Arend van SprielThe cordic function which calculates cosine and sine values for given angle is now provided in library module. The phy code now uses this module function.
--- drivers/staging/brcm80211/Kconfig | 1 + drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c | 62 ---------------------- drivers/staging/brcm80211/brcmsmac/phy/phy_int.h | 1 - drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c | 7 ++- drivers/staging/brcm80211/brcmsmac/phy/phy_n.c | 14 +++-- 5 files changed, 13 insertions(+), 72 deletions(-)
drivers/staging/brcm80211/Kconfig +1 -0
@@ -12,6 +12,7 @@ config BRCMSMAC select FW_LOADER select CRC_CCITT select CRC8 + select CORDIC ---help--- This module adds support for PCIe wireless adapters based on Broadcom IEEE802.11n SoftMAC chipsets. If you choose to build a module, it'll
drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +0 -62
68 lines not on this page · raw message
drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +0 -1
@@ -1039,7 +1039,6 @@ extern void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val);extern void write_phy_channel_reg (struct brcms_phy *pi,uint val);extern void wlc_phy_txpower_update_shm (struct brcms_phy *pi); -extern void wlc_phy_cordic (s32 theta,struct cs32 *val);extern u8 wlc_phy_nbits (s32 value);extern void wlc_phy_compute_dB (u32 *cmplx_pwr,s8 *p_dB,u8 core);
drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +4 -3
@@ -15,6 +15,7 @@*/ #include <linux/delay.h> +#include <linux/cordic.h> #include <pmu.h> #include <d11.h>
@@ -2723,7 +2724,7 @@ wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val,u16 num_samps, t, k;u32 bw;s32 theta =0 , rot =0 ; -struct cs32 tone_samp; +struct cordic_iq tone_samp;u32 data_buf[64 ];u16 i_samp, q_samp;struct phytbl_info tab;
@@ -2751,12 +2752,12 @@ wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz, u16 max_val, }else num_samps =2 ; - rot =FIXED ((f_kHz *36 ) / phy_bw) /100 ; + rot = ((f_kHz *36 ) / phy_bw) /100 ; theta =0 ;for (t =0 ; t < num_samps; t++) { -wlc_phy_cordic (theta, &tone_samp); + tone_samp =cordic_calc_iq (theta); theta += rot;
drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +8 -6
@@ -15,6 +15,7 @@*/ #include <linux/delay.h> +#include <linux/cordic.h> #include <brcm_hw_ids.h> #include <aiutils.h>
@@ -14214,7 +14215,8 @@ static u16 wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz,u16 max_val, u8 dac_test_mode);static void wlc_phy_loadsampletable_nphy (struct brcms_phy *pi, -struct cs32 *tone_buf,u16 num_samps); +struct cordic_iq *tone_buf, +u16 num_samps);static void wlc_phy_runsamples_nphy (struct brcms_phy *pi,u16 n,u16 lps,u16 wait,u8 iq,u8 dac_test_mode,bool modify_bbmult);
@@ -22179,7 +22181,7 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val,u16 num_samps, t, spur;s32 theta =0 , rot =0 ;u32 tbl_len; -struct cs32 *tone_buf =NULL ; +struct cordic_iq *tone_buf =NULL ; is_phybw40 =CHSPEC_IS40 (pi->radio_chanspec); phy_bw = (is_phybw40 ==1 ) ?40 :20 ;
@@ -22194,17 +22196,17 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, tbl_len = (phy_bw <<1 ); } - tone_buf =kmalloc (sizeof (struct cs32 ) * tbl_len,GFP_ATOMIC ); + tone_buf =kmalloc (sizeof (struct cordic_iq ) * tbl_len,GFP_ATOMIC );if (tone_buf ==NULL )return 0 ; num_samps = (u16 ) tbl_len; - rot =FIXED ((f_kHz *36 ) / phy_bw) /100 ; + rot = ((f_kHz *36 ) / phy_bw) /100 ; theta =0 ;for (t =0 ; t < num_samps; t++) { -wlc_phy_cordic (theta, &tone_buf[t]); + tone_buf[t] =cordic_calc_iq (theta); theta += rot;
@@ -22239,7 +22241,7 @@ wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, }static void -wlc_phy_loadsampletable_nphy (struct brcms_phy *pi,struct cs32 *tone_buf, +wlc_phy_loadsampletable_nphy (struct brcms_phy *pi,struct cordic_iq *tone_buf,u16 num_samps) {u16 t;
Signature · 1 line
1.7.4.1
PATCH 8/8 staging: brcm80211: fill in proper rx rate in mac80211 rx status
In reply to Arend van SprielThe brcmsmac driver supports different rates on 5GHz but this is not taken into account when providing the rate index in the receive status information passed to mac80211.
--- drivers/staging/brcm80211/brcmsmac/mac80211_if.c | 9 +++++++-- drivers/staging/brcm80211/brcmsmac/mac80211_if.h | 6 ++++++ drivers/staging/brcm80211/brcmsmac/main.c | 8 ++++++++ 3 files changed, 21 insertions(+), 2 deletions(-)
drivers/staging/brcm80211/brcmsmac/mac80211_if.c +7 -2
@@ -971,6 +971,10 @@ static struct ieee80211_channel brcms_5ghz_nphy_chantable[] = { .hw_value = (rate100m / 5), \ } +/* +* The rate table is used for both 2.4G and 5G rates. The +* latter being a subset as it does not support CCK rates. +*/ static struct ieee80211_rate legacy_ratetable[] = {RATE (10 ,0 ),RATE (20 ,IEEE80211_RATE_SHORT_PREAMBLE ),
@@ -1012,8 +1016,9 @@ static struct ieee80211_supported_band brcms_band_5GHz_nphy = { .band = IEEE80211_BAND_5GHZ, .channels = brcms_5ghz_nphy_chantable, .n_channels = ARRAY_SIZE(brcms_5ghz_nphy_chantable), - .bitrates = legacy_ratetable + 4, - .n_bitrates = ARRAY_SIZE(legacy_ratetable) - 4, + .bitrates = legacy_ratetable + BRCMS_LEGACY_5G_RATE_OFFSET, + .n_bitrates =ARRAY_SIZE (legacy_ratetable) - + BRCMS_LEGACY_5G_RATE_OFFSET, .ht_cap = { .cap =IEEE80211_HT_CAP_GRN_FLD |IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
drivers/staging/brcm80211/brcmsmac/mac80211_if.h +6 -0
@@ -20,6 +20,12 @@#include <linux/timer.h> #include <linux/interrupt.h> +/* +* Starting index for 5G rates in the +* legacy rate table. +*/ +#define BRCMS_LEGACY_5G_RATE_OFFSET 4 +/* softmac ioctl definitions */ #define BRCMS_SET_SHORTSLOT_OVERRIDE 146
drivers/staging/brcm80211/brcmsmac/main.c +8 -0
@@ -8252,6 +8252,14 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh,wiphy_err (wlc->wiphy,"%s: Unknown rate\n" , __func__); } +/* +* For 5GHz, we should decrease the index as it is +* a subset of the 2.4G rates. See bitrates field +* of brcms_band_5GHz_nphy (in mac80211_if.c). +*/ +if (rx_status->band ==IEEE80211_BAND_5GHZ ) + rx_status->rate_idx -=BRCMS_LEGACY_5G_RATE_OFFSET ; +/* Determine short preamble and rate_idx */ preamble =0 ;if (IS_CCK (rspec)) {
Signature · 1 line
1.7.4.1
Quoted 7 lines · Arend van Spriel
With 3.1 kernel the crc8 and cordic library modules are available in the staging tree. The brcmsmac driver now uses them. Some small fixes have been made and the driver is made to work on the Sparc platform.
This series applies to staging-next and depends on the following patch set:
Message-ID: <[email protected]>
All applied.
That's everything that you have pending, right? Anything I miss?
thanks,
greg k-h
Quoted 7 lines · Greg KH
Quoted 6 lines · Arend van Spriel
With 3.1 kernel the crc8 and cordic library modules are available in the staging tree. The brcmsmac driver now uses them. Some small fixes have been made and the driver is made to work on the Sparc platform.
This series applies to staging-next and depends on the following patch set:
Quoted 8 lines
Quoted 1 line
Message-ID:<[email protected]>
All applied.
That's everything that you have pending, right? Anything I miss?
thanks,
greg k-h
Great. It was quite a number of patches. I did a diff between your tree and our internal one. Apart from the two community patches we are in sync so no misses. Thanks.
Gr. AvS
Signature · 2 lines
Almost nobody dances sober, unless they happen to be insane. -- H.P. Lovecraft --