From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 519EAC07E98 for ; Wed, 29 Nov 2023 06:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID:References: Mime-Version:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iHBqtUxqCE17m9akD+V9Tu6LeHr85ceyzNeNGZfjbJw=; b=fNa7yDzWXFzfRC +ijib0ItU/T1e7CrraEI2B1nPRgU3++3mYRDch6i39Vsd+YcuwZm7xAaRPbzkrEMc86b3+jOGr3dO nz6DF5l74VGXunAxaWwcwpz4tgc6Jq0UbJrBr2/HgMF6p232/hp4lU0u6yjtGswvfVVM0QJJcOfkK lvlobdl42lAnICNqFpvfi8tkFhbue38VQKUw/Xgy3v9268mQNR3iGuhEJ2qgj1wfi8NNAe/Q7TeP0 ndarLF/o6nHqd2hAgOo/8MBzN7vSYWCccerkZL/ee/EhEixmoeqRXP3X7NqkQkcpUhXrqziVZWtAx 96hBsOoqGap7XXe/p7kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8DhB-007Azj-39; Wed, 29 Nov 2023 06:05:13 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Dh2-007AvI-1E for linux-riscv@lists.infradead.org; Wed, 29 Nov 2023 06:05:13 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5ccf44b0423so85008087b3.0 for ; Tue, 28 Nov 2023 22:05:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701237903; x=1701842703; darn=lists.infradead.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=WO7CXB1mNGxZSEafQP2SArLxdW3co4lj0A5pbLIXeXc=; b=zuEm1iJ6DDOjQwGKcqfHnvJ4C5DkogXqzPVYPu43JnzwCRu3u2vBwnJC6aWd9xa+jf zd3d8PFXN+MQnKuDj+YezZOKbJvCIU3j4WRUyJ25lAmvSU8TlaPb5P14pJdX3rGRfg4W Z0oPaynoRcQGOCVT4gW5N5wH7QYkdUCZg4b+vHB99BgT2lpeNAW7+kaK/GZMnQiVOKLP oWB4sW7GiyKuqDsRXoVElm6cA8wfNwhLPT1HK4hLuBxBXmS5oBPGgI7bGYpid25YjFmw /7Px0tdrv1zjP6Ml6oOEM6g5ApMHAh5TXTP31F8r8sm5qpPA8T0IxMw87iMn0oKVI5+Q 3HSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701237903; x=1701842703; 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=WO7CXB1mNGxZSEafQP2SArLxdW3co4lj0A5pbLIXeXc=; b=s9ABgOBX4ZaGr8g28rbpXtp9q6y+wty+wi/Usn2QPriT6PsazVk3yNCHo/Q8UNvhna wVrJUxI/fskpldAH2RzJKeSaPWAwSOkHpJn7PUuSNJMaqKjNEFCpXyKjUcFp4KEjFYyP dnHQUjVbn7hoIMh0f7rMA75tW3l6mst9wPZGvUflWvDc+2TFbSEOF4NaR4yyzLJ/K2UN FBvGdViDHMeAVB86j78Tq/lW5dysuwQ4AR/Ns3R+OmrFjs/MFt/YlZrdAXs43Q0YPS73 beGlHZTrvwsgZ+X0ZPUBq48BkvfvTNkWk5k6bXyddfExbsnU3CYIjyi/7XcfI9GQ60Oo kpnw== X-Gm-Message-State: AOJu0YyB1+rd0Sy+BvUF3udGJrZrfHIRnACTkRwK/uZP3yPgGrdNJ7re 3i9/4DONtyhYH75b1ksToeeRwmewN9pB X-Google-Smtp-Source: AGHT+IHL7hgboFJ1jDI8fHK0ttAzMEfTsQjA7vmjwBnF03SxrfXdHuhYyFsTgeIfr3cTonrW5FaGXfJVhISd X-Received: from morats.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:d9e]) (user=moritzf job=sendgmr) by 2002:a05:690c:903:b0:59b:eb63:4beb with SMTP id cb3-20020a05690c090300b0059beb634bebmr584543ywb.7.1701237903050; Tue, 28 Nov 2023 22:05:03 -0800 (PST) Date: Wed, 29 Nov 2023 06:04:59 +0000 In-Reply-To: <3-v1-720585788a7d+811b-iommu_fwspec_p1_jgg@nvidia.com> Mime-Version: 1.0 References: <0-v1-720585788a7d+811b-iommu_fwspec_p1_jgg@nvidia.com> <3-v1-720585788a7d+811b-iommu_fwspec_p1_jgg@nvidia.com> Message-ID: <20231129060459.gcunam3msksainng@google.com> Subject: Re: [PATCH 03/10] iommu/of: Use -ENODEV consistently in of_iommu_configure() 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231128_220504_429547_61915C53 X-CRM114-Status: GOOD ( 28.99 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed"; DelSp="yes" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, Nov 28, 2023 at 08:47:59PM -0400, Jason Gunthorpe wrote: > Instead of returning 1 and trying to handle positive error codes just > stick to the convention of returning -ENODEV. Remove references to ops > from of_iommu_configure(), a NULL ops will already generate an error code. > There is no reason to check dev->bus, if err=0 at this point then the > called configure functions thought there was an iommu and we should try to > probe it. Remove it. > Reviewed-by: Jerry Snitselaar > Tested-by: Hector Martin > Signed-off-by: Jason Gunthorpe > --- > drivers/iommu/of_iommu.c | 49 ++++++++++++---------------------------- > 1 file changed, 15 insertions(+), 34 deletions(-) > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index c6510d7e7b241b..164317bfb8a81f 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -17,8 +17,6 @@ > #include > #include > -#define NO_IOMMU 1 > - > static int of_iommu_xlate(struct device *dev, > struct of_phandle_args *iommu_spec) > { > @@ -29,7 +27,7 @@ static int of_iommu_xlate(struct device *dev, > ops = iommu_ops_from_fwnode(fwnode); > if ((ops && !ops->of_xlate) || > !of_device_is_available(iommu_spec->np)) > - return NO_IOMMU; > + return -ENODEV; > ret = iommu_fwspec_init(dev, &iommu_spec->np->fwnode, ops); > if (ret) > @@ -61,7 +59,7 @@ static int of_iommu_configure_dev_id(struct device_node > *master_np, > "iommu-map-mask", &iommu_spec.np, > iommu_spec.args); > if (err) > - return err == -ENODEV ? NO_IOMMU : err; > + return err; > err = of_iommu_xlate(dev, &iommu_spec); > of_node_put(iommu_spec.np); > @@ -72,7 +70,7 @@ static int of_iommu_configure_dev(struct device_node > *master_np, > struct device *dev) > { > struct of_phandle_args iommu_spec; > - int err = NO_IOMMU, idx = 0; > + int err = -ENODEV, idx = 0; > while (!of_parse_phandle_with_args(master_np, "iommus", > "#iommu-cells", > @@ -117,9 +115,8 @@ static int of_iommu_configure_device(struct > device_node *master_np, > int of_iommu_configure(struct device *dev, struct device_node *master_np, > const u32 *id) > { > - const struct iommu_ops *ops = NULL; > struct iommu_fwspec *fwspec; > - int err = NO_IOMMU; > + int err; > if (!master_np) > return -ENODEV; > @@ -153,37 +150,21 @@ int of_iommu_configure(struct device *dev, struct > device_node *master_np, > } else { > err = of_iommu_configure_device(master_np, dev, id); > } > - > - /* > - * Two success conditions can be represented by non-negative err here: > - * >0 : there is no IOMMU, or one was unavailable for non-fatal reasons > - * 0 : we found an IOMMU, and dev->fwspec is initialised appropriately > - * <0 : any actual error > - */ > - if (!err) { > - /* The fwspec pointer changed, read it again */ > - fwspec = dev_iommu_fwspec_get(dev); > - ops = fwspec->ops; > - } > mutex_unlock(&iommu_probe_device_lock); > - /* > - * If we have reason to believe the IOMMU driver missed the initial > - * probe for dev, replay it to get things in order. > - */ > - if (!err && dev->bus) > - err = iommu_probe_device(dev); > - > - /* Ignore all other errors apart from EPROBE_DEFER */ > - if (err < 0) { > - if (err == -EPROBE_DEFER) > - return err; > - dev_dbg(dev, "Adding to IOMMU failed: %pe\n", ERR_PTR(err)); > + if (err == -ENODEV || err == -EPROBE_DEFER) > return err; > - } > - if (!ops) > - return -ENODEV; > + if (err) > + goto err_log; > + > + err = iommu_probe_device(dev); > + if (err) > + goto err_log; > return 0; > + > +err_log: > + dev_dbg(dev, "Adding to IOMMU failed: %pe\n", ERR_PTR(err)); > + return err; > } > static enum iommu_resv_type __maybe_unused > -- > 2.42.0 Reviewed-by: Moritz Fischer _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv