Commit 045b9b5f authored by Ido Yariv's avatar Ido Yariv Committed by Luciano Coelho

wlcore: Propagate errors from wl1271_read

Propagate errors from wl1271_read and request for recovery when
appropriate.
Also rename prefixes of wlcore functions which their prototypes had to
be changed.
Signed-off-by: default avatarIdo Yariv <ido@wizery.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent 8b7c0fc3
...@@ -1162,13 +1162,13 @@ static u32 wl12xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data, ...@@ -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; 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 == if (wl->fw_status_1->tx_results_counter ==
(wl->tx_results_count & 0xff)) (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) static int wl12xx_hw_init(struct wl1271 *wl)
......
...@@ -87,7 +87,9 @@ static int wlcore_boot_static_data(struct wl1271 *wl) ...@@ -87,7 +87,9 @@ static int wlcore_boot_static_data(struct wl1271 *wl)
goto out; 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); ret = wlcore_boot_parse_fw_ver(wl, static_data);
if (ret < 0) if (ret < 0)
......
...@@ -95,7 +95,10 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len, ...@@ -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 */ /* read back the status code of the command */
if (res_len == 0) if (res_len == 0)
res_len = sizeof(struct wl1271_cmd_header); 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); status = le16_to_cpu(cmd->status);
if (status != CMD_STATUS_SUCCESS) { if (status != CMD_STATUS_SUCCESS) {
...@@ -141,11 +144,18 @@ static int wl1271_cmd_wait_for_event_or_timeout(struct wl1271 *wl, u32 mask) ...@@ -141,11 +144,18 @@ static int wl1271_cmd_wait_for_event_or_timeout(struct wl1271 *wl, u32 mask)
msleep(1); msleep(1);
/* read from both event fields */ /* read from both event fields */
wl1271_read(wl, wl->mbox_ptr[0], events_vector, ret = wlcore_read(wl, wl->mbox_ptr[0], events_vector,
sizeof(*events_vector), false); sizeof(*events_vector), false);
if (ret < 0)
goto out;
event = *events_vector & mask; 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; event |= *events_vector & mask;
} while (!event); } while (!event);
......
...@@ -301,8 +301,10 @@ int wl1271_event_handle(struct wl1271 *wl, u8 mbox_num) ...@@ -301,8 +301,10 @@ int wl1271_event_handle(struct wl1271 *wl, u8 mbox_num)
return -EINVAL; return -EINVAL;
/* first we read the mbox descriptor */ /* first we read the mbox descriptor */
wl1271_read(wl, wl->mbox_ptr[mbox_num], wl->mbox, ret = wlcore_read(wl, wl->mbox_ptr[mbox_num], wl->mbox,
sizeof(*wl->mbox), false); sizeof(*wl->mbox), false);
if (ret < 0)
return ret;
/* process the descriptor */ /* process the descriptor */
ret = wl1271_event_process(wl); ret = wl1271_event_process(wl);
......
...@@ -81,10 +81,12 @@ wlcore_hw_get_rx_packet_len(struct wl1271 *wl, void *rx_data, u32 data_len) ...@@ -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); 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) 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) static inline void wlcore_hw_tx_immediate_compl(struct wl1271 *wl)
......
...@@ -92,14 +92,14 @@ static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val) ...@@ -92,14 +92,14 @@ static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val)
sizeof(wl->buffer_32), false); sizeof(wl->buffer_32), false);
} }
static inline void wl1271_read(struct wl1271 *wl, int addr, void *buf, static inline int wlcore_read(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed) size_t len, bool fixed)
{ {
int physical; int physical;
physical = wlcore_translate_addr(wl, addr); 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, 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, ...@@ -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); 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) 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, static inline void wl1271_read_hwaddr(struct wl1271 *wl, int hwaddr,
......
...@@ -572,7 +572,11 @@ static irqreturn_t wl1271_irq(int irq, void *cookie) ...@@ -572,7 +572,11 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)
if (likely(intr & WL1271_ACX_INTR_DATA)) { if (likely(intr & WL1271_ACX_INTR_DATA)) {
wl1271_debug(DEBUG_IRQ, "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 */ /* Check if any tx blocks were freed */
spin_lock_irqsave(&wl->wl_lock, flags); spin_lock_irqsave(&wl->wl_lock, flags);
...@@ -589,7 +593,11 @@ static irqreturn_t wl1271_irq(int irq, void *cookie) ...@@ -589,7 +593,11 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)
} }
/* check for tx results */ /* 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 */ /* Make sure the deferred queues don't get too long */
defer_count = skb_queue_len(&wl->deferred_tx_queue) + defer_count = skb_queue_len(&wl->deferred_tx_queue) +
...@@ -600,12 +608,20 @@ static irqreturn_t wl1271_irq(int irq, void *cookie) ...@@ -600,12 +608,20 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)
if (intr & WL1271_ACX_INTR_EVENT_A) { if (intr & WL1271_ACX_INTR_EVENT_A) {
wl1271_debug(DEBUG_IRQ, "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) { if (intr & WL1271_ACX_INTR_EVENT_B) {
wl1271_debug(DEBUG_IRQ, "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) if (intr & WL1271_ACX_INTR_INIT_COMPLETE)
......
...@@ -200,7 +200,7 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, ...@@ -200,7 +200,7 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length,
return is_data; 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}; unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0};
u32 buf_size; u32 buf_size;
...@@ -211,6 +211,7 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status) ...@@ -211,6 +211,7 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status)
u32 pkt_offset, des; u32 pkt_offset, des;
u8 hlid; u8 hlid;
enum wl_rx_buf_align rx_align; enum wl_rx_buf_align rx_align;
int ret = 0;
while (drv_rx_counter != fw_rx_counter) { while (drv_rx_counter != fw_rx_counter) {
buf_size = 0; buf_size = 0;
...@@ -235,8 +236,11 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status) ...@@ -235,8 +236,11 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status)
/* Read all available packets at once */ /* Read all available packets at once */
des = le32_to_cpu(status->rx_pkt_descs[drv_rx_counter]); des = le32_to_cpu(status->rx_pkt_descs[drv_rx_counter]);
wlcore_hw_prepare_read(wl, des, buf_size); 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 */ /* Split data into separate packets */
pkt_offset = 0; pkt_offset = 0;
...@@ -278,6 +282,9 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status) ...@@ -278,6 +282,9 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status_1 *status)
wl->rx_counter); wl->rx_counter);
wl12xx_rearm_rx_streaming(wl, active_hlids); wl12xx_rearm_rx_streaming(wl, active_hlids);
out:
return ret;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
...@@ -143,7 +143,7 @@ struct wl1271_rx_descriptor { ...@@ -143,7 +143,7 @@ struct wl1271_rx_descriptor {
u8 reserved; u8 reserved;
} __packed; } __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); u8 wl1271_rate_to_idx(int rate, enum ieee80211_band band);
int wl1271_rx_filter_enable(struct wl1271 *wl, int wl1271_rx_filter_enable(struct wl1271 *wl,
int index, bool enable, int index, bool enable,
......
...@@ -881,16 +881,20 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, ...@@ -881,16 +881,20 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
} }
/* Called upon reception of a TX complete interrupt */ /* 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 *memmap =
(struct wl1271_acx_mem_map *)wl->target_mem_map; (struct wl1271_acx_mem_map *)wl->target_mem_map;
u32 count, fw_counter; u32 count, fw_counter;
u32 i; u32 i;
int ret;
/* read the tx results from the chipset */ /* read the tx results from the chipset */
wl1271_read(wl, le32_to_cpu(memmap->tx_result), ret = wlcore_read(wl, le32_to_cpu(memmap->tx_result),
wl->tx_res_if, sizeof(*wl->tx_res_if), false); 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); fw_counter = le32_to_cpu(wl->tx_res_if->tx_result_fw_counter);
/* write host counter to chipset (to ack) */ /* write host counter to chipset (to ack) */
...@@ -916,8 +920,11 @@ void wl1271_tx_complete(struct wl1271 *wl) ...@@ -916,8 +920,11 @@ void wl1271_tx_complete(struct wl1271 *wl)
wl->tx_results_count++; 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) void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid)
{ {
......
...@@ -235,7 +235,7 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl) ...@@ -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(struct work_struct *work);
void wl1271_tx_work_locked(struct wl1271 *wl); 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_wlvif(struct wl1271 *wl, struct wl12xx_vif *wlvif);
void wl12xx_tx_reset(struct wl1271 *wl); void wl12xx_tx_reset(struct wl1271 *wl);
void wl1271_tx_flush(struct wl1271 *wl); void wl1271_tx_flush(struct wl1271 *wl);
......
...@@ -56,7 +56,7 @@ struct wlcore_ops { ...@@ -56,7 +56,7 @@ struct wlcore_ops {
void (*prepare_read)(struct wl1271 *wl, u32 rx_desc, u32 len); void (*prepare_read)(struct wl1271 *wl, u32 rx_desc, u32 len);
u32 (*get_rx_packet_len)(struct wl1271 *wl, void *rx_data, u32 (*get_rx_packet_len)(struct wl1271 *wl, void *rx_data,
u32 data_len); u32 data_len);
void (*tx_delayed_compl)(struct wl1271 *wl); int (*tx_delayed_compl)(struct wl1271 *wl);
void (*tx_immediate_compl)(struct wl1271 *wl); void (*tx_immediate_compl)(struct wl1271 *wl);
int (*hw_init)(struct wl1271 *wl); int (*hw_init)(struct wl1271 *wl);
int (*init_vif)(struct wl1271 *wl, struct wl12xx_vif *wlvif); int (*init_vif)(struct wl1271 *wl, struct wl12xx_vif *wlvif);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment