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 684A9606A333 for ; Thu, 19 Nov 2026 11:38:35 +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=F+pRMLvU; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=1l7Upd4u 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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=BwG6pO180ts3EsXk8dPvrXRrI1JUEETTIVLE0jahKVc=; b=F+pRMLvU953h0f th8TYG4PShxR/E+Ei9ejdNqLXOAwYHLH3ZATKg8VqPvHVQMq1YGRlbwCDzVjl2nsyDTZoPrVteys8 A37UnwITVxopZSwOzJkPCdmNMKJxstJUULZupWNpijAyQjgN0IUDLK1R4kZNX0spehOhFvXaB41hr zYG8irylyt7v6rC57gtFQYzH2lQ4Ax7S37yRO5psvVvERXV7YrMZoWYGGJiXqUtm4M6lsbPn6OjDb 9Ph3CMQX/ISDISdMG7XwnybuwSvMS3trt+si2Uato4w0IXLs7ERB+3BY7BB3arlLoBbkAAKkS7wkJ oyBidKJBo4RhphZucM1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xU0TE-0000000BiNb-3Ig6; Thu, 19 Nov 2026 11:38:28 +0000 Received: from smtpout-03.galae.net ([185.246.85.4]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xU0TA-0000000BiMH-1b66 for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2026 11:38:27 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 662694E41666; Thu, 19 Nov 2026 11:38:22 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3AE7E60237; Thu, 19 Nov 2026 11:38:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4409411BC1249; Thu, 19 Nov 2026 12:38:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795088296; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=BwG6pO180ts3EsXk8dPvrXRrI1JUEETTIVLE0jahKVc=; b=1l7Upd4uTZdbbbvfHSuMTHUhvapkpfFGqkwgtq7Fn6XGui7RzpF++cOrWUJLq5hs+RTtKi DIBLjOIpJ2KpU0aumygE6CBmMVJ21lCP5/ur7i1672TBxmHOBkk9coN917WZ/dGlBLBDIe 2Xbys0dC3kMrFUyOipQg8sIqz2XQzDaw5Dt+htEBYweJQ4w3Enl3Msf2MUNPZzYoABmtAG F4nQiCERIut8IPSfoN+E+XD82HkeSPSmf7RiJLzV84IvkKF+G8iq80TfkzBH166U561hpq 23qojzjxRpovEOTdataKYcH5eUedT9kb3+PHF6w+7fazvuHSYFz6MD2e1Jo3Cg== From: Herve Codina To: Andrew Lunn , Rob Herring , Saravana Kannan , Geert Uytterhoeven , Kalle Niemi , Matti Vaittinen , Aaro Koskinen , Andreas Kemnade , Kevin Hilman , Roger Quadros , Tony Lindgren , Russell King , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Johan Hovold Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, driver-core@lists.linux.dev, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Daniel Machon , Steen Hegelund , Luca Ceresoli , Thomas Petazzoni , Herve Codina , Sashiko , stable@vger.kernel.org Subject: [PATCH v11 1/5] bus: simple-pm-bus: Avoid inconsistencies between probe() and remove() Date: Thu, 19 Nov 2026 12:37:52 +0100 Message-ID: <20261119113758.603074-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261119113758.603074-1-herve.codina@bootlin.com> References: <20261119113758.603074-1-herve.codina@bootlin.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261119_033825_487492_E975C216 X-CRM114-Status: GOOD ( 16.56 ) 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=-18.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,USER_AGENT_GIT autolearn=ham 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 At probe(), operations done depends on device_has_driver_override(). At remove() a call to device_has_driver_override() is also present to identify operations that need to be done in order to revert operations previously done at probe(). Nothing prevents device_has_driver_override() to return a different value when called at probe() and when called at remove(). Indeed, a user can set driver_override (or clear it) after the probe() call and before the remove() call. In that case, inconsistencies are present between pm_runtime_enable() called at probe() and pm_runtime_disable() called at remove(). In order to ensure that pm_runtime_disable() is called only if pm_runtime_enable() has been called at probe(), use the devres version of pm_runtime_enable(). Reported-by: Sashiko Link: https://lore.kernel.org/all/20260630105701.7D0471F00A3A@smtp.kernel.org/ Fixes: 98e96cf80045 ("drivers: bus: simple-pm-bus: Add support for probing simple bus only devices") Cc: stable@vger.kernel.org Signed-off-by: Herve Codina --- drivers/bus/simple-pm-bus.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c index c920bd6fbaaf..4322a778e801 100644 --- a/drivers/bus/simple-pm-bus.c +++ b/drivers/bus/simple-pm-bus.c @@ -29,6 +29,7 @@ static int simple_pm_bus_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; const struct of_device_id *match; struct simple_pm_bus *bus; + int ret; /* * Allow user to use driver_override to bind this driver to a @@ -66,7 +67,9 @@ static int simple_pm_bus_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "%s\n", __func__); - pm_runtime_enable(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); + if (ret) + return dev_err_probe(&pdev->dev, ret, "failed enable pm_runtime\n"); if (np) of_platform_populate(np, NULL, lookup, &pdev->dev); @@ -76,14 +79,7 @@ static int simple_pm_bus_probe(struct platform_device *pdev) static void simple_pm_bus_remove(struct platform_device *pdev) { - const void *data = of_device_get_match_data(&pdev->dev); - - if (device_has_driver_override(&pdev->dev) || data) - return; - dev_dbg(&pdev->dev, "%s\n", __func__); - - pm_runtime_disable(&pdev->dev); } static int simple_pm_bus_runtime_suspend(struct device *dev) -- 2.56.0