include/linux/pm_runtime.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Since pm_runtime_get_active() returns 0 on success, all of the
DEFINE_GUARD_COND() macros in pm_runtime.h need the "_RET == 0"
condition at the end of the argument list or they would not work
correctly.
Fixes: 9a0abc39450a ("PM: runtime: Add auto-cleanup macros for "resume and get" operations")
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/linux-pm/202510191529.BCyjKlLQ-lkp@intel.com/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
include/linux/pm_runtime.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -629,13 +629,13 @@ DEFINE_GUARD(pm_runtime_active_auto, str
* device.
*/
DEFINE_GUARD_COND(pm_runtime_active, _try,
- pm_runtime_get_active(_T, RPM_TRANSPARENT))
+ pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
DEFINE_GUARD_COND(pm_runtime_active, _try_enabled,
- pm_runtime_resume_and_get(_T))
+ pm_runtime_resume_and_get(_T), _RET == 0)
DEFINE_GUARD_COND(pm_runtime_active_auto, _try,
- pm_runtime_get_active(_T, RPM_TRANSPARENT))
+ pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled,
- pm_runtime_resume_and_get(_T))
+ pm_runtime_resume_and_get(_T), _RET == 0)
/**
* pm_runtime_put_sync - Drop device usage counter and run "idle check" if 0.
On Oct 20, 2025 at 17:03:28 +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Since pm_runtime_get_active() returns 0 on success, all of the
> DEFINE_GUARD_COND() macros in pm_runtime.h need the "_RET == 0"
> condition at the end of the argument list or they would not work
> correctly.
>
> Fixes: 9a0abc39450a ("PM: runtime: Add auto-cleanup macros for "resume and get" operations")
> Reported-by: kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/linux-pm/202510191529.BCyjKlLQ-lkp@intel.com/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> include/linux/pm_runtime.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -629,13 +629,13 @@ DEFINE_GUARD(pm_runtime_active_auto, str
> * device.
> */
> DEFINE_GUARD_COND(pm_runtime_active, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
The 3-argument form automatically assumes success, so we were
essentially ignoring RET val. This seems correct now.
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Best regards,
Dhruva Gole
Texas Instruments Incorporated
On 10/20/2025 8:03 AM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Since pm_runtime_get_active() returns 0 on success, all of the
> DEFINE_GUARD_COND() macros in pm_runtime.h need the "_RET == 0"
> condition at the end of the argument list or they would not work
> correctly.
>
> Fixes: 9a0abc39450a ("PM: runtime: Add auto-cleanup macros for "resume and get" operations")
> Reported-by: kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/linux-pm/202510191529.BCyjKlLQ-lkp@intel.com/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> include/linux/pm_runtime.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -629,13 +629,13 @@ DEFINE_GUARD(pm_runtime_active_auto, str
> * device.
> */
> DEFINE_GUARD_COND(pm_runtime_active, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
>
> /**
> * pm_runtime_put_sync - Drop device usage counter and run "idle check" if 0.
>
>
This does fix the issue for me mentioned here
https://lore.kernel.org/all/25435d82-575d-495f-ae61-bd38570ff9ad@linux.ibm.com/
Feel free to add
Tested-by: Farhan Ali <alifm@linux.ibm.com>
Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Since pm_runtime_get_active() returns 0 on success, all of the
> DEFINE_GUARD_COND() macros in pm_runtime.h need the "_RET == 0"
> condition at the end of the argument list or they would not work
> correctly.
>
> Fixes: 9a0abc39450a ("PM: runtime: Add auto-cleanup macros for "resume and get" operations")
> Reported-by: kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/linux-pm/202510191529.BCyjKlLQ-lkp@intel.com/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> include/linux/pm_runtime.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -629,13 +629,13 @@ DEFINE_GUARD(pm_runtime_active_auto, str
> * device.
> */
> DEFINE_GUARD_COND(pm_runtime_active, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
I missed the detail that these are named "try" guards, but return
"-error" on failure. In all the existing cases of "try" vs "conditional"
acquire the polarity is different, e.g.:
DEFINE_GUARD_COND(rwsem_read, _try, down_read_trylock(_T))
DEFINE_GUARD_COND(rwsem_read, _intr, down_read_interruptible(_T), _RET == 0)
So, while this fix is correct, I wonder if a follow-on patch should
change the naming..., but I cannot think of sufficient replacement.
Reminder for me to be vigilant about this detail moving forward:
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
On Mon, 20 Oct 2025 17:03:28 +0200
"Rafael J. Wysocki" <rafael@kernel.org> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Since pm_runtime_get_active() returns 0 on success, all of the
> DEFINE_GUARD_COND() macros in pm_runtime.h need the "_RET == 0"
> condition at the end of the argument list or they would not work
> correctly.
>
> Fixes: 9a0abc39450a ("PM: runtime: Add auto-cleanup macros for "resume and get" operations")
> Reported-by: kernel test robot <lkp@intel.com>
> Link: https://lore.kernel.org/linux-pm/202510191529.BCyjKlLQ-lkp@intel.com/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Makes sense.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
These macros are a bit awkward to get right - I'd forgotten the oddity that
conditional locks use != 0 to mean the lock was taken.
> ---
> include/linux/pm_runtime.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -629,13 +629,13 @@ DEFINE_GUARD(pm_runtime_active_auto, str
> * device.
> */
> DEFINE_GUARD_COND(pm_runtime_active, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
>
> /**
> * pm_runtime_put_sync - Drop device usage counter and run "idle check" if 0.
>
>
>
© 2016 - 2026 Red Hat, Inc.