From patchwork Tue Feb 26 14:54:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 159214 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3303886jad; Tue, 26 Feb 2019 06:54:32 -0800 (PST) X-Received: by 2002:a19:5205:: with SMTP id m5mr13836725lfb.61.1551192872168; Tue, 26 Feb 2019 06:54:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551192872; cv=none; d=google.com; s=arc-20160816; b=0TjpcPlhL5p+fjTmz7G+PFhAAtUUnJqm433tUnpNfdi7gpM26TtaMxdZxFC6tOTG0V BRuIb5fIHzul5XqlhsJhvlY6h4sBhByrzIehfT+agZuSTP3s1NoBemCJ6U6thy/N8r7g PzeTvp2Fp3ChZ5zpBssjNGFBFr803p9IvxcmjRIg7rvtIPQ4l/kOpS9ABppc+JFUpxhf 0drq0Pn4ln+7QTNlQmbS4XE6jcqrXZ4eeg70Ad2PafSCRCFN8yJRtrbQcMvKwpmoZz+x hdOgmq112s2LYY5PSW8woAnShvpyNuujBUa1JE5VRqmYk3rJCeykFFXHSB7Rk4z/UQrz svUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=bAWEQtmf+fggjn633EQ0gBHasaIotZNQ6JNtd1TnYlY=; b=qd802mp1mcZi0nQ3yTsNuuGmQgiM94HQ0vsoRsOILrzmbXmSNG/rX7b6sEzEtHPDCx SMGA32cQsHDWXGFwk3qtt3K89rr7ZP9Ld1x6EK3S1PeslOTiR/jgqr+SRdSPJ8PyzrlA U5tTD5spL55CbCaAFpBjIY2DocDvjEyMJmaiyOIt7eX7fE+e733DQEth9jGpBNeuGUxD vlFsqxjCLeQ5ko4ne24hpYnR6gW2sDBelD/Tv7kDL6xXNbCo4YDREgaWOU5myOpkjqny sRkGxVe4fqm4y5TVl7vaJ6fSib5Ck7Z3zLBdgicGo2mApZIwiGQIrXgAsTxQfPeaMe+8 0ryA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yEhuYlCn; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@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 z84sor7236743ljb.26.2019.02.26.06.54.31 for (Google Transport Security); Tue, 26 Feb 2019 06:54:32 -0800 (PST) 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=yEhuYlCn; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@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; bh=bAWEQtmf+fggjn633EQ0gBHasaIotZNQ6JNtd1TnYlY=; b=yEhuYlCnoHOeoTTeypOCSSGycNr6eghlJAYY/0Qk/w47J4Xm7zDOZWXf3VzOryDoFH JUK9D/277P9gzy0yI1MPay9RVdBQBSrIIqwFVv/mnGXNTCWa3O84uGSBtMAt5Rbp8/sU QhhjCK7dXpC+PmeW5EF7+3YKj7RZyPEHoZEtKbuHv0dA8+Zk6uaoqmEnUu9XdBrRd657 Qp6OrgrPjz4PBgXbIowa4MZAZIYLGSiRyKtuL9sXs+yMInHRPT+XHbXSJXLLn44zr/n2 HppDP59Xbtzej/fU50ecScZMDnuAVHKTTjw79ZYu9ACC36wh7VFAtudJ4Dq8a2eivgkc uidQ== 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; bh=bAWEQtmf+fggjn633EQ0gBHasaIotZNQ6JNtd1TnYlY=; b=fsaCloqnN0Uh2T7qgVqRDEPV238wijcQkJUcnJRWpdsqgOrGdqu4CCQoTGe7Zc8rKb haLofJR75Qgn4jHgYXsquTYv9xOcrPEEamraCrfzntnLLqDIRrnvFJ5YK7bqc9QaeXm2 p2YHjNgfMw3pN+cSZvpZd51OAWqGzBb/P9RyeXGFI/siawWUbPdCmMQB/7n8aONNyKP4 C9y9neRiO7V/xtLAsncTosvSkBuVIQy4ejG5qoBpSp6g948FXzsuHHLrB9KZFhB2ZqTI wosO7gHLwVS7IM337YXGqr+ZMWHyXLzm4Kuh1sIlKcD6MUoI8x+WsZIrWiQcA+OlID0T Bf4w== X-Gm-Message-State: AHQUAuZsuLWViCIVBWqfqj5J2dziZtxahJ5rz4Ajqp6n4RFCYctnKvPW RzASrxUAoJTWARHooba7Gic0DTKi X-Google-Smtp-Source: AHgI3IY7Fh/iJB1rM3CbMbsCZao4labBAhvTuxuXpfkMpQyUIWovpYBREFulbYA+w07Ewxce5yxHLA== X-Received: by 2002:a2e:964b:: with SMTP id z11mr12327938ljh.138.1551192871604; Tue, 26 Feb 2019 06:54:31 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t11sm2206554ljj.92.2019.02.26.06.54.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 06:54:30 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Frederic Weisbecker , Thomas Gleixner , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 0/8] PM / Domains: Support hierarchical CPU arrangement (PSCI/ARM) Date: Tue, 26 Feb 2019 15:54:07 +0100 Message-Id: <20190226145415.19411-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Changes in v11: - This version contains only the infrastructure changes that is needed for deployment. The PSCI/ARM changes have also been updated and tested, but I will post them separately. Still, to provide completeness, I have published a branch containing everything to a git tree [1], feel free to have a look and test. - The v10 series contained a patch, "timer: Export next wakeup time of a CPU", which has been replaced by a couple of new patches, whom reworks the existing tick_nohz_get_sleep_length() function, to provide the next timer expiration instead of the duration. - More changelogs are available per patch. Changes in v10: - Quite significant changes have been to the PSCI driver deployment. According to an agreement with Lorenzo, the hierarchical CPU layout for PSCI should be orthogonal to whether the PSCI FW supports OSI or not. This has been taken care of in this version. - Drop the generic attach/detach helpers of CPUs to genpd, instead make that related code internal to PSCI, for now. - Fix "BUG: sleeping for invalid context" for hotplug, as reported by Raju. - Addressed various comments from version 8 and 9. - Clarified changelogs and re-wrote the cover-letter to better explain the motivations behind these changes. Background: For ARM64/ARM based platforms CPUs are often arranged in a hierarchical manner. >From a CPU idle state perspective, this means some states may be shared among a group of CPUs (aka CPU cluster). To deal with idle management of a group of CPUs, sometimes the kernel needs to be involved to manage the last-man standing algorithm, simply because it can't rely solely on power management FWs to deal with this. Depending on the platform, of course. There are a couple of typical scenarios for when the kernel needs to be in control, dealing with synchronization of when the last CPU in a cluster is about to enter a deep idle state. 1) The kernel needs to carry out so called last-man activities before the CPU cluster can enter a deep idle state. This may for example involve to configure external logics for wakeups, as the GIC may no longer be functional once a deep cluster idle state have been entered. Likewise, these operations may need to be restored, when the first CPU wakes up. 2) Other more generic I/O devices, such as an MMC controller for example, may be a part of the same power domain as the CPU cluster, due to a shared power-rail. For these scenarios, when the MMC controller is in use dealing with an MMC request, a deeper idle state of the CPU cluster may needs to be temporarily disabled. This is needed to retain the MMC controller in a functional state, else it may loose its register-context in the middle of serving a request. In this series, we are extending the generic PM domain (aka genpd) to be used for also CPU devices. Hence the goal is to re-use much of its current code to help us manage the last-man standing synchronization. Moreover, as we already use genpd to model power domains for generic I/O devices, both 1) and 2) can be address with its help. Moreover, to address these problems for ARM64 DT based platforms, we are deploying support for genpd and runtime PM to the PSCI FW driver - and finally we make some updates to two ARM64 DTBs, as to deploy the new PSCI CPU topology layout. The series has been tested on a Qcom 410c dragonboard and on a Hisilicon Hikey board. The first one uses PSCI OS-initiated mode, while the second uses the PSCI Platform-Coordinated mode. Kind regards Ulf Hansson [1] git.linaro.org/people/ulf.hansson/linux-pm.git next_v11 Daniel Lezcano (4): time: tick-sched: Provide helpers to get the next timer expiration cpuidle: menu: Convert to tick_nohz_get_next_timer|hrtimer() cpuidle: teo: Convert to tick_nohz_get_next_timer() time: tick-sched: Remove tick_nohz_get_sleep_length() Ulf Hansson (4): PM / Domains: Add a generic data pointer to the genpd_power_state struct PM / Domains: Add support for CPU devices to genpd cpuidle: Pre-store next timer/tick before selecting an idle state PM / Domains: Add genpd governor for CPUs drivers/base/power/domain.c | 78 ++++++++++++++++++++++++++-- drivers/base/power/domain_governor.c | 62 +++++++++++++++++++++- drivers/cpuidle/cpuidle.c | 2 + drivers/cpuidle/governors/menu.c | 14 ++++- drivers/cpuidle/governors/teo.c | 4 +- include/linux/cpuidle.h | 2 + include/linux/pm_domain.h | 20 ++++++- include/linux/tick.h | 11 ++-- kernel/time/tick-sched.c | 71 +++++++++++++++++-------- 9 files changed, 229 insertions(+), 35 deletions(-) -- 2.17.1 Signed-off-by: Ulf Hansson