Re: [PATCH v3 1/2] PM: runtime: fix stub pm_runtime_get_if_active() for !CONFIG_PM
From: Ulf Hansson
Date: Wed Nov 25 2026 - 10:06:55 EST
On Tue, Nov 17, 2026 at 6:37 PM <Frank.Li@xxxxxxxxxxx> wrote:
>
> From: Frank Li <Frank.Li@xxxxxxx>
>
> When CONFIG_PM is not enabled, should be treated as if runtime PM were
> enabled for the device and the runtime status is active.
>
> It's a subtle distinction but the previous behavior returned -EINVAL, which
> means "runtime PM is disabled for the device"
>
> __pm_runtime_resume() returns 1 (called by pm_runtime_get()).
> pm_runtime_get_if_active() is the try-and-get version of pm_runtime_get().
> stub pm_runtime_active() also returns true. So pm_runtime_get_if_active()
> should return the same value as the stub pm_runtime_get(), which is 1.
>
> Analysis of all callers and their behavior with old (-EINVAL) vs new (1):
>
> Pattern A: if (!pm_runtime_get_if_active(dev)) -- no impact
> Both -EINVAL and 1 are non-zero, so !ret is false in both cases.
> Callers: drivers/accel/ethosu/ethosu_perfmon.c,
> drivers/gpu/drm/msm/adreno/a6xx_gmu.c,
> drivers/gpu/drm/msm/msm_perfcntr.c,
> drivers/gpu/drm/v3d/v3d_mmu.c,
> drivers/gpu/drm/v3d/v3d_perfmon.c (x4),
> drivers/media/i2c/gc08a3.c gc05a2.c og0ve1b.c ov6211.c,
> drivers/media/i2c/ccs/ccs-core.c s5kjn1.c lm3560.c (x2),
> drivers/media/i2c/s5k3m5.c thp7312.c imx283.c ov64a40.c,
> drivers/media/pci/intel/ipu6/ipu6-buttress.c,
> sound/hda/core/device.c
>
> Pattern B: if (!ret) after get -- no impact
> Both -EINVAL and 1 are non-zero, !ret is false in both cases.
> drivers/gpu/drm/amd/pm/amdgpu_pm.c (comment says "allow access"
> in kernels without CONFIG_PM), drivers/pci/pci.c
>
> Pattern C: ret > 0 / ret <= 0 / ret != 1 checks -- FIXED
> drivers/usb/core/offload.c: checks (!= 1), old -EINVAL caused
> -EBUSY even with !CONFIG_PM. Fixed: now returns 1, proceeds.
> drivers/accel/ivpu/ivpu_job.c: drm_WARN_ON(<= 0), old -EINVAL
> spuriously triggered WARN. Fixed: 1 > 0, no warn.
> drivers/gpu/drm/i915/intel_runtime_pm.c: checks (<= 0), old
> -EINVAL triggered error path. Fixed: 1 > 0, correct path.
> drivers/accel/ivpu/ivpu_sysfs.c: (> 0), old skipped freq read.
> Fixed: proceeds correctly without CONFIG_PM.
> drivers/gpu/drm/xe/xe_pm.c: wraps (> 0), all xe callers
> (xe_bo.c, xe_shrinker.c, xe_vsec.c, xe_ggtt.c, xe_guc_ct.c,
> xe_pxp.c) now correctly treat !CONFIG_PM as active.
> drivers/net/ipa/ipa_smp2p.c: power_on = (> 0), now correctly true.
> drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c: (> 0), now correctly
> executes stall register update.
> drivers/staging/media/ipu7/ipu7-buttress.c: active (<= 0) early
> return now skipped, correctly proceeds.
>
> Pattern D: explicit -EINVAL check
> drivers/hwmon/prom21-xhci.c: checks (> 0) then (== -EINVAL).
> Old: took -EINVAL fallback. New: takes (> 0) fast path.
> Both succeed when CONFIG_PM is disabled; functionally equivalent.
> drivers/hwmon/eic7700-pvt.c: call is guarded by IS_ENABLED(CONFIG_PM),
> stub is never reached. No impact.
>
> Fixes: c0ef3df8dbaef ("PM: runtime: Simplify pm_runtime_get_if_active() usage")
> Fixes: bd3d245b0fef5 ("usb: core: use dedicated spinlock for offload state")
> Fixes: 7806bad76ac39 ("accel/ivpu: Prevent runtime suspend during context abort work")
> Fixes: 1524c28b99527 ("accel/ivpu: Show NPU frequency in sysfs")
> Fixes: 46edb0a3eb16c ("drm/xe: Fix xe_pm_runtime_get_if_active return")
> Fixes: a71aeff3dd0a7 ("net: ipa: kill IPA clock reference count")
> Fixes: 70892277ca2db ("iommu/arm-smmu-qcom: Make set_stall work when the device is on")
> Fixes: 9ad65684b9285 ("media: staging/ipu7: Ignore interrupts when device is suspended")
> Acked-by: Alex Elder <elder@xxxxxxxxxxxx>
> Signed-off-by: Frank Li <Frank.Li@xxxxxxx>
Reviewed-by: Ulf Hansson <ulfh@xxxxxxxxxx
Kind regards
Uffe
> ---
> Change in v3
> - fix drm/xe fixes tag hash (sashiko)
> - drop i915 fix tag because guard by CONFIG_PM (sashiko)
> - fix net ipa fixes tag hash (sashiko)
> - Add c0ef3df8dbae ("PM: runtime: Simplify pm_runtime_get_if_active() usage" (sashiko)
>
> Change in v2
> - add fixes tag for patten C.
> - add Alex Elder ack tags
> - change subject to fix stub pm_runtime_get_if_active()
>
> Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Cc: Andrzej Kacprowski <andrzej.kacprowski@xxxxxxxxxxxxxxx>
> Cc: Karol Wachowski <karol.wachowski@xxxxxxxxxxxxxxx>
> Cc: Oded Gabbay <ogabbay@xxxxxxxxxx>
> Cc: Jani Nikula <jani.nikula@xxxxxxxxxxxxxxx>
> Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
> Cc: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>
> Cc: Tvrtko Ursulin <tursulin@xxxxxxxxxxx>
> Cc: Matthew Brost <matthew.brost@xxxxxxxxx>
> Cc: "Thomas Hellstrom" <thomas.hellstrom@xxxxxxxxxxxxxxx>
> Cc: David Airlie <airlied@xxxxxxxxx>
> Cc: Simona Vetter <simona@xxxxxxxx>
> Cc: Alex Elder <elder@xxxxxxxxxx>
> Cc: Will Deacon <will@xxxxxxxxxx>
> Cc: Robin Murphy <robin.murphy@xxxxxxx>
> Cc: "Joerg Roedel" <joro@xxxxxxxxxx>
> Cc: Rob Clark <robin.clark@xxxxxxxxxxxxxxxx>
> Cc: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
> Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
> Cc: Guenter Roeck <linux@xxxxxxxxxxxx>
> Cc: Guan-Yu Lin <guanyulin@xxxxxxxxxx>
> Cc: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
> Cc: linux-pm@xxxxxxxxxxxxxxx
> Cc: linux-usb@xxxxxxxxxxxxxxx
> Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
> Cc: intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> Cc: intel-xe@xxxxxxxxxxxxxxxxxxxxx
> Cc: linux-hwmon@xxxxxxxxxxxxxxx
> Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> Cc: iommu@xxxxxxxxxxxxxxx
> Cc: linux-arm-msm@xxxxxxxxxxxxxxx
> Cc: linux-media@xxxxxxxxxxxxxxx
> Cc: linux-staging@xxxxxxxxxxxxxxx
> Cc: netdev@xxxxxxxxxxxxxxx
> Cc: imx@xxxxxxxxxxxxxxx
> ---
> include/linux/pm_runtime.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
> index 64921b10ac74f..de9e7518ecef2 100644
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -280,7 +280,7 @@ static inline int pm_runtime_get_if_in_use(struct device *dev)
> }
> static inline int pm_runtime_get_if_active(struct device *dev)
> {
> - return -EINVAL;
> + return 1;
> }
> static inline int __pm_runtime_set_status(struct device *dev,
> unsigned int status) { return 0; }
> --
> 2.43.0