[PATCH v3 2/2] PM: runtime: fix stub pm_runtime_get_if_in_use() for !CONFIG_PM
From: Frank . Li
Date: Tue Nov 17 2026 - 12:38:14 EST
From: Frank Li <Frank.Li@xxxxxxx>
The stub for pm_runtime_get_if_in_use() under !CONFIG_PM currently
returns -EINVAL. The real implementation returns:
1 - device is active and its usage counter is non-zero (bumped)
0 - device is not in use or not active (counter not bumped)
-EINVAL - runtime PM disabled for this device
When CONFIG_PM is not set every device is permanently "active" and
always considered "in use", so the stub must return 1, mirroring
__pm_runtime_resume() which already returns 1 in the same build.
Returning -EINVAL breaks callers that test the return value with
comparisons other than "!= 0 / == 0":
drivers/gpu/drm/i915/intel_runtime_pm.c:
if (intel_runtime_pm_get_if_in_use(rpm))
which wraps to: ret = pm_runtime_get_if_in_use(); return ret > 0;
With -EINVAL the wrapper returns false, causing an incorrect error
path in the GT fence revocation code.
drivers/gpu/drm/xe/xe_pm.c:
if (pm_runtime_get_if_in_use(xe->drm.dev) > 0)
With -EINVAL the condition is false; xe_pm_runtime_get_if_in_use()
returns false, so callers believe the device is not usable.
drivers/gpu/drm/gma500/power.c:
return pm_runtime_get_if_in_use(dev) == 1;
-EINVAL != 1, so the helper always returns false when !CONFIG_PM.
drivers/gpu/drm/imagination/pvr_power.c:
if (pm_runtime_get_if_in_use(...) <= 0)
-EINVAL <= 0 is true, so the driver always takes the "requeue" error
path instead of proceeding with the active device.
sound/soc/sof/debug.c:
if (pm_runtime_get_if_in_use(sdev->dev) == 1)
-EINVAL != 1, so d3_prevented is never set, corrupting exception
debug accounting.
drivers/iommu/mtk_iommu.c:
if (pm_runtime_get_if_in_use(dom->plat_dev->dev) <= 0)
-EINVAL <= 0 skips the TLB flush, leaving stale IOMMU mappings.
drivers/iommu/rockchip-iommu.c:
Three call sites use WARN_ON_ONCE(err < 0) or similar patterns.
-EINVAL < 0 triggers a spurious WARNING on every call.
drivers/media/i2c/isl7998x.c:
if (pm_runtime_get_if_in_use(dev) <= 0) (two call sites)
-EINVAL <= 0 causes the driver to always skip register programming
when !CONFIG_PM.
drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c:
if (pm_runtime_get_if_in_use(dev) <= 0) (two call sites)
-EINVAL <= 0 prevents any debug statistics from being collected.
Fixes: a436b6a19f57 ("PM / runtime: Add new helper for conditional usage count incrementation")
Fixes: 3b85b7bcccf4 ("drm/xe: Fix display runtime_pm handling")
Fixes: 672c473576ca ("drm/gma500: Rewrite power management code")
Fixes: b30289e7fa92 ("ASoC: SOF: Fix runtime pm usage counter balance after fw exception")
Fixes: c0b57581b73b ("iommu/mediatek: Add power-domain operation")
Fixes: 51ef2be546e2 ("media: i2c: isl7998x: Add driver for Intersil ISL7998x")
Signed-off-by: Frank Li <Frank.Li@xxxxxxx>
---
Change in v3
- drop tag: cbb819c363c5 ("media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD")
selected PM at arch config
- drop tag: 0f181d3cf7d9 ("iommu/rockchip: Add runtime PM support")
selected PM at arch config
- drop tag: 9d58aa46291d ("drm/i915: Fix the GT fence revocation runtime PM logic")
guard by CONFIG_PM
- drop tag 727538a4bbff ("drm/imagination: Implement power management")
depend on PM
`
Change in v2
- new patches.
Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
Cc: linux-pm@xxxxxxxxxxxxxxx
Cc: Jani Nikula <jani.nikula@xxxxxxxxxxxxxxx>
Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
Cc: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>
Cc: Tvrtko Ursulin <tursulin@xxxxxxxxxxx>
Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
Cc: Maxime Ripard <mripard@xxxxxxxxxx>
Cc: "Thomas Hellstrom" <thomas.hellstrom@xxxxxxxxxxxxxxx>
Cc: Simona Vetter <simona@xxxxxxxx>
Cc: David Airlie <airlied@xxxxxxxxx>
Cc: Matthew Brost <matthew.brost@xxxxxxxxx>
Cc: Thomas Zimmermann <tzimmermann@xxxxxxx>
Cc: Patrik Jakobsson <patrik.r.jakobsson@xxxxxxxxx>
Cc: Alessio Belle <alessio.belle@xxxxxxxxxx>
Cc: Luigi Santivetti <luigi.santivetti@xxxxxxxxxx>
Cc: Liam Girdwood <lgirdwood@xxxxxxxxx>
Cc: Mark Brown <broonie@xxxxxxxxxx>
Cc: Jaroslav Kysela <perex@xxxxxxxx>
Cc: Takashi Iwai <tiwai@xxxxxxxx>
Cc: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxx>
Cc: Peter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>
Cc: Kai Vehmanen <kai.vehmanen@xxxxxxxxxxxxxxx>
Cc: Robin Murphy <robin.murphy@xxxxxxx>
Cc: Yong Wu <yong.wu@xxxxxxxxxxxx>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
Cc: Matthias Brugger <matthias.bgg@xxxxxxxxx>
Cc: Heiko Stuebner <heiko@xxxxxxxxx>
Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
Cc: Dafna Hirschfeld <dafna@xxxxxxxxxxxx>
Cc: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
Cc: Michael Tretter <m.tretter@xxxxxxxxxxxxxx>
Cc: Daniel Baluta <daniel.baluta@xxxxxxx>
Cc: Will Deacon <will@xxxxxxxxxx>
Cc: Vijendar Mukunda <Vijendar.Mukunda@xxxxxxx>
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: imagination@xxxxxxxxxxxxxxxxxxxxx
Cc: intel-gfx@xxxxxxxxxxxxxxxxxxxxx
Cc: intel-xe@xxxxxxxxxxxxxxxxxxxxx
Cc: iommu@xxxxxxxxxxxxxxx
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-mediatek@xxxxxxxxxxxxxxxxxxx
Cc: linux-media@xxxxxxxxxxxxxxx
Cc: linux-rockchip@xxxxxxxxxxxxxxxxxxx
Cc: linux-sound@xxxxxxxxxxxxxxx
Cc: sound-open-firmware@xxxxxxxxxxxxxxxx
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 de9e7518ecef2..1d983fe55a16a 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -276,7 +276,7 @@ static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
}
static inline int pm_runtime_get_if_in_use(struct device *dev)
{
- return -EINVAL;
+ return 1;
}
static inline int pm_runtime_get_if_active(struct device *dev)
{
--
2.43.0