iommu: Introduce iommu_iotlb_gather_add_page()
Introduce a helper function for drivers to use when updating an iommu_iotlb_gather structure in response to an ->unmap() call, rather than having to open-code the logic in every page-table implementation. Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
parent
a7d20dc19d
commit
4fcf8544fc
|
@ -507,6 +507,31 @@ static inline void iommu_tlb_sync(struct iommu_domain *domain,
|
||||||
iommu_iotlb_gather_init(iotlb_gather);
|
iommu_iotlb_gather_init(iotlb_gather);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the new page is disjoint from the current range or is mapped at
|
||||||
|
* a different granularity, then sync the TLB so that the gather
|
||||||
|
* structure can be rewritten.
|
||||||
|
*/
|
||||||
|
if (gather->pgsize != size ||
|
||||||
|
end < gather->start || start > gather->end) {
|
||||||
|
if (gather->pgsize)
|
||||||
|
iommu_tlb_sync(domain, gather);
|
||||||
|
gather->pgsize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gather->end < end)
|
||||||
|
gather->end = end;
|
||||||
|
|
||||||
|
if (gather->start > start)
|
||||||
|
gather->start = start;
|
||||||
|
}
|
||||||
|
|
||||||
/* PCI device grouping function */
|
/* PCI device grouping function */
|
||||||
extern struct iommu_group *pci_device_group(struct device *dev);
|
extern struct iommu_group *pci_device_group(struct device *dev);
|
||||||
/* Generic device grouping function */
|
/* Generic device grouping function */
|
||||||
|
@ -847,6 +872,12 @@ static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain,
|
||||||
|
struct iommu_iotlb_gather *gather,
|
||||||
|
unsigned long iova, size_t size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static inline void iommu_device_unregister(struct iommu_device *iommu)
|
static inline void iommu_device_unregister(struct iommu_device *iommu)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue