Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] PM: runtime: fix stub pm_runtime_get_if_active() for !CONFIG_PM
@ 2026-11-16 15:25 Frank.Li
       [not found] ` <20261116152513.2676573-2-Frank.Li@oss.nxp.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Frank.Li @ 2026-11-16 15:25 UTC (permalink / raw)
  Cc: Frank Li, Alex Elder, Rafael J. Wysocki, Greg Kroah-Hartman,
	Andrzej Kacprowski, Karol Wachowski, Oded Gabbay, Jani Nikula,
	Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin, Matthew Brost,
	Thomas Hellstrom, David Airlie, Simona Vetter, Alex Elder,
	Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark, Sakari Ailus,
	Mauro Carvalho Chehab, Guenter Roeck, Guan-Yu Lin, Mathias Nyman,
	linux-pm, linux-usb, dri-devel, intel-gfx, intel-xe, linux-hwmon,
	linux-arm-kernel, iommu, linux-arm-msm, linux-media,
	linux-staging, netdev, imx

From: Frank Li <Frank.Li@nxp.com>

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: bd3d245b0fef5 ("usb: core: use dedicated spinlock for offload state")
Fixes: 7806bad76ac39 ("accel/ivpu: Prevent runtime suspend during context abort work")
Fixes: 9d58aa46291d4 ("drm/i915: Fix the GT fence revocation runtime PM logic")
Fixes: 1524c28b99527 ("accel/ivpu: Show NPU frequency in sysfs")
Fixes: 30c399529f4c6 ("drm/xe: Document Xe PM component")
Fixes: 0d08026ac6099 ("net: ipa: kill ipa_clock_get_additional()")
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@riscstar.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
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@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
Cc: Karol Wachowski <karol.wachowski@linux.intel.com>
Cc: Oded Gabbay <ogabbay@kernel.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: "Thomas Hellstrom" <thomas.hellstrom@linux.intel.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: Alex Elder <elder@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: "Joerg Roedel" <joro@8bytes.org>
Cc: Rob Clark <robin.clark@oss.qualcomm.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Guan-Yu Lin <guanyulin@google.com>
Cc: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org
Cc: linux-hwmon@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: iommu@lists.linux.dev
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-media@vger.kernel.org
Cc: linux-staging@lists.linux.dev
Cc: netdev@vger.kernel.org
Cc: imx@lists.linux.dev
---
 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



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

* Re: [PATCH v2 2/2] PM: runtime: fix stub pm_runtime_get_if_in_use() for !CONFIG_PM
       [not found] ` <20261116152513.2676573-2-Frank.Li@oss.nxp.com>
@ 2026-11-16 15:31   ` Laurent Pinchart
  2026-11-16 15:43     ` Frank Li
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2026-11-16 15:31 UTC (permalink / raw)
  To: Frank.Li
  Cc: Frank Li, Rafael J. Wysocki, linux-pm, Jani Nikula,
	Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin, Maarten Lankhorst,
	Maxime Ripard, Thomas Hellstrom, Simona Vetter, David Airlie,
	Matthew Brost, Thomas Zimmermann, Patrik Jakobsson, Alessio Belle,
	Luigi Santivetti, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Bard Liao, Pierre-Louis Bossart, Peter Ujfalusi,
	Kai Vehmanen, Robin Murphy, Yong Wu, AngeloGioacchino Del Regno,
	Matthias Brugger, Heiko Stuebner, Mauro Carvalho Chehab,
	Dafna Hirschfeld, Michael Tretter, Daniel Baluta, Will Deacon,
	Vijendar Mukunda, dri-devel, imagination, intel-gfx, intel-xe,
	iommu, linux-arm-kernel, linux-mediatek, linux-media,
	linux-rockchip, linux-sound, sound-open-firmware, imx

Hi Frank,

On Mon, Nov 16, 2026 at 10:25:11AM -0500, Frank.Li@oss.nxp.com wrote:
> From: Frank Li <Frank.Li@nxp.com>
> 
> 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: 9d58aa46291d ("drm/i915: Fix the GT fence revocation runtime PM logic")
> Fixes: cbb6a7413b17 ("drm/xe: Introduce xe_pm_runtime_get_noresume for inner callers")
> Fixes: 672c473576ca ("drm/gma500: Rewrite power management code")
> Fixes: 727538a4bbff ("drm/imagination: Implement power management")
> Fixes: b30289e7fa92 ("ASoC: SOF: Fix runtime pm usage counter balance after fw exception")
> Fixes: c0b57581b73b ("iommu/mediatek: Add power-domain operation")
> Fixes: 0f181d3cf7d9 ("iommu/rockchip: Add runtime PM support")
> Fixes: 51ef2be546e2 ("media: i2c: isl7998x: Add driver for Intersil ISL7998x")
> Fixes: cbb819c363c5 ("media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD")

I don't think this one is right. The rkisp1 driver only runs on ARCH_MXC
and ARCH_ROCKCHIP, which select CONFIG_PM. The same may be true for some
of the other fixes tags.

> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> Change in v2
> - new patches.
> 
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: linux-pm@vger.kernel.org
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Tvrtko Ursulin <tursulin@ursulin.net>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: "Thomas Hellstrom" <thomas.hellstrom@linux.intel.com>
> Cc: Simona Vetter <simona@ffwll.ch>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Cc: Alessio Belle <alessio.belle@imgtec.com>
> Cc: Luigi Santivetti <luigi.santivetti@imgtec.com>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
> Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
> Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Yong Wu <yong.wu@mediatek.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Dafna Hirschfeld <dafna@fastmail.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Michael Tretter <m.tretter@pengutronix.de>
> Cc: Daniel Baluta <daniel.baluta@nxp.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: imagination@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: intel-xe@lists.freedesktop.org
> Cc: iommu@lists.linux.dev
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-rockchip@lists.infradead.org
> Cc: linux-sound@vger.kernel.org
> Cc: sound-open-firmware@alsa-project.org
> Cc: imx@lists.linux.dev
> ---
>  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)
>  {

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH v2 2/2] PM: runtime: fix stub pm_runtime_get_if_in_use() for !CONFIG_PM
  2026-11-16 15:31   ` [PATCH v2 2/2] PM: runtime: fix stub pm_runtime_get_if_in_use() " Laurent Pinchart
@ 2026-11-16 15:43     ` Frank Li
  2026-11-16 15:52       ` Laurent Pinchart
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Li @ 2026-11-16 15:43 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Frank Li, Rafael J. Wysocki, linux-pm, Jani Nikula,
	Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin, Maarten Lankhorst,
	Maxime Ripard, Thomas Hellstrom, Simona Vetter, David Airlie,
	Matthew Brost, Thomas Zimmermann, Patrik Jakobsson, Alessio Belle,
	Luigi Santivetti, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Bard Liao, Pierre-Louis Bossart, Peter Ujfalusi,
	Kai Vehmanen, Robin Murphy, Yong Wu, AngeloGioacchino Del Regno,
	Matthias Brugger, Heiko Stuebner, Mauro Carvalho Chehab,
	Dafna Hirschfeld, Michael Tretter, Daniel Baluta, Will Deacon,
	Vijendar Mukunda, dri-devel, imagination, intel-gfx, intel-xe,
	iommu, linux-arm-kernel, linux-mediatek, linux-media,
	linux-rockchip, linux-sound, sound-open-firmware, imx

On Mon, Nov 16, 2026 at 05:31:39PM +0200, Laurent Pinchart wrote:
> Hi Frank,
>
> On Mon, Nov 16, 2026 at 10:25:11AM -0500, Frank.Li@oss.nxp.com wrote:
> > From: Frank Li <Frank.Li@nxp.com>
> >
> > 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: 9d58aa46291d ("drm/i915: Fix the GT fence revocation runtime PM logic")
> > Fixes: cbb6a7413b17 ("drm/xe: Introduce xe_pm_runtime_get_noresume for inner callers")
> > Fixes: 672c473576ca ("drm/gma500: Rewrite power management code")
> > Fixes: 727538a4bbff ("drm/imagination: Implement power management")
> > Fixes: b30289e7fa92 ("ASoC: SOF: Fix runtime pm usage counter balance after fw exception")
> > Fixes: c0b57581b73b ("iommu/mediatek: Add power-domain operation")
> > Fixes: 0f181d3cf7d9 ("iommu/rockchip: Add runtime PM support")
> > Fixes: 51ef2be546e2 ("media: i2c: isl7998x: Add driver for Intersil ISL7998x")
> > Fixes: cbb819c363c5 ("media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD")
>
> I don't think this one is right. The rkisp1 driver only runs on ARCH_MXC
> and ARCH_ROCKCHIP, which select CONFIG_PM. The same may be true for some
> of the other fixes tags.

But code itself should be wrong even though these platform force enable
CONFIG_PM.

Frank

>
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> > Change in v2
> > - new patches.
> >
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: linux-pm@vger.kernel.org
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Cc: Tvrtko Ursulin <tursulin@ursulin.net>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Cc: Maxime Ripard <mripard@kernel.org>
> > Cc: "Thomas Hellstrom" <thomas.hellstrom@linux.intel.com>
> > Cc: Simona Vetter <simona@ffwll.ch>
> > Cc: David Airlie <airlied@gmail.com>
> > Cc: Matthew Brost <matthew.brost@intel.com>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> > Cc: Alessio Belle <alessio.belle@imgtec.com>
> > Cc: Luigi Santivetti <luigi.santivetti@imgtec.com>
> > Cc: Liam Girdwood <lgirdwood@gmail.com>
> > Cc: Mark Brown <broonie@kernel.org>
> > Cc: Jaroslav Kysela <perex@perex.cz>
> > Cc: Takashi Iwai <tiwai@suse.com>
> > Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
> > Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
> > Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> > Cc: Robin Murphy <robin.murphy@arm.com>
> > Cc: Yong Wu <yong.wu@mediatek.com>
> > Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > Cc: Matthias Brugger <matthias.bgg@gmail.com>
> > Cc: Heiko Stuebner <heiko@sntech.de>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: Dafna Hirschfeld <dafna@fastmail.com>
> > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Cc: Michael Tretter <m.tretter@pengutronix.de>
> > Cc: Daniel Baluta <daniel.baluta@nxp.com>
> > Cc: Will Deacon <will@kernel.org>
> > Cc: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> > Cc: dri-devel@lists.freedesktop.org
> > Cc: imagination@lists.freedesktop.org
> > Cc: intel-gfx@lists.freedesktop.org
> > Cc: intel-xe@lists.freedesktop.org
> > Cc: iommu@lists.linux.dev
> > Cc: linux-arm-kernel@lists.infradead.org
> > Cc: linux-mediatek@lists.infradead.org
> > Cc: linux-media@vger.kernel.org
> > Cc: linux-rockchip@lists.infradead.org
> > Cc: linux-sound@vger.kernel.org
> > Cc: sound-open-firmware@alsa-project.org
> > Cc: imx@lists.linux.dev
> > ---
> >  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)
> >  {
>
> --
> Regards,
>
> Laurent Pinchart


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

* Re: [PATCH v2 2/2] PM: runtime: fix stub pm_runtime_get_if_in_use() for !CONFIG_PM
  2026-11-16 15:43     ` Frank Li
@ 2026-11-16 15:52       ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2026-11-16 15:52 UTC (permalink / raw)
  To: Frank Li
  Cc: Frank Li, Rafael J. Wysocki, linux-pm, Jani Nikula,
	Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin, Maarten Lankhorst,
	Maxime Ripard, Thomas Hellstrom, Simona Vetter, David Airlie,
	Matthew Brost, Thomas Zimmermann, Patrik Jakobsson, Alessio Belle,
	Luigi Santivetti, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Bard Liao, Pierre-Louis Bossart, Peter Ujfalusi,
	Kai Vehmanen, Robin Murphy, Yong Wu, AngeloGioacchino Del Regno,
	Matthias Brugger, Heiko Stuebner, Mauro Carvalho Chehab,
	Dafna Hirschfeld, Michael Tretter, Daniel Baluta, Will Deacon,
	Vijendar Mukunda, dri-devel, imagination, intel-gfx, intel-xe,
	iommu, linux-arm-kernel, linux-mediatek, linux-media,
	linux-rockchip, linux-sound, sound-open-firmware, imx

On Mon, Nov 16, 2026 at 09:43:13AM -0600, Frank Li wrote:
> On Mon, Nov 16, 2026 at 05:31:39PM +0200, Laurent Pinchart wrote:
> > On Mon, Nov 16, 2026 at 10:25:11AM -0500, Frank.Li@oss.nxp.com wrote:
> > > From: Frank Li <Frank.Li@nxp.com>
> > >
> > > 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: 9d58aa46291d ("drm/i915: Fix the GT fence revocation runtime PM logic")
> > > Fixes: cbb6a7413b17 ("drm/xe: Introduce xe_pm_runtime_get_noresume for inner callers")
> > > Fixes: 672c473576ca ("drm/gma500: Rewrite power management code")
> > > Fixes: 727538a4bbff ("drm/imagination: Implement power management")
> > > Fixes: b30289e7fa92 ("ASoC: SOF: Fix runtime pm usage counter balance after fw exception")
> > > Fixes: c0b57581b73b ("iommu/mediatek: Add power-domain operation")
> > > Fixes: 0f181d3cf7d9 ("iommu/rockchip: Add runtime PM support")
> > > Fixes: 51ef2be546e2 ("media: i2c: isl7998x: Add driver for Intersil ISL7998x")
> > > Fixes: cbb819c363c5 ("media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD")
> >
> > I don't think this one is right. The rkisp1 driver only runs on ARCH_MXC
> > and ARCH_ROCKCHIP, which select CONFIG_PM. The same may be true for some
> > of the other fixes tags.
> 
> But code itself should be wrong even though these platform force enable
> CONFIG_PM.

How does it make the code wrong in the rkisp1 driver ? There's nothing
to fix there, because there's no bug.

I'm not saying this patch is wrong (I'll let the runtime PM folks
provide expert feedback), but I think some of the Fixes: tags are not
correct.

> > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > ---
> > > Change in v2
> > > - new patches.
> > >
> > > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > > Cc: linux-pm@vger.kernel.org
> > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > Cc: Tvrtko Ursulin <tursulin@ursulin.net>
> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Cc: Maxime Ripard <mripard@kernel.org>
> > > Cc: "Thomas Hellstrom" <thomas.hellstrom@linux.intel.com>
> > > Cc: Simona Vetter <simona@ffwll.ch>
> > > Cc: David Airlie <airlied@gmail.com>
> > > Cc: Matthew Brost <matthew.brost@intel.com>
> > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> > > Cc: Alessio Belle <alessio.belle@imgtec.com>
> > > Cc: Luigi Santivetti <luigi.santivetti@imgtec.com>
> > > Cc: Liam Girdwood <lgirdwood@gmail.com>
> > > Cc: Mark Brown <broonie@kernel.org>
> > > Cc: Jaroslav Kysela <perex@perex.cz>
> > > Cc: Takashi Iwai <tiwai@suse.com>
> > > Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> > > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
> > > Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
> > > Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> > > Cc: Robin Murphy <robin.murphy@arm.com>
> > > Cc: Yong Wu <yong.wu@mediatek.com>
> > > Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > > Cc: Matthias Brugger <matthias.bgg@gmail.com>
> > > Cc: Heiko Stuebner <heiko@sntech.de>
> > > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > > Cc: Dafna Hirschfeld <dafna@fastmail.com>
> > > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > Cc: Michael Tretter <m.tretter@pengutronix.de>
> > > Cc: Daniel Baluta <daniel.baluta@nxp.com>
> > > Cc: Will Deacon <will@kernel.org>
> > > Cc: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> > > Cc: dri-devel@lists.freedesktop.org
> > > Cc: imagination@lists.freedesktop.org
> > > Cc: intel-gfx@lists.freedesktop.org
> > > Cc: intel-xe@lists.freedesktop.org
> > > Cc: iommu@lists.linux.dev
> > > Cc: linux-arm-kernel@lists.infradead.org
> > > Cc: linux-mediatek@lists.infradead.org
> > > Cc: linux-media@vger.kernel.org
> > > Cc: linux-rockchip@lists.infradead.org
> > > Cc: linux-sound@vger.kernel.org
> > > Cc: sound-open-firmware@alsa-project.org
> > > Cc: imx@lists.linux.dev
> > > ---
> > >  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)
> > >  {

-- 
Regards,

Laurent Pinchart


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

end of thread, other threads:[~2026-11-16 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 15:25 [PATCH v2 1/2] PM: runtime: fix stub pm_runtime_get_if_active() for !CONFIG_PM Frank.Li
     [not found] ` <20261116152513.2676573-2-Frank.Li@oss.nxp.com>
2026-11-16 15:31   ` [PATCH v2 2/2] PM: runtime: fix stub pm_runtime_get_if_in_use() " Laurent Pinchart
2026-11-16 15:43     ` Frank Li
2026-11-16 15:52       ` Laurent Pinchart

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