Parcourir la source

qcacmn: Clarify usage on Q_TARGET_ACCESS_BEGIN/END

Document where register writes are for legacy vs srng devices.
With the target access begin/end calls being associated with
the register writes and the register writes being associated to
specific HW, we avoid performing unneeded force wakes on common
code paths shared by legacy & srng based hardware.

Change-Id: Id91399d03298bfc5df56f0c5d5d14b648b665279
CRs-Fixed: 2117144
Yun Park il y a 7 ans
Parent
commit
3fb3644e61

+ 1 - 1
hif/src/ce/ce_api.h

@@ -495,7 +495,7 @@ struct CE_ring_state;
 
 struct ce_ops {
 	uint32_t (*ce_get_desc_size)(uint8_t ring_type);
-	void (*ce_ring_setup)(struct hif_softc *scn, uint8_t ring_type,
+	int (*ce_ring_setup)(struct hif_softc *scn, uint8_t ring_type,
 		uint32_t ce_id, struct CE_ring_state *ring,
 		struct CE_attr *attr);
 	int (*ce_send_nolock)(struct CE_handle *copyeng,

+ 4 - 0
hif/src/ce/ce_diag.c

@@ -173,6 +173,8 @@ QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *hif_ctx,
 		HIF_ERROR("%s: DIAG CE not present", __func__);
 		return QDF_STATUS_E_INVAL;
 	}
+	/* not supporting diag ce on srng based systems, therefore we know this
+	 * isn't an srng based system */
 
 	transaction_id = (mux_id & MUX_ID_MASK) |
 		 (transaction_id & TRANSACTION_ID_MASK);
@@ -377,6 +379,8 @@ QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *hif_ctx,
 		HIF_ERROR("%s: DIAG CE not present", __func__);
 		return QDF_STATUS_E_INVAL;
 	}
+	/* not supporting diag ce on srng based systems, therefore we know this
+	 * isn't an srng based system */
 
 	transaction_id = (mux_id & MUX_ID_MASK) |
 		(transaction_id & TRANSACTION_ID_MASK);

+ 16 - 19
hif/src/ce/ce_main.c

@@ -786,13 +786,13 @@ static struct CE_ring_state *ce_alloc_ring_state(struct CE_state *CE_state,
 	return ce_ring;
 }
 
-static void ce_ring_setup(struct hif_softc *scn, uint8_t ring_type,
+static int ce_ring_setup(struct hif_softc *scn, uint8_t ring_type,
 			uint32_t ce_id, struct CE_ring_state *ring,
 			struct CE_attr *attr)
 {
 	struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
 
-	hif_state->ce_services->ce_ring_setup(scn, ring_type, ce_id,
+	return hif_state->ce_services->ce_ring_setup(scn, ring_type, ce_id,
 					      ring, attr);
 }
 
@@ -897,6 +897,7 @@ struct CE_handle *ce_init(struct hif_softc *scn,
 	unsigned int nentries;
 	bool malloc_CE_state = false;
 	bool malloc_src_ring = false;
+	int status;
 
 	QDF_ASSERT(CE_id < scn->ce_count);
 	ctrl_addr = CE_BASE_ADDRESS(CE_id);
@@ -982,13 +983,11 @@ struct CE_handle *ce_init(struct hif_softc *scn,
 				CE_DESC_RING_ALIGN - 1) &
 				 ~(CE_DESC_RING_ALIGN - 1));
 
-			if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
+			status = ce_ring_setup(scn, CE_RING_SRC, CE_id,
+					       src_ring, attr);
+			if (status < 0)
 				goto error_target_access;
 
-			ce_ring_setup(scn, CE_RING_SRC, CE_id, src_ring, attr);
-
-			if (Q_TARGET_ACCESS_END(scn) < 0)
-				goto error_target_access;
 			ce_ring_test_initial_indexes(CE_id, src_ring,
 						     "src_ring");
 		}
@@ -1017,13 +1016,9 @@ struct CE_handle *ce_init(struct hif_softc *scn,
 				goto error_no_dma_mem;
 			}
 
-			if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
-				goto error_target_access;
-
-			ce_ring_setup(scn, CE_RING_DEST, CE_id,
+			status = ce_ring_setup(scn, CE_RING_DEST, CE_id,
 				      dest_ring, attr);
-
-			if (Q_TARGET_ACCESS_END(scn) < 0)
+			if (status < 0)
 				goto error_target_access;
 
 			ce_ring_test_initial_indexes(CE_id, dest_ring,
@@ -1054,13 +1049,11 @@ struct CE_handle *ce_init(struct hif_softc *scn,
 
 					return NULL;
 				}
-				if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
-					goto error_target_access;
-
-				ce_ring_setup(scn, CE_RING_STATUS, CE_id,
-						CE_state->status_ring, attr);
 
-				if (Q_TARGET_ACCESS_END(scn) < 0)
+				status = ce_ring_setup(scn, CE_RING_STATUS,
+					       CE_id, CE_state->status_ring,
+					       attr);
+				if (status < 0)
 					goto error_target_access;
 
 			}
@@ -3105,6 +3098,8 @@ void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib)
 	scn->hif_attribute = hif_attrib;
 }
 
+
+/* disable interrupts (only applicable for legacy copy engine currently */
 void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num)
 {
 	struct hif_softc *scn = HIF_GET_SOFTC(osc);
@@ -3145,6 +3140,8 @@ static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state)
  * Called from the PCI interrupt handler when a
  * firmware-generated interrupt to the Host.
  *
+ * only registered for legacy ce devices
+ *
  * Return: status of handled irq
  */
 irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)

+ 11 - 1
hif/src/ce/ce_service.c

@@ -2594,10 +2594,16 @@ static uint32_t ce_get_desc_size_legacy(uint8_t ring_type)
 	return 0;
 }
 
-static void ce_ring_setup_legacy(struct hif_softc *scn, uint8_t ring_type,
+static int ce_ring_setup_legacy(struct hif_softc *scn, uint8_t ring_type,
 		uint32_t ce_id, struct CE_ring_state *ring,
 		struct CE_attr *attr)
 {
+	int status = Q_TARGET_ACCESS_BEGIN(scn);
+
+	if (status < 0)
+		goto out;
+
+
 	switch (ring_type) {
 	case CE_RING_SRC:
 		ce_legacy_src_ring_setup(scn, ce_id, ring, attr);
@@ -2610,6 +2616,10 @@ static void ce_ring_setup_legacy(struct hif_softc *scn, uint8_t ring_type,
 		qdf_assert(0);
 		break;
 	}
+
+	Q_TARGET_ACCESS_END(scn);
+out:
+	return status;
 }
 
 static void ce_prepare_shadow_register_v2_cfg_legacy(struct hif_softc *scn,

+ 3 - 1
hif/src/ce/ce_service_srng.c

@@ -710,7 +710,7 @@ static void ce_srng_status_ring_setup(struct hif_softc *scn, uint32_t ce_id,
 			ce_id, 0, &ring_params);
 }
 
-static void ce_ring_setup_srng(struct hif_softc *scn, uint8_t ring_type,
+static int ce_ring_setup_srng(struct hif_softc *scn, uint8_t ring_type,
 		uint32_t ce_id, struct CE_ring_state *ring,
 		struct CE_attr *attr)
 {
@@ -728,6 +728,8 @@ static void ce_ring_setup_srng(struct hif_softc *scn, uint8_t ring_type,
 		qdf_assert(0);
 		break;
 	}
+
+	return 0;
 }
 
 static void ce_construct_shadow_config_srng(struct hif_softc *scn)

+ 10 - 5
hif/src/pcie/if_pci.c

@@ -159,7 +159,7 @@ static void pci_dispatch_interrupt(struct hif_softc *scn)
 	}
 }
 
-irqreturn_t hif_pci_interrupt_handler(int irq, void *arg)
+irqreturn_t hif_pci_legacy_ce_interrupt_handler(int irq, void *arg)
 {
 	struct hif_pci_softc *sc = (struct hif_pci_softc *)arg;
 	struct hif_softc *scn = HIF_GET_SOFTC(sc);
@@ -602,6 +602,7 @@ static void hif_pci_device_warm_reset(struct hif_pci_softc *sc)
 }
 
 #ifndef QCA_WIFI_3_0
+/* only applicable to legacy ce */
 int hif_check_fw_reg(struct hif_opaque_softc *hif_ctx)
 {
 	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
@@ -2436,7 +2437,7 @@ static int hif_configure_msi(struct hif_pci_softc *sc)
 			tasklet_init(&sc->intr_tq,
 				wlan_tasklet, (unsigned long)sc);
 			ret = request_irq(sc->pdev->irq,
-					  hif_pci_interrupt_handler,
+					 hif_pci_legacy_ce_interrupt_handler,
 					  IRQF_SHARED, "wlan_pci", sc);
 			if (ret) {
 				HIF_ERROR("%s: request_irq failed", __func__);
@@ -2458,8 +2459,8 @@ static int hif_configure_msi(struct hif_pci_softc *sc)
 		sc->num_msi_intrs = 1;
 		tasklet_init(&sc->intr_tq, wlan_tasklet, (unsigned long)sc);
 		ret = request_irq(sc->pdev->irq,
-				  hif_pci_interrupt_handler, IRQF_SHARED,
-				  "wlan_pci", sc);
+				  hif_pci_legacy_ce_interrupt_handler,
+				  IRQF_SHARED, "wlan_pci", sc);
 		if (ret) {
 			HIF_ERROR("%s: request_irq failed", __func__);
 			goto err_intr;
@@ -2495,7 +2496,7 @@ static int hif_pci_configure_legacy_irq(struct hif_pci_softc *sc)
 	/* do notn support MSI or MSI IRQ failed */
 	tasklet_init(&sc->intr_tq, wlan_tasklet, (unsigned long)sc);
 	ret = request_irq(sc->pdev->irq,
-			  hif_pci_interrupt_handler, IRQF_SHARED,
+			  hif_pci_legacy_ce_interrupt_handler, IRQF_SHARED,
 			  "wlan_pci", sc);
 	if (ret) {
 		HIF_ERROR("%s: request_irq failed, ret = %d", __func__, ret);
@@ -3118,6 +3119,8 @@ bus_resume:
  * ensure that the fastpath write index register is up to date
  * since runtime pm may cause ce_send_fast to skip the register
  * write.
+ *
+ * fastpath only applicable to legacy copy engine
  */
 void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx)
 {
@@ -3981,6 +3984,8 @@ void hif_pci_irq_enable(struct hif_softc *scn, int ce_id)
  * @scn: hif_softc
  * @ce_id: ce_id
  *
+ * only applicable to legacy copy engine...
+ *
  * Return: void
  */
 void hif_pci_irq_disable(struct hif_softc *scn, int ce_id)

+ 1 - 1
hif/src/pcie/if_pci.h

@@ -148,7 +148,7 @@ bool hif_pci_targ_is_present(struct hif_softc *scn, void *__iomem *mem);
 int hif_configure_irq(struct hif_softc *sc);
 void hif_pci_cancel_deferred_target_sleep(struct hif_softc *scn);
 void wlan_tasklet(unsigned long data);
-irqreturn_t hif_pci_interrupt_handler(int irq, void *arg);
+irqreturn_t hif_pci_legacy_ce_interrupt_handler(int irq, void *arg);
 int hif_pci_addr_in_boundary(struct hif_softc *scn, uint32_t offset);
 
 /*

+ 1 - 1
hif/src/snoc/if_ahb.c

@@ -222,7 +222,7 @@ int hif_ahb_configure_legacy_irq(struct hif_pci_softc *sc)
 		ret = -1;
 		goto end;
 	}
-	ret = request_irq(irq, hif_pci_interrupt_handler,
+	ret = request_irq(irq, hif_pci_legacy_ce_interrupt_handler,
 				IRQF_DISABLED, "wlan_ahb", sc);
 	if (ret) {
 		dev_err(&pdev->dev, "ath_request_irq failed\n");