MediaTek IOMMU improve tlb flush performance in map/unmap
Subsystems (5)
Yong Wu
maintainerv3 cover MediaTek IOMMU improve tlb flush performance in map/unmap
This patchset is to improve tlb flushing performance in iommu_map/unmap for MediaTek IOMMU.
For iommu_map, currently MediaTek IOMMU use IO_PGTABLE_QUIRK_TLBI_ON_MAP to do tlb_flush for each a memory chunk. this is so unnecessary. we could improve it by tlb flushing one time at the end of iommu_map.
For iommu_unmap, currently we have already improve this performance by gather. But the current gather should take care its granule size. if the granule size is different, it will do tlb flush and gather again. Our HW don't care about granule size. thus I gather the range in our file.
After this patchset, we could achieve only tlb flushing once in iommu_map and iommu_unmap.
Regardless of sg, for each a segment, I did a simple test:
size = 20 * SZ_1M; /* the worst case, all are 4k mapping. */ ret = iommu_map(domain, 0x5bb02000, 0x123f1000, size, IOMMU_READ); iommu_unmap(domain, 0x5bb02000, size);
This is the comparing time(unit is us):
original-time after-improve
map-20M 59943 2347 unmap-20M 264 36
This patchset also flush tlb once in the iommu_map_sg case.
patch [1/7][2/7][3/7] are for map while the others are for unmap.
This patchset base on:
a) mt8192 iommu v5
https://lore.kernel.org/linux-iommu/[email protected]/T/#t
b) iommu/io-pgtable: Remove tlb_flush_leaf
https://lore.kernel.org/linux-iommu/[email protected]/T/#mc8fbc98bee8bca865d73c873275ab34fed1c25c7
change note:
v3: Refactor the unmap flow suggested by Robin.
v2: https://lore.kernel.org/linux-iommu/[email protected]/
Refactor all the code.
base on v5.10-rc1.
Yong Wu (7):
iommu: Move iotlb_sync_map out from __iommu_map
iommu: Add iova and size as parameters in iotlb_sync_map iommu/mediatek: Add iotlb_sync_map to sync whole the iova range
iommu: Switch gather->end to unsigned long long
iommu: Allow io_pgtable_tlb ops optional
iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once iommu/mediatek: Remove the tlb-ops for v7s
drivers/iommu/iommu.c | 24 +++++++++++++++----- drivers/iommu/mtk_iommu.c | 45 +++++++++++++++----------------------- drivers/iommu/tegra-gart.c | 3 ++- include/linux/io-pgtable.h | 8 ++++--- include/linux/iommu.h | 8 ++++--- 5 files changed, 49 insertions(+), 39 deletions(-)
Signature · 7 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerPATCH v3 1/7 iommu: Move iotlb_sync_map out from __iommu_map
In the end of __iommu_map, It alway call iotlb_sync_map. This patch moves iotlb_sync_map out from __iommu_map since it is unnecessary to call this for each sg segment especially iotlb_sync_map is flush tlb all currently.
--- drivers/iommu/iommu.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
drivers/iommu/iommu.c +19 -5
@@ -2407,9 +2407,6 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova, size -= pgsize; } -if (ops->iotlb_sync_map) - ops->iotlb_sync_map (domain); -/* unroll mapping in case something went wrong */ if (ret)iommu_unmap (domain, orig_iova, orig_size - size);
@@ -2422,15 +2419,29 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova,int iommu_map (struct iommu_domain *domain,unsigned long iova,phys_addr_t paddr,size_t size,int prot) { +const struct iommu_ops *ops = domain->ops; +int ret; +might_sleep (); -return __iommu_map (domain, iova, paddr, size, prot,GFP_KERNEL ); + ret =__iommu_map (domain, iova, paddr, size, prot,GFP_KERNEL ); +if (ret ==0 && ops->iotlb_sync_map) + ops->iotlb_sync_map (domain); + +return ret; }EXPORT_SYMBOL_GPL (iommu_map);int iommu_map_atomic (struct iommu_domain *domain,unsigned long iova,phys_addr_t paddr,size_t size,int prot) { -return __iommu_map (domain, iova, paddr, size, prot,GFP_ATOMIC ); +const struct iommu_ops *ops = domain->ops; +int ret; + + ret =__iommu_map (domain, iova, paddr, size, prot,GFP_ATOMIC ); +if (ret ==0 && ops->iotlb_sync_map) + ops->iotlb_sync_map (domain); + +return ret; }EXPORT_SYMBOL_GPL (iommu_map_atomic);
@@ -2514,6 +2525,7 @@ static size_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sg, unsigned int nents, int prot, gfp_t gfp) { + const struct iommu_ops *ops = domain->ops;size_t len =0 , mapped =0 ;phys_addr_t start;unsigned int i =0 ;
@@ -2544,6 +2556,8 @@ static size_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova, sg =sg_next (sg); } +if (ops->iotlb_sync_map) + ops->iotlb_sync_map (domain);return mapped; out_err:
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 1/7] iommu: Move iotlb_sync_map out from __iommu_map
Quoted 7 lines · Yong Wu
In the end of
__iommu_map, It alway calliotlb_sync_map. This patch movesiotlb_sync_mapout from__iommu_mapsince it is unnecessary to call this for each sg segment especiallyiotlb_sync_mapis flush tlb all currently.Signed-off-by Yong Wu <[email protected]>Reviewed-by Robin Murphy <[email protected]>
What about adding a little helper that does the NULL check and method call instead of duplicating it all over?
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Yong Wu
maintainerRe: [PATCH v3 1/7] iommu: Move iotlb_sync_map out from __iommu_map
Quoted 11 lines · Christoph Hellwig
Quoted 7 lines · Yong Wu
In the end of
__iommu_map, It alway calliotlb_sync_map. This patch movesiotlb_sync_mapout from__iommu_mapsince it is unnecessary to call this for each sg segment especiallyiotlb_sync_mapis flush tlb all currently.Signed-off-by Yong Wu <[email protected]>Reviewed-by Robin Murphy <[email protected]>What about adding a little helper that does the NULL check and method call instead of duplicating it all over?
Thanks for the review. Of course OK.
Then the code like below.
(If the helper name "_iommu_map" is not good, please tell me.)
+static int _iommu_map(struct iommu_domain *domain, unsigned long iova,
+ phys_addr_t paddr, size_t size, int prot, gfp_t gfp)
+{
+ const struct iommu_ops *ops = domain->ops;
+ int ret;
+
+ ret = __iommu_map(domain, iova, paddr, size, prot, gfp);
+ if (ret == 0 && ops->iotlb_sync_map)
+ ops->iotlb_sync_map(domain);
+ return ret;
+}
+
int iommu_map(struct iommu_domain *domain, unsigned long iova,
phys_addr_t paddr, size_t size, int prot)
{
might_sleep();
- return __iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL);
+ return _iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL);
}
EXPORT_SYMBOL_GPL(iommu_map);
int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova,
phys_addr_t paddr, size_t size, int prot)
{
- return __iommu_map(domain, iova, paddr, size, prot, GFP_ATOMIC);
+ return _iommu_map(domain, iova, paddr, size, prot, GFP_ATOMIC);
}
EXPORT_SYMBOL_GPL(iommu_map_atomic);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerPATCH v3 2/7 iommu: Add iova and size as parameters in iotlb_sync_map
In reply to Yong Wuiotlb_sync_map allow IOMMU drivers tlb sync after completing the whole mapping. This patch adds iova and size as the parameters in it. then the IOMMU driver could flush tlb with the whole range once after iova mapping to improve performance.
--- drivers/iommu/iommu.c | 6 +++--- drivers/iommu/tegra-gart.c | 3 ++- include/linux/iommu.h | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/iommu/iommu.c +3 -3
@@ -2425,7 +2425,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,might_sleep (); ret =__iommu_map (domain, iova, paddr, size, prot,GFP_KERNEL );if (ret ==0 && ops->iotlb_sync_map) - ops->iotlb_sync_map (domain); + ops->iotlb_sync_map (domain, iova, size);return ret; }
@@ -2439,7 +2439,7 @@ int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova, ret =__iommu_map (domain, iova, paddr, size, prot,GFP_ATOMIC );if (ret ==0 && ops->iotlb_sync_map) - ops->iotlb_sync_map (domain); + ops->iotlb_sync_map (domain, iova, size);return ret; }
@@ -2557,7 +2557,7 @@ static size_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova, }if (ops->iotlb_sync_map) - ops->iotlb_sync_map (domain); + ops->iotlb_sync_map (domain, iova, mapped);return mapped; out_err:
drivers/iommu/tegra-gart.c +2 -1
@@ -261,7 +261,8 @@ static int gart_iommu_of_xlate(struct device *dev,return 0 ; } -static void gart_iommu_sync_map (struct iommu_domain *domain) +static void gart_iommu_sync_map (struct iommu_domain *domain,unsigned long iova, +size_t size) {FLUSH_GART_REGS (gart_handle); }
include/linux/iommu.h +2 -1
@@ -244,7 +244,8 @@ struct iommu_ops {size_t (*unmap)(struct iommu_domain *domain,unsigned long iova,size_t size,struct iommu_iotlb_gather *iotlb_gather);void (*flush_iotlb_all)(struct iommu_domain *domain); -void (*iotlb_sync_map)(struct iommu_domain *domain); +void (*iotlb_sync_map)(struct iommu_domain *domain,unsigned long iova, +size_t size);void (*iotlb_sync)(struct iommu_domain *domain,struct iommu_iotlb_gather *iotlb_gather);phys_addr_t (*iova_to_phys)(struct iommu_domain *domain,dma_addr_t iova);
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerPATCH v3 3/7 iommu/mediatek: Add iotlb_sync_map to sync whole the iova range
In reply to Yong WuRemove IO_PGTABLE_QUIRK_TLBI_ON_MAP to avoid tlb sync for each a small chunk memory, Use the new iotlb_sync_map to tlb_sync once for whole the iova range of iommu_map.
--- drivers/iommu/mtk_iommu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/iommu/mtk_iommu.c +9 -1
@@ -376,7 +376,6 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) dom->cfg = (struct io_pgtable_cfg ) { .quirks =IO_PGTABLE_QUIRK_ARM_NS |IO_PGTABLE_QUIRK_NO_PERMS | -IO_PGTABLE_QUIRK_TLBI_ON_MAP |IO_PGTABLE_QUIRK_ARM_MTK_EXT , .pgsize_bitmap = mtk_iommu_ops.pgsize_bitmap, .ias =MTK_IOMMU_HAS_FLAG (data->plat_data,IOVA_34_EN ) ?34 :32 ,
@@ -531,6 +530,14 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain, dom->data); } +static void mtk_iommu_sync_map (struct iommu_domain *domain,unsigned long iova, +size_t size) +{ +struct mtk_iommu_domain *dom =to_mtk_domain (domain); + +mtk_iommu_tlb_flush_range_sync (iova, size, size, dom->data); +} +static phys_addr_t mtk_iommu_iova_to_phys (struct iommu_domain *domain,dma_addr_t iova) {
@@ -655,6 +662,7 @@ static const struct iommu_ops mtk_iommu_ops = { .unmap = mtk_iommu_unmap, .flush_iotlb_all = mtk_iommu_flush_iotlb_all, .iotlb_sync = mtk_iommu_iotlb_sync, + .iotlb_sync_map = mtk_iommu_sync_map, .iova_to_phys = mtk_iommu_iova_to_phys, .probe_device = mtk_iommu_probe_device, .release_device = mtk_iommu_release_device,
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerPATCH v3 4/7 iommu: Switch gather->end to unsigned long long
In reply to Yong WuCurrently gather->end is "unsigned long" which may be overflow in arch32 in the corner case: 0xfff00000 + 0x100000(iova + size). Although it doesn't affect the size(end - start), it affects the checking "gather->end < end"
--- include/linux/iommu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/iommu.h +3 -2
@@ -178,7 +178,7 @@ enum iommu_dev_features {*/ struct iommu_iotlb_gather {unsigned long start; -unsigned long end; +unsigned long long end;size_t pgsize; };
@@ -537,7 +537,8 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain,struct iommu_iotlb_gather *gather, unsigned long iova, size_t size) { - unsigned long start = iova, end = start + size; + unsigned long start = iova; +unsigned long long end = start + size;/* * If the new page is disjoint from the current range or is mapped at
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
RE: [PATCH v3 4/7] iommu: Switch gather->end to unsigned long long
From: Yong Wu
Quoted 18 lines
Sent: 16 December 2020 10:36
Currently
gather->endis "unsigned long" which may be overflow in arch32 in the corner case:0xfff00000+ 0x100000(iova + size). Although it doesn't affect the size(end - start), it affects the checking "gather->end< end"Fixes a7d20dc19d9e ("iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes")Signed-off-by Yong Wu <[email protected]>--- include/linux/iommu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)include/linux/iommu.h +0
-0
include/linux/iommu.h enum iommu_dev_features { · line 183
Quoted 7 lines
include/linux/iommu.h +1
-1@@ -178,7 +178,7 @@ enum iommu_dev_features {*/ struct iommu_iotlb_gather {unsigned long start; -unsigned long end; +unsigned long long end;size_t pgsize; };
Doesn't that add two pad words on many 32bit systems? You probably ought to re-order the structure to keep the fields on their natural boundaries.
I'm not sure what is being mapped here, but could it make sense to just avoid using the highest addresses?
Then you never hit the problem.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerRe: [PATCH v3 4/7] iommu: Switch gather->end to unsigned long long
Hi David,
Quoted 31 lines · David Laight
From: Yong Wu
Quoted 18 lines
Sent: 16 December 2020 10:36
Currently
gather->endis "unsigned long" which may be overflow in arch32 in the corner case:0xfff00000+ 0x100000(iova + size). Although it doesn't affect the size(end - start), it affects the checking "gather->end< end"Fixes a7d20dc19d9e ("iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes")Signed-off-by Yong Wu <[email protected]>--- include/linux/iommu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)include/linux/iommu.h +0
-0include/linux/iommu.h enum iommu_dev_features { · line 183
Quoted 7 lines
include/linux/iommu.h +1
-1@@ -178,7 +178,7 @@ enum iommu_dev_features {*/ struct iommu_iotlb_gather {unsigned long start; -unsigned long end; +unsigned long long end;size_t pgsize; };Doesn't that add two pad words on many 32bit systems? You probably ought to re-order the structure to keep the fields on their natural boundaries.
Quoted 3 lines
I'm not sure what is being mapped here, but could it make sense to just avoid using the highest addresses?
Then you never hit the problem.
Thanks for your review. following Robin's suggesting, I will use "iova + size - 1", then avoid this.
Quoted 7 lines
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Robin Murphy
reviewerRe: [PATCH v3 4/7] iommu: Switch gather->end to unsigned long long
In reply to Yong WuQuoted 4 lines · Yong Wu
Currently
gather->endis "unsigned long" which may be overflow in arch32 in the corner case:0xfff00000+ 0x100000(iova + size). Although it doesn't affect the size(end - start), it affects the checking "gather->end< end"
This won't help the same situation at the top of a 64-bit address space, though, and now that we have TTBR1 support for AArch64 format that is definitely a thing. Better to just encode the end address as the actual end address, i.e. iova + size - 1. We don't lose anything other than the ability to encode zero-sized invalidations that don't make sense anyway.
Robin.
Quoted 21 lines
Fixes a7d20dc19d9e ("iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes")Signed-off-by Yong Wu <[email protected]>--- include/linux/iommu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)include/linux/iommu.h +1
-1@@ -178,7 +178,7 @@ enum iommu_dev_features {*/ struct iommu_iotlb_gather {unsigned long start; -unsigned long end; +unsigned long long end;size_t pgsize; };
include/linux/iommu.h static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, · line 544
Quoted 9 lines
include/linux/iommu.h +2
-1@@ -537,7 +537,8 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain,struct iommu_iotlb_gather *gather, unsigned long iova, size_t size) { - unsigned long start = iova, end = start + size; + unsigned long start = iova; +unsigned long long end = start + size;/* * If the new page is disjoint from the current range or is mapped at
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerRe: [PATCH v3 4/7] iommu: Switch gather->end to unsigned long long
Quoted 11 lines · Robin Murphy
Quoted 4 lines · Yong Wu
Currently
gather->endis "unsigned long" which may be overflow in arch32 in the corner case:0xfff00000+ 0x100000(iova + size). Although it doesn't affect the size(end - start), it affects the checking "gather->end< end"This won't help the same situation at the top of a 64-bit address space, though, and now that we have TTBR1 support for AArch64 format that is definitely a thing. Better to just encode the end address as the actual end address, i.e. iova + size - 1. We don't lose anything other than the ability to encode zero-sized invalidations that don't make sense anyway.
Thanks for the suggestion. "iova + size - 1" is better. Also I will change the "size" to "gather->end - gather->start + 1" in the iotlb_sync of arm-smmu-v3.c and mtk_iommu.c.
Quoted 30 lines
Robin.
Quoted 27 lines
Fixes a7d20dc19d9e ("iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes")Signed-off-by Yong Wu <[email protected]>--- include/linux/iommu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)include/linux/iommu.h +3
-2@@ -178,7 +178,7 @@ enum iommu_dev_features {*/ struct iommu_iotlb_gather {unsigned long start; -unsigned long end; +unsigned long long end;size_t pgsize; };@@ -537,7 +537,8 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain,struct iommu_iotlb_gather *gather, unsigned long iova, size_t size) { - unsigned long start = iova, end = start + size; + unsigned long start = iova; +unsigned long long end = start + size;
Quoted 3 lines
include/linux/iommu.h static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, · line 544
Quoted 3 lines
include/linux/iommu.h +0
-0/* * If the new page is disjoint from the current range or is mapped at
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Yong Wu
maintainerPATCH v3 5/7 iommu: Allow io_pgtable_tlb ops optional
In reply to Yong WuThis patch allows io_pgtable_tlb ops could be null since the IOMMU drivers may use the tlb ops from iommu framework.
--- include/linux/io-pgtable.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
include/linux/io-pgtable.h +5 -3
@@ -206,14 +206,16 @@ struct io_pgtable {static inline void io_pgtable_tlb_flush_all (struct io_pgtable *iop) { - iop->cfg.tlb->tlb_flush_all (iop->cookie); +if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_all) + iop->cfg.tlb->tlb_flush_all (iop->cookie); }static inline void io_pgtable_tlb_flush_walk (struct io_pgtable *iop,unsigned long iova,size_t size,size_t granule) { - iop->cfg.tlb->tlb_flush_walk (iova, size, granule, iop->cookie); +if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_walk) + iop->cfg.tlb->tlb_flush_walk (iova, size, granule, iop->cookie); } static inline void
@@ -221,7 +223,7 @@ io_pgtable_tlb_add_page(struct io_pgtable *iop, struct iommu_iotlb_gather * gather, unsigned long iova, size_t granule) { - if (iop->cfg.tlb->tlb_add_page) + if (iop->cfg.tlb && iop->cfg.tlb->tlb_add_page) iop->cfg.tlb->tlb_add_page(gather, iova, granule, iop->cookie); }
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 5/7] iommu: Allow io_pgtable_tlb ops optional
Quoted 2 lines · Yong Wu
This patch allows
io_pgtable_tlbops could be null since the IOMMU drivers may use the tlb ops from iommu framework.
There's not much in it, but I guess this does make more sense overall than just making .tlb_flush_all optional and drivers having to provide a full set of NULL callbacks.
Quoted 30 lines
Signed-off-by Yong Wu <[email protected]>--- include/linux/io-pgtable.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)include/linux/io-pgtable.h +4
-2@@ -206,14 +206,16 @@ struct io_pgtable {static inline void io_pgtable_tlb_flush_all (struct io_pgtable *iop) { - iop->cfg.tlb->tlb_flush_all (iop->cookie); +if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_all) + iop->cfg.tlb->tlb_flush_all (iop->cookie); }static inline void io_pgtable_tlb_flush_walk (struct io_pgtable *iop,unsigned long iova,size_t size,size_t granule) { - iop->cfg.tlb->tlb_flush_walk (iova, size, granule, iop->cookie); +if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_walk) + iop->cfg.tlb->tlb_flush_walk (iova, size, granule, iop->cookie); } static inline void
include/linux/io-pgtable.h io_pgtable_tlb_add_page(struct io_pgtable *iop, · line 229
Quoted 8 lines
include/linux/io-pgtable.h +1
-1@@ -221,7 +223,7 @@ io_pgtable_tlb_add_page(struct io_pgtable *iop, struct iommu_iotlb_gather * gather, unsigned long iova, size_t granule) { - if (iop->cfg.tlb->tlb_add_page) + if (iop->cfg.tlb && iop->cfg.tlb->tlb_add_page) iop->cfg.tlb->tlb_add_page(gather, iova, granule, iop->cookie); }
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerPATCH v3 6/7 iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once
In reply to Yong WuIn current iommu_unmap, this code is:
iommu_iotlb_gather_init(&iotlb_gather); ret = __iommu_unmap(domain, iova, size, &iotlb_gather); iommu_iotlb_sync(domain, &iotlb_gather);
We could gather the whole iova range in __iommu_unmap, and then do tlb synchronization in the iommu_iotlb_sync.
This patch implement this, Gather the range in mtk_iommu_unmap. then iommu_iotlb_sync call tlb synchronization for the gathered iova range. we don't call iommu_iotlb_gather_add_page since our tlb synchronization could be regardless of granule size.
In this way, gather->start is impossible ULONG_MAX, remove the checking.
This patch aims to do tlb synchronization *once* in the iommu_unmap.
--- drivers/iommu/mtk_iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iommu/mtk_iommu.c +5 -3
@@ -506,7 +506,12 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) {struct mtk_iommu_domain *dom =to_mtk_domain (domain); +unsigned long long end = iova + size; +if (gather->start > iova) + gather->start = iova; +if (gather->end < end) + gather->end = end;return dom->iop->unmap (dom->iop, iova, size, gather); }
@@ -523,9 +528,6 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain,struct mtk_iommu_domain *dom =to_mtk_domain (domain);size_t length = gather->end - gather->start; -if (gather->start ==ULONG_MAX ) -return ; -mtk_iommu_tlb_flush_range_sync (gather->start, length, gather->pgsize, dom->data); }
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once
Quoted 28 lines · Yong Wu
In current
iommu_unmap, this code is:iommu_iotlb_gather_init(&iotlb_gather); ret = __iommu_unmap(domain, iova, size, &iotlb_gather); iommu_iotlb_sync(domain, &iotlb_gather);We could gather the whole iova range in
__iommu_unmap, and then do tlb synchronization in theiommu_iotlb_sync.This patch implement this, Gather the range in
mtk_iommu_unmap. theniommu_iotlb_synccall tlb synchronization for the gathered iova range. we don't calliommu_iotlb_gather_add_pagesince our tlb synchronization could be regardless of granule size.In this way,
gather->startis impossibleULONG_MAX, remove the checking.This patch aims to do tlb synchronization *once* in the
iommu_unmap.Signed-off-by Yong Wu <[email protected]>--- drivers/iommu/mtk_iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/iommu/mtk_iommu.c +0
-0
drivers/iommu/mtk_iommu.c static size_t mtk_iommu_unmap(struct iommu_domain *domain, · line 514
Quoted 9 lines
drivers/iommu/mtk_iommu.c +5
-0@@ -506,7 +506,12 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) {struct mtk_iommu_domain *dom =to_mtk_domain (domain); +unsigned long long end = iova + size; +if (gather->start > iova) + gather->start = iova; +if (gather->end < end) + gather->end = end;
I don't know how common the case is, but what happens if gather->start...gather->end is a disjoint range from iova...end? E.g.
| gather | ..XXX... | iova |
| | | |
gather->start | iova |
gather->end endWe would also end up invalidating the TLB for the XXX area, which could affect the performance.
Also, why is the existing code in __arm_v7s_unmap() not enough? It seems to call io_pgtable_tlb_add_page() already, so it should be batching the flushes.
Quoted 20 lines
drivers/iommu/mtk_iommu.c +0
-3return dom->iop->unmap (dom->iop, iova, size, gather); }@@ -523,9 +528,6 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain,struct mtk_iommu_domain *dom =to_mtk_domain (domain);size_t length = gather->end - gather->start; -if (gather->start ==ULONG_MAX ) -return ; -mtk_iommu_tlb_flush_range_sync (gather->start, length, gather->pgsize, dom->data); }Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Robin Murphy
reviewerRe: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once
Quoted 42 lines · Tomasz Figa
Quoted 28 lines · Yong Wu
In current
iommu_unmap, this code is:iommu_iotlb_gather_init(&iotlb_gather); ret = __iommu_unmap(domain, iova, size, &iotlb_gather); iommu_iotlb_sync(domain, &iotlb_gather);We could gather the whole iova range in
__iommu_unmap, and then do tlb synchronization in theiommu_iotlb_sync.This patch implement this, Gather the range in
mtk_iommu_unmap. theniommu_iotlb_synccall tlb synchronization for the gathered iova range. we don't calliommu_iotlb_gather_add_pagesince our tlb synchronization could be regardless of granule size.In this way,
gather->startis impossibleULONG_MAX, remove the checking.This patch aims to do tlb synchronization *once* in the
iommu_unmap.Signed-off-by Yong Wu <[email protected]>--- drivers/iommu/mtk_iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/iommu/mtk_iommu.c +0
-0drivers/iommu/mtk_iommu.c static size_t mtk_iommu_unmap(struct iommu_domain *domain, · line 514
Quoted 9 lines
drivers/iommu/mtk_iommu.c +5
-0@@ -506,7 +506,12 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) {struct mtk_iommu_domain *dom =to_mtk_domain (domain); +unsigned long long end = iova + size; +if (gather->start > iova) + gather->start = iova; +if (gather->end < end) + gather->end = end;I don't know how common the case is, but what happens if gather->start...gather->end is a disjoint range from iova...end? E.g.
Quoted 7 lines
| gather | ..XXX... | iova | | | | | gather->start | iova | gather->end endWe would also end up invalidating the TLB for the XXX area, which could affect the performance.
Take a closer look at iommu_unmap() - the gather data is scoped to each individual call, so that can't possibly happen.
Quoted 3 lines
Also, why is the existing code in
__arm_v7s_unmap()not enough? It seems to callio_pgtable_tlb_add_page()already, so it should be batching the flushes.
Because if we leave io-pgtable in charge of maintenance it will also inject additional invalidations and syncs for the sake of strictly correct walk cache maintenance. Apparently we can get away without that on this hardware, so the fundamental purpose of this series is to sidestep it.
It's proven to be cleaner overall to devolve this kind of "non-standard" TLB maintenance back to drivers rather than try to cram yet more special-case complexity into io-pgtable itself. I'm planning to clean up the remains of the TLBI_ON_MAP quirk entirely after this.
Robin.
Quoted 16 lines
Quoted 16 lines
drivers/iommu/mtk_iommu.c +0
-3return dom->iop->unmap (dom->iop, iova, size, gather); }@@ -523,9 +528,6 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain,struct mtk_iommu_domain *dom =to_mtk_domain (domain);size_t length = gather->end - gather->start; -if (gather->start ==ULONG_MAX ) -return ; -mtk_iommu_tlb_flush_range_sync (gather->start, length, gather->pgsize, dom->data); }Signature · 1 line
2.18.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once
Quoted 88 lines · Robin Murphy
Quoted 42 lines · Tomasz Figa
Quoted 28 lines · Yong Wu
In current
iommu_unmap, this code is:iommu_iotlb_gather_init(&iotlb_gather); ret = __iommu_unmap(domain, iova, size, &iotlb_gather); iommu_iotlb_sync(domain, &iotlb_gather);We could gather the whole iova range in
__iommu_unmap, and then do tlb synchronization in theiommu_iotlb_sync.This patch implement this, Gather the range in
mtk_iommu_unmap. theniommu_iotlb_synccall tlb synchronization for the gathered iova range. we don't calliommu_iotlb_gather_add_pagesince our tlb synchronization could be regardless of granule size.In this way,
gather->startis impossibleULONG_MAX, remove the checking.This patch aims to do tlb synchronization *once* in the
iommu_unmap.Signed-off-by Yong Wu <[email protected]>--- drivers/iommu/mtk_iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/iommu/mtk_iommu.c +0
-0drivers/iommu/mtk_iommu.c static size_t mtk_iommu_unmap(struct iommu_domain *domain, · line 514
Quoted 9 lines
drivers/iommu/mtk_iommu.c +5
-0@@ -506,7 +506,12 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) {struct mtk_iommu_domain *dom =to_mtk_domain (domain); +unsigned long long end = iova + size; +if (gather->start > iova) + gather->start = iova; +if (gather->end < end) + gather->end = end;I don't know how common the case is, but what happens if gather->start...gather->end is a disjoint range from iova...end? E.g.
Quoted 7 lines
| gather | ..XXX... | iova | | | | | gather->start | iova | gather->end endWe would also end up invalidating the TLB for the XXX area, which could affect the performance.
Take a closer look at
iommu_unmap()- the gather data is scoped to each individual call, so that can't possibly happen.Quoted 3 lines
Also, why is the existing code in
__arm_v7s_unmap()not enough? It seems to callio_pgtable_tlb_add_page()already, so it should be batching the flushes.Because if we leave io-pgtable in charge of maintenance it will also inject additional invalidations and syncs for the sake of strictly correct walk cache maintenance. Apparently we can get away without that on this hardware, so the fundamental purpose of this series is to sidestep it.
It's proven to be cleaner overall to devolve this kind of "non-standard" TLB maintenance back to drivers rather than try to cram yet more special-case complexity into io-pgtable itself. I'm planning to clean up the remains of the
TLBI_ON_MAPquirk entirely after this.Robin.
Quoted 16 lines
Quoted 16 lines
drivers/iommu/mtk_iommu.c +0
-4return dom->iop->unmap (dom->iop, iova, size, gather); }@@ -523,9 +528,6 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain,struct mtk_iommu_domain *dom =to_mtk_domain (domain);size_t length = gather->end - gather->start; -if (gather->start ==ULONG_MAX ) -return ; -mtk_iommu_tlb_flush_range_sync (gather->start, length, gather->pgsize, dom->data); } --2.18.0
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once
In reply to Robin MurphyQuoted 65 lines · Robin Murphy
Quoted 42 lines · Tomasz Figa
Quoted 28 lines · Yong Wu
In current
iommu_unmap, this code is:iommu_iotlb_gather_init(&iotlb_gather); ret = __iommu_unmap(domain, iova, size, &iotlb_gather); iommu_iotlb_sync(domain, &iotlb_gather);We could gather the whole iova range in
__iommu_unmap, and then do tlb synchronization in theiommu_iotlb_sync.This patch implement this, Gather the range in
mtk_iommu_unmap. theniommu_iotlb_synccall tlb synchronization for the gathered iova range. we don't calliommu_iotlb_gather_add_pagesince our tlb synchronization could be regardless of granule size.In this way,
gather->startis impossibleULONG_MAX, remove the checking.This patch aims to do tlb synchronization *once* in the
iommu_unmap.Signed-off-by Yong Wu <[email protected]>--- drivers/iommu/mtk_iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/iommu/mtk_iommu.c +0
-0drivers/iommu/mtk_iommu.c static size_t mtk_iommu_unmap(struct iommu_domain *domain, · line 514
Quoted 9 lines
drivers/iommu/mtk_iommu.c +5
-0@@ -506,7 +506,12 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) {struct mtk_iommu_domain *dom =to_mtk_domain (domain); +unsigned long long end = iova + size; +if (gather->start > iova) + gather->start = iova; +if (gather->end < end) + gather->end = end;I don't know how common the case is, but what happens if gather->start...gather->end is a disjoint range from iova...end? E.g.
Quoted 7 lines
| gather | ..XXX... | iova | | | | | gather->start | iova | gather->end endWe would also end up invalidating the TLB for the XXX area, which could affect the performance.
Take a closer look at
iommu_unmap()- the gather data is scoped to each individual call, so that can't possibly happen.Quoted 3 lines
Also, why is the existing code in
__arm_v7s_unmap()not enough? It seems to callio_pgtable_tlb_add_page()already, so it should be batching the flushes.Because if we leave io-pgtable in charge of maintenance it will also inject additional invalidations and syncs for the sake of strictly correct walk cache maintenance. Apparently we can get away without that on this hardware, so the fundamental purpose of this series is to sidestep it.
Quoted 4 lines
It's proven to be cleaner overall to devolve this kind of "non-standard" TLB maintenance back to drivers rather than try to cram yet more special-case complexity into io-pgtable itself. I'm planning to clean up the remains of the
TLBI_ON_MAPquirk entirely after this.
(Sorry, I sent an empty email accidentally.)
I see, thanks for clarifying. The patch looks good to me then.
Best regards,
Tomasz
Quoted 19 lines
Robin.
Quoted 16 lines
Quoted 16 lines
drivers/iommu/mtk_iommu.c +0
-4return dom->iop->unmap (dom->iop, iova, size, gather); }@@ -523,9 +528,6 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain,struct mtk_iommu_domain *dom =to_mtk_domain (domain);size_t length = gather->end - gather->start; -if (gather->start ==ULONG_MAX ) -return ; -mtk_iommu_tlb_flush_range_sync (gather->start, length, gather->pgsize, dom->data); } --2.18.0
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once
In reply to Yong WuQuoted 9 lines · Yong Wu
In current
iommu_unmap, this code is:iommu_iotlb_gather_init(&iotlb_gather); ret = __iommu_unmap(domain, iova, size, &iotlb_gather); iommu_iotlb_sync(domain, &iotlb_gather);We could gather the whole iova range in
__iommu_unmap, and then do tlb synchronization in theiommu_iotlb_sync.
Quoted 8 lines
This patch implement this, Gather the range in
mtk_iommu_unmap. theniommu_iotlb_synccall tlb synchronization for the gathered iova range. we don't calliommu_iotlb_gather_add_pagesince our tlb synchronization could be regardless of granule size.In this way,
gather->startis impossibleULONG_MAX, remove the checking.This patch aims to do tlb synchronization *once* in the
iommu_unmap.
Assuming the update to patch #4 simply results in "unsigned long end = iova + size - 1;" here,
Quoted 24 lines
Signed-off-by Yong Wu <[email protected]>--- drivers/iommu/mtk_iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/iommu/mtk_iommu.c +5
-0@@ -506,7 +506,12 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) {struct mtk_iommu_domain *dom =to_mtk_domain (domain); +unsigned long long end = iova + size; +if (gather->start > iova) + gather->start = iova; +if (gather->end < end) + gather->end = end;return dom->iop->unmap (dom->iop, iova, size, gather); }
drivers/iommu/mtk_iommu.c static void mtk_iommu_iotlb_sync(struct iommu_domain *domain, · line 533
Quoted 9 lines
drivers/iommu/mtk_iommu.c +0
-3@@ -523,9 +528,6 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain,struct mtk_iommu_domain *dom =to_mtk_domain (domain);size_t length = gather->end - gather->start; -if (gather->start ==ULONG_MAX ) -return ; -mtk_iommu_tlb_flush_range_sync (gather->start, length, gather->pgsize, dom->data); }
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Will Deacon
maintainerRe: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once
Quoted 15 lines · Robin Murphy
Quoted 14 lines · Yong Wu
In current
iommu_unmap, this code is:iommu_iotlb_gather_init(&iotlb_gather); ret = __iommu_unmap(domain, iova, size, &iotlb_gather); iommu_iotlb_sync(domain, &iotlb_gather);We could gather the whole iova range in
__iommu_unmap, and then do tlb synchronization in theiommu_iotlb_sync.This patch implement this, Gather the range in
mtk_iommu_unmap. theniommu_iotlb_synccall tlb synchronization for the gathered iova range. we don't calliommu_iotlb_gather_add_pagesince our tlb synchronization could be regardless of granule size.
Quoted 8 lines
Quoted 3 lines
In this way,
gather->startis impossibleULONG_MAX, remove the checking.This patch aims to do tlb synchronization *once* in the
iommu_unmap.Assuming the update to patch #4 simply results in "unsigned long end = iova
+ size - 1;" here,Reviewed-by Robin Murphy <[email protected]>
There's a v4 here:
https://lore.kernel.org/r/[email protected]
Will
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Robin Murphy
reviewerRe: [PATCH v3 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once
Quoted 20 lines · Will Deacon
Quoted 19 lines · Robin Murphy
Quoted 17 lines · Yong Wu
In current
iommu_unmap, this code is:iommu_iotlb_gather_init(&iotlb_gather); ret = __iommu_unmap(domain, iova, size, &iotlb_gather); iommu_iotlb_sync(domain, &iotlb_gather);We could gather the whole iova range in
__iommu_unmap, and then do tlb synchronization in theiommu_iotlb_sync.This patch implement this, Gather the range in
mtk_iommu_unmap. theniommu_iotlb_synccall tlb synchronization for the gathered iova range. we don't calliommu_iotlb_gather_add_pagesince our tlb synchronization could be regardless of granule size.In this way,
gather->startis impossibleULONG_MAX, remove the checking.This patch aims to do tlb synchronization *once* in the
iommu_unmap.
Quoted 8 lines
Quoted 4 lines
Assuming the update to patch #4 simply results in "unsigned long end = iova
+ size - 1;" here,Reviewed-by Robin Murphy <[email protected]>There's a v4 here:
Ha, so there is! Apparently I missed that in my post-holiday sweep last week and leant too heavily on the inbox-in-date-order assumption. Lemme just go catch up...
Thanks,
Robin.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerPATCH v3 7/7 iommu/mediatek: Remove the tlb-ops for v7s
In reply to Yong WuUntil now, we have already used the tlb operations from iommu framework, then the tlb operations for v7s can be removed.
Correspondingly, Switch the paramenter "cookie" to internal structure.
--- drivers/iommu/mtk_iommu.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
drivers/iommu/mtk_iommu.c +4 -23
@@ -206,10 +206,8 @@ static struct mtk_iommu_domain *to_mtk_domain(struct iommu_domain *dom) return container_of(dom, struct mtk_iommu_domain, domain); } -static void mtk_iommu_tlb_flush_all (void *cookie) +static void mtk_iommu_tlb_flush_all (struct mtk_iommu_data *data) { -struct mtk_iommu_data *data = cookie; -for_each_m4u (data) {if (!pm_runtime_active (data->dev))continue ;
@@ -221,9 +219,9 @@ static void mtk_iommu_tlb_flush_all(void *cookie) }static void mtk_iommu_tlb_flush_range_sync (unsigned long iova,size_t size, -size_t granule,void *cookie) +size_t granule, +struct mtk_iommu_data *data) { -struct mtk_iommu_data *data = cookie;unsigned long flags;int ret;u32 tmp;
@@ -250,7 +248,7 @@ static void mtk_iommu_tlb_flush_range_sync(unsigned long iova, size_t size,if (ret) {dev_warn (data->dev,"Partial TLB flush timed out, falling back to full flush\n" ); -mtk_iommu_tlb_flush_all (cookie); +mtk_iommu_tlb_flush_all (data); }/* Clear the CPE status */ writel_relaxed (0 , data->base +REG_MMU_CPE_DONE );
@@ -258,22 +256,6 @@ static void mtk_iommu_tlb_flush_range_sync(unsigned long iova, size_t size, } } -static void mtk_iommu_tlb_flush_page_nosync (struct iommu_iotlb_gather *gather, -unsigned long iova,size_t granule, -void *cookie) -{ -struct mtk_iommu_data *data = cookie; -struct iommu_domain *domain = &data->m4u_dom->domain; - -iommu_iotlb_gather_add_page (domain, gather, iova, granule); -} - -static const struct iommu_flush_ops mtk_iommu_flush_ops = { - .tlb_flush_all = mtk_iommu_tlb_flush_all, - .tlb_flush_walk = mtk_iommu_tlb_flush_range_sync, - .tlb_add_page = mtk_iommu_tlb_flush_page_nosync, -}; -static irqreturn_t mtk_iommu_isr (int irq,void *dev_id) {struct mtk_iommu_data *data = dev_id;
@@ -380,7 +362,6 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) .pgsize_bitmap = mtk_iommu_ops.pgsize_bitmap, .ias = MTK_IOMMU_HAS_FLAG(data->plat_data, IOVA_34_EN) ? 34 : 32, .oas = 35, - .tlb = &mtk_iommu_flush_ops, .iommu_dev = data->dev, };
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 7/7] iommu/mediatek: Remove the tlb-ops for v7s
Quoted 4 lines · Yong Wu
Until now, we have already used the tlb operations from iommu framework, then the tlb operations for v7s can be removed.
Correspondingly, Switch the paramenter "cookie" to internal structure.
FWIW,
Quoted 67 lines
Signed-off-by Yong Wu <[email protected]>--- drivers/iommu/mtk_iommu.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)drivers/iommu/mtk_iommu.c +4
-22@@ -206,10 +206,8 @@ static struct mtk_iommu_domain *to_mtk_domain(struct iommu_domain *dom) return container_of(dom, struct mtk_iommu_domain, domain); } -static void mtk_iommu_tlb_flush_all (void *cookie) +static void mtk_iommu_tlb_flush_all (struct mtk_iommu_data *data) { -struct mtk_iommu_data *data = cookie; -for_each_m4u (data) {if (!pm_runtime_active (data->dev))continue ;@@ -221,9 +219,9 @@ static void mtk_iommu_tlb_flush_all(void *cookie) }static void mtk_iommu_tlb_flush_range_sync (unsigned long iova,size_t size, -size_t granule,void *cookie) +size_t granule, +struct mtk_iommu_data *data) { -struct mtk_iommu_data *data = cookie;unsigned long flags;int ret;u32 tmp;@@ -250,7 +248,7 @@ static void mtk_iommu_tlb_flush_range_sync(unsigned long iova, size_t size,if (ret) {dev_warn (data->dev,"Partial TLB flush timed out, falling back to full flush\n" ); -mtk_iommu_tlb_flush_all (cookie); +mtk_iommu_tlb_flush_all (data); }/* Clear the CPE status */ writel_relaxed (0 , data->base +REG_MMU_CPE_DONE );@@ -258,22 +256,6 @@ static void mtk_iommu_tlb_flush_range_sync(unsigned long iova, size_t size, } } -static void mtk_iommu_tlb_flush_page_nosync (struct iommu_iotlb_gather *gather, -unsigned long iova,size_t granule, -void *cookie) -{ -struct mtk_iommu_data *data = cookie; -struct iommu_domain *domain = &data->m4u_dom->domain; - -iommu_iotlb_gather_add_page (domain, gather, iova, granule); -} - -static const struct iommu_flush_ops mtk_iommu_flush_ops = { - .tlb_flush_all = mtk_iommu_tlb_flush_all, - .tlb_flush_walk = mtk_iommu_tlb_flush_range_sync, - .tlb_add_page = mtk_iommu_tlb_flush_page_nosync, -}; -static irqreturn_t mtk_iommu_isr (int irq,void *dev_id) {struct mtk_iommu_data *data = dev_id;
drivers/iommu/mtk_iommu.c static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) · line 367
Quoted 7 lines
drivers/iommu/mtk_iommu.c +0
-1@@ -380,7 +362,6 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) .pgsize_bitmap = mtk_iommu_ops.pgsize_bitmap, .ias = MTK_IOMMU_HAS_FLAG(data->plat_data, IOVA_34_EN) ? 34 : 32, .oas = 35, - .tlb = &mtk_iommu_flush_ops, .iommu_dev = data->dev, };
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu