From patchwork Fri Jul 9 02:24:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenxiang X-Patchwork-Id: 472146 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C91B5C07E96 for ; Fri, 9 Jul 2021 02:24:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AAAFD61477 for ; Fri, 9 Jul 2021 02:24:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230501AbhGIC0t (ORCPT ); Thu, 8 Jul 2021 22:26:49 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:6773 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbhGIC0t (ORCPT ); Thu, 8 Jul 2021 22:26:49 -0400 Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GLcK54WvBzXr3N for ; Fri, 9 Jul 2021 10:18:33 +0800 (CST) Received: from [127.0.0.1] (10.40.193.166) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 9 Jul 2021 10:24:04 +0800 From: "chenxiang (M)" Subject: Question about __pm_runtime_disable() To: CC: , Linux PM , John Garry Message-ID: <4c65cdd3-05cd-499d-0dd1-b7d6e76372b1@hisilicon.com> Date: Fri, 9 Jul 2021 10:24:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 X-Originating-IP: [10.40.193.166] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Hi Rafael and other guys, I encounter a runtime PM issue: there are four devices, and device 0 is the parent device, and device 1/2/3 are the children devices of device 0. All of them supports runtime PM. But i want to ignore device2 and device3, so that if device 1 is suspended, then device0 can be suspended. I use function pm_runtime_disable() to disable device2 and device3, and device 1 is suspended but device0 is still active. I find that runtime_active_kids of device0 is still 2 though runtime_usage = 0, so it doesn't enter suspend status. And i hack the code of funciton __pm_runtime_disable() to decrease child_count of device's parent as follows, and it works. } Is it appropriate for me to use function pm_runtime_disable() to ignore them (i try function function pm_suspend_ignore_children(), but it ignores all children of the device )? Or does it need to decrease child_count the device's parent in function __pm_runtime_disable() ? Best Regard, Xiang Chen diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index b570848..6ba224b 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1382,6 +1382,8 @@ EXPORT_SYMBOL_GPL(pm_runtime_barrier); */ void __pm_runtime_disable(struct device *dev, bool check_resume) { + struct device *parent = NULL; + spin_lock_irq(&dev->power.lock); if (dev->power.disable_depth > 0) { @@ -1413,6 +1415,10 @@ void __pm_runtime_disable(struct device *dev, bool check_resume) if (!dev->power.disable_depth++) __pm_runtime_barrier(dev); + if (dev->parent) { + parent = dev->parent; + atomic_add_unless(&parent->power.child_count, -1, 0); + } out: spin_unlock_irq(&dev->power.lock);