Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3250349rwl; Sun, 2 Apr 2023 03:53:33 -0700 (PDT) X-Google-Smtp-Source: AKy350buH8OYwAbALQRJJD2MiWY2q4ld1iKtlnUaQ2ydW/FpRR8JMv/PTOTfzG9DWeLFRw5UjeQm X-Received: by 2002:a17:903:2844:b0:19e:73a9:c21b with SMTP id kq4-20020a170903284400b0019e73a9c21bmr28784081plb.45.1680432813556; Sun, 02 Apr 2023 03:53:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680432813; cv=none; d=google.com; s=arc-20160816; b=XsobMkaTo0WJP+MRJSwdXRKtecoLTeX2jKV/7YLGwa5IdhGuyRmXXFKE26PosJznJP IbqHXiw7nr4/lAa1udJGdVT9F0px4KFNawFPveDN7wjZIXY67VXgUFZGP8p0Bf6onodV 2G9GlgJdF9hxkLLaQ7pjqRtjl63zkEpOkmU9VXLoDPF/LmOGtag5z1YB0CDVAIqGQvrH 4+AjPn7AKISgkTYR9ufDGItHjhwFRup8yhHURZ04wvikWlHtMWjAyiCGbIMD1ItBL2ou /NIhZsKANg2njdkXYVAeAnhtwbA8yjZGynYpC9dlMdWi0QdmHyWzVDWeQmZ8euHHWH9u oLeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=iwVTPqyXaA7lq/yXyAskoEyYBgxU2FvvvPnW5iYzaeM=; b=LMWp7+aZ6kSXrhJEoZZdFs/XTIJZ6/+RPJ1bUHbhgk8HgKOEsv909wg5NBpQejQl9p Aawyhg0f+nyVZLG8EG1fgECWuogcSRVcPj+cAgtRppdtgXH/prR7hwWcWzThuSYh1lMi v3W4j2cG+gx+56JBajy3Lz2d/P+u/o8r3EewwrBQ9qpd0FkBmNOT7St9IEXsTw8Fe12a UYphT+JFUtsZitCt8DXql1pAwZ7ZVw5uzCu7/Ms4UrJPi6VyIITTQ4UdajuG+0r7HrsF cDJ/I9g47J8HLhoy+T2u4t8rR59y2AWH7+Kjx7qs0Fwsk5AniB4I/7BE1ypUh5occkh4 xjMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a63b303000000b004fbc70b72cesi454762pgf.771.2023.04.02.03.53.21; Sun, 02 Apr 2023 03:53:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230271AbjDBKkG (ORCPT + 99 others); Sun, 2 Apr 2023 06:40:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjDBKkE (ORCPT ); Sun, 2 Apr 2023 06:40:04 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ABC211EB4 for ; Sun, 2 Apr 2023 03:40:03 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1piv7v-0006tR-Ry; Sun, 02 Apr 2023 12:39:59 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1piv7v-008QnH-1T; Sun, 02 Apr 2023 12:39:59 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1piv7u-009wdU-3H; Sun, 02 Apr 2023 12:39:58 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: "Rafael J . Wysocki" , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH RFC] PM: runtime: Drop device usage only after remove is done Date: Sun, 2 Apr 2023 12:39:51 +0200 Message-Id: <20230402103951.2510773-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1132; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=OwxwmIKy2FteW/idb53cSJwTf/azfHPSb/pvNvtIfZk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBkKVt24IsjqrU6OjFcCEbuoukKPpqOuraJJ4cT8 vbfjV7XCsmJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZClbdgAKCRCPgPtYfRL+ TuAeB/0fFBunTODyu0Ux6drM0CqTKwcuxZqIwRBw9axgz5Pf8pM7kX6SE92K+kzNzGc34n3aDIK TQvludfF2wS2ZDX94uz5yfaPmSId1fkKxl7iqFp8OklGHKWUd/1QtpISzgZmIjB5w5Ya6TzwelT Ggudv/W8C2diVHqDWdKpiOfFV32AF0IocWHRRBWGZaEglY+IkBGS7tf8wRCJ2Ygl0J+OAmq7n5q K7NXzO1mZlZcrTSYPJHZ/jHr3QtZtvkjqbNwRyBsim5zhrV2+WrqbbQRjFVhtBaxGAdtQJPh+8R w+q1McUZ8srxFzfeYdd8xmqUKWFFKIha0XdCy/AuzIuJmiIs X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Many device drivers call one of the variants of pm_runtime_resume() in their remove callback. So calling pm_runtime_put_sync() just before that is ineffective as the suspend callback might just be called just to resume the device directly afterwards again. Signed-off-by: Uwe Kleine-König --- Hello, this is a theoretical issue that I noticed while doing some research how pm-runtime works. Not sure it makes sense, so I marked it as RFC. Best regards Uwe drivers/base/dd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 8def2ba08a82..6beac141d3d2 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1235,10 +1235,10 @@ static void __device_release_driver(struct device *dev, struct device *parent) bus_notify(dev, BUS_NOTIFY_UNBIND_DRIVER); - pm_runtime_put_sync(dev); - device_remove(dev); + pm_runtime_put_sync(dev); + if (dev->bus && dev->bus->dma_cleanup) dev->bus->dma_cleanup(dev); base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6 -- 2.39.2