* [PATCH v2] i2c: hix5hd2: Make sure clk is disabled in remove
@ 2023-06-08 22:55 Andi Shyti
2023-06-08 23:10 ` Andi Shyti
2023-06-23 10:10 ` Wolfram Sang
0 siblings, 2 replies; 5+ messages in thread
From: Andi Shyti @ 2023-06-08 22:55 UTC (permalink / raw)
To: Alexey Khoroshilov; +Cc: Wolfram Sang, Linux I2C, Andi Shyti
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
pm_runtime_set_suspended() does not lead to call of suspend callback,
so clk may be left undisabled in hix5hd2_i2c_remove().
By the way, the patch adds error handling for clk_prepare_enable().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
---
Hi,
Look what I fished from the far December 2017 :)
It looked better to respin it rather than replying to such an old
mail.
I haven't made any modification to the patch exept for a little
rebase conflict. Here's a full changelog, anyway.
Changelog
=========
v1 -> v2:
- Fished this out from the muddy pond.
- Added my SoB
- Fixed rebase conflict
Andi
drivers/i2c/busses/i2c-hix5hd2.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c
index 0e34cbaca22dc..ec775ffefa9fc 100644
--- a/drivers/i2c/busses/i2c-hix5hd2.c
+++ b/drivers/i2c/busses/i2c-hix5hd2.c
@@ -421,7 +421,11 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "cannot get clock\n");
return PTR_ERR(priv->clk);
}
- clk_prepare_enable(priv->clk);
+ ret = clk_prepare_enable(priv->clk);
+ if (ret) {
+ dev_err(&pdev->dev, "cannot enable clock\n");
+ return ret;
+ }
strscpy(priv->adap.name, "hix5hd2-i2c", sizeof(priv->adap.name));
priv->dev = &pdev->dev;
@@ -469,8 +473,10 @@ static int hix5hd2_i2c_remove(struct platform_device *pdev)
struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);
i2c_del_adapter(&priv->adap);
- pm_runtime_disable(priv->dev);
- pm_runtime_set_suspended(priv->dev);
+
+ /* Make sure priv->clk is disabled */
+ pm_runtime_force_suspend(priv->dev);
+
clk_disable_unprepare(priv->clk);
return 0;
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] i2c: hix5hd2: Make sure clk is disabled in remove
2023-06-08 22:55 [PATCH v2] i2c: hix5hd2: Make sure clk is disabled in remove Andi Shyti
@ 2023-06-08 23:10 ` Andi Shyti
2023-06-08 23:31 ` Alexey Khoroshilov
2023-06-23 10:10 ` Wolfram Sang
1 sibling, 1 reply; 5+ messages in thread
From: Andi Shyti @ 2023-06-08 23:10 UTC (permalink / raw)
To: Alexey Khoroshilov; +Cc: Wolfram Sang, Linux I2C
Hi Alexey,
are you still around? Your patch looks good, just two things...
On Fri, Jun 09, 2023 at 12:55:13AM +0200, Andi Shyti wrote:
> From: Alexey Khoroshilov <khoroshilov@ispras.ru>
>
> pm_runtime_set_suspended() does not lead to call of suspend callback,
> so clk may be left undisabled in hix5hd2_i2c_remove().
>
> By the way, the patch adds error handling for clk_prepare_enable().
could you please put this in a separate patch?
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
if you're taking this, feel free to drop my SoB...
> ---
> Hi,
>
> Look what I fished from the far December 2017 :)
>
> It looked better to respin it rather than replying to such an old
> mail.
>
> I haven't made any modification to the patch exept for a little
> rebase conflict. Here's a full changelog, anyway.
>
> Changelog
> =========
> v1 -> v2:
> - Fished this out from the muddy pond.
> - Added my SoB
> - Fixed rebase conflict
... but please keep the changelog.
> Andi
>
> drivers/i2c/busses/i2c-hix5hd2.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c
> index 0e34cbaca22dc..ec775ffefa9fc 100644
> --- a/drivers/i2c/busses/i2c-hix5hd2.c
> +++ b/drivers/i2c/busses/i2c-hix5hd2.c
> @@ -421,7 +421,11 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
> dev_err(&pdev->dev, "cannot get clock\n");
> return PTR_ERR(priv->clk);
> }
> - clk_prepare_enable(priv->clk);
> + ret = clk_prepare_enable(priv->clk);
please use devm_clk_get_enabled();
Thanks,
Andi
> + if (ret) {
> + dev_err(&pdev->dev, "cannot enable clock\n");
> + return ret;
> + }
>
> strscpy(priv->adap.name, "hix5hd2-i2c", sizeof(priv->adap.name));
> priv->dev = &pdev->dev;
> @@ -469,8 +473,10 @@ static int hix5hd2_i2c_remove(struct platform_device *pdev)
> struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);
>
> i2c_del_adapter(&priv->adap);
> - pm_runtime_disable(priv->dev);
> - pm_runtime_set_suspended(priv->dev);
> +
> + /* Make sure priv->clk is disabled */
> + pm_runtime_force_suspend(priv->dev);
> +
> clk_disable_unprepare(priv->clk);
>
> return 0;
> --
> 2.40.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] i2c: hix5hd2: Make sure clk is disabled in remove
2023-06-08 23:10 ` Andi Shyti
@ 2023-06-08 23:31 ` Alexey Khoroshilov
0 siblings, 0 replies; 5+ messages in thread
From: Alexey Khoroshilov @ 2023-06-08 23:31 UTC (permalink / raw)
To: Andi Shyti; +Cc: Wolfram Sang, Linux I2C
Hi Andi,
On 09.06.2023 02:10, Andi Shyti wrote:
> Hi Alexey,
>
> are you still around? Your patch looks good, just two things...
>
> On Fri, Jun 09, 2023 at 12:55:13AM +0200, Andi Shyti wrote:
>> From: Alexey Khoroshilov <khoroshilov@ispras.ru>
>>
>> pm_runtime_set_suspended() does not lead to call of suspend callback,
>> so clk may be left undisabled in hix5hd2_i2c_remove().
>>
>> By the way, the patch adds error handling for clk_prepare_enable().
>
> could you please put this in a separate patch?
Sure I can do that, thank you for catching it up!
--
Alexey
>
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
>
> if you're taking this, feel free to drop my SoB...
>
>> ---
>> Hi,
>>
>> Look what I fished from the far December 2017 :)
>>
>> It looked better to respin it rather than replying to such an old
>> mail.
>>
>> I haven't made any modification to the patch exept for a little
>> rebase conflict. Here's a full changelog, anyway.
>>
>> Changelog
>> =========
>> v1 -> v2:
>> - Fished this out from the muddy pond.
>> - Added my SoB
>> - Fixed rebase conflict
>
> ... but please keep the changelog.
>
>> Andi
>>
>> drivers/i2c/busses/i2c-hix5hd2.c | 12 +++++++++---
>> 1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c
>> index 0e34cbaca22dc..ec775ffefa9fc 100644
>> --- a/drivers/i2c/busses/i2c-hix5hd2.c
>> +++ b/drivers/i2c/busses/i2c-hix5hd2.c
>> @@ -421,7 +421,11 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
>> dev_err(&pdev->dev, "cannot get clock\n");
>> return PTR_ERR(priv->clk);
>> }
>> - clk_prepare_enable(priv->clk);
>> + ret = clk_prepare_enable(priv->clk);
>
> please use devm_clk_get_enabled();
>
> Thanks,
> Andi
>
>> + if (ret) {
>> + dev_err(&pdev->dev, "cannot enable clock\n");
>> + return ret;
>> + }
>>
>> strscpy(priv->adap.name, "hix5hd2-i2c", sizeof(priv->adap.name));
>> priv->dev = &pdev->dev;
>> @@ -469,8 +473,10 @@ static int hix5hd2_i2c_remove(struct platform_device *pdev)
>> struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);
>>
>> i2c_del_adapter(&priv->adap);
>> - pm_runtime_disable(priv->dev);
>> - pm_runtime_set_suspended(priv->dev);
>> +
>> + /* Make sure priv->clk is disabled */
>> + pm_runtime_force_suspend(priv->dev);
>> +
>> clk_disable_unprepare(priv->clk);
>>
>> return 0;
>> --
>> 2.40.1
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] i2c: hix5hd2: Make sure clk is disabled in remove
2023-06-08 22:55 [PATCH v2] i2c: hix5hd2: Make sure clk is disabled in remove Andi Shyti
2023-06-08 23:10 ` Andi Shyti
@ 2023-06-23 10:10 ` Wolfram Sang
2023-06-23 11:38 ` Andi Shyti
1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2023-06-23 10:10 UTC (permalink / raw)
To: Andi Shyti; +Cc: Alexey Khoroshilov, Linux I2C
[-- Attachment #1: Type: text/plain, Size: 643 bytes --]
On Fri, Jun 09, 2023 at 12:55:13AM +0200, Andi Shyti wrote:
> From: Alexey Khoroshilov <khoroshilov@ispras.ru>
>
> pm_runtime_set_suspended() does not lead to call of suspend callback,
> so clk may be left undisabled in hix5hd2_i2c_remove().
>
> By the way, the patch adds error handling for clk_prepare_enable().
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
I have now applied "[PATCH 05/15] i2c: busses: hix5hd2: Use
devm_clk_get_enabled()". Can this patch then be dropped entirely?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] i2c: hix5hd2: Make sure clk is disabled in remove
2023-06-23 10:10 ` Wolfram Sang
@ 2023-06-23 11:38 ` Andi Shyti
0 siblings, 0 replies; 5+ messages in thread
From: Andi Shyti @ 2023-06-23 11:38 UTC (permalink / raw)
To: Wolfram Sang, Alexey Khoroshilov, Linux I2C
Hi Wolfram,
On Fri, Jun 23, 2023 at 12:10:07PM +0200, Wolfram Sang wrote:
> On Fri, Jun 09, 2023 at 12:55:13AM +0200, Andi Shyti wrote:
> > From: Alexey Khoroshilov <khoroshilov@ispras.ru>
> >
> > pm_runtime_set_suspended() does not lead to call of suspend callback,
> > so clk may be left undisabled in hix5hd2_i2c_remove().
> >
> > By the way, the patch adds error handling for clk_prepare_enable().
> >
> > Found by Linux Driver Verification project (linuxtesting.org).
> >
> > Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> > Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
>
> I have now applied "[PATCH 05/15] i2c: busses: hix5hd2: Use
> devm_clk_get_enabled()". Can this patch then be dropped entirely?
yes, this patch can be dropped. When I resent this I didn't plan
that refactoring.
Thanks,
Andi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-23 11:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-08 22:55 [PATCH v2] i2c: hix5hd2: Make sure clk is disabled in remove Andi Shyti
2023-06-08 23:10 ` Andi Shyti
2023-06-08 23:31 ` Alexey Khoroshilov
2023-06-23 10:10 ` Wolfram Sang
2023-06-23 11:38 ` Andi Shyti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox