ath10k: scan should handle scan-start-failed event properly.
PATCH 1/8 ath10k: scan should handle scan-start-failed event properly.
From: Ben Greear <[email protected]>
In case firmware fails to start the scan, then complete the start condition and clean up so that driver does not block on timeout.
--- drivers/net/wireless/ath/ath10k/mac.c | 11 +++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+)
drivers/net/wireless/ath/ath10k/mac.c +11 -0
@@ -2375,6 +2375,17 @@ static int ath10k_start_scan(struct ath10k *ar,return -ETIMEDOUT ; } +/* If we failed to start the scan, return error code at +* this point. This is probably due to some issue in the +* firmware, but no need to wedge the driver due to that... +*/ +spin_lock_bh (&ar->data_lock); +if (ar->scan.state ==ATH10K_SCAN_IDLE ) { +spin_unlock_bh (&ar->data_lock); +return -EINVAL ; + } +spin_unlock_bh (&ar->data_lock); +/* Add a 200ms margin to account for event/command processing */ ieee80211_queue_delayed_work (ar->hw, &ar->scan.timeout,msecs_to_jiffies (arg->max_scan_time+200 ));
drivers/net/wireless/ath/ath10k/wmi.c +20 -0
@@ -916,6 +916,25 @@ static void ath10k_wmi_event_scan_started(struct ath10k *ar) } } +static void ath10k_wmi_event_scan_start_failed (struct ath10k *ar) +{ +lockdep_assert_held (&ar->data_lock); + +switch (ar->scan.state) { +case ATH10K_SCAN_IDLE : +case ATH10K_SCAN_RUNNING : +case ATH10K_SCAN_ABORTING : +ath10k_warn (ar,"received scan start failed event in an invalid scan state: %s (%d)\n" , +ath10k_scan_state_str (ar->scan.state), + ar->scan.state); +break ; +case ATH10K_SCAN_STARTING : +complete (&ar->scan.started); +__ath10k_scan_finish (ar); +break ; + } +} +static void ath10k_wmi_event_scan_completed (struct ath10k *ar) {lockdep_assert_held (&ar->data_lock);
@@ -1057,6 +1076,7 @@ static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)break ;case WMI_SCAN_EVENT_START_FAILED :ath10k_warn (ar,"received scan start failure event\n" ); +ath10k_wmi_event_scan_start_failed (ar);break ;case WMI_SCAN_EVENT_DEQUEUED :case WMI_SCAN_EVENT_PREEMPTED :
Signature · 1 line
1.7.11.7
PATCH 2/8 ath10k: add wmi-id to htc credits debugging.
From: Ben Greear <[email protected]>
This helps when trying to figure out exactly which commands are consuming credits when trying to debug wmi credit hangs.
--- drivers/net/wireless/ath/ath10k/htc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +12 -3
@@ -137,9 +137,18 @@ int ath10k_htc_send(struct ath10k_htc *htc, goto err_pull; } ep->tx_credits -= credits; -ath10k_dbg (ar,ATH10K_DBG_HTC , -"htc ep %d consumed %d credits (total %d)\n" , - eid, credits, ep->tx_credits); +if (eid == ar->wmi.eid) { +struct wmi_cmd_hdr * hdr; + hdr = (struct wmi_cmd_hdr *)(skb->data +sizeof (struct ath10k_htc_hdr )); +ath10k_dbg (ar,ATH10K_DBG_HTC , +"htc ep %d consumed %d credits (total %d, wmi-cmd 0x%x)\n" , + eid, credits, ep->tx_credits,__le32_to_cpu (hdr->cmd_id)); + } +else { +ath10k_dbg (ar,ATH10K_DBG_HTC , +"htc ep %d consumed %d credits (total %d)\n" , + eid, credits, ep->tx_credits); + }spin_unlock_bh (&htc->tx_lock); }
Signature · 1 line
1.7.11.7
PATCH 3/8 ath10k: fix spelling mistakes and add details to mac logging.
In reply to [email protected]From: Ben Greear <[email protected]>
A bit of general cleanup to make debug messages more useful.
--- drivers/net/wireless/ath/ath10k/mac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/mac.c +5 -5
@@ -604,7 +604,7 @@ static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id) ret =ath10k_vdev_setup_sync (ar);if (ret) { -ath10k_warn (ar,"failed to synchronize setup for monitor vdev %i: %d\n" , +ath10k_warn (ar,"failed to synchronize setup for monitor vdev %i: %d (start)\n" , vdev_id, ret);return ret; }
@@ -651,7 +651,7 @@ static int ath10k_monitor_vdev_stop(struct ath10k *ar) ret =ath10k_vdev_setup_sync (ar);if (ret) -ath10k_warn (ar,"failed to synchronise monitor vdev %i: %d\n" , +ath10k_warn (ar,"failed to synchronize monitor vdev %i: %d (stop)\n" , ar->monitor_vdev_id, ret); ath10k_dbg(ar, ATH10K_DBG_MAC, "mac monitor vdev %i stopped\n",
@@ -936,8 +936,8 @@ static int ath10k_vdev_start_restart(struct ath10k_vif *arvif, bool restart) ret =ath10k_vdev_setup_sync (ar);if (ret) { -ath10k_warn (ar,"failed to synchronise setup for vdev %i: %d\n" , - arg.vdev_id, ret); +ath10k_warn (ar,"failed to synchronize setup for vdev %i: %d (restart %d)\n" , + arg.vdev_id, ret, restart);return ret; }
@@ -975,7 +975,7 @@ static int ath10k_vdev_stop(struct ath10k_vif *arvif) ret =ath10k_vdev_setup_sync (ar);if (ret) { -ath10k_warn (ar,"failed to syncronise setup for vdev %i: %d\n" , +ath10k_warn (ar,"failed to synchronize setup for vdev %i: %d (stop)\n" , arvif->vdev_id, ret);return ret; }
Signature · 1 line
1.7.11.7
PATCH 4/8 ath10k: make dbglog debug messages be 'warn' level.
In reply to [email protected]From: Ben Greear <[email protected]>
This only happens on firmware crash, and it appears this logic is not always perfect, so make sure the information is printed to logs at higher level.
--- drivers/net/wireless/ath/ath10k/pci.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +6 -8
@@ -1132,9 +1132,8 @@ static void ath10k_pci_dump_dbglog(struct ath10k *ar)return ; } -ath10k_dbg (ar,ATH10K_DBG_PCI , -"debug log header, dbuf: 0x%x dropped: %i\n" , -le32_to_cpu (dbg_hdr.dbuf),le32_to_cpu (dbg_hdr.dropped)); +ath10k_warn (ar,"debug log header, dbuf: 0x%x dropped: %i\n" , +le32_to_cpu (dbg_hdr.dbuf),le32_to_cpu (dbg_hdr.dropped)); dbufp =le32_to_cpu (dbg_hdr.dbuf);/* i is for logging purposes and sanity check in case firmware buffers
@@ -1154,11 +1153,10 @@ static void ath10k_pci_dump_dbglog(struct ath10k *ar) len =le32_to_cpu (dbuf.length); -ath10k_dbg (ar,ATH10K_DBG_PCI , -"[%i] next: 0x%x buf: 0x%x sz: %i len: %i count: %i free: %i\n" , - i,le32_to_cpu (dbuf.next),le32_to_cpu (dbuf.buffer), -le32_to_cpu (dbuf.bufsize), len, -le32_to_cpu (dbuf.count),le32_to_cpu (dbuf.free)); +ath10k_warn (ar,"[%i] next: 0x%x buf: 0x%x sz: %i len: %i count: %i free: %i\n" , + i,le32_to_cpu (dbuf.next),le32_to_cpu (dbuf.buffer), +le32_to_cpu (dbuf.bufsize), len, +le32_to_cpu (dbuf.count),le32_to_cpu (dbuf.free));if (dbuf.buffer ==0 || len ==0 ) goto next;
Signature · 1 line
1.7.11.7
RFC 5/8 ath10k: add firmware wmi keep-alive message.
In reply to [email protected]From: Ben Greear <[email protected]>
Only useful for CT firmware.
This sends a wmi message to the firmware every 2 seconds or so. Once CT firmware receives one of these messages, it will assert if it does not receive more within a 10 second window.
This helps debug and work-around wmi transport hangs.
---
This is for comment only, as it requires at least minimal CT firmware support patches in order to compile or work.
drivers/net/wireless/ath/ath10k/core.h | 2 ++ drivers/net/wireless/ath/ath10k/debug.c | 29 +++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 32 ++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.h | 7 +++++++ 4 files changed, 70 insertions(+)
drivers/net/wireless/ath/ath10k/core.h +2 -0
@@ -367,6 +367,7 @@ struct ath10k_debug {unsigned long htt_stats_mask;struct delayed_work htt_stats_dwork; +struct delayed_work nop_dwork;struct ath10k_dfs_stats dfs_stats;struct ath_dfs_pool_stats dfs_pool_stats;
@@ -374,6 +375,7 @@ struct ath10k_debug {u32 fw_dbglog_mask;u32 pktlog_filter;u32 reg_addr; +u32 nop_id;u8 htt_max_amsdu;u8 htt_max_ampdu;
drivers/net/wireless/ath/ath10k/debug.c +29 -0
@@ -27,6 +27,8 @@/* ms */ #define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000 +#define ATH10K_DEBUG_NOP_INTERVAL 2000/* ms */ +#define ATH10K_FW_CRASH_DUMP_VERSION 1/**
@@ -1550,6 +1552,27 @@ static void ath10k_debug_htt_stats_dwork(struct work_struct *work)mutex_unlock (&ar->conf_mutex); } +static void ath10k_debug_nop_dwork (struct work_struct *work) +{ + struct ath10k *ar = container_of(work, struct ath10k, + debug.nop_dwork.work); + +mutex_lock (&ar->conf_mutex); + +if (ar->state ==ATH10K_STATE_ON ) { +int ret =ath10k_wmi_request_nop (ar); +if (ret) { +ath10k_warn (ar,"failed to send wmi nop: %d\n" , ret); + } + } + +/* Re-arm periodic work. */ +queue_delayed_work (ar->workqueue, &ar->debug.nop_dwork, +msecs_to_jiffies (ATH10K_DEBUG_NOP_INTERVAL )); + +mutex_unlock (&ar->conf_mutex); +} +static ssize_t ath10k_read_htt_stats_mask (struct file *file,char __user *user_buf,size_t count,loff_t *ppos)
@@ -2192,6 +2215,11 @@ int ath10k_debug_register(struct ath10k *ar)return -ENOMEM ; } +INIT_DELAYED_WORK (&ar->debug.nop_dwork, ath10k_debug_nop_dwork); + +queue_delayed_work (ar->workqueue, &ar->debug.nop_dwork, +msecs_to_jiffies (ATH10K_DEBUG_NOP_INTERVAL )); +INIT_DELAYED_WORK (&ar->debug.htt_stats_dwork, ath10k_debug_htt_stats_dwork);
@@ -2262,6 +2290,7 @@ int ath10k_debug_register(struct ath10k *ar)void ath10k_debug_unregister (struct ath10k *ar) { +cancel_delayed_work_sync (&ar->debug.nop_dwork);cancel_delayed_work_sync (&ar->debug.htt_stats_dwork); }
drivers/net/wireless/ath/ath10k/wmi.c +32 -0
@@ -4480,6 +4480,38 @@ int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id)return ath10k_wmi_cmd_send (ar, skb, ar->wmi.cmd->request_stats_cmdid); } +#ifdef CONFIG_ATH10K_DEBUG +/* CT firmware only: +* (re) start wmi keep-alive timer in firmware. Once we start +* sending these, firmware will assert if it does not receive one +* after about 10 seconds. +*/ + +struct wmi_request_nop_cmd { +u32 nop_id;/* for debugging purposes */ +}; + +int ath10k_wmi_request_nop (struct ath10k *ar) +{ +struct wmi_request_nop_cmd *cmd; +struct sk_buff *skb; + +if (!test_bit (ATH10K_FW_FEATURE_WMI_10X_CT , ar->fw_features)) +return 0 ; + + skb =ath10k_wmi_alloc_skb (ar,sizeof (*cmd)); +if (!skb) +return -ENOMEM ; + + cmd = (struct wmi_request_nop_cmd *)skb->data; + cmd->nop_id =__cpu_to_le32 (ar->debug.nop_id++); + +ath10k_dbg (ar,ATH10K_DBG_WMI ,"wmi request nop (id %d)\n" , + ar->debug.nop_id -1 ); +return ath10k_wmi_cmd_send (ar, skb,WMI_NOP ); +} +#endif +int ath10k_wmi_force_fw_hang (struct ath10k *ar,enum wmi_force_fw_hang_type type,u32 delay_ms) {
drivers/net/wireless/ath/ath10k/wmi.h +7 -0
@@ -901,6 +901,8 @@ enum wmi_10x_cmd_id {WMI_10X_GPIO_CONFIG_CMDID ,WMI_10X_GPIO_OUTPUT_CMDID , +WMI_NOP =WMI_10X_END_CMDID -100 ,/* CT only: wmi transport keep-alive, basically */ + WMI_10X_PDEV_UTF_CMDID = WMI_10X_END_CMDID - 1, };
@@ -4736,4 +4738,9 @@ int ath10k_wmi_pull_fw_stats(struct ath10k *ar, struct sk_buff *skb,int ath10k_wmi_pdev_pktlog_enable (struct ath10k *ar,u32 ev_list);int ath10k_wmi_pdev_pktlog_disable (struct ath10k *ar); +#ifdef CONFIG_ATH10K_DEBUG +/* CT Firmware only */ +int ath10k_wmi_request_nop (struct ath10k *ar); +#endif +#endif /* _WMI_H_ */
Signature · 1 line
1.7.11.7
PATCH 6/8 ath10k: fix spelling in htt code comment.
In reply to [email protected]From: Ben Greear <[email protected]>
Fix spelling error.
--- drivers/net/wireless/ath/ath10k/htt_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +1 -1
@@ -130,7 +130,7 @@ static void ath10k_htt_rx_msdu_buff_replenish(struct ath10k_htt *htt)* automatically balances load wrt to CPU power. * * This probably comes at a cost of lower maximum throughput but -* improves the avarage and stability. */ +* improves the average and stability. */ spin_lock_bh (&htt->rx_ring.lock); num_deficit = htt->rx_ring.fill_level - htt->rx_ring.fill_cnt; num_to_fill =min (ATH10K_HTT_MAX_NUM_REFILL , num_deficit);
Signature · 1 line
1.7.11.7
PATCH 7/8 ath10k: start using htt/pci/ce transfer_id properly.
In reply to [email protected]From: Ben Greear <[email protected]>
Upstream firmware may ingore, but someone hacking on firmware can use this (and similar instrumentation on the firmware side) to help determine what is happening when there are communication issues between firmware and host.
--- drivers/net/wireless/ath/ath10k/ce.c | 1 + drivers/net/wireless/ath/ath10k/ce.h | 7 +++++++ drivers/net/wireless/ath/ath10k/htc.c | 2 +- drivers/net/wireless/ath/ath10k/htc.h | 1 + drivers/net/wireless/ath/ath10k/htt.h | 1 + drivers/net/wireless/ath/ath10k/htt_tx.c | 6 ++++-- drivers/net/wireless/ath/ath10k/pci.c | 31 +++++++++++++++++++++++-------- 7 files changed, 38 insertions(+), 11 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +1 -0
@@ -319,6 +319,7 @@ int ath10k_ce_send_nolock(struct ath10k_ce_pipe *ce_state,ath10k_ce_src_ring_write_index_set (ar, ctrl_addr, write_index); src_ring->write_index = write_index; + ce_state->last_tx_transfer_id = transfer_id; exit:return ret; }
drivers/net/wireless/ath/ath10k/ce.h +7 -0
@@ -120,6 +120,13 @@ struct ath10k_ce_pipe {unsigned int src_sz_max;struct ath10k_ce_ring *src_ring;struct ath10k_ce_ring *dest_ring; + +/* Some fields used for debugging */ +unsigned int last_rx_transfer_id; +unsigned int last_ce_send_done_transfer_id; +unsigned int last_tx_transfer_id; +unsigned int last_bmi_send_done_transfer_id; +unsigned int last_bmi_recv_transfer_id; };/* Copy Engine settable attributes */
drivers/net/wireless/ath/ath10k/htc.c +1 -1
@@ -160,7 +160,7 @@ int ath10k_htc_send(struct ath10k_htc *htc,if (ret) goto err_credits; - sg_item.transfer_id = ep->eid; + sg_item.transfer_id = ep->next_transfer_id++; sg_item.transfer_context = skb; sg_item.vaddr = skb->data; sg_item.paddr = skb_cb->paddr;
drivers/net/wireless/ath/ath10k/htc.h +1 -0
@@ -316,6 +316,7 @@ struct ath10k_htc_ep {int dl_is_polled;/* call HIF to fetch rx (not implemented) */ u8 seq_no;/* for debugging */ +u16 next_transfer_id;/* for debugging */ int tx_credits;int tx_credit_size;int tx_credits_per_max_message;
drivers/net/wireless/ath/ath10k/htt.h +1 -0
@@ -1223,6 +1223,7 @@ struct ath10k_htt {int max_throughput_mbps;u8 target_version_major;u8 target_version_minor; +u16 htt_transfer_id;struct completion target_version_received;struct {
drivers/net/wireless/ath/ath10k/htt_tx.c +4 -2
@@ -456,6 +456,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)dma_addr_t paddr;u32 frags_paddr;bool use_frags; +unsigned int htt_transfer_id; res =ath10k_htt_tx_inc_pending (htt);if (res)
@@ -469,6 +470,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) } msdu_id = res; htt->pending_tx[msdu_id] = msdu; + htt_transfer_id = htt->htt_transfer_id++;spin_unlock_bh (&htt->tx_lock); prefetch_len =min (htt->prefetch_len, msdu->len);
@@ -569,7 +571,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)trace_ath10k_tx_hdr (ar, msdu->data, msdu->len);trace_ath10k_tx_payload (ar, msdu->data, msdu->len); - sg_items[0 ].transfer_id =0 ; + sg_items[0 ].transfer_id = htt_transfer_id; sg_items[0 ].transfer_context =NULL ; sg_items[0 ].vaddr = &skb_cb->htt.txbuf->htc_hdr; sg_items[0].paddr = skb_cb->htt.txbuf_paddr +
@@ -578,7 +580,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)sizeof (skb_cb->htt.txbuf->cmd_hdr) +sizeof (skb_cb->htt.txbuf->cmd_tx); - sg_items[1 ].transfer_id =0 ; + sg_items[1 ].transfer_id = sg_items[0 ].transfer_id; sg_items[1 ].transfer_context =NULL ; sg_items[1 ].vaddr = msdu->data; sg_items[1 ].paddr = skb_cb->paddr;
drivers/net/wireless/ath/ath10k/pci.c +23 -8
@@ -846,11 +846,11 @@ static void ath10k_pci_ce_send_done(struct ath10k_ce_pipe *ce_state)struct sk_buff *skb;u32 ce_data;unsigned int nbytes; -unsigned int transfer_id;__skb_queue_head_init (&list);while (ath10k_ce_completed_send_next (ce_state, (void **)&skb, &ce_data, - &nbytes, &transfer_id) ==0 ) { + &nbytes, + &ce_state->last_ce_send_done_transfer_id) ==0 ) {/* no need to call tx completion for NULL pointers */ if (skb ==NULL )continue ;
@@ -874,12 +874,11 @@ static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state)void *transfer_context;u32 ce_data;unsigned int nbytes, max_nbytes; -unsigned int transfer_id;unsigned int flags;__skb_queue_head_init (&list);while (ath10k_ce_completed_recv_next (ce_state, &transfer_context, - &ce_data, &nbytes, &transfer_id, + &ce_data, &nbytes, &ce_state->last_rx_transfer_id, &flags) ==0 ) { skb = transfer_context; max_nbytes = skb->len +skb_tailroom (skb);
@@ -1209,6 +1208,8 @@ static void ath10k_pci_fw_crashed_dump(struct ath10k *ar) {struct ath10k_fw_crash_data *crash_data;char uuid[50 ]; +struct ath10k_pci *pci; +int i;spin_lock_bh (&ar->data_lock);
@@ -1234,6 +1235,19 @@ static void ath10k_pci_fw_crashed_dump(struct ath10k *ar)spin_unlock_bh (&ar->data_lock); +/* Print out some info on the CE pipes */ + pci =ath10k_pci_priv (ar); +for (i =0 ; i<CE_COUNT_MAX ; i++) { +ath10k_err (ar,"ce-pipe [%i] rx-id: %i ce-send-done: %d tx-id: %d bmi-send-done: %d bmi-recv: %d\n" , + i, + pci->ce_states[i].last_rx_transfer_id, + pci->ce_states[i].last_ce_send_done_transfer_id, + pci->ce_states[i].last_tx_transfer_id, + pci->ce_states[i].last_bmi_send_done_transfer_id, + pci->ce_states[i].last_bmi_recv_transfer_id); + } +ath10k_err (ar,"last htt-tx-id: %d\n" , ar->htt.htt_transfer_id); +queue_work (ar->workqueue, &ar->restart_work); }
@@ -1640,10 +1654,10 @@ static void ath10k_pci_bmi_send_done(struct ath10k_ce_pipe *ce_state)struct bmi_xfer *xfer;u32 ce_data;unsigned int nbytes; -unsigned int transfer_id;if (ath10k_ce_completed_send_next (ce_state, (void **)&xfer, &ce_data, - &nbytes, &transfer_id)) + &nbytes, + &ce_state->last_bmi_send_done_transfer_id))return ; xfer->tx_done = true;
@@ -1655,11 +1669,12 @@ static void ath10k_pci_bmi_recv_data(struct ath10k_ce_pipe *ce_state)struct bmi_xfer *xfer;u32 ce_data;unsigned int nbytes; -unsigned int transfer_id;unsigned int flags;if (ath10k_ce_completed_recv_next (ce_state, (void **)&xfer, &ce_data, - &nbytes, &transfer_id, &flags)) + &nbytes, + &ce_state->last_bmi_recv_transfer_id, + &flags))return ;if (WARN_ON_ONCE (!xfer))
Signature · 1 line
1.7.11.7
PATCH 8/8 ath10k: fix CE_DESC_FLAGS_META_DATA_LSB definition.
In reply to [email protected]From: Ben Greear <[email protected]>
The value was off by one. The error probably has no negative affect on any upstream firmware, but should be fixed anyway in case it comes into use in the future.
--- drivers/net/wireless/ath/ath10k/ce.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/ce.h +1 -1
@@ -39,7 +39,7 @@ struct ath10k_ce_pipe;#define CE_DESC_FLAGS_GATHER (1 << 0)#define CE_DESC_FLAGS_BYTE_SWAP (1 << 1)#define CE_DESC_FLAGS_META_DATA_MASK 0xFFFC -#define CE_DESC_FLAGS_META_DATA_LSB 3 +#define CE_DESC_FLAGS_META_DATA_LSB 2struct ce_desc {__le32 addr;
Signature · 1 line
1.7.11.7