3 changes: 2 additions & 1 deletion drivers/iommu/mtk_iommu.c
Expand Up @@ -402,7 +402,8 @@ static int mtk_iommu_map(struct iommu_domain *domain, unsigned long iova,

static size_t mtk_iommu_unmap(struct iommu_domain *domain,
unsigned long iova, size_t size,
struct iommu_iotlb_gather *gather)
struct iommu_iotlb_gather *gather,
struct page **freelist)
{
struct mtk_iommu_domain *dom = to_mtk_domain(domain);

Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/omap-iommu.c
Expand Up @@ -1367,7 +1367,8 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da,
}

static size_t omap_iommu_unmap(struct iommu_domain *domain, unsigned long da,
size_t size, struct iommu_iotlb_gather *gather)
size_t size, struct iommu_iotlb_gather *gather,
struct page **freelist)
{
struct omap_iommu_domain *omap_domain = to_omap_domain(domain);
struct device *dev = omap_domain->dev;
Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/qcom_iommu.c
Expand Up @@ -447,7 +447,8 @@ static int qcom_iommu_map(struct iommu_domain *domain, unsigned long iova,
}

static size_t qcom_iommu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t size, struct iommu_iotlb_gather *gather)
size_t size, struct iommu_iotlb_gather *gather,
struct page **freelist)
{
size_t ret;
unsigned long flags;
Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/rockchip-iommu.c
Expand Up @@ -795,7 +795,8 @@ static int rk_iommu_map(struct iommu_domain *domain, unsigned long _iova,
}

static size_t rk_iommu_unmap(struct iommu_domain *domain, unsigned long _iova,
size_t size, struct iommu_iotlb_gather *gather)
size_t size, struct iommu_iotlb_gather *gather,
struct page **freelist)
{
struct rk_iommu_domain *rk_domain = to_rk_domain(domain);
unsigned long flags;
Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/s390-iommu.c
Expand Up @@ -305,7 +305,8 @@ static phys_addr_t s390_iommu_iova_to_phys(struct iommu_domain *domain,

static size_t s390_iommu_unmap(struct iommu_domain *domain,
unsigned long iova, size_t size,
struct iommu_iotlb_gather *gather)
struct iommu_iotlb_gather *gather,
struct page **freelist)
{
struct s390_domain *s390_domain = to_s390_domain(domain);
int flags = ZPCI_PTE_INVALID;
Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/sun50i-iommu.c
Expand Up @@ -552,7 +552,8 @@ static int sun50i_iommu_map(struct iommu_domain *domain, unsigned long iova,
}

static size_t sun50i_iommu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t size, struct iommu_iotlb_gather *gather)
size_t size, struct iommu_iotlb_gather *gather,
struct page **freelist)
{
struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain);
phys_addr_t pt_phys;
Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/tegra-gart.c
Expand Up @@ -207,7 +207,8 @@ static inline int __gart_iommu_unmap(struct gart_device *gart,
}

static size_t gart_iommu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t bytes, struct iommu_iotlb_gather *gather)
size_t bytes, struct iommu_iotlb_gather *gather,
struct page **freelist)
{
struct gart_device *gart = gart_handle;
int err;
Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/tegra-smmu.c
Expand Up @@ -686,7 +686,8 @@ static int tegra_smmu_map(struct iommu_domain *domain, unsigned long iova,
}

static size_t tegra_smmu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t size, struct iommu_iotlb_gather *gather)
size_t size, struct iommu_iotlb_gather *gather,
struct page **freelist)
{
struct tegra_smmu_as *as = to_smmu_as(domain);
dma_addr_t pte_dma;
Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/virtio-iommu.c
Expand Up @@ -762,7 +762,8 @@ static int viommu_map(struct iommu_domain *domain, unsigned long iova,
}

static size_t viommu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t size, struct iommu_iotlb_gather *gather)
size_t size, struct iommu_iotlb_gather *gather,
struct page **freelist)
{
int ret = 0;
size_t unmapped;
Expand Down
2 changes: 1 addition & 1 deletion drivers/vfio/vfio_iommu_type1.c
Expand Up @@ -812,7 +812,7 @@ static size_t unmap_unpin_fast(struct vfio_domain *domain,

if (entry) {
unmapped = iommu_unmap_fast(domain->domain, *iova, len,
iotlb_gather);
iotlb_gather, NULL);

if (!unmapped) {
kfree(entry);
Expand Down
21 changes: 18 additions & 3 deletions include/linux/iommu.h
Expand Up @@ -198,6 +198,7 @@ struct iommu_iotlb_gather {
* @map: map a physically contiguous memory region to an iommu domain
* @unmap: unmap a physically contiguous memory region from an iommu domain
* @flush_iotlb_all: Synchronously flush all hardware TLBs for this domain
* @flush_iotlb_range: Flush given iova range of hardware TLBs for this domain
* @iotlb_sync_map: Sync mappings created recently using @map to the hardware
* @iotlb_sync: Flush all queued ranges from the hardware TLBs and empty flush
* queue
Expand Down Expand Up @@ -248,8 +249,12 @@ struct iommu_ops {
int (*map)(struct iommu_domain *domain, unsigned long iova,
phys_addr_t paddr, size_t size, int prot, gfp_t gfp);
size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
size_t size, struct iommu_iotlb_gather *iotlb_gather);
size_t size, struct iommu_iotlb_gather *iotlb_gather,
struct page **freelist);
void (*flush_iotlb_all)(struct iommu_domain *domain);
void (*flush_iotlb_range)(struct iommu_domain *domain,
unsigned long iova, size_t size,
struct page *freelist);
void (*iotlb_sync_map)(struct iommu_domain *domain);
void (*iotlb_sync)(struct iommu_domain *domain,
struct iommu_iotlb_gather *iotlb_gather);
Expand Down Expand Up @@ -447,7 +452,8 @@ extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t size);
extern size_t iommu_unmap_fast(struct iommu_domain *domain,
unsigned long iova, size_t size,
struct iommu_iotlb_gather *iotlb_gather);
struct iommu_iotlb_gather *iotlb_gather,
struct page **freelist);
extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
struct scatterlist *sg,unsigned int nents, int prot);
extern size_t iommu_map_sg_atomic(struct iommu_domain *domain,
Expand Down Expand Up @@ -542,6 +548,14 @@ static inline void iommu_flush_tlb_all(struct iommu_domain *domain)
domain->ops->flush_iotlb_all(domain);
}

static inline void flush_iotlb_range(struct iommu_domain *domain,
unsigned long iova, size_t size,
struct page *freelist)
{
if (domain->ops->flush_iotlb_range)
domain->ops->flush_iotlb_range(domain, iova, size, freelist);
}

static inline void iommu_tlb_sync(struct iommu_domain *domain,
struct iommu_iotlb_gather *iotlb_gather)
{
Expand Down Expand Up @@ -728,7 +742,8 @@ static inline size_t iommu_unmap(struct iommu_domain *domain,

static inline size_t iommu_unmap_fast(struct iommu_domain *domain,
unsigned long iova, int gfp_order,
struct iommu_iotlb_gather *iotlb_gather)
struct iommu_iotlb_gather *iotlb_gather,
struct page **freelist)
{
return 0;
}
Expand Down