From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 04C67C4727C for ; Thu, 1 Oct 2020 10:18:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD4DC20838 for ; Thu, 1 Oct 2020 10:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725975AbgJAKSD (ORCPT ); Thu, 1 Oct 2020 06:18:03 -0400 Received: from foss.arm.com ([217.140.110.172]:58128 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbgJAKSD (ORCPT ); Thu, 1 Oct 2020 06:18:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4074ED6E; Thu, 1 Oct 2020 03:18:02 -0700 (PDT) Received: from bogus (unknown [10.57.52.244]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 627973F70D; Thu, 1 Oct 2020 03:17:59 -0700 (PDT) Date: Thu, 1 Oct 2020 11:17:56 +0100 From: Sudeep Holla To: Ulf Hansson Cc: Lorenzo Pieralisi , linux-pm@vger.kernel.org, "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Sudeep Holla , Benjamin Gaignard , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/2] cpuidle: psci: Enable s2idle when using OSI with the PM domain topology Message-ID: <20201001101756.GB906@bogus> References: <20200901082707.106860-1-ulf.hansson@linaro.org> <20200901082707.106860-3-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200901082707.106860-3-ulf.hansson@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Tue, Sep 01, 2020 at 10:27:07AM +0200, Ulf Hansson wrote: > To select domain idle states for cpuidle-psci, the PM domains via genpd are > being managed by using runtime PM. This works fine for the regular idle > path, but it doesn't when doing s2idle. > > More precisely, the domain idle states becomes temporarily disabled, which > is because the PM core disables runtime PM for devices during system > suspend. When you refer system suspend above, you mean both S2R and S2I ? > Even if genpd tries to power off the PM domain in the > suspend_noirq phase, that doesn't help to properly select a domain idle > state, as this needs to be done on per CPU basis. > And what prevents doing per CPU basis ? > Let's address the issue by enabling the syscore flag for the attached CPU > devices. This prevents genpd from trying to power off the corresponding PM > domains in the suspend_noirq phase. Moreover, let's assign a specific > ->enter_s2idle() callback for the corresponding domain idle state and let > it invoke pm_genpd_syscore_poweroff|poweron(), rather than using runtime > PM. > The syscore_suspend is not executed for S2I and using syscore APIs here is bit confusing IMO. If Rafael is fine, I have no objections. > Signed-off-by: Ulf Hansson > --- > drivers/cpuidle/cpuidle-psci-domain.c | 2 ++ > drivers/cpuidle/cpuidle-psci.c | 30 +++++++++++++++++++++++---- > 2 files changed, 28 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c > index b6e9649ab0da..65437ba5fa78 100644 > --- a/drivers/cpuidle/cpuidle-psci-domain.c > +++ b/drivers/cpuidle/cpuidle-psci-domain.c > @@ -324,6 +324,8 @@ struct device *psci_dt_attach_cpu(int cpu) > if (cpu_online(cpu)) > pm_runtime_get_sync(dev); > > + dev_pm_syscore_device(dev, true); > + > return dev; > } > > diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c > index 74463841805f..6322d55a0a7d 100644 > --- a/drivers/cpuidle/cpuidle-psci.c > +++ b/drivers/cpuidle/cpuidle-psci.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -52,8 +53,9 @@ static inline int psci_enter_state(int idx, u32 state) > return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, idx, state); > } > > -static int psci_enter_domain_idle_state(struct cpuidle_device *dev, > - struct cpuidle_driver *drv, int idx) > +static int __psci_enter_domain_idle_state(struct cpuidle_device *dev, > + struct cpuidle_driver *drv, int idx, > + bool s2idle) > { > struct psci_cpuidle_data *data = this_cpu_ptr(&psci_cpuidle_data); > u32 *states = data->psci_states; > @@ -66,7 +68,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev, > return -1; > > /* Do runtime PM to manage a hierarchical CPU toplogy. */ > - pm_runtime_put_sync_suspend(pd_dev); > + if (s2idle) > + pm_genpd_syscore_poweroff(pd_dev); > + else > + pm_runtime_put_sync_suspend(pd_dev); Since CPU genpd is special and handled so in core, can this be moved to core ? I mean pm_runtime_put_sync_suspend handle that based genpd_is_cpu_domain. -- Regards, Sudeep From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 353C7C4727C for ; Thu, 1 Oct 2020 10:19:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB81321531 for ; Thu, 1 Oct 2020 10:19:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nfvYR+Uj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB81321531 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7JtjCSm0QYlsUuEXE7JVSKR+agZl/RCu/srhOmFlqaA=; b=nfvYR+UjkBZJEKgwgNLxPL0R2 hVyegiW4UZ0lTZo3kcvYD0Iy98vftz6Fc8WkM2ovvef/6BErCFm+QeMtndsnKQ6h2hCdEMAGFhH5e 2kXvZudQKfZ25JTF/faD8lXkpSVe5OfNBTbyUKE+3OuA+qRWB97G9uICGhqy4KK+Mee2h21RQRVbd t7QNd1zvcxfwpa5eRAk/m8kKwVq2mJfw/zZP8MoqU82w4h1VsB9H99TNcJamo/PR7ILwTMR92K+lT wLBIWnZmilV85/8SXambmHpccHCHJInweaK7TmSc21MEHLxQMA8VoWvdbiNVcZVQmqOIOshiD2hLs PJRVXI5Pg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNvf5-0002JA-0H; Thu, 01 Oct 2020 10:18:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNvf2-0002Ia-R2 for linux-arm-kernel@lists.infradead.org; Thu, 01 Oct 2020 10:18:05 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4074ED6E; Thu, 1 Oct 2020 03:18:02 -0700 (PDT) Received: from bogus (unknown [10.57.52.244]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 627973F70D; Thu, 1 Oct 2020 03:17:59 -0700 (PDT) Date: Thu, 1 Oct 2020 11:17:56 +0100 From: Sudeep Holla To: Ulf Hansson Subject: Re: [PATCH 2/2] cpuidle: psci: Enable s2idle when using OSI with the PM domain topology Message-ID: <20201001101756.GB906@bogus> References: <20200901082707.106860-1-ulf.hansson@linaro.org> <20200901082707.106860-3-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200901082707.106860-3-ulf.hansson@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201001_061804_960765_32DD094C X-CRM114-Status: GOOD ( 25.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Vincent Guittot , Benjamin Gaignard , linux-pm@vger.kernel.org, Stephen Boyd , Daniel Lezcano , "Rafael J . Wysocki" , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, Sudeep Holla , Lukasz Luba Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Sep 01, 2020 at 10:27:07AM +0200, Ulf Hansson wrote: > To select domain idle states for cpuidle-psci, the PM domains via genpd are > being managed by using runtime PM. This works fine for the regular idle > path, but it doesn't when doing s2idle. > > More precisely, the domain idle states becomes temporarily disabled, which > is because the PM core disables runtime PM for devices during system > suspend. When you refer system suspend above, you mean both S2R and S2I ? > Even if genpd tries to power off the PM domain in the > suspend_noirq phase, that doesn't help to properly select a domain idle > state, as this needs to be done on per CPU basis. > And what prevents doing per CPU basis ? > Let's address the issue by enabling the syscore flag for the attached CPU > devices. This prevents genpd from trying to power off the corresponding PM > domains in the suspend_noirq phase. Moreover, let's assign a specific > ->enter_s2idle() callback for the corresponding domain idle state and let > it invoke pm_genpd_syscore_poweroff|poweron(), rather than using runtime > PM. > The syscore_suspend is not executed for S2I and using syscore APIs here is bit confusing IMO. If Rafael is fine, I have no objections. > Signed-off-by: Ulf Hansson > --- > drivers/cpuidle/cpuidle-psci-domain.c | 2 ++ > drivers/cpuidle/cpuidle-psci.c | 30 +++++++++++++++++++++++---- > 2 files changed, 28 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c > index b6e9649ab0da..65437ba5fa78 100644 > --- a/drivers/cpuidle/cpuidle-psci-domain.c > +++ b/drivers/cpuidle/cpuidle-psci-domain.c > @@ -324,6 +324,8 @@ struct device *psci_dt_attach_cpu(int cpu) > if (cpu_online(cpu)) > pm_runtime_get_sync(dev); > > + dev_pm_syscore_device(dev, true); > + > return dev; > } > > diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c > index 74463841805f..6322d55a0a7d 100644 > --- a/drivers/cpuidle/cpuidle-psci.c > +++ b/drivers/cpuidle/cpuidle-psci.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -52,8 +53,9 @@ static inline int psci_enter_state(int idx, u32 state) > return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, idx, state); > } > > -static int psci_enter_domain_idle_state(struct cpuidle_device *dev, > - struct cpuidle_driver *drv, int idx) > +static int __psci_enter_domain_idle_state(struct cpuidle_device *dev, > + struct cpuidle_driver *drv, int idx, > + bool s2idle) > { > struct psci_cpuidle_data *data = this_cpu_ptr(&psci_cpuidle_data); > u32 *states = data->psci_states; > @@ -66,7 +68,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev, > return -1; > > /* Do runtime PM to manage a hierarchical CPU toplogy. */ > - pm_runtime_put_sync_suspend(pd_dev); > + if (s2idle) > + pm_genpd_syscore_poweroff(pd_dev); > + else > + pm_runtime_put_sync_suspend(pd_dev); Since CPU genpd is special and handled so in core, can this be moved to core ? I mean pm_runtime_put_sync_suspend handle that based genpd_is_cpu_domain. -- Regards, Sudeep _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel