Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp4020555pxm; Tue, 1 Mar 2022 09:37:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzh5/9lsxxzedTvR8uRjTH6uVpxlIo8fDAk/jCqxKMg1n48fGm7CqqZjq6NA1HVwpGAcT6k X-Received: by 2002:a17:902:7043:b0:14f:47:a455 with SMTP id h3-20020a170902704300b0014f0047a455mr26768874plt.44.1646156241999; Tue, 01 Mar 2022 09:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646156241; cv=none; d=google.com; s=arc-20160816; b=Idc6ZfcIwcWfe1f89XOCF+fQZ0q9/EISj3RTx9oRZsRYcGgykDwdFOpmLqHO+WXBWK wLcv/qBmOm4ssH+V4psg4cas6inhQAupxwaBh++6lo6eCIaKJNKR83b9eN5zvfEb5EDJ aweYAIOdCx/QKd2/EQeegrEuN07A3ipjrlTLa8YRa4buQU0cExvqjZRC1y2jTJnLTrSW 453+eSliOseURcWdfszoSYbHfsEEVWmUFvJ1wG7l0A+vkRPunhnTbhG9K3djzBffE0Wy ZaTbznMechy52325DPnvmtxHbQ1qFnbt6EeGPWiUY4+faAAXD653gXHe3lnKDRskWYqL +D2Q== 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=eOQjC5X2h+0/02vts4OH5etlUvBGGK8ceOSnA2de0iw=; b=CTHCTl2CoYxVViwTOckco7l7v5BZfm6NyXjAlAXLpGElsGd/qG7+0CK4BBtFi4lBis bfQJOBujn72ecn5DCPQ6hRXz39GhXG7qEsF47WBQGCzUQyIkabIbCoxdYv2VuB2dQOBe QFaKfAoMTWmSbkMc2srAYs2vXSScI9Z6euILoN72AJJbLGJ5EJ65QYdLBqXQcq9hS8/L 3Rf4pVeWsgl9HiXyy89JrIzkpZ7CgnYqsAs4Aqk1NSL76NJzry62W6ZhuppK1znxY4o+ aYc4TEwqq6gi/87hqJTZ3eWmYm/I4SnqN3jFHkd5fWv+sbHnfeAtrtimwjGP9d7NIz3+ iIZQ== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a056a0008c200b004f0f268ebdfsi13326561pfu.266.2022.03.01.09.37.02; Tue, 01 Mar 2022 09:37:21 -0800 (PST) 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235475AbiCAO5Z convert rfc822-to-8bit (ORCPT + 99 others); Tue, 1 Mar 2022 09:57:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232020AbiCAO5Y (ORCPT ); Tue, 1 Mar 2022 09:57:24 -0500 Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F10A252C; Tue, 1 Mar 2022 06:56:43 -0800 (PST) Received: by mail-yb1-f174.google.com with SMTP id y189so27705991ybe.4; Tue, 01 Mar 2022 06:56:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=IXZ6ThxTiXXN8hNTJoySMR/9n+H4s9P6qNdmGcFsy2Q=; b=MdUQUBRsDNA+wOEUTzWxtUuCU3uL4lpd53OVuv1yCclnphxELJ3fPI/g+GvvRLY0Eh rHnYp60s11hbvCdDn4XTsL++LK0V/St28Q8oRvhM78PK42Iq1BrXlOntonRL1DybaGyN vliqg6/Iq9Ku05Q0AQlVcrgeHxvsSnRTCHctT8beiNvtTcOCh+efIh9hP9wnl5z7Q+IB cu+umm8HoHI9HhDCFnDOwAJMAQ8hKR7PuA1EuGVqifYrJu/nzdv03AKPpQ0ha5zWATIR Th3v35UFEXms2qsheFem4nDxtDF9ON0rBJkPJBUwSfM0R70wN2sliCCY6+uLGVsUN14l oTEA== X-Gm-Message-State: AOAM530f9rXkNyzqqOfWOMQiShZcEaiLbKmHsFPOlwLCWCM55UnLrCaJ OJLBOD8pTA93kdCxxg7QCg6Nlr5h8sPb+R3JVOA= X-Received: by 2002:a25:24d7:0:b0:628:79dc:1250 with SMTP id k206-20020a2524d7000000b0062879dc1250mr2985360ybk.153.1646146602616; Tue, 01 Mar 2022 06:56:42 -0800 (PST) MIME-Version: 1.0 References: <20220217124950.211354-1-ulf.hansson@linaro.org> In-Reply-To: From: "Rafael J. Wysocki" Date: Tue, 1 Mar 2022 15:56:31 +0100 Message-ID: Subject: Re: [PATCH v2] PM: domains: Prevent power off for parent unless child is in deepest state To: Ulf Hansson Cc: Dmitry Osipenko , "Rafael J . Wysocki" , Linux PM , Kevin Hilman , Alexandre Torgue , Geert Uytterhoeven , Rajendra Nayak , Dong Aisheng , Linux ARM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 On Mon, Feb 28, 2022 at 9:56 AM Ulf Hansson wrote: > > On Fri, 18 Feb 2022 at 00:11, Dmitry Osipenko wrote: > > > > 17.02.2022 15:49, Ulf Hansson пишет: > > > A PM domain managed by genpd may support multiple idlestates (power-off > > > states). During genpd_power_off() a genpd governor may be asked to select > > > one of the idlestates based upon the dev PM QoS constraints, for example. > > > > > > However, there is a problem with the behaviour around this in genpd. More > > > precisely, a parent-domain is allowed to be powered off, no matter of what > > > idlestate that has been selected for the child-domain. > > > > > > For the stm32mp1 platform from STMicro, this behaviour doesn't play well. > > > Instead, the parent-domain must not be powered off, unless the deepest > > > idlestate has been selected for the child-domain. As the current behaviour > > > in genpd is quite questionable anyway, let's simply change it into what is > > > needed by the stm32mp1 platform. > > > > > > If it surprisingly turns out that other platforms may need a different > > > behaviour from genpd, then we will have to revisit this to find a way to > > > make it configurable. > > > > > > Signed-off-by: Ulf Hansson > > > --- > > > > > > Changes in v2: > > > - Clarified commit message - based upon discussions with Dmitry. > > > - Updated a comment in the code, suggested by Dmitry. > > > > > > --- > > > drivers/base/power/domain.c | 19 +++++++++++++++++++ > > > 1 file changed, 19 insertions(+) > > > > > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > > > index 5db704f02e71..c87588c21700 100644 > > > --- a/drivers/base/power/domain.c > > > +++ b/drivers/base/power/domain.c > > > @@ -636,6 +636,18 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, > > > atomic_read(&genpd->sd_count) > 0) > > > return -EBUSY; > > > > > > + /* > > > + * The children must be in their deepest (powered-off) states to allow > > > + * the parent to be powered off. Note that, there's no need for > > > + * additional locking, as powering on a child, requires the parent's > > > + * lock to be acquired first. > > > + */ > > > + list_for_each_entry(link, &genpd->parent_links, parent_node) { > > > + struct generic_pm_domain *child = link->child; > > > + if (child->state_idx < child->state_count - 1) > > > + return -EBUSY; > > > + } > > > + > > > list_for_each_entry(pdd, &genpd->dev_list, list_node) { > > > enum pm_qos_flags_status stat; > > > > > > @@ -1073,6 +1085,13 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock, > > > || atomic_read(&genpd->sd_count) > 0) > > > return; > > > > > > + /* Check that the children are in their deepest (powered-off) state. */ > > > + list_for_each_entry(link, &genpd->parent_links, parent_node) { > > > + struct generic_pm_domain *child = link->child; > > > + if (child->state_idx < child->state_count - 1) > > > + return; > > > + } > > > + > > > /* Choose the deepest state when suspending */ > > > genpd->state_idx = genpd->state_count - 1; > > > if (_genpd_power_off(genpd, false)) > > > > Thank you, looks good. Although, this should be v3. > > > > Reviewed-by: Dmitry Osipenko > > Thanks Dmitry! I think v2 should be correct. At least I haven't sent a > v2 before. :-) > > Rafael, I think this is ready to go, can please pick it up? Applied as 5.18 material, thanks!