[iwm] Get rid of iwm_disable_rx_dma, just use iwm_pcie_rx_stop directly.

* This also fixes one of many small nic lock handling bugs, and matches
  iwlwifi's code.

Obtained from:	DragonflyBSD git 50787d03cd0a0366c9cc4a055bb6977e5f65c85d
This commit is contained in:
adrian 2017-02-08 06:43:02 +00:00
parent 073acc8136
commit 9048965cc1
2 changed files with 18 additions and 25 deletions

View File

@ -302,7 +302,6 @@ static int iwm_alloc_sched(struct iwm_softc *);
static int iwm_alloc_kw(struct iwm_softc *);
static int iwm_alloc_ict(struct iwm_softc *);
static int iwm_alloc_rx_ring(struct iwm_softc *, struct iwm_rx_ring *);
static void iwm_disable_rx_dma(struct iwm_softc *);
static void iwm_reset_rx_ring(struct iwm_softc *, struct iwm_rx_ring *);
static void iwm_free_rx_ring(struct iwm_softc *, struct iwm_rx_ring *);
static int iwm_alloc_tx_ring(struct iwm_softc *, struct iwm_tx_ring *,
@ -1103,18 +1102,6 @@ fail: iwm_free_rx_ring(sc, ring);
return error;
}
static void
iwm_disable_rx_dma(struct iwm_softc *sc)
{
/* XXX conditional nic locks are stupid */
/* XXX print out if we can't lock the NIC? */
if (iwm_nic_lock(sc)) {
/* XXX handle if RX stop doesn't finish? */
(void) iwm_pcie_rx_stop(sc);
iwm_nic_unlock(sc);
}
}
static void
iwm_reset_rx_ring(struct iwm_softc *sc, struct iwm_rx_ring *ring)
{
@ -1401,7 +1388,7 @@ iwm_stop_device(struct iwm_softc *sc)
}
iwm_nic_unlock(sc);
}
iwm_disable_rx_dma(sc);
iwm_pcie_rx_stop(sc);
/* Stop RX ring. */
iwm_reset_rx_ring(sc, &sc->rxq);
@ -1485,16 +1472,18 @@ iwm_mvm_nic_config(struct iwm_softc *sc)
static int
iwm_nic_rx_init(struct iwm_softc *sc)
{
if (!iwm_nic_lock(sc))
return EBUSY;
/*
* Initialize RX ring. This is from the iwn driver.
*/
memset(sc->rxq.stat, 0, sizeof(*sc->rxq.stat));
/* stop DMA */
iwm_disable_rx_dma(sc);
/* Stop Rx DMA */
iwm_pcie_rx_stop(sc);
if (!iwm_nic_lock(sc))
return EBUSY;
/* reset and flush pointers */
IWM_WRITE(sc, IWM_FH_MEM_RCSR_CHNL0_RBDCB_WPTR, 0);
IWM_WRITE(sc, IWM_FH_MEM_RCSR_CHNL0_FLUSH_RB_REQ, 0);
IWM_WRITE(sc, IWM_FH_RSCSR_CHNL0_RDPTR, 0);

View File

@ -572,10 +572,14 @@ iwm_set_pwr(struct iwm_softc *sc)
int
iwm_pcie_rx_stop(struct iwm_softc *sc)
{
IWM_WRITE(sc, IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
return (iwm_poll_bit(sc, IWM_FH_MEM_RSSR_RX_STATUS_REG,
IWM_FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE,
IWM_FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE,
1000));
int ret = 0;
if (iwm_nic_lock(sc)) {
IWM_WRITE(sc, IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
ret = iwm_poll_bit(sc, IWM_FH_MEM_RSSR_RX_STATUS_REG,
IWM_FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE,
IWM_FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE,
1000);
iwm_nic_unlock(sc);
}
return ret;
}