* [PATCH] i2c: xiic: Make sure to disable clock on .remove()
@ 2022-10-19 20:28 Uwe Kleine-König
2022-12-01 11:42 ` Michal Simek
2022-12-07 20:05 ` Wolfram Sang
0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2022-10-19 20:28 UTC (permalink / raw)
To: Michal Simek; +Cc: linux-arm-kernel, linux-i2c, kernel
If for whatever reasons pm_runtime_resume_and_get() failed, .remove() is
exited early, the clock isn't freed and runtime PM state isn't reset.
The right thing to do however is to free all resources that don't need
HW access after a problem with runtime PM. Also issue a warning in that
case and return 0 to suppress a less helpful warning by the driver core.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/i2c/busses/i2c-xiic.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index b3fe6b2aa3ca..809d6eadae2d 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -858,11 +858,14 @@ static int xiic_i2c_remove(struct platform_device *pdev)
/* remove adapter & data */
i2c_del_adapter(&i2c->adap);
- ret = pm_runtime_resume_and_get(i2c->dev);
+ ret = pm_runtime_get_sync(i2c->dev);
+
if (ret < 0)
- return ret;
+ dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n",
+ ERR_PTR(ret));
+ else
+ xiic_deinit(i2c);
- xiic_deinit(i2c);
pm_runtime_put_sync(i2c->dev);
clk_disable_unprepare(i2c->clk);
pm_runtime_disable(&pdev->dev);
base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
--
2.37.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] 3+ messages in thread
* Re: [PATCH] i2c: xiic: Make sure to disable clock on .remove()
2022-10-19 20:28 [PATCH] i2c: xiic: Make sure to disable clock on .remove() Uwe Kleine-König
@ 2022-12-01 11:42 ` Michal Simek
2022-12-07 20:05 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2022-12-01 11:42 UTC (permalink / raw)
To: Uwe Kleine-König, Michal Simek
Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
kernel@pengutronix.de
On 10/19/22 22:28, Uwe Kleine-König wrote:
>
> If for whatever reasons pm_runtime_resume_and_get() failed, .remove() is
> exited early, the clock isn't freed and runtime PM state isn't reset.
>
> The right thing to do however is to free all resources that don't need
> HW access after a problem with runtime PM. Also issue a warning in that
> case and return 0 to suppress a less helpful warning by the driver core.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/i2c/busses/i2c-xiic.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
> index b3fe6b2aa3ca..809d6eadae2d 100644
> --- a/drivers/i2c/busses/i2c-xiic.c
> +++ b/drivers/i2c/busses/i2c-xiic.c
> @@ -858,11 +858,14 @@ static int xiic_i2c_remove(struct platform_device *pdev)
> /* remove adapter & data */
> i2c_del_adapter(&i2c->adap);
>
> - ret = pm_runtime_resume_and_get(i2c->dev);
> + ret = pm_runtime_get_sync(i2c->dev);
> +
> if (ret < 0)
> - return ret;
> + dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n",
> + ERR_PTR(ret));
> + else
> + xiic_deinit(i2c);
>
> - xiic_deinit(i2c);
> pm_runtime_put_sync(i2c->dev);
> clk_disable_unprepare(i2c->clk);
> pm_runtime_disable(&pdev->dev);
>
> base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
> --
> 2.37.2
>
Acked-by: Michal Simek <michal.simek@amd.com>
Thanks,
Michal
_______________________________________________
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] 3+ messages in thread
* Re: [PATCH] i2c: xiic: Make sure to disable clock on .remove()
2022-10-19 20:28 [PATCH] i2c: xiic: Make sure to disable clock on .remove() Uwe Kleine-König
2022-12-01 11:42 ` Michal Simek
@ 2022-12-07 20:05 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2022-12-07 20:05 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: Michal Simek, linux-arm-kernel, linux-i2c, kernel
[-- Attachment #1.1: Type: text/plain, Size: 553 bytes --]
On Wed, Oct 19, 2022 at 10:28:08PM +0200, Uwe Kleine-König wrote:
> If for whatever reasons pm_runtime_resume_and_get() failed, .remove() is
> exited early, the clock isn't freed and runtime PM state isn't reset.
>
> The right thing to do however is to free all resources that don't need
> HW access after a problem with runtime PM. Also issue a warning in that
> case and return 0 to suppress a less helpful warning by the driver core.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Applied to for-next, thanks!
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
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] 3+ messages in thread
end of thread, other threads:[~2022-12-07 20:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-19 20:28 [PATCH] i2c: xiic: Make sure to disable clock on .remove() Uwe Kleine-König
2022-12-01 11:42 ` Michal Simek
2022-12-07 20:05 ` Wolfram Sang
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).