iommu/io-pgtable-arm-v7s: Convert to IOMMU API TLB sync
authorRobin Murphy <robin.murphy@arm.com>
Thu, 28 Sep 2017 14:55:02 +0000 (15:55 +0100)
committerJoerg Roedel <jroedel@suse.de>
Mon, 2 Oct 2017 13:45:25 +0000 (15:45 +0200)
Now that the core API issues its own post-unmap TLB sync call, push that
operation out from the io-pgtable-arm-v7s internals into the users. For
now, we leave the invalidation implicit in the unmap operation, since
none of the current users would benefit much from any change to that.

Note that the conversion of msm_iommu is implicit, since that apparently
has no specific TLB sync operation anyway.

CC: Yong Wu <yong.wu@mediatek.com>
CC: Rob Clark <robdclark@gmail.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/io-pgtable-arm-v7s.c
drivers/iommu/mtk_iommu.c
drivers/iommu/qcom_iommu.c

index d665d0dc16e8f787813a6106d15bd83afacc4f34..397531da8d9c658077922ac74b168103f6662775 100644 (file)
@@ -660,16 +660,11 @@ static int arm_v7s_unmap(struct io_pgtable_ops *ops, unsigned long iova,
                         size_t size)
 {
        struct arm_v7s_io_pgtable *data = io_pgtable_ops_to_data(ops);
-       size_t unmapped;
 
        if (WARN_ON(upper_32_bits(iova)))
                return 0;
 
-       unmapped = __arm_v7s_unmap(data, iova, size, 1, data->pgd);
-       if (unmapped)
-               io_pgtable_tlb_sync(&data->iop);
-
-       return unmapped;
+       return __arm_v7s_unmap(data, iova, size, 1, data->pgd);
 }
 
 static phys_addr_t arm_v7s_iova_to_phys(struct io_pgtable_ops *ops,
index bd515be5b380e32ac224b55d5b9a2dfff26a15ef..d0c8dfbbd74d89e29e53bfee8cd57988fa031d37 100644 (file)
@@ -391,6 +391,11 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain,
        return unmapsz;
 }
 
+static void mtk_iommu_iotlb_sync(struct iommu_domain *domain)
+{
+       mtk_iommu_tlb_sync(mtk_iommu_get_m4u_data());
+}
+
 static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
                                          dma_addr_t iova)
 {
@@ -490,6 +495,8 @@ static struct iommu_ops mtk_iommu_ops = {
        .map            = mtk_iommu_map,
        .unmap          = mtk_iommu_unmap,
        .map_sg         = default_iommu_map_sg,
+       .flush_iotlb_all = mtk_iommu_iotlb_sync,
+       .iotlb_sync     = mtk_iommu_iotlb_sync,
        .iova_to_phys   = mtk_iommu_iova_to_phys,
        .add_device     = mtk_iommu_add_device,
        .remove_device  = mtk_iommu_remove_device,
index c8a587d034b0d7e75d276af1b8c7cdc9e02e5aad..4a2c4378b3dbe9ff48ea38f91569386534f0cb17 100644 (file)
@@ -443,6 +443,19 @@ static size_t qcom_iommu_unmap(struct iommu_domain *domain, unsigned long iova,
        return ret;
 }
 
+static void qcom_iommu_iotlb_sync(struct iommu_domain *domain)
+{
+       struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
+       struct io_pgtable *pgtable = container_of(qcom_domain->pgtbl_ops,
+                                                 struct io_pgtable, ops);
+       if (!qcom_domain->pgtbl_ops)
+               return;
+
+       pm_runtime_get_sync(qcom_domain->iommu->dev);
+       qcom_iommu_tlb_sync(pgtable->cookie);
+       pm_runtime_put_sync(qcom_domain->iommu->dev);
+}
+
 static phys_addr_t qcom_iommu_iova_to_phys(struct iommu_domain *domain,
                                           dma_addr_t iova)
 {
@@ -570,6 +583,8 @@ static const struct iommu_ops qcom_iommu_ops = {
        .map            = qcom_iommu_map,
        .unmap          = qcom_iommu_unmap,
        .map_sg         = default_iommu_map_sg,
+       .flush_iotlb_all = qcom_iommu_iotlb_sync,
+       .iotlb_sync     = qcom_iommu_iotlb_sync,
        .iova_to_phys   = qcom_iommu_iova_to_phys,
        .add_device     = qcom_iommu_add_device,
        .remove_device  = qcom_iommu_remove_device,