Skip to content

Commit

Permalink
iommu: bcm2712: Fixup for new APIs
Browse files Browse the repository at this point in the history
Based on upstream commits
983efef ("iommu/exynos: Update to {map,unmap}_pages")
fa4c450 ("iommu: Allow .iotlb_sync_map to fail and handle s390's -ENOMEM return")

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
  • Loading branch information
6by9 authored and pelwell committed Jan 23, 2024
1 parent 955086f commit 11e8442
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions drivers/iommu/bcm2712-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ static int bcm2712_iommu_attach_dev(struct iommu_domain *domain, struct device *
}

static int bcm2712_iommu_map(struct iommu_domain *domain, unsigned long iova,
phys_addr_t pa, size_t bytes, int prot, gfp_t gfp)
phys_addr_t pa, size_t bytes, size_t count,
int prot, gfp_t gfp, size_t *mapped)
{
struct bcm2712_iommu *mmu = domain_to_mmu(domain);

Expand Down Expand Up @@ -276,12 +277,14 @@ static int bcm2712_iommu_map(struct iommu_domain *domain, unsigned long iova,
(unsigned long long)pa, (unsigned long long)bytes);
return -EINVAL;
}
*mapped = bytes;

return 0;
}

static size_t bcm2712_iommu_unmap(struct iommu_domain *domain, unsigned long iova,
size_t bytes, struct iommu_iotlb_gather *gather)
size_t bytes, size_t count,
struct iommu_iotlb_gather *gather)
{
struct bcm2712_iommu *mmu = domain_to_mmu(domain);

Expand Down Expand Up @@ -318,15 +321,15 @@ static size_t bcm2712_iommu_unmap(struct iommu_domain *domain, unsigned long iov
return bytes;
}

static void bcm2712_iommu_sync_range(struct iommu_domain *domain,
static int bcm2712_iommu_sync_range(struct iommu_domain *domain,
unsigned long iova, size_t size)
{
struct bcm2712_iommu *mmu = domain_to_mmu(domain);
unsigned long iova_end;
unsigned int i, p4;

if (!mmu || !mmu->dirty)
return;
return 0;

/* Ensure tables are cleaned from CPU cache or write-buffer */
dma_sync_sgtable_for_device(mmu->dev, mmu->sgt, DMA_TO_DEVICE);
Expand Down Expand Up @@ -371,6 +374,8 @@ static void bcm2712_iommu_sync_range(struct iommu_domain *domain,
}
}
}

return 0;
}

static void bcm2712_iommu_sync(struct iommu_domain *domain,
Expand Down Expand Up @@ -412,8 +417,8 @@ static void bcm2712_iommu_domain_free(struct iommu_domain *domain)

static const struct iommu_domain_ops bcm2712_iommu_domain_ops = {
.attach_dev = bcm2712_iommu_attach_dev,
.map = bcm2712_iommu_map,
.unmap = bcm2712_iommu_unmap,
.map_pages = bcm2712_iommu_map,
.unmap_pages = bcm2712_iommu_unmap,
.iotlb_sync = bcm2712_iommu_sync,
.iotlb_sync_map = bcm2712_iommu_sync_range,
.flush_iotlb_all = bcm2712_iommu_sync_all,
Expand Down

0 comments on commit 11e8442

Please sign in to comment.