* [PATCH 01/10] iommu/arm-smmu: Drop if with an always false condition
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-28 13:42 ` Joerg Roedel
2023-03-28 14:10 ` Robin Murphy
2023-03-21 8:41 ` [PATCH 02/10] iommu/apple-dart: Convert to platform remove callback returning void Uwe Kleine-König
` (5 subsequent siblings)
6 siblings, 2 replies; 12+ 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
Cc: Robin Murphy, linux-arm-kernel, iommu, kernel
The remove and shutdown callback are only called after probe completed
successfully. In this case platform_set_drvdata() was called with a
non-NULL argument and so smmu is never NULL. Other functions in this
driver also don't check for smmu being non-NULL before using it.
Also note that returning an error code from a remove callback doesn't
result in the device staying bound. It's still removed and devm allocated
resources are freed (among others *smmu and the register mapping). So
after an early exit to iommu device stayed around and using it probably
oopses.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/iommu/arm/arm-smmu/arm-smmu.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 2ff7a72cf377..f4a36533ae47 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2195,9 +2195,6 @@ static void arm_smmu_device_shutdown(struct platform_device *pdev)
{
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
- if (!smmu)
- return;
-
if (!bitmap_empty(smmu->context_map, ARM_SMMU_MAX_CBS))
dev_notice(&pdev->dev, "disabling translation\n");
@@ -2218,9 +2215,6 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
{
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
- if (!smmu)
- return -ENODEV;
-
iommu_device_unregister(&smmu->iommu);
iommu_device_sysfs_remove(&smmu->iommu);
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 01/10] iommu/arm-smmu: Drop if with an always false condition
2023-03-21 8:41 ` [PATCH 01/10] iommu/arm-smmu: Drop if with an always false condition Uwe Kleine-König
@ 2023-03-28 13:42 ` Joerg Roedel
2023-03-28 14:10 ` Robin Murphy
1 sibling, 0 replies; 12+ messages in thread
From: Joerg Roedel @ 2023-03-28 13:42 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Will Deacon, Lu Baolu, Vladimir Oltean, Sai Prakash Ranjan,
Jon Nettleton, Robin Murphy, linux-arm-kernel, iommu, kernel
On Tue, Mar 21, 2023 at 09:41:16AM +0100, Uwe Kleine-König wrote:
> The remove and shutdown callback are only called after probe completed
> successfully. In this case platform_set_drvdata() was called with a
> non-NULL argument and so smmu is never NULL. Other functions in this
> driver also don't check for smmu being non-NULL before using it.
>
> Also note that returning an error code from a remove callback doesn't
> result in the device staying bound. It's still removed and devm allocated
> resources are freed (among others *smmu and the register mapping). So
> after an early exit to iommu device stayed around and using it probably
> oopses.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/iommu/arm/arm-smmu/arm-smmu.c | 6 ------
> 1 file changed, 6 deletions(-)
Need an ack or review by either Will or Robin on this patch.
Regards,
Joerg
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 01/10] iommu/arm-smmu: Drop if with an always false condition
2023-03-21 8:41 ` [PATCH 01/10] iommu/arm-smmu: Drop if with an always false condition Uwe Kleine-König
2023-03-28 13:42 ` Joerg Roedel
@ 2023-03-28 14:10 ` Robin Murphy
1 sibling, 0 replies; 12+ messages in thread
From: Robin Murphy @ 2023-03-28 14:10 UTC (permalink / raw)
To: Uwe Kleine-König, Will Deacon, Joerg Roedel, Lu Baolu,
Vladimir Oltean, Sai Prakash Ranjan, Jon Nettleton
Cc: linux-arm-kernel, iommu, kernel
On 21/03/2023 8:41 am, Uwe Kleine-König wrote:
> The remove and shutdown callback are only called after probe completed
> successfully. In this case platform_set_drvdata() was called with a
> non-NULL argument and so smmu is never NULL. Other functions in this
> driver also don't check for smmu being non-NULL before using it.
Indeed, it seems this impossible condition has been here since day 1;
shame on me for not paying more attention when Vladimir dutifully
refactored it :)
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Also note that returning an error code from a remove callback doesn't
> result in the device staying bound. It's still removed and devm allocated
> resources are freed (among others *smmu and the register mapping). So
> after an early exit to iommu device stayed around and using it probably
> oopses.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/iommu/arm/arm-smmu/arm-smmu.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 2ff7a72cf377..f4a36533ae47 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -2195,9 +2195,6 @@ static void arm_smmu_device_shutdown(struct platform_device *pdev)
> {
> struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
>
> - if (!smmu)
> - return;
> -
> if (!bitmap_empty(smmu->context_map, ARM_SMMU_MAX_CBS))
> dev_notice(&pdev->dev, "disabling translation\n");
>
> @@ -2218,9 +2215,6 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
> {
> struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
>
> - if (!smmu)
> - return -ENODEV;
> -
> iommu_device_unregister(&smmu->iommu);
> iommu_device_sysfs_remove(&smmu->iommu);
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 02/10] iommu/apple-dart: 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 01/10] iommu/arm-smmu: Drop if with an always false condition Uwe Kleine-König
@ 2023-03-21 8:41 ` Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 03/10] iommu/arm-smmu-v3: " Uwe Kleine-König
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2023-03-21 8:41 UTC (permalink / raw)
To: Hector Martin, Sven Peter, Joerg Roedel, Will Deacon
Cc: Alyssa Rosenzweig, Robin Murphy, asahi, linux-arm-kernel, iommu,
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/apple-dart.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index 06169d36eab8..8af64b57f048 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -1150,7 +1150,7 @@ static int apple_dart_probe(struct platform_device *pdev)
return ret;
}
-static int apple_dart_remove(struct platform_device *pdev)
+static void apple_dart_remove(struct platform_device *pdev)
{
struct apple_dart *dart = platform_get_drvdata(pdev);
@@ -1161,8 +1161,6 @@ static int apple_dart_remove(struct platform_device *pdev)
iommu_device_sysfs_remove(&dart->iommu);
clk_bulk_disable_unprepare(dart->num_clks, dart->clks);
-
- return 0;
}
static const struct apple_dart_hw apple_dart_hw_t8103 = {
@@ -1296,7 +1294,7 @@ static struct platform_driver apple_dart_driver = {
.pm = pm_sleep_ptr(&apple_dart_pm_ops),
},
.probe = apple_dart_probe,
- .remove = apple_dart_remove,
+ .remove_new = apple_dart_remove,
};
module_platform_driver(apple_dart_driver);
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 03/10] iommu/arm-smmu-v3: 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 01/10] iommu/arm-smmu: Drop if with an always false condition Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 02/10] iommu/apple-dart: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-03-21 8:41 ` Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 04/10] iommu/arm-smmu: " Uwe Kleine-König
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2023-03-21 8:41 UTC (permalink / raw)
To: Will Deacon, Joerg Roedel, Lu Baolu, Jason Gunthorpe,
Shameer Kolothum, Yicong Yang, Nicolin Chen
Cc: Robin Murphy, linux-arm-kernel, iommu, 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/arm/arm-smmu-v3/arm-smmu-v3.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index f2425b0f0cd6..d99e1a8dbe44 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3844,7 +3844,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
return 0;
}
-static int arm_smmu_device_remove(struct platform_device *pdev)
+static void arm_smmu_device_remove(struct platform_device *pdev)
{
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
@@ -3852,8 +3852,6 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
iommu_device_sysfs_remove(&smmu->iommu);
arm_smmu_device_disable(smmu);
iopf_queue_free(smmu->evtq.iopf);
-
- return 0;
}
static void arm_smmu_device_shutdown(struct platform_device *pdev)
@@ -3882,7 +3880,7 @@ static struct platform_driver arm_smmu_driver = {
.suppress_bind_attrs = true,
},
.probe = arm_smmu_device_probe,
- .remove = arm_smmu_device_remove,
+ .remove_new = arm_smmu_device_remove,
.shutdown = arm_smmu_device_shutdown,
};
module_driver(arm_smmu_driver, platform_driver_register,
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 04/10] iommu/arm-smmu: 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
` (2 preceding siblings ...)
2023-03-21 8:41 ` [PATCH 03/10] iommu/arm-smmu-v3: " Uwe Kleine-König
@ 2023-03-21 8:41 ` Uwe Kleine-König
2023-03-21 8:41 ` [PATCH 07/10] iommu/mtk: " Uwe Kleine-König
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2023-03-21 8:41 UTC (permalink / raw)
To: Will Deacon, Joerg Roedel, Rob Clark, Lu Baolu, Nicolin Chen,
Sai Prakash Ranjan, Vladimir Oltean, Jon Nettleton
Cc: Robin Murphy, linux-arm-kernel, iommu, kernel, linux-arm-msm
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/arm/arm-smmu/arm-smmu.c | 6 ++----
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 12 ++++--------
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index f4a36533ae47..b30a4bd7c79d 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2211,7 +2211,7 @@ static void arm_smmu_device_shutdown(struct platform_device *pdev)
clk_bulk_unprepare(smmu->num_clks, smmu->clks);
}
-static int arm_smmu_device_remove(struct platform_device *pdev)
+static void arm_smmu_device_remove(struct platform_device *pdev)
{
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
@@ -2219,8 +2219,6 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
iommu_device_sysfs_remove(&smmu->iommu);
arm_smmu_device_shutdown(pdev);
-
- return 0;
}
static int __maybe_unused arm_smmu_runtime_resume(struct device *dev)
@@ -2296,7 +2294,7 @@ static struct platform_driver arm_smmu_driver = {
.suppress_bind_attrs = true,
},
.probe = arm_smmu_device_probe,
- .remove = arm_smmu_device_remove,
+ .remove_new = arm_smmu_device_remove,
.shutdown = arm_smmu_device_shutdown,
};
module_platform_driver(arm_smmu_driver);
diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
index c8b70f476cd8..a503ed758ec3 100644
--- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
@@ -682,7 +682,7 @@ static int qcom_iommu_ctx_probe(struct platform_device *pdev)
return 0;
}
-static int qcom_iommu_ctx_remove(struct platform_device *pdev)
+static void qcom_iommu_ctx_remove(struct platform_device *pdev)
{
struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(pdev->dev.parent);
struct qcom_iommu_ctx *ctx = platform_get_drvdata(pdev);
@@ -690,8 +690,6 @@ static int qcom_iommu_ctx_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
qcom_iommu->ctxs[ctx->asid - 1] = NULL;
-
- return 0;
}
static const struct of_device_id ctx_of_match[] = {
@@ -706,7 +704,7 @@ static struct platform_driver qcom_iommu_ctx_driver = {
.of_match_table = ctx_of_match,
},
.probe = qcom_iommu_ctx_probe,
- .remove = qcom_iommu_ctx_remove,
+ .remove_new = qcom_iommu_ctx_remove,
};
static bool qcom_iommu_has_secure_context(struct qcom_iommu_dev *qcom_iommu)
@@ -824,7 +822,7 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
return ret;
}
-static int qcom_iommu_device_remove(struct platform_device *pdev)
+static void qcom_iommu_device_remove(struct platform_device *pdev)
{
struct qcom_iommu_dev *qcom_iommu = platform_get_drvdata(pdev);
@@ -832,8 +830,6 @@ static int qcom_iommu_device_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
iommu_device_sysfs_remove(&qcom_iommu->iommu);
iommu_device_unregister(&qcom_iommu->iommu);
-
- return 0;
}
static int __maybe_unused qcom_iommu_resume(struct device *dev)
@@ -870,7 +866,7 @@ static struct platform_driver qcom_iommu_driver = {
.pm = &qcom_iommu_pm_ops,
},
.probe = qcom_iommu_device_probe,
- .remove = qcom_iommu_device_remove,
+ .remove_new = qcom_iommu_device_remove,
};
static int __init qcom_iommu_init(void)
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 12+ 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
` (3 preceding siblings ...)
2023-03-21 8:41 ` [PATCH 04/10] iommu/arm-smmu: " 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
6 siblings, 1 reply; 12+ 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 12+ 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; 12+ 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>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 12+ 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
` (4 preceding siblings ...)
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
6 siblings, 1 reply; 12+ 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 12+ 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; 12+ 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>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 12+ 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
` (5 preceding siblings ...)
2023-03-21 8:41 ` [PATCH 08/10] iommu/mtk_iommu_v1: " Uwe Kleine-König
@ 2023-03-31 8:02 ` Joerg Roedel
6 siblings, 0 replies; 12+ 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.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 12+ messages in thread