From owner-svn-src-all@freebsd.org Wed Feb 8 06:43:03 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7207DCC7D50; Wed, 8 Feb 2017 06:43:03 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 44290D92; Wed, 8 Feb 2017 06:43:03 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v186h2Hm009230; Wed, 8 Feb 2017 06:43:02 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v186h2Ic009228; Wed, 8 Feb 2017 06:43:02 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201702080643.v186h2Ic009228@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Wed, 8 Feb 2017 06:43:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313412 - head/sys/dev/iwm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Feb 2017 06:43:03 -0000 Author: adrian Date: Wed Feb 8 06:43:02 2017 New Revision: 313412 URL: https://svnweb.freebsd.org/changeset/base/313412 Log: [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 Modified: head/sys/dev/iwm/if_iwm.c head/sys/dev/iwm/if_iwm_pcie_trans.c Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Wed Feb 8 03:21:29 2017 (r313411) +++ head/sys/dev/iwm/if_iwm.c Wed Feb 8 06:43:02 2017 (r313412) @@ -302,7 +302,6 @@ static int iwm_alloc_sched(struct iwm_so 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: head/sys/dev/iwm/if_iwm_pcie_trans.c ============================================================================== --- head/sys/dev/iwm/if_iwm_pcie_trans.c Wed Feb 8 03:21:29 2017 (r313411) +++ head/sys/dev/iwm/if_iwm_pcie_trans.c Wed Feb 8 06:43:02 2017 (r313412) @@ -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; }