Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v1] PM: runtime: Eliminate __pm_runtime_put_autosuspend()
@ 2026-11-24 16:36 Rafael J. Wysocki
  2026-11-24 17:00 ` Robin Murphy
  2026-11-24 18:03 ` Brian Norris
  0 siblings, 2 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2026-11-24 16:36 UTC (permalink / raw)
  To: Linux PM
  Cc: Linux Driver Core Development, Will Deacon, Robin Murphy,
	Joerg Roedel (AMD), iommu, Brian Norris, Sakari Ailus,
	Ulf Hansson

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

There are two users of __pm_runtime_put_autosuspend(),
pm_runtime_put_autosuspend() and arm_smmu_rpm_put(), but
the latter duplicates the code from the former.

Fold __pm_runtime_put_autosuspend() into pm_runtime_put_autosuspend()
and make arm_smmu_rpm_put() call the latter.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 Documentation/power/runtime_pm.rst    |    1 -
 drivers/iommu/arm/arm-smmu/arm-smmu.c |    7 ++-----
 include/linux/pm_runtime.h            |   26 +-------------------------
 3 files changed, 3 insertions(+), 31 deletions(-)

--- a/Documentation/power/runtime_pm.rst
+++ b/Documentation/power/runtime_pm.rst
@@ -338,7 +338,6 @@ It is safe to execute the following help
 - pm_runtime_put_noidle()
 - pm_runtime_put()
 - pm_runtime_put_autosuspend()
-- __pm_runtime_put_autosuspend()
 - pm_runtime_enable()
 - pm_suspend_ignore_children()
 - pm_runtime_set_active()
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -79,11 +79,8 @@ static inline int arm_smmu_rpm_get(struc
 
 static inline void arm_smmu_rpm_put(struct arm_smmu_device *smmu)
 {
-	if (pm_runtime_enabled(smmu->dev)) {
-		pm_runtime_mark_last_busy(smmu->dev);
-		__pm_runtime_put_autosuspend(smmu->dev);
-
-	}
+	if (pm_runtime_enabled(smmu->dev))
+		pm_runtime_put_autosuspend(smmu->dev);
 }
 
 static void arm_smmu_rpm_use_autosuspend(struct arm_smmu_device *smmu)
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -588,30 +588,6 @@ static inline void pm_runtime_put(struct
 }
 
 /**
- * __pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
- * @dev: Target device.
- *
- * Decrement the runtime PM usage counter of @dev and if it turns out to be
- * equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
- *
- * Return:
- * * %1: Success. Usage counter dropped to zero, but device was already suspended.
- * * %0: Success.
- * * %-EINVAL: Runtime PM error.
- * * %-EACCES: Runtime PM disabled.
- * * %-EAGAIN: Runtime PM usage counter became non-zero or Runtime PM status
- *   change ongoing.
- * * %-EBUSY: Runtime PM child_count non-zero.
- * * %-EPERM: Device PM QoS resume latency 0.
- * * %-EINPROGRESS: Suspend already in progress.
- * * %-ENOSYS: %CONFIG_PM not enabled.
- */
-static inline int __pm_runtime_put_autosuspend(struct device *dev)
-{
-	return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
-}
-
-/**
  * pm_runtime_put_autosuspend - Update the last access time, drop usage counter
  * and request autosuspend.
  * @dev: Target device.
@@ -635,7 +611,7 @@ static inline int __pm_runtime_put_autos
 static inline int pm_runtime_put_autosuspend(struct device *dev)
 {
 	pm_runtime_mark_last_busy(dev);
-	return __pm_runtime_put_autosuspend(dev);
+	return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
 }
 
 DEFINE_GUARD(pm_runtime_noresume, struct device *,




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

* Re: [PATCH v1] PM: runtime: Eliminate __pm_runtime_put_autosuspend()
  2026-11-24 16:36 [PATCH v1] PM: runtime: Eliminate __pm_runtime_put_autosuspend() Rafael J. Wysocki
@ 2026-11-24 17:00 ` Robin Murphy
  2026-11-24 18:03 ` Brian Norris
  1 sibling, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2026-11-24 17:00 UTC (permalink / raw)
  To: Rafael J. Wysocki, Linux PM
  Cc: Linux Driver Core Development, Will Deacon, Joerg Roedel (AMD),
	iommu, Brian Norris, Sakari Ailus, Ulf Hansson

On 24/11/2026 4:36 pm, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> 
> There are two users of __pm_runtime_put_autosuspend(),
> pm_runtime_put_autosuspend() and arm_smmu_rpm_put(), but
> the latter duplicates the code from the former.

Aha, indeed it was only this way to minimise conflicts with Sakari's 
original refactoring, since that led us to realise that we did actually 
want the mark_last_busy behaviour here anyway[1]. Evidently it missed 
anyone's to-do list to come back and clean it up post-merge - thanks for 
finally sorting it!

> Fold __pm_runtime_put_autosuspend() into pm_runtime_put_autosuspend()
> and make arm_smmu_rpm_put() call the latter.
> 
> No intentional functional impact.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

[1] https://lore.kernel.org/all/ZxpnFPsk2OBC8vqd@google.com/

> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>   Documentation/power/runtime_pm.rst    |    1 -
>   drivers/iommu/arm/arm-smmu/arm-smmu.c |    7 ++-----
>   include/linux/pm_runtime.h            |   26 +-------------------------
>   3 files changed, 3 insertions(+), 31 deletions(-)
> 
> --- a/Documentation/power/runtime_pm.rst
> +++ b/Documentation/power/runtime_pm.rst
> @@ -338,7 +338,6 @@ It is safe to execute the following help
>   - pm_runtime_put_noidle()
>   - pm_runtime_put()
>   - pm_runtime_put_autosuspend()
> -- __pm_runtime_put_autosuspend()
>   - pm_runtime_enable()
>   - pm_suspend_ignore_children()
>   - pm_runtime_set_active()
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -79,11 +79,8 @@ static inline int arm_smmu_rpm_get(struc
>   
>   static inline void arm_smmu_rpm_put(struct arm_smmu_device *smmu)
>   {
> -	if (pm_runtime_enabled(smmu->dev)) {
> -		pm_runtime_mark_last_busy(smmu->dev);
> -		__pm_runtime_put_autosuspend(smmu->dev);
> -
> -	}
> +	if (pm_runtime_enabled(smmu->dev))
> +		pm_runtime_put_autosuspend(smmu->dev);
>   }
>   
>   static void arm_smmu_rpm_use_autosuspend(struct arm_smmu_device *smmu)
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -588,30 +588,6 @@ static inline void pm_runtime_put(struct
>   }
>   
>   /**
> - * __pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
> - * @dev: Target device.
> - *
> - * Decrement the runtime PM usage counter of @dev and if it turns out to be
> - * equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
> - *
> - * Return:
> - * * %1: Success. Usage counter dropped to zero, but device was already suspended.
> - * * %0: Success.
> - * * %-EINVAL: Runtime PM error.
> - * * %-EACCES: Runtime PM disabled.
> - * * %-EAGAIN: Runtime PM usage counter became non-zero or Runtime PM status
> - *   change ongoing.
> - * * %-EBUSY: Runtime PM child_count non-zero.
> - * * %-EPERM: Device PM QoS resume latency 0.
> - * * %-EINPROGRESS: Suspend already in progress.
> - * * %-ENOSYS: %CONFIG_PM not enabled.
> - */
> -static inline int __pm_runtime_put_autosuspend(struct device *dev)
> -{
> -	return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
> -}
> -
> -/**
>    * pm_runtime_put_autosuspend - Update the last access time, drop usage counter
>    * and request autosuspend.
>    * @dev: Target device.
> @@ -635,7 +611,7 @@ static inline int __pm_runtime_put_autos
>   static inline int pm_runtime_put_autosuspend(struct device *dev)
>   {
>   	pm_runtime_mark_last_busy(dev);
> -	return __pm_runtime_put_autosuspend(dev);
> +	return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
>   }
>   
>   DEFINE_GUARD(pm_runtime_noresume, struct device *,
> 
> 
> 


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

* Re: [PATCH v1] PM: runtime: Eliminate __pm_runtime_put_autosuspend()
  2026-11-24 16:36 [PATCH v1] PM: runtime: Eliminate __pm_runtime_put_autosuspend() Rafael J. Wysocki
  2026-11-24 17:00 ` Robin Murphy
@ 2026-11-24 18:03 ` Brian Norris
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Norris @ 2026-11-24 18:03 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM, Linux Driver Core Development, Will Deacon,
	Robin Murphy, Joerg Roedel (AMD), iommu, Sakari Ailus,
	Ulf Hansson, Prakash Gupta

On Tue, Nov 24, 2026 at 05:36:41PM +0100, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> 
> There are two users of __pm_runtime_put_autosuspend(),
> pm_runtime_put_autosuspend() and arm_smmu_rpm_put(), but
> the latter duplicates the code from the former.
> 
> Fold __pm_runtime_put_autosuspend() into pm_runtime_put_autosuspend()
> and make arm_smmu_rpm_put() call the latter.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Ah, it's about time. I was thinking Prakash's patches would handle this
semi-naturally eventually, but they seem to be stalling.

Reviewed-by: Brian Norris <briannorris@chromium.org>

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

end of thread, other threads:[~2026-11-24 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 16:36 [PATCH v1] PM: runtime: Eliminate __pm_runtime_put_autosuspend() Rafael J. Wysocki
2026-11-24 17:00 ` Robin Murphy
2026-11-24 18:03 ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox