Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5876545pxu; Thu, 22 Oct 2020 13:23:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj/9g+OCQHismJN0za4KJUguHI5XUjmjj0KwXebS0be0vW2MyvyMx/hQltm6tzbpmuAY4f X-Received: by 2002:a50:f316:: with SMTP id p22mr3803517edm.201.1603398227452; Thu, 22 Oct 2020 13:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603398227; cv=none; d=google.com; s=arc-20160816; b=Wxj/tUEMYZPpMYvm5qs3H6cf7ztsXD/qI0aaiCgvAnzCBrLmi4GOKVLlVf3Hsc01wR rrFSWv94NLlwPZN08S+ZEFXIQ1oQaMsDAy4ojCV1YvJYh+r7xojt23QhtBqRK0P2DReW 49Fnqnlyga2SFsMOS/ZkaMOx0agZnuVUqxExVTLKhBBX/ZFcxUmdWgMgiFQc6EHoChOM yFXqQeLpvqjfvphapOK4XRNhEPpBjCWo0PMzJlOcyRF7ggFIoro3Ws6lORkld0pG240U Ti2YMPbvmUb2H1EQHYYwiX3Mn0BqQGgXqomoBtVk99WIh2FlzFm78+5ae1+gnd/z3Zdx 7Aeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=zCeucYNo+omd2zLgoFL5F1k9XkmGlE0XAZFm8/Qgi5M=; b=Rl1TTV2LXrJfGQ5u3RQ+1L3+o64xAN2i2fTnHK6T3z5P7Fo1etJAvGzkEBcWHHb1Hr KTWGICtenuyhZAj0gERFUC4+tzu1q7fQCYw1FKu21/91+bII8gTtCE6n7SlSr0OEDGPS 0QRWmshTUDlqs21fThluHfSp6YwU6rtecMIu90bx7B9TZwiJyQUWZOwhba3sI4pzR7Y7 q017qMEZ5srucFgI0m3IwmJOKa4JHpV5npXWAXfxFc7Iwz50jwHZkbWRLo1ad6n4fZZq GKKXIosmR8t7VscYg5lIpWA8GdsrC/cNMM943j5EANthD3QqgpGAaQhzX9F/S3mxQMjd grQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si15570ejh.309.2020.10.22.13.23.24; Thu, 22 Oct 2020 13:23:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2900754AbgJVOQh convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Oct 2020 10:16:37 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:46431 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443913AbgJVOQh (ORCPT ); Thu, 22 Oct 2020 10:16:37 -0400 Received: by mail-oi1-f196.google.com with SMTP id l4so1836639oii.13; Thu, 22 Oct 2020 07:16:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=VmqFptAKOhB1kwEn7QNAQ1eEtfGRIzRebrKouxM4Uzo=; b=Ry3XC5BfnDaBUKmmQN+gJhiUy5BF6QGArnbJYivjXt0T1TqJY85stkTERZtcqlPq0B 0OimRCQli9JtWayF6r9UmWoq0NRWpYIczSCuVDZaokWPQPVdFxvOTmtmFJ7fFI9/4Ssx 8DKSl4kNErzmUziZ4esEPJ6rm8lAGa9Pc5aO96LWB4vus2KneRaqFLenANGCduy1sTh4 2kTsXakchQb4r9GmbxbblAUnPctYmrmUnNLpLGcQFpFP4N1yoZjqjCrj5gCbIyJv4X/f IPPaxuyoWr3OYJM8An+R6tHMPJTqnaKs/Cn8EbcFnGljyyaX8ayMBGMCFK3Z8entjd6O OOiA== X-Gm-Message-State: AOAM533PUmIqMDGE/axFeoVek1mFs7KSIkZtOp9zm6ZVL4+72LXtKM00 ld25Dfun9LyDr9Gim9I0lMiw7smjUl6F675azk3ovuF5 X-Received: by 2002:aca:724a:: with SMTP id p71mr1680623oic.157.1603376195959; Thu, 22 Oct 2020 07:16:35 -0700 (PDT) MIME-Version: 1.0 References: <6543936.FbWAdBN1tG@kreacher> <1708806.S9fAqql2gf@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 22 Oct 2020 16:16:25 +0200 Message-ID: Subject: Re: [PATCH 3/3] PM: runtime: Resume the device earlier in __device_release_driver() To: "chenxiang (M)" Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , Linux PM , LKML , Lukas Wunner , Saravana Kannan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 22, 2020 at 3:40 PM chenxiang (M) wrote: > > Hi Rafael, > > 在 2020/10/22 3:14, Rafael J. Wysocki 写道: > > From: Rafael J. Wysocki > > > > Since the device is resumed from runtime-suspend in > > __device_release_driver() anyway, it is better to do that before > > looking for busy managed device links from it to consumers, because > > if there are any, device_links_unbind_consumers() will be called > > and it will cause the consumer devices' drivers to unbind, so the > > consumer devices will be runtime-resumed. In turn, resuming each > > consumer device will cause the supplier to be resumed and when the > > runtime PM references from the given consumer to it are dropped, it > > may be suspended. Then, the runtime-resume of the next consumer > > will cause the supplier to resume again and so on. > > > > Update the code accordingly. > > > > Signed-off-by: Rafael J. Wysocki > > Fixes: 9ed9895370ae ("driver core: Functional dependencies tracking support") > > Cc: All applicable # All applicable > > --- > > drivers/base/dd.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > Index: linux-pm/drivers/base/dd.c > > =================================================================== > > --- linux-pm.orig/drivers/base/dd.c > > +++ linux-pm/drivers/base/dd.c > > @@ -1117,6 +1117,8 @@ static void __device_release_driver(stru > > > > drv = dev->driver; > > if (drv) { > > + pm_runtime_get_sync(dev); > > + > > while (device_links_busy(dev)) { > > __device_driver_unlock(dev, parent); > > > > @@ -1132,8 +1134,6 @@ static void __device_release_driver(stru > > pm_runtime_put_sync() is required to be called if existed from here. > > > return; Right, I overlooked this, thanks! > > } > > > > - pm_runtime_get_sync(dev); > > - > > driver_sysfs_remove(dev); > > > > if (dev->bus)