* [PATCH 00/10] iommu: Convert to platform remove callback returning void
@ 2023-03-21 8:41 Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 07/10] iommu/mtk: " Uwe Kleine-König
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2023-03-21 8:41 UTC (permalink / raw)
To: Will Deacon, Joerg Roedel, Lu Baolu, Vladimir Oltean,
Sai Prakash Ranjan, Jon Nettleton, Hector Martin, Sven Peter,
Jason Gunthorpe, Shameer Kolothum, Yicong Yang, Nicolin Chen,
Rob Clark, Andy Gross, Bjorn Andersson, Yong Wu, Matthias Brugger,
Orson Zhai, Baolin Wang, Chunyan Zhang
Cc: Robin Murphy, linux-arm-kernel, iommu, kernel, Alyssa Rosenzweig,
asahi, linux-arm-msm, Konrad Dybcio, AngeloGioacchino Del Regno,
linux-mediatek
Hello,
this series adapts the platform drivers below drivers/iommu to use the
.remove_new() callback. Compared to the traditional .remove() callback
.remove_new() returns no value. This is a good thing because the driver core
doesn't (and cannot) cope for errors during remove. The only effect of a
non-zero return value in .remove() is that the driver core emits a warning. The
device is removed anyhow and an early return from .remove() usually yields a
resource leak.
By changing the remove callback to return void driver authors cannot
reasonably assume any more that there is some kind of cleanup later.
After the first patch all drivers return zero unconditionally in their
.remove() callback, then the remaining patches convert to .remove_new()
without side effects.
There is only a single interdependency (namely patch #4 depends on #1).
If there are concerns for individual patches[1], please still apply the
others. Then I'd only care for the actual change requests and don't need
to resend the other unchanged patches at a later point in time.
Thanks
Uwe
[1] I don't expect something more tragic than "You picked the wrong
subject prefix" or similar.
Uwe Kleine-König (10):
iommu/arm-smmu: Drop if with an always false condition
iommu/apple-dart: Convert to platform remove callback returning void
iommu/arm-smmu-v3: Convert to platform remove callback returning void
iommu/arm-smmu: Convert to platform remove callback returning void
iommu/ipmmu-vmsa: Convert to platform remove callback returning void
iommu/msm: Convert to platform remove callback returning void
iommu/mtk: Convert to platform remove callback returning void
iommu/mtk_iommu_v1: Convert to platform remove callback returning void
iommu/omap: Convert to platform remove callback returning void
iommu/sprd: Convert to platform remove callback returning void
drivers/iommu/apple-dart.c | 6 ++----
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 ++----
drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++----------
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 12 ++++--------
drivers/iommu/ipmmu-vmsa.c | 6 ++----
drivers/iommu/msm_iommu.c | 5 ++---
drivers/iommu/mtk_iommu.c | 5 ++---
drivers/iommu/mtk_iommu_v1.c | 5 ++---
drivers/iommu/omap-iommu.c | 5 ++---
drivers/iommu/sprd-iommu.c | 6 ++----
10 files changed, 22 insertions(+), 46 deletions(-)
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 07/10] iommu/mtk: Convert to platform remove callback returning void
2023-03-21 8:41 [PATCH 00/10] iommu: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-03-21 8:41 ` Uwe Kleine-König
2023-03-21 9:45 ` AngeloGioacchino Del Regno
2023-03-21 8:41 ` [PATCH 08/10] iommu/mtk_iommu_v1: " Uwe Kleine-König
2023-03-31 8:02 ` [PATCH 00/10] iommu: " Joerg Roedel
2 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2023-03-21 8:41 UTC (permalink / raw)
To: Yong Wu, Joerg Roedel, Will Deacon, Matthias Brugger
Cc: Robin Murphy, AngeloGioacchino Del Regno, iommu, linux-mediatek,
kernel, linux-arm-kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/iommu/mtk_iommu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index d5a4955910ff..bcc7ccdb2d6e 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -1316,7 +1316,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
return ret;
}
-static int mtk_iommu_remove(struct platform_device *pdev)
+static void mtk_iommu_remove(struct platform_device *pdev)
{
struct mtk_iommu_data *data = platform_get_drvdata(pdev);
struct mtk_iommu_bank_data *bank;
@@ -1338,7 +1338,6 @@ static int mtk_iommu_remove(struct platform_device *pdev)
continue;
devm_free_irq(&pdev->dev, bank->irq, bank);
}
- return 0;
}
static int __maybe_unused mtk_iommu_runtime_suspend(struct device *dev)
@@ -1595,7 +1594,7 @@ static const struct of_device_id mtk_iommu_of_ids[] = {
static struct platform_driver mtk_iommu_driver = {
.probe = mtk_iommu_probe,
- .remove = mtk_iommu_remove,
+ .remove_new = mtk_iommu_remove,
.driver = {
.name = "mtk-iommu",
.of_match_table = mtk_iommu_of_ids,
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 08/10] iommu/mtk_iommu_v1: Convert to platform remove callback returning void
2023-03-21 8:41 [PATCH 00/10] iommu: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 07/10] iommu/mtk: " Uwe Kleine-König
@ 2023-03-21 8:41 ` Uwe Kleine-König
2023-03-21 9:45 ` AngeloGioacchino Del Regno
2023-03-31 8:02 ` [PATCH 00/10] iommu: " Joerg Roedel
2 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2023-03-21 8:41 UTC (permalink / raw)
To: Yong Wu, Joerg Roedel, Will Deacon, Matthias Brugger
Cc: Robin Murphy, AngeloGioacchino Del Regno, iommu, linux-mediatek,
kernel, linux-arm-kernel
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/iommu/mtk_iommu_v1.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index 43e4c8f89e23..8a0a5e5d049f 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -703,7 +703,7 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev)
return ret;
}
-static int mtk_iommu_v1_remove(struct platform_device *pdev)
+static void mtk_iommu_v1_remove(struct platform_device *pdev)
{
struct mtk_iommu_v1_data *data = platform_get_drvdata(pdev);
@@ -713,7 +713,6 @@ static int mtk_iommu_v1_remove(struct platform_device *pdev)
clk_disable_unprepare(data->bclk);
devm_free_irq(&pdev->dev, data->irq, data);
component_master_del(&pdev->dev, &mtk_iommu_v1_com_ops);
- return 0;
}
static int __maybe_unused mtk_iommu_v1_suspend(struct device *dev)
@@ -752,7 +751,7 @@ static const struct dev_pm_ops mtk_iommu_v1_pm_ops = {
static struct platform_driver mtk_iommu_v1_driver = {
.probe = mtk_iommu_v1_probe,
- .remove = mtk_iommu_v1_remove,
+ .remove_new = mtk_iommu_v1_remove,
.driver = {
.name = "mtk-iommu-v1",
.of_match_table = mtk_iommu_v1_of_ids,
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 08/10] iommu/mtk_iommu_v1: Convert to platform remove callback returning void
2023-03-21 8:41 ` [PATCH 08/10] iommu/mtk_iommu_v1: " Uwe Kleine-König
@ 2023-03-21 9:45 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-03-21 9:45 UTC (permalink / raw)
To: Uwe Kleine-König, Yong Wu, Joerg Roedel, Will Deacon,
Matthias Brugger
Cc: Robin Murphy, iommu, linux-mediatek, kernel, linux-arm-kernel
Il 21/03/23 09:41, Uwe Kleine-König ha scritto:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
>
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 07/10] iommu/mtk: Convert to platform remove callback returning void
2023-03-21 8:41 ` [PATCH 07/10] iommu/mtk: " Uwe Kleine-König
@ 2023-03-21 9:45 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-03-21 9:45 UTC (permalink / raw)
To: Uwe Kleine-König, Yong Wu, Joerg Roedel, Will Deacon,
Matthias Brugger
Cc: Robin Murphy, iommu, linux-mediatek, kernel, linux-arm-kernel
Il 21/03/23 09:41, Uwe Kleine-König ha scritto:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is (mostly) ignored
> and this typically results in resource leaks. To improve here there is a
> quest to make the remove callback return void. In the first step of this
> quest all drivers are converted to .remove_new() which already returns
> void.
>
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 00/10] iommu: Convert to platform remove callback returning void
2023-03-21 8:41 [PATCH 00/10] iommu: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 07/10] iommu/mtk: " Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 08/10] iommu/mtk_iommu_v1: " Uwe Kleine-König
@ 2023-03-31 8:02 ` Joerg Roedel
2 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2023-03-31 8:02 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Will Deacon, Lu Baolu, Vladimir Oltean, Sai Prakash Ranjan,
Jon Nettleton, Hector Martin, Sven Peter, Jason Gunthorpe,
Shameer Kolothum, Yicong Yang, Nicolin Chen, Rob Clark,
Andy Gross, Bjorn Andersson, Yong Wu, Matthias Brugger,
Orson Zhai, Baolin Wang, Chunyan Zhang, Robin Murphy,
linux-arm-kernel, iommu, kernel, Alyssa Rosenzweig, asahi,
linux-arm-msm, Konrad Dybcio, AngeloGioacchino Del Regno,
linux-mediatek
On Tue, Mar 21, 2023 at 09:41:15AM +0100, Uwe Kleine-König wrote:
> Uwe Kleine-König (10):
> iommu/arm-smmu: Drop if with an always false condition
> iommu/apple-dart: Convert to platform remove callback returning void
> iommu/arm-smmu-v3: Convert to platform remove callback returning void
> iommu/arm-smmu: Convert to platform remove callback returning void
> iommu/ipmmu-vmsa: Convert to platform remove callback returning void
> iommu/msm: Convert to platform remove callback returning void
> iommu/mtk: Convert to platform remove callback returning void
> iommu/mtk_iommu_v1: Convert to platform remove callback returning void
> iommu/omap: Convert to platform remove callback returning void
> iommu/sprd: Convert to platform remove callback returning void
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-03-31 8:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-21 8:41 [PATCH 00/10] iommu: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 07/10] iommu/mtk: " Uwe Kleine-König
2023-03-21 9:45 ` AngeloGioacchino Del Regno
2023-03-21 8:41 ` [PATCH 08/10] iommu/mtk_iommu_v1: " Uwe Kleine-König
2023-03-21 9:45 ` AngeloGioacchino Del Regno
2023-03-31 8:02 ` [PATCH 00/10] iommu: " Joerg Roedel
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).