From patchwork Wed Mar 27 14:35:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 161260 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp6561493jan; Wed, 27 Mar 2019 07:35:55 -0700 (PDT) X-Received: by 2002:a2e:1257:: with SMTP id t84mr21379603lje.115.1553697355664; Wed, 27 Mar 2019 07:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553697355; cv=none; d=google.com; s=arc-20160816; b=StlsX1x0VAZbxFklPgF8N1kOt4Uxs2T8+BmflD8IKY6zDB6jmIAMzV9WkwrvpNdZIh r4GTDQZ4+rP6vDD81KTq8I9NjAP2wJIRo70X1unlpR6Fc9sXoahXwKzqa568FhoG2cRM Fjq5qpNWghmNvX7xOnc38JIP+3Zsjbf+NrGCvkfMItnH/lcGDJXXgXnfcQ4GJvjntK0R xb1fXU0I+hHod+GfX57vuJMRNbBFnOe+YqhQQNgY+PB/U27Zb0Tl7yU7r7CzKeIawbez 4KSwJ480YcGxdDQkpDsjXd2E9xDYT8RX0xMdlvXI82agPATgm9UKd4ic2t8ziEnH5jgm jxxQ== 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=tTP4WXtvUVNuaj15IAHE9v9jeKlaPu5z60ek326J1pE=; b=UeWK2bODEmh+qVZb4WTlPnS0nRZ3NKY1nEqMEuR0kLAE3ft8pNz4QODLz4PiDU86EC nCogk/TmK8KTlPG/snvL3zS+84YM3lzB50M5aBZTlcyLekR7d255K/qIsucnk1yr+1pU tJdBedFj53IiKICOojEq9jI+ZX+bXeHvULyiG+dK1E6AxUty2mtkRuUeWZ28Ql9ibNIi u8zBUxCaypwmyoRKn7AGOaSeulCnieiHramyEKcD1Aa5CWOq0uMoPAaP7tm3tSSyNOm9 wWBXCMhlcqUlViIzj9gc5yPGNCtLoo7JsGXDa03LgV1U/ToN8gYz/mJ/1JWSXIFq7471 UPkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lekRZFQ3; 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 w15sor6321512lfc.71.2019.03.27.07.35.55 for (Google Transport Security); Wed, 27 Mar 2019 07:35:55 -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=lekRZFQ3; 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; bh=tTP4WXtvUVNuaj15IAHE9v9jeKlaPu5z60ek326J1pE=; b=lekRZFQ3GVWA9DKIshAekuOafvfVdDPwrpH8Vfx73XGldYcbORLXPuHlmxD+kqljA9 zzZxwSIqzKs4wTKSWyXjtkGkamZ0n+YdX0QIcXPG7uJindtbdqEvSjAnVwHKCaFQ+X7a NW/rS4HUF4fm3dkrNpi3vP3dApXHGx3l168uHHEb+bt9if5pX7WmLp0dP2kUhnHOiCZT ZMN9QXzzahf1cZy/RkywPi1A6JYx7Ouvao6xhkjnDa5nTyu5+am5yenkrrxqMOc0JUMP 05LJ2aSPgAsfTqtDV7EEVehwFNE8EiQ/nRDdcCl0ipxe64NTWb/SzK9LjxRFu7Aj6n2y AIQg== 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=tTP4WXtvUVNuaj15IAHE9v9jeKlaPu5z60ek326J1pE=; b=ca49MbQue+ZoYGvbCdmOt+XDRlRn8D+sr5IkLuLKWCYFIAVYcuLIrytucgOoOIlBdR 0Byyl4dwzQjhXRFkqSMt4uZNRLBQBIGBpI4MfA1lmUZsqz1Pow9PK3i3aGOEzNZI7ILz MJPBzkEf562ZUz4zimsTbo5LUUqp/oC7xh8dpfyUfveea8FQEk1qKk5S0DwnAc01cK6u 8ArWOX1Fa0WJA//YDP3ppum79dQbBZYbYOPtn75gba+JPncaU+eKNi6gSVDgQElEYdVS vJRVescW60vYvhaf0natvVUYSESq8PWu1Z0Lz6jZGLBBt2G3k7WHPfKNbg3zVC362A6P 9ydA== X-Gm-Message-State: APjAAAXdPDjoWoE1V9xaP7lK1hBdD8GmBAfB1An/Oz+UFGmeAU/5HdeF a1TbT3d3MnRusnyiYeaoIrdc+m64 X-Google-Smtp-Source: APXvYqwjzHeBHi/UZ85e+8kLqzktdRv5C3LeC3sTk/wqNmq1s2CI3cJbf2pBIjwOHo8gO18kRCLtkQ== X-Received: by 2002:ac2:5638:: with SMTP id b24mr5036135lff.18.1553697354848; Wed, 27 Mar 2019 07:35:54 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q2sm4548789lfj.58.2019.03.27.07.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 07:35:54 -0700 (PDT) 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 v13 0/4] PM / Domains: Support hierarchical CPU arrangement (PSCI/ARM) Date: Wed, 27 Mar 2019 15:35:44 +0100 Message-Id: <20190327143548.25305-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Changes in v13: - Use WRITE|READ_ONCE when reading/writing the "next_hrtimer" variable in the struct cpuidle_device. Also reset the same variable after resumed from idle to avoid it from containing a stale value. - Added acks from Daniel Lezcano. - The entire v13 series, including the PSCI/ARM changes are available in a git branch [3]. Changes in v12: - Drop the patches for restructuring tick_nohz_get_sleep_length(). Instead replace them all with a new timer/cpuidle patch, according to suggestions by Rafael. - The entire v12 series, including the PSCI/ARM changes are available in a git branch [2]. 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 [2] git.linaro.org/people/ulf.hansson/linux-pm.git next_v12 [2] git.linaro.org/people/ulf.hansson/linux-pm.git next_v13 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: Export the next timer/tick expiration for a CPU PM / Domains: Add genpd governor for CPUs drivers/base/power/domain.c | 77 ++++++++++++++++++++++++++-- drivers/base/power/domain_governor.c | 65 ++++++++++++++++++++++- drivers/cpuidle/cpuidle.c | 19 ++++++- include/linux/cpuidle.h | 1 + include/linux/pm_domain.h | 20 +++++++- include/linux/tick.h | 7 ++- kernel/time/tick-sched.c | 12 +++++ 7 files changed, 193 insertions(+), 8 deletions(-) -- 2.17.1