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: 248840 Delivered-To: patches@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4017785ilg; Tue, 1 Sep 2020 01:27:19 -0700 (PDT) X-Received: by 2002:a05:651c:110d:: with SMTP id d13mr8651ljo.206.1598948839553; Tue, 01 Sep 2020 01:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598948839; cv=none; d=google.com; s=arc-20160816; b=Ads8rXGfhn8iRQWrArx4Ae6eKAc1++ln2lH0fsE9yzgS2SiFnHT6GXkAMnk0y8kSIw XNBX/UT4+v331ZgSMjo76C9gicNcUryp3dvoUAwxJtY/ltgKspawF2mSS1rAjLK+xzUJ YhN1TF1K2prK8xOZCgNYTL9mXcO4IkcUZDFF8lpBw4HmXDhSgC/Mq83KwhoLbTl+jcpE Fd62UKP/Ke1oQAAArbPXbkkLkHMEdPBlR/okoTfynk3VtRaLHjxVN3ObxXkOFQ26O+9D QqyPfy4oo2zCa1VTq/P/HxISHqtWGJkOGLBFJDA/GRDHPxDMSsalWAmN4/KkA+NYJAzE tgTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=lXhXw6gw2mHmJ9Say6lfS63FssmiQ2xQJb+o3xFUf34=; b=Pux+EGILSTdMTiDYpy/UxwT+7aYPG2fHMpn1t6XMbWg9nCBtu///dDkidgEad0qdW2 12VQ+TGdBhYHR+YVGDM7sXmaftnlcMAzleJXXpKh8p25nFoJqBB04t15VkYxri4nr4wT 0Xnv8UhDyFO35dNdVaTdwB83kBOv7o4E4g3AOML3b4MGr7oOokz5y44DMPQmMnl4TbMv 0pz1dsNnHtu4G+GSw5w0Qp+c3eF8UjG5AvOb3qGI18tF8eUmAtiHeKpwJtphBG2UGVx/ sZXsTBBkFXsj2upNuTYhBOFbqQgCiHgTAj9BCHWhhBbr2QcnnVAtiIi+8aW3S6EE5Kgn lsnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zfzrThjF; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d12sor208780ljj.54.2020.09.01.01.27.19 for (Google Transport Security); Tue, 01 Sep 2020 01:27:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zfzrThjF; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=GiryWOmmNWdwUkO630VcmZ3z24VISQAHdZgOQIm7+MFPYbBfowaovZ2PN7IRaSyVWn dApzSufHZ9VOsjtkd4vqgEdmcZkjdhamuXe2sh59lnhYckTSMuMmPo/L7uJzDhsCfVym FVC6VLgghNxamgAm3Z/4F6UqmGDspo6vthERFeNsj9DzW2KWJXiElDvbpsCh8xj2SIum lR72ybDkBQOfMaP8t7XODxQ/0SYPK80AcPGPiTQRNMj6oSQMUUMGnfXxC44DD9jSYgZc VSAJbJlZY9T4iRFcs/s3geYuq/wpWGGCeeGKI4dt34XjQPrsIaTGXTixYszXZY7V990k P9aQ== X-Gm-Message-State: AOAM530ImtQXrsadKBRncYLvIWrq39NjhsJJ0BsLIP6Sm8t2XCNdI1Eq 9pAgkzAxg0Jvk55LTJmjsdGIOJFF 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) Return-Path: 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 Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.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 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(-) -- 2.25.1 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;