From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62974606A31C for ; Mon, 16 Nov 2026 15:52:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=QvD82s5H; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=NusKEKiY DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=tc6KfHj5fySnLDo/yssasn7KXGGvXcSn8JCgqMRWVxQ=; b=QvD82s5Hhuo2Wtty07advPEaUj EgUGliYJbxmtbmElvzqoO8cstv45SRhWcfj+JKuz6ewoIuOiD8yoEl5jpNNllnynXpNFAsWzboLum 43xPpOY8QMJ4JqjanEWRIGRkb9XFvukjuoKiroGhQrv07a6DXmORzdu0jQOu/fMeQGlCbgcpzeVIN XKHg8MYZ/sXbX37XMHzF5Ddm2IUdcB2WS5jZtDTzApukC8pxF0t64MYVvpSICnE9j8Zpd66/f9G2f Q8qLgYllR0Ua70CrwVPHc0tuvOPXFbL+ro/Zd/BY9JsK2SoYw3eo0QKd95TScUfREaGx6H2wKdoAa bYXU57VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xSz0D-0000000380I-1WCs; Mon, 16 Nov 2026 15:52:17 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xSz0B-000000037zR-02nq; Mon, 16 Nov 2026 15:52:16 +0000 Received: from killaraus.ideasonboard.com (2001-14ba-7086-3000--a06.rev.dnainternet.fi [IPv6:2001:14ba:7086:3000::a06]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ED0204BB; Mon, 16 Nov 2026 16:49:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1794844186; bh=dmodi+YIJbHNHccq3QM7tWgiNzPRHtMFkx//VJBaXh4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NusKEKiY4bzAOfEoYrIhBXyGlIkZI3PnloPf2BxBVRwuEIJvmtu+vw7O/jc41VQuU J3Ty1U67T4ibE4hILXY3O/CpMrCBJQpictxpRHUyim+WJ3gBdqwhQf8GriCHlXRv3w cuUezGZlAQGClI/3BR6NS7TrNFoxwJ2vIQYfr6tw= Date: Mon, 16 Nov 2026 17:52:11 +0200 From: Laurent Pinchart To: Frank Li Cc: Frank Li , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, 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@lists.freedesktop.org, imagination@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sound@vger.kernel.org, sound-open-firmware@alsa-project.org, imx@lists.linux.dev Subject: Re: [PATCH v2 2/2] PM: runtime: fix stub pm_runtime_get_if_in_use() for !CONFIG_PM Message-ID: <20261116155211.GB1763340@killaraus.ideasonboard.com> References: <20261116152513.2676573-1-Frank.Li@oss.nxp.com> <20261116152513.2676573-2-Frank.Li@oss.nxp.com> <20261116153139.GB1763944@killaraus.ideasonboard.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261116_075215_204000_A2651BE1 X-CRM114-Status: GOOD ( 41.80 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 > > > > > > 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 > > > --- > > > Change in v2 > > > - new patches. > > > > > > Cc: "Rafael J. Wysocki" > > > Cc: linux-pm@vger.kernel.org > > > Cc: Jani Nikula > > > Cc: Joonas Lahtinen > > > Cc: Rodrigo Vivi > > > Cc: Tvrtko Ursulin > > > Cc: Maarten Lankhorst > > > Cc: Maxime Ripard > > > Cc: "Thomas Hellstrom" > > > Cc: Simona Vetter > > > Cc: David Airlie > > > Cc: Matthew Brost > > > Cc: Thomas Zimmermann > > > Cc: Patrik Jakobsson > > > Cc: Alessio Belle > > > Cc: Luigi Santivetti > > > Cc: Liam Girdwood > > > Cc: Mark Brown > > > Cc: Jaroslav Kysela > > > Cc: Takashi Iwai > > > Cc: Bard Liao > > > Cc: Pierre-Louis Bossart > > > Cc: Peter Ujfalusi > > > Cc: Kai Vehmanen > > > Cc: Robin Murphy > > > Cc: Yong Wu > > > Cc: AngeloGioacchino Del Regno > > > Cc: Matthias Brugger > > > Cc: Heiko Stuebner > > > Cc: Mauro Carvalho Chehab > > > Cc: Dafna Hirschfeld > > > Cc: Laurent Pinchart > > > Cc: Michael Tretter > > > Cc: Daniel Baluta > > > Cc: Will Deacon > > > Cc: Vijendar Mukunda > > > 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