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
191 191
192#ifdef CONFIG_IOMMU_API192#ifdef CONFIG_IOMMU_API
193 193
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 */
205struct iommu_iotlb_gather {
206 unsigned long start;
207 unsigned long end;
208 size_t pgsize;
209};
210
194/**211/**
195 * struct iommu_ops - iommu ops and capabilities212 * struct iommu_ops - iommu ops and capabilities
196 * @capable: check capability213 * @capable: check capability
@@ -375,6 +392,13 @@ static inline struct iommu_device *dev_to_iommu_device(struct device *dev) · 178 unmodified lines
375 return (struct iommu_device *)dev_get_drvdata(dev);392 return (struct iommu_device *)dev_get_drvdata(dev);
376}393}
377 394
395static 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
378#define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */402#define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
379#define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */403#define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
380#define IOMMU_GROUP_NOTIFY_BIND_DRIVER 3 /* Pre Driver bind */404#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
399extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,423extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
400 size_t size);424 size_t size);
401extern size_t iommu_unmap_fast(struct iommu_domain *domain,425extern 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);
403extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,428extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
404 struct scatterlist *sg,unsigned int nents, int prot);429 struct scatterlist *sg,unsigned int nents, int prot);
405extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);430extern 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
473 domain->ops->flush_iotlb_all(domain);498 domain->ops->flush_iotlb_all(domain);
474}499}
475 500
476static inline void iommu_tlb_sync(struct iommu_domain *domain)501static inline void iommu_tlb_sync(struct iommu_domain *domain,
502 struct iommu_iotlb_gather *iotlb_gather)
477{503{
478 if (domain->ops->iotlb_sync)504 if (domain->ops->iotlb_sync)
479 domain->ops->iotlb_sync(domain);505 domain->ops->iotlb_sync(domain);
506
507 iommu_iotlb_gather_init(iotlb_gather);
480}508}
481 509
482/* PCI device grouping function */510/* PCI device grouping function */
@@ -557,6 +585,7 @@ struct iommu_group {}; · 74 unmodified lines
557struct iommu_fwspec {};585struct iommu_fwspec {};
558struct iommu_device {};586struct iommu_device {};
559struct iommu_fault_param {};587struct iommu_fault_param {};
588struct iommu_iotlb_gather {};
560 589
561static inline bool iommu_present(struct bus_type *bus)590static inline bool iommu_present(struct bus_type *bus)
562{591{
@@ -611,7 +640,8 @@ static inline size_t iommu_unmap(struct iommu_domain *domain, · 48 unmodified lines
611}640}
612 641
613static inline size_t iommu_unmap_fast(struct iommu_domain *domain,642static 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)
615{645{
616 return 0;646 return 0;
617}647}
@@ -627,7 +657,8 @@ static inline void iommu_flush_tlb_all(struct iommu_domain *domain) · 9 unmodified lines
627{657{
628}658}
629 659
630static inline void iommu_tlb_sync(struct iommu_domain *domain)660static inline void iommu_tlb_sync(struct iommu_domain *domain,
661 struct iommu_iotlb_gather *iotlb_gather)
631{662{
632}663}
633 664
@@ -812,6 +843,10 @@ static inline struct iommu_device *dev_to_iommu_device(struct device *dev) · 178 unmodified lines
812 return NULL;843 return NULL;
813}844}
814 845
846static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather)
847{
848}
849
815static inline void iommu_device_unregister(struct iommu_device *iommu)850static inline void iommu_device_unregister(struct iommu_device *iommu)
816{851{
817}852}

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