Explorar o código

qcacmn: Add API to set dma mask for device

Currently DMA mask for the device is set during hif_enable_bus.
If the datapath memory prealloc feature is enabled, there are
a few dma memory allocation which is done before the DMA mask
is set for the device. This leads to the aforementioned dma
memory pre-allocation to be attempted at the default DMA mask.
Due to this the entire device capability of dma address might
not be used.

Add hif api to set dma mask before hif is initialized. This
is needed to set dma mask in case of datapath memory pre allocation.

Change-Id: I6fd25d9cb6ab3aaacd6f959abe4e060e23f37095
CRs-Fixed: 2845020
Rakesh Pillai %!s(int64=4) %!d(string=hai) anos
pai
achega
4138c9b7d8
Modificáronse 2 ficheiros con 35 adicións e 0 borrados
  1. 13 0
      hif/inc/hif.h
  2. 22 0
      hif/src/hif_main.c

+ 13 - 0
hif/inc/hif.h

@@ -916,6 +916,19 @@ struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx,
 				  struct hif_driver_state_callbacks *cbk,
 				  struct wlan_objmgr_psoc *psoc);
 
+/**
+ * hif_init_dma_mask() - Set dma mask for the dev
+ * @dev: dev for which DMA mask is to be set
+ * @bus_type: bus type for the target
+ *
+ * This API sets the DMA mask for the device. before the datapath
+ * memory pre-allocation is done. If the DMA mask is not set before
+ * requesting the DMA memory, kernel defaults to a 32-bit DMA mask,
+ * and does not utilize the full device capability.
+ *
+ * Return: 0 - success, non-zero on failure.
+ */
+int hif_init_dma_mask(struct device *dev, enum qdf_bus_type bus_type);
 void hif_close(struct hif_opaque_softc *hif_ctx);
 QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
 		      void *bdev, const struct hif_bus_id *bid,

+ 22 - 0
hif/src/hif_main.c

@@ -843,6 +843,28 @@ static QDF_STATUS hif_hal_detach(struct hif_softc *scn)
 }
 #endif
 
+int hif_init_dma_mask(struct device *dev, enum qdf_bus_type bus_type)
+{
+	int ret;
+
+	switch (bus_type) {
+	case QDF_BUS_TYPE_IPCI:
+		ret = qdf_set_dma_coherent_mask(dev,
+						DMA_COHERENT_MASK_DEFAULT);
+		if (ret) {
+			hif_err("Failed to set dma mask error = %d", ret);
+			return ret;
+		}
+
+		break;
+	default:
+		/* Follow the existing sequence for other targets */
+		break;
+	}
+
+	return 0;
+}
+
 /**
  * hif_enable(): hif_enable
  * @hif_ctx: hif_ctx