From: Jason Gunthorpe <jgg@nvidia.com>
To: acpica-devel@lists.linuxfoundation.org,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Albert Ou <aou@eecs.berkeley.edu>,
asahi@lists.linux.dev, Lu Baolu <baolu.lu@linux.intel.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Dexuan Cui <decui@microsoft.com>,
devicetree@vger.kernel.org, David Woodhouse <dwmw2@infradead.org>,
Frank Rowand <frowand.list@gmail.com>,
Hanjun Guo <guohanjun@huawei.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Christoph Hellwig <hch@lst.de>,
iommu@lists.linux.dev,
Jean-Philippe Brucker <jean-philippe@linaro.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
Joerg Roedel <joro@8bytes.org>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Len Brown <lenb@kernel.org>,
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 <linux@armlinux.org.uk>,
Lorenzo Pieralisi <lpieralisi@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Hector Martin <marcan@marcan.st>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Robert Moore <robert.moore@intel.com>,
Rob Herring <robh+dt@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Sven Peter <sven@svenpeter.dev>,
Thierry Reding <thierry.reding@gmail.com>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Krishna Reddy <vdumpa@nvidia.com>,
Vineet Gupta <vgupta@kernel.org>,
virtualization@lists.linux-foundation.org,
Wei Liu <wei.liu@kernel.org>, Will Deacon <will@kernel.org>
Cc: Zhenhua Huang <quic_zhenhuah@quicinc.com>
Subject: [PATCH RFC 14/17] iommu: Remove pointless iommu_fwspec_free()
Date: Fri, 3 Nov 2023 13:44:59 -0300 [thread overview]
Message-ID: <14-v1-5f734af130a3+34f-iommu_fwspec_jgg@nvidia.com> (raw)
In-Reply-To: <0-v1-5f734af130a3+34f-iommu_fwspec_jgg@nvidia.com>
These days the core code will free the fwspec if probe fails, no reason
for any driver to call this on a probe failure path.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/arm/arm-smmu/arm-smmu.c | 14 +++++---------
drivers/iommu/tegra-smmu.c | 1 -
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index d6d1a2a55cc069..854efcb1b84ddf 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -1348,6 +1348,8 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
if (using_legacy_binding) {
ret = arm_smmu_register_legacy_master(dev, &smmu);
+ if (ret)
+ return ERR_PTR(ret);
/*
* If dev->iommu_fwspec is initally NULL, arm_smmu_register_legacy_master()
@@ -1355,15 +1357,12 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
* later use.
*/
fwspec = dev_iommu_fwspec_get(dev);
- if (ret)
- goto out_free;
} else if (fwspec && fwspec->ops == &arm_smmu_ops) {
smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode);
} else {
return ERR_PTR(-ENODEV);
}
- ret = -EINVAL;
for (i = 0; i < fwspec->num_ids; i++) {
u16 sid = FIELD_GET(ARM_SMMU_SMR_ID, fwspec->ids[i]);
u16 mask = FIELD_GET(ARM_SMMU_SMR_MASK, fwspec->ids[i]);
@@ -1371,20 +1370,19 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
if (sid & ~smmu->streamid_mask) {
dev_err(dev, "stream ID 0x%x out of range for SMMU (0x%x)\n",
sid, smmu->streamid_mask);
- goto out_free;
+ return ERR_PTR(-EINVAL);
}
if (mask & ~smmu->smr_mask_mask) {
dev_err(dev, "SMR mask 0x%x out of range for SMMU (0x%x)\n",
mask, smmu->smr_mask_mask);
- goto out_free;
+ return ERR_PTR(-EINVAL);
}
}
- ret = -ENOMEM;
cfg = kzalloc(offsetof(struct arm_smmu_master_cfg, smendx[i]),
GFP_KERNEL);
if (!cfg)
- goto out_free;
+ return ERR_PTR(-ENOMEM);
cfg->smmu = smmu;
dev_iommu_priv_set(dev, cfg);
@@ -1408,8 +1406,6 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
out_cfg_free:
kfree(cfg);
-out_free:
- iommu_fwspec_free(dev);
return ERR_PTR(ret);
}
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 310871728ab4b6..e3101aa2f35689 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -844,7 +844,6 @@ static int tegra_smmu_configure(struct tegra_smmu *smmu, struct device *dev,
err = ops->of_xlate(dev, args);
if (err < 0) {
dev_err(dev, "failed to parse SW group ID: %d\n", err);
- iommu_fwspec_free(dev);
return err;
}
--
2.42.0
next prev parent reply other threads:[~2023-11-03 16:45 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 16:44 [PATCH RFC 00/17] Solve iommu probe races around iommu_fwspec Jason Gunthorpe
2023-11-03 16:44 ` [PATCH RFC 01/17] iommu: Remove struct iommu_ops *iommu from arch_setup_dma_ops() Jason Gunthorpe
2023-11-03 20:04 ` Jerry Snitselaar
2023-11-06 7:17 ` Christoph Hellwig
2023-11-08 8:01 ` Baolu Lu
2023-11-08 16:18 ` Rob Herring
2023-11-12 17:35 ` Moritz Fischer
2023-11-03 16:44 ` [PATCH RFC 02/17] of: Do not return struct iommu_ops from of_iommu_configure() Jason Gunthorpe
2023-11-03 21:42 ` Jerry Snitselaar
2023-11-03 21:47 ` Jerry Snitselaar
2023-11-05 13:31 ` Jason Gunthorpe
2023-11-08 16:17 ` Rob Herring
2023-11-03 16:44 ` [PATCH RFC 03/17] of: Use -ENODEV consistently in of_iommu_configure() Jason Gunthorpe
2023-11-03 22:03 ` Jerry Snitselaar
2023-11-05 13:26 ` Jason Gunthorpe
2023-11-08 16:11 ` Rob Herring
2023-11-03 16:44 ` [PATCH RFC 04/17] acpi: Do not return struct iommu_ops from acpi_iommu_configure_id() Jason Gunthorpe
2023-11-04 0:48 ` Jerry Snitselaar
2023-11-05 13:24 ` Jason Gunthorpe
2023-11-05 17:55 ` Jerry Snitselaar
2023-11-06 14:32 ` Rafael J. Wysocki
2023-11-03 16:44 ` [PATCH RFC 05/17] iommu: Make iommu_fwspec->ids a distinct allocation Jason Gunthorpe
2023-11-13 20:10 ` Jerry Snitselaar
2023-11-03 16:44 ` [PATCH RFC 06/17] iommu: Add iommu_fwspec_alloc/dealloc() Jason Gunthorpe
2023-11-13 20:11 ` Jerry Snitselaar
2023-11-03 16:44 ` [PATCH RFC 07/17] iommu: Add iommu_probe_device_fwspec() Jason Gunthorpe
2023-11-13 20:11 ` Jerry Snitselaar
2023-11-03 16:44 ` [PATCH RFC 08/17] of: Do not use dev->iommu within of_iommu_configure() Jason Gunthorpe
2023-11-13 20:11 ` Jerry Snitselaar
2023-11-03 16:44 ` [PATCH RFC 09/17] iommu: Add iommu_fwspec_append_ids() Jason Gunthorpe
2023-11-13 20:12 ` Jerry Snitselaar
2023-11-03 16:44 ` [PATCH RFC 10/17] acpi: Do not use dev->iommu within acpi_iommu_configure() Jason Gunthorpe
2023-11-06 14:36 ` Rafael J. Wysocki
2023-11-12 17:44 ` Moritz Fischer
2023-11-13 22:37 ` Jason Gunthorpe
2023-11-13 20:13 ` Jerry Snitselaar
2023-11-03 16:44 ` [PATCH RFC 11/17] iommu: Hold iommu_probe_device_lock while calling ops->of_xlate Jason Gunthorpe
2023-11-13 20:14 ` Jerry Snitselaar
2023-11-03 16:44 ` [PATCH RFC 12/17] iommu: Make iommu_ops_from_fwnode() static Jason Gunthorpe
2023-11-08 18:12 ` André Draszik
2023-11-13 20:02 ` Jerry Snitselaar
2023-11-03 16:44 ` [PATCH RFC 13/17] iommu: Remove dev_iommu_fwspec_set() Jason Gunthorpe
2023-11-13 20:06 ` Jerry Snitselaar
2023-11-03 16:44 ` Jason Gunthorpe [this message]
2023-11-13 20:18 ` [PATCH RFC 14/17] iommu: Remove pointless iommu_fwspec_free() Jerry Snitselaar
2023-11-03 16:45 ` [PATCH RFC 15/17] iommu: Add ops->of_xlate_fwspec() Jason Gunthorpe
2023-11-13 20:23 ` Jerry Snitselaar
2023-11-03 16:45 ` [PATCH RFC 16/17] iommu: Mark dev_iommu_get() with lockdep Jason Gunthorpe
2023-11-13 20:25 ` Jerry Snitselaar
2023-11-03 16:45 ` [PATCH RFC 17/17] iommu: Mark dev_iommu_priv_set() with a lockdep Jason Gunthorpe
2023-11-08 8:18 ` Baolu Lu
2023-11-13 20:35 ` Jerry Snitselaar
2023-11-08 18:34 ` [PATCH RFC 00/17] Solve iommu probe races around iommu_fwspec André Draszik
2023-11-08 19:22 ` Jason Gunthorpe
2023-11-14 4:56 ` Zhenhua Huang
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=14-v1-5f734af130a3+34f-iommu_fwspec_jgg@nvidia.com \
--to=jgg@nvidia.com \
--cc=acpica-devel@lists.linuxfoundation.org \
--cc=alyssa@rosenzweig.io \
--cc=aou@eecs.berkeley.edu \
--cc=asahi@lists.linux.dev \
--cc=baolu.lu@linux.intel.com \
--cc=catalin.marinas@arm.com \
--cc=decui@microsoft.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=frowand.list@gmail.com \
--cc=guohanjun@huawei.com \
--cc=haiyangz@microsoft.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=kys@microsoft.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lpieralisi@kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=marcan@marcan.st \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=quic_zhenhuah@quicinc.com \
--cc=rafael@kernel.org \
--cc=robert.moore@intel.com \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sudeep.holla@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=sven@svenpeter.dev \
--cc=thierry.reding@gmail.com \
--cc=tsbogend@alpha.franken.de \
--cc=vdumpa@nvidia.com \
--cc=vgupta@kernel.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=wei.liu@kernel.org \
--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).