From: "Janne Grunau" <j@jannau.net>
To: "Jason Gunthorpe" <jgg@nvidia.com>,
"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
asahi@lists.linux.dev,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"David Woodhouse" <dwmw2@infradead.org>,
iommu@lists.linux.dev, "Joerg Roedel" <joro@8bytes.org>,
"Kevin Tian" <kevin.tian@intel.com>,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, "Hector Martin" <marcan@marcan.st>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Sven Peter" <sven@svenpeter.dev>,
"Will Deacon" <will@kernel.org>
Cc: Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH v2 9/9] iommu/dart: Remove the force_bypass variable
Date: Mon, 16 Oct 2023 13:44:29 +0200 [thread overview]
Message-ID: <2111fedf-a690-453a-a705-6e9b8141d93d@app.fastmail.com> (raw)
In-Reply-To: <9-v2-bff223cf6409+282-dart_paging_jgg@nvidia.com>
Hej,
On Thu, Sep 28, 2023, at 01:47, Jason Gunthorpe wrote:
> This flag just caches if the IO page size is larger than the CPU
> PAGE_SIZE. This only needs to be checked in two places so remove the
> confusingly named cache.
>
> dart would like to not support paging domains at all if the IO page size
> is larger than the CPU page size. In this case we should ideally fail
> domain_alloc_paging(), as there is no point in creating a domain that can
> never be attached. Move the test into apple_dart_finalize_domain().
>
> The check in apple_dart_mod_streams() will prevent the domain from being
> attached to the wrong dart
>
> There is no HW limitation that prevents BLOCKED domains from working,
> remove that test.
>
> The check in apple_dart_of_xlate() is redundant since immediately after
> the pgsize is checked. Remove it.
>
> Remove the variable.
>
> Suggested-by: Janne Grunau <j@jannau.net>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/apple-dart.c | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
> index 126da0d89f0dd4..821b4a3465dfb9 100644
> --- a/drivers/iommu/apple-dart.c
> +++ b/drivers/iommu/apple-dart.c
> @@ -196,7 +196,6 @@ struct apple_dart_hw {
> * @lock: lock for hardware operations involving this dart
> * @pgsize: pagesize supported by this DART
> * @supports_bypass: indicates if this DART supports bypass mode
> - * @force_bypass: force bypass mode due to pagesize mismatch?
> * @sid2group: maps stream ids to iommu_groups
> * @iommu: iommu core device
> */
> @@ -217,7 +216,6 @@ struct apple_dart {
> u32 pgsize;
> u32 num_streams;
> u32 supports_bypass : 1;
> - u32 force_bypass : 1;
>
> struct iommu_group *sid2group[DART_MAX_STREAMS];
> struct iommu_device iommu;
> @@ -576,6 +574,9 @@ static int apple_dart_finalize_domain(struct
> apple_dart_domain *dart_domain,
> int ret = 0;
> int i, j;
>
> + if (dart->pgsize > PAGE_SIZE)
> + return -EINVAL;
> +
> mutex_lock(&dart_domain->init_lock);
>
> if (dart_domain->finalized)
> @@ -659,9 +660,6 @@ static int apple_dart_attach_dev_paging(struct
> iommu_domain *domain,
> struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
> struct apple_dart_domain *dart_domain = to_dart_domain(domain);
>
> - if (cfg->stream_maps[0].dart->force_bypass)
> - return -EINVAL;
> -
> ret = apple_dart_finalize_domain(dart_domain, cfg);
> if (ret)
> return ret;
> @@ -706,9 +704,6 @@ static int apple_dart_attach_dev_blocked(struct
> iommu_domain *domain,
> struct apple_dart_stream_map *stream_map;
> int i;
>
> - if (cfg->stream_maps[0].dart->force_bypass)
> - return -EINVAL;
> -
> for_each_stream_map(i, cfg, stream_map)
> apple_dart_hw_disable_dma(stream_map);
> return 0;
> @@ -803,8 +798,6 @@ static int apple_dart_of_xlate(struct device *dev,
> struct of_phandle_args *args)
> if (cfg_dart) {
> if (cfg_dart->supports_bypass != dart->supports_bypass)
> return -EINVAL;
> - if (cfg_dart->force_bypass != dart->force_bypass)
> - return -EINVAL;
> if (cfg_dart->pgsize != dart->pgsize)
> return -EINVAL;
> }
> @@ -946,7 +939,7 @@ static int apple_dart_def_domain_type(struct device
> *dev)
> {
> struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
>
> - if (cfg->stream_maps[0].dart->force_bypass)
> + if (cfg->stream_maps[0].dart->pgsize > PAGE_SIZE)
> return IOMMU_DOMAIN_IDENTITY;
> if (!cfg->stream_maps[0].dart->supports_bypass)
> return IOMMU_DOMAIN_DMA;
> @@ -1146,8 +1139,6 @@ static int apple_dart_probe(struct platform_device *pdev)
> goto err_clk_disable;
> }
>
> - dart->force_bypass = dart->pgsize > PAGE_SIZE;
> -
> ret = apple_dart_hw_reset(dart);
> if (ret)
> goto err_clk_disable;
> @@ -1171,7 +1162,8 @@ static int apple_dart_probe(struct
> platform_device *pdev)
> dev_info(
> &pdev->dev,
> "DART [pagesize %x, %d streams, bypass support: %d, bypass forced:
> %d] initialized\n",
> - dart->pgsize, dart->num_streams, dart->supports_bypass,
> dart->force_bypass);
> + dart->pgsize, dart->num_streams, dart->supports_bypass,
> + dart->pgsize > PAGE_SIZE);
> return 0;
>
> err_sysfs_remove:
> --
Reviewed-by: Janne Grunau <j@jannau.net>
thanks,
Janne
next prev parent reply other threads:[~2023-10-16 11:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 2/9] iommu/vt-d: Update the definition of the blocking domain Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 3/9] iommu/vt-d: Use ops->blocked_domain Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 4/9] iommufd: Convert to alloc_domain_paging() Jason Gunthorpe
2023-10-09 7:48 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 5/9] iommu/dart: Use static global identity domains Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 6/9] iommu/dart: Move the blocked domain support to a global static Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 7/9] iommu/dart: Convert to domain_alloc_paging() Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 8/9] iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging() Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 9/9] iommu/dart: Remove the force_bypass variable Jason Gunthorpe
2023-10-16 11:44 ` Janne Grunau [this message]
2023-10-25 15:58 ` [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() jgg
2023-10-26 7:49 ` Joerg Roedel
2023-10-26 10:34 ` Sven Peter
2023-10-26 14:55 ` Joerg Roedel
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=2111fedf-a690-453a-a705-6e9b8141d93d@app.fastmail.com \
--to=j@jannau.net \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=baolu.lu@linux.intel.com \
--cc=christophe.leroy@csgroup.eu \
--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=mpe@ellerman.id.au \
--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).