[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z8HnWdgPNMmCoXtX@blossom>
Date: Fri, 28 Feb 2025 11:42:01 -0500
From: Alyssa Rosenzweig <alyssa@...enzweig.io>
To: fnkl.kernel@...il.com
Cc: Sven Peter <sven@...npeter.dev>, Janne Grunau <j@...nau.net>,
Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>, asahi@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org, Hector Martin <marcan@...can.st>
Subject: Re: [PATCH v2 2/2] iommu: apple-dart: Allow mismatched bypass support
Reviewed-by: Alyssa Rosenzweig <alyssa@...enzweig.io>
Le Fri , Feb 28, 2025 at 05:32:08PM +0100, Sasha Finkelstein via B4 Relay a écrit :
> From: Hector Martin <marcan@...can.st>
>
> This is needed by ISP, which has DART0 with bypass and DART1/2 without.
>
> Signed-off-by: Hector Martin <marcan@...can.st>
> Signed-off-by: Sasha Finkelstein <fnkl.kernel@...il.com>
> ---
> drivers/iommu/apple-dart.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
> index edb2fb22333506d7c64ad1b6321df00ebfd07747..13ccb801f52a4d34f6653f78e92787af7dfed1bc 100644
> --- a/drivers/iommu/apple-dart.c
> +++ b/drivers/iommu/apple-dart.c
> @@ -277,6 +277,9 @@ struct apple_dart_domain {
> * @streams: streams for this device
> */
> struct apple_dart_master_cfg {
> + /* Intersection of DART capabilitles */
> + u32 supports_bypass : 1;
> +
> struct apple_dart_stream_map stream_maps[MAX_DARTS_PER_DEVICE];
> };
>
> @@ -684,7 +687,7 @@ static int apple_dart_attach_dev_identity(struct iommu_domain *domain,
> struct apple_dart_stream_map *stream_map;
> int i;
>
> - if (!cfg->stream_maps[0].dart->supports_bypass)
> + if (!cfg->supports_bypass)
> return -EINVAL;
>
> for_each_stream_map(i, cfg, stream_map)
> @@ -792,20 +795,24 @@ static int apple_dart_of_xlate(struct device *dev,
> return -EINVAL;
> sid = args->args[0];
>
> - if (!cfg)
> + if (!cfg) {
> cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
> +
> + /* Will be ANDed with DART capabilities */
> + cfg->supports_bypass = true;
> + }
> if (!cfg)
> return -ENOMEM;
> dev_iommu_priv_set(dev, cfg);
>
> cfg_dart = cfg->stream_maps[0].dart;
> if (cfg_dart) {
> - if (cfg_dart->supports_bypass != dart->supports_bypass)
> - return -EINVAL;
> if (cfg_dart->pgsize != dart->pgsize)
> return -EINVAL;
> }
>
> + cfg->supports_bypass &= dart->supports_bypass;
> +
> for (i = 0; i < MAX_DARTS_PER_DEVICE; ++i) {
> if (cfg->stream_maps[i].dart == dart) {
> set_bit(sid, cfg->stream_maps[i].sidmap);
> @@ -945,7 +952,7 @@ static int apple_dart_def_domain_type(struct device *dev)
>
> if (cfg->stream_maps[0].dart->pgsize > PAGE_SIZE)
> return IOMMU_DOMAIN_IDENTITY;
> - if (!cfg->stream_maps[0].dart->supports_bypass)
> + if (!cfg->supports_bypass)
> return IOMMU_DOMAIN_DMA;
>
> return 0;
>
> --
> 2.48.1
>
>
Powered by blists - more mailing lists