Messages in this thread | | | Subject | Re: [PATCH v2 4/6] iommu: Add granule_ignore when tlb gather | From | Robin Murphy <> | Date | Wed, 25 Nov 2020 16:38:35 +0000 |
| |
On 2020-11-19 06:18, Yong Wu wrote: > Add a granule_ignore option when tlb gather for some HW which don't care > about granule when it flush tlb. > > Signed-off-by: Yong Wu <yong.wu@mediatek.com> > --- > include/linux/iommu.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 794d4085edd3..1aad32238510 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -171,6 +171,7 @@ enum iommu_dev_features { > * @start: IOVA representing the start of the range to be flushed > * @end: IOVA representing the end of the range to be flushed (exclusive) > * @pgsize: The interval at which to perform the flush > + * @granule_ignore: For tlb flushing that could be regardless of granule. > * > * This structure is intended to be updated by multiple calls to the > * ->unmap() function in struct iommu_ops before eventually being passed > @@ -180,6 +181,7 @@ struct iommu_iotlb_gather { > unsigned long start; > unsigned long end; > size_t pgsize; > + bool granule_ignore;
I can't see that this would ever need to vary on a per-unmap-operation basis, so this doesn't seem like the right level of abstraction. AFAICS it should simply be hard-coded in the driver logic.
> }; > > /** > @@ -544,7 +546,7 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, > * a different granularity, then sync the TLB so that the gather > * structure can be rewritten. > */ > - if (gather->pgsize != size || > + if ((!gather->granule_ignore && gather->pgsize != size) ||
I also think this is a slippery slope in the wrong direction anyway - there is likely to be a fair bit of hardware-dependent variation around how low-level TLB maintenance works (also consider drivers that may want to convert a sufficiently large range to an "invalidate all" operation), so if a generic helper function doesn't do the right thing for a given driver, that driver should simply not use the helper, and directly implement the logic it does need.
Robin.
> end < gather->start || start > gather->end) { > if (gather->pgsize) > iommu_iotlb_sync(domain, gather); >
| |