linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Janne Grunau <j@jannau.net>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: linux-arm-kernel@lists.infradead.org,
	Kevin Tian <kevin.tian@intel.com>, Will Deacon <will@kernel.org>,
	Sven Peter <sven@svenpeter.dev>,
	linuxppc-dev@lists.ozlabs.org, Joerg Roedel <joro@8bytes.org>,
	Hector Martin <marcan@marcan.st>,
	Nicholas Piggin <npiggin@gmail.com>,
	Robin Murphy <robin.murphy@arm.com>,
	iommu@lists.linux.dev, asahi@lists.linux.dev,
	David Woodhouse <dwmw2@infradead.org>,
	Alyssa Rosenzweig <alyssa@rosenzweig.io>,
	Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH 8/8] iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()
Date: Tue, 26 Sep 2023 21:07:33 +0200	[thread overview]
Message-ID: <ZRMr9SK3F85WGXE7@robin> (raw)
In-Reply-To: <8-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com>

On Fri, Sep 22, 2023 at 02:07:59PM -0300, Jason Gunthorpe wrote:
> In many cases the dev argument will now be !NULL so we should use it to
> finalize the domain at allocation.
> 
> Make apple_dart_finalize_domain() accept the correct type.
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/iommu/apple-dart.c | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
> index 62efe0aa056f60..2c1832e357c7c6 100644
> --- a/drivers/iommu/apple-dart.c
> +++ b/drivers/iommu/apple-dart.c
> @@ -568,10 +568,9 @@ apple_dart_setup_translation(struct apple_dart_domain *domain,
>  	stream_map->dart->hw->invalidate_tlb(stream_map);
>  }
>  
> -static int apple_dart_finalize_domain(struct iommu_domain *domain,
> +static int apple_dart_finalize_domain(struct apple_dart_domain *dart_domain,
>  				      struct apple_dart_master_cfg *cfg)
>  {
> -	struct apple_dart_domain *dart_domain = to_dart_domain(domain);
>  	struct apple_dart *dart = cfg->stream_maps[0].dart;
>  	struct io_pgtable_cfg pgtbl_cfg;
>  	int ret = 0;
> @@ -597,16 +596,17 @@ 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(dart->hw->fmt, &pgtbl_cfg,
> +						      &dart_domain->domain);
>  	if (!dart_domain->pgtbl_ops) {
>  		ret = -ENOMEM;
>  		goto done;
>  	}
>  
> -	domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
> -	domain->geometry.aperture_start = 0;
> -	domain->geometry.aperture_end = (dma_addr_t)DMA_BIT_MASK(dart->ias);
> +	dart_domain->domain.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
> +	dart_domain->domain.geometry.aperture_start = 0;
> +	dart_domain->domain.geometry.aperture_end =
> +		(dma_addr_t)DMA_BIT_MASK(dart->ias);
>  
>  	dart_domain->finalized = true;
>  
> @@ -661,7 +661,7 @@ static int apple_dart_attach_dev_paging(struct iommu_domain *domain,
>  	if (cfg->stream_maps[0].dart->force_bypass)
>  		return -EINVAL;
>  
> -	ret = apple_dart_finalize_domain(domain, cfg);
> +	ret = apple_dart_finalize_domain(dart_domain, cfg);
>  	if (ret)
>  		return ret;
>  
> @@ -757,6 +757,16 @@ static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev)
>  
>  	mutex_init(&dart_domain->init_lock);
>  
> +	if (dev) {
> +		struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
> +		int ret;
> +
> +		ret = apple_dart_finalize_domain(dart_domain, cfg);
> +		if (ret) {
> +			kfree(dart_domain);
> +			return ERR_PTR(ret);
> +		}
> +	}
>  	return &dart_domain->domain;
>  }
>  
> -- 
> 2.42.0

Reviewed-by: Janne Grunau <j@jannau.net>

best regards

Janne

      reply	other threads:[~2023-09-26 21:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22 17:07 [PATCH 0/8] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
2023-09-22 17:07 ` [PATCH 1/8] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain Jason Gunthorpe
2023-09-25  2:26   ` Baolu Lu
2023-09-22 17:07 ` [PATCH 2/8] iommu/vt-d: Update the definition of the blocking domain Jason Gunthorpe
2023-09-25  2:27   ` Baolu Lu
2023-09-22 17:07 ` [PATCH 3/8] iommu/vt-d: Use ops->blocked_domain Jason Gunthorpe
2023-09-25  2:29   ` Baolu Lu
2023-09-25 11:41     ` Jason Gunthorpe
2023-09-26  3:28       ` Baolu Lu
2023-09-22 17:07 ` [PATCH 4/8] iommufd: Convert to alloc_domain_paging() Jason Gunthorpe
2023-09-22 17:07 ` [PATCH 5/8] iommu/dart: Use static global identity domains Jason Gunthorpe
2023-09-22 17:07 ` [PATCH 6/8] iommu/dart: Move the blocked domain support to a global static Jason Gunthorpe
2023-09-26 19:05   ` Janne Grunau
2023-09-26 19:34     ` Robin Murphy
2023-09-26 19:41       ` Robin Murphy
2023-09-27 12:59     ` Jason Gunthorpe
2023-09-22 17:07 ` [PATCH 7/8] iommu/dart: Convert to domain_alloc_paging() Jason Gunthorpe
2023-09-26 19:06   ` Janne Grunau
2023-09-22 17:07 ` [PATCH 8/8] iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging() Jason Gunthorpe
2023-09-26 19:07   ` Janne Grunau [this message]

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=ZRMr9SK3F85WGXE7@robin \
    --to=j@jannau.net \
    --cc=alyssa@rosenzweig.io \
    --cc=asahi@lists.linux.dev \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=marcan@marcan.st \
    --cc=npiggin@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=sven@svenpeter.dev \
    --cc=will@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).