Commit 7c5ba4a8 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

iwlwifi: move queue watchdog into transport

This removes one of the two sources of device
restarts in the upper layer -- those are a bit
inconvenient because normal restarts originate
in the transport. By moving the watchdog down
it can be treated the same.

Also rewrite the watchdog logic. Timers are
much more efficient when they never fire, so
instead firing a timer every 500ms set up a
timer for each TX queue and fire it only when
the queue is really stuck. This avoids the CPU
waking up when everything is working well.

While at it, remove the wd_disable config item
and replace it by simply setting wd_timeout to
IWL_WATCHHDOG_DISABLED (0).
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 52bcbff7
...@@ -165,9 +165,8 @@ static const struct iwl_base_params iwl1000_base_params = { ...@@ -165,9 +165,8 @@ static const struct iwl_base_params iwl1000_base_params = {
.support_ct_kill_exit = true, .support_ct_kill_exit = true,
.plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF, .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
.chain_noise_scale = 1000, .chain_noise_scale = 1000,
.wd_timeout = IWL_DEF_WD_TIMEOUT, .wd_timeout = IWL_WATCHHDOG_DISABLED,
.max_event_log_size = 128, .max_event_log_size = 128,
.wd_disable = true,
}; };
static const struct iwl_ht_params iwl1000_ht_params = { static const struct iwl_ht_params iwl1000_ht_params = {
......
...@@ -312,10 +312,9 @@ static const struct iwl_base_params iwl5000_base_params = { ...@@ -312,10 +312,9 @@ static const struct iwl_base_params iwl5000_base_params = {
.led_compensation = 51, .led_compensation = 51,
.plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
.chain_noise_scale = 1000, .chain_noise_scale = 1000,
.wd_timeout = IWL_LONG_WD_TIMEOUT, .wd_timeout = IWL_WATCHHDOG_DISABLED,
.max_event_log_size = 512, .max_event_log_size = 512,
.no_idle_support = true, .no_idle_support = true,
.wd_disable = true,
}; };
static const struct iwl_ht_params iwl5000_ht_params = { static const struct iwl_ht_params iwl5000_ht_params = {
......
...@@ -741,9 +741,6 @@ int iwl_alive_start(struct iwl_priv *priv) ...@@ -741,9 +741,6 @@ int iwl_alive_start(struct iwl_priv *priv)
/* After the ALIVE response, we can send host commands to the uCode */ /* After the ALIVE response, we can send host commands to the uCode */
set_bit(STATUS_ALIVE, &priv->status); set_bit(STATUS_ALIVE, &priv->status);
/* Enable watchdog to monitor the driver tx queues */
iwl_setup_watchdog(priv);
if (iwl_is_rfkill(priv)) if (iwl_is_rfkill(priv))
return -ERFKILL; return -ERFKILL;
...@@ -887,10 +884,6 @@ void iwl_down(struct iwl_priv *priv) ...@@ -887,10 +884,6 @@ void iwl_down(struct iwl_priv *priv)
exit_pending = exit_pending =
test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); test_and_set_bit(STATUS_EXIT_PENDING, &priv->status);
/* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
* to prevent rearm timer */
del_timer_sync(&priv->watchdog);
iwl_clear_ucode_stations(priv, NULL); iwl_clear_ucode_stations(priv, NULL);
iwl_dealloc_bcast_stations(priv); iwl_dealloc_bcast_stations(priv);
iwl_clear_driver_stations(priv); iwl_clear_driver_stations(priv);
...@@ -1092,10 +1085,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv) ...@@ -1092,10 +1085,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
init_timer(&priv->ucode_trace); init_timer(&priv->ucode_trace);
priv->ucode_trace.data = (unsigned long)priv; priv->ucode_trace.data = (unsigned long)priv;
priv->ucode_trace.function = iwl_bg_ucode_trace; priv->ucode_trace.function = iwl_bg_ucode_trace;
init_timer(&priv->watchdog);
priv->watchdog.data = (unsigned long)priv;
priv->watchdog.function = iwl_bg_watchdog;
} }
void iwl_cancel_deferred_work(struct iwl_priv *priv) void iwl_cancel_deferred_work(struct iwl_priv *priv)
...@@ -1410,8 +1399,6 @@ static void iwl_set_hw_params(struct iwl_priv *priv) ...@@ -1410,8 +1399,6 @@ static void iwl_set_hw_params(struct iwl_priv *priv)
if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_ALL) if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_ALL)
hw_params(priv).sku &= ~EEPROM_SKU_CAP_11N_ENABLE; hw_params(priv).sku &= ~EEPROM_SKU_CAP_11N_ENABLE;
hw_params(priv).wd_timeout = cfg(priv)->base_params->wd_timeout;
/* Device-specific setup */ /* Device-specific setup */
cfg(priv)->lib->set_hw_params(priv); cfg(priv)->lib->set_hw_params(priv);
} }
...@@ -1498,6 +1485,11 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, ...@@ -1498,6 +1485,11 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
trans_cfg.no_reclaim_cmds = no_reclaim_cmds; trans_cfg.no_reclaim_cmds = no_reclaim_cmds;
trans_cfg.n_no_reclaim_cmds = ARRAY_SIZE(no_reclaim_cmds); trans_cfg.n_no_reclaim_cmds = ARRAY_SIZE(no_reclaim_cmds);
trans_cfg.rx_buf_size_8k = iwlagn_mod_params.amsdu_size_8K; trans_cfg.rx_buf_size_8k = iwlagn_mod_params.amsdu_size_8K;
if (!iwlagn_mod_params.wd_disable)
trans_cfg.queue_watchdog_timeout =
cfg(priv)->base_params->wd_timeout;
else
trans_cfg.queue_watchdog_timeout = IWL_WATCHHDOG_DISABLED;
ucode_flags = fw->ucode_capa.flags; ucode_flags = fw->ucode_capa.flags;
......
...@@ -837,74 +837,6 @@ int iwl_cmd_echo_test(struct iwl_priv *priv) ...@@ -837,74 +837,6 @@ int iwl_cmd_echo_test(struct iwl_priv *priv)
return ret; return ret;
} }
static inline int iwl_check_stuck_queue(struct iwl_priv *priv, int txq)
{
if (iwl_trans_check_stuck_queue(trans(priv), txq)) {
int ret;
ret = iwl_force_reset(priv, IWL_FW_RESET, false);
return (ret == -EAGAIN) ? 0 : 1;
}
return 0;
}
/*
* Making watchdog tick be a quarter of timeout assure we will
* discover the queue hung between timeout and 1.25*timeout
*/
#define IWL_WD_TICK(timeout) ((timeout) / 4)
/*
* Watchdog timer callback, we check each tx queue for stuck, if if hung
* we reset the firmware. If everything is fine just rearm the timer.
*/
void iwl_bg_watchdog(unsigned long data)
{
struct iwl_priv *priv = (struct iwl_priv *)data;
int cnt;
unsigned long timeout;
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return;
if (iwl_is_rfkill(priv))
return;
timeout = hw_params(priv).wd_timeout;
if (timeout == 0)
return;
/* monitor and check for stuck queues */
for (cnt = 0; cnt < cfg(priv)->base_params->num_of_queues; cnt++)
if (iwl_check_stuck_queue(priv, cnt))
return;
mod_timer(&priv->watchdog, jiffies +
msecs_to_jiffies(IWL_WD_TICK(timeout)));
}
void iwl_setup_watchdog(struct iwl_priv *priv)
{
unsigned int timeout = hw_params(priv).wd_timeout;
if (!iwlagn_mod_params.wd_disable) {
/* use system default */
if (timeout && !cfg(priv)->base_params->wd_disable)
mod_timer(&priv->watchdog,
jiffies +
msecs_to_jiffies(IWL_WD_TICK(timeout)));
else
del_timer(&priv->watchdog);
} else {
/* module parameter overwrite default configuration */
if (timeout && iwlagn_mod_params.wd_disable == 2)
mod_timer(&priv->watchdog,
jiffies +
msecs_to_jiffies(IWL_WD_TICK(timeout)));
else
del_timer(&priv->watchdog);
}
}
/** /**
* iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time * iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time
* @priv -- pointer to iwl_priv data structure * @priv -- pointer to iwl_priv data structure
......
...@@ -151,7 +151,6 @@ static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx, ...@@ -151,7 +151,6 @@ static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
******************************************************/ ******************************************************/
void iwl_chswitch_done(struct iwl_priv *priv, bool is_success); void iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
void iwl_setup_watchdog(struct iwl_priv *priv);
/***************************************************** /*****************************************************
* TX power * TX power
****************************************************/ ****************************************************/
...@@ -193,7 +192,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, ...@@ -193,7 +192,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
* S e n d i n g H o s t C o m m a n d s * * S e n d i n g H o s t C o m m a n d s *
*****************************************************/ *****************************************************/
void iwl_bg_watchdog(unsigned long data);
u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval); u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval);
__le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base, __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
u32 addon, u32 beacon_interval); u32 addon, u32 beacon_interval);
......
...@@ -585,6 +585,7 @@ struct iwl_event_log { ...@@ -585,6 +585,7 @@ struct iwl_event_log {
#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
/* TX queue watchdog timeouts in mSecs */ /* TX queue watchdog timeouts in mSecs */
#define IWL_WATCHHDOG_DISABLED (0)
#define IWL_DEF_WD_TIMEOUT (2000) #define IWL_DEF_WD_TIMEOUT (2000)
#define IWL_LONG_WD_TIMEOUT (10000) #define IWL_LONG_WD_TIMEOUT (10000)
#define IWL_MAX_WD_TIMEOUT (120000) #define IWL_MAX_WD_TIMEOUT (120000)
...@@ -973,7 +974,6 @@ struct iwl_priv { ...@@ -973,7 +974,6 @@ struct iwl_priv {
struct work_struct run_time_calib_work; struct work_struct run_time_calib_work;
struct timer_list statistics_periodic; struct timer_list statistics_periodic;
struct timer_list ucode_trace; struct timer_list ucode_trace;
struct timer_list watchdog;
struct iwl_event_log event_log; struct iwl_event_log event_log;
......
...@@ -169,7 +169,6 @@ struct iwl_mod_params { ...@@ -169,7 +169,6 @@ struct iwl_mod_params {
* @ct_kill_threshold: temperature threshold - in hw dependent unit * @ct_kill_threshold: temperature threshold - in hw dependent unit
* @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit
* relevant for 1000, 6000 and up * relevant for 1000, 6000 and up
* @wd_timeout: TX queues watchdog timeout
* @struct iwl_sensitivity_ranges: range of sensitivity values * @struct iwl_sensitivity_ranges: range of sensitivity values
* @use_rts_for_aggregation: use rts/cts protection for HT traffic * @use_rts_for_aggregation: use rts/cts protection for HT traffic
*/ */
...@@ -183,7 +182,6 @@ struct iwl_hw_params { ...@@ -183,7 +182,6 @@ struct iwl_hw_params {
u16 sku; u16 sku;
u32 ct_kill_threshold; u32 ct_kill_threshold;
u32 ct_kill_exit_threshold; u32 ct_kill_exit_threshold;
unsigned int wd_timeout;
const struct iwl_sensitivity_ranges *sens; const struct iwl_sensitivity_ranges *sens;
}; };
...@@ -221,7 +219,6 @@ enum iwl_led_mode { ...@@ -221,7 +219,6 @@ enum iwl_led_mode {
* @shadow_reg_enable: HW shadhow register bit * @shadow_reg_enable: HW shadhow register bit
* @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
* @no_idle_support: do not support idle mode * @no_idle_support: do not support idle mode
* wd_disable: disable watchdog timer
*/ */
struct iwl_base_params { struct iwl_base_params {
int eeprom_size; int eeprom_size;
...@@ -241,7 +238,6 @@ struct iwl_base_params { ...@@ -241,7 +238,6 @@ struct iwl_base_params {
const bool shadow_reg_enable; const bool shadow_reg_enable;
const bool hd_v2; const bool hd_v2;
const bool no_idle_support; const bool no_idle_support;
const bool wd_disable;
}; };
/* /*
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/timer.h>
#include "iwl-fh.h" #include "iwl-fh.h"
#include "iwl-csr.h" #include "iwl-csr.h"
...@@ -204,7 +205,8 @@ struct iwl_tx_queue { ...@@ -204,7 +205,8 @@ struct iwl_tx_queue {
struct iwl_cmd_meta *meta; struct iwl_cmd_meta *meta;
struct sk_buff **skbs; struct sk_buff **skbs;
spinlock_t lock; spinlock_t lock;
unsigned long time_stamp; struct timer_list stuck_timer;
struct iwl_trans_pcie *trans_pcie;
u8 need_update; u8 need_update;
u8 active; u8 active;
}; };
...@@ -227,6 +229,7 @@ struct iwl_tx_queue { ...@@ -227,6 +229,7 @@ struct iwl_tx_queue {
* @cmd_queue - command queue number * @cmd_queue - command queue number
* @rx_buf_size_8k: 8 kB RX buffer size * @rx_buf_size_8k: 8 kB RX buffer size
* @rx_page_order: page order for receive buffer size * @rx_page_order: page order for receive buffer size
* @wd_timeout: queue watchdog timeout (jiffies)
*/ */
struct iwl_trans_pcie { struct iwl_trans_pcie {
struct iwl_rx_queue rxq; struct iwl_rx_queue rxq;
...@@ -269,11 +272,22 @@ struct iwl_trans_pcie { ...@@ -269,11 +272,22 @@ struct iwl_trans_pcie {
bool rx_buf_size_8k; bool rx_buf_size_8k;
u32 rx_page_order; u32 rx_page_order;
/* queue watchdog */
unsigned long wd_timeout;
}; };
#define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \ #define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \
((struct iwl_trans_pcie *) ((_iwl_trans)->trans_specific)) ((struct iwl_trans_pcie *) ((_iwl_trans)->trans_specific))
static inline struct iwl_trans *
iwl_trans_pcie_get_trans(struct iwl_trans_pcie *trans_pcie)
{
return container_of((void *)trans_pcie, struct iwl_trans,
trans_specific);
}
/***************************************************** /*****************************************************
* RX * RX
******************************************************/ ******************************************************/
......
...@@ -668,6 +668,10 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) ...@@ -668,6 +668,10 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
trace_bufs[2], trace_lens[2]); trace_bufs[2], trace_lens[2]);
#endif #endif
/* start timer if queue currently empty */
if (q->read_ptr == q->write_ptr && trans_pcie->wd_timeout)
mod_timer(&txq->stuck_timer, jiffies + trans_pcie->wd_timeout);
/* Increment and update queue's write index */ /* Increment and update queue's write index */
q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
iwl_txq_update_write_ptr(trans, txq); iwl_txq_update_write_ptr(trans, txq);
...@@ -677,6 +681,22 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) ...@@ -677,6 +681,22 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
return idx; return idx;
} }
static inline void iwl_queue_progress(struct iwl_trans_pcie *trans_pcie,
struct iwl_tx_queue *txq)
{
if (!trans_pcie->wd_timeout)
return;
/*
* if empty delete timer, otherwise move timer forward
* since we're making progress on this queue
*/
if (txq->q.read_ptr == txq->q.write_ptr)
del_timer(&txq->stuck_timer);
else
mod_timer(&txq->stuck_timer, jiffies + trans_pcie->wd_timeout);
}
/** /**
* iwl_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd * iwl_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd
* *
...@@ -711,6 +731,8 @@ static void iwl_hcmd_queue_reclaim(struct iwl_trans *trans, int txq_id, ...@@ -711,6 +731,8 @@ static void iwl_hcmd_queue_reclaim(struct iwl_trans *trans, int txq_id,
} }
} }
iwl_queue_progress(trans_pcie, txq);
} }
/** /**
...@@ -754,8 +776,6 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_cmd_buffer *rxb, ...@@ -754,8 +776,6 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_cmd_buffer *rxb,
cmd = txq->cmd[cmd_index]; cmd = txq->cmd[cmd_index];
meta = &txq->meta[cmd_index]; meta = &txq->meta[cmd_index];
txq->time_stamp = jiffies;
iwlagn_unmap_tfd(trans, meta, &txq->tfds[index], iwlagn_unmap_tfd(trans, meta, &txq->tfds[index],
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
...@@ -949,5 +969,8 @@ int iwl_tx_queue_reclaim(struct iwl_trans *trans, int txq_id, int index, ...@@ -949,5 +969,8 @@ int iwl_tx_queue_reclaim(struct iwl_trans *trans, int txq_id, int index,
iwlagn_txq_free_tfd(trans, txq, txq->q.read_ptr, DMA_TO_DEVICE); iwlagn_txq_free_tfd(trans, txq, txq->q.read_ptr, DMA_TO_DEVICE);
freed++; freed++;
} }
iwl_queue_progress(trans_pcie, txq);
return freed; return freed;
} }
...@@ -299,6 +299,33 @@ static inline void iwlagn_free_dma_ptr(struct iwl_trans *trans, ...@@ -299,6 +299,33 @@ static inline void iwlagn_free_dma_ptr(struct iwl_trans *trans,
memset(ptr, 0, sizeof(*ptr)); memset(ptr, 0, sizeof(*ptr));
} }
static void iwl_trans_pcie_queue_stuck_timer(unsigned long data)
{
struct iwl_tx_queue *txq = (void *)data;
struct iwl_trans_pcie *trans_pcie = txq->trans_pcie;
struct iwl_trans *trans = iwl_trans_pcie_get_trans(trans_pcie);
spin_lock(&txq->lock);
/* check if triggered erroneously */
if (txq->q.read_ptr == txq->q.write_ptr) {
spin_unlock(&txq->lock);
return;
}
spin_unlock(&txq->lock);
IWL_ERR(trans, "Queue %d stuck for %u ms.\n", txq->q.id,
jiffies_to_msecs(trans_pcie->wd_timeout));
IWL_ERR(trans, "Current SW read_ptr %d write_ptr %d\n",
txq->q.read_ptr, txq->q.write_ptr);
IWL_ERR(trans, "Current HW read_ptr %d write_ptr %d\n",
iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq->q.id))
& (TFD_QUEUE_SIZE_MAX - 1),
iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq->q.id)));
iwl_op_mode_nic_error(trans->op_mode);
}
static int iwl_trans_txq_alloc(struct iwl_trans *trans, static int iwl_trans_txq_alloc(struct iwl_trans *trans,
struct iwl_tx_queue *txq, int slots_num, struct iwl_tx_queue *txq, int slots_num,
u32 txq_id) u32 txq_id)
...@@ -310,6 +337,10 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans, ...@@ -310,6 +337,10 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans,
if (WARN_ON(txq->meta || txq->cmd || txq->skbs || txq->tfds)) if (WARN_ON(txq->meta || txq->cmd || txq->skbs || txq->tfds))
return -EINVAL; return -EINVAL;
setup_timer(&txq->stuck_timer, iwl_trans_pcie_queue_stuck_timer,
(unsigned long)txq);
txq->trans_pcie = trans_pcie;
txq->q.n_window = slots_num; txq->q.n_window = slots_num;
txq->meta = kcalloc(slots_num, sizeof(txq->meta[0]), GFP_KERNEL); txq->meta = kcalloc(slots_num, sizeof(txq->meta[0]), GFP_KERNEL);
...@@ -472,6 +503,8 @@ static void iwl_tx_queue_free(struct iwl_trans *trans, int txq_id) ...@@ -472,6 +503,8 @@ static void iwl_tx_queue_free(struct iwl_trans *trans, int txq_id)
txq->cmd = NULL; txq->cmd = NULL;
txq->meta = NULL; txq->meta = NULL;
del_timer_sync(&txq->stuck_timer);
/* 0-fill queue descriptor structure */ /* 0-fill queue descriptor structure */
memset(txq, 0, sizeof(*txq)); memset(txq, 0, sizeof(*txq));
} }
...@@ -1347,6 +1380,10 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, ...@@ -1347,6 +1380,10 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
&dev_cmd->hdr, firstlen, &dev_cmd->hdr, firstlen,
skb->data + hdr_len, secondlen); skb->data + hdr_len, secondlen);
/* start timer if queue currently empty */
if (q->read_ptr == q->write_ptr && trans_pcie->wd_timeout)
mod_timer(&txq->stuck_timer, jiffies + trans_pcie->wd_timeout);
/* Tell device the write index *just past* this latest filled TFD */ /* Tell device the write index *just past* this latest filled TFD */
q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
iwl_txq_update_write_ptr(trans, txq); iwl_txq_update_write_ptr(trans, txq);
...@@ -1442,8 +1479,6 @@ static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn, ...@@ -1442,8 +1479,6 @@ static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
spin_lock(&txq->lock); spin_lock(&txq->lock);
txq->time_stamp = jiffies;
if (txq->q.read_ptr != tfd_num) { if (txq->q.read_ptr != tfd_num) {
IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d -> %d (%d)\n", IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d -> %d (%d)\n",
txq_id, txq->q.read_ptr, tfd_num, ssn); txq_id, txq->q.read_ptr, tfd_num, ssn);
...@@ -1500,6 +1535,9 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans, ...@@ -1500,6 +1535,9 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans,
trans_pcie->rx_page_order = get_order(8 * 1024); trans_pcie->rx_page_order = get_order(8 * 1024);
else else
trans_pcie->rx_page_order = get_order(4 * 1024); trans_pcie->rx_page_order = get_order(4 * 1024);
trans_pcie->wd_timeout =
msecs_to_jiffies(trans_cfg->queue_watchdog_timeout);
} }
static void iwl_trans_pcie_free(struct iwl_trans *trans) static void iwl_trans_pcie_free(struct iwl_trans *trans)
...@@ -1589,40 +1627,6 @@ static int iwl_trans_pcie_wait_tx_queue_empty(struct iwl_trans *trans) ...@@ -1589,40 +1627,6 @@ static int iwl_trans_pcie_wait_tx_queue_empty(struct iwl_trans *trans)
return ret; return ret;
} }
/*
* On every watchdog tick we check (latest) time stamp. If it does not
* change during timeout period and queue is not empty we reset firmware.
*/
static int iwl_trans_pcie_check_stuck_queue(struct iwl_trans *trans, int cnt)
{
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
struct iwl_tx_queue *txq = &trans_pcie->txq[cnt];
struct iwl_queue *q = &txq->q;
unsigned long timeout;
if (q->read_ptr == q->write_ptr) {
txq->time_stamp = jiffies;
return 0;
}
timeout = txq->time_stamp +
msecs_to_jiffies(hw_params(trans).wd_timeout);
if (time_after(jiffies, timeout)) {
IWL_ERR(trans, "Queue %d stuck for %u ms.\n", q->id,
hw_params(trans).wd_timeout);
IWL_ERR(trans, "Current SW read_ptr %d write_ptr %d\n",
q->read_ptr, q->write_ptr);
IWL_ERR(trans, "Current HW read_ptr %d write_ptr %d\n",
iwl_read_prph(trans, SCD_QUEUE_RDPTR(cnt))
& (TFD_QUEUE_SIZE_MAX - 1),
iwl_read_prph(trans, SCD_QUEUE_WRPTR(cnt)));
return 1;
}
return 0;
}
static const char *get_fh_string(int cmd) static const char *get_fh_string(int cmd)
{ {
switch (cmd) { switch (cmd) {
...@@ -2039,7 +2043,6 @@ const struct iwl_trans_ops trans_ops_pcie = { ...@@ -2039,7 +2043,6 @@ const struct iwl_trans_ops trans_ops_pcie = {
.dbgfs_register = iwl_trans_pcie_dbgfs_register, .dbgfs_register = iwl_trans_pcie_dbgfs_register,
.wait_tx_queue_empty = iwl_trans_pcie_wait_tx_queue_empty, .wait_tx_queue_empty = iwl_trans_pcie_wait_tx_queue_empty,
.check_stuck_queue = iwl_trans_pcie_check_stuck_queue,
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
.suspend = iwl_trans_pcie_suspend, .suspend = iwl_trans_pcie_suspend,
......
...@@ -307,6 +307,8 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) ...@@ -307,6 +307,8 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r)
* @n_no_reclaim_cmds: # of commands in list * @n_no_reclaim_cmds: # of commands in list
* @rx_buf_size_8k: 8 kB RX buffer size needed for A-MSDUs, * @rx_buf_size_8k: 8 kB RX buffer size needed for A-MSDUs,
* if unset 4k will be the RX buffer size * if unset 4k will be the RX buffer size
* @queue_watchdog_timeout: time (in ms) after which queues
* are considered stuck and will trigger device restart
*/ */
struct iwl_trans_config { struct iwl_trans_config {
struct iwl_op_mode *op_mode; struct iwl_op_mode *op_mode;
...@@ -318,6 +320,7 @@ struct iwl_trans_config { ...@@ -318,6 +320,7 @@ struct iwl_trans_config {
int n_no_reclaim_cmds; int n_no_reclaim_cmds;
bool rx_buf_size_8k; bool rx_buf_size_8k;
unsigned int queue_watchdog_timeout;
}; };
/** /**
...@@ -355,7 +358,6 @@ struct iwl_trans_config { ...@@ -355,7 +358,6 @@ struct iwl_trans_config {
* irq, tasklet etc... From this point on, the device may not issue * irq, tasklet etc... From this point on, the device may not issue
* any interrupt (incl. RFKILL). * any interrupt (incl. RFKILL).
* May sleep * May sleep
* @check_stuck_queue: check if a specific queue is stuck
* @wait_tx_queue_empty: wait until all tx queues are empty * @wait_tx_queue_empty: wait until all tx queues are empty
* May sleep * May sleep
* @dbgfs_register: add the dbgfs files under this directory. Files will be * @dbgfs_register: add the dbgfs files under this directory. Files will be
...@@ -394,7 +396,6 @@ struct iwl_trans_ops { ...@@ -394,7 +396,6 @@ struct iwl_trans_ops {
void (*free)(struct iwl_trans *trans); void (*free)(struct iwl_trans *trans);
int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir);
int (*check_stuck_queue)(struct iwl_trans *trans, int q);
int (*wait_tx_queue_empty)(struct iwl_trans *trans); int (*wait_tx_queue_empty)(struct iwl_trans *trans);
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
int (*suspend)(struct iwl_trans *trans); int (*suspend)(struct iwl_trans *trans);
...@@ -577,13 +578,6 @@ static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) ...@@ -577,13 +578,6 @@ static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans)
return trans->ops->wait_tx_queue_empty(trans); return trans->ops->wait_tx_queue_empty(trans);
} }
static inline int iwl_trans_check_stuck_queue(struct iwl_trans *trans, int q)
{
WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,
"%s bad state = %d", __func__, trans->state);
return trans->ops->check_stuck_queue(trans, q);
}
static inline int iwl_trans_dbgfs_register(struct iwl_trans *trans, static inline int iwl_trans_dbgfs_register(struct iwl_trans *trans,
struct dentry *dir) struct dentry *dir)
{ {
......
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