From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4hz6Fo0z" Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C3CCCA for ; Tue, 28 Nov 2023 22:09:08 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5cef61289fdso63994067b3.1 for ; Tue, 28 Nov 2023 22:09:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701238147; x=1701842947; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=KtrAPaslMvSrZFznq3cpY4nyS514mOCdxUhLK1bsTtI=; b=4hz6Fo0zr13+6MdTqERmKQ2VkYDymvvESL+rjVDOPONoVDKJ89JS5vZAr9cGWgmXeI iCe4Gr1jGA18zFyltB0mAD/LvIZELVoE4c6EchCPHovFaQBUpiekq7sj9kf+v7Wo8EJx Bm88PjF0fpSLVtBhcE5rMR6F2oPPd6VcEL7z3yoUssqZtKKmZXq1surFKjBwgpE7KTGB 45g0aomlFJveBDLt1HtrdcU0h7pVzqQqVGdMrOL48/QkMYR4xYLFGf/1+0gDvqZJ/CB6 Go1mLYlC8a6PciJgAAiTpf4CoQrR+BbzOfToCpWOsL7ZNwT+lyqyaGCbo+M6Eii4LMDn IpRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701238147; x=1701842947; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KtrAPaslMvSrZFznq3cpY4nyS514mOCdxUhLK1bsTtI=; b=fWvdmWQyM5D/3HQe1NlSJ6RoG+IT20/PTdg9TpPvV6OF9dREkTayoOsYMabcn1C8Jd 3rLSgS+C1/t2fW4hjRKe4RlLsk3MBAxwMlKcDVDd8l+n7mQctDFW0TU5ycie2m5LPq0N s+5L2vGr5KB6bs2sRBEYROb67VK/4w2mt5/DKnV41VuCk0MvzipOarFIvhUfFWd2yWKP dvtpew84iRqJh5gKVf99+Y/JyloT1Llb4t+5SYkKTn/RmPQoKiWic5VQQSgwiSp1w08G gCueIjF4IvRMwGBbhBtwBhCXKyA02bPNV2eMAQ2LUd/sQ+GXagpoiDDT8rpEBECtwUfa 4BaQ== X-Gm-Message-State: AOJu0YwA99rkGZXSHAutUMjUyRdFVLkb68EFMOYG48dHIj/CYAaw4Dq7 zDOaGO/nN+melkOHLhZLpd8kUm7O2jch X-Google-Smtp-Source: AGHT+IErKpR33sSuZDb458AGzbTTTl+rmkeUZNxvoUYyius6/ySrcsirHg/Fcs0NR9CFHutX0EyL3PHfE3h2 X-Received: from morats.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:d9e]) (user=moritzf job=sendgmr) by 2002:a25:3741:0:b0:db5:2a4:aef1 with SMTP id e62-20020a253741000000b00db502a4aef1mr107973yba.13.1701238147290; Tue, 28 Nov 2023 22:09:07 -0800 (PST) Date: Wed, 29 Nov 2023 06:09:06 +0000 In-Reply-To: <7-v1-720585788a7d+811b-iommu_fwspec_p1_jgg@nvidia.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <0-v1-720585788a7d+811b-iommu_fwspec_p1_jgg@nvidia.com> <7-v1-720585788a7d+811b-iommu_fwspec_p1_jgg@nvidia.com> Message-ID: <20231129060906.qti7uztsk2u7ehlp@google.com> Subject: Re: [PATCH 07/10] acpi: Do not return struct iommu_ops from acpi_iommu_configure_id() From: Moritz Fischer To: Jason Gunthorpe Cc: David Airlie , Alyssa Rosenzweig , Albert Ou , asahi@lists.linux.dev, Catalin Marinas , Danilo Krummrich , Daniel Vetter , Dexuan Cui , devicetree@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, David Woodhouse , Frank Rowand , Hanjun Guo , Haiyang Zhang , iommu@lists.linux.dev, Jon Hunter , Joerg Roedel , Karol Herbst , Krzysztof Kozlowski , "K. Y. Srinivasan" , Laxman Dewangan , Len Brown , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-tegra@vger.kernel.org, Russell King , Lorenzo Pieralisi , Lyude Paul , Marek Szyprowski , nouveau@lists.freedesktop.org, Palmer Dabbelt , Paul Walmsley , "Rafael J. Wysocki" , Rob Herring , Robin Murphy , Sudeep Holla , Suravee Suthikulpanit , Sven Peter , Thomas Bogendoerfer , Vineet Gupta , Vinod Koul , Wei Liu , Will Deacon , Lu Baolu , Christoph Hellwig , Jerry Snitselaar , Hector Martin , Moritz Fischer , patches@lists.linux.dev, "Rafael J. Wysocki" , Rob Herring , Thierry Reding Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes On Tue, Nov 28, 2023 at 08:48:03PM -0400, Jason Gunthorpe wrote: > Nothing needs this pointer. Return a normal error code with the usual > IOMMU semantic that ENODEV means 'there is no IOMMU driver'. > Acked-by: Rafael J. Wysocki > Reviewed-by: Jerry Snitselaar > Tested-by: Hector Martin > Signed-off-by: Jason Gunthorpe > --- > drivers/acpi/scan.c | 29 +++++++++++++++++------------ > 1 file changed, 17 insertions(+), 12 deletions(-) > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 444a0b3c72f2d8..340ba720c72129 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -1562,8 +1562,7 @@ static inline const struct iommu_ops > *acpi_iommu_fwspec_ops(struct device *dev) > return fwspec ? fwspec->ops : NULL; > } > -static const struct iommu_ops *acpi_iommu_configure_id(struct device > *dev, > - const u32 *id_in) > +static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in) > { > int err; > const struct iommu_ops *ops; > @@ -1577,7 +1576,7 @@ static const struct iommu_ops > *acpi_iommu_configure_id(struct device *dev, > ops = acpi_iommu_fwspec_ops(dev); > if (ops) { > mutex_unlock(&iommu_probe_device_lock); > - return ops; > + return 0; > } > err = iort_iommu_configure_id(dev, id_in); > @@ -1594,12 +1593,14 @@ static const struct iommu_ops > *acpi_iommu_configure_id(struct device *dev, > /* Ignore all other errors apart from EPROBE_DEFER */ > if (err == -EPROBE_DEFER) { > - return ERR_PTR(err); > + return err; > } else if (err) { > dev_dbg(dev, "Adding to IOMMU failed: %d\n", err); > - return NULL; > + return -ENODEV; > } > - return acpi_iommu_fwspec_ops(dev); > + if (!acpi_iommu_fwspec_ops(dev)) > + return -ENODEV; > + return 0; > } > #else /* !CONFIG_IOMMU_API */ > @@ -1611,10 +1612,9 @@ int acpi_iommu_fwspec_init(struct device *dev, u32 > id, > return -ENODEV; > } > -static const struct iommu_ops *acpi_iommu_configure_id(struct device > *dev, > - const u32 *id_in) > +static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in) > { > - return NULL; > + return -ENODEV; > } > #endif /* !CONFIG_IOMMU_API */ > @@ -1628,7 +1628,7 @@ static const struct iommu_ops > *acpi_iommu_configure_id(struct device *dev, > int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr, > const u32 *input_id) > { > - const struct iommu_ops *iommu; > + int ret; > if (attr == DEV_DMA_NOT_SUPPORTED) { > set_dma_ops(dev, &dma_dummy_ops); > @@ -1637,10 +1637,15 @@ int acpi_dma_configure_id(struct device *dev, > enum dev_dma_attr attr, > acpi_arch_dma_setup(dev); > - iommu = acpi_iommu_configure_id(dev, input_id); > - if (PTR_ERR(iommu) == -EPROBE_DEFER) > + ret = acpi_iommu_configure_id(dev, input_id); > + if (ret == -EPROBE_DEFER) > return -EPROBE_DEFER; > + /* > + * Historically this routine doesn't fail driver probing due to errors > + * in acpi_iommu_configure_id() > + */ > + > arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT); > return 0; > -- > 2.42.0 Reviewed-by: Moritz Fischer Cheers, Moritz