Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp59697pxu; Thu, 22 Oct 2020 15:28:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjPQhS3Tt67G/NdFcA+pa3CbWLCUKMvvSkaGVAJ7cjq91RykEW/jzfjhEW1uVf18xeELqX X-Received: by 2002:aa7:d988:: with SMTP id u8mr4475134eds.64.1603405686084; Thu, 22 Oct 2020 15:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603405686; cv=none; d=google.com; s=arc-20160816; b=Uos485AY/gN7vENGXgBuVgZxJJlXrOMRq5yY5+iTw0NIDm8DpX515vYqj9WAREQFXa n4lMlwW/opTSB+jKIZQkgdHummBRxG4ZoZAJIlF/jgzA3r1HO0ceOgxAfpemVSO0xszU J7pKOcE9mdelkBF8+EGif6pRx2Ndl2yC2ue91vodrqg4rPyrXIP9zGC2cJy1ZarsLguD 2UxuPM/0DlhFgc2pPpg1d8oNGQ0lqGGdDmPd4hK4NL2apf6SSlJmVvGdmogctZQ9VlrX oiVW2YNoViODLUwyvC1AqXc2O0y2vzJszE2EiyGV1beJ8AP9o+7/sp46io3A4IH9CyTv UWxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=N2lGxpYNheYzOyJ4+48k9UeR6aAynIg0jYzo7DuaBIs=; b=vwEFiWqtdiH5ovA+VblzwRI8rumPDqEpq9OWeH7Ym8Yj48M5GuH4gD0sqQWp1jJkvg xciRQs+PjhTh0iNW+YaGly4d/XKSBKAgU57Yb3DUlDiznX/otkwP7Xv3HDBENxEl2EKP otneEYHviiFgcwMBs2Su5GtANMFEhXQV6vssbIbNTWdstHjlb+HySa0XXA79gGbL63E6 thXrqm5K+sVCZ5erc6h0mn5hnCaHGPEgxj0RHeat2/RZW8qnOvcN1FD25r63899E4oYM j3ISRW8DdOxhWxTtDF/JHPqtVpJnd7NrgDyobPALWZvXAoSZpHBnvgWy/mAXFsL4MKOk m3SA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a14si2042871edn.216.2020.10.22.15.27.43; Thu, 22 Oct 2020 15:28:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2507751AbgJVNkl (ORCPT + 99 others); Thu, 22 Oct 2020 09:40:41 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:53746 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2437595AbgJVNkk (ORCPT ); Thu, 22 Oct 2020 09:40:40 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9CE98CCD67AE021F82B3; Thu, 22 Oct 2020 21:40:37 +0800 (CST) Received: from [127.0.0.1] (10.74.219.194) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Thu, 22 Oct 2020 21:40:35 +0800 Subject: Re: [PATCH 3/3] PM: runtime: Resume the device earlier in __device_release_driver() To: "Rafael J. Wysocki" , Greg Kroah-Hartman References: <6543936.FbWAdBN1tG@kreacher> <1708806.S9fAqql2gf@kreacher> CC: Linux PM , LKML , Lukas Wunner , Saravana Kannan From: "chenxiang (M)" Message-ID: Date: Thu, 22 Oct 2020 21:40:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1708806.S9fAqql2gf@kreacher> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.74.219.194] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > } > > - pm_runtime_get_sync(dev); > - > driver_sysfs_remove(dev); > > if (dev->bus) > > > > > . >