Переглянути джерело

qcacmn: Add support for iommu domain in place of mapping

Add support for iommu domain instead of mapping in
struct __qdf_device to support use of API
pld_smmu_get_domain in place of pld_smmu_get_mapping,
which is to be deprecated.

Change-Id: I89e9eea8ec7095a79493c0adca15c8034c21f79a
CRs-Fixed: 2464861
Rakshith Suresh Patkar 5 роки тому
батько
коміт
49f2d779be
2 змінених файлів з 32 додано та 5 видалено
  1. 28 5
      qdf/linux/src/i_qdf_mem.h
  2. 4 0
      qdf/linux/src/i_qdf_types.h

+ 28 - 5
qdf/linux/src/i_qdf_mem.h

@@ -211,13 +211,36 @@ static inline bool __qdf_mem_smmu_s1_enabled(qdf_device_t osdev)
 }
 
 #ifdef CONFIG_ARM_SMMU
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
+/**
+ * __qdf_dev_get_domain() - get iommu domain from osdev
+ * @osdev: parent device instance
+ *
+ * Return: iommu domain
+ */
+static inline struct iommu_domain *
+__qdf_dev_get_domain(qdf_device_t osdev)
+{
+	return osdev->domain;
+}
+#else
+static inline struct iommu_domain *
+__qdf_dev_get_domain(qdf_device_t osdev)
+{
+	if (osdev->iommu_mapping)
+		return osdev->iommu_mapping->domain;
+
+	return NULL;
+}
+#endif
+
 /**
  * __qdf_mem_paddr_from_dmaaddr() - get actual physical address from dma_addr
  * @osdev: parent device instance
  * @dma_addr: dma_addr
  *
  * Get actual physical address from dma_addr based on SMMU enablement status.
- * IF SMMU Stage 1 tranlation is enabled, DMA APIs return IO virtual address
+ * IF SMMU Stage 1 translation is enabled, DMA APIs return IO virtual address
  * (IOVA) otherwise returns physical address. So get SMMU physical address
  * mapping from IOVA.
  *
@@ -227,12 +250,12 @@ static inline unsigned long
 __qdf_mem_paddr_from_dmaaddr(qdf_device_t osdev,
 			     qdf_dma_addr_t dma_addr)
 {
-	struct dma_iommu_mapping *mapping;
+	struct iommu_domain *domain;
 
 	if (__qdf_mem_smmu_s1_enabled(osdev)) {
-		mapping = osdev->iommu_mapping;
-		if (mapping)
-			return iommu_iova_to_phys(mapping->domain, dma_addr);
+		domain = __qdf_dev_get_domain(osdev);
+		if (domain)
+			return iommu_iova_to_phys(domain, dma_addr);
 	}
 
 	return dma_addr;

+ 4 - 0
qdf/linux/src/i_qdf_types.h

@@ -246,7 +246,11 @@ struct __qdf_device {
 	enum qdf_bus_type bus_type;
 	const struct hif_bus_id *bid;
 	bool smmu_s1_enabled;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
+	struct iommu_domain *domain;
+#else
 	struct dma_iommu_mapping *iommu_mapping;
+#endif
 };
 typedef struct __qdf_device *__qdf_device_t;