From 49f2d779be43ac3dca88b40f74c88f370423b688 Mon Sep 17 00:00:00 2001 From: Rakshith Suresh Patkar Date: Thu, 16 May 2019 12:53:48 +0530 Subject: [PATCH] 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 --- qdf/linux/src/i_qdf_mem.h | 33 ++++++++++++++++++++++++++++----- qdf/linux/src/i_qdf_types.h | 4 ++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/qdf/linux/src/i_qdf_mem.h b/qdf/linux/src/i_qdf_mem.h index 5fd5c971f841..5262aa85a4ba 100644 --- a/qdf/linux/src/i_qdf_mem.h +++ b/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; diff --git a/qdf/linux/src/i_qdf_types.h b/qdf/linux/src/i_qdf_types.h index d23a1b90d76b..affd9d09225b 100644 --- a/qdf/linux/src/i_qdf_types.h +++ b/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;