History

iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes

To permit batching of TLB flushes across multiple calls to the IOMMU driver's ->unmap() implementation, introduce a new structure for tracking the address range to be flushed and the granularity at which the flushing is required. This is hooked into the IOMMU API and its caller are updated to make use of the new structure. Subsequent patches will plumb this into the IOMMU drivers as well, but for now the gathering information is ignored.

Will Deacon committed 7 years ago

Commit a7d20dc1 parent 298f7884 files · +75 −22Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/iommu.h+39−4
@@ -191,6 +191,23 @@ struct iommu_sva_ops { · 190 unmodified lines
191191
192192 #ifdef CONFIG_IOMMU_API
193193
194+/**
195+ * struct iommu_iotlb_gather - Range information for a pending IOTLB flush
196+ *
197+ * @start: IOVA representing the start of the range to be flushed
198+ * @end: IOVA representing the end of the range to be flushed (exclusive)
199+ * @pgsize: The interval at which to perform the flush
200+ *
201+ * This structure is intended to be updated by multiple calls to the
202+ * ->unmap() function in struct iommu_ops before eventually being passed
203+ * into ->iotlb_sync().
204+ */
205+struct iommu_iotlb_gather {
206+ unsigned long start;
207+ unsigned long end;
208+ size_t pgsize;
209+};
210+
194211 /**
195212 * struct iommu_ops - iommu ops and capabilities
196213 * @capable: check capability
@@ -375,6 +392,13 @@ static inline struct iommu_device *dev_to_iommu_device(struct device *dev) · 178 unmodified lines
375392 return (struct iommu_device *)dev_get_drvdata(dev);
376393 }
377394
395+static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather)
396+{
397+ *gather = (struct iommu_iotlb_gather) {
398+ .start = ULONG_MAX,
399+ };
400+}
401+
378402 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
379403 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
380404 #define IOMMU_GROUP_NOTIFY_BIND_DRIVER 3 /* Pre Driver bind */
@@ -399,7 +423,8 @@ extern int iommu_map(struct iommu_domain *domain, unsigned long iova, · 18 unmodified lines
399423 extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
400424 size_t size);
401425 extern size_t iommu_unmap_fast(struct iommu_domain *domain,
402− unsigned long iova, size_t size);
426+ unsigned long iova, size_t size,
427+ struct iommu_iotlb_gather *iotlb_gather);
403428 extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
404429 struct scatterlist *sg,unsigned int nents, int prot);
405430 extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
@@ -473,10 +498,13 @@ static inline void iommu_flush_tlb_all(struct iommu_domain *domain) · 67 unmodified lines
473498 domain->ops->flush_iotlb_all(domain);
474499 }
475500
476−static inline void iommu_tlb_sync(struct iommu_domain *domain)
501+static inline void iommu_tlb_sync(struct iommu_domain *domain,
502+ struct iommu_iotlb_gather *iotlb_gather)
477503 {
478504 if (domain->ops->iotlb_sync)
479505 domain->ops->iotlb_sync(domain);
506+
507+ iommu_iotlb_gather_init(iotlb_gather);
480508 }
481509
482510 /* PCI device grouping function */
@@ -557,6 +585,7 @@ struct iommu_group {}; · 74 unmodified lines
557585 struct iommu_fwspec {};
558586 struct iommu_device {};
559587 struct iommu_fault_param {};
588+struct iommu_iotlb_gather {};
560589
561590 static inline bool iommu_present(struct bus_type *bus)
562591 {
@@ -611,7 +640,8 @@ static inline size_t iommu_unmap(struct iommu_domain *domain, · 48 unmodified lines
611640 }
612641
613642 static inline size_t iommu_unmap_fast(struct iommu_domain *domain,
614− unsigned long iova, int gfp_order)
643+ unsigned long iova, int gfp_order,
644+ struct iommu_iotlb_gather *iotlb_gather)
615645 {
616646 return 0;
617647 }
@@ -627,7 +657,8 @@ static inline void iommu_flush_tlb_all(struct iommu_domain *domain) · 9 unmodified lines
627657 {
628658 }
629659
630−static inline void iommu_tlb_sync(struct iommu_domain *domain)
660+static inline void iommu_tlb_sync(struct iommu_domain *domain,
661+ struct iommu_iotlb_gather *iotlb_gather)
631662 {
632663 }
633664
@@ -812,6 +843,10 @@ static inline struct iommu_device *dev_to_iommu_device(struct device *dev) · 178 unmodified lines
812843 return NULL;
813844 }
814845
846+static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather)
847+{
848+}
849+
815850 static inline void iommu_device_unregister(struct iommu_device *iommu)
816851 {
817852 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t