Linux IOMMU Development
 help / color / mirror / Atom feed
From: Mostafa Saleh <smostafa@google.com>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org,
	joro@8bytes.org, robin.murphy@arm.com, james.morse@arm.com,
	suzuki.poulose@arm.com, oliver.upton@linux.dev,
	yuzenghui@huawei.com, dbrazdil@google.com, ryan.roberts@arm.com,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	iommu@lists.linux.dev
Subject: Re: [RFC PATCH 03/45] iommu/io-pgtable: Move fmt into io_pgtable_cfg
Date: Fri, 16 Feb 2024 11:55:21 +0000	[thread overview]
Message-ID: <Zc9NKU18_uF4XHWY@google.com> (raw)
In-Reply-To: <20230201125328.2186498-4-jean-philippe@linaro.org>

Hi Jean,

On Wed, Feb 01, 2023 at 12:52:47PM +0000, Jean-Philippe Brucker wrote:
> When passing the I/O pagetable configuration around and adding new
> operations, it will be slightly more convenient to have fmt be part of
> the config structure rather than a separate parameter.
> 
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
>  include/linux/io-pgtable.h                  |  8 +++----
>  drivers/gpu/drm/msm/msm_iommu.c             |  3 +--
>  drivers/gpu/drm/panfrost/panfrost_mmu.c     |  4 ++--
>  drivers/iommu/amd/iommu.c                   |  3 ++-
>  drivers/iommu/apple-dart.c                  |  4 ++--
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c |  3 ++-
>  drivers/iommu/arm/arm-smmu/arm-smmu.c       |  3 ++-
>  drivers/iommu/arm/arm-smmu/qcom_iommu.c     |  3 ++-
>  drivers/iommu/io-pgtable-arm-common.c       | 26 ++++++++++-----------
>  drivers/iommu/io-pgtable-arm-v7s.c          |  3 ++-
>  drivers/iommu/io-pgtable-arm.c              |  3 ++-
>  drivers/iommu/io-pgtable-dart.c             |  8 +++----
>  drivers/iommu/io-pgtable.c                  | 10 ++++----
>  drivers/iommu/ipmmu-vmsa.c                  |  4 ++--
>  drivers/iommu/msm_iommu.c                   |  3 ++-
>  drivers/iommu/mtk_iommu.c                   |  3 ++-
>  16 files changed, 47 insertions(+), 44 deletions(-)
> 
> diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h
> index 1b7a44b35616..1b0c26241a78 100644
> --- a/include/linux/io-pgtable.h
> +++ b/include/linux/io-pgtable.h
> @@ -49,6 +49,7 @@ struct iommu_flush_ops {
>  /**
>   * struct io_pgtable_cfg - Configuration data for a set of page tables.
>   *
> + * @fmt	           Format used for these page tables
>   * @quirks:        A bitmap of hardware quirks that require some special
>   *                 action by the low-level page table allocator.
>   * @pgsize_bitmap: A bitmap of page sizes supported by this set of page
> @@ -62,6 +63,7 @@ struct iommu_flush_ops {
>   *                 page table walker.
>   */
>  struct io_pgtable_cfg {
> +	enum io_pgtable_fmt		fmt;
>  	/*
>  	 * IO_PGTABLE_QUIRK_ARM_NS: (ARM formats) Set NS and NSTABLE bits in
>  	 *	stage 1 PTEs, for hardware which insists on validating them
> @@ -171,15 +173,13 @@ struct io_pgtable_ops {
>  /**
>   * alloc_io_pgtable_ops() - Allocate a page table allocator for use by an IOMMU.
>   *
> - * @fmt:    The page table format.
>   * @cfg:    The page table configuration. This will be modified to represent
>   *          the configuration actually provided by the allocator (e.g. the
>   *          pgsize_bitmap may be restricted).
>   * @cookie: An opaque token provided by the IOMMU driver and passed back to
>   *          the callback routines in cfg->tlb.
>   */
> -struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
> -					    struct io_pgtable_cfg *cfg,
> +struct io_pgtable_ops *alloc_io_pgtable_ops(struct io_pgtable_cfg *cfg,
>  					    void *cookie);
>  
>  /**
> @@ -199,14 +199,12 @@ void free_io_pgtable_ops(struct io_pgtable_ops *ops);
>  /**
>   * struct io_pgtable - Internal structure describing a set of page tables.
>   *
> - * @fmt:    The page table format.
>   * @cookie: An opaque token provided by the IOMMU driver and passed back to
>   *          any callback routines.
>   * @cfg:    A copy of the page table configuration.
>   * @ops:    The page table operations in use for this set of page tables.
>   */
>  struct io_pgtable {
> -	enum io_pgtable_fmt	fmt;
>  	void			*cookie;
>  	struct io_pgtable_cfg	cfg;
>  	struct io_pgtable_ops	ops;
> diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
> index c2507582ecf3..e9c6f281e3dd 100644
> --- a/drivers/gpu/drm/msm/msm_iommu.c
> +++ b/drivers/gpu/drm/msm/msm_iommu.c
> @@ -258,8 +258,7 @@ struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent)
>  	ttbr0_cfg.quirks &= ~IO_PGTABLE_QUIRK_ARM_TTBR1;
>  	ttbr0_cfg.tlb = &null_tlb_ops;
>  
> -	pagetable->pgtbl_ops = alloc_io_pgtable_ops(ARM_64_LPAE_S1,
> -		&ttbr0_cfg, iommu->domain);
This seems to miss:
+	ttbr0_cfg.fmt = ARM_64_LPAE_S1;
> +	pagetable->pgtbl_ops = alloc_io_pgtable_ops(&ttbr0_cfg, iommu->domain);
>  
>  	if (!pagetable->pgtbl_ops) {
>  		kfree(pagetable);
> diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> index 4e83a1891f3e..31bdb5d46244 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> @@ -622,6 +622,7 @@ struct panfrost_mmu *panfrost_mmu_ctx_create(struct panfrost_device *pfdev)
>  	mmu->as = -1;
>  
>  	mmu->pgtbl_cfg = (struct io_pgtable_cfg) {
> +		.fmt		= ARM_MALI_LPAE,
>  		.pgsize_bitmap	= SZ_4K | SZ_2M,
>  		.ias		= FIELD_GET(0xff, pfdev->features.mmu_features),
>  		.oas		= FIELD_GET(0xff00, pfdev->features.mmu_features),
> @@ -630,8 +631,7 @@ struct panfrost_mmu *panfrost_mmu_ctx_create(struct panfrost_device *pfdev)
>  		.iommu_dev	= pfdev->dev,
>  	};
>  
> -	mmu->pgtbl_ops = alloc_io_pgtable_ops(ARM_MALI_LPAE, &mmu->pgtbl_cfg,
> -					      mmu);
> +	mmu->pgtbl_ops = alloc_io_pgtable_ops(&mmu->pgtbl_cfg, mmu);
>  	if (!mmu->pgtbl_ops) {
>  		kfree(mmu);
>  		return ERR_PTR(-EINVAL);
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index cbeaab55c0db..7efb6b467041 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2072,7 +2072,8 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
>  	if (ret)
>  		goto out_err;
>  
> -	pgtbl_ops = alloc_io_pgtable_ops(pgtable, &domain->iop.pgtbl_cfg, domain);
> +	domain->iop.pgtbl_cfg.fmt = pgtable;
> +	pgtbl_ops = alloc_io_pgtable_ops(&domain->iop.pgtbl_cfg, domain);
>  	if (!pgtbl_ops) {
>  		domain_id_free(domain->id);
>  		goto out_err;
> diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
> index 4f4a323be0d0..571f948add7c 100644
> --- a/drivers/iommu/apple-dart.c
> +++ b/drivers/iommu/apple-dart.c
> @@ -427,6 +427,7 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,
>  	}
>  
>  	pgtbl_cfg = (struct io_pgtable_cfg){
> +		.fmt = dart->hw->fmt,
>  		.pgsize_bitmap = dart->pgsize,
>  		.ias = 32,
>  		.oas = dart->hw->oas,
> @@ -434,8 +435,7 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,
>  		.iommu_dev = dart->dev,
>  	};
>  
> -	dart_domain->pgtbl_ops =
> -		alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, domain);
> +	dart_domain->pgtbl_ops = alloc_io_pgtable_ops(&pgtbl_cfg, domain);
>  	if (!dart_domain->pgtbl_ops) {
>  		ret = -ENOMEM;
>  		goto done;
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index ab160198edd6..c033b23ca4b2 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2209,6 +2209,7 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain,
>  	}
>  
>  	pgtbl_cfg = (struct io_pgtable_cfg) {
> +		.fmt		= fmt,
>  		.pgsize_bitmap	= smmu->pgsize_bitmap,
>  		.ias		= ias,
>  		.oas		= oas,
> @@ -2217,7 +2218,7 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain,
>  		.iommu_dev	= smmu->dev,
>  	};
>  
> -	pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);
> +	pgtbl_ops = alloc_io_pgtable_ops(&pgtbl_cfg, smmu_domain);
>  	if (!pgtbl_ops)
>  		return -ENOMEM;
>  
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 719fbca1fe52..f230d2ce977a 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -747,6 +747,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
>  		cfg->asid = cfg->cbndx;
>  
>  	pgtbl_cfg = (struct io_pgtable_cfg) {
> +		.fmt		= fmt,
>  		.pgsize_bitmap	= smmu->pgsize_bitmap,
>  		.ias		= ias,
>  		.oas		= oas,
> @@ -764,7 +765,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
>  	if (smmu_domain->pgtbl_quirks)
>  		pgtbl_cfg.quirks |= smmu_domain->pgtbl_quirks;
>  
> -	pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);
> +	pgtbl_ops = alloc_io_pgtable_ops(&pgtbl_cfg, smmu_domain);
>  	if (!pgtbl_ops) {
>  		ret = -ENOMEM;
>  		goto out_clear_smmu;
> diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> index 270c3d9128ba..65eb8bdcbe50 100644
> --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> @@ -239,6 +239,7 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain,
>  		goto out_unlock;
>  
>  	pgtbl_cfg = (struct io_pgtable_cfg) {
> +		.fmt		= ARM_32_LPAE_S1,
>  		.pgsize_bitmap	= qcom_iommu_ops.pgsize_bitmap,
>  		.ias		= 32,
>  		.oas		= 40,
> @@ -249,7 +250,7 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain,
>  	qcom_domain->iommu = qcom_iommu;
>  	qcom_domain->fwspec = fwspec;
>  
> -	pgtbl_ops = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &pgtbl_cfg, qcom_domain);
> +	pgtbl_ops = alloc_io_pgtable_ops(&pgtbl_cfg, qcom_domain);
>  	if (!pgtbl_ops) {
>  		dev_err(qcom_iommu->dev, "failed to allocate pagetable ops\n");
>  		ret = -ENOMEM;
> diff --git a/drivers/iommu/io-pgtable-arm-common.c b/drivers/iommu/io-pgtable-arm-common.c
> index 7340b5096499..4b3a9ce806ea 100644
> --- a/drivers/iommu/io-pgtable-arm-common.c
> +++ b/drivers/iommu/io-pgtable-arm-common.c
> @@ -62,7 +62,7 @@ static void __arm_lpae_init_pte(struct arm_lpae_io_pgtable *data,
>  	size_t sz = ARM_LPAE_BLOCK_SIZE(lvl, data);
>  	int i;
>  
> -	if (data->iop.fmt != ARM_MALI_LPAE && lvl == ARM_LPAE_MAX_LEVELS - 1)
> +	if (data->iop.cfg.fmt != ARM_MALI_LPAE && lvl == ARM_LPAE_MAX_LEVELS - 1)
>  		pte |= ARM_LPAE_PTE_TYPE_PAGE;
>  	else
>  		pte |= ARM_LPAE_PTE_TYPE_BLOCK;
> @@ -82,7 +82,7 @@ static int arm_lpae_init_pte(struct arm_lpae_io_pgtable *data,
>  	int i;
>  
>  	for (i = 0; i < num_entries; i++)
> -		if (iopte_leaf(ptep[i], lvl, data->iop.fmt)) {
> +		if (iopte_leaf(ptep[i], lvl, data->iop.cfg.fmt)) {
>  			/* We require an unmap first */
>  			WARN_ON(!selftest_running);
>  			return -EEXIST;
> @@ -183,7 +183,7 @@ int __arm_lpae_map(struct arm_lpae_io_pgtable *data, unsigned long iova,
>  		__arm_lpae_sync_pte(ptep, 1, cfg);
>  	}
>  
> -	if (pte && !iopte_leaf(pte, lvl, data->iop.fmt)) {
> +	if (pte && !iopte_leaf(pte, lvl, data->iop.cfg.fmt)) {
>  		cptep = iopte_deref(pte, data);
>  	} else if (pte) {
>  		/* We require an unmap first */
> @@ -201,8 +201,8 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
>  {
>  	arm_lpae_iopte pte;
>  
> -	if (data->iop.fmt == ARM_64_LPAE_S1 ||
> -	    data->iop.fmt == ARM_32_LPAE_S1) {
> +	if (data->iop.cfg.fmt == ARM_64_LPAE_S1 ||
> +	    data->iop.cfg.fmt == ARM_32_LPAE_S1) {
>  		pte = ARM_LPAE_PTE_nG;
>  		if (!(prot & IOMMU_WRITE) && (prot & IOMMU_READ))
>  			pte |= ARM_LPAE_PTE_AP_RDONLY;
> @@ -220,8 +220,8 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
>  	 * Note that this logic is structured to accommodate Mali LPAE
>  	 * having stage-1-like attributes but stage-2-like permissions.
>  	 */
> -	if (data->iop.fmt == ARM_64_LPAE_S2 ||
> -	    data->iop.fmt == ARM_32_LPAE_S2) {
> +	if (data->iop.cfg.fmt == ARM_64_LPAE_S2 ||
> +	    data->iop.cfg.fmt == ARM_32_LPAE_S2) {
>  		if (prot & IOMMU_MMIO)
>  			pte |= ARM_LPAE_PTE_MEMATTR_DEV;
>  		else if (prot & IOMMU_CACHE)
> @@ -243,7 +243,7 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
>  	 * "outside the GPU" (i.e. either the Inner or System domain in CPU
>  	 * terms, depending on coherency).
>  	 */
> -	if (prot & IOMMU_CACHE && data->iop.fmt != ARM_MALI_LPAE)
> +	if (prot & IOMMU_CACHE && data->iop.cfg.fmt != ARM_MALI_LPAE)
>  		pte |= ARM_LPAE_PTE_SH_IS;
>  	else
>  		pte |= ARM_LPAE_PTE_SH_OS;
> @@ -254,7 +254,7 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
>  	if (data->iop.cfg.quirks & IO_PGTABLE_QUIRK_ARM_NS)
>  		pte |= ARM_LPAE_PTE_NS;
>  
> -	if (data->iop.fmt != ARM_MALI_LPAE)
> +	if (data->iop.cfg.fmt != ARM_MALI_LPAE)
>  		pte |= ARM_LPAE_PTE_AF;
>  
>  	return pte;
> @@ -317,7 +317,7 @@ void __arm_lpae_free_pgtable(struct arm_lpae_io_pgtable *data, int lvl,
>  	while (ptep != end) {
>  		arm_lpae_iopte pte = *ptep++;
>  
> -		if (!pte || iopte_leaf(pte, lvl, data->iop.fmt))
> +		if (!pte || iopte_leaf(pte, lvl, data->iop.cfg.fmt))
>  			continue;
>  
>  		__arm_lpae_free_pgtable(data, lvl + 1, iopte_deref(pte, data));
> @@ -417,7 +417,7 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
>  
>  			__arm_lpae_clear_pte(ptep, &iop->cfg);
>  
> -			if (!iopte_leaf(pte, lvl, iop->fmt)) {
> +			if (!iopte_leaf(pte, lvl, iop->cfg.fmt)) {
>  				/* Also flush any partial walks */
>  				io_pgtable_tlb_flush_walk(iop, iova + i * size, size,
>  							  ARM_LPAE_GRANULE(data));
> @@ -431,7 +431,7 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
>  		}
>  
>  		return i * size;
> -	} else if (iopte_leaf(pte, lvl, iop->fmt)) {
> +	} else if (iopte_leaf(pte, lvl, iop->cfg.fmt)) {
>  		/*
>  		 * Insert a table at the next level to map the old region,
>  		 * minus the part we want to unmap
> @@ -487,7 +487,7 @@ phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops,
>  			return 0;
>  
>  		/* Leaf entry? */
> -		if (iopte_leaf(pte, lvl, data->iop.fmt))
> +		if (iopte_leaf(pte, lvl, data->iop.cfg.fmt))
>  			goto found_translation;
>  
>  		/* Take it to the next level */
> diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
> index 75f244a3e12d..278b4299d757 100644
> --- a/drivers/iommu/io-pgtable-arm-v7s.c
> +++ b/drivers/iommu/io-pgtable-arm-v7s.c
> @@ -930,6 +930,7 @@ static int __init arm_v7s_do_selftests(void)
>  {
>  	struct io_pgtable_ops *ops;
>  	struct io_pgtable_cfg cfg = {
> +		.fmt = ARM_V7S,
>  		.tlb = &dummy_tlb_ops,
>  		.oas = 32,
>  		.ias = 32,
> @@ -945,7 +946,7 @@ static int __init arm_v7s_do_selftests(void)
>  
>  	cfg_cookie = &cfg;
>  
> -	ops = alloc_io_pgtable_ops(ARM_V7S, &cfg, &cfg);
> +	ops = alloc_io_pgtable_ops(&cfg, &cfg);
>  	if (!ops) {
>  		pr_err("selftest: failed to allocate io pgtable ops\n");
>  		return -EINVAL;
> diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> index b2b188bb86b3..b76b903400de 100644
> --- a/drivers/iommu/io-pgtable-arm.c
> +++ b/drivers/iommu/io-pgtable-arm.c
> @@ -319,7 +319,8 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
>  
>  	for (i = 0; i < ARRAY_SIZE(fmts); ++i) {
>  		cfg_cookie = cfg;
> -		ops = alloc_io_pgtable_ops(fmts[i], cfg, cfg);
> +		cfg->fmt = fmts[i];
> +		ops = alloc_io_pgtable_ops(cfg, cfg);
>  		if (!ops) {
>  			pr_err("selftest: failed to allocate io pgtable ops\n");
>  			return -ENOMEM;
> diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dart.c
> index 74b1ef2b96be..f981b25d8c98 100644
> --- a/drivers/iommu/io-pgtable-dart.c
> +++ b/drivers/iommu/io-pgtable-dart.c
> @@ -81,7 +81,7 @@ static dart_iopte paddr_to_iopte(phys_addr_t paddr,
>  {
>  	dart_iopte pte;
>  
> -	if (data->iop.fmt == APPLE_DART)
> +	if (data->iop.cfg.fmt == APPLE_DART)
>  		return paddr & APPLE_DART1_PADDR_MASK;
>  
>  	/* format is APPLE_DART2 */
> @@ -96,7 +96,7 @@ static phys_addr_t iopte_to_paddr(dart_iopte pte,
>  {
>  	u64 paddr;
>  
> -	if (data->iop.fmt == APPLE_DART)
> +	if (data->iop.cfg.fmt == APPLE_DART)
>  		return pte & APPLE_DART1_PADDR_MASK;
>  
>  	/* format is APPLE_DART2 */
> @@ -215,13 +215,13 @@ static dart_iopte dart_prot_to_pte(struct dart_io_pgtable *data,
>  {
>  	dart_iopte pte = 0;
>  
> -	if (data->iop.fmt == APPLE_DART) {
> +	if (data->iop.cfg.fmt == APPLE_DART) {
>  		if (!(prot & IOMMU_WRITE))
>  			pte |= APPLE_DART1_PTE_PROT_NO_WRITE;
>  		if (!(prot & IOMMU_READ))
>  			pte |= APPLE_DART1_PTE_PROT_NO_READ;
>  	}
> -	if (data->iop.fmt == APPLE_DART2) {
> +	if (data->iop.cfg.fmt == APPLE_DART2) {
>  		if (!(prot & IOMMU_WRITE))
>  			pte |= APPLE_DART2_PTE_PROT_NO_WRITE;
>  		if (!(prot & IOMMU_READ))
> diff --git a/drivers/iommu/io-pgtable.c b/drivers/iommu/io-pgtable.c
> index b843fcd365d2..79e459f95012 100644
> --- a/drivers/iommu/io-pgtable.c
> +++ b/drivers/iommu/io-pgtable.c
> @@ -34,17 +34,16 @@ io_pgtable_init_table[IO_PGTABLE_NUM_FMTS] = {
>  #endif
>  };
>  
> -struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
> -					    struct io_pgtable_cfg *cfg,
> +struct io_pgtable_ops *alloc_io_pgtable_ops(struct io_pgtable_cfg *cfg,
>  					    void *cookie)
>  {
>  	struct io_pgtable *iop;
>  	const struct io_pgtable_init_fns *fns;
>  
> -	if (fmt >= IO_PGTABLE_NUM_FMTS)
> +	if (cfg->fmt >= IO_PGTABLE_NUM_FMTS)
>  		return NULL;
>  
> -	fns = io_pgtable_init_table[fmt];
> +	fns = io_pgtable_init_table[cfg->fmt];
>  	if (!fns)
>  		return NULL;
>  
> @@ -52,7 +51,6 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
>  	if (!iop)
>  		return NULL;
>  
> -	iop->fmt	= fmt;
>  	iop->cookie	= cookie;
>  	iop->cfg	= *cfg;
>  
> @@ -73,6 +71,6 @@ void free_io_pgtable_ops(struct io_pgtable_ops *ops)
>  
>  	iop = io_pgtable_ops_to_pgtable(ops);
>  	io_pgtable_tlb_flush_all(iop);
> -	io_pgtable_init_table[iop->fmt]->free(iop);
> +	io_pgtable_init_table[iop->cfg.fmt]->free(iop);
>  }
>  EXPORT_SYMBOL_GPL(free_io_pgtable_ops);
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index a003bd5fc65c..4a1927489635 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -447,6 +447,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
>  	 */
>  	domain->cfg.coherent_walk = false;
>  	domain->cfg.iommu_dev = domain->mmu->root->dev;
> +	domain->cfg.fmt = ARM_32_LPAE_S1;
>  
>  	/*
>  	 * Find an unused context.
> @@ -457,8 +458,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
>  
>  	domain->context_id = ret;
>  
> -	domain->iop = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &domain->cfg,
> -					   domain);
> +	domain->iop = alloc_io_pgtable_ops(&domain->cfg, domain);
>  	if (!domain->iop) {
>  		ipmmu_domain_free_context(domain->mmu->root,
>  					  domain->context_id);
> diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
> index c60624910872..2c05a84ec1bf 100644
> --- a/drivers/iommu/msm_iommu.c
> +++ b/drivers/iommu/msm_iommu.c
> @@ -342,6 +342,7 @@ static int msm_iommu_domain_config(struct msm_priv *priv)
>  	spin_lock_init(&priv->pgtlock);
>  
>  	priv->cfg = (struct io_pgtable_cfg) {
> +		.fmt = ARM_V7S,
>  		.pgsize_bitmap = msm_iommu_ops.pgsize_bitmap,
>  		.ias = 32,
>  		.oas = 32,
> @@ -349,7 +350,7 @@ static int msm_iommu_domain_config(struct msm_priv *priv)
>  		.iommu_dev = priv->dev,
>  	};
>  
> -	priv->iop = alloc_io_pgtable_ops(ARM_V7S, &priv->cfg, priv);
> +	priv->iop = alloc_io_pgtable_ops(&priv->cfg, priv);
>  	if (!priv->iop) {
>  		dev_err(priv->dev, "Failed to allocate pgtable\n");
>  		return -EINVAL;
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 2badd6acfb23..0d754d94ae52 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -598,6 +598,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,
>  	}
>  
>  	dom->cfg = (struct io_pgtable_cfg) {
> +		.fmt = ARM_V7S,
>  		.quirks = IO_PGTABLE_QUIRK_ARM_NS |
>  			IO_PGTABLE_QUIRK_NO_PERMS |
>  			IO_PGTABLE_QUIRK_ARM_MTK_EXT,
> @@ -614,7 +615,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,
>  	else
>  		dom->cfg.oas = 35;
>  
> -	dom->iop = alloc_io_pgtable_ops(ARM_V7S, &dom->cfg, data);
> +	dom->iop = alloc_io_pgtable_ops(&dom->cfg, data);
>  	if (!dom->iop) {
>  		dev_err(data->dev, "Failed to alloc io pgtable\n");
>  		return -ENOMEM;
> -- 
> 2.39.0
> 
Thanks,
Mostafa

  reply	other threads:[~2024-02-16 11:55 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 12:52 [RFC PATCH 00/45] KVM: Arm SMMUv3 driver for pKVM Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 01/45] iommu/io-pgtable-arm: Split the page table driver Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 02/45] iommu/io-pgtable-arm: Split initialization Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 03/45] iommu/io-pgtable: Move fmt into io_pgtable_cfg Jean-Philippe Brucker
2024-02-16 11:55   ` Mostafa Saleh [this message]
2023-02-01 12:52 ` [RFC PATCH 04/45] iommu/io-pgtable: Add configure() operation Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 05/45] iommu/io-pgtable: Split io_pgtable structure Jean-Philippe Brucker
2023-02-07 12:16   ` Mostafa Saleh
2023-02-08 18:01     ` Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 06/45] iommu/io-pgtable-arm: Extend __arm_lpae_free_pgtable() to only free child tables Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 07/45] iommu/arm-smmu-v3: Move some definitions to arm64 include/ Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 08/45] KVM: arm64: pkvm: Add pkvm_udelay() Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 09/45] KVM: arm64: pkvm: Add pkvm_create_hyp_device_mapping() Jean-Philippe Brucker
2023-02-07 12:22   ` Mostafa Saleh
2023-02-08 18:02     ` Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 10/45] KVM: arm64: pkvm: Expose pkvm_map/unmap_donated_memory() Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 11/45] KVM: arm64: pkvm: Expose pkvm_admit_host_page() Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 12/45] KVM: arm64: pkvm: Unify pkvm_pkvm_teardown_donated_memory() Jean-Philippe Brucker
2024-01-15 14:33   ` Sebastian Ene
2024-01-23 19:49     ` Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 13/45] KVM: arm64: pkvm: Add hyp_page_ref_inc_return() Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 14/45] KVM: arm64: pkvm: Prevent host donation of device memory Jean-Philippe Brucker
2023-02-01 12:52 ` [RFC PATCH 15/45] KVM: arm64: pkvm: Add __pkvm_host_share/unshare_dma() Jean-Philippe Brucker
2023-02-04 12:51   ` tina.zhang
2023-02-06 12:13     ` Jean-Philippe Brucker
2023-02-07  2:37       ` tina.zhang
2023-02-07 10:39         ` Jean-Philippe Brucker
2023-02-07 12:53   ` Mostafa Saleh
2023-02-10 19:21     ` Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 16/45] KVM: arm64: Introduce IOMMU driver infrastructure Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 17/45] KVM: arm64: pkvm: Add IOMMU hypercalls Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 18/45] KVM: arm64: iommu: Add per-cpu page queue Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 19/45] KVM: arm64: iommu: Add domains Jean-Philippe Brucker
2023-02-07 13:13   ` Mostafa Saleh
2023-02-08 12:31     ` Mostafa Saleh
2023-02-08 18:05       ` Jean-Philippe Brucker
2023-02-10 22:03         ` Mostafa Saleh
2023-05-19 15:33   ` Mostafa Saleh
2023-06-02 15:29     ` Jean-Philippe Brucker
2023-06-15 13:32       ` Mostafa Saleh
2023-02-01 12:53 ` [RFC PATCH 20/45] KVM: arm64: iommu: Add map() and unmap() operations Jean-Philippe Brucker
2023-03-30 18:14   ` Mostafa Saleh
2023-04-04 16:00     ` Jean-Philippe Brucker
2023-09-20 16:23       ` Mostafa Saleh
2023-09-25 17:21         ` Jean-Philippe Brucker
2024-02-16 11:59   ` Mostafa Saleh
2024-02-26 14:12     ` Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 21/45] KVM: arm64: iommu: Add SMMUv3 driver Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 22/45] KVM: arm64: smmu-v3: Initialize registers Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 23/45] KVM: arm64: smmu-v3: Setup command queue Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 24/45] KVM: arm64: smmu-v3: Setup stream table Jean-Philippe Brucker
2024-01-16  8:59   ` Mostafa Saleh
2024-01-23 19:45     ` Jean-Philippe Brucker
2024-02-16 12:19       ` Mostafa Saleh
2024-02-26 14:13         ` Jean-Philippe Brucker
2024-03-06 12:51           ` Mostafa Saleh
2023-02-01 12:53 ` [RFC PATCH 25/45] KVM: arm64: smmu-v3: Reset the device Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 26/45] KVM: arm64: smmu-v3: Support io-pgtable Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 27/45] KVM: arm64: smmu-v3: Setup domains and page table configuration Jean-Philippe Brucker
2023-06-23 19:12   ` Mostafa Saleh
2023-07-03 10:41     ` Jean-Philippe Brucker
2024-01-15 14:34   ` Mostafa Saleh
2024-01-23 19:50     ` Jean-Philippe Brucker
2024-02-16 12:11       ` Mostafa Saleh
2024-02-26 14:18         ` Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 28/45] iommu/arm-smmu-v3: Extract driver-specific bits from probe function Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 29/45] iommu/arm-smmu-v3: Move some functions to arm-smmu-v3-common.c Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 30/45] iommu/arm-smmu-v3: Move queue and table allocation " Jean-Philippe Brucker
2024-02-16 12:03   ` Mostafa Saleh
2024-02-26 14:19     ` Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 31/45] iommu/arm-smmu-v3: Move firmware probe to arm-smmu-v3-common Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 32/45] iommu/arm-smmu-v3: Move IOMMU registration to arm-smmu-v3-common.c Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 33/45] iommu/arm-smmu-v3: Use single pages for level-2 stream tables Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 34/45] iommu/arm-smmu-v3: Add host driver for pKVM Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 35/45] iommu/arm-smmu-v3-kvm: Pass a list of SMMU devices to the hypervisor Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 36/45] iommu/arm-smmu-v3-kvm: Validate device features Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 37/45] iommu/arm-smmu-v3-kvm: Allocate structures and reset device Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 38/45] iommu/arm-smmu-v3-kvm: Add per-cpu page queue Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 39/45] iommu/arm-smmu-v3-kvm: Initialize page table configuration Jean-Philippe Brucker
2023-03-22 10:23   ` Mostafa Saleh
2023-03-22 14:42     ` Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 40/45] iommu/arm-smmu-v3-kvm: Add IOMMU ops Jean-Philippe Brucker
2023-02-07 13:22   ` Mostafa Saleh
2023-02-08 18:13     ` Jean-Philippe Brucker
2023-09-20 16:27   ` Mostafa Saleh
2023-09-25 17:18     ` Jean-Philippe Brucker
2023-09-26  9:54       ` Mostafa Saleh
2023-02-01 12:53 ` [RFC PATCH 41/45] KVM: arm64: pkvm: Add __pkvm_host_add_remove_page() Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 42/45] KVM: arm64: pkvm: Support SCMI power domain Jean-Philippe Brucker
2023-02-07 13:27   ` Mostafa Saleh
2023-02-10 19:23     ` Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 43/45] KVM: arm64: smmu-v3: Support power management Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 44/45] iommu/arm-smmu-v3-kvm: Support power management with SCMI SMC Jean-Philippe Brucker
2023-02-01 12:53 ` [RFC PATCH 45/45] iommu/arm-smmu-v3-kvm: Enable runtime PM Jean-Philippe Brucker
2023-02-02  7:07 ` [RFC PATCH 00/45] KVM: Arm SMMUv3 driver for pKVM Tian, Kevin
2023-02-02 10:05   ` Jean-Philippe Brucker
2023-02-03  2:04     ` Tian, Kevin
2023-02-03  8:39       ` Chen, Jason CJ
2023-02-03 11:23         ` Jean-Philippe Brucker
2023-02-04  8:19           ` Chen, Jason CJ
2023-02-04 12:30             ` tina.zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zc9NKU18_uF4XHWY@google.com \
    --to=smostafa@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=dbrazdil@google.com \
    --cc=iommu@lists.linux.dev \
    --cc=james.morse@arm.com \
    --cc=jean-philippe@linaro.org \
    --cc=joro@8bytes.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=robin.murphy@arm.com \
    --cc=ryan.roberts@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox