From patchwork Tue Sep 1 08:27:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11747631 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32BFB14E5 for ; Tue, 1 Sep 2020 08:27:37 +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 0D2542071B for ; Tue, 1 Sep 2020 08:27:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pW7s2Q3p"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zfzrThjF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D2542071B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RnZRC4tqZj5TCo1C56fot/GjL9iOo3Gei3s9ucfWeAQ=; b=pW7s2Q3psIiJScEZm6xBH+akl fNdLT6qEB08OqvrPhaQCR7af0ocDHxaae8fvHKbRu4NAFWRDaN9bGKv07QhaKMJQ3SWND/d8Q/8+7 iOA5GpwvrLH3no9RPdZkYnp8nB8SbXpd4XMqTMtxNG/ap3YfvhfaaogDELA2ISv1Y+MWaQhYfBmBK 5eqYiWfVQ1uyXY2lwDoP2WluT/Lein3ioRdzCWDiYWa27vtU/tXhmiGWDsFv7nlBxsEasWobGm12l diby5Nrypw8VVKwBIonED+Zu9hb7aqK/NgSTL/pwpPVq2QVI/FoL+rNLyw1TjeofNTkY2kk8eJPMC 2Vhzljf7Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kD1dW-0005Mx-3z; Tue, 01 Sep 2020 08:27:26 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kD1dQ-0005LO-R3 for linux-arm-kernel@lists.infradead.org; Tue, 01 Sep 2020 08:27:22 +0000 Received: by mail-lj1-x242.google.com with SMTP id c2so445388ljj.12 for ; Tue, 01 Sep 2020 01:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lXhXw6gw2mHmJ9Say6lfS63FssmiQ2xQJb+o3xFUf34=; b=zfzrThjFMwF1c1XHJi778ZPH/w59mrO8rbDIg8IHZiiE0F8rQSGJCpKFoeWGheWK96 Idd0WZeKs/qriujA6iGr594rONIcY2Pe1Y1GVVQsO4lgvEGU9+96HJPQvxRP13iXjLUj Cz0eNJgi9pyOL2kxRsm79ad9LWMkDThPn4Mcgpbd9Doky3fX2IubA6wmvKv4XemYHSLt 8FabgI94lsEGxTNuzvzvg2tuD5eGP/jQX+/pWz19CWEXnwuwMGAInYbNigJBwfNqAXkQ Y9trrilA+YtBMww71ASpqRvRfImGrLaEL+yZObCcq/97LXeMmI3a6o0LdkJx2aY4/GhX IOCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lXhXw6gw2mHmJ9Say6lfS63FssmiQ2xQJb+o3xFUf34=; b=Q9KQzmikzwD0ZpNbNfsldJLhSqQ+D/kDEX6XwQBOYFZ50rqJG2uwN98Qi6sU5syQin MluL40AMEUi/xDpi/5zN4SajhfNrLAQtOWnEU1QGTj22HZ2VzrphtEbhSYVa55e0PCUW dBK2qlpbVrfdAjkTceFTf7NdETOSSVSekbcCZ1HusFcy0ellp71gAL82n2gJJVq0NYi/ fH8CpmOAGKy6b5qkJvbfF5nFh30GimmEbyKIHfzJQKTnaJHjCSii77uwI+t2pVCyeJcR oxj/urAQ3JOYmTXDNlrhojPXKWyv/Nk04/aSu00pUc4Yf6HZJ5Z7tEbiDB8k8lcplvrQ fBTg== X-Gm-Message-State: AOAM5310z1HDVZmjuA/5fUtK6Uc0DWE0aflxSqC2At8g7QqsxgWgTngW dBcziKybfMlmaiMK7fENjkAH/A== X-Google-Smtp-Source: ABdhPJzVe2jkEa7XevmysGxEov7CVQX9Xjx6o7FSE+FdPUQgf+fKxVXEDSf0N3C1OuCCKppIMFQdzw== X-Received: by 2002:a05:651c:110:: with SMTP id a16mr12283ljb.152.1598948839148; Tue, 01 Sep 2020 01:27:19 -0700 (PDT) Received: from localhost.localdomain (h-98-128-180-79.NA.cust.bahnhof.se. [98.128.180.79]) by smtp.gmail.com with ESMTPSA id c5sm111252lfb.24.2020.09.01.01.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 01:27:18 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH 2/2] cpuidle: psci: Enable s2idle when using OSI with the PM domain topology Date: Tue, 1 Sep 2020 10:27:07 +0200 Message-Id: <20200901082707.106860-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200901082707.106860-1-ulf.hansson@linaro.org> References: <20200901082707.106860-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200901_042720_920574_383A7154 X-CRM114-Status: GOOD ( 19.69 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: Ulf Hansson , Vincent Guittot , Benjamin Gaignard , Stephen Boyd , Daniel Lezcano , "Rafael J . Wysocki" , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, Lukasz Luba Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. 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. 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. 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); state = psci_get_domain_state(); if (!state) @@ -74,7 +79,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev, ret = psci_cpu_suspend_enter(state) ? -1 : idx; - pm_runtime_get_sync(pd_dev); + if (s2idle) + pm_genpd_syscore_poweron(pd_dev); + else + pm_runtime_get_sync(pd_dev); cpu_pm_exit(); @@ -83,6 +91,19 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev, return ret; } +static int psci_enter_domain_idle_state(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + return __psci_enter_domain_idle_state(dev, drv, idx, false); +} + +static int psci_enter_s2idle_domain_idle_state(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int idx) +{ + return __psci_enter_domain_idle_state(dev, drv, idx, true); +} + static int psci_idle_cpuhp_up(unsigned int cpu) { struct device *pd_dev = __this_cpu_read(psci_cpuidle_data.dev); @@ -170,6 +191,7 @@ static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv, * deeper states. */ drv->states[state_count - 1].enter = psci_enter_domain_idle_state; + drv->states[state_count - 1].enter_s2idle = psci_enter_s2idle_domain_idle_state; psci_cpuidle_use_cpuhp = true; return 0;