linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: core: Drop dev_pm_domain_detach() call
@ 2025-08-27 10:10 Claudiu
  2025-08-27 11:35 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Claudiu @ 2025-08-27 10:10 UTC (permalink / raw)
  To: wsa+renesas, ulf.hansson, rafael
  Cc: claudiu.beznea, linux-i2c, linux-kernel, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Starting with commit f99508074e78 ("PM: domains: Detach on
device_unbind_cleanup()"), there is no longer a need to call
dev_pm_domain_detach() in the bus remove function. The
device_unbind_cleanup() function now handles this to avoid
invoking devres cleanup handlers while the PM domain is
powered off, which could otherwise lead to failures as
described in the above-mentioned commit.

Drop the explicit dev_pm_domain_detach() call and rely instead
on the flags passed to dev_pm_domain_attach() to power off the
domain.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
 drivers/i2c/i2c-core-base.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index ecca8c006b02..ae7e9c8b65a6 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -573,7 +573,8 @@ static int i2c_device_probe(struct device *dev)
 		goto err_clear_wakeup_irq;
 
 	do_power_on = !i2c_acpi_waive_d0_probe(dev);
-	status = dev_pm_domain_attach(&client->dev, do_power_on ? PD_FLAG_ATTACH_POWER_ON : 0);
+	status = dev_pm_domain_attach(&client->dev, PD_FLAG_DETACH_POWER_OFF |
+				      (do_power_on ? PD_FLAG_ATTACH_POWER_ON : 0));
 	if (status)
 		goto err_clear_wakeup_irq;
 
@@ -581,7 +582,7 @@ static int i2c_device_probe(struct device *dev)
 						    GFP_KERNEL);
 	if (!client->devres_group_id) {
 		status = -ENOMEM;
-		goto err_detach_pm_domain;
+		goto err_clear_wakeup_irq;
 	}
 
 	client->debugfs = debugfs_create_dir(dev_name(&client->dev),
@@ -608,8 +609,6 @@ static int i2c_device_probe(struct device *dev)
 err_release_driver_resources:
 	debugfs_remove_recursive(client->debugfs);
 	devres_release_group(&client->dev, client->devres_group_id);
-err_detach_pm_domain:
-	dev_pm_domain_detach(&client->dev, do_power_on);
 err_clear_wakeup_irq:
 	dev_pm_clear_wake_irq(&client->dev);
 	device_init_wakeup(&client->dev, false);
@@ -636,8 +635,6 @@ static void i2c_device_remove(struct device *dev)
 
 	devres_release_group(&client->dev, client->devres_group_id);
 
-	dev_pm_domain_detach(&client->dev, true);
-
 	dev_pm_clear_wake_irq(&client->dev);
 	device_init_wakeup(&client->dev, false);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i2c: core: Drop dev_pm_domain_detach() call
  2025-08-27 10:10 [PATCH] i2c: core: Drop dev_pm_domain_detach() call Claudiu
@ 2025-08-27 11:35 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2025-08-27 11:35 UTC (permalink / raw)
  To: Claudiu; +Cc: wsa+renesas, rafael, linux-i2c, linux-kernel, Claudiu Beznea

On Wed, 27 Aug 2025 at 12:10, Claudiu <claudiu.beznea@tuxon.dev> wrote:
>
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> Starting with commit f99508074e78 ("PM: domains: Detach on
> device_unbind_cleanup()"), there is no longer a need to call
> dev_pm_domain_detach() in the bus remove function. The
> device_unbind_cleanup() function now handles this to avoid
> invoking devres cleanup handlers while the PM domain is
> powered off, which could otherwise lead to failures as
> described in the above-mentioned commit.
>
> Drop the explicit dev_pm_domain_detach() call and rely instead
> on the flags passed to dev_pm_domain_attach() to power off the
> domain.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe


> ---
>  drivers/i2c/i2c-core-base.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index ecca8c006b02..ae7e9c8b65a6 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -573,7 +573,8 @@ static int i2c_device_probe(struct device *dev)
>                 goto err_clear_wakeup_irq;
>
>         do_power_on = !i2c_acpi_waive_d0_probe(dev);
> -       status = dev_pm_domain_attach(&client->dev, do_power_on ? PD_FLAG_ATTACH_POWER_ON : 0);
> +       status = dev_pm_domain_attach(&client->dev, PD_FLAG_DETACH_POWER_OFF |
> +                                     (do_power_on ? PD_FLAG_ATTACH_POWER_ON : 0));
>         if (status)
>                 goto err_clear_wakeup_irq;
>
> @@ -581,7 +582,7 @@ static int i2c_device_probe(struct device *dev)
>                                                     GFP_KERNEL);
>         if (!client->devres_group_id) {
>                 status = -ENOMEM;
> -               goto err_detach_pm_domain;
> +               goto err_clear_wakeup_irq;
>         }
>
>         client->debugfs = debugfs_create_dir(dev_name(&client->dev),
> @@ -608,8 +609,6 @@ static int i2c_device_probe(struct device *dev)
>  err_release_driver_resources:
>         debugfs_remove_recursive(client->debugfs);
>         devres_release_group(&client->dev, client->devres_group_id);
> -err_detach_pm_domain:
> -       dev_pm_domain_detach(&client->dev, do_power_on);
>  err_clear_wakeup_irq:
>         dev_pm_clear_wake_irq(&client->dev);
>         device_init_wakeup(&client->dev, false);
> @@ -636,8 +635,6 @@ static void i2c_device_remove(struct device *dev)
>
>         devres_release_group(&client->dev, client->devres_group_id);
>
> -       dev_pm_domain_detach(&client->dev, true);
> -
>         dev_pm_clear_wake_irq(&client->dev);
>         device_init_wakeup(&client->dev, false);
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-27 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 10:10 [PATCH] i2c: core: Drop dev_pm_domain_detach() call Claudiu
2025-08-27 11:35 ` Ulf Hansson

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).