svn commit: r330199 - stable/11/sys/dev/iwm

Eitan Adler eadler at FreeBSD.org
Thu Mar 1 06:32:47 UTC 2018


Author: eadler
Date: Thu Mar  1 06:32:46 2018
New Revision: 330199
URL: https://svnweb.freebsd.org/changeset/base/330199

Log:
  MFC r318002:
  
  [iwm] iwm_{read,write}_prph() don't grab the nic lock in iwm themselves.
  
  * Fix a couple of cases where the nic lock ended up not being grabbed
    during an iwm_read_prph() or iwm_write_prph().

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 06:31:07 2018	(r330198)
+++ stable/11/sys/dev/iwm/if_iwm.c	Thu Mar  1 06:32:46 2018	(r330199)
@@ -1293,9 +1293,9 @@ iwm_stop_device(struct iwm_softc *sc)
 
 	/* stop tx and rx.  tx and rx bits, as usual, are from if_iwn */
 
-	iwm_write_prph(sc, IWM_SCD_TXFACT, 0);
-
 	if (iwm_nic_lock(sc)) {
+		iwm_write_prph(sc, IWM_SCD_TXFACT, 0);
+
 		/* Stop each Tx DMA channel */
 		for (chnl = 0; chnl < IWM_FH_TCSR_CHNL_NUM; chnl++) {
 			IWM_WRITE(sc,
@@ -1323,8 +1323,10 @@ iwm_stop_device(struct iwm_softc *sc)
 
 	if (sc->cfg->device_family == IWM_DEVICE_FAMILY_7000) {
 		/* Power-down device's busmaster DMA clocks */
-		iwm_write_prph(sc, IWM_APMG_CLK_DIS_REG,
-		    IWM_APMG_CLK_VAL_DMA_CLK_RQT);
+		if (iwm_nic_lock(sc)) {
+			iwm_write_prph(sc, IWM_APMG_CLK_DIS_REG,
+			    IWM_APMG_CLK_VAL_DMA_CLK_RQT);
+		}
 		DELAY(5);
 	}
 
@@ -1621,8 +1623,6 @@ iwm_trans_pcie_fw_alive(struct iwm_softc *sc, uint32_t
 
 	iwm_ict_reset(sc);
 
-	iwm_nic_unlock(sc);
-
 	sc->scd_base_addr = iwm_read_prph(sc, IWM_SCD_SRAM_BASE_ADDR);
 	if (scd_base_addr != 0 &&
 	    scd_base_addr != sc->scd_base_addr) {
@@ -1631,6 +1631,8 @@ iwm_trans_pcie_fw_alive(struct iwm_softc *sc, uint32_t
 		    __func__, sc->scd_base_addr, scd_base_addr);
 	}
 
+	iwm_nic_unlock(sc);
+
 	/* reset context data, TX status and translation data */
 	error = iwm_write_mem(sc,
 	    sc->scd_base_addr + IWM_SCD_CONTEXT_MEM_LOWER_BOUND,
@@ -2590,9 +2592,11 @@ iwm_pcie_load_given_ucode(struct iwm_softc *sc,
 
 	if (image->is_dual_cpus) {
 		/* set CPU2 header address */
-                iwm_write_prph(sc,
-			       IWM_LMPM_SECURE_UCODE_LOAD_CPU2_HDR_ADDR,
-			       IWM_LMPM_SECURE_CPU2_HDR_MEM_SPACE);
+		if (iwm_nic_lock(sc)) {
+			iwm_write_prph(sc,
+				       IWM_LMPM_SECURE_UCODE_LOAD_CPU2_HDR_ADDR,
+				       IWM_LMPM_SECURE_CPU2_HDR_MEM_SPACE);
+		}
 
 		/* load to FW the binary sections of CPU2 */
 		ret = iwm_pcie_load_cpu_sections(sc, image, 2,
@@ -2621,7 +2625,10 @@ iwm_pcie_load_given_ucode_8000(struct iwm_softc *sc,
 
 	/* configure the ucode to be ready to get the secured image */
 	/* release CPU reset */
-	iwm_write_prph(sc, IWM_RELEASE_CPU_RESET, IWM_RELEASE_CPU_RESET_BIT);
+	if (iwm_nic_lock(sc)) {
+		iwm_write_prph(sc, IWM_RELEASE_CPU_RESET,
+		    IWM_RELEASE_CPU_RESET_BIT);
+	}
 
 	/* load to FW the binary Secured sections of CPU1 */
 	ret = iwm_pcie_load_cpu_sections_8000(sc, image, 1,
@@ -2875,10 +2882,14 @@ iwm_mvm_load_ucode_wait_alive(struct iwm_softc *sc,
 	IWM_LOCK(sc);
 	if (error) {
 		if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000) {
+			uint32_t a = 0x5a5a5a5a, b = 0x5a5a5a5a;
+			if (iwm_nic_lock(sc)) {
+				a = iwm_read_prph(sc, IWM_SB_CPU_1_STATUS);
+				b = iwm_read_prph(sc, IWM_SB_CPU_2_STATUS);
+			}
 			device_printf(sc->sc_dev,
 			    "SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
-			    iwm_read_prph(sc, IWM_SB_CPU_1_STATUS),
-			    iwm_read_prph(sc, IWM_SB_CPU_2_STATUS));
+			    a, b);
 		}
 		sc->cur_ucode = old_type;
 		return error;

Modified: stable/11/sys/dev/iwm/if_iwm_pcie_trans.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_pcie_trans.c	Thu Mar  1 06:31:07 2018	(r330198)
+++ stable/11/sys/dev/iwm/if_iwm_pcie_trans.c	Thu Mar  1 06:32:46 2018	(r330199)
@@ -498,11 +498,15 @@ iwm_apm_init(struct iwm_softc *sc)
 		 * just to discard the value. But that's the way the hardware
 		 * seems to like it.
 		 */
-		iwm_read_prph(sc, IWM_OSC_CLK);
-		iwm_read_prph(sc, IWM_OSC_CLK);
+		if (iwm_nic_lock(sc)) {
+			iwm_read_prph(sc, IWM_OSC_CLK);
+			iwm_read_prph(sc, IWM_OSC_CLK);
+		}
 		iwm_set_bits_prph(sc, IWM_OSC_CLK, IWM_OSC_CLK_FORCE_CONTROL);
-		iwm_read_prph(sc, IWM_OSC_CLK);
-		iwm_read_prph(sc, IWM_OSC_CLK);
+		if (iwm_nic_lock(sc)) {
+			iwm_read_prph(sc, IWM_OSC_CLK);
+			iwm_read_prph(sc, IWM_OSC_CLK);
+		}
 	}
 
 	/*
@@ -513,8 +517,10 @@ iwm_apm_init(struct iwm_softc *sc)
 	 * set by default in "CLK_CTRL_REG" after reset.
 	 */
 	if (sc->cfg->device_family == IWM_DEVICE_FAMILY_7000) {
-		iwm_write_prph(sc, IWM_APMG_CLK_EN_REG,
-		    IWM_APMG_CLK_VAL_DMA_CLK_RQT);
+		if (iwm_nic_lock(sc)) {
+			iwm_write_prph(sc, IWM_APMG_CLK_EN_REG,
+			    IWM_APMG_CLK_VAL_DMA_CLK_RQT);
+		}
 		DELAY(20);
 
 		/* Disable L1-Active */
@@ -522,8 +528,10 @@ iwm_apm_init(struct iwm_softc *sc)
 		    IWM_APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
 
 		/* Clear the interrupt in APMG if the NIC is in RFKILL */
-		iwm_write_prph(sc, IWM_APMG_RTC_INT_STT_REG,
-		    IWM_APMG_RTC_INT_STT_RFKILL);
+		if (iwm_nic_lock(sc)) {
+			iwm_write_prph(sc, IWM_APMG_RTC_INT_STT_REG,
+			    IWM_APMG_RTC_INT_STT_RFKILL);
+		}
 	}
  out:
 	if (error)
@@ -625,12 +633,12 @@ iwm_pcie_set_cmd_in_flight(struct iwm_softc *sc)
 		IWM_SETBITS(sc, IWM_CSR_GP_CNTRL,
 		    IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
 
-                ret = iwm_poll_bit(sc, IWM_CSR_GP_CNTRL,
+		ret = iwm_poll_bit(sc, IWM_CSR_GP_CNTRL,
 		    IWM_CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
 		    (IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
 		     IWM_CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP),
 		    15000);
-                if (ret == 0) {
+		if (ret == 0) {
 			IWM_CLRBITS(sc, IWM_CSR_GP_CNTRL,
 			    IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
 			device_printf(sc->sc_dev,


More information about the svn-src-all mailing list