Author: eadler
Date: Thu Mar  1 05:50:48 2018
New Revision: 330172
URL: https://svnweb.freebsd.org/changeset/base/330172

Log:
  MFC r313412:
  
  [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.

Modified:
  stable/11/sys/dev/iwm/if_iwm.c
  stable/11/sys/dev/iwm/if_iwm_pcie_trans.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/iwm/if_iwm.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm.c      Thu Mar  1 05:49:32 2018        
(r330171)
+++ stable/11/sys/dev/iwm/if_iwm.c      Thu Mar  1 05:50:48 2018        
(r330172)
@@ -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 *,
@@ -1104,18 +1103,6 @@ fail:    iwm_free_rx_ring(sc, ring);
 }
 
 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)
 {
        /* Reset the ring state */
@@ -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);

Modified: stable/11/sys/dev/iwm/if_iwm_pcie_trans.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_pcie_trans.c   Thu Mar  1 05:49:32 2018        
(r330171)
+++ stable/11/sys/dev/iwm/if_iwm_pcie_trans.c   Thu Mar  1 05:50:48 2018        
(r330172)
@@ -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;
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to