Commit 23c30bed authored by Isaac J. Manjarres's avatar Isaac J. Manjarres Committed by Joerg Roedel
Browse files

iommu/io-pgtable-arm-v7s: Implement arm_v7s_map_pages()



Implement the map_pages() callback for the ARM v7s io-pgtable
format.

Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
Signed-off-by: default avatarGeorgi Djakov <quic_c_gdjako@quicinc.com>
Link: https://lore.kernel.org/r/1623850736-389584-14-git-send-email-quic_c_gdjako@quicinc.com


Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent f13eabcf
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -519,11 +519,12 @@ static int __arm_v7s_map(struct arm_v7s_io_pgtable *data, unsigned long iova,
	return __arm_v7s_map(data, iova, paddr, size, prot, lvl + 1, cptep, gfp);
}

static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova,
			phys_addr_t paddr, size_t size, int prot, gfp_t gfp)
static int arm_v7s_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
			     phys_addr_t paddr, size_t pgsize, size_t pgcount,
			     int prot, gfp_t gfp, size_t *mapped)
{
	struct arm_v7s_io_pgtable *data = io_pgtable_ops_to_data(ops);
	int ret;
	int ret = -EINVAL;

	if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias) ||
		    paddr >= (1ULL << data->iop.cfg.oas)))
@@ -533,7 +534,17 @@ static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova,
	if (!(prot & (IOMMU_READ | IOMMU_WRITE)))
		return 0;

	ret = __arm_v7s_map(data, iova, paddr, size, prot, 1, data->pgd, gfp);
	while (pgcount--) {
		ret = __arm_v7s_map(data, iova, paddr, pgsize, prot, 1, data->pgd,
				    gfp);
		if (ret)
			break;

		iova += pgsize;
		paddr += pgsize;
		if (mapped)
			*mapped += pgsize;
	}
	/*
	 * Synchronise all PTE updates for the new mapping before there's
	 * a chance for anything to kick off a table walk for the new iova.
@@ -543,6 +554,12 @@ static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova,
	return ret;
}

static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova,
		       phys_addr_t paddr, size_t size, int prot, gfp_t gfp)
{
	return arm_v7s_map_pages(ops, iova, paddr, size, 1, prot, gfp, NULL);
}

static void arm_v7s_free_pgtable(struct io_pgtable *iop)
{
	struct arm_v7s_io_pgtable *data = io_pgtable_to_data(iop);
@@ -797,6 +814,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg,

	data->iop.ops = (struct io_pgtable_ops) {
		.map		= arm_v7s_map,
		.map_pages	= arm_v7s_map_pages,
		.unmap		= arm_v7s_unmap,
		.unmap_pages	= arm_v7s_unmap_pages,
		.iova_to_phys	= arm_v7s_iova_to_phys,