wlcore: improvements in SDIO error handling
cover wlcore: improvements in SDIO error handling
Hi,
This series with patches from Ido and Arik improve the driver's handling of SDIO errors. Ido's series propagates the errors up for better handling and Arik's series ensures that suspend/resume don't get messed up when such errors occur.
There is also one patch by Arkady (welcome!) that allows the userspace to read/write to the chip's memory directly for firmware debugging purposes.
Please review.
Cheers,
Luca.
Arik Nemtsov (6):
wlcore: cancel suspend when recovery is pending
wlcore: don't allow SDIO read/writes after failure
wlcore: force recovery on resume if suspended without recovering
wlcore: check Rx-filter functions in the suspend path
wlcore: refactor threaded IRQ routine
wlcore: prevent recovery in the middle of resume
Arkady Miasnikov (1):
wlcore: access the firmware memory via debugfs
Ido Yariv (11):
wlcore: Fix sdio out-of-sync power state
wlcore: Disable interrupts while recovering
wlcore: Change read/write ops to return errors
wlcore: Change raw io functions to return errors
wlcore: Propagate errors from wlcore_raw_*_data functions
wlcore: Propagate errors from wl1271_read
wlcore: Propagate errors from wl1271_write
wlcore: Propagate errors from wl1271_raw_read32
wlcore: Propagate errors from wl1271_raw_write32
wlcore: Propagate errors from wl1271_read_hwaddr
wlcore: Force checking of io functions' return values
drivers/net/wireless/ti/wl12xx/main.c | 343 +++++++++++++++++++++-------- drivers/net/wireless/ti/wl18xx/io.c | 39 +++- drivers/net/wireless/ti/wl18xx/io.h | 4 +- drivers/net/wireless/ti/wl18xx/main.c | 219 ++++++++++++------ drivers/net/wireless/ti/wlcore/boot.c | 84 +++++-- drivers/net/wireless/ti/wlcore/cmd.c | 47 +++- drivers/net/wireless/ti/wlcore/debugfs.c | 192 ++++++++++++++++ drivers/net/wireless/ti/wlcore/event.c | 15 +- drivers/net/wireless/ti/wlcore/hw_ops.h | 12 +- drivers/net/wireless/ti/wlcore/io.c | 55 +++-- drivers/net/wireless/ti/wlcore/io.h | 144 +++++++----- drivers/net/wireless/ti/wlcore/main.c | 240 +++++++++++++++----- drivers/net/wireless/ti/wlcore/ps.c | 14 +- drivers/net/wireless/ti/wlcore/rx.c | 37 +++- drivers/net/wireless/ti/wlcore/rx.h | 4 +- drivers/net/wireless/ti/wlcore/sdio.c | 50 +++-- drivers/net/wireless/ti/wlcore/spi.c | 14 +- drivers/net/wireless/ti/wlcore/tx.c | 61 +++-- drivers/net/wireless/ti/wlcore/tx.h | 4 +- drivers/net/wireless/ti/wlcore/wlcore.h | 14 +- drivers/net/wireless/ti/wlcore/wlcore_i.h | 9 +- 21 files changed, 1196 insertions(+), 405 deletions(-)
Signature · 1 line
1.7.10
PATCH 1/18 wlcore: Fix sdio out-of-sync power state
From: Ido Yariv <[email protected]>
wl12xx_sdio_power_off() manually powers down the card regardless of the runtime pm state. If wl12xx_sdio_power_on() is called before the card was suspended by runtime PM, it will not power up the card.
As part of the HW detection, the chip's power is toggled. Since this happens in the context of probing sdio, the power reference counter will be higher than zero. As a result, when wl12xx_sdio_power_off() is called, the chip will be powered down while still having a positive power reference counter. If the interface is quickly activated, the driver might try to transfer data to a powered off chip.
Fix this by ensuring that wl12xx_sdio_power_on() explicitly powers on the chip in case runtime pm claims the chip is already powered on. To avoid cases in which it is not possible to determine if the chip was really powered on (card's power reference counter is positive), operate on the mmc_card instead of the function.
Also verify that the chip is indeed powered on before powering off, to avoid wrong reference counter values in error cases.
--- drivers/net/wireless/ti/wlcore/io.h | 10 ++++++++-- drivers/net/wireless/ti/wlcore/sdio.c | 34 ++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 17 deletions(-)
drivers/net/wireless/ti/wlcore/io.h +8 -2
@@ -160,8 +160,14 @@ static inline void wlcore_write_reg(struct wl1271 *wl, int reg, u32 val)static inline void wl1271_power_off (struct wl1271 *wl) { - wl->if_ops->power (wl->dev, false); -clear_bit (WL1271_FLAG_GPIO_POWER , &wl->flags); +int ret; + +if (!test_bit (WL1271_FLAG_GPIO_POWER , &wl->flags)) +return ; + + ret = wl->if_ops->power (wl->dev, false); +if (!ret) +clear_bit (WL1271_FLAG_GPIO_POWER , &wl->flags); }static inline int wl1271_power_on (struct wl1271 *wl)
drivers/net/wireless/ti/wlcore/sdio.c +19 -15
@@ -147,17 +147,20 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) {int ret;struct sdio_func *func =dev_to_sdio_func (glue->dev); +struct mmc_card *card = func->card; -/* If enabled, tell runtime PM not to power off the card */ -if (pm_runtime_enabled (&func->dev)) { - ret =pm_runtime_get_sync (&func->dev); -if (ret <0 ) - goto out; - }else { -/* Runtime PM is disabled: power up the card manually */ - ret =mmc_power_restore_host (func->card->host); -if (ret <0 ) + ret =pm_runtime_get_sync (&card->dev); +if (ret) { +/* +* Runtime PM might be temporarily disabled, or the device +* might have a positive reference counter. Make sure it is +* really powered on. +*/ + ret =mmc_power_restore_host (card->host); +if (ret <0 ) { +pm_runtime_put_sync (&card->dev); goto out; + } }sdio_claim_host (func);
@@ -172,20 +175,21 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) {int ret;struct sdio_func *func =dev_to_sdio_func (glue->dev); +struct mmc_card *card = func->card;sdio_claim_host (func);sdio_disable_func (func);sdio_release_host (func); -/* Power off the card manually, even if runtime PM is enabled. */ - ret =mmc_power_save_host (func->card->host); +/* Power off the card manually in case it wasn't powered off above */ + ret =mmc_power_save_host (card->host);if (ret <0 ) -return ret; + goto out; -/* If enabled, let runtime PM know the card is powered off */ -if (pm_runtime_enabled (&func->dev)) - ret =pm_runtime_put_sync (&func->dev); +/* Let runtime PM know the card is powered off */ +pm_runtime_put_sync (&card->dev); +out:return ret; }
Signature · 1 line
1.7.10
PATCH 2/18 wlcore: Disable interrupts while recovering
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
In case a recovery is initiated, the FW can no longer be trusted, and the driver should not handle any new FW events.
Disable the interrupt handler when a recovery is scheduled and balance it back in the op_stop callback.
--- drivers/net/wireless/ti/wlcore/io.c | 6 ++++++ drivers/net/wireless/ti/wlcore/io.h | 1 + drivers/net/wireless/ti/wlcore/main.c | 21 +++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-)
drivers/net/wireless/ti/wlcore/io.c +6 -0
@@ -48,6 +48,12 @@ void wlcore_disable_interrupts(struct wl1271 *wl) }EXPORT_SYMBOL_GPL (wlcore_disable_interrupts); +void wlcore_disable_interrupts_nosync (struct wl1271 *wl) +{ +disable_irq_nosync (wl->irq); +} +EXPORT_SYMBOL_GPL (wlcore_disable_interrupts_nosync); +void wlcore_enable_interrupts (struct wl1271 *wl) {enable_irq (wl->irq);
drivers/net/wireless/ti/wlcore/io.h +1 -0
@@ -45,6 +45,7 @@struct wl1271 ;void wlcore_disable_interrupts (struct wl1271 *wl); +void wlcore_disable_interrupts_nosync (struct wl1271 *wl);void wlcore_enable_interrupts (struct wl1271 *wl);void wl1271_io_reset (struct wl1271 *wl);
drivers/net/wireless/ti/wlcore/main.c +15 -6
@@ -743,8 +743,11 @@ out:void wl12xx_queue_recovery_work (struct wl1271 *wl) { -if (!test_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , &wl->flags)) +/* Avoid a recursive recovery */ +if (!test_and_set_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , &wl->flags)) { +wlcore_disable_interrupts_nosync (wl);ieee80211_queue_work (wl->hw, &wl->recovery_work); + } }size_t wl12xx_copy_fwlog (struct wl1271 *wl,u8 *memblock,size_t maxlen)
@@ -848,9 +851,6 @@ static void wl1271_recovery_work(struct work_struct *work)if (wl->state !=WL1271_STATE_ON || wl->plt) goto out_unlock; -/* Avoid a recursive recovery */ -set_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , &wl->flags); -wl12xx_read_fwlog_panic (wl);/* change partitions momentarily so we can read the FW pc */
@@ -902,8 +902,6 @@ static void wl1271_recovery_work(struct work_struct *work)mutex_unlock (&wl->mutex);wl1271_op_stop (wl->hw); -clear_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , &wl->flags); -ieee80211_restart_hw (wl->hw);/*
@@ -1706,6 +1704,10 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)wlcore_disable_interrupts (wl);mutex_lock (&wl->mutex);if (wl->state ==WL1271_STATE_OFF ) { +if (test_and_clear_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , + &wl->flags)) +wlcore_enable_interrupts (wl); +mutex_unlock (&wl->mutex);/*
@@ -1737,6 +1739,13 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)mutex_lock (&wl->mutex);wl1271_power_off (wl); +/* +* In case a recovery was scheduled, interrupts were disabled to avoid +* an interrupt storm. Now that the power is down, it is safe to +* re-enable interrupts to balance the disable depth +*/ +if (test_and_clear_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , &wl->flags)) +wlcore_enable_interrupts (wl); wl->band =IEEE80211_BAND_2GHZ ;
Signature · 1 line
1.7.10
PATCH 3/18 wlcore: Change read/write ops to return errors
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
While bus operations may fail, either due to HW or FW issues, these are never propagated to higher layers. As a result, the core driver has no way of knowing that the operations failed, and will only recover if high level logic requires it (e.g. no command completion).
Change read/write bus operations to return errors to let higher layer functionality handle these.
--- drivers/net/wireless/ti/wlcore/sdio.c | 16 ++++++++++------ drivers/net/wireless/ti/wlcore/spi.c | 14 +++++++++----- drivers/net/wireless/ti/wlcore/wlcore_i.h | 6 +++--- 3 files changed, 22 insertions(+), 14 deletions(-)
drivers/net/wireless/ti/wlcore/sdio.c +10 -6
@@ -71,8 +71,8 @@ static void wl1271_sdio_set_block_size(struct device *child,sdio_release_host (func); } -static void wl12xx_sdio_raw_read (struct device *child,int addr,void *buf, -size_t len,bool fixed) +static int wl12xx_sdio_raw_read (struct device *child,int addr,void *buf, +size_t len,bool fixed) {int ret;struct wl12xx_sdio_glue *glue =dev_get_drvdata (child->parent);
@@ -103,12 +103,14 @@ static void wl12xx_sdio_raw_read(struct device *child, int addr, void *buf,sdio_release_host (func); -if (ret) +if (WARN_ON (ret))dev_err (child->parent,"sdio read failed (%d)\n" , ret); + +return ret; } -static void wl12xx_sdio_raw_write (struct device *child,int addr,void *buf, -size_t len,bool fixed) +static int wl12xx_sdio_raw_write (struct device *child,int addr,void *buf, +size_t len,bool fixed) {int ret;struct wl12xx_sdio_glue *glue =dev_get_drvdata (child->parent);
@@ -139,8 +141,10 @@ static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf,sdio_release_host (func); -if (ret) +if (WARN_ON (ret))dev_err (child->parent,"sdio write failed (%d)\n" , ret); + +return ret; }static int wl12xx_sdio_power_on (struct wl12xx_sdio_glue *glue)
drivers/net/wireless/ti/wlcore/spi.c +9 -5
@@ -193,8 +193,8 @@ static int wl12xx_spi_read_busy(struct device *child)return -ETIMEDOUT ; } -static void wl12xx_spi_raw_read (struct device *child,int addr,void *buf, -size_t len,bool fixed) +static int wl12xx_spi_raw_read (struct device *child,int addr,void *buf, +size_t len,bool fixed) {struct wl12xx_spi_glue *glue =dev_get_drvdata (child->parent);struct wl1271 *wl =dev_get_drvdata (child);
@@ -238,7 +238,7 @@ static void wl12xx_spi_raw_read(struct device *child, int addr, void *buf,if (!(busy_buf[WL1271_BUSY_WORD_CNT -1 ] &0x1 ) &&wl12xx_spi_read_busy (child)) {memset (buf,0 , chunk_len); -return ; +return 0 ; }spi_message_init (&m);
@@ -256,10 +256,12 @@ static void wl12xx_spi_raw_read(struct device *child, int addr, void *buf, buf += chunk_len; len -= chunk_len; } + +return 0 ; } -static void wl12xx_spi_raw_write (struct device *child,int addr,void *buf, -size_t len,bool fixed) +static int wl12xx_spi_raw_write (struct device *child,int addr,void *buf, +size_t len,bool fixed) {struct wl12xx_spi_glue *glue =dev_get_drvdata (child->parent);struct spi_transfer t[2 *WSPI_MAX_NUM_OF_CHUNKS ];
@@ -304,6 +306,8 @@ static void wl12xx_spi_raw_write(struct device *child, int addr, void *buf, }spi_sync (to_spi_device (glue->dev), &m); + +return 0 ; }static struct wl1271_if_operations spi_ops = {
drivers/net/wireless/ti/wlcore/wlcore_i.h +3 -3
@@ -209,9 +209,9 @@ struct wl1271_scan { };struct wl1271_if_operations { -void (*read)(struct device *child,int addr,void *buf,size_t len, -bool fixed); -void (*write)(struct device *child,int addr,void *buf,size_t len, +int (*read)(struct device *child,int addr,void *buf,size_t len, +bool fixed); +int (*write)(struct device *child,int addr,void *buf,size_t len,bool fixed);void (*reset)(struct device *child);void (*init)(struct device *child);
Signature · 1 line
1.7.10
PATCH 4/18 wlcore: Change raw io functions to return errors
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
Make wl1271_raw_write and wl1271_raw_read return errors so the driver could handle these appropriately.
Since the prototype has changed, also rename the prefix of these functions to wlcore.
--- drivers/net/wireless/ti/wlcore/io.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/wireless/ti/wlcore/io.h +13 -13
@@ -53,33 +53,33 @@ void wl1271_io_init(struct wl1271 *wl);int wlcore_translate_addr (struct wl1271 *wl,int addr);/* Raw target IO, address is not translated */ -static inline void wl1271_raw_write (struct wl1271 *wl,int addr,void *buf, -size_t len,bool fixed) +static inline int wlcore_raw_write (struct wl1271 *wl,int addr,void *buf, +size_t len,bool fixed) { - wl->if_ops->write (wl->dev, addr, buf, len, fixed); +return wl->if_ops->write (wl->dev, addr, buf, len, fixed); } -static inline void wl1271_raw_read (struct wl1271 *wl,int addr,void *buf, -size_t len,bool fixed) +static inline int wlcore_raw_read (struct wl1271 *wl,int addr,void *buf, +size_t len,bool fixed) { - wl->if_ops->read (wl->dev, addr, buf, len, fixed); +return wl->if_ops->read (wl->dev, addr, buf, len, fixed); }static inline void wlcore_raw_read_data (struct wl1271 *wl,int reg,void *buf,size_t len,bool fixed) { -wl1271_raw_read (wl, wl->rtable[reg], buf, len, fixed); +wlcore_raw_read (wl, wl->rtable[reg], buf, len, fixed); }static inline void wlcore_raw_write_data (struct wl1271 *wl,int reg,void *buf,size_t len,bool fixed) { -wl1271_raw_write (wl, wl->rtable[reg], buf, len, fixed); +wlcore_raw_write (wl, wl->rtable[reg], buf, len, fixed); }static inline u32 wl1271_raw_read32 (struct wl1271 *wl,int addr) { -wl1271_raw_read (wl, addr, &wl->buffer_32, +wlcore_raw_read (wl, addr, &wl->buffer_32,sizeof (wl->buffer_32), false);return le32_to_cpu (wl->buffer_32);
@@ -88,7 +88,7 @@ static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr)static inline void wl1271_raw_write32 (struct wl1271 *wl,int addr,u32 val) { wl->buffer_32 =cpu_to_le32 (val); -wl1271_raw_write (wl, addr, &wl->buffer_32, +wlcore_raw_write (wl, addr, &wl->buffer_32,sizeof (wl->buffer_32), false); }
@@ -99,7 +99,7 @@ static inline void wl1271_read(struct wl1271 *wl, int addr, void *buf, physical =wlcore_translate_addr (wl, addr); -wl1271_raw_read (wl, physical, buf, len, fixed); +wlcore_raw_read (wl, physical, buf, len, fixed); } static inline void wl1271_write(struct wl1271 *wl, int addr, void *buf,
@@ -109,7 +109,7 @@ static inline void wl1271_write(struct wl1271 *wl, int addr, void *buf, physical =wlcore_translate_addr (wl, addr); -wl1271_raw_write (wl, physical, buf, len, fixed); +wlcore_raw_write (wl, physical, buf, len, fixed); } static inline void wlcore_write_data(struct wl1271 *wl, int reg, void *buf,
@@ -135,7 +135,7 @@ static inline void wl1271_read_hwaddr(struct wl1271 *wl, int hwaddr, physical =wlcore_translate_addr (wl, addr); -wl1271_raw_read (wl, physical, buf, len, fixed); +wlcore_raw_read (wl, physical, buf, len, fixed); }static inline u32 wl1271_read32 (struct wl1271 *wl,int addr)
Signature · 1 line
1.7.10
PATCH 5/18 wlcore: Propagate errors from wlcore_raw_*_data functions
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
wlcore_raw_read_data is called when the FW status is read which happens while handling interrupts and when the FW log is read following a recovery. Request a recovery in the former case, and don't read the FW log in case the FW status read failed.
--- drivers/net/wireless/ti/wlcore/io.h | 12 ++++++------ drivers/net/wireless/ti/wlcore/main.c | 27 ++++++++++++++++++++------- 2 files changed, 26 insertions(+), 13 deletions(-)
drivers/net/wireless/ti/wlcore/io.h +6 -6
@@ -65,16 +65,16 @@ static inline int wlcore_raw_read(struct wl1271 *wl, int addr, void *buf,return wl->if_ops->read (wl->dev, addr, buf, len, fixed); } -static inline void wlcore_raw_read_data (struct wl1271 *wl,int reg,void *buf, -size_t len,bool fixed) +static inline int wlcore_raw_read_data (struct wl1271 *wl,int reg,void *buf, +size_t len,bool fixed) { -wlcore_raw_read (wl, wl->rtable[reg], buf, len, fixed); +return wlcore_raw_read (wl, wl->rtable[reg], buf, len, fixed); } -static inline void wlcore_raw_write_data (struct wl1271 *wl,int reg,void *buf, -size_t len,bool fixed) +static inline int wlcore_raw_write_data (struct wl1271 *wl,int reg,void *buf, +size_t len,bool fixed) { -wlcore_raw_write (wl, wl->rtable[reg], buf, len, fixed); +return wlcore_raw_write (wl, wl->rtable[reg], buf, len, fixed); }static inline u32 wl1271_raw_read32 (struct wl1271 *wl,int addr)
drivers/net/wireless/ti/wlcore/main.c +20 -7
@@ -378,9 +378,9 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, } } -static void wl12xx_fw_status (struct wl1271 *wl, -struct wl_fw_status_1 *status_1, -struct wl_fw_status_2 *status_2) +static int wlcore_fw_status (struct wl1271 *wl, +struct wl_fw_status_1 *status_1, +struct wl_fw_status_2 *status_2) {struct wl12xx_vif *wlvif;struct timespec ts;
@@ -388,12 +388,15 @@ static void wl12xx_fw_status(struct wl1271 *wl,int avail, freed_blocks;int i;size_t status_len; +int ret; status_len =WLCORE_FW_STATUS_1_LEN (wl->num_rx_desc) +sizeof (*status_2) + wl->fw_status_priv_len; -wlcore_raw_read_data (wl,REG_RAW_FW_STATUS_ADDR , status_1, - status_len, false); + ret =wlcore_raw_read_data (wl,REG_RAW_FW_STATUS_ADDR , status_1, + status_len, false); +if (ret <0 ) +return ret; wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, " "drv_rx_counter = %d, tx_results_counter = %d)",
@@ -462,6 +465,8 @@ static void wl12xx_fw_status(struct wl1271 *wl,getnstimeofday (&ts); wl->time_offset = (timespec_to_ns (&ts) >>10 ) - (s64 )le32_to_cpu (status_2->fw_localtime); + +return 0 ; }static void wl1271_flush_deferred_work (struct wl1271 *wl)
@@ -530,7 +535,11 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)clear_bit (WL1271_FLAG_IRQ_RUNNING , &wl->flags);smp_mb__after_clear_bit (); -wl12xx_fw_status (wl, wl->fw_status_1, wl->fw_status_2); + ret =wlcore_fw_status (wl, wl->fw_status_1, wl->fw_status_2); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto out; + }wlcore_hw_tx_immediate_compl (wl);
@@ -781,6 +790,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)u32 offset;u32 end_of_log;u8 *block; +int ret;if ((wl->quirks &WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED ) || (wl->conf.fwlog.mem_blocks ==0 ))
@@ -802,7 +812,10 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)wl12xx_cmd_stop_fwlog (wl);/* Read the first memory block address */ -wl12xx_fw_status (wl, wl->fw_status_1, wl->fw_status_2); + ret =wlcore_fw_status (wl, wl->fw_status_1, wl->fw_status_2); +if (ret <0 ) + goto out; + addr =le32_to_cpu (wl->fw_status_2->log_start_addr);if (!addr) goto out;
Signature · 1 line
1.7.10
PATCH 6/18 wlcore: Propagate errors from wl1271_read
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
Propagate errors from wl1271_read and request for recovery when appropriate.
Also rename prefixes of wlcore functions which their prototypes had to be changed.
--- drivers/net/wireless/ti/wl12xx/main.c | 6 +++--- drivers/net/wireless/ti/wlcore/boot.c | 4 +++- drivers/net/wireless/ti/wlcore/cmd.c | 20 +++++++++++++++----- drivers/net/wireless/ti/wlcore/event.c | 6 ++++-- drivers/net/wireless/ti/wlcore/hw_ops.h | 6 ++++-- drivers/net/wireless/ti/wlcore/io.h | 10 +++++----- drivers/net/wireless/ti/wlcore/main.c | 24 ++++++++++++++++++++---- drivers/net/wireless/ti/wlcore/rx.c | 13 ++++++++++--- drivers/net/wireless/ti/wlcore/rx.h | 2 +- drivers/net/wireless/ti/wlcore/tx.c | 15 +++++++++++---- drivers/net/wireless/ti/wlcore/tx.h | 2 +- drivers/net/wireless/ti/wlcore/wlcore.h | 2 +- 12 files changed, 78 insertions(+), 32 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +3 -3
@@ -1162,13 +1162,13 @@ static u32 wl12xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data,return data_len -sizeof (*desc) - desc->pad_len; } -static void wl12xx_tx_delayed_compl (struct wl1271 *wl) +static int wl12xx_tx_delayed_compl (struct wl1271 *wl) {if (wl->fw_status_1->tx_results_counter == (wl->tx_results_count &0xff )) -return ; +return 0 ; -wl1271_tx_complete (wl); +return wlcore_tx_complete (wl); }static int wl12xx_hw_init (struct wl1271 *wl)
drivers/net/wireless/ti/wlcore/boot.c +3 -1
@@ -87,7 +87,9 @@ static int wlcore_boot_static_data(struct wl1271 *wl) goto out; } -wl1271_read (wl, wl->cmd_box_addr, static_data, len, false); + ret =wlcore_read (wl, wl->cmd_box_addr, static_data, len, false); +if (ret <0 ) + goto out_free; ret =wlcore_boot_parse_fw_ver (wl, static_data);if (ret <0 )
drivers/net/wireless/ti/wlcore/cmd.c +15 -5
@@ -95,7 +95,10 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,/* read back the status code of the command */ if (res_len ==0 ) res_len =sizeof (struct wl1271_cmd_header ); -wl1271_read (wl, wl->cmd_box_addr, cmd, res_len, false); + + ret =wlcore_read (wl, wl->cmd_box_addr, cmd, res_len, false); +if (ret <0 ) + goto fail; status =le16_to_cpu (cmd->status);if (status !=CMD_STATUS_SUCCESS ) {
@@ -141,11 +144,18 @@ static int wl1271_cmd_wait_for_event_or_timeout(struct wl1271 *wl, u32 mask)msleep (1 );/* read from both event fields */ -wl1271_read (wl, wl->mbox_ptr[0 ], events_vector, -sizeof (*events_vector), false); + ret =wlcore_read (wl, wl->mbox_ptr[0 ], events_vector, +sizeof (*events_vector), false); +if (ret <0 ) + goto out; + event = *events_vector & mask; -wl1271_read (wl, wl->mbox_ptr[1 ], events_vector, -sizeof (*events_vector), false); + + ret =wlcore_read (wl, wl->mbox_ptr[1 ], events_vector, +sizeof (*events_vector), false); +if (ret <0 ) + goto out; + event |= *events_vector & mask; }while (!event);
drivers/net/wireless/ti/wlcore/event.c +4 -2
@@ -301,8 +301,10 @@ int wl1271_event_handle(struct wl1271 *wl, u8 mbox_num)return -EINVAL ;/* first we read the mbox descriptor */ -wl1271_read (wl, wl->mbox_ptr[mbox_num], wl->mbox, -sizeof (*wl->mbox), false); + ret =wlcore_read (wl, wl->mbox_ptr[mbox_num], wl->mbox, +sizeof (*wl->mbox), false); +if (ret <0 ) +return ret;/* process the descriptor */ ret =wl1271_event_process (wl);
drivers/net/wireless/ti/wlcore/hw_ops.h +4 -2
@@ -81,10 +81,12 @@ wlcore_hw_get_rx_packet_len(struct wl1271 *wl, void *rx_data, u32 data_len)return wl->ops->get_rx_packet_len (wl, rx_data, data_len); } -static inline void wlcore_hw_tx_delayed_compl (struct wl1271 *wl) +static inline int wlcore_hw_tx_delayed_compl (struct wl1271 *wl) {if (wl->ops->tx_delayed_compl) - wl->ops->tx_delayed_compl (wl); +return wl->ops->tx_delayed_compl (wl); + +return 0 ; }static inline void wlcore_hw_tx_immediate_compl (struct wl1271 *wl)
drivers/net/wireless/ti/wlcore/io.h +5 -5
@@ -92,14 +92,14 @@ static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val) sizeof(wl->buffer_32), false); } -static inline void wl1271_read (struct wl1271 *wl,int addr,void *buf, -size_t len,bool fixed) +static inline int wlcore_read (struct wl1271 *wl,int addr,void *buf, +size_t len,bool fixed) {int physical; physical =wlcore_translate_addr (wl, addr); -wlcore_raw_read (wl, physical, buf, len, fixed); +return wlcore_raw_read (wl, physical, buf, len, fixed); } static inline void wl1271_write(struct wl1271 *wl, int addr, void *buf,
@@ -118,10 +118,10 @@ static inline void wlcore_write_data(struct wl1271 *wl, int reg, void *buf,wl1271_write (wl, wl->rtable[reg], buf, len, fixed); } -static inline void wlcore_read_data (struct wl1271 *wl,int reg,void *buf, +static inline int wlcore_read_data (struct wl1271 *wl,int reg,void *buf,size_t len,bool fixed) { -wl1271_read (wl, wl->rtable[reg], buf, len, fixed); +return wlcore_read (wl, wl->rtable[reg], buf, len, fixed); } static inline void wl1271_read_hwaddr(struct wl1271 *wl, int hwaddr,
drivers/net/wireless/ti/wlcore/main.c +20 -4
@@ -572,7 +572,11 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)if (likely (intr &WL1271_ACX_INTR_DATA )) {wl1271_debug (DEBUG_IRQ ,"WL1271_ACX_INTR_DATA" ); -wl12xx_rx (wl, wl->fw_status_1); + ret =wlcore_rx (wl, wl->fw_status_1); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto out; + }/* Check if any tx blocks were freed */ spin_lock_irqsave (&wl->wl_lock, flags);
@@ -589,7 +593,11 @@ static irqreturn_t wl1271_irq(int irq, void *cookie) }/* check for tx results */ -wlcore_hw_tx_delayed_compl (wl); + ret =wlcore_hw_tx_delayed_compl (wl); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto out; + }/* Make sure the deferred queues don't get too long */ defer_count = skb_queue_len(&wl->deferred_tx_queue) +
@@ -600,12 +608,20 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)if (intr &WL1271_ACX_INTR_EVENT_A ) {wl1271_debug (DEBUG_IRQ ,"WL1271_ACX_INTR_EVENT_A" ); -wl1271_event_handle (wl,0 ); + ret =wl1271_event_handle (wl,0 ); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto out; + } }if (intr &WL1271_ACX_INTR_EVENT_B ) {wl1271_debug (DEBUG_IRQ ,"WL1271_ACX_INTR_EVENT_B" ); -wl1271_event_handle (wl,1 ); + ret =wl1271_event_handle (wl,1 ); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto out; + } }if (intr &WL1271_ACX_INTR_INIT_COMPLETE )
drivers/net/wireless/ti/wlcore/rx.c +10 -3
@@ -200,7 +200,7 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length,return is_data; } -void wl12xx_rx (struct wl1271 *wl,struct wl_fw_status_1 *status) +int wlcore_rx (struct wl1271 *wl,struct wl_fw_status_1 *status) {unsigned long active_hlids[BITS_TO_LONGS (WL12XX_MAX_LINKS )] = {0 };u32 buf_size;
@@ -211,6 +211,7 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status)u32 pkt_offset, des;u8 hlid;enum wl_rx_buf_align rx_align; +int ret =0 ;while (drv_rx_counter != fw_rx_counter) { buf_size =0 ;
@@ -235,8 +236,11 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status)/* Read all available packets at once */ des =le32_to_cpu (status->rx_pkt_descs[drv_rx_counter]);wlcore_hw_prepare_read (wl, des, buf_size); -wlcore_read_data (wl,REG_SLV_MEM_DATA , wl->aggr_buf, - buf_size, true); + + ret =wlcore_read_data (wl,REG_SLV_MEM_DATA , wl->aggr_buf, + buf_size, true); +if (ret <0 ) + goto out;/* Split data into separate packets */ pkt_offset =0 ;
@@ -278,6 +282,9 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status) wl->rx_counter);wl12xx_rearm_rx_streaming (wl, active_hlids); + +out: +return ret; }#ifdef CONFIG_PM
drivers/net/wireless/ti/wlcore/rx.h +1 -1
@@ -143,7 +143,7 @@ struct wl1271_rx_descriptor {u8 reserved; } __packed; -void wl12xx_rx (struct wl1271 *wl,struct wl_fw_status_1 *status); +int wlcore_rx (struct wl1271 *wl,struct wl_fw_status_1 *status);u8 wl1271_rate_to_idx (int rate,enum ieee80211_band band); int wl1271_rx_filter_enable(struct wl1271 *wl, int index, bool enable,
drivers/net/wireless/ti/wlcore/tx.c +11 -4
@@ -881,16 +881,20 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, }/* Called upon reception of a TX complete interrupt */ -void wl1271_tx_complete (struct wl1271 *wl) +int wlcore_tx_complete (struct wl1271 *wl) {struct wl1271_acx_mem_map *memmap = (struct wl1271_acx_mem_map *)wl->target_mem_map;u32 count, fw_counter;u32 i; +int ret;/* read the tx results from the chipset */ -wl1271_read (wl,le32_to_cpu (memmap->tx_result), - wl->tx_res_if,sizeof (*wl->tx_res_if), false); + ret =wlcore_read (wl,le32_to_cpu (memmap->tx_result), + wl->tx_res_if,sizeof (*wl->tx_res_if), false); +if (ret <0 ) + goto out; + fw_counter =le32_to_cpu (wl->tx_res_if->tx_result_fw_counter);/* write host counter to chipset (to ack) */
@@ -916,8 +920,11 @@ void wl1271_tx_complete(struct wl1271 *wl) wl->tx_results_count++; } + +out: +return ret; } -EXPORT_SYMBOL (wl1271_tx_complete); +EXPORT_SYMBOL (wlcore_tx_complete);void wl1271_tx_reset_link_queues (struct wl1271 *wl,u8 hlid) {
drivers/net/wireless/ti/wlcore/tx.h +1 -1
@@ -235,7 +235,7 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl)void wl1271_tx_work (struct work_struct *work);void wl1271_tx_work_locked (struct wl1271 *wl); -void wl1271_tx_complete (struct wl1271 *wl); +int wlcore_tx_complete (struct wl1271 *wl);void wl12xx_tx_reset_wlvif (struct wl1271 *wl,struct wl12xx_vif *wlvif);void wl12xx_tx_reset (struct wl1271 *wl);void wl1271_tx_flush (struct wl1271 *wl);
drivers/net/wireless/ti/wlcore/wlcore.h +1 -1
@@ -56,7 +56,7 @@ struct wlcore_ops {void (*prepare_read)(struct wl1271 *wl,u32 rx_desc,u32 len);u32 (*get_rx_packet_len)(struct wl1271 *wl,void *rx_data,u32 data_len); -void (*tx_delayed_compl)(struct wl1271 *wl); +int (*tx_delayed_compl)(struct wl1271 *wl);void (*tx_immediate_compl)(struct wl1271 *wl);int (*hw_init)(struct wl1271 *wl);int (*init_vif)(struct wl1271 *wl,struct wl12xx_vif *wlvif);
Signature · 1 line
1.7.10
PATCH 7/18 wlcore: Propagate errors from wl1271_write
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
Propagate errors from wl1271_write and request for recovery when appropriate.
Also rename prefixes of wlcore functions which their prototypes had to be changed.
--- drivers/net/wireless/ti/wl12xx/main.c | 23 ++++++++++++++++++----- drivers/net/wireless/ti/wl18xx/main.c | 19 ++++++++++++------- drivers/net/wireless/ti/wlcore/boot.c | 17 +++++++++++------ drivers/net/wireless/ti/wlcore/cmd.c | 12 +++++++++--- drivers/net/wireless/ti/wlcore/event.c | 5 ++++- drivers/net/wireless/ti/wlcore/hw_ops.h | 6 ++++-- drivers/net/wireless/ti/wlcore/io.h | 12 ++++++------ drivers/net/wireless/ti/wlcore/main.c | 13 ++++++++++--- drivers/net/wireless/ti/wlcore/rx.c | 4 +++- drivers/net/wireless/ti/wlcore/tx.c | 29 +++++++++++++++++++++-------- drivers/net/wireless/ti/wlcore/tx.h | 2 +- drivers/net/wireless/ti/wlcore/wlcore.h | 6 +++--- 12 files changed, 102 insertions(+), 46 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +18 -5
@@ -598,8 +598,10 @@ static const int wl12xx_rtable[REG_TABLE_LEN] = {#define WL128X_FW_NAME_SINGLE "ti-connectivity/wl128x-fw-4-sr.bin"#define WL128X_PLT_FW_NAME "ti-connectivity/wl128x-fw-4-plt.bin" -static void wl127x_prepare_read (struct wl1271 *wl,u32 rx_desc,u32 len) +static int wl127x_prepare_read (struct wl1271 *wl,u32 rx_desc,u32 len) { +int ret; +if (wl->chip.id !=CHIP_ID_1283_PG20 ) {struct wl1271_acx_mem_map *wl_mem_map = wl->target_mem_map;struct wl127x_rx_mem_pool_addr rx_mem_addr;
@@ -616,9 +618,13 @@ static void wl127x_prepare_read(struct wl1271 *wl, u32 rx_desc, u32 len) rx_mem_addr.addr_extra = rx_mem_addr.addr +4 ; -wl1271_write (wl,WL1271_SLV_REG_DATA , - &rx_mem_addr,sizeof (rx_mem_addr), false); + ret =wlcore_write (wl,WL1271_SLV_REG_DATA , &rx_mem_addr, +sizeof (rx_mem_addr), false); +if (ret <0 ) +return ret; } + +return 0 ; }static int wl12xx_identify_chip (struct wl1271 *wl)
@@ -1073,11 +1079,18 @@ out:return ret; } -static void wl12xx_trigger_cmd (struct wl1271 *wl,int cmd_box_addr, +static int wl12xx_trigger_cmd (struct wl1271 *wl,int cmd_box_addr,void *buf,size_t len) { -wl1271_write (wl, cmd_box_addr, buf, len, false); +int ret; + + ret =wlcore_write (wl, cmd_box_addr, buf, len, false); +if (ret <0 ) +return ret; +wlcore_write_reg (wl,REG_INTERRUPT_TRIG ,WL12XX_INTR_TRIG_CMD ); + +return ret; }static void wl12xx_ack_event (struct wl1271 *wl)
drivers/net/wireless/ti/wl18xx/main.c +12 -7
@@ -720,10 +720,11 @@ static void wl18xx_pre_upload(struct wl1271 *wl) tmp =wl1271_read32 (wl,WL18XX_SCR_PAD2 ); } -static void wl18xx_set_mac_and_phy (struct wl1271 *wl) +static int wl18xx_set_mac_and_phy (struct wl1271 *wl) {struct wl18xx_priv *priv = wl->priv;size_t len; +int ret;/* the parameters struct is smaller for PG1 */ if (wl->chip.id == CHIP_ID_185x_PG10)
@@ -732,8 +733,10 @@ static void wl18xx_set_mac_and_phy(struct wl1271 *wl) len =sizeof (struct wl18xx_mac_and_phy_params );wlcore_set_partition (wl, &wl->ptable[PART_PHY_INIT ]); -wl1271_write (wl,WL18XX_PHY_INIT_MEM_ADDR , (u8 *)&priv->conf.phy, len, - false); + ret =wlcore_write (wl,WL18XX_PHY_INIT_MEM_ADDR , (u8 *)&priv->conf.phy, + len, false); + +return ret; }static void wl18xx_enable_interrupts (struct wl1271 *wl)
@@ -769,7 +772,9 @@ static int wl18xx_boot(struct wl1271 *wl)if (ret <0 ) goto out; -wl18xx_set_mac_and_phy (wl); + ret =wl18xx_set_mac_and_phy (wl); +if (ret <0 ) + goto out; ret =wlcore_boot_run_firmware (wl);if (ret <0 )
@@ -781,7 +786,7 @@ out:return ret; } -static void wl18xx_trigger_cmd (struct wl1271 *wl,int cmd_box_addr, +static int wl18xx_trigger_cmd (struct wl1271 *wl,int cmd_box_addr,void *buf,size_t len) {struct wl18xx_priv *priv = wl->priv;
@@ -789,8 +794,8 @@ static void wl18xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr,memcpy (priv->cmd_buf, buf, len);memset (priv->cmd_buf + len,0 ,WL18XX_CMD_MAX_SIZE - len); -wl1271_write (wl, cmd_box_addr, priv->cmd_buf,WL18XX_CMD_MAX_SIZE , - false); +return wlcore_write (wl, cmd_box_addr, priv->cmd_buf, +WL18XX_CMD_MAX_SIZE , false); }static void wl18xx_ack_event (struct wl1271 *wl)
drivers/net/wireless/ti/wlcore/boot.c +11 -6
@@ -111,6 +111,7 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,struct wlcore_partition_set partition;int addr, chunk_num, partition_limit;u8 *p, *chunk; +int ret;/* whal_FwCtrl_LoadFwImageSm() */
@@ -155,7 +156,9 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,memcpy (chunk, p,CHUNK_SIZE );wl1271_debug (DEBUG_BOOT ,"uploading fw chunk 0x%p to 0x%x" , p, addr); -wl1271_write (wl, addr, chunk,CHUNK_SIZE , false); + ret =wlcore_write (wl, addr, chunk,CHUNK_SIZE , false); +if (ret <0 ) + goto out; chunk_num++; }
@@ -166,10 +169,11 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,memcpy (chunk, p, fw_data_len %CHUNK_SIZE );wl1271_debug (DEBUG_BOOT ,"uploading fw last chunk (%zd B) 0x%p to 0x%x" , fw_data_len %CHUNK_SIZE , p, addr); -wl1271_write (wl, addr, chunk, fw_data_len %CHUNK_SIZE , false); + ret =wlcore_write (wl, addr, chunk, fw_data_len %CHUNK_SIZE , false); +out:kfree (chunk); -return 0 ; +return ret; }int wlcore_boot_upload_firmware (struct wl1271 *wl)
@@ -212,6 +216,7 @@ int wlcore_boot_upload_nvs(struct wl1271 *wl)int i;u32 dest_addr, val;u8 *nvs_ptr, *nvs_aligned; +int ret;if (wl->nvs ==NULL ) {wl1271_error ("NVS file is needed during boot" );
@@ -343,11 +348,11 @@ int wlcore_boot_upload_nvs(struct wl1271 *wl)return -ENOMEM ;/* And finally we upload the NVS tables */ -wlcore_write_data (wl,REG_CMD_MBOX_ADDRESS , - nvs_aligned, nvs_len, false); + ret =wlcore_write_data (wl,REG_CMD_MBOX_ADDRESS , nvs_aligned, nvs_len, + false);kfree (nvs_aligned); -return 0 ; +return ret; out_badnvs:wl1271_error ("nvs data is malformed" );
drivers/net/wireless/ti/wlcore/cmd.c +9 -3
@@ -65,13 +65,17 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,WARN_ON (len %4 !=0 );WARN_ON (test_bit (WL1271_FLAG_IN_ELP , &wl->flags)); -wl1271_write (wl, wl->cmd_box_addr, buf, len, false); + ret =wlcore_write (wl, wl->cmd_box_addr, buf, len, false); +if (ret <0 ) + goto fail;/* * TODO: we just need this because one bit is in a different * place. Is there any better way? */ - wl->ops->trigger_cmd (wl, wl->cmd_box_addr, buf, len); + ret = wl->ops->trigger_cmd (wl, wl->cmd_box_addr, buf, len); +if (ret <0 ) + goto fail; timeout = jiffies +msecs_to_jiffies (WL1271_COMMAND_TIMEOUT );
@@ -1764,7 +1768,9 @@ int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif)return -EINVAL ;/* flush all pending packets */ -wl1271_tx_work_locked (wl); + ret =wlcore_tx_work_locked (wl); +if (ret <0 ) + goto out;if (test_bit (wlvif->dev_role_id, wl->roc_map)) { ret =wl12xx_croc (wl, wlvif->dev_role_id);
drivers/net/wireless/ti/wlcore/event.c +4 -1
@@ -105,6 +105,7 @@ static int wl1271_event_process(struct wl1271 *wl)u32 vector;bool disconnect_sta = false;unsigned long sta_bitmap =0 ; +int ret;wl1271_event_mbox_dump (mbox);
@@ -228,7 +229,9 @@ static int wl1271_event_process(struct wl1271 *wl)if ((vector &DUMMY_PACKET_EVENT_ID )) {wl1271_debug (DEBUG_EVENT ,"DUMMY_PACKET_ID_EVENT_ID" ); -wl1271_tx_dummy_packet (wl); + ret =wl1271_tx_dummy_packet (wl); +if (ret <0 ) +return ret; }/*
drivers/net/wireless/ti/wlcore/hw_ops.h +4 -2
@@ -65,11 +65,13 @@ wlcore_hw_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)return wl->ops->get_rx_buf_align (wl, rx_desc); } -static inline void +static inline int wlcore_hw_prepare_read (struct wl1271 *wl,u32 rx_desc,u32 len) {if (wl->ops->prepare_read) - wl->ops->prepare_read (wl, rx_desc, len); +return wl->ops->prepare_read (wl, rx_desc, len); + +return 0 ; } static inline u32
drivers/net/wireless/ti/wlcore/io.h +6 -6
@@ -102,20 +102,20 @@ static inline int wlcore_read(struct wl1271 *wl, int addr, void *buf,return wlcore_raw_read (wl, physical, buf, len, fixed); } -static inline void wl1271_write (struct wl1271 *wl,int addr,void *buf, -size_t len,bool fixed) +static inline int wlcore_write (struct wl1271 *wl,int addr,void *buf, +size_t len,bool fixed) {int physical; physical =wlcore_translate_addr (wl, addr); -wlcore_raw_write (wl, physical, buf, len, fixed); +return wlcore_raw_write (wl, physical, buf, len, fixed); } -static inline void wlcore_write_data (struct wl1271 *wl,int reg,void *buf, -size_t len,bool fixed) +static inline int wlcore_write_data (struct wl1271 *wl,int reg,void *buf, +size_t len,bool fixed) { -wl1271_write (wl, wl->rtable[reg], buf, len, fixed); +return wlcore_write (wl, wl->rtable[reg], buf, len, fixed); } static inline int wlcore_read_data(struct wl1271 *wl, int reg, void *buf,
drivers/net/wireless/ti/wlcore/main.c +10 -3
@@ -587,7 +587,11 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)* In order to avoid starvation of the TX path, * call the work function directly. */ -wl1271_tx_work_locked (wl); + ret =wlcore_tx_work_locked (wl); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto out; + } }else {spin_unlock_irqrestore (&wl->wl_lock, flags); }
@@ -1211,7 +1215,7 @@ int wl1271_tx_dummy_packet(struct wl1271 *wl)/* The FW is low on RX memory blocks, so send the dummy packet asap */ if (!test_bit (WL1271_FLAG_FW_TX_BUSY , &wl->flags)) -wl1271_tx_work_locked (wl); +return wlcore_tx_work_locked (wl);/* * If the FW TX is busy, TX work will be scheduled by the threaded
@@ -2513,7 +2517,10 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, (wlvif->channel != channel) || (wlvif->channel_type != conf->channel_type))) {/* send all pending packets */ -wl1271_tx_work_locked (wl); + ret =wlcore_tx_work_locked (wl); +if (ret <0 ) +return ret; + wlvif->band = conf->channel->band; wlvif->channel = channel; wlvif->channel_type = conf->channel_type;
drivers/net/wireless/ti/wlcore/rx.c +3 -1
@@ -235,7 +235,9 @@ int wlcore_rx(struct wl1271 *wl, struct wl_fw_status_1 *status)/* Read all available packets at once */ des =le32_to_cpu (status->rx_pkt_descs[drv_rx_counter]); -wlcore_hw_prepare_read (wl, des, buf_size); + ret =wlcore_hw_prepare_read (wl, des, buf_size); +if (ret <0 ) + goto out; ret =wlcore_read_data (wl,REG_SLV_MEM_DATA , wl->aggr_buf, buf_size, true);
drivers/net/wireless/ti/wlcore/tx.c +21 -8
@@ -662,7 +662,7 @@ void wl12xx_rearm_rx_streaming(struct wl1271 *wl, unsigned long *active_hlids) } } -void wl1271_tx_work_locked (struct wl1271 *wl) +int wlcore_tx_work_locked (struct wl1271 *wl) {struct wl12xx_vif *wlvif;struct sk_buff *skb;
@@ -670,10 +670,10 @@ void wl1271_tx_work_locked(struct wl1271 *wl)u32 buf_offset =0 , last_len =0 ;bool sent_packets = false;unsigned long active_hlids[BITS_TO_LONGS (WL12XX_MAX_LINKS )] = {0 }; -int ret; +int ret =0 ;if (unlikely (wl->state ==WL1271_STATE_OFF )) -return ; +return -EIO ;while ((skb =wl1271_skb_dequeue (wl))) {struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);
@@ -694,8 +694,11 @@ void wl1271_tx_work_locked(struct wl1271 *wl) buf_offset =wlcore_hw_pre_pkt_send (wl, buf_offset, last_len); -wlcore_write_data (wl,REG_SLV_MEM_DATA , wl->aggr_buf, - buf_offset, true); + ret =wlcore_write_data (wl,REG_SLV_MEM_DATA , + wl->aggr_buf, buf_offset, true); +if (ret <0 ) + goto out; + sent_packets = true; buf_offset =0 ;continue ;
@@ -731,8 +734,11 @@ void wl1271_tx_work_locked(struct wl1271 *wl) out_ack:if (buf_offset) { buf_offset =wlcore_hw_pre_pkt_send (wl, buf_offset, last_len); -wlcore_write_data (wl,REG_SLV_MEM_DATA , wl->aggr_buf, - buf_offset, true); + ret =wlcore_write_data (wl,REG_SLV_MEM_DATA , wl->aggr_buf, + buf_offset, true); +if (ret <0 ) + goto out; + sent_packets = true; }if (sent_packets) {
@@ -747,6 +753,9 @@ out_ack:wl1271_handle_tx_low_watermark (wl); }wl12xx_rearm_rx_streaming (wl, active_hlids); + +out: +return ret; }void wl1271_tx_work (struct work_struct *work)
@@ -759,7 +768,11 @@ void wl1271_tx_work(struct work_struct *work)if (ret <0 ) goto out; -wl1271_tx_work_locked (wl); + ret =wlcore_tx_work_locked (wl); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto out; + }wl1271_ps_elp_sleep (wl); out:
drivers/net/wireless/ti/wlcore/tx.h +1 -1
@@ -234,7 +234,7 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl) }void wl1271_tx_work (struct work_struct *work); -void wl1271_tx_work_locked (struct wl1271 *wl); +int wlcore_tx_work_locked (struct wl1271 *wl);int wlcore_tx_complete (struct wl1271 *wl);void wl12xx_tx_reset_wlvif (struct wl1271 *wl,struct wl12xx_vif *wlvif);void wl12xx_tx_reset (struct wl1271 *wl);
drivers/net/wireless/ti/wlcore/wlcore.h +3 -3
@@ -41,8 +41,8 @@ struct wlcore_ops {int (*identify_fw)(struct wl1271 *wl);int (*boot)(struct wl1271 *wl);int (*plt_init)(struct wl1271 *wl); -void (*trigger_cmd)(struct wl1271 *wl,int cmd_box_addr, -void *buf,size_t len); +int (*trigger_cmd)(struct wl1271 *wl,int cmd_box_addr, +void *buf,size_t len);void (*ack_event)(struct wl1271 *wl);u32 (*calc_tx_blocks)(struct wl1271 *wl,u32 len,u32 spare_blks); void (*set_tx_desc_blocks)(struct wl1271 *wl,
@@ -53,7 +53,7 @@ struct wlcore_ops { struct sk_buff *skb);enum wl_rx_buf_align (*get_rx_buf_align)(struct wl1271 *wl,u32 rx_desc); -void (*prepare_read)(struct wl1271 *wl,u32 rx_desc,u32 len); +int (*prepare_read)(struct wl1271 *wl,u32 rx_desc,u32 len);u32 (*get_rx_packet_len)(struct wl1271 *wl,void *rx_data,u32 data_len);int (*tx_delayed_compl)(struct wl1271 *wl);
Signature · 1 line
1.7.10
PATCH 8/18 wlcore: Propagate errors from wl1271_raw_read32
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
Propagate errors from wl1271_raw_read32. Since the read functions had no way of returning errors in-band, change their prototypes. Also rename prefixes of wlcore functions which their prototypes had to be changed.
--- drivers/net/wireless/ti/wl12xx/main.c | 152 +++++++++++++++++++++++-------- drivers/net/wireless/ti/wl18xx/io.c | 35 +++++-- drivers/net/wireless/ti/wl18xx/io.h | 4 +- drivers/net/wireless/ti/wl18xx/main.c | 114 ++++++++++++++++------- drivers/net/wireless/ti/wlcore/boot.c | 31 +++++-- drivers/net/wireless/ti/wlcore/cmd.c | 9 +- drivers/net/wireless/ti/wlcore/io.h | 26 ++++-- drivers/net/wireless/ti/wlcore/main.c | 47 +++++++--- drivers/net/wireless/ti/wlcore/wlcore.h | 4 +- 9 files changed, 309 insertions(+), 113 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +115 -37
@@ -701,10 +701,11 @@ static void wl12xx_top_reg_write(struct wl1271 *wl, int addr, u16 val)wl1271_write32 (wl,WL12XX_OCP_CMD ,OCP_CMD_WRITE ); } -static u16 wl12xx_top_reg_read (struct wl1271 *wl,int addr) +static int wl12xx_top_reg_read (struct wl1271 *wl,int addr,u16 *out) {u32 val;int timeout =OCP_CMD_LOOP ; +int ret;/* write address >> 1 + 0x30000 to OCP_POR_CTR */ addr = (addr >>1 ) +0x30000 ;
@@ -715,29 +716,38 @@ static u16 wl12xx_top_reg_read(struct wl1271 *wl, int addr)/* poll for data ready */ do { - val =wl1271_read32 (wl,WL12XX_OCP_DATA_READ ); + ret =wlcore_read32 (wl,WL12XX_OCP_DATA_READ , &val); +if (ret <0 ) +return ret; }while (!(val &OCP_READY_MASK ) && --timeout);if (!timeout) {wl1271_warning ("Top register access timed out." ); -return 0xffff ; +return -ETIMEDOUT ; }/* check data status and return if OK */ -if ((val &OCP_STATUS_MASK ) ==OCP_STATUS_OK ) -return val &0xffff ; -else { +if ((val &OCP_STATUS_MASK ) !=OCP_STATUS_OK ) {wl1271_warning ("Top register access returned error." ); -return 0xffff ; +return -EIO ; } + +if (out) + *out = val &0xffff ; + +return 0 ; }static int wl128x_switch_tcxo_to_fref (struct wl1271 *wl) {u16 spare_reg; +int ret;/* Mask bits [2] & [8:4] in the sys_clk_cfg register */ - spare_reg =wl12xx_top_reg_read (wl,WL_SPARE_REG ); + ret =wl12xx_top_reg_read (wl,WL_SPARE_REG , &spare_reg); +if (ret <0 ) +return ret; +if (spare_reg ==0xFFFF )return -EFAULT ; spare_reg |= (BIT (3 ) |BIT (5 ) |BIT (6 ));
@@ -756,8 +766,12 @@ static int wl128x_switch_tcxo_to_fref(struct wl1271 *wl)static bool wl128x_is_tcxo_valid (struct wl1271 *wl) {u16 tcxo_detection; +int ret; + + ret =wl12xx_top_reg_read (wl,TCXO_CLK_DETECT_REG , &tcxo_detection); +if (ret <0 ) +return false; - tcxo_detection =wl12xx_top_reg_read (wl,TCXO_CLK_DETECT_REG );if (tcxo_detection &TCXO_DET_FAILED )return false;
@@ -767,8 +781,12 @@ static bool wl128x_is_tcxo_valid(struct wl1271 *wl)static bool wl128x_is_fref_valid (struct wl1271 *wl) {u16 fref_detection; +int ret; + + ret =wl12xx_top_reg_read (wl,FREF_CLK_DETECT_REG , &fref_detection); +if (ret <0 ) +return false; - fref_detection =wl12xx_top_reg_read (wl,FREF_CLK_DETECT_REG );if (fref_detection &FREF_CLK_DETECT_FAIL )return false;
@@ -790,9 +808,13 @@ static int wl128x_configure_mcs_pll(struct wl1271 *wl, int clk)u16 pll_config;u8 input_freq;struct wl12xx_priv *priv = wl->priv; +int ret;/* Mask bits [3:1] in the sys_clk_cfg register */ - spare_reg =wl12xx_top_reg_read (wl,WL_SPARE_REG ); + ret =wl12xx_top_reg_read (wl,WL_SPARE_REG , &spare_reg); +if (ret <0 ) +return ret; +if (spare_reg ==0xFFFF )return -EFAULT ; spare_reg |=BIT (2 );
@@ -806,7 +828,10 @@ static int wl128x_configure_mcs_pll(struct wl1271 *wl, int clk)/* Set the input frequency according to the selected clock source */ input_freq = (clk &1 ) +1 ; - pll_config =wl12xx_top_reg_read (wl,MCS_PLL_CONFIG_REG ); + ret =wl12xx_top_reg_read (wl,MCS_PLL_CONFIG_REG , &pll_config); +if (ret <0 ) +return ret; +if (pll_config ==0xFFFF )return -EFAULT ; pll_config |= (input_freq <<MCS_SEL_IN_FREQ_SHIFT );
@@ -827,6 +852,7 @@ static int wl128x_boot_clk(struct wl1271 *wl, int *selected_clock) {struct wl12xx_priv *priv = wl->priv;u16 sys_clk_cfg; +int ret;/* For XTAL-only modes, FREF will be used after switching from TCXO */ if (priv->ref_clock == WL12XX_REFCLOCK_26_XTAL ||
@@ -837,7 +863,10 @@ static int wl128x_boot_clk(struct wl1271 *wl, int *selected_clock) }/* Query the HW, to determine which clock source we should use */ - sys_clk_cfg =wl12xx_top_reg_read (wl,SYS_CLK_CFG_REG ); + ret =wl12xx_top_reg_read (wl,SYS_CLK_CFG_REG , &sys_clk_cfg); +if (ret <0 ) +return ret; +if (sys_clk_cfg ==0xFFFF )return -EINVAL ;if (sys_clk_cfg &PRCM_CM_EN_MUX_WLAN_FREF )
@@ -872,6 +901,7 @@ static int wl127x_boot_clk(struct wl1271 *wl)struct wl12xx_priv *priv = wl->priv;u32 pause;u32 clk; +int ret;if (WL127X_PG_GET_MAJOR (wl->hw_pg_ver) <3 ) wl->quirks |=WLCORE_QUIRK_END_OF_TRANSACTION ;
@@ -892,18 +922,27 @@ static int wl127x_boot_clk(struct wl1271 *wl)if (priv->ref_clock !=CONF_REF_CLK_19_2_E ) {u16 val;/* Set clock type (open drain) */ - val =wl12xx_top_reg_read (wl,OCP_REG_CLK_TYPE ); + ret =wl12xx_top_reg_read (wl,OCP_REG_CLK_TYPE , &val); +if (ret <0 ) + goto out; + val &=FREF_CLK_TYPE_BITS ;wl12xx_top_reg_write (wl,OCP_REG_CLK_TYPE , val);/* Set clock pull mode (no pull) */ - val =wl12xx_top_reg_read (wl,OCP_REG_CLK_PULL ); + ret =wl12xx_top_reg_read (wl,OCP_REG_CLK_PULL , &val); +if (ret <0 ) + goto out; + val |=NO_PULL ;wl12xx_top_reg_write (wl,OCP_REG_CLK_PULL , val); }else {u16 val;/* Set clock polarity */ - val =wl12xx_top_reg_read (wl,OCP_REG_CLK_POLARITY ); + ret =wl12xx_top_reg_read (wl,OCP_REG_CLK_POLARITY , &val); +if (ret <0 ) + goto out; + val &=FREF_CLK_POLARITY_BITS ; val |=CLK_REQ_OUTN_SEL ;wl12xx_top_reg_write (wl,OCP_REG_CLK_POLARITY , val);
@@ -911,7 +950,9 @@ static int wl127x_boot_clk(struct wl1271 *wl)wl1271_write32 (wl,WL12XX_PLL_PARAMETERS , clk); - pause =wl1271_read32 (wl,WL12XX_PLL_PARAMETERS ); + ret =wlcore_read32 (wl,WL12XX_PLL_PARAMETERS , &pause); +if (ret <0 ) + goto out;wl1271_debug (DEBUG_BOOT ,"pause1 0x%x" , pause);
@@ -919,13 +960,15 @@ static int wl127x_boot_clk(struct wl1271 *wl) pause |=WU_COUNTER_PAUSE_VAL ;wl1271_write32 (wl,WL12XX_WU_COUNTER_PAUSE , pause); -return 0 ; +out: +return ret; }static int wl1271_boot_soft_reset (struct wl1271 *wl) {unsigned long timeout;u32 boot_data; +int ret =0 ;/* perform soft reset */ wl1271_write32 (wl,WL12XX_SLV_SOFT_RESET ,ACX_SLV_SOFT_RESET_BIT );
@@ -933,7 +976,10 @@ static int wl1271_boot_soft_reset(struct wl1271 *wl)/* SOFT_RESET is self clearing */ timeout = jiffies +usecs_to_jiffies (SOFT_RESET_MAX_TIME );while (1 ) { - boot_data =wl1271_read32 (wl,WL12XX_SLV_SOFT_RESET ); + ret =wlcore_read32 (wl,WL12XX_SLV_SOFT_RESET , &boot_data); +if (ret <0 ) + goto out; +wl1271_debug (DEBUG_BOOT ,"soft reset bootdata 0x%x" , boot_data);if ((boot_data &ACX_SLV_SOFT_RESET_BIT ) ==0 )break ;
@@ -954,7 +1000,8 @@ static int wl1271_boot_soft_reset(struct wl1271 *wl)/* disable auto calibration on start*/ wl1271_write32 (wl,WL12XX_SPARE_A2 ,0xffff ); -return 0 ; +out: +return ret; }static int wl12xx_pre_boot (struct wl1271 *wl)
@@ -984,7 +1031,9 @@ static int wl12xx_pre_boot(struct wl1271 *wl)to be used by DRPw FW. The RTRIM value will be added by the FW before taking DRPw out of reset */ - clk =wl1271_read32 (wl,WL12XX_DRPW_SCRATCH_START ); + ret =wlcore_read32 (wl,WL12XX_DRPW_SCRATCH_START , &clk); +if (ret <0 ) + goto out;wl1271_debug (DEBUG_BOOT ,"clk2 0x%x" , clk);
@@ -1008,9 +1057,11 @@ out:return ret; } -static void wl12xx_pre_upload (struct wl1271 *wl) +static int wl12xx_pre_upload (struct wl1271 *wl) { -u32 tmp, polarity; +u32 tmp; +u16 polarity; +int ret;/* write firmware's last address (ie. it's length) to * ACX_EEPROMLESS_IND_REG */
@@ -1018,12 +1069,16 @@ static void wl12xx_pre_upload(struct wl1271 *wl)wl1271_write32 (wl,WL12XX_EEPROMLESS_IND ,WL12XX_EEPROMLESS_IND ); - tmp =wlcore_read_reg (wl,REG_CHIP_ID_B ); + ret =wlcore_read_reg (wl,REG_CHIP_ID_B , &tmp); +if (ret <0 ) + goto out;wl1271_debug (DEBUG_BOOT ,"chip id 0x%x" , tmp);/* 6. read the EEPROM parameters */ - tmp =wl1271_read32 (wl,WL12XX_SCR_PAD2 ); + ret =wlcore_read32 (wl,WL12XX_SCR_PAD2 , &tmp); +if (ret <0 ) + goto out;/* WL1271: The reference driver skips steps 7 to 10 (jumps directly * to upload_fw) */
@@ -1032,12 +1087,16 @@ static void wl12xx_pre_upload(struct wl1271 *wl)wl12xx_top_reg_write (wl,SDIO_IO_DS ,HCI_IO_DS_6MA );/* polarity must be set before the firmware is loaded */ - polarity =wl12xx_top_reg_read (wl,OCP_REG_POLARITY ); + ret =wl12xx_top_reg_read (wl,OCP_REG_POLARITY , &polarity); +if (ret <0 ) + goto out;/* We use HIGH polarity, so unset the LOW bit */ polarity &= ~POLARITY_LOW ;wl12xx_top_reg_write (wl,OCP_REG_POLARITY , polarity); +out: +return ret; }static void wl12xx_enable_interrupts (struct wl1271 *wl)
@@ -1063,7 +1122,9 @@ static int wl12xx_boot(struct wl1271 *wl)if (ret <0 ) goto out; -wl12xx_pre_upload (wl); + ret =wl12xx_pre_upload (wl); +if (ret <0 ) + goto out; ret =wlcore_boot_upload_firmware (wl);if (ret <0 )
@@ -1282,14 +1343,20 @@ static bool wl12xx_mac_in_fuse(struct wl1271 *wl)return supported; } -static void wl12xx_get_fuse_mac (struct wl1271 *wl) +static int wl12xx_get_fuse_mac (struct wl1271 *wl) {u32 mac1, mac2; +int ret;wlcore_set_partition (wl, &wl->ptable[PART_DRPW ]); - mac1 =wl1271_read32 (wl,WL12XX_REG_FUSE_BD_ADDR_1 ); - mac2 =wl1271_read32 (wl,WL12XX_REG_FUSE_BD_ADDR_2 ); + ret =wlcore_read32 (wl,WL12XX_REG_FUSE_BD_ADDR_1 , &mac1); +if (ret <0 ) + goto out; + + ret =wlcore_read32 (wl,WL12XX_REG_FUSE_BD_ADDR_2 , &mac2); +if (ret <0 ) + goto out;/* these are the two parts of the BD_ADDR */ wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) +
@@ -1297,24 +1364,35 @@ static void wl12xx_get_fuse_mac(struct wl1271 *wl) wl->fuse_nic_addr = mac1 &0xffffff ;wlcore_set_partition (wl, &wl->ptable[PART_DOWN ]); + +out: +return ret; } -static s8 wl12xx_get_pg_ver (struct wl1271 *wl) +static int wl12xx_get_pg_ver (struct wl1271 *wl,s8 *ver) { -u32 die_info; +u16 die_info; +int ret;if (wl->chip.id ==CHIP_ID_1283_PG20 ) - die_info =wl12xx_top_reg_read (wl,WL128X_REG_FUSE_DATA_2_1 ); + ret =wl12xx_top_reg_read (wl,WL128X_REG_FUSE_DATA_2_1 , + &die_info);else - die_info =wl12xx_top_reg_read (wl,WL127X_REG_FUSE_DATA_2_1 ); + ret =wl12xx_top_reg_read (wl,WL127X_REG_FUSE_DATA_2_1 , + &die_info); -return (s8) (die_info &PG_VER_MASK ) >>PG_VER_OFFSET ; +if (ret >=0 && ver) + *ver = (s8)((die_info &PG_VER_MASK ) >>PG_VER_OFFSET ); + +return ret; } -static void wl12xx_get_mac (struct wl1271 *wl) +static int wl12xx_get_mac (struct wl1271 *wl) {if (wl12xx_mac_in_fuse (wl)) -wl12xx_get_fuse_mac (wl); +return wl12xx_get_fuse_mac (wl); + +return 0 ; } static void wl12xx_set_tx_desc_csum(struct wl1271 *wl,
drivers/net/wireless/ti/wl18xx/io.c +25 -10
@@ -24,37 +24,52 @@#include "io.h" -void wl18xx_top_reg_write (struct wl1271 *wl,int addr,u16 val) +int wl18xx_top_reg_write (struct wl1271 *wl,int addr,u16 val) {u32 tmp; +int ret;if (WARN_ON (addr %2 )) -return ; +return -EINVAL ;if ((addr %4 ) ==0 ) { - tmp =wl1271_read32 (wl, addr); + ret =wlcore_read32 (wl, addr, &tmp); +if (ret <0 ) + goto out; + tmp = (tmp &0xffff0000 ) | val;wl1271_write32 (wl, addr, tmp); }else { - tmp =wl1271_read32 (wl, addr -2 ); + ret =wlcore_read32 (wl, addr -2 , &tmp); +if (ret <0 ) + goto out; + tmp = (tmp &0xffff ) | (val <<16 );wl1271_write32 (wl, addr -2 , tmp); } + +out: +return ret; } -u16 wl18xx_top_reg_read (struct wl1271 *wl,int addr) +int wl18xx_top_reg_read (struct wl1271 *wl,int addr,u16 *out) {u32 val; +int ret;if (WARN_ON (addr %2 )) -return 0 ; +return -EINVAL ;if ((addr %4 ) ==0 ) {/* address is 4-bytes aligned */ - val =wl1271_read32 (wl, addr); -return val &0xffff ; + ret =wlcore_read32 (wl, addr, &val); +if (ret >=0 && out) + *out = val &0xffff ; }else { - val =wl1271_read32 (wl, addr -2 ); -return (val &0xffff0000 ) >>16 ; + ret =wlcore_read32 (wl, addr -2 , &val); +if (ret >=0 && out) + *out = (val &0xffff0000 ) >>16 ; } + +return ret; }
drivers/net/wireless/ti/wl18xx/io.h +2 -2
@@ -22,7 +22,7 @@#ifndef __WL18XX_IO_H__#define __WL18XX_IO_H__ -void wl18xx_top_reg_write (struct wl1271 *wl,int addr,u16 val); -u16 wl18xx_top_reg_read (struct wl1271 *wl,int addr); +int wl18xx_top_reg_write (struct wl1271 *wl,int addr,u16 val); +int wl18xx_top_reg_read (struct wl1271 *wl,int addr,u16 *out);#endif /* __WL18XX_IO_H__ */
drivers/net/wireless/ti/wl18xx/main.c +82 -32
202 lines not on this page · raw message
drivers/net/wireless/ti/wlcore/boot.c +24 -7
@@ -33,16 +33,22 @@#include "rx.h" #include "hw_ops.h" -static void wl1271_boot_set_ecpu_ctrl (struct wl1271 *wl,u32 flag) +static int wl1271_boot_set_ecpu_ctrl (struct wl1271 *wl,u32 flag) {u32 cpu_ctrl; +int ret;/* 10.5.0 run the firmware (I) */ - cpu_ctrl =wlcore_read_reg (wl,REG_ECPU_CONTROL ); + ret =wlcore_read_reg (wl,REG_ECPU_CONTROL , &cpu_ctrl); +if (ret <0 ) + goto out;/* 10.5.1 run the firmware (II) */ cpu_ctrl |= flag;wlcore_write_reg (wl,REG_ECPU_CONTROL , cpu_ctrl); + +out: +return ret; } static int wlcore_boot_parse_fw_ver(struct wl1271 *wl,
@@ -368,9 +374,13 @@ int wlcore_boot_run_firmware(struct wl1271 *wl)/* Make sure we have the boot partition */ wlcore_set_partition (wl, &wl->ptable[PART_BOOT ]); -wl1271_boot_set_ecpu_ctrl (wl,ECPU_CONTROL_HALT ); + ret =wl1271_boot_set_ecpu_ctrl (wl,ECPU_CONTROL_HALT ); +if (ret <0 ) +return ret; - chip_id =wlcore_read_reg (wl,REG_CHIP_ID_B ); + ret =wlcore_read_reg (wl,REG_CHIP_ID_B , &chip_id); +if (ret <0 ) +return ret;wl1271_debug (DEBUG_BOOT ,"chip id after firmware boot: 0x%x" , chip_id);
@@ -383,7 +393,9 @@ int wlcore_boot_run_firmware(struct wl1271 *wl) loop =0 ;while (loop++ <INIT_LOOP ) {udelay (INIT_LOOP_DELAY ); - intr =wlcore_read_reg (wl,REG_INTERRUPT_NO_CLEAR ); + ret =wlcore_read_reg (wl,REG_INTERRUPT_NO_CLEAR , &intr); +if (ret <0 ) +return ret;if (intr ==0xffffffff ) { wl1271_error("error reading hardware complete "
@@ -405,12 +417,17 @@ int wlcore_boot_run_firmware(struct wl1271 *wl) }/* get hardware config command mail box */ - wl->cmd_box_addr =wlcore_read_reg (wl,REG_COMMAND_MAILBOX_PTR ); + ret =wlcore_read_reg (wl,REG_COMMAND_MAILBOX_PTR , &wl->cmd_box_addr); +if (ret <0 ) +return ret;wl1271_debug (DEBUG_MAILBOX ,"cmd_box_addr 0x%x" , wl->cmd_box_addr);/* get hardware config event mail box */ - wl->mbox_ptr[0 ] =wlcore_read_reg (wl,REG_EVENT_MAILBOX_PTR ); + ret =wlcore_read_reg (wl,REG_EVENT_MAILBOX_PTR , &wl->mbox_ptr[0 ]); +if (ret <0 ) +return ret; + wl->mbox_ptr[1 ] = wl->mbox_ptr[0 ] +sizeof (struct event_mailbox ); wl1271_debug(DEBUG_MAILBOX, "MBOX ptrs: 0x%x 0x%x",
drivers/net/wireless/ti/wlcore/cmd.c +7 -2
@@ -79,7 +79,10 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len, timeout = jiffies +msecs_to_jiffies (WL1271_COMMAND_TIMEOUT ); - intr =wlcore_read_reg (wl,REG_INTERRUPT_NO_CLEAR ); + ret =wlcore_read_reg (wl,REG_INTERRUPT_NO_CLEAR , &intr); +if (ret <0 ) + goto fail; +while (!(intr &WL1271_ACX_INTR_CMD_COMPLETE )) {if (time_after (jiffies, timeout)) {wl1271_error ("command complete timeout" );
@@ -93,7 +96,9 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,else msleep (1 ); - intr =wlcore_read_reg (wl,REG_INTERRUPT_NO_CLEAR ); + ret =wlcore_read_reg (wl,REG_INTERRUPT_NO_CLEAR , &intr); +if (ret <0 ) + goto fail; }/* read back the status code of the command */
drivers/net/wireless/ti/wlcore/io.h +17 -9
@@ -77,12 +77,19 @@ static inline int wlcore_raw_write_data(struct wl1271 *wl, int reg, void *buf,return wlcore_raw_write (wl, wl->rtable[reg], buf, len, fixed); } -static inline u32 wl1271_raw_read32 (struct wl1271 *wl,int addr) +static inline int wlcore_raw_read32 (struct wl1271 *wl,int addr,u32 *val) { -wlcore_raw_read (wl, addr, &wl->buffer_32, -sizeof (wl->buffer_32), false); +int ret; + + ret =wlcore_raw_read (wl, addr, &wl->buffer_32, +sizeof (wl->buffer_32), false); +if (ret <0 ) +return ret; + +if (val) + *val =le32_to_cpu (wl->buffer_32); -return le32_to_cpu (wl->buffer_32); +return 0 ; }static inline void wl1271_raw_write32 (struct wl1271 *wl,int addr,u32 val)
@@ -138,9 +145,9 @@ static inline void wl1271_read_hwaddr(struct wl1271 *wl, int hwaddr,wlcore_raw_read (wl, physical, buf, len, fixed); } -static inline u32 wl1271_read32 (struct wl1271 *wl,int addr) +static inline int wlcore_read32 (struct wl1271 *wl,int addr,u32 *val) { -return wl1271_raw_read32 (wl,wlcore_translate_addr (wl, addr)); +return wlcore_raw_read32 (wl,wlcore_translate_addr (wl, addr), val); }static inline void wl1271_write32 (struct wl1271 *wl,int addr,u32 val)
@@ -148,10 +155,11 @@ static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val)wl1271_raw_write32 (wl,wlcore_translate_addr (wl, addr), val); } -static inline u32 wlcore_read_reg (struct wl1271 *wl,int reg) +static inline int wlcore_read_reg (struct wl1271 *wl,int reg,u32 *val) { -return wl1271_raw_read32 (wl, -wlcore_translate_addr (wl, wl->rtable[reg])); +return wlcore_raw_read32 (wl, +wlcore_translate_addr (wl, wl->rtable[reg]), + val); }static inline void wlcore_write_reg (struct wl1271 *wl,int reg,u32 val)
drivers/net/wireless/ti/wlcore/main.c +35 -12
73 lines not on this page · raw message
drivers/net/wireless/ti/wlcore/wlcore.h +2 -2
@@ -62,8 +62,8 @@ struct wlcore_ops {int (*init_vif)(struct wl1271 *wl,struct wl12xx_vif *wlvif);u32 (*sta_get_ap_rate_mask)(struct wl1271 *wl,struct wl12xx_vif *wlvif); -s8 (*get_pg_ver)(struct wl1271 *wl); -void (*get_mac)(struct wl1271 *wl); +int (*get_pg_ver)(struct wl1271 *wl,s8 *ver); +int (*get_mac)(struct wl1271 *wl);void (*set_tx_desc_csum)(struct wl1271 *wl,struct wl1271_tx_hw_descr *desc,struct sk_buff *skb);
Signature · 1 line
1.7.10
PATCH 9/18 wlcore: Propagate errors from wl1271_raw_write32
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
Propagate errors from wl1271_raw_write32 and request for recovery when appropriate.
Also rename prefixes of wlcore functions which their prototypes had to be changed.
--- drivers/net/wireless/ti/wl12xx/main.c | 160 ++++++++++++++++++++++--------- drivers/net/wireless/ti/wl18xx/io.c | 4 +- drivers/net/wireless/ti/wl18xx/main.c | 86 ++++++++++++----- drivers/net/wireless/ti/wlcore/boot.c | 32 +++++-- drivers/net/wireless/ti/wlcore/cmd.c | 6 +- drivers/net/wireless/ti/wlcore/event.c | 4 +- drivers/net/wireless/ti/wlcore/io.c | 49 ++++++---- drivers/net/wireless/ti/wlcore/io.h | 22 ++--- drivers/net/wireless/ti/wlcore/main.c | 20 +++- drivers/net/wireless/ti/wlcore/ps.c | 14 ++- drivers/net/wireless/ti/wlcore/rx.c | 9 +- drivers/net/wireless/ti/wlcore/tx.c | 17 ++-- drivers/net/wireless/ti/wlcore/wlcore.h | 2 +- 13 files changed, 298 insertions(+), 127 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +116 -44
@@ -688,17 +688,28 @@ out:return ret; } -static void wl12xx_top_reg_write (struct wl1271 *wl,int addr,u16 val) +static int wl12xx_top_reg_write (struct wl1271 *wl,int addr,u16 val) { +int ret; +/* write address >> 1 + 0x30000 to OCP_POR_CTR */ addr = (addr >>1 ) +0x30000 ; -wl1271_write32 (wl,WL12XX_OCP_POR_CTR , addr); + ret =wlcore_write32 (wl,WL12XX_OCP_POR_CTR , addr); +if (ret <0 ) + goto out;/* write value to OCP_POR_WDATA */ -wl1271_write32 (wl,WL12XX_OCP_DATA_WRITE , val); + ret =wlcore_write32 (wl,WL12XX_OCP_DATA_WRITE , val); +if (ret <0 ) + goto out;/* write 1 to OCP_CMD */ -wl1271_write32 (wl,WL12XX_OCP_CMD ,OCP_CMD_WRITE ); + ret =wlcore_write32 (wl,WL12XX_OCP_CMD ,OCP_CMD_WRITE ); +if (ret <0 ) + goto out; + +out: +return ret; }static int wl12xx_top_reg_read (struct wl1271 *wl,int addr,u16 *out)
@@ -709,10 +720,14 @@ static int wl12xx_top_reg_read(struct wl1271 *wl, int addr, u16 *out)/* write address >> 1 + 0x30000 to OCP_POR_CTR */ addr = (addr >>1 ) +0x30000 ; -wl1271_write32 (wl,WL12XX_OCP_POR_CTR , addr); + ret =wlcore_write32 (wl,WL12XX_OCP_POR_CTR , addr); +if (ret <0 ) +return ret;/* write 2 to OCP_CMD */ -wl1271_write32 (wl,WL12XX_OCP_CMD ,OCP_CMD_READ ); + ret =wlcore_write32 (wl,WL12XX_OCP_CMD ,OCP_CMD_READ ); +if (ret <0 ) +return ret;/* poll for data ready */ do {
@@ -751,11 +766,15 @@ static int wl128x_switch_tcxo_to_fref(struct wl1271 *wl)if (spare_reg ==0xFFFF )return -EFAULT ; spare_reg |= (BIT (3 ) |BIT (5 ) |BIT (6 )); -wl12xx_top_reg_write (wl,WL_SPARE_REG , spare_reg); + ret =wl12xx_top_reg_write (wl,WL_SPARE_REG , spare_reg); +if (ret <0 ) +return ret;/* Enable FREF_CLK_REQ & mux MCS and coex PLLs to FREF */ -wl12xx_top_reg_write (wl,SYS_CLK_CFG_REG , -WL_CLK_REQ_TYPE_PG2 |MCS_PLL_CLK_SEL_FREF ); + ret =wl12xx_top_reg_write (wl,SYS_CLK_CFG_REG , +WL_CLK_REQ_TYPE_PG2 |MCS_PLL_CLK_SEL_FREF ); +if (ret <0 ) +return ret;/* Delay execution for 15msec, to let the HW settle */ mdelay (15 );
@@ -795,11 +814,21 @@ static bool wl128x_is_fref_valid(struct wl1271 *wl)static int wl128x_manually_configure_mcs_pll (struct wl1271 *wl) { -wl12xx_top_reg_write (wl,MCS_PLL_M_REG ,MCS_PLL_M_REG_VAL ); -wl12xx_top_reg_write (wl,MCS_PLL_N_REG ,MCS_PLL_N_REG_VAL ); -wl12xx_top_reg_write (wl,MCS_PLL_CONFIG_REG ,MCS_PLL_CONFIG_REG_VAL ); +int ret; -return 0 ; + ret =wl12xx_top_reg_write (wl,MCS_PLL_M_REG ,MCS_PLL_M_REG_VAL ); +if (ret <0 ) + goto out; + + ret =wl12xx_top_reg_write (wl,MCS_PLL_N_REG ,MCS_PLL_N_REG_VAL ); +if (ret <0 ) + goto out; + + ret =wl12xx_top_reg_write (wl,MCS_PLL_CONFIG_REG , +MCS_PLL_CONFIG_REG_VAL ); + +out: +return ret; }static int wl128x_configure_mcs_pll (struct wl1271 *wl,int clk)
@@ -818,7 +847,9 @@ static int wl128x_configure_mcs_pll(struct wl1271 *wl, int clk)if (spare_reg ==0xFFFF )return -EFAULT ; spare_reg |=BIT (2 ); -wl12xx_top_reg_write (wl,WL_SPARE_REG , spare_reg); + ret =wl12xx_top_reg_write (wl,WL_SPARE_REG , spare_reg); +if (ret <0 ) +return ret;/* Handle special cases of the TCXO clock */ if (priv->tcxo_clock == WL12XX_TCXOCLOCK_16_8 ||
@@ -836,9 +867,9 @@ static int wl128x_configure_mcs_pll(struct wl1271 *wl, int clk)return -EFAULT ; pll_config |= (input_freq <<MCS_SEL_IN_FREQ_SHIFT ); pll_config |=MCS_PLL_ENABLE_HP ; -wl12xx_top_reg_write (wl,MCS_PLL_CONFIG_REG , pll_config); + ret =wl12xx_top_reg_write (wl,MCS_PLL_CONFIG_REG , pll_config); -return 0 ; +return ret; }/*
@@ -927,7 +958,9 @@ static int wl127x_boot_clk(struct wl1271 *wl) goto out; val &=FREF_CLK_TYPE_BITS ; -wl12xx_top_reg_write (wl,OCP_REG_CLK_TYPE , val); + ret =wl12xx_top_reg_write (wl,OCP_REG_CLK_TYPE , val); +if (ret <0 ) + goto out;/* Set clock pull mode (no pull) */ ret =wl12xx_top_reg_read (wl,OCP_REG_CLK_PULL , &val);
@@ -935,7 +968,9 @@ static int wl127x_boot_clk(struct wl1271 *wl) goto out; val |=NO_PULL ; -wl12xx_top_reg_write (wl,OCP_REG_CLK_PULL , val); + ret =wl12xx_top_reg_write (wl,OCP_REG_CLK_PULL , val); +if (ret <0 ) + goto out; }else {u16 val;/* Set clock polarity */
@@ -945,10 +980,14 @@ static int wl127x_boot_clk(struct wl1271 *wl) val &=FREF_CLK_POLARITY_BITS ; val |=CLK_REQ_OUTN_SEL ; -wl12xx_top_reg_write (wl,OCP_REG_CLK_POLARITY , val); + ret =wl12xx_top_reg_write (wl,OCP_REG_CLK_POLARITY , val); +if (ret <0 ) + goto out; } -wl1271_write32 (wl,WL12XX_PLL_PARAMETERS , clk); + ret =wlcore_write32 (wl,WL12XX_PLL_PARAMETERS , clk); +if (ret <0 ) + goto out; ret =wlcore_read32 (wl,WL12XX_PLL_PARAMETERS , &pause);if (ret <0 )
@@ -958,7 +997,7 @@ static int wl127x_boot_clk(struct wl1271 *wl) pause &= ~(WU_COUNTER_PAUSE_VAL ); pause |=WU_COUNTER_PAUSE_VAL ; -wl1271_write32 (wl,WL12XX_WU_COUNTER_PAUSE , pause); + ret =wlcore_write32 (wl,WL12XX_WU_COUNTER_PAUSE , pause); out:return ret;
@@ -971,7 +1010,9 @@ static int wl1271_boot_soft_reset(struct wl1271 *wl)int ret =0 ;/* perform soft reset */ -wl1271_write32 (wl,WL12XX_SLV_SOFT_RESET ,ACX_SLV_SOFT_RESET_BIT ); + ret =wlcore_write32 (wl,WL12XX_SLV_SOFT_RESET ,ACX_SLV_SOFT_RESET_BIT ); +if (ret <0 ) + goto out;/* SOFT_RESET is self clearing */ timeout = jiffies +usecs_to_jiffies (SOFT_RESET_MAX_TIME );
@@ -995,10 +1036,12 @@ static int wl1271_boot_soft_reset(struct wl1271 *wl) }/* disable Rx/Tx */ -wl1271_write32 (wl,WL12XX_ENABLE ,0x0 ); + ret =wlcore_write32 (wl,WL12XX_ENABLE ,0x0 ); +if (ret <0 ) + goto out;/* disable auto calibration on start*/ -wl1271_write32 (wl,WL12XX_SPARE_A2 ,0xffff ); + ret =wlcore_write32 (wl,WL12XX_SPARE_A2 ,0xffff ); out:return ret;
@@ -1022,10 +1065,15 @@ static int wl12xx_pre_boot(struct wl1271 *wl) }/* Continue the ELP wake up sequence */ -wl1271_write32 (wl,WL12XX_WELP_ARM_COMMAND ,WELP_ARM_COMMAND_VAL ); + ret =wlcore_write32 (wl,WL12XX_WELP_ARM_COMMAND ,WELP_ARM_COMMAND_VAL ); +if (ret <0 ) + goto out; +udelay (500 ); -wlcore_set_partition (wl, &wl->ptable[PART_DRPW ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_DRPW ]); +if (ret <0 ) + goto out;/* Read-modify-write DRPW_SCRATCH_START register (see next state) to be used by DRPw FW. The RTRIM value will be added by the FW
@@ -1042,12 +1090,18 @@ static int wl12xx_pre_boot(struct wl1271 *wl)else clk |= (priv->ref_clock <<1 ) <<4 ; -wl1271_write32 (wl,WL12XX_DRPW_SCRATCH_START , clk); + ret =wlcore_write32 (wl,WL12XX_DRPW_SCRATCH_START , clk); +if (ret <0 ) + goto out; -wlcore_set_partition (wl, &wl->ptable[PART_WORK ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_WORK ]); +if (ret <0 ) + goto out;/* Disable interrupts */ -wlcore_write_reg (wl,REG_INTERRUPT_MASK ,WL1271_ACX_INTR_ALL ); + ret =wlcore_write_reg (wl,REG_INTERRUPT_MASK ,WL1271_ACX_INTR_ALL ); +if (ret <0 ) + goto out; ret =wl1271_boot_soft_reset (wl);if (ret <0 )
@@ -1067,7 +1121,9 @@ static int wl12xx_pre_upload(struct wl1271 *wl)* ACX_EEPROMLESS_IND_REG */ wl1271_debug (DEBUG_BOOT ,"ACX_EEPROMLESS_IND_REG" ); -wl1271_write32 (wl,WL12XX_EEPROMLESS_IND ,WL12XX_EEPROMLESS_IND ); + ret =wlcore_write32 (wl,WL12XX_EEPROMLESS_IND ,WL12XX_EEPROMLESS_IND ); +if (ret <0 ) + goto out; ret =wlcore_read_reg (wl,REG_CHIP_ID_B , &tmp);if (ret <0 )
@@ -1083,8 +1139,11 @@ static int wl12xx_pre_upload(struct wl1271 *wl)/* WL1271: The reference driver skips steps 7 to 10 (jumps directly * to upload_fw) */ -if (wl->chip.id ==CHIP_ID_1283_PG20 ) -wl12xx_top_reg_write (wl,SDIO_IO_DS ,HCI_IO_DS_6MA ); +if (wl->chip.id ==CHIP_ID_1283_PG20 ) { + ret =wl12xx_top_reg_write (wl,SDIO_IO_DS ,HCI_IO_DS_6MA ); +if (ret <0 ) + goto out; + }/* polarity must be set before the firmware is loaded */ ret =wl12xx_top_reg_read (wl,OCP_REG_POLARITY , &polarity);
@@ -1093,21 +1152,31 @@ static int wl12xx_pre_upload(struct wl1271 *wl)/* We use HIGH polarity, so unset the LOW bit */ polarity &= ~POLARITY_LOW ; -wl12xx_top_reg_write (wl,OCP_REG_POLARITY , polarity); + ret =wl12xx_top_reg_write (wl,OCP_REG_POLARITY , polarity); out:return ret; } -static void wl12xx_enable_interrupts (struct wl1271 *wl) +static int wl12xx_enable_interrupts (struct wl1271 *wl) { -wlcore_write_reg (wl,REG_INTERRUPT_MASK ,WL12XX_ACX_ALL_EVENTS_VECTOR ); +int ret; + + ret =wlcore_write_reg (wl,REG_INTERRUPT_MASK , +WL12XX_ACX_ALL_EVENTS_VECTOR ); +if (ret <0 ) + goto out;wlcore_enable_interrupts (wl); -wlcore_write_reg (wl,REG_INTERRUPT_MASK , -WL1271_ACX_INTR_ALL & ~(WL12XX_INTR_MASK )); + ret =wlcore_write_reg (wl,REG_INTERRUPT_MASK , +WL1271_ACX_INTR_ALL & ~(WL12XX_INTR_MASK )); +if (ret <0 ) + goto out; + + ret =wlcore_write32 (wl,WL12XX_HI_CFG ,HI_CFG_DEF_VAL ); -wl1271_write32 (wl,WL12XX_HI_CFG ,HI_CFG_DEF_VAL ); +out: +return ret; }static int wl12xx_boot (struct wl1271 *wl)
@@ -1134,7 +1203,7 @@ static int wl12xx_boot(struct wl1271 *wl)if (ret <0 ) goto out; -wl12xx_enable_interrupts (wl); + ret =wl12xx_enable_interrupts (wl); out:return ret;
@@ -1149,14 +1218,15 @@ static int wl12xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr,if (ret <0 )return ret; -wlcore_write_reg (wl,REG_INTERRUPT_TRIG ,WL12XX_INTR_TRIG_CMD ); + ret =wlcore_write_reg (wl,REG_INTERRUPT_TRIG ,WL12XX_INTR_TRIG_CMD );return ret; } -static void wl12xx_ack_event (struct wl1271 *wl) +static int wl12xx_ack_event (struct wl1271 *wl) { -wlcore_write_reg (wl,REG_INTERRUPT_TRIG ,WL12XX_INTR_TRIG_EVENT_ACK ); +return wlcore_write_reg (wl,REG_INTERRUPT_TRIG , +WL12XX_INTR_TRIG_EVENT_ACK ); }static u32 wl12xx_calc_tx_blocks (struct wl1271 *wl,u32 len,u32 spare_blks)
@@ -1348,7 +1418,9 @@ static int wl12xx_get_fuse_mac(struct wl1271 *wl)u32 mac1, mac2;int ret; -wlcore_set_partition (wl, &wl->ptable[PART_DRPW ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_DRPW ]); +if (ret <0 ) + goto out; ret =wlcore_read32 (wl,WL12XX_REG_FUSE_BD_ADDR_1 , &mac1);if (ret <0 )
@@ -1363,7 +1435,7 @@ static int wl12xx_get_fuse_mac(struct wl1271 *wl) ((mac1 &0xff000000 ) >>24 ); wl->fuse_nic_addr = mac1 &0xffffff ; -wlcore_set_partition (wl, &wl->ptable[PART_DOWN ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_DOWN ]); out:return ret;
drivers/net/wireless/ti/wl18xx/io.c +2 -2
@@ -38,14 +38,14 @@ int wl18xx_top_reg_write(struct wl1271 *wl, int addr, u16 val) goto out; tmp = (tmp &0xffff0000 ) | val; -wl1271_write32 (wl, addr, tmp); + ret =wlcore_write32 (wl, addr, tmp); }else { ret =wlcore_read32 (wl, addr -2 , &tmp);if (ret <0 ) goto out; tmp = (tmp &0xffff ) | (val <<16 ); -wl1271_write32 (wl, addr -2 , tmp); + ret =wlcore_write32 (wl, addr -2 , tmp); } out:
drivers/net/wireless/ti/wl18xx/main.c +63 -23
186 lines not on this page · raw message
drivers/net/wireless/ti/wlcore/boot.c +22 -10
@@ -45,7 +45,7 @@ static int wl1271_boot_set_ecpu_ctrl(struct wl1271 *wl, u32 flag)/* 10.5.1 run the firmware (II) */ cpu_ctrl |= flag; -wlcore_write_reg (wl,REG_ECPU_CONTROL , cpu_ctrl); + ret =wlcore_write_reg (wl,REG_ECPU_CONTROL , cpu_ctrl); out:return ret;
@@ -139,7 +139,9 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,memcpy (&partition, &wl->ptable[PART_DOWN ],sizeof (partition)); partition.mem.start = dest; -wlcore_set_partition (wl, &partition); + ret =wlcore_set_partition (wl, &partition); +if (ret <0 ) +return ret;/* 10.1 set partition limit and chunk num */ chunk_num =0 ;
@@ -153,7 +155,9 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf, partition_limit = chunk_num *CHUNK_SIZE + wl->ptable[PART_DOWN ].mem.size; partition.mem.start = addr; -wlcore_set_partition (wl, &partition); + ret =wlcore_set_partition (wl, &partition); +if (ret <0 ) +return ret; }/* 10.3 upload the chunk */
@@ -320,7 +324,9 @@ int wlcore_boot_upload_nvs(struct wl1271 *wl)wl1271_debug (DEBUG_BOOT ,"nvs burst write 0x%x: 0x%x" , dest_addr, val); -wl1271_write32 (wl, dest_addr, val); + ret =wlcore_write32 (wl, dest_addr, val); +if (ret <0 ) +return ret; nvs_ptr +=4 ; dest_addr +=4 ;
@@ -346,7 +352,9 @@ int wlcore_boot_upload_nvs(struct wl1271 *wl) nvs_len -= nvs_ptr - (u8 *)wl->nvs;/* Now we must set the partition correctly */ -wlcore_set_partition (wl, &wl->ptable[PART_WORK ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_WORK ]); +if (ret <0 ) +return ret;/* Copy the NVS tables to a new block to ensure alignment */ nvs_aligned =kmemdup (nvs_ptr, nvs_len,GFP_KERNEL );
@@ -372,7 +380,9 @@ int wlcore_boot_run_firmware(struct wl1271 *wl)u32 chip_id, intr;/* Make sure we have the boot partition */ -wlcore_set_partition (wl, &wl->ptable[PART_BOOT ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_BOOT ]); +if (ret <0 ) +return ret; ret =wl1271_boot_set_ecpu_ctrl (wl,ECPU_CONTROL_HALT );if (ret <0 )
@@ -404,8 +414,10 @@ int wlcore_boot_run_firmware(struct wl1271 *wl) }/* check that ACX_INTR_INIT_COMPLETE is enabled */ else if (intr &WL1271_ACX_INTR_INIT_COMPLETE ) { -wlcore_write_reg (wl,REG_INTERRUPT_ACK , -WL1271_ACX_INTR_INIT_COMPLETE ); + ret =wlcore_write_reg (wl,REG_INTERRUPT_ACK , +WL1271_ACX_INTR_INIT_COMPLETE ); +if (ret <0 ) +return ret;break ; } }
@@ -469,9 +481,9 @@ int wlcore_boot_run_firmware(struct wl1271 *wl) }/* set the working partition to its "running" mode offset */ -wlcore_set_partition (wl, &wl->ptable[PART_WORK ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_WORK ]);/* firmware startup completed */ -return 0 ; +return ret; }EXPORT_SYMBOL_GPL (wlcore_boot_run_firmware);
drivers/net/wireless/ti/wlcore/cmd.c +5 -1
@@ -116,7 +116,11 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len, goto fail; } -wlcore_write_reg (wl,REG_INTERRUPT_ACK ,WL1271_ACX_INTR_CMD_COMPLETE ); + ret =wlcore_write_reg (wl,REG_INTERRUPT_ACK , +WL1271_ACX_INTR_CMD_COMPLETE ); +if (ret <0 ) + goto fail; +return 0 ; fail:
drivers/net/wireless/ti/wlcore/event.c +2 -2
@@ -318,7 +318,7 @@ int wl1271_event_handle(struct wl1271 *wl, u8 mbox_num)* TODO: we just need this because one bit is in a different * place. Is there any better way? */ - wl->ops->ack_event (wl); + ret = wl->ops->ack_event (wl); -return 0 ; +return ret; }
drivers/net/wireless/ti/wlcore/io.c +32 -17
69 lines not on this page · raw message
drivers/net/wireless/ti/wlcore/io.h +11 -11
@@ -92,11 +92,11 @@ static inline int wlcore_raw_read32(struct wl1271 *wl, int addr, u32 *val)return 0 ; } -static inline void wl1271_raw_write32 (struct wl1271 *wl,int addr,u32 val) +static inline int wlcore_raw_write32 (struct wl1271 *wl,int addr,u32 val) { wl->buffer_32 =cpu_to_le32 (val); -wlcore_raw_write (wl, addr, &wl->buffer_32, -sizeof (wl->buffer_32), false); +return wlcore_raw_write (wl, addr, &wl->buffer_32, +sizeof (wl->buffer_32), false); } static inline int wlcore_read(struct wl1271 *wl, int addr, void *buf,
@@ -150,9 +150,9 @@ static inline int wlcore_read32(struct wl1271 *wl, int addr, u32 *val)return wlcore_raw_read32 (wl,wlcore_translate_addr (wl, addr), val); } -static inline void wl1271_write32 (struct wl1271 *wl,int addr,u32 val) +static inline int wlcore_write32 (struct wl1271 *wl,int addr,u32 val) { -wl1271_raw_write32 (wl,wlcore_translate_addr (wl, addr), val); +return wlcore_raw_write32 (wl,wlcore_translate_addr (wl, addr), val); }static inline int wlcore_read_reg (struct wl1271 *wl,int reg,u32 *val)
@@ -162,9 +162,11 @@ static inline int wlcore_read_reg(struct wl1271 *wl, int reg, u32 *val) val); } -static inline void wlcore_write_reg (struct wl1271 *wl,int reg,u32 val) +static inline int wlcore_write_reg (struct wl1271 *wl,int reg,u32 val) { -wl1271_raw_write32 (wl,wlcore_translate_addr (wl, wl->rtable[reg]), val); +return wlcore_raw_write32 (wl, +wlcore_translate_addr (wl, wl->rtable[reg]), + val); }static inline void wl1271_power_off (struct wl1271 *wl)
@@ -188,8 +190,8 @@ static inline int wl1271_power_on(struct wl1271 *wl)return ret; } -void wlcore_set_partition (struct wl1271 *wl, -const struct wlcore_partition_set *p); +int wlcore_set_partition (struct wl1271 *wl, +const struct wlcore_partition_set *p);bool wl1271_set_block_size (struct wl1271 *wl);
@@ -197,6 +199,4 @@ bool wl1271_set_block_size(struct wl1271 *wl);int wl1271_tx_dummy_packet (struct wl1271 *wl); -void wlcore_select_partition (struct wl1271 *wl,u8 part); -#endif
drivers/net/wireless/ti/wlcore/main.c +15 -5
@@ -882,7 +882,9 @@ static void wlcore_print_recovery(struct wl1271 *wl) wl->chip.fw_ver_str);/* change partitions momentarily so we can read the FW pc */ -wlcore_set_partition (wl, &wl->ptable[PART_BOOT ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_BOOT ]); +if (ret <0 ) +return ; ret =wlcore_read_reg (wl,REG_PC_ON_RECOVERY , &pc);if (ret <0 )
@@ -967,9 +969,9 @@ out_unlock:mutex_unlock (&wl->mutex); } -static void wl1271_fw_wakeup (struct wl1271 *wl) +static int wlcore_fw_wakeup (struct wl1271 *wl) { -wl1271_raw_write32 (wl,HW_ACCESS_ELP_CTRL_REG ,ELPCTRL_WAKE_UP ); +return wlcore_raw_write32 (wl,HW_ACCESS_ELP_CTRL_REG ,ELPCTRL_WAKE_UP ); }static int wl1271_setup (struct wl1271 *wl)
@@ -1005,13 +1007,21 @@ static int wl12xx_set_power_on(struct wl1271 *wl)wl1271_io_reset (wl);wl1271_io_init (wl); -wlcore_set_partition (wl, &wl->ptable[PART_BOOT ]); + ret =wlcore_set_partition (wl, &wl->ptable[PART_BOOT ]); +if (ret <0 ) + goto fail;/* ELP module wake up */ -wl1271_fw_wakeup (wl); + ret =wlcore_fw_wakeup (wl); +if (ret <0 ) + goto fail; out:return ret; + +fail: +wl1271_power_off (wl); +return ret; }static int wl12xx_chip_wakeup (struct wl1271 *wl,bool plt)
drivers/net/wireless/ti/wlcore/ps.c +12 -2
@@ -35,6 +35,7 @@ void wl1271_elp_work(struct work_struct *work)struct delayed_work *dwork;struct wl1271 *wl;struct wl12xx_vif *wlvif; +int ret; dwork = container_of(work, struct delayed_work, work); wl = container_of(dwork, struct wl1271, elp_work);
@@ -63,7 +64,12 @@ void wl1271_elp_work(struct work_struct *work) }wl1271_debug (DEBUG_PSM ,"chip to elp" ); -wl1271_raw_write32 (wl,HW_ACCESS_ELP_CTRL_REG ,ELPCTRL_SLEEP ); + ret =wlcore_raw_write32 (wl,HW_ACCESS_ELP_CTRL_REG ,ELPCTRL_SLEEP ); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto out; + } +set_bit (WL1271_FLAG_IN_ELP , &wl->flags); out:
@@ -135,7 +141,11 @@ int wl1271_ps_elp_wakeup(struct wl1271 *wl) wl->elp_compl = &compl;spin_unlock_irqrestore (&wl->wl_lock, flags); -wl1271_raw_write32 (wl,HW_ACCESS_ELP_CTRL_REG ,ELPCTRL_WAKE_UP ); + ret =wlcore_raw_write32 (wl,HW_ACCESS_ELP_CTRL_REG ,ELPCTRL_WAKE_UP ); +if (ret <0 ) { +wl12xx_queue_recovery_work (wl); + goto err; + }if (!pending) { ret = wait_for_completion_timeout(
drivers/net/wireless/ti/wlcore/rx.c +6 -3
@@ -279,9 +279,12 @@ int wlcore_rx(struct wl1271 *wl, struct wl_fw_status_1 *status)* Write the driver's packet counter to the FW. This is only required * for older hardware revisions */ -if (wl->quirks &WLCORE_QUIRK_END_OF_TRANSACTION ) -wl1271_write32 (wl,WL12XX_REG_RX_DRIVER_COUNTER , - wl->rx_counter); +if (wl->quirks &WLCORE_QUIRK_END_OF_TRANSACTION ) { + ret =wlcore_write32 (wl,WL12XX_REG_RX_DRIVER_COUNTER , + wl->rx_counter); +if (ret <0 ) + goto out; + }wl12xx_rearm_rx_streaming (wl, active_hlids);
drivers/net/wireless/ti/wlcore/tx.c +11 -6
@@ -746,9 +746,12 @@ out_ack:* Interrupt the firmware with the new packets. This is only * required for older hardware revisions */ -if (wl->quirks &WLCORE_QUIRK_END_OF_TRANSACTION ) -wl1271_write32 (wl,WL12XX_HOST_WR_ACCESS , - wl->tx_packets_count); +if (wl->quirks &WLCORE_QUIRK_END_OF_TRANSACTION ) { + ret =wlcore_write32 (wl,WL12XX_HOST_WR_ACCESS , + wl->tx_packets_count); +if (ret <0 ) + goto out; + }wl1271_handle_tx_low_watermark (wl); }
@@ -911,9 +914,11 @@ int wlcore_tx_complete(struct wl1271 *wl) fw_counter =le32_to_cpu (wl->tx_res_if->tx_result_fw_counter);/* write host counter to chipset (to ack) */ -wl1271_write32 (wl,le32_to_cpu (memmap->tx_result) + - offsetof(struct wl1271_tx_hw_res_if , - tx_result_host_counter), fw_counter); + ret =wlcore_write32 (wl,le32_to_cpu (memmap->tx_result) + + offsetof(struct wl1271_tx_hw_res_if , + tx_result_host_counter), fw_counter); +if (ret <0 ) + goto out; count = fw_counter - wl->tx_results_count;wl1271_debug (DEBUG_TX ,"tx_complete received, packets: %d" , count);
drivers/net/wireless/ti/wlcore/wlcore.h +1 -1
@@ -43,7 +43,7 @@ struct wlcore_ops {int (*plt_init)(struct wl1271 *wl);int (*trigger_cmd)(struct wl1271 *wl,int cmd_box_addr,void *buf,size_t len); -void (*ack_event)(struct wl1271 *wl); +int (*ack_event)(struct wl1271 *wl);u32 (*calc_tx_blocks)(struct wl1271 *wl,u32 len,u32 spare_blks); void (*set_tx_desc_blocks)(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
Signature · 1 line
1.7.10
PATCH 10/18 wlcore: Propagate errors from wl1271_read_hwaddr
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
Propagate errors from wl1271_read_hwaddr. This function is only used when reading the FW log (following a recovery), so don't read the FW log in case of a bus error.
Also rename prefixes of wlcore functions which their prototypes had to be changed.
--- drivers/net/wireless/ti/wlcore/io.h | 4 ++-- drivers/net/wireless/ti/wlcore/main.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/ti/wlcore/io.h +2 -2
@@ -131,7 +131,7 @@ static inline int wlcore_read_data(struct wl1271 *wl, int reg, void *buf,return wlcore_read (wl, wl->rtable[reg], buf, len, fixed); } -static inline void wl1271_read_hwaddr (struct wl1271 *wl,int hwaddr, +static inline int wlcore_read_hwaddr (struct wl1271 *wl,int hwaddr,void *buf,size_t len,bool fixed) {int physical;
@@ -142,7 +142,7 @@ static inline void wl1271_read_hwaddr(struct wl1271 *wl, int hwaddr, physical =wlcore_translate_addr (wl, addr); -wlcore_raw_read (wl, physical, buf, len, fixed); +return wlcore_raw_read (wl, physical, buf, len, fixed); }static inline int wlcore_read32 (struct wl1271 *wl,int addr,u32 *val)
drivers/net/wireless/ti/wlcore/main.c +4 -2
@@ -851,8 +851,10 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)/* Traverse the memory blocks linked list */ do { memset(block, 0, WL12XX_HW_BLOCK_SIZE); - wl1271_read_hwaddr(wl, addr, block, WL12XX_HW_BLOCK_SIZE, - false); + ret = wlcore_read_hwaddr(wl, addr, block, WL12XX_HW_BLOCK_SIZE, + false); + if (ret < 0) + goto out; /* * Memory blocks are linked to one another. The first 4 bytes
Signature · 1 line
1.7.10
PATCH 11/18 wlcore: Force checking of io functions' return values
In reply to Luciano CoelhoFrom: Ido Yariv <[email protected]>
All io functions' return values should be propagated and handled. Add a __must_check annotation to verify that the return values are checked and to avoid future mistakes.
--- drivers/net/wireless/ti/wl12xx/main.c | 6 ++- drivers/net/wireless/ti/wl18xx/io.h | 4 +- drivers/net/wireless/ti/wlcore/io.h | 61 +++++++++++++++++------------ drivers/net/wireless/ti/wlcore/sdio.c | 8 ++-- drivers/net/wireless/ti/wlcore/spi.c | 8 ++-- drivers/net/wireless/ti/wlcore/wlcore_i.h | 8 ++-- 6 files changed, 55 insertions(+), 40 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +4 -2
@@ -688,7 +688,8 @@ out:return ret; } -static int wl12xx_top_reg_write (struct wl1271 *wl,int addr,u16 val) +static int __must_check wl12xx_top_reg_write (struct wl1271 *wl,int addr, +u16 val) {int ret;
@@ -712,7 +713,8 @@ out:return ret; } -static int wl12xx_top_reg_read (struct wl1271 *wl,int addr,u16 *out) +static int __must_check wl12xx_top_reg_read (struct wl1271 *wl,int addr, +u16 *out) {u32 val;int timeout =OCP_CMD_LOOP ;
drivers/net/wireless/ti/wl18xx/io.h +2 -2
@@ -22,7 +22,7 @@#ifndef __WL18XX_IO_H__#define __WL18XX_IO_H__ -int wl18xx_top_reg_write (struct wl1271 *wl,int addr,u16 val); -int wl18xx_top_reg_read (struct wl1271 *wl,int addr,u16 *out); +int __must_check wl18xx_top_reg_write (struct wl1271 *wl,int addr,u16 val); +int __must_check wl18xx_top_reg_read (struct wl1271 *wl,int addr,u16 *out);#endif /* __WL18XX_IO_H__ */
drivers/net/wireless/ti/wlcore/io.h +37 -24
135 lines not on this page · raw message
drivers/net/wireless/ti/wlcore/sdio.c +4 -4
@@ -71,8 +71,8 @@ static void wl1271_sdio_set_block_size(struct device *child,sdio_release_host (func); } -static int wl12xx_sdio_raw_read (struct device *child,int addr,void *buf, -size_t len,bool fixed) +static int __must_check wl12xx_sdio_raw_read (struct device *child,int addr, +void *buf,size_t len,bool fixed) {int ret;struct wl12xx_sdio_glue *glue =dev_get_drvdata (child->parent);
@@ -109,8 +109,8 @@ static int wl12xx_sdio_raw_read(struct device *child, int addr, void *buf,return ret; } -static int wl12xx_sdio_raw_write (struct device *child,int addr,void *buf, -size_t len,bool fixed) +static int __must_check wl12xx_sdio_raw_write (struct device *child,int addr, +void *buf,size_t len,bool fixed) {int ret;struct wl12xx_sdio_glue *glue =dev_get_drvdata (child->parent);
drivers/net/wireless/ti/wlcore/spi.c +4 -4
@@ -193,8 +193,8 @@ static int wl12xx_spi_read_busy(struct device *child)return -ETIMEDOUT ; } -static int wl12xx_spi_raw_read (struct device *child,int addr,void *buf, -size_t len,bool fixed) +static int __must_check wl12xx_spi_raw_read (struct device *child,int addr, +void *buf,size_t len,bool fixed) {struct wl12xx_spi_glue *glue =dev_get_drvdata (child->parent);struct wl1271 *wl =dev_get_drvdata (child);
@@ -260,8 +260,8 @@ static int wl12xx_spi_raw_read(struct device *child, int addr, void *buf,return 0 ; } -static int wl12xx_spi_raw_write (struct device *child,int addr,void *buf, -size_t len,bool fixed) +static int __must_check wl12xx_spi_raw_write (struct device *child,int addr, +void *buf,size_t len,bool fixed) {struct wl12xx_spi_glue *glue =dev_get_drvdata (child->parent);struct spi_transfer t[2 *WSPI_MAX_NUM_OF_CHUNKS ];
drivers/net/wireless/ti/wlcore/wlcore_i.h +4 -4
@@ -209,10 +209,10 @@ struct wl1271_scan { };struct wl1271_if_operations { -int (*read)(struct device *child,int addr,void *buf,size_t len, -bool fixed); -int (*write)(struct device *child,int addr,void *buf,size_t len, -bool fixed); +int __must_check (*read)(struct device *child,int addr,void *buf, +size_t len,bool fixed); +int __must_check (*write)(struct device *child,int addr,void *buf, +size_t len,bool fixed);void (*reset)(struct device *child);void (*init)(struct device *child);int (*power)(struct device *child,bool enable);
Signature · 1 line
1.7.10
PATCH 12/18 wlcore: access the firmware memory via debugfs
In reply to Luciano CoelhoFrom: Arkady Miasnikov <[email protected]>
Applications running in the user space needs access to the memory of the chip. Examples of such access
- read/write global variables
- access to firmware log
- dump memory after firmware panic event
Arbitrary 4-bytes aligned location can be accessed by read/write file wlcore/mem
[Check return value of wlcore_raw_read/write and wlcore_set_partition calls as required by the recent IO changes. -- Luca]
--- drivers/net/wireless/ti/wlcore/debugfs.c | 192 ++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+)
drivers/net/wireless/ti/wlcore/debugfs.c +192 -0
@@ -38,6 +38,8 @@/* ms */ #define WL1271_DEBUGFS_STATS_LIFETIME 1000 +#define WLCORE_MAX_BLOCK_SIZE ((size_t)(4*PAGE_SIZE)) +/* debugfs macros idea from mac80211 */ int wl1271_format_buffer (char __user *userbuf,size_t count,loff_t *ppos,char *fmt, ...)
@@ -1025,6 +1027,195 @@ static const struct file_operations sleep_auth_ops = { .llseek = default_llseek, }; +static ssize_t dev_mem_read (struct file *file, +char __user *user_buf,size_t count, +loff_t *ppos) +{ +struct wl1271 *wl = file->private_data; +struct wlcore_partition_set part, old_part; +size_t bytes = count; +int ret; +char *buf; + +/* only requests of dword-aligned size and offset are supported */ +if (bytes %4 ) +return -EINVAL ; + +if (*ppos %4 ) +return -EINVAL ; + +/* function should return in reasonable time */ + bytes =min (bytes,WLCORE_MAX_BLOCK_SIZE ); + +if (bytes ==0 ) +return -EINVAL ; + +memset (&part,0 ,sizeof (part)); + part.mem.start = file->f_pos; + part.mem.size = bytes; + + buf =kmalloc (bytes,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +mutex_lock (&wl->mutex); + +if (wl->state ==WL1271_STATE_OFF ) { + ret = -EFAULT ; + goto skip_read; + } + + ret =wl1271_ps_elp_wakeup (wl); +if (ret <0 ) + goto skip_read; + +/* store current partition and switch partition */ +memcpy (&old_part, &wl->curr_part,sizeof (old_part)); + ret =wlcore_set_partition (wl, &part); +if (ret <0 ) + goto part_err; + + ret =wlcore_raw_read (wl,0 , buf, bytes, false); +if (ret <0 ) + goto read_err; + +read_err: +/* recover partition */ + ret =wlcore_set_partition (wl, &old_part); +if (ret <0 ) + goto part_err; + +part_err: +wl1271_ps_elp_sleep (wl); + +skip_read: +mutex_unlock (&wl->mutex); + +if (ret ==0 ) { + ret =copy_to_user (user_buf, buf, bytes); +if (ret < bytes) { + bytes -= ret; + *ppos += bytes; + ret =0 ; + }else { + ret = -EFAULT ; + } + } + +kfree (buf); + +return ((ret ==0 ) ? bytes : ret); +} + +static ssize_t dev_mem_write (struct file *file,const char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct wl1271 *wl = file->private_data; +struct wlcore_partition_set part, old_part; +size_t bytes = count; +int ret; +char *buf; + +/* only requests of dword-aligned size and offset are supported */ +if (bytes %4 ) +return -EINVAL ; + +if (*ppos %4 ) +return -EINVAL ; + +/* function should return in reasonable time */ + bytes =min (bytes,WLCORE_MAX_BLOCK_SIZE ); + +if (bytes ==0 ) +return -EINVAL ; + +memset (&part,0 ,sizeof (part)); + part.mem.start = file->f_pos; + part.mem.size = bytes; + + buf =kmalloc (bytes,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + ret =copy_from_user (buf, user_buf, bytes); +if (ret) { + ret = -EFAULT ; + goto err_out; + } + +mutex_lock (&wl->mutex); + +if (wl->state ==WL1271_STATE_OFF ) { + ret = -EFAULT ; + goto skip_write; + } + + ret =wl1271_ps_elp_wakeup (wl); +if (ret <0 ) + goto skip_write; + +/* store current partition and switch partition */ +memcpy (&old_part, &wl->curr_part,sizeof (old_part)); + ret =wlcore_set_partition (wl, &part); +if (ret <0 ) + goto part_err; + + ret =wlcore_raw_write (wl,0 , buf, bytes, false); +if (ret <0 ) + goto write_err; + +write_err: +/* recover partition */ + ret =wlcore_set_partition (wl, &old_part); +if (ret <0 ) + goto part_err; + +part_err: +wl1271_ps_elp_sleep (wl); + +skip_write: +mutex_unlock (&wl->mutex); + +if (ret ==0 ) + *ppos += bytes; + +err_out: +kfree (buf); + +return ((ret ==0 ) ? bytes : ret); +} + +static loff_t dev_mem_seek (struct file *file,loff_t offset,int orig) +{ +loff_t ret; + +/* only requests of dword-aligned size and offset are supported */ +if (offset %4 ) +return -EINVAL ; + +switch (orig) { +case SEEK_SET : + file->f_pos = offset; + ret = file->f_pos; +break ; +case SEEK_CUR : + file->f_pos += offset; + ret = file->f_pos; +break ; +default : + ret = -EINVAL ; + } + +return ret; +} + +static const struct file_operations dev_mem_ops = { + .open = simple_open, + .read = dev_mem_read, + .write = dev_mem_write, + .llseek = dev_mem_seek, +}; +static int wl1271_debugfs_add_files (struct wl1271 *wl,struct dentry *rootdir) {
@@ -1059,6 +1250,7 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl,DEBUGFS_ADD_PREFIX (rx_streaming, interval, streaming);DEBUGFS_ADD_PREFIX (rx_streaming, always, streaming); +DEBUGFS_ADD_PREFIX (dev, mem, rootdir);return 0 ;
Signature · 1 line
1.7.10
PATCH 13/18 wlcore: cancel suspend when recovery is pending
In reply to Luciano CoelhoFrom: Arik Nemtsov <[email protected]>
We wish to postpone suspend if recovery is pending. This will make sure the FW is in a good state and perform wowlan wakeup.
--- drivers/net/wireless/ti/wlcore/main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/ti/wlcore/main.c +6 -0
@@ -1661,6 +1661,12 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,wl1271_debug (DEBUG_MAC80211 ,"mac80211 suspend wow=%d" , !!wow);WARN_ON (!wow); +/* we want to perform the recovery before suspending */ +if (test_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , &wl->flags)) { +wl1271_warning ("postponing suspend to perform recovery" ); +return -EBUSY ; + } +wl1271_tx_flush (wl);mutex_lock (&wl->mutex);
Signature · 1 line
1.7.10
PATCH 14/18 wlcore: don't allow SDIO read/writes after failure
In reply to Luciano CoelhoFrom: Arik Nemtsov <[email protected]>
Set a flag and after the first read/write failure is encountered. This flag will disallow further SDIO read/writes until op_stop() is executed, which will clear all flags.
This prevents further errors from occurring, since one error usually indicates that IO operations won't work anymore until the chip is rebooted. By blocking more calls, we avoid extra timeouts and having to wait for them to occur.
[Added second paragraph explaining why the change is needed. -- Luca]
--- drivers/net/wireless/ti/wlcore/io.h | 22 ++++++++++++++++++++-- drivers/net/wireless/ti/wlcore/wlcore_i.h | 1 + 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/net/wireless/ti/wlcore/io.h +20 -2
@@ -57,14 +57,32 @@ static inline int __must_check wlcore_raw_write(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { - return wl->if_ops->write(wl->dev, addr, buf, len, fixed); + int ret; + +if (test_bit (WL1271_FLAG_SDIO_FAILED , &wl->flags)) +return -EIO ; + + ret = wl->if_ops->write (wl->dev, addr, buf, len, fixed); +if (ret) +set_bit (WL1271_FLAG_SDIO_FAILED , &wl->flags); + +return ret; }static inline int __must_check wlcore_raw_read (struct wl1271 *wl,int addr,void *buf,size_t len,bool fixed) { -return wl->if_ops->read (wl->dev, addr, buf, len, fixed); +int ret; + +if (test_bit (WL1271_FLAG_SDIO_FAILED , &wl->flags)) +return -EIO ; + + ret = wl->if_ops->read (wl->dev, addr, buf, len, fixed); +if (ret) +set_bit (WL1271_FLAG_SDIO_FAILED , &wl->flags); + +return ret; } static inline int __must_check wlcore_raw_read_data(struct wl1271 *wl, int reg,
drivers/net/wireless/ti/wlcore/wlcore_i.h +1 -0
@@ -247,6 +247,7 @@ enum wl12xx_flags {WL1271_FLAG_RECOVERY_IN_PROGRESS ,WL1271_FLAG_VIF_CHANGE_IN_PROGRESS ,WL1271_FLAG_INTENDED_FW_RECOVERY , + WL1271_FLAG_SDIO_FAILED, }; enum wl12xx_vif_flags {
Signature · 1 line
1.7.10
PATCH 15/18 wlcore: force recovery on resume if suspended without recovering
In reply to Luciano CoelhoFrom: Arik Nemtsov <[email protected]>
If an error is detected after mac80211 is already suspended, the recovery work will not be queued. This will leave the driver in a bad state on resume.
Detect this in the resume op and re-queue a recovery.
--- drivers/net/wireless/ti/wlcore/main.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/net/wireless/ti/wlcore/main.c +18 -2
@@ -1707,7 +1707,7 @@ static int wl1271_op_resume(struct ieee80211_hw *hw)struct wl1271 *wl = hw->priv;struct wl12xx_vif *wlvif;unsigned long flags; -bool run_irq_work = false; +bool run_irq_work = false, pending_recovery;wl1271_debug (DEBUG_MAC80211 ,"mac80211 resume wow=%d" , wl->wow_enabled);
@@ -1723,17 +1723,33 @@ static int wl1271_op_resume(struct ieee80211_hw *hw) run_irq_work = true;spin_unlock_irqrestore (&wl->wl_lock, flags); +/* test the recovery flag before calling any SDIO functions */ + pending_recovery =test_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , + &wl->flags); +if (run_irq_work) {wl1271_debug (DEBUG_MAC80211 ,"run postponed irq_work directly" ); -wl1271_irq (0 , wl); + +/* don't talk to the HW if recovery is pending */ +if (!pending_recovery) +wl1271_irq (0 , wl); +wlcore_enable_interrupts (wl); }mutex_lock (&wl->mutex); +if (pending_recovery) { +wl1271_warning ("queuing forgotten recovery on resume" ); +ieee80211_queue_work (wl->hw, &wl->recovery_work); + goto out; + } +wl12xx_for_each_wlvif (wl, wlvif) {wl1271_configure_resume (wl, wlvif); } + +out: wl->wow_enabled = false;mutex_unlock (&wl->mutex);
Signature · 1 line
1.7.10
PATCH 16/18 wlcore: check Rx-filter functions in the suspend path
In reply to Luciano CoelhoFrom: Arik Nemtsov <[email protected]>
Propagate some missing return values for Rx-filter related functions. This and makes sure we always fail the suspend in case of SDIO errors.
--- drivers/net/wireless/ti/wlcore/main.c | 27 +++++++++++++++++++++------ drivers/net/wireless/ti/wlcore/rx.c | 11 ++++++++--- drivers/net/wireless/ti/wlcore/rx.h | 2 +- 3 files changed, 30 insertions(+), 10 deletions(-)
drivers/net/wireless/ti/wlcore/main.c +21 -6
@@ -1513,8 +1513,15 @@ static int wl1271_configure_wowlan(struct wl1271 *wl,int i, ret;if (!wow || wow->any || !wow->n_patterns) { -wl1271_acx_default_rx_filter_enable (wl,0 ,FILTER_SIGNAL ); -wl1271_rx_filter_clear_all (wl); + ret =wl1271_acx_default_rx_filter_enable (wl,0 , +FILTER_SIGNAL ); +if (ret) + goto out; + + ret =wl1271_rx_filter_clear_all (wl); +if (ret) + goto out; +return 0 ; }
@@ -1530,8 +1537,13 @@ static int wl1271_configure_wowlan(struct wl1271 *wl, } } -wl1271_acx_default_rx_filter_enable (wl,0 ,FILTER_SIGNAL ); -wl1271_rx_filter_clear_all (wl); + ret =wl1271_acx_default_rx_filter_enable (wl,0 ,FILTER_SIGNAL ); +if (ret) + goto out; + + ret =wl1271_rx_filter_clear_all (wl); +if (ret) + goto out;/* Translate WoWLAN patterns into filters */ for (i =0 ; i < wow->n_patterns; i++) {
@@ -1573,7 +1585,10 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl,if (ret <0 ) goto out; -wl1271_configure_wowlan (wl, wow); + ret =wl1271_configure_wowlan (wl, wow); +if (ret <0 ) + goto out_sleep; + ret =wl1271_acx_wake_up_conditions (wl, wlvif, wl->conf.conn.suspend_wake_up_event, wl->conf.conn.suspend_listen_interval);
@@ -1581,8 +1596,8 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl,if (ret <0 )wl1271_error ("suspend: set wake up conditions failed: %d" , ret); +out_sleep:wl1271_ps_elp_sleep (wl); - out:return ret;
drivers/net/wireless/ti/wlcore/rx.c +8 -3
@@ -318,14 +318,19 @@ int wl1271_rx_filter_enable(struct wl1271 *wl, return 0; } -void wl1271_rx_filter_clear_all (struct wl1271 *wl) +int wl1271_rx_filter_clear_all (struct wl1271 *wl) { -int i; +int i, ret =0 ;for (i =0 ; i <WL1271_MAX_RX_FILTERS ; i++) {if (!wl->rx_filter_enabled[i])continue ; -wl1271_rx_filter_enable (wl, i,0 ,NULL ); + ret =wl1271_rx_filter_enable (wl, i,0 ,NULL ); +if (ret) + goto out; } + +out: +return ret; }#endif /* CONFIG_PM */
drivers/net/wireless/ti/wlcore/rx.h +1 -1
@@ -148,6 +148,6 @@ u8 wl1271_rate_to_idx(int rate, enum ieee80211_band band);int wl1271_rx_filter_enable (struct wl1271 *wl,int index,bool enable,struct wl12xx_rx_filter *filter); -void wl1271_rx_filter_clear_all (struct wl1271 *wl); +int wl1271_rx_filter_clear_all (struct wl1271 *wl);#endif
Signature · 1 line
1.7.10
PATCH 17/18 wlcore: refactor threaded IRQ routine
In reply to Luciano CoelhoFrom: Arik Nemtsov <[email protected]>
Separate the threaded IRQ handling routine into two functions. The outer function takes the mutex and calls recovery on errors. It also performs a Tx-path optimization to avoid redundant works.
The inner function is simplified - all calls to recovery are removed and it assumes the lock is taken. The locked variant will be reused elsewhere.
--- drivers/net/wireless/ti/wlcore/main.c | 62 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-)
drivers/net/wireless/ti/wlcore/main.c +31 -31
@@ -494,20 +494,15 @@ static void wl1271_netstack_work(struct work_struct *work)#define WL1271_IRQ_MAX_LOOPS 256 -static irqreturn_t wl1271_irq (int irq,void *cookie) +static int wlcore_irq_locked (struct wl1271 *wl) { -int ret; +int ret =0 ;u32 intr;int loopcount =WL1271_IRQ_MAX_LOOPS ; -struct wl1271 *wl = (struct wl1271 *)cookie;bool done = false;unsigned int defer_count;unsigned long flags; -/* TX might be handled here, avoid redundant work */ -set_bit (WL1271_FLAG_TX_PENDING , &wl->flags); -cancel_work_sync (&wl->tx_work); -/* * In case edge triggered interrupt must be used, we cannot iterate * more than once without introducing race conditions with the hardirq.
@@ -515,8 +510,6 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)if (wl->platform_quirks &WL12XX_PLATFORM_QUIRK_EDGE_IRQ ) loopcount =1 ; -mutex_lock (&wl->mutex); -wl1271_debug (DEBUG_IRQ ,"IRQ work" );if (unlikely (wl->state ==WL1271_STATE_OFF ))
@@ -536,10 +529,8 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)smp_mb__after_clear_bit (); ret =wlcore_fw_status (wl, wl->fw_status_1, wl->fw_status_2); -if (ret <0 ) { -wl12xx_queue_recovery_work (wl); +if (ret <0 ) goto out; - }wlcore_hw_tx_immediate_compl (wl);
@@ -553,7 +544,7 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)if (unlikely (intr &WL1271_ACX_INTR_WATCHDOG )) {wl1271_error ("HW watchdog interrupt received! starting recovery." ); wl->watchdog_recovery = true; -wl12xx_queue_recovery_work (wl); + ret = -EIO ;/* restarting the chip. ignore any other interrupt. */ goto out;
@@ -563,7 +554,7 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)wl1271_error ("SW watchdog interrupt received! " "starting recovery." ); wl->watchdog_recovery = true; -wl12xx_queue_recovery_work (wl); + ret = -EIO ;/* restarting the chip. ignore any other interrupt. */ goto out;
@@ -573,10 +564,8 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)wl1271_debug (DEBUG_IRQ ,"WL1271_ACX_INTR_DATA" ); ret =wlcore_rx (wl, wl->fw_status_1); -if (ret <0 ) { -wl12xx_queue_recovery_work (wl); +if (ret <0 ) goto out; - }/* Check if any tx blocks were freed */ spin_lock_irqsave (&wl->wl_lock, flags);
@@ -588,20 +577,16 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)* call the work function directly. */ ret =wlcore_tx_work_locked (wl); -if (ret <0 ) { -wl12xx_queue_recovery_work (wl); +if (ret <0 ) goto out; - } }else {spin_unlock_irqrestore (&wl->wl_lock, flags); }/* check for tx results */ ret =wlcore_hw_tx_delayed_compl (wl); -if (ret <0 ) { -wl12xx_queue_recovery_work (wl); +if (ret <0 ) goto out; - }/* Make sure the deferred queues don't get too long */ defer_count = skb_queue_len(&wl->deferred_tx_queue) +
@@ -613,19 +598,15 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)if (intr &WL1271_ACX_INTR_EVENT_A ) {wl1271_debug (DEBUG_IRQ ,"WL1271_ACX_INTR_EVENT_A" ); ret =wl1271_event_handle (wl,0 ); -if (ret <0 ) { -wl12xx_queue_recovery_work (wl); +if (ret <0 ) goto out; - } }if (intr &WL1271_ACX_INTR_EVENT_B ) {wl1271_debug (DEBUG_IRQ ,"WL1271_ACX_INTR_EVENT_B" ); ret =wl1271_event_handle (wl,1 ); -if (ret <0 ) { -wl12xx_queue_recovery_work (wl); +if (ret <0 ) goto out; - } }if (intr &WL1271_ACX_INTR_INIT_COMPLETE )
@@ -639,6 +620,25 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)wl1271_ps_elp_sleep (wl); out: +return ret; +} + +static irqreturn_t wlcore_irq (int irq,void *cookie) +{ +int ret; +unsigned long flags; +struct wl1271 *wl = cookie; + +/* TX might be handled here, avoid redundant work */ +set_bit (WL1271_FLAG_TX_PENDING , &wl->flags); +cancel_work_sync (&wl->tx_work); + +mutex_lock (&wl->mutex); + + ret =wlcore_irq_locked (wl); +if (ret) +wl12xx_queue_recovery_work (wl); +spin_lock_irqsave (&wl->wl_lock, flags);/* In case TX was not handled here, queue TX work */ clear_bit (WL1271_FLAG_TX_PENDING , &wl->flags);
@@ -1748,7 +1748,7 @@ static int wl1271_op_resume(struct ieee80211_hw *hw)/* don't talk to the HW if recovery is pending */ if (!pending_recovery) -wl1271_irq (0 , wl); +wlcore_irq (0 , wl);wlcore_enable_interrupts (wl); }
@@ -5489,7 +5489,7 @@ int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)else irqflags =IRQF_TRIGGER_HIGH |IRQF_ONESHOT ; - ret =request_threaded_irq (wl->irq, wl12xx_hardirq, wl1271_irq, + ret =request_threaded_irq (wl->irq, wl12xx_hardirq, wlcore_irq, irqflags, pdev->name, wl);if (ret <0 ) {
Signature · 1 line
1.7.10
PATCH 18/18 wlcore: prevent recovery in the middle of resume
In reply to Luciano CoelhoFrom: Arik Nemtsov <[email protected]>
Take the mutex early in the resume handler and use the locked version of the IRQ routine. This ensures any recoveries queued will only take place after resume has fully completed.
--- drivers/net/wireless/ti/wlcore/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/wireless/ti/wlcore/main.c +8 -3
@@ -1723,6 +1723,7 @@ static int wl1271_op_resume(struct ieee80211_hw *hw)struct wl12xx_vif *wlvif;unsigned long flags;bool run_irq_work = false, pending_recovery; +int ret;wl1271_debug (DEBUG_MAC80211 ,"mac80211 resume wow=%d" , wl->wow_enabled);
@@ -1738,6 +1739,8 @@ static int wl1271_op_resume(struct ieee80211_hw *hw) run_irq_work = true;spin_unlock_irqrestore (&wl->wl_lock, flags); +mutex_lock (&wl->mutex); +/* test the recovery flag before calling any SDIO functions */ pending_recovery =test_bit (WL1271_FLAG_RECOVERY_IN_PROGRESS , &wl->flags);
@@ -1747,13 +1750,15 @@ static int wl1271_op_resume(struct ieee80211_hw *hw) "run postponed irq_work directly");/* don't talk to the HW if recovery is pending */ -if (!pending_recovery) -wlcore_irq (0 , wl); +if (!pending_recovery) { + ret =wlcore_irq_locked (wl); +if (ret) +wl12xx_queue_recovery_work (wl); + }wlcore_enable_interrupts (wl); } -mutex_lock (&wl->mutex);if (pending_recovery) {wl1271_warning ("queuing forgotten recovery on resume" );ieee80211_queue_work (wl->hw, &wl->recovery_work);
Signature · 1 line
1.7.10
Quoted 7 lines · Luciano Coelho
Hi,
This series with patches from Ido and Arik improve the driver's handling of SDIO errors. Ido's series propagates the errors up for better handling and Arik's series ensures that suspend/resume don't get messed up when such errors occur.
Quoted 5 lines
There is also one patch by Arkady (welcome!) that allows the userspace to read/write to the chip's memory directly for firmware debugging purposes.
Please review.
Applied and push this series to wl12xx.git/master.
--
Luca.