From patchwork Mon May 13 19:22:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164050 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728155ili; Mon, 13 May 2019 12:23:07 -0700 (PDT) X-Received: by 2002:a2e:9c85:: with SMTP id x5mr14906472lji.45.1557775387850; Mon, 13 May 2019 12:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775387; cv=none; d=google.com; s=arc-20160816; b=0/mUeGbi+mdLEi+N9OHonObMsyh8TyZ0A6tYV5kLgq13OQ/oIUkxpGdsq2lHmSbI7B vBarUDOWv1SJ7Qy8J0iM9x8lPhm1j+iCDZ3vx25tYWGlHO+0krTPxs0NgEwlGwTEwGHu b7emTpdtLWS5KL8/sbMIKNOaTDL1s7M+ubysAEqc12Q1wjwUYhHNG92aWTUvSid4JdOI YSa2DngK99tVxlhi4OleYvixiCjCyxS/MMeorAxscSshuPg2H2AwgFEUlPrx5OAxUpYU tyvYrjz4Q2n55Tkb655OT7tSmLD/tY0pU6vMfAoZIg7r1bK8B++dpuAizg2VnHeeULY4 BySw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PRL03ayf+3gKTw6ZyGNmbuvOXDVJf1omVj5w82VYj+c=; b=FfFdtTW+AlLYmQUiij+RiSmIyS4laNQaavuFdir8ePs+uoeE+ieAebpdDnmPIrSsJo 1UrXYzAntj01RUk3byGDtTYskrce+JJJl+rHMNreaWHS2LcMuGmOKa/g9rxFZKFarZuZ XwBVo6kVJGABP1wn7EBZioHbEELxWqFcuXFbJPIoyHJM6xk7Bhq8teanpMHctuhquikv /dhKEbqdewvFC2xtj1zh1r81hPxr7N2E3iX1jbIt9vdirF65mZE/Qq1jsIF0MAbObOU0 palNtjrOWEvv1cVPEBoUbv5cK/8OH+aGYSAmIaFrBL7FfZdHr48MkGOFNjoKXPzPYLvt s/ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Znmj+Rap; 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 e8sor2977919ljk.39.2019.05.13.12.23.07 for (Google Transport Security); Mon, 13 May 2019 12:23:07 -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=Znmj+Rap; 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; bh=PRL03ayf+3gKTw6ZyGNmbuvOXDVJf1omVj5w82VYj+c=; b=Znmj+Rap5uWxgIXFcTCRFXUCBeWlHqU14s7GfponHlIVTdIN7IzEc61HXMm4h5nMBl pijn+Gtm6cLPHDMK+OyeGhMq851kXOyT9eVvz5Eyww1m2u+MiAMZ1ZmxhMmNVVYT67kD mS34rNa0TU+vC/QIphSceYIH1L6a0ZvjhvREogDJycRMkS+Rs2TfV8eY8m+0ZbMStq5P dk5lfkFlLuy6i4z/FJSh7h6pWspZbXExojy+vKqzYVKfbdd54IxWPB6JsuTVRCSLt0ye MCtEkLESrZG/lkG0+OyQr8OvzGk5uYyHT8MItOwqjKlbO+fTi4c83DsDsSQhdL3amg2j JoKA== 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; bh=PRL03ayf+3gKTw6ZyGNmbuvOXDVJf1omVj5w82VYj+c=; b=YFa2B2gDOXjR3MPbQwjWDj3WoBjRQAL4/eiMasMofLvME2nZgaB66a6AgxbTba7gdo rDetCj189ytUrVuD3NfMUakRlM21gV+h+/TpyFubSf/PWJUteyF1+SJVY+00rxd4+PyW fZ9H46QQoXTckZeJ6bl5jKgfzYXiMls8UxWBNPxp8BgC/KbmLDfQJc80jn3sUgfe5W4I eTzEIXAz9ANNImDRjILz1SzLDpGkWxIqA+Y8+62n2lVHUZnQkLWxVjpo8u/Dy4IUSs8/ qE/cIETJXIgYykiyvuqHDht6tSFgzr8IvKT678ChmKhuZLa9kz/gT4nIBNY2tGbKtbZV uYew== X-Gm-Message-State: APjAAAVuc9yBhsqrVuWgRIvb+hn6Ydex4/cld0jAUTpeT8wVk9GZA/ie OQ/PnzlvW0it41yA5HjMOUU0vMoP X-Google-Smtp-Source: APXvYqw+k+LeWintu25cglIZU1CDGNn5D+9RA2OiP0AoKwBrDnOS5hnqd/Xey6gfGS2F/GmEje2j4w== X-Received: by 2002:a2e:86c5:: with SMTP id n5mr14855773ljj.184.1557775387446; Mon, 13 May 2019 12:23:07 -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 q21sm3449365lfa.84.2019.05.13.12.23.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:06 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer , Ulf Hansson Subject: [PATCH 01/18] dt: psci: Update DT bindings to support hierarchical PSCI states Date: Mon, 13 May 2019 21:22:43 +0200 Message-Id: <20190513192300.653-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> From: Lina Iyer Update DT bindings to represent hierarchical CPU and CPU PM domain idle states for PSCI. Also update the PSCI examples to clearly show how flattened and hierarchical idle states can be represented in DT. Signed-off-by: Lina Iyer Reviewed-by: Rob Herring Reviewed-by: Sudeep Holla Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes: - None. --- .../devicetree/bindings/arm/psci.txt | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) -- 2.17.1 diff --git a/Documentation/devicetree/bindings/arm/psci.txt b/Documentation/devicetree/bindings/arm/psci.txt index a2c4f1d52492..e6d3553c8df8 100644 --- a/Documentation/devicetree/bindings/arm/psci.txt +++ b/Documentation/devicetree/bindings/arm/psci.txt @@ -105,7 +105,173 @@ Case 3: PSCI v0.2 and PSCI v0.1. ... }; +ARM systems can have multiple cores sometimes in hierarchical arrangement. +This often, but not always, maps directly to the processor power topology of +the system. Individual nodes in a topology have their own specific power states +and can be better represented in DT hierarchically. + +For these cases, the definitions of the idle states for the CPUs and the CPU +topology, must conform to the domain idle state specification [3]. The domain +idle states themselves, must be compatible with the defined 'domain-idle-state' +binding [1], and also need to specify the arm,psci-suspend-param property for +each idle state. + +DT allows representing CPUs and CPU idle states in two different ways - + +The flattened model as given in Example 1, lists CPU's idle states followed by +the domain idle state that the CPUs may choose. Note that the idle states are +all compatible with "arm,idle-state". Additionally, for the domain idle state +the "arm,psci-suspend-param" represents a superset of the CPU's idle state. + +Example 2 represents the hierarchical model of CPUs and domain idle states. +CPUs define their domain provider in their psci DT node. The domain controls +the power to the CPU and possibly other h/w blocks that would enter an idle +state along with the CPU. The CPU's idle states may therefore be considered as +the domain's idle states and have the compatible "arm,idle-state". Such domains +may also be embedded within another domain that may represent common h/w blocks +between these CPUs. The idle states of the CPU topology shall be represented as +the domain's idle states. Note that for the domain idle state, the +"arm,psci-suspend-param" represents idle states hierarchically. + +In PSCI firmware v1.0, the OS-Initiated mode is introduced. However, the +flattened vs hierarchical DT representation is orthogonal to the OS-Initiated +vs the platform-coordinated PSCI CPU suspend modes, thus should be considered +independent of each other. + +The hierarchical representation helps and makes it easy to implement OSI mode +and OS implementations may choose to mandate it. For the default platform- +coordinated mode, both representations are viable options. + +Example 1: Flattened representation of CPU and domain idle states + cpus { + #address-cells = <1>; + #size-cells = <0>; + + CPU0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53", "arm,armv8"; + reg = <0x0>; + enable-method = "psci"; + cpu-idle-states = <&CPU_PWRDN>, <&CLUSTER_RET>, + <&CLUSTER_PWRDN>; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a57", "arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + cpu-idle-states = <&CPU_PWRDN>, <&CLUSTER_RET>, + <&CLUSTER_PWRDN>; + }; + + idle-states { + CPU_PWRDN: cpu-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x0000001>; + entry-latency-us = <10>; + exit-latency-us = <10>; + min-residency-us = <100>; + }; + + CLUSTER_RET: cluster-retention { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x1000011>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x1000031>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; + }; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +Example 2: Hierarchical representation of CPU and domain idle states + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + CPU0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53", "arm,armv8"; + reg = <0x0>; + enable-method = "psci"; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a57", "arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; + }; + + idle-states { + CPU_PWRDN: cpu-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x0000001>; + entry-latency-us = <10>; + exit-latency-us = <10>; + min-residency-us = <100>; + }; + + CLUSTER_RET: cluster-retention { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000010>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-power-down { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000030>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; + }; + }; + + psci { + compatible = "arm,psci-1.0"; + method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + domain-idle-states = <&CPU_PWRDN>; + power-domains = <&CLUSTER_PD>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + domain-idle-states = <&CPU_PWRDN>; + power-domains = <&CLUSTER_PD>; + }; + + CLUSTER_PD: cluster-pd { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_RET>, <&CLUSTER_PWRDN>; + }; + }; + [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/arm/idle-states.txt [2] Power State Coordination Interface (PSCI) specification http://infocenter.arm.com/help/topic/com.arm.doc.den0022c/DEN0022C_Power_State_Coordination_Interface.pdf +[3]. PM Domains description + Documentation/devicetree/bindings/power/power_domain.txt From patchwork Mon May 13 19:22: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: 164051 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728189ili; Mon, 13 May 2019 12:23:09 -0700 (PDT) X-Received: by 2002:ac2:55a9:: with SMTP id y9mr9390094lfg.58.1557775389700; Mon, 13 May 2019 12:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775389; cv=none; d=google.com; s=arc-20160816; b=JGd1VlDD/BtbOLK6QAB0yxT3wmEPBJUEnA4e9CTqLruFa2eXjZEfEKjEw3BebF/4WV 1bXNmLYGwfo/Gu0MgY7yuBPzPajTBkbFV+Ad/3fE3wTqKVjSTRTqIfWVgeds1bUjy3tG xCk8OBpkGic8wbX1t4zklZECcc5GyGUdBiI9d/aO0Wde/WPDKFAvz1RH3bI+E0qHWO8J CjIjb9B3yms/y7Or4x0ZLZKTq4aQ1AP5X3Gm5LFjghtC/7QP9Ah8Z6s6G+dM3x9cfOPI MtfCfY8SdJiT7kQhZYTLTU7RsPz8+M7ExQxbh3hnHtmJG0gReHqRJAqqKjRpsO2/uJsn WrpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y7css3ZNjj71s6qH3VZ02Gz19f8ZGlmnEuYgt6KvYro=; b=J0IV+nNZ4Dfr7KgvnjPnQP1DLY8kjSzsU8rUKTYjxW9OaIVgX0uhVYkFsjeKi9kc7n TlygJYmzNOhGy9r5yTLIMQl8hLYllZdRECelsaLnZ4WoTXvPndske0YbzzXwCw8voSno yjnbS9avDh6tfn58MkS5LPAd+TyCo8upoRZxoRGyeLx4H7bqLWWl3Rb7dUlefRPZYkS3 HYpsrXDmYuE80/JLh1WON7uXzyT4Oe918GVh9ulU4uIPFeetI6vTOf0PVqvcnqiCAt0F hH/s3IbdI8l8YLV7vDnssG6tDN1kAA92tGH3vZNNK9DJU/HCL66fObCd5Wu9gVlbRMAz ZWzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JQDERog4; 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 y17sor4132744lfh.61.2019.05.13.12.23.09 for (Google Transport Security); Mon, 13 May 2019 12:23:09 -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=JQDERog4; 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; bh=Y7css3ZNjj71s6qH3VZ02Gz19f8ZGlmnEuYgt6KvYro=; b=JQDERog4rov3X+DqEg2H7/3Odpqc2zC02GWbC2dA3cdRByYxi61kDxumi6NKwfVrRo MthcOUmpimuvOLKrvD0vrkrnD69QBrGcqvLE2ekX0Ag1GhHhK8CeFO3PPP/rY48StudY uvMfjdjZJgcj/HMAcKg56hIjoXHwqFwxeas8Q/zJXHNh/9VUNbu2dAIaiKo7Pc+MwALa 9SWhEPexpgP2e3ql1zXtp3jydNVwmcUGR79PdmwSfMGqrslIYLqcKywJk7qgkw396soe HPSSW/N9cuYmE47cwNMWq0RyVq2SCoJKdaaGjnwEZbeXCXeUlh1q2N/e+59FIltHYDFZ Milg== 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; bh=Y7css3ZNjj71s6qH3VZ02Gz19f8ZGlmnEuYgt6KvYro=; b=DL4v402zB2bp8uRhOOsAYSX4ElfhhNpg8Bf2Q+qDN6dS/tdpeBgW4iM3QzBKm78ly9 KWl7D4+ZIwim4LSK4wbgwIUiEDJ+StKQnp/rD6xhjokaH0USbAbf5iSuH9mvYjzU3YXA Ad+MjkVSlyaooW39G415MTQE2UAEVk3JMrPst1cRF8b+GuQJWItkFdJjleZ4tmsl1sDs MDQYcpeyCYMCfpWZoqTLFp6suIfRAxe3E8eAEQU4T2aEIHGcvYy+BpVqCNLCjasFK6b9 3LUW8ho3BeOf1oE62w81NKopSTPbk9+2EyGNeuE8y9JCiz197QGnzUYmg+TyY0pG28d1 ASYQ== X-Gm-Message-State: APjAAAVRYCClQio+Zkudyay4QsGw5oT8QqMocATsQd0dKF4XAw1FfX/J S5LQiYsUhsCUGM3XAfjnAx5+Lt+x X-Google-Smtp-Source: APXvYqwTyaAA0SKlYfwt/EkTngvPeOt4VBe6xlPqr7JTEF8fvJF80/c14TQZyy9mXnggagGHR0SUYw== X-Received: by 2002:ac2:457a:: with SMTP id k26mr14042867lfm.161.1557775389309; Mon, 13 May 2019 12:23:09 -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 q21sm3449365lfa.84.2019.05.13.12.23.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:08 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Lina Iyer Subject: [PATCH 02/18] of: base: Add of_get_cpu_state_node() to get idle states for a CPU node Date: Mon, 13 May 2019 21:22:44 +0200 Message-Id: <20190513192300.653-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> The CPU's idle state nodes are currently parsed at the common cpuidle DT library, but also when initializing back-end data for the arch specific CPU operations, as in the PSCI driver case. To avoid open-coding, let's introduce of_get_cpu_state_node(), which takes the device node for the CPU and the index to the requested idle state node, as in-parameters. In case a corresponding idle state node is found, it returns the node with the refcount incremented for it, else it returns NULL. Moreover, for ARM, there are two generic methods, to describe the CPU's idle states, either via the flattened description through the "cpu-idle-states" binding [1] or via the hierarchical layout, using the "power-domains" and the "domain-idle-states" bindings [2]. Hence, let's take both options into account. [1] Documentation/devicetree/bindings/arm/idle-states.txt [2] Documentation/devicetree/bindings/arm/psci.txt Suggested-by: Sudeep Holla Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Reviewed-by: Rob Herring Reviewed-by: Daniel Lezcano Signed-off-by: Ulf Hansson --- Changes: - Fixed some kernel docs typos. - Fall-back to use "cpu-idle-states" when "power-domains" is present but "domain-idle-states" is missing. --- drivers/of/base.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/of.h | 8 ++++++++ 2 files changed, 44 insertions(+) -- 2.17.1 diff --git a/drivers/of/base.c b/drivers/of/base.c index 20e0e7ee4edf..05866f0c65b4 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -477,6 +477,42 @@ int of_cpu_node_to_id(struct device_node *cpu_node) } EXPORT_SYMBOL(of_cpu_node_to_id); +/** + * of_get_cpu_state_node - Get CPU's idle state node at the given index + * + * @cpu_node: The device node for the CPU + * @index: The index in the list of the idle states + * + * Two generic methods can be used to describe a CPU's idle states, either via + * a flattened description through the "cpu-idle-states" binding or via the + * hierarchical layout, using the "power-domains" and the "domain-idle-states" + * bindings. This function check for both and returns the idle state node for + * the requested index. + * + * In case an idle state node is found at @index, the refcount is incremented + * for it, so call of_node_put() on it when done. Returns NULL if not found. + */ +struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index) +{ + struct of_phandle_args args; + int err; + + err = of_parse_phandle_with_args(cpu_node, "power-domains", + "#power-domain-cells", 0, &args); + if (!err) { + struct device_node *state_node = + of_parse_phandle(args.np, "domain-idle-states", index); + + of_node_put(args.np); + if (state_node) + return state_node; + } + + return of_parse_phandle(cpu_node, "cpu-idle-states", index); +} +EXPORT_SYMBOL(of_get_cpu_state_node); + /** * __of_device_is_compatible() - Check if the node matches given constraints * @device: pointer to node diff --git a/include/linux/of.h b/include/linux/of.h index 0cf857012f11..6ae5c2c4b104 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -351,6 +351,8 @@ extern const void *of_get_property(const struct device_node *node, int *lenp); extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); extern struct device_node *of_get_next_cpu_node(struct device_node *prev); +extern struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index); #define for_each_property_of_node(dn, pp) \ for (pp = dn->properties; pp != NULL; pp = pp->next) @@ -765,6 +767,12 @@ static inline struct device_node *of_get_next_cpu_node(struct device_node *prev) return NULL; } +static inline struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index) +{ + return NULL; +} + static inline int of_n_addr_cells(struct device_node *np) { return 0; From patchwork Mon May 13 19:22:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164052 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728220ili; Mon, 13 May 2019 12:23:11 -0700 (PDT) X-Received: by 2002:a2e:9848:: with SMTP id e8mr2873287ljj.27.1557775391481; Mon, 13 May 2019 12:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775391; cv=none; d=google.com; s=arc-20160816; b=0Q8j3ES/hwGm8TWfGmOXzax1t1DDKM2vpAknZw6CLrNiulPNjwvpH5mmCERr522dM8 763VUyT8feOmaF7/N4KMyL9DnAYUCuaCMRdzFp7LtBk9OtewCKgMp4fUnVBao4IpgBco CBFbKAofQwzo6j/7qpFHsh6/P1LVDl4TrJyGeAR539Pl3oc+EN4YmnI4FCGvT4VetN00 WMWBnWYiqLYnxB7mJmOqRP+WoRqrILzT31YqkI81l/8kcs8LTSTIn7wK4YV3t54EgGUv b+/DlYw9smc+/rc0hcpo+MSrzeZGJCWOMRHWSSUDuyyzROgH+qH6bK0tDGoTnMyelCkB k2FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F5AEltUKfed5w7dHNisHSX8S1wBzU63rf2dZ2cHwfSs=; b=Wlj/osf8eMm5HL+Zqgwebd0A4j8p0g557QLppTqBT+ffs5ZBdumE+LVnGb67rlnyRn UmrFSJF93qJyqrUF7QDcWwmpa9ozzLbkc38RZm3gQ0OYCIp9wZZUipngW8Mxupj17eTn HkIKlAdP5cl/85IWHEfzM8xE3TtGS3uy7wTwv8ztxcaIIseFfOZtJx2XTFVU9oUtTu3N lmB/WL8bHPr/44m7JhUYomiHVFocbUi0HboXWK1v7Gh8JkKp0mhNbM30lDcYFTxNqIHb 9k6/HhY3fC6TXRfqWKJ+JhhYtDzF79WTGYYP4VYsNUZnUE8IO8UaCILnF5pHfk0mUvRM Od5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ihwtaKGH; 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 w16sor2197354ljg.41.2019.05.13.12.23.11 for (Google Transport Security); Mon, 13 May 2019 12:23:11 -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=ihwtaKGH; 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; bh=F5AEltUKfed5w7dHNisHSX8S1wBzU63rf2dZ2cHwfSs=; b=ihwtaKGHm5HWQDkvQkty6/m7be/aDE2Ue2EF8h2aUL7J5q3dbOjBQl/7riCd7391Bk 6mt4yavZncehbr1dqBkKzd5+XE6F5UVYInUI/aMbhArbPszaqyttf3MVOOEailuYdP3R fucpydZkU9Xe7taVXR0KfQZCmk+WPepu9Fz5czOMEkZzxq0cyv/O9xzdwPbelTwhxiAt AgLFcBQz4OuHsSIHPRYM79Mx2eXRaijBK738WDXPRnaM8wcxzwaXGNHAtjVqh3N6NVfn PALPweQK2a7Hw+qtF1599CtdwmhaZJP3Loxm6jMlG87c2/LPW1b4sxzN22fBdrGhOVkv xgGA== 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; bh=F5AEltUKfed5w7dHNisHSX8S1wBzU63rf2dZ2cHwfSs=; b=DeDrjMtyHbfAsCJbjZskg/KuAq1JjAIfmprstgOEF708pFEi9n/cajxzjALXVH3Ilz 8ibl8crrqDU0OKXXdwAwE/jywJHDL004pC5vDzaIEJIgmu0gUOqG4Ywuto09W1EBTGtG wF30IjbQjcA3caOGujlYRVxiKYWLCda0kG+C2IqfVxCuOvwvim4nx2JZr0uCT7x/DP3a GIdYAHhXCZfy75Q++cHqFARCc1fnhnRipwEYjNTbY3KXNmokWpc2Bc7r9pnaxtz7qEDn DlMFbVdfUH4DVZsBFk17MuoP66ONCgKNM4xiZEPDUfNPP2tDeM770k/5JaOF23efvsPr udEA== X-Gm-Message-State: APjAAAXZnGH5662SzKkZUIGRNqjcctBiO0bbtrqKIIqFscwRd4lGtDdL fLH3QZguwhYxJiPaEYlgo25fv8Xw X-Google-Smtp-Source: APXvYqxS293Cibnm8BvM4OA/7mePaZMMHGVjPn5T9aLCXEe34R5mqSI/nCjgK/Ib9ssZWuTZNP1Trw== X-Received: by 2002:a2e:c41:: with SMTP id o1mr8693546ljd.23.1557775391156; Mon, 13 May 2019 12:23:11 -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 q21sm3449365lfa.84.2019.05.13.12.23.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:10 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer , Ulf Hansson Subject: [PATCH 03/18] cpuidle: dt: Support hierarchical CPU idle states Date: Mon, 13 May 2019 21:22:45 +0200 Message-Id: <20190513192300.653-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> From: Lina Iyer Currently CPU's idle states are represented in a flattened model, via the "cpu-idle-states" binding from within the CPU's device nodes. Support the hierarchical layout during parsing and validating of the CPU's idle states. This is simply done by calling the new OF helper, of_get_cpu_state_node(). Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer Reviewed-by: Daniel Lezcano Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes: - None. --- drivers/cpuidle/dt_idle_states.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c index add9569636b5..97ad25399ca8 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -114,8 +114,7 @@ static bool idle_state_valid(struct device_node *state_node, unsigned int idx, for (cpu = cpumask_next(cpumask_first(cpumask), cpumask); cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpumask)) { cpu_node = of_cpu_device_node_get(cpu); - curr_state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - idx); + curr_state_node = of_get_cpu_state_node(cpu_node, idx); if (state_node != curr_state_node) valid = false; @@ -173,7 +172,7 @@ int dt_init_idle_driver(struct cpuidle_driver *drv, cpu_node = of_cpu_device_node_get(cpumask_first(cpumask)); for (i = 0; ; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_get_cpu_state_node(cpu_node, i); if (!state_node) break; From patchwork Mon May 13 19:22:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164053 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728252ili; Mon, 13 May 2019 12:23:13 -0700 (PDT) X-Received: by 2002:a2e:834d:: with SMTP id l13mr1067843ljh.97.1557775393831; Mon, 13 May 2019 12:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775393; cv=none; d=google.com; s=arc-20160816; b=yrU3YGXjAjY9pajL1gXxl7252U6q1h1aJws4MlG9bG4Uc+8y6iIJ7Lrrc2UTMHN9aS f3pqNAb925hU4uDyWl+/gYu4LN5so5J5TXKVRjijhSH8Y/6E3ml/XC+dzfy1FH5N/pE0 CFuIKNALJgajfN2QzPH+4EuH09cgHo2JpRu8q2wKFNA2dsD/KBKQHj34X5eSyt+Ih//D rc5B7iDvny+AHhkfJbZ0PCgINrlyJeQId5c6TlJ2+LBOarxedWa5LVPovBxqiiSN2I+j Onzv1fmGvjG/kINfiy30tbEblCOHKVCJ6WJhWiEIYH4T7XQrVdNx6y3Ae5MC48XaixL1 dklQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HHIW4beg1Jo/n8yn03ZEmR2mqH0MtY+zTbuMOhYgiNI=; b=VIDzN+Ow0Z6UzeCPL8pioYVr/haLSmzdkABs5+oVAMh/w51T0uJ49uZGnf9Pb7H+nZ 6Fu7v5K40xamuxRfiDp+sZMBAwM9K8tP/9tH9hWY/6AH4qdWw5uzwSfLvaV1r2XzgRj3 RbJU8hxfELbzWXe1yxzJUdLJNTcEdteNVBCdRaFxgIM78akGl48pbie5o8MKS8Y90i71 UYkr5ooUnyS+QogrbspEPY3fwtNBbrH0IuG09Y3b9Xziy6IMwze6+b6dzurN+d4RY6e5 Lf2UZ0PNtBGUqX/GNSOSIWYDhiJocegvyqh8u++r4ItKIhCeFzyOiugpY6nODx3MaiAN Pc+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=anVw6Y6E; 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 j28sor4072388lfk.0.2019.05.13.12.23.13 for (Google Transport Security); Mon, 13 May 2019 12:23:13 -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=anVw6Y6E; 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; bh=HHIW4beg1Jo/n8yn03ZEmR2mqH0MtY+zTbuMOhYgiNI=; b=anVw6Y6EzHqSNxrL6pGJpo0scx6tqJdSTeUKkDH1VoRuqz97rmscnr3deHcKsbcTF9 KBUeSJS+GoswseXScGGlJTy0SXat8ZH2YEchgAhGyniX/PXerb1jLyWkPb9fOUxfu0Lw IUL2YhhLknbWKObj+AdmWeg4lbExhFib0lAuxr50jWg5yFgGkT0hrzvCnBhiv+cBPeZP 2EMMNN28h8myMwiax1VcJt7Y/V2t3O/wZnNuc61AwrUov8LMgRP4C601bVL3eyn/P31r R81H8S2BAi5piWYLe8XXYPuZgg59NszI1sA3l2CVOpIAXy6JNGqLYmyGqsFRZ5tCJK6G StRw== 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; bh=HHIW4beg1Jo/n8yn03ZEmR2mqH0MtY+zTbuMOhYgiNI=; b=WcL3DwKrnVAiMStufnNJ3FbQ0k00Iq9hMiYGpdPrFH1t7NzbURAi8jwiANxAoBBrBQ EYQWaLwQ6HPPtNh4UKiSpY17ANqkUu9R08bYawK0jl4rgb5sED1vji9/p2a/Uv2+0LZS 6wFpElb936Cb7NhAsa8ZMraogMApWBh/sxSi/RARFQuUj2UvhA8DuOTjt5lzVRWVJiMf +G7e2CRaVoWwrSKFt1iN6qH2OiL8qXBQVsjhpKNFVBECwYXh3c/azimn7FJYmXDAspou wsjQuBqlgYiyPQdionxrD2kDuOEepeQdPmNsIfxt0qFeS16p2l0+YyMnUKrMGv9pBtw3 rDTQ== X-Gm-Message-State: APjAAAWFTHPPo0RumA+vW6jRaBJK3ZnueqwqD26zoEWMFqoHmRZIukZk wmF2Xmi8N0tTZbLbRHpCJcNalO8w X-Google-Smtp-Source: APXvYqxRt2bTvjgwV68tXj3LgqrAAbaA1jPCgVPYT0nHrhupILypGycEOanmCUjC0XjwqBqYOWLpQg== X-Received: by 2002:ac2:593a:: with SMTP id v26mr14391804lfi.64.1557775393399; Mon, 13 May 2019 12:23:13 -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 q21sm3449365lfa.84.2019.05.13.12.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:12 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Russell King , Catalin Marinas , Will Deacon , Andy Gross , David Brown Subject: [PATCH 04/18] ARM/ARM64: cpuidle: Let back-end init ops take the driver as input Date: Mon, 13 May 2019 21:22:46 +0200 Message-Id: <20190513192300.653-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> To allow arch back-end init ops to operate on the cpuidle driver for the corresponding CPU, let's pass along a pointer to the struct cpuidle_driver* and forward it the relevant layers of callbacks for ARM/ARM64. Following changes for the PSCI firmware driver starts making use of this. Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: David Brown Signed-off-by: Ulf Hansson Acked-by: Daniel Lezcano --- Changes: - None. Note: - This patch is needed by the subsequent patch, but more importantly, also by "[PATCH 10/18] drivers: firmware: psci: Add hierarchical domain idle states converter". --- arch/arm/include/asm/cpuidle.h | 4 ++-- arch/arm/kernel/cpuidle.c | 5 +++-- arch/arm64/include/asm/cpu_ops.h | 4 +++- arch/arm64/include/asm/cpuidle.h | 6 ++++-- arch/arm64/kernel/cpuidle.c | 6 +++--- drivers/cpuidle/cpuidle-arm.c | 2 +- drivers/firmware/psci/psci.c | 7 ++++--- drivers/soc/qcom/spm.c | 3 ++- include/linux/psci.h | 4 +++- 9 files changed, 25 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h index 6b2ff7243b4b..bee0a7847733 100644 --- a/arch/arm/include/asm/cpuidle.h +++ b/arch/arm/include/asm/cpuidle.h @@ -32,7 +32,7 @@ struct device_node; struct cpuidle_ops { int (*suspend)(unsigned long arg); - int (*init)(struct device_node *, int cpu); + int (*init)(struct cpuidle_driver *, struct device_node *, int cpu); }; struct of_cpuidle_method { @@ -47,6 +47,6 @@ struct of_cpuidle_method { extern int arm_cpuidle_suspend(int index); -extern int arm_cpuidle_init(int cpu); +extern int arm_cpuidle_init(struct cpuidle_driver *drv, int cpu); #endif diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c index fda5579123a8..43778c9b373d 100644 --- a/arch/arm/kernel/cpuidle.c +++ b/arch/arm/kernel/cpuidle.c @@ -122,6 +122,7 @@ static int __init arm_cpuidle_read_ops(struct device_node *dn, int cpu) /** * arm_cpuidle_init() - Initialize cpuidle_ops for a specific cpu + * @drv: the drv to be initialized * @cpu: the cpu to be initialized * * Initialize the cpuidle ops with the device for the cpu and then call @@ -137,7 +138,7 @@ static int __init arm_cpuidle_read_ops(struct device_node *dn, int cpu) * -ENXIO if the HW reports a failure or a misconfiguration, * -ENOMEM if the HW report an memory allocation failure */ -int __init arm_cpuidle_init(int cpu) +int __init arm_cpuidle_init(struct cpuidle_driver *drv, int cpu) { struct device_node *cpu_node = of_cpu_device_node_get(cpu); int ret; @@ -147,7 +148,7 @@ int __init arm_cpuidle_init(int cpu) ret = arm_cpuidle_read_ops(cpu_node, cpu); if (!ret) - ret = cpuidle_ops[cpu].init(cpu_node, cpu); + ret = cpuidle_ops[cpu].init(drv, cpu_node, cpu); of_node_put(cpu_node); diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index 8f03446cf89f..8db870c29f1b 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -19,6 +19,8 @@ #include #include +struct cpuidle_driver; + /** * struct cpu_operations - Callback operations for hotplugging CPUs. * @@ -58,7 +60,7 @@ struct cpu_operations { int (*cpu_kill)(unsigned int cpu); #endif #ifdef CONFIG_CPU_IDLE - int (*cpu_init_idle)(unsigned int); + int (*cpu_init_idle)(struct cpuidle_driver *, unsigned int); int (*cpu_suspend)(unsigned long); #endif }; diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h index 3c5ddb429ea2..3fd3efb61649 100644 --- a/arch/arm64/include/asm/cpuidle.h +++ b/arch/arm64/include/asm/cpuidle.h @@ -4,11 +4,13 @@ #include +struct cpuidle_driver; + #ifdef CONFIG_CPU_IDLE -extern int arm_cpuidle_init(unsigned int cpu); +extern int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu); extern int arm_cpuidle_suspend(int index); #else -static inline int arm_cpuidle_init(unsigned int cpu) +static inline int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu) { return -EOPNOTSUPP; } diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c index f2d13810daa8..aaf9dc5cb87a 100644 --- a/arch/arm64/kernel/cpuidle.c +++ b/arch/arm64/kernel/cpuidle.c @@ -18,13 +18,13 @@ #include #include -int arm_cpuidle_init(unsigned int cpu) +int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu) { int ret = -EOPNOTSUPP; if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_suspend && cpu_ops[cpu]->cpu_init_idle) - ret = cpu_ops[cpu]->cpu_init_idle(cpu); + ret = cpu_ops[cpu]->cpu_init_idle(drv, cpu); return ret; } @@ -51,7 +51,7 @@ int arm_cpuidle_suspend(int index) int acpi_processor_ffh_lpi_probe(unsigned int cpu) { - return arm_cpuidle_init(cpu); + return arm_cpuidle_init(NULL, cpu); } int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi) diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 3a407a3ef22b..39413973b21d 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -106,7 +106,7 @@ static int __init arm_idle_init_cpu(int cpu) * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ - ret = arm_cpuidle_init(cpu); + ret = arm_cpuidle_init(drv, cpu); /* * Allow the initialization to continue for other CPUs, if the reported diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index fe090ef43d28..88e90e0f06b9 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -303,7 +303,8 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } -static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) +static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, + struct device_node *cpu_node, int cpu) { int i, ret = 0, count = 0; u32 *psci_states; @@ -391,7 +392,7 @@ static int __maybe_unused psci_acpi_cpu_init_idle(unsigned int cpu) } #endif -int psci_cpu_init_idle(unsigned int cpu) +int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu) { struct device_node *cpu_node; int ret; @@ -410,7 +411,7 @@ int psci_cpu_init_idle(unsigned int cpu) if (!cpu_node) return -ENODEV; - ret = psci_dt_cpu_init_idle(cpu_node, cpu); + ret = psci_dt_cpu_init_idle(drv, cpu_node, cpu); of_node_put(cpu_node); diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c index 53807e839664..6e967f0a8608 100644 --- a/drivers/soc/qcom/spm.c +++ b/drivers/soc/qcom/spm.c @@ -208,7 +208,8 @@ static const struct of_device_id qcom_idle_state_match[] __initconst = { { }, }; -static int __init qcom_cpuidle_init(struct device_node *cpu_node, int cpu) +static int __init qcom_cpuidle_init(struct cpuidle_driver *drv, + struct device_node *cpu_node, int cpu) { const struct of_device_id *match_id; struct device_node *state_node; diff --git a/include/linux/psci.h b/include/linux/psci.h index 8b1b3b5935ab..4f29a3bff379 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -20,9 +20,11 @@ #define PSCI_POWER_STATE_TYPE_STANDBY 0 #define PSCI_POWER_STATE_TYPE_POWER_DOWN 1 +struct cpuidle_driver; + bool psci_tos_resident_on(int cpu); -int psci_cpu_init_idle(unsigned int cpu); +int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu); int psci_cpu_suspend_enter(unsigned long index); enum psci_conduit { From patchwork Mon May 13 19:22:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164054 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728274ili; Mon, 13 May 2019 12:23:15 -0700 (PDT) X-Received: by 2002:a2e:4a09:: with SMTP id x9mr12731350lja.19.1557775395479; Mon, 13 May 2019 12:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775395; cv=none; d=google.com; s=arc-20160816; b=Dz79tfAQOGgbABqYC8CoYgHYT8KWQ+L+ZGRdnoHggzDbhKcMz1Rtj58vXE/lBMFT12 3Nk+zBRpDuMoI99mDurXBFqU/neq+DBBmMTSQSXUCuya7yWca9uNDFI1krBjCi0u0pOW jmWBDlAvz77gPVLD0OLvAKESyOj0vNW33YwakSL0z4BVDLT08nhupG1HmNWlGdEF54cx hvJDUSMsuH0Tn/IISL5/p53vmrhvDBicL7zyW6LVYADvRjKgZe2Blq3pM6lc+sbvbrnY gtseC7xlyr2c9VNIFmXcpkMlDPgZEd55+f8dbtEeoQ26qiAuey1g185Cu5y+jA5Z/KkC Npbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h+mBrphGE8r6kKGvHPN2hwwjlulIBItsLgwHs6HK8tw=; b=hsv21B83xhh9xJM8kUsgVWJ0WOZr5eTxcJk9ct4tGDoxze7tkeuPQY2c8yIS+MW6bP /deen3xzFnJaX6vZeSdSIILrxCZLHLjEB7vZW9gIh4cI3CRsDs6xN7mRotkiG3UiGwUo N0bf/tJG4f6KYGLHs5s6ySTGlzGpiI3MMtIvwWyNDx0qAUG5fbicqC5CWtcHEyRTkEfq AtEE2kWpSNZGSNNt7ag+CLad+D4xA4BYAsC0rB+XduTt8TCnbcfdH1G7d6cBcbJrD4lh j6Z0zRPI8jrbijLrdMjTylun1Z7l70QMku7VDPdZg1UUDknR+yvdnMhcJejiwgsO2bdB 0peQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z1qwoOxf; 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 p16sor1392428ljc.9.2019.05.13.12.23.15 for (Google Transport Security); Mon, 13 May 2019 12:23:15 -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=z1qwoOxf; 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; bh=h+mBrphGE8r6kKGvHPN2hwwjlulIBItsLgwHs6HK8tw=; b=z1qwoOxfxP8ws6K0eXeqsi0M8rg4AiA8aC+/rjIVQbuJPoKSAquEg4iySw4L3cN5x8 jjlTDZuSJciHj+R09dPL+gALzrtUwcXOVPCSnr1zV5JjUxXC+jTH/bs1uFkycg9wYG8L 3ilSYwaJ4Q/40soKA1mrFGCJYk6E1a5pkxpihVokTsS7TPrP5nTxTdm7Jw+QAnCFWTxO uSmb50ZRpi0pFqGue364kuAdvMUhtO582nHQ8c2OptpkJde/IrOfk1AUVO3SIIewRV7N vt3h/dJVN+5qmhzobmOPYqBY1Id026c5O41E9qZf/leKI1FYytDGLpKNJm1MNCm4XpMm 8yxg== 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; bh=h+mBrphGE8r6kKGvHPN2hwwjlulIBItsLgwHs6HK8tw=; b=SIgZbpno9uEMokenP6aEzRP0Uj1daWiMqY/AKsqvDdY3JYMRKnQXG8rEuCf2Uh2Ejt m3Buc+A2Ja6oatPj/vGlfreB1QChaS+mw504pLIMkgUbv4SNpYC8W1E7PVCImnxRk5Xt 7W1JeteIhfEJQw4DH3iRYG+Np5O+CQ+LHvkLyfd8C+8v1GFJryhw/EI9Nk08exLNu9+N WbfBo/rypR6gIz6oyEK18sbegLZ67V1Pp2SgyyyjBIwM6qTIf4M/EyinzLqDXO8Selqw KlmoNRIuIfJ3nUO12ZdMyoZ5cPpPwmLRW4iO8hwxMP8ovMJQ3sB/ydPhDKggzvcY/xnp t71A== X-Gm-Message-State: APjAAAVhBz99f87ESsahkiBnyHFpjLApGd4izykDWX/HPWtthFvjSiQx t2BV39QruxWbIUefAKfVYHzEBx9H X-Google-Smtp-Source: APXvYqyeVfJKdGokU/doivXzmlRxtYYG8D4KXKrSzXVVKA9wCQvIkwAm3xVkfpldRQZcHwdKpXbyIA== X-Received: by 2002:a2e:9241:: with SMTP id v1mr14737256ljg.6.1557775395160; Mon, 13 May 2019 12:23:15 -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 q21sm3449365lfa.84.2019.05.13.12.23.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:14 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 05/18] drivers: firmware: psci: Simplify state node parsing Date: Mon, 13 May 2019 21:22:47 +0200 Message-Id: <20190513192300.653-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> Instead of iterating through all the state nodes in DT, to find out how many states that needs to be allocated, let's use the number already known by the cpuidle driver. In this way we can drop the iteration altogether. Signed-off-by: Ulf Hansson Acked-by: Daniel Lezcano --- Changes: - None. --- drivers/firmware/psci/psci.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 88e90e0f06b9..9c2180bcee4c 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -306,26 +306,20 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state) static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, int cpu) { - int i, ret = 0, count = 0; + int i, ret = 0, num_state_nodes = drv->state_count - 1; u32 *psci_states; struct device_node *state_node; - /* Count idle states */ - while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - count))) { - count++; - of_node_put(state_node); - } - - if (!count) - return -ENODEV; - - psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL); + psci_states = kcalloc(num_state_nodes, sizeof(*psci_states), + GFP_KERNEL); if (!psci_states) return -ENOMEM; - for (i = 0; i < count; i++) { + for (i = 0; i < num_state_nodes; i++) { state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + if (!state_node) + break; + ret = psci_dt_parse_state_node(state_node, &psci_states[i]); of_node_put(state_node); @@ -335,6 +329,11 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); } + if (i != num_state_nodes) { + ret = -ENODEV; + goto free_mem; + } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0; From patchwork Mon May 13 19:22:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164055 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728312ili; Mon, 13 May 2019 12:23:17 -0700 (PDT) X-Received: by 2002:a2e:9a94:: with SMTP id p20mr4545227lji.2.1557775397388; Mon, 13 May 2019 12:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775397; cv=none; d=google.com; s=arc-20160816; b=Vi/C38RU2jD0671kMm2CmjGqJiYntLByi52sF/ZAucZ+tZdSVwjVEzoN2JQlSL8Hi+ bv6q7KhCkYQLMZ/T60EP2EGVwhP+K4HmGtvASS1XgQXhrb9Qk2sDliC9W6refonE28bC +aZA7jMzTfp3e8fEjDYaQSUvgkwA6wlUqibAllX9rdp0PhX+idSLfwtJNVgJtxR9LKG0 s0rk3gphi11h/8F07kkdD4iEqE62OnuPABv0nbzgGcEzgFizzOmWo6DfWQBkLhOAcO0N cRdaJbAG9gBh7ZwYFmk07IOGBbdKx0FlIeHgTpvqvNtc23dpus+NxcFpxb7L4J5ISNHx k6WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Nbt/R0uZX9P8HTLZOOX7O4bQjSSh3KmuxEw/gJfnJ0w=; b=UDPxRYVOIpXDDBoLNETszJhOJ0E4P4EjNUTZCdXGjg0iRJ7nOEqhWzpNRiWDNKcDDN /bnFqGZRQeO3faBWqvZuJaaGHuk5JHo0AG5hWdDr9UuFPS3vjpH1bGRv72jk3EtIGBZ0 AFoeZNj2dcY1woqae9E0zuB18LhxKKJMza1CcAxloVeT2KKQP9IAdzZm26fCTiQ0ItPB OLeLd00H7a0hy1lfHRi1rGDuNx6+X5aOV7oONIflYciyVUlfuK/QWp0Dv+yXp0Oks4oz QS/ySWabyLOSHgjrQrd4n1fw5qcLPJA+frhGIJh9TQnOa7r40Jfvei7bbgQGTWvqewkq 4QjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c9ATK+kF; 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 d13sor2981516ljj.14.2019.05.13.12.23.17 for (Google Transport Security); Mon, 13 May 2019 12:23:17 -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=c9ATK+kF; 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; bh=Nbt/R0uZX9P8HTLZOOX7O4bQjSSh3KmuxEw/gJfnJ0w=; b=c9ATK+kF7r7EPNbGkGdt7Bm63ADC4YHAW78L6XgGCewkxmYTEtG+L0LG2PjuZOY9P6 GIc/wvpLNy0UH3lkOe6ZFzROaxSq6yzGyHcvnwD2CRd7HZc2KPc2eU2Qqjw/+V6Y/odG 8g1QUs5Jnsr58ljysRy+9dUb1w4F/dykHejwWNEfEpnjahvDUevoLs2Q6KSLe41qv/kt 0zP1wQEuDypoCPrKTbmlS2icrt04INJA7iFSJ5TpXPM+7IfemYXsH5ks1f1TIKzK3DDH bHfdYw7ILT8JPAFLDWe6W30v1tHH6XaC6WnzwDnPcwbc/4E0bjVz5MHKP4astQUCxbqu Hwvg== 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; bh=Nbt/R0uZX9P8HTLZOOX7O4bQjSSh3KmuxEw/gJfnJ0w=; b=TmWWAILQsu5/MUoj8aUNl8cwllFDrVtY6//vNp4XBt3JoZ7DkOQECmiM+qxvBZXr5K J243oqYI69LZ36YCLm1Yco70mu67Nm6McaxnvzrnuzP9YAay4aB+zS8yCIAomI0sOnHQ 8eUWyssyMsgTglQXVeM3Z000khcOCKPeZjEx30B5Rk+qUjnaZvG1rX33rBqbAbrgAPJr PnxsiK/XrBIsIVLc8tFq/ZmNTBZ8Y6YI+OPuYITp5BEqdiY+Wp1ZUYWaNIERBqeE21/h 1Yc6dTrvZmT95oTodEudbC9BUs2T1b8EUOK6Nzjc7E6dk0Mr+PziJtreKJc0x7eF80Xn JlgA== X-Gm-Message-State: APjAAAVT/fexCtRa54TajjarJ0wtHGuPJmqwHKb1HnIw89W9NAFpAZ6n xvD9pKj7gYj0Gm/jMpNg9aMtDgCJ X-Google-Smtp-Source: APXvYqw/K4DSr+T5mHbidlXB09i9OsKjJE0jmVRY6GRi9vogaHyD5Mxz5/BfqSTiLW4LknGP/8Tf2g== X-Received: by 2002:a2e:1312:: with SMTP id 18mr4211531ljt.79.1557775397083; Mon, 13 May 2019 12:23:17 -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 q21sm3449365lfa.84.2019.05.13.12.23.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:16 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer , Ulf Hansson Subject: [PATCH 06/18] drivers: firmware: psci: Support hierarchical CPU idle states Date: Mon, 13 May 2019 21:22:48 +0200 Message-Id: <20190513192300.653-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> From: Lina Iyer Currently CPU's idle states are represented in a flattened model, via the "cpu-idle-states" binding from within the CPU's device nodes. Support the hierarchical layout, simply by converting to calling the new OF helper, of_get_cpu_state_node(). Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes: - None. --- drivers/firmware/psci/psci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 9c2180bcee4c..b11560f7c4b9 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -316,7 +316,7 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, return -ENOMEM; for (i = 0; i < num_state_nodes; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_get_cpu_state_node(cpu_node, i); if (!state_node) break; From patchwork Mon May 13 19:22:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164056 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728343ili; Mon, 13 May 2019 12:23:19 -0700 (PDT) X-Received: by 2002:ac2:4246:: with SMTP id m6mr82886lfl.0.1557775399146; Mon, 13 May 2019 12:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775399; cv=none; d=google.com; s=arc-20160816; b=a9kYRvrMKrQPeY7BE7puYLMcU60CBfxUPXq4GV1SeQE9HYbPbANxz1L5uFWlkjTDeF BrLtRbLBFcUIFZ9EL980ZgXC53omnSp03ivafGaZsaF2F0q2lKRLrtqOcV/Te6p6Xkfk JTXd3SqoLjFrWwSEziVYy+CVPee/wB/+mIeVTRvWqC5MPHVYY/WMen2VjZquefPBCWMc UeOqKcLvE+96LUPEuxDLBUK3JzMUYNemIQqj0n8c/Zj0b/OvBKm8BQ01Q0LdKR5U8dj7 hW/WEii7hATgBPcrMriJwHclXQIdKeekR+xOUujcCKWbk11EAsNMuT8eqZhDcZqG0VD/ kVyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=Gu7mAuS/u5uDDBWQ3Acq4H8oICjlppPNWwOJj+8NaQ+i1pdJ6qjO99aXFV/PRz97St Nyh/tBpLeLY1IbReJK7IjkbbrF1oQtGgS/qvKpy1avxbxlsn/HHtuo1kJo9QbrrOX0uZ TfXrA5eGhlaaSaZ3Xp2IEkJgngqAwIBkLqodcpRgvZSreStetcFz8/4O8HE1dOiFQyBi 6BsjcsLoYo5rzOXUyWKl/qL5oLNcq4yiS2WpcNcYt/FL0IZlugKfwXiN9JqkeoObWA3x jD74puYvTePpJsSIurqkqDHIdURmVufmH3z7Cr8nPfwKJqWO7Byw07NPnSmBtletFnxy SvUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FV//hyoM"; 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 l24sor3955074lfh.64.2019.05.13.12.23.18 for (Google Transport Security); Mon, 13 May 2019 12:23: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="FV//hyoM"; 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; bh=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=FV//hyoMnEuhzttuAwy+3IjGHtAXZchGsvSZSUyMAJmSDn6Qk/tkPJX+DlL6/5jYzf jjMWLRDOaqPCtvzv2sKC48W9o1aofdOROz4I4viJvVGZPZnvq+pyPn3BVrwCJB/hIPhj xoxPevY6gXOnHpj09x2OwoTmPkocCKVcE7Z93ckD9UyadrfNo3LJ7pOTKkOK+xuf6SLV Afnne5GeWsYyFeQRUOEE13gZvwjrLN5xx482cgJ/AFWRxxE3zyhRueMlyLJa7HIuxd+d tSoTPkin1gaqwGLGobS1zs6UV3QuJLhH0X8bHUVoBjRumtVozN5vQTbZ8hJpt19iAGq+ W/Ww== 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; bh=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=meBVEyk8T2zqyst1gvlEh74hgLkKcKxMREe2PFmNnOQJfHx3tBBhgxIsxHe+AER2nW 5hebIBynOl59+IRg1bSVfdzxFLYEQoqNOqVmPWTaoxezdo/pDWdDwFhoJV4t+56gSNIp eNjdvspbCqAw1vGUj9xI9/NH4/PZernGQYmrPz3bCytv5RfIrmxTxytUPJsPBZTmd81d TOcDCBzoQTFahjhdMt79psWY5d+TmF2UuqjnmNnlKwb6Xf9yT2xSKuWZX7eTq0kITQwR 15d8lKftlxQ16SdoFhVu+b9NjUT0rSJ49m1/Qwcn+fFlQ16F4Pfz5HPRx9FWgUWQfcLZ w2kw== X-Gm-Message-State: APjAAAWoRPuTmXb2C3Td+GEdY3RmGuXPJb4MTDDA0Bf1JnLs8iKXosUw d0hDPchIaW0BsDtGU11yvijd9VD1 X-Google-Smtp-Source: APXvYqw2t+LdElc4Xj4e0QzMBJlLjpK3q+ffxnx73kmsSfuwHRWHbqmUdPJVxZsVxNzXZK8vAzoQbQ== X-Received: by 2002:a19:4a04:: with SMTP id x4mr14103234lfa.124.1557775398769; Mon, 13 May 2019 12:23:18 -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 q21sm3449365lfa.84.2019.05.13.12.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:18 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Lina Iyer Subject: [PATCH 07/18] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Mon, 13 May 2019 21:22:49 +0200 Message-Id: <20190513192300.653-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> The per CPU variable psci_power_state, contains an array of fixed values, which reflects the corresponding arm,psci-suspend-param parsed from DT, for each of the available CPU idle states. This isn't sufficient when using the hierarchical CPU topology in DT in combination with having PSCI OS initiated (OSI) mode enabled. More precisely, in OSI mode, Linux is responsible of telling the PSCI FW what idle state the cluster (a group of CPUs) should enter, while in PSCI Platform Coordinated (PC) mode, each CPU independently votes for an idle state of the cluster. For this reason, let's introduce an additional per CPU variable called domain_state and implement two helper functions to read/write its values. Following patches, which implements PM domain support for PSCI, will use the domain_state variable and set it to corresponding bits that represents the selected idle state for the cluster. Finally, in psci_cpu_suspend_enter() and psci_suspend_finisher(), let's take into account the values in the domain_state, as to get the complete suspend parameter. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - Clarify changelog. - Drop changes in psci_cpu_on() as it belongs in the patch for hotplug. - Move some code inside "#ifdef CONFIG_CPU_IDLE". --- drivers/firmware/psci/psci.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index b11560f7c4b9..4aec513136e4 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -285,6 +285,17 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +static DEFINE_PER_CPU(u32, domain_state); + +static inline u32 psci_get_domain_state(void) +{ + return __this_cpu_read(domain_state); +} + +static inline void psci_set_domain_state(u32 state) +{ + __this_cpu_write(domain_state, state); +} static int psci_dt_parse_state_node(struct device_node *np, u32 *state) { @@ -420,15 +431,17 @@ int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu) static int psci_suspend_finisher(unsigned long index) { u32 *state = __this_cpu_read(psci_power_state); + u32 composite_state = state[index - 1] | psci_get_domain_state(); - return psci_ops.cpu_suspend(state[index - 1], - __pa_symbol(cpu_resume)); + return psci_ops.cpu_suspend(composite_state, __pa_symbol(cpu_resume)); } int psci_cpu_suspend_enter(unsigned long index) { int ret; u32 *state = __this_cpu_read(psci_power_state); + u32 composite_state = state[index - 1] | psci_get_domain_state(); + /* * idle state index 0 corresponds to wfi, should never be called * from the cpu_suspend operations @@ -436,11 +449,14 @@ int psci_cpu_suspend_enter(unsigned long index) if (WARN_ON_ONCE(!index)) return -EINVAL; - if (!psci_power_state_loses_context(state[index - 1])) - ret = psci_ops.cpu_suspend(state[index - 1], 0); + if (!psci_power_state_loses_context(composite_state)) + ret = psci_ops.cpu_suspend(composite_state, 0); else ret = cpu_suspend(index, psci_suspend_finisher); + /* Clear the domain state to start fresh when back from idle. */ + psci_set_domain_state(0); + return ret; } From patchwork Mon May 13 19:22:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164057 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728376ili; Mon, 13 May 2019 12:23:21 -0700 (PDT) X-Received: by 2002:a19:9f01:: with SMTP id i1mr13971956lfe.98.1557775401147; Mon, 13 May 2019 12:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775401; cv=none; d=google.com; s=arc-20160816; b=OmA1zewHfpxkNvnlEI3j+l1g9tYS3idEnDE7zhMHNsSGTGg260RBTAnTYGgH1VfOZ7 2D6SbHq5IESMA4FhwVH3847z8gIc/VrXx/7kVx+vwt/90o1f/qrVM1mIj1cVMo6ftL9I i8xFpH5UiqMFFlXYI3YKI2Vx22dNHsAO7TmtQsZH1ICjBF0JSjjlicjwNJPXQHgpFjFi F07BPWYYP88OzC7TO7F9922kFx52m2saRzTtU/hbDNng1CNQqsBsgF6fnHumM5pydC9f c3xdqX4lHylt2TZRWA+0Hcctz03bJfBCTQXcUgctmnIAxbKS8Fd4e8+Z4s4hhc4sOEZK AGjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tL+sK5pEBsAoCFopnPPwt4es9T7EwxPGgYEkm8O7IBI=; b=u9illhJ1WvKn7gMkWKIKxqP9HPMb7tCICnzvHnwJ2L8hQt/RKpyXq4qdLwsyD40gGo eDNn5pJYY71g8NxCo9PuCUZC/Sjv3P1fQrG1nuYLMOTSO8qcdQmy0kDp7vyhb3BetVDV CzKVXNjR3TVZ5n3sKMvT4d5e8/seCNopZ08hoCOFuTapVwx0SR6ScPuwY2+3sAINa0Cd 1mtddmQ55eilbM2p1KAcRCMKQ5r8aZ0nvvEZbT1QtYTIglvdEG6b1m23q5bFSpHAN7Nt D/zP0RqvFqLnOGDl70D4cYuFj+0NwNK7quYRUVPWuwXECPzs0ComKp9331l59nYIDSkn qpCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PleXZ03X; 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 m80sor2938830lje.32.2019.05.13.12.23.20 for (Google Transport Security); Mon, 13 May 2019 12:23:21 -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=PleXZ03X; 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; bh=tL+sK5pEBsAoCFopnPPwt4es9T7EwxPGgYEkm8O7IBI=; b=PleXZ03XqpXkNBmDfAycSfGQdOAnwKcgjPE/yvddT6ahyVQYQIimbvzlM0ZT24i2e5 LUFZWo+Tdttrv0PhN9+zyZsiyAIl0piyFql/WuOFoJwf6rT/ApfowwA2yVJk5ycqSnHJ tVjZQ/8bSIufYfq7D+pcmCxP7awzaUFp1ndubavu4Rg3LGgEgIDKhT1v5im0eJXErzwM yeE7sM0FGOsZqtCWMwGXPx4qW6dtJwALcEcJrbDFKC6sEY00Uvvm8/vcCf8KVozLm45m GNwRj8IB28P/Qgq9gd8i2bHXXGget+HBMR2KuUq4pUtz49trTZoVO+c/X53DLD2flOHv U9zg== 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; bh=tL+sK5pEBsAoCFopnPPwt4es9T7EwxPGgYEkm8O7IBI=; b=iYS/4mE9xTR7pEGEflpKb2QSs3opovaQnzne9Vmp/jxZzKKizocv+u39+icHGj38By ZgoVPpAlUSr8NQk4N9lzf7jn4zNQlqLW9Dgz2bHiDIOnRX79mncb2kKJKg6U4mUsTJWv 6pGbfYUsCFzV6Qsby7Wj0exjd3QGVvlwBkm6PCUXFMmQZua4W7tPeh3JBQwpB9bMuuK0 gz+JyyRMVR3b12oD/cYK++bqmb8JTy04zVaHoVCEGH4zPs+9s8hvAEVvJDUjzK69III4 pEPPwr4FVA2E6O5dsBLrxcmrZH6B4dqaU9a1NX0Wu6c9phOrcI5HTyYCh/pPnQjWLFyE 11bQ== X-Gm-Message-State: APjAAAUbCc7D99fX3MC5r6JrcJz/nCCGgyLZoyNjgmTnYhS87ZITejoc zLAhZBMgJwVFjEiEat0GU0SYqUB+ X-Google-Smtp-Source: APXvYqx4whMnRpTm4m80h2xmvQbwZJE+FnBv/f7E0p3WgnHRPkfQ9mN1Bj/AUSzvNa+UTmcvCbPkvw== X-Received: by 2002:a2e:81cf:: with SMTP id s15mr14626643ljg.193.1557775400776; Mon, 13 May 2019 12:23:20 -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 q21sm3449365lfa.84.2019.05.13.12.23.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:19 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 08/18] drivers: firmware: psci: Prepare to support PM domains Date: Mon, 13 May 2019 21:22:50 +0200 Message-Id: <20190513192300.653-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> Subsequent changes implements support for PM domains to PSCI. Those changes are mainly implemented in a new separate c-file, hence a couple of the internal PSCI functions needs to be shared to be accessible. Let's do that via adding a new PSCI header file. Moreover, to implement support for PM domains, switching the PSCI FW into the OS initiated mode is sometimes needed. Therefore, let's share a new function that implement this. Signed-off-by: Ulf Hansson --- Changes: - Convert psci_set_osi_mode() to return an int. - Don't share psci_get_domain_state() as that's no longer needed. - Update changelog. --- drivers/firmware/psci/psci.c | 17 ++++++++++++++--- drivers/firmware/psci/psci.h | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 drivers/firmware/psci/psci.h -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 4aec513136e4..0e91d864e346 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -34,6 +34,8 @@ #include #include +#include "psci.h" + /* * While a 64-bit OS can make calls with SMC32 calling conventions, for some * calls it is necessary to use SMC64 to pass or return 64-bit values. @@ -96,7 +98,7 @@ static inline bool psci_has_ext_power_state(void) PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; } -static inline bool psci_has_osi_support(void) +bool psci_has_osi_support(void) { return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; } @@ -161,6 +163,15 @@ static u32 psci_get_version(void) return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); } +int psci_set_osi_mode(void) +{ + int err; + + err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + return psci_to_linux_errno(err); +} + static int psci_cpu_suspend(u32 state, unsigned long entry_point) { int err; @@ -292,12 +303,12 @@ static inline u32 psci_get_domain_state(void) return __this_cpu_read(domain_state); } -static inline void psci_set_domain_state(u32 state) +void psci_set_domain_state(u32 state) { __this_cpu_write(domain_state, state); } -static int psci_dt_parse_state_node(struct device_node *np, u32 *state) +int psci_dt_parse_state_node(struct device_node *np, u32 *state) { int err = of_property_read_u32(np, "arm,psci-suspend-param", state); diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h new file mode 100644 index 000000000000..f2277c3ad405 --- /dev/null +++ b/drivers/firmware/psci/psci.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PSCI_H +#define __PSCI_H + +struct device_node; + +int psci_set_osi_mode(void); +bool psci_has_osi_support(void); + +#ifdef CONFIG_CPU_IDLE +void psci_set_domain_state(u32 state); +int psci_dt_parse_state_node(struct device_node *np, u32 *state); +#endif + +#endif /* __PSCI_H */ From patchwork Mon May 13 19:22:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164058 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728403ili; Mon, 13 May 2019 12:23:23 -0700 (PDT) X-Received: by 2002:ac2:4893:: with SMTP id x19mr14092992lfc.109.1557775403036; Mon, 13 May 2019 12:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775403; cv=none; d=google.com; s=arc-20160816; b=DyU9mzQmZUUaLqQtb2ttD2JiYlHxAGlOGf22p6dVuEzcviU8sPS+ipj/XjI3+lLlbk 6jrdY+vYZgRFUNvvz7I6erdFIwAKUim+0oGrexqB37lXynu/PzvzoTpmjO6ngqYfBd6n pw6qC4FsOquZ2os7K9i6Bv27RQ5ZsMNMPpqk/H3E0dFLkX0fp0TtEtbDEyKxNlaAFafH QWEsiCZxrKLkp/nIbnVcZ3ypVq3Qh5ixhHGay4nQJs1gjxXjhcq5TZiPD8NaBMHMgl2v HMs6H/0skYyKzAkDhFAF9zL31IJ27ebvxqhRuJhjZwFAXrDqJPw7Q6pzzp6s9DV1Gg9a h7EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0Bq5498AOcSF9nWVNbhGQT9xwPiaFsmcqnV/fxv1rlk=; b=w5ygo4oQQrF+T7N5PcODVqv7RaUa+yE0OvRSHxljMqcLBu35F7Lg2L0DjxN9yblejU XnkwAJFOpGj1rPSFAe5Cmt6uxbzgZXBUaI2zHRAuOF0ocT7zEs4H9+E6eyVyupXkGiyB EBPJFnArHgUomlx0O1SsUzIQspOcjn1syd1yDGh1v8JcCgOE4gAprtiFfj2ZQtkkzFvi r32vbDDKs6ALiEpVAhpAbSHQoJtGaTYx3gkUgmX3vODAHYwggqLtBokp89lSwao8t7ht 4L6zu1wTp+H6AK8KThp22oQmeA7Jn5N1AhDwsOVe6mf14R0RMxkJ1cS5FH/vasIjqlZk 2UFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W4GhQnl8; 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 a5sor2989792lji.21.2019.05.13.12.23.22 for (Google Transport Security); Mon, 13 May 2019 12:23:23 -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=W4GhQnl8; 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; bh=0Bq5498AOcSF9nWVNbhGQT9xwPiaFsmcqnV/fxv1rlk=; b=W4GhQnl8ZsdBUVqc7l5KLussGmwg71kqOstSI+0Ph1Lr8vtPu9C8+icwujP0k7qwj9 5TvlopE+qiKZV7fIhJrr2LcsOWK4knRqcbjI3G606AbC5uurrDPc2GBqBm2Z8X7wFqcb xuy2+GAFpVZPm3a4PgV1+kuQcOFBsu5X8EQf3CLRm/NY65JX12Jphpgy0BQ+ErCA8MCX XsgxxvmN9Z8ltKyBNnDzlSHpbzkBWLl35VLjd/y7Rf4k97Vd2ckc3dCg4vydyK0sZ/nj C2KJHlpK/BuH7Z72z3Gs9vGq81hQW/3d8xcMAg7uKl8L8MYlYOGjQS9YqTX6hTirdBD6 +zBw== 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; bh=0Bq5498AOcSF9nWVNbhGQT9xwPiaFsmcqnV/fxv1rlk=; b=TJxTLfMOcRyRtqOmUMBhE9bPBCBXH1EjqeNShdK0FsyilYZkNJvts9VgOcESwk03ZM XcBrrVTnVKVjWQfks+76/jWsAyWQL2UnbVIFGEk/dGlY4DRtKnWDEMIBlPI3LbmJ/JFq WUfVVWRVERmhdxIwRhI+dJ95xBZDOxTuwsFj42nFRa12uGJwnfXjlQf8RKfWXE1QzMX4 jnSHqpTnOohBf7c4hVWycK9aDiBK/vT6/DCUgNYzlD+VArh8aVcxYXYdd5h82feVkG3t VoOasmpBMNNcQZRiJEbIbwxLOA2mnB0Mq/p7gWwXy5DZucH52g8r8/Ff7JqM9rSeHEaH X8zA== X-Gm-Message-State: APjAAAVh4E6d5Pm/0XXBx3B0hqKQy/NKLJN+wjtHi6KrJbCOoVwFjKeP yo2JxXE+L98BwaFaGG6xUAzYs4vB X-Google-Smtp-Source: APXvYqw7+OiJXxfFee31pCrymAeYS08U5pee+00MkBLRYZuV1nu61St5Md6HOWASXzRRprmmKqAw5g== X-Received: by 2002:a2e:92ce:: with SMTP id k14mr14559128ljh.83.1557775402543; Mon, 13 May 2019 12:23:22 -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 q21sm3449365lfa.84.2019.05.13.12.23.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:21 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Lina Iyer Subject: [PATCH 09/18] drivers: firmware: psci: Add support for PM domains using genpd Date: Mon, 13 May 2019 21:22:51 +0200 Message-Id: <20190513192300.653-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> When the hierarchical CPU topology layout is used in DT, we need to setup the corresponding PM domain data structures, as to allow a CPU and a group of CPUs to be power managed accordingly. Let's enable this by deploying support through the genpd interface. Additionally, when the OS initiated mode is supported by the PSCI FW, let's also parse the domain idle states DT bindings as to make genpd responsible for the state selection, when the states are compatible with "domain-idle-state". Otherwise, when only Platform Coordinated mode is supported, we rely solely on the state selection to be managed through the regular cpuidle framework. If the initialization of the PM domain data structures succeeds and the OS initiated mode is supported, we try to switch to it. In case it fails, let's fall back into a degraded mode, rather than bailing out and returning an error code. Due to that the OS initiated mode may become enabled, we need to adjust to maintain backwards compatibility for a kernel started through a kexec call. Do this by explicitly switch to Platform Coordinated mode during boot. Finally, the actual initialization of the PM domain data structures, is done via calling the new shared function, psci_dt_init_pm_domains(). However, this is implemented by subsequent changes. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - Simplify code setting domain_state at power off. - Use the genpd ->free_state() callback to manage freeing of states. - Fixup a bogus while loop. --- drivers/firmware/psci/Makefile | 2 +- drivers/firmware/psci/psci.c | 7 +- drivers/firmware/psci/psci.h | 5 + drivers/firmware/psci/psci_pm_domain.c | 268 +++++++++++++++++++++++++ 4 files changed, 280 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/psci/psci_pm_domain.c -- 2.17.1 diff --git a/drivers/firmware/psci/Makefile b/drivers/firmware/psci/Makefile index 1956b882470f..ff300f1fec86 100644 --- a/drivers/firmware/psci/Makefile +++ b/drivers/firmware/psci/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 # -obj-$(CONFIG_ARM_PSCI_FW) += psci.o +obj-$(CONFIG_ARM_PSCI_FW) += psci.o psci_pm_domain.o obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 0e91d864e346..bfef300b7ebe 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -721,9 +721,14 @@ static int __init psci_1_0_init(struct device_node *np) if (err) return err; - if (psci_has_osi_support()) + if (psci_has_osi_support()) { pr_info("OSI mode supported.\n"); + /* Make sure we default to PC mode. */ + invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_PC, 0, 0); + } + return 0; } diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index f2277c3ad405..00d2e3dcef49 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -11,6 +11,11 @@ bool psci_has_osi_support(void); #ifdef CONFIG_CPU_IDLE void psci_set_domain_state(u32 state); int psci_dt_parse_state_node(struct device_node *np, u32 *state); +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF +int psci_dt_init_pm_domains(struct device_node *np); +#else +static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } +#endif #endif #endif /* __PSCI_H */ diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c new file mode 100644 index 000000000000..3c6ca846caf4 --- /dev/null +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PM domains for CPUs via genpd - managed by PSCI. + * + * Copyright (C) 2019 Linaro Ltd. + * Author: Ulf Hansson + * + */ + +#define pr_fmt(fmt) "psci: " fmt + +#include +#include +#include +#include +#include + +#include "psci.h" + +#if defined(CONFIG_CPU_IDLE) && defined(CONFIG_PM_GENERIC_DOMAINS_OF) + +struct psci_pd_provider { + struct list_head link; + struct device_node *node; +}; + +static LIST_HEAD(psci_pd_providers); +static bool osi_mode_enabled; + +static int psci_pd_power_off(struct generic_pm_domain *pd) +{ + struct genpd_power_state *state = &pd->states[pd->state_idx]; + u32 *pd_state; + + /* If we have failed to enable OSI mode, then abort power off. */ + if (psci_has_osi_support() && !osi_mode_enabled) + return -EBUSY; + + if (!state->data) + return 0; + + /* When OSI mode is enabled, set the corresponding domain state. */ + pd_state = state->data; + psci_set_domain_state(*pd_state); + + return 0; +} + +static int psci_pd_parse_state_nodes(struct genpd_power_state *states, + int state_count) +{ + int i, ret; + u32 psci_state, *psci_state_buf; + + for (i = 0; i < state_count; i++) { + ret = psci_dt_parse_state_node(to_of_node(states[i].fwnode), + &psci_state); + if (ret) + goto free_state; + + psci_state_buf = kmalloc(sizeof(u32), GFP_KERNEL); + if (!psci_state_buf) { + ret = -ENOMEM; + goto free_state; + } + *psci_state_buf = psci_state; + states[i].data = psci_state_buf; + } + + return 0; + +free_state: + i--; + for (; i >= 0; i--) + kfree(states[i].data); + return ret; +} + +static int psci_pd_parse_states(struct device_node *np, + struct genpd_power_state **states, int *state_count) +{ + int ret; + + /* Parse the domain idle states. */ + ret = of_genpd_parse_idle_states(np, states, state_count); + if (ret) + return ret; + + /* Fill out the PSCI specifics for each found state. */ + ret = psci_pd_parse_state_nodes(*states, *state_count); + if (ret) + kfree(*states); + + return ret; +} + +static void psci_pd_free_states(struct genpd_power_state *states, + unsigned int state_count) +{ + int i; + + for (i = 0; i < state_count; i++) + kfree(states[i].data); + kfree(states); +} + +static int psci_pd_init(struct device_node *np) +{ + struct generic_pm_domain *pd; + struct psci_pd_provider *pd_provider; + struct dev_power_governor *pd_gov; + struct genpd_power_state *states = NULL; + int ret = -ENOMEM, state_count = 0; + + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) + goto out; + + pd_provider = kzalloc(sizeof(*pd_provider), GFP_KERNEL); + if (!pd_provider) + goto free_pd; + + pd->name = kasprintf(GFP_KERNEL, "%pOF", np); + if (!pd->name) + goto free_pd_prov; + + /* + * For OSI mode, parse the domain idle states and let genpd manage the + * state selection for those being compatible with "domain-idle-state". + */ + if (psci_has_osi_support()) { + ret = psci_pd_parse_states(np, &states, &state_count); + if (ret) + goto free_name; + pd->free_states = psci_pd_free_states; + } + + pd->name = kbasename(pd->name); + pd->power_off = psci_pd_power_off; + pd->states = states; + pd->state_count = state_count; + pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN; + + /* Use governor for CPU PM domains if it has some states to manage. */ + pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL; + + ret = pm_genpd_init(pd, pd_gov, false); + if (ret) { + psci_pd_free_states(states, state_count); + goto free_name; + } + + ret = of_genpd_add_provider_simple(np, pd); + if (ret) + goto remove_pd; + + pd_provider->node = of_node_get(np); + list_add(&pd_provider->link, &psci_pd_providers); + + pr_debug("init PM domain %s\n", pd->name); + return 0; + +remove_pd: + pm_genpd_remove(pd); +free_name: + kfree(pd->name); +free_pd_prov: + kfree(pd_provider); +free_pd: + kfree(pd); +out: + pr_err("failed to init PM domain ret=%d %pOF\n", ret, np); + return ret; +} + +static void psci_pd_remove(void) +{ + struct psci_pd_provider *pd_provider, *it; + struct generic_pm_domain *genpd; + + list_for_each_entry_safe(pd_provider, it, &psci_pd_providers, link) { + of_genpd_del_provider(pd_provider->node); + + genpd = of_genpd_remove_last(pd_provider->node); + if (!IS_ERR(genpd)) + kfree(genpd); + + of_node_put(pd_provider->node); + list_del(&pd_provider->link); + kfree(pd_provider); + } +} + +static int psci_pd_init_topology(struct device_node *np) +{ + struct device_node *node; + struct of_phandle_args child, parent; + int ret; + + for_each_child_of_node(np, node) { + if (of_parse_phandle_with_args(node, "power-domains", + "#power-domain-cells", 0, &parent)) + continue; + + child.np = node; + child.args_count = 0; + + ret = of_genpd_add_subdomain(&parent, &child); + of_node_put(parent.np); + if (ret) { + of_node_put(node); + return ret; + } + } + + return 0; +} + +int psci_dt_init_pm_domains(struct device_node *np) +{ + struct device_node *node; + int ret, pd_count = 0; + + /* + * Parse child nodes for the "#power-domain-cells" property and + * initialize a genpd/genpd-of-provider pair when it's found. + */ + for_each_child_of_node(np, node) { + if (!of_find_property(node, "#power-domain-cells", NULL)) + continue; + + ret = psci_pd_init(node); + if (ret) + goto put_node; + + pd_count++; + } + + /* Bail out if not using the hierarchical CPU topology. */ + if (!pd_count) + return 0; + + /* Link genpd masters/subdomains to model the CPU topology. */ + ret = psci_pd_init_topology(np); + if (ret) + goto remove_pd; + + /* Try to enable OSI mode if supported. */ + if (psci_has_osi_support()) { + ret = psci_set_osi_mode(); + if (ret) + pr_warn("failed to enable OSI mode: %d\n", ret); + else + osi_mode_enabled = true; + } + + pr_info("Initialized CPU PM domain topology\n"); + return pd_count; + +put_node: + of_node_put(node); +remove_pd: + if (pd_count) + psci_pd_remove(); + pr_err("failed to create CPU PM domains ret=%d\n", ret); + return ret; +} +#endif From patchwork Mon May 13 19:22:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164059 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728435ili; Mon, 13 May 2019 12:23:24 -0700 (PDT) X-Received: by 2002:a2e:3607:: with SMTP id d7mr12888993lja.188.1557775404750; Mon, 13 May 2019 12:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775404; cv=none; d=google.com; s=arc-20160816; b=osuHFGPo5+RUlSD16NX+Dvu5Y1nSotAC48qkP6/otORe/rABI7FeOOeftIEnEuWkHd 5BB//8Zwsd5fXAmFh7x7rTQJe40JLH7WUh8tfuLz+yz6QoNZr2RX0ZoOb4LuJxavrNbu qvbkQSef3owxEspC6jDI5Ov+J6UJg71iC53Pi8A8knP2AXWbdhhkreccSgEP/osuoAP9 YtAb4jS1Mb9UwkR76BwRhYgORoXQ9D6UZe4jfyNcLtd9k9Z1nawwItUi4E1hBtFtedPj TidNVbpddYRUULwYdGuW3GgYIN5O3H4KW+l2s+qu/2OZY4JDnjQJu/oEqa0oyQTmSeh8 Mhfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v5R43yf4/qed6bgDurPjUl3jOQa4Rl4O09rX4nZosQI=; b=ROwc24u1kZ09lK5o0ml+YHVIrUOjWNrTYpPDEmLL4UFqwaS7tdMhVbLdiLuLGQ4Jfw WnVuFvGx1iA1Mod8Pn7jyWhFF9LAZo9DCB4W2Gzv71Sj7rSGNdlLyDJccUKuPPEBWN6O Zj2gLHFN0ftzlu61e00yeffo6ipblmc1TLOGvfLjfj8QN/Y+J6QUB2796eYAxc8FLNKE QQGcsGln1sWRUcetl2seMIYpXfxGNWRKv4rPcf3b/khNPtM2y36ooeUklZ/LvwhqBAvL PugvFR79BAlR+9Rmu7M16bQxVcSMYoqRkzXaQpzAAF8eOX4r7FLfI4HbRgNitKkRm49C BKWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n1vBqM2W; 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 y18sor2971579lji.38.2019.05.13.12.23.24 for (Google Transport Security); Mon, 13 May 2019 12:23:24 -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=n1vBqM2W; 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; bh=v5R43yf4/qed6bgDurPjUl3jOQa4Rl4O09rX4nZosQI=; b=n1vBqM2Wy+eX7IIQwl58KXauTGw8VuTEGAX0h49n6Y7x7DeOz7yckXoyzuskCHuZba 1xAff9sl5Pn24Ww5EjGImQxE+Xjp0ZlEpFiRP2XtesR7J79ntNXSjy5FeLhv2J8vZg+s HvwlRlO1bFAQ2/iSrQsGbnUzYubUQ1MND9xOUp8qstnZys3tixpffazhGjpJm2B4Cs0K +wZIkTKzjh7afvMrsGBeVFajOFnWn4D56sbRZOF7ZTR2lA4wT3bBpQp+eeoG2HSjPOm7 jEERqEEeDnlsjbgODSFVGzARt+Jknp8L9nxIOXc38jr5PsMUb8Vm3lVE80bFETDWU2ua nuzw== 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; bh=v5R43yf4/qed6bgDurPjUl3jOQa4Rl4O09rX4nZosQI=; b=kYMFjFAF+39G+LI1vd5iPURntqgTRwgfwX5RYIMxpXSqFtm1OZvfmyc4BNs+6fH3YX OZg8Es0Vh9/dGS2teykbkjOd86Jmso6IuB6mq3KZvduwKZk1VMsrwzNgA+MHcusrbJY8 0xAPfY0kHHbz/5sybP/HCEUy2NNcd3iKFh7iqfz4alBqk4l9mXuwzajjrvaZ4BetsmgJ 77E3I/QTbwQLYhPO3qS0PF6GNw7h3F7906Ne3s88DKc7CTEvB4zBzDAllwMrxoadBr9i RIA9UqRicH0Yo5wPC+ZaHqOiacIHf7jNoQgdx+FS8zcuvuEMwA8i9AUn15ESMe2/rb/S HU7Q== X-Gm-Message-State: APjAAAXFYAhG6cz9iG2S8/KLAmY6OZ4aW/NxL4J5n+V//X9RDz6WhVkI UM+haIQdItcJ/0Pue2C8cSxH5LQv X-Google-Smtp-Source: APXvYqx2Vh1KSuzK1Is/V87g7ZsLmQej7M/ZhTd5zzA/N3YXZQ+9NtPLtW9JLqQfxVA+I0oz+0bQLw== X-Received: by 2002:a2e:4701:: with SMTP id u1mr10153531lja.38.1557775404368; Mon, 13 May 2019 12:23:24 -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 q21sm3449365lfa.84.2019.05.13.12.23.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:23 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 10/18] drivers: firmware: psci: Add hierarchical domain idle states converter Date: Mon, 13 May 2019 21:22:52 +0200 Message-Id: <20190513192300.653-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> If the hierarchical CPU topology is used, but the OS initiated mode isn't supported, we need to rely solely on the regular cpuidle framework to manage the idle state selection, rather than using genpd and its governor. For this reason, introduce a new PSCI DT helper function, psci_dt_pm_domains_parse_states(), which parses and converts the hierarchically described domain idle states from DT, into regular flattened cpuidle states. The converted states are added to the existing cpuidle driver's array of idle states, which make them available for cpuidle. Signed-off-by: Ulf Hansson --- Changes: - Some simplification of the code. --- drivers/firmware/psci/psci.h | 5 ++ drivers/firmware/psci/psci_pm_domain.c | 118 +++++++++++++++++++++++++ 2 files changed, 123 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index 00d2e3dcef49..c36e0e6649e9 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -3,6 +3,7 @@ #ifndef __PSCI_H #define __PSCI_H +struct cpuidle_driver; struct device_node; int psci_set_osi_mode(void); @@ -13,8 +14,12 @@ void psci_set_domain_state(u32 state); int psci_dt_parse_state_node(struct device_node *np, u32 *state); #ifdef CONFIG_PM_GENERIC_DOMAINS_OF int psci_dt_init_pm_domains(struct device_node *np); +int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, + struct device_node *cpu_node, u32 *psci_states); #else static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } +static inline int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, + struct device_node *cpu_node, u32 *psci_states) { return 0; } #endif #endif diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c index 3c6ca846caf4..3aa645dba81b 100644 --- a/drivers/firmware/psci/psci_pm_domain.c +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -14,6 +14,10 @@ #include #include #include +#include +#include + +#include #include "psci.h" @@ -104,6 +108,53 @@ static void psci_pd_free_states(struct genpd_power_state *states, kfree(states); } +static int psci_pd_enter_pc(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx); +} + +static void psci_pd_enter_s2idle_pc(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + psci_pd_enter_pc(dev, drv, idx); +} + +static void psci_pd_convert_states(struct cpuidle_state *idle_state, + u32 *psci_state, struct genpd_power_state *state) +{ + u32 *state_data = state->data; + u64 target_residency_us = state->residency_ns; + u64 exit_latency_us = state->power_on_latency_ns + + state->power_off_latency_ns; + + *psci_state = *state_data; + do_div(target_residency_us, 1000); + idle_state->target_residency = target_residency_us; + do_div(exit_latency_us, 1000); + idle_state->exit_latency = exit_latency_us; + idle_state->enter = &psci_pd_enter_pc; + idle_state->enter_s2idle = &psci_pd_enter_s2idle_pc; + idle_state->flags |= CPUIDLE_FLAG_TIMER_STOP; + + strncpy(idle_state->name, to_of_node(state->fwnode)->name, + CPUIDLE_NAME_LEN - 1); + strncpy(idle_state->desc, to_of_node(state->fwnode)->name, + CPUIDLE_NAME_LEN - 1); +} + +static bool psci_pd_is_provider(struct device_node *np) +{ + struct psci_pd_provider *pd_prov, *it; + + list_for_each_entry_safe(pd_prov, it, &psci_pd_providers, link) { + if (pd_prov->node == np) + return true; + } + + return false; +} + static int psci_pd_init(struct device_node *np) { struct generic_pm_domain *pd; @@ -265,4 +316,71 @@ int psci_dt_init_pm_domains(struct device_node *np) pr_err("failed to create CPU PM domains ret=%d\n", ret); return ret; } + +int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, + struct device_node *cpu_node, u32 *psci_states) +{ + struct genpd_power_state *pd_states; + struct of_phandle_args args; + int ret, pd_state_count, i, state_idx, psci_idx; + u32 cpu_psci_state = psci_states[drv->state_count - 2]; + struct device_node *np = of_node_get(cpu_node); + + + /* Walk the CPU topology to find compatible domain idle states. */ + while (np) { + ret = of_parse_phandle_with_args(np, "power-domains", + "#power-domain-cells", 0, &args); + of_node_put(np); + if (ret) + return 0; + + np = args.np; + + /* Verify that the node represents a psci pd provider. */ + if (!psci_pd_is_provider(np)) { + of_node_put(np); + return 0; + } + + /* Parse for compatible domain idle states. */ + ret = psci_pd_parse_states(np, &pd_states, &pd_state_count); + if (ret) { + of_node_put(np); + return ret; + } + + i = 0; + while (i < pd_state_count) { + + state_idx = drv->state_count; + if (state_idx >= CPUIDLE_STATE_MAX) { + pr_warn("exceeding max cpuidle states\n"); + of_node_put(np); + return 0; + } + + /* WFI state is not part of psci_states. */ + psci_idx = state_idx - 1 + i; + psci_pd_convert_states(&drv->states[state_idx + i], + &psci_states[psci_idx], &pd_states[i]); + + /* + * In the hierarchical CPU topology the master PM domain + * idle state's DT property, "arm,psci-suspend-param", + * don't contain the bits for the idle state of the CPU, + * let's add those here. + */ + psci_states[psci_idx] |= cpu_psci_state; + pr_debug("psci-power-state %#x index %d\n", + psci_states[psci_idx], psci_idx); + + drv->state_count++; + i++; + } + psci_pd_free_states(pd_states, pd_state_count); + } + + return 0; +} #endif From patchwork Mon May 13 19:22:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164060 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728465ili; Mon, 13 May 2019 12:23:26 -0700 (PDT) X-Received: by 2002:a2e:41c:: with SMTP id 28mr12895750lje.69.1557775406521; Mon, 13 May 2019 12:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775406; cv=none; d=google.com; s=arc-20160816; b=i/qlOZDdp397FsX6KdByBNeG2JqDrxrE2AsemnKntp74wJrMvFeplFiYgj2LUrokvi mtYPnl9yPSZxfjHyngXHx5Ms6MzNJ1GaBANzeevbKJuA1jkJhImdpkTClgycYC98/Ksk AWJDf0SryHFeQDolbLJijfVyXRDlKlXO6wNV0xKZ0b7KP3aR8D238UFCM2YwmxyXSuz1 ZmzWI3JtQFyOS97kv2/Hor7lt7ypQ5540QWGoByOczbQM8xybe+XvZBmKU5+EaLbPV3S ukjQXHHwmZucZSh3obSCAsEZ4xq8ZCw0I/8Wex/lTM5Z+AWd7AojEs2S0M0nqo4XAP6J hY/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XTy06JPjF+Flbr9WT5p68Fa18r9/HEAcUQNjh0fiSxI=; b=TtCDOhi45dZ89JLWm6N8LgfyBx2JMH8t8dLrZR/Ci/NiaVj4agvkQDYFy1G3FCqOt+ 9ly/MnnxP8gZzXswtu9Gqgw5BpRoy7oJmhT7S0ybtHuO3s5MyauvYEveuAavuRHCLbhy bYUi06lFkh44o5BCXgsUDUuF71C1DBejj1NunK+IWiO0gvFDZF5bPCIBeLpijG5zo+s1 nmkrwt3FM+1aq+XdeE/jzKpy2cotvrou5xrwt26tLgrlDfuv1WlZzCbdLbSM8d+8IZQu BvVA+LcBRLSvndcmPR4EOMjv6sw1J1UdUU2/yVdsVWdGWeqxovJgNrNtBDKziwL6ytdx dJpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xNwX3XNe; 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 65sor3934294lfa.34.2019.05.13.12.23.26 for (Google Transport Security); Mon, 13 May 2019 12:23:26 -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=xNwX3XNe; 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; bh=XTy06JPjF+Flbr9WT5p68Fa18r9/HEAcUQNjh0fiSxI=; b=xNwX3XNe/fEpvPHbUQrZ5x+LqEpdA/RH0mdOzfdRzVQASPFEcNy/mFD0OfHWCToaZ0 PrLL4rnH27RSud7LIy378Wj4Wj8Hh9/Xt0I8VfOlVZRAh/O3hbwv62GHEi7+LF8SOLO2 tt3BCSJoO1lX0RHEpuYlTM6SspGottirXeynSYFliz9YP8Y+Zzt7m+A613Qa7wbd7vf9 9Bq4pR31rg1WKJVhfAuJ5QPRwmYRPdi4ueAQ4ADAi0B9GO8o48sWaERmDbLHwHzGEjEy 1VAPQLLEoIZKP/kHIeO1MNUF7XhwAH5ChUeHgtbVhjw8ggkBEECcBqw/N9bFX+WErUR/ 8B/Q== 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; bh=XTy06JPjF+Flbr9WT5p68Fa18r9/HEAcUQNjh0fiSxI=; b=TqBWwvq2hR0UEPBGekAon/Yw4yZBy0la7u0Laub6uB6p8PRE5NsMoIpW2WOzqtUgRX LtSe8m9bw7N2aSK8otXuGs+uX+J36tKaXuOxDNHVLIa86sXpoZjQUbU6/dc0j9X3wlMC XiGWgooW8ErIhHjizpcC6qy+Nw3fCMBNRdg04p1wQhLHUcI/w+mOhAYQ6n/Q7l5xIAFw UwAOE2lA9k4JHL5oBfFGpEYWBnGngVm9JzyU2wHnejPKhT89QqhoQ8zuYn4KWWTXtIX5 2B98yinLop6+6reF2fXB0DpAKfu/Z8UvMAPWBeqxTgMSbl7vR5+h3E+5zF4rVcY8W6pt rBUg== X-Gm-Message-State: APjAAAUt1c89H/6jpvY0Dj5fJ6cYU5F3htY4XYsCOpY4/9UzHI2k85SX bUCYgUFgoaOsCR1Q3Jezbfo8baXH X-Google-Smtp-Source: APXvYqy6lylq/7RbTmCodW9mEbVCUkckcxopczjrEblxG06MxFPhpTcYSizZjnHDtDbPl63l4lZbOw== X-Received: by 2002:ac2:410e:: with SMTP id b14mr7738149lfi.100.1557775406156; Mon, 13 May 2019 12:23:26 -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 q21sm3449365lfa.84.2019.05.13.12.23.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:25 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Lina Iyer Subject: [PATCH 11/18] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Mon, 13 May 2019 21:22:53 +0200 Message-Id: <20190513192300.653-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> To be able to initiate the PM domain data structures for PSCI at a specific point during boot, let's export a new init function, psci_dt_topology_init(). If CONFIG_CPU_IDLE is set, it calls psci_dt_init_pm_domains(), which performs the actual initialization. Note that, it may seem like feasible idea to hook into the existing psci_dt_init() function, rather than adding a new separate init function. However, this doesn't work because psci_dt_init() is called early in the boot sequence, when allocating dynamic data structures isn't yet possible. Subsequent changes calls this new init function. Finally, following changes on top needs to know whether the hierarchical PM domain topology is used or not. Therefore, let's store this information in an internal PSCI flag. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - Moved some code inside "#ifdef CONFIG_CPU_IDLE". - Updated changelog. --- drivers/firmware/psci/psci.c | 30 ++++++++++++++++++++++++++++++ include/linux/psci.h | 2 ++ 2 files changed, 32 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index bfef300b7ebe..28745234b53f 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -297,6 +297,7 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); static DEFINE_PER_CPU(u32, domain_state); +static bool psci_dt_topology; static inline u32 psci_get_domain_state(void) { @@ -480,6 +481,19 @@ static const struct cpuidle_ops psci_cpuidle_ops __initconst = { CPUIDLE_METHOD_OF_DECLARE(psci, "psci", &psci_cpuidle_ops); #endif + +static int __init _psci_dt_topology_init(struct device_node *np) +{ + int ret; + + /* Initialize the CPU PM domains based on topology described in DT. */ + ret = psci_dt_init_pm_domains(np); + psci_dt_topology = ret > 0; + + return ret; +} +#else +static inline int _psci_dt_topology_init(struct device_node *np) { return 0; } #endif static int psci_system_suspend(unsigned long unused) @@ -758,6 +772,22 @@ int __init psci_dt_init(void) return ret; } +int __init psci_dt_topology_init(void) +{ + struct device_node *np; + int ret; + + np = of_find_matching_node_and_match(NULL, psci_of_match, NULL); + if (!np) + return -ENODEV; + + /* Initialize the topology described in DT. */ + ret = _psci_dt_topology_init(np); + + of_node_put(np); + return ret; +} + #ifdef CONFIG_ACPI /* * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's diff --git a/include/linux/psci.h b/include/linux/psci.h index 4f29a3bff379..16beccccbbcc 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -55,8 +55,10 @@ extern struct psci_operations psci_ops; #if defined(CONFIG_ARM_PSCI_FW) int __init psci_dt_init(void); +int __init psci_dt_topology_init(void); #else static inline int psci_dt_init(void) { return 0; } +static inline int psci_dt_topology_init(void) { return 0; } #endif #if defined(CONFIG_ARM_PSCI_FW) && defined(CONFIG_ACPI) From patchwork Mon May 13 19:22:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164061 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728500ili; Mon, 13 May 2019 12:23:28 -0700 (PDT) X-Received: by 2002:a19:6b0d:: with SMTP id d13mr14261970lfa.79.1557775408412; Mon, 13 May 2019 12:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775408; cv=none; d=google.com; s=arc-20160816; b=z6bCSPmX0iKsGJkAFYHqKec0t1jF6+Aw8tc8dv45k/85nsZI0mPZqsZ9YLPPBzmGaz fyvVcBlx0g5x24VYPv/BDSC9tbD51lo4iw3+LlHyZLgs+1PoOtylv9K4EKesN/bmrQYN KAc+b+BdAs2imIjE3NgSL0N3ijBzFE8tP4QUYTHxhTJqxKUOJD3IF/vGerVzH3QYPaH9 AGJTn5qpnzc3hMJwQtv36ay7r5nr30kXGsqGGTdFIVeQMGL9saibF3qE/aqDhWzJRb0O gPPgXZ30qCwLAlb4I7TIYrqR13TVoU/FpJlg6dM/ZFmnEfGr1tYhgSVtI9mwnlucSXuB 1nBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=KQuZIjubfUifv3ssAR+G5wSzyOOUxlNCuasLn5gNJby4swFZF+k1skuF4poE1p2Ir2 v8H4y/Vk5dtjlV1UzsO0pb+EkFrfwKCSlbBCGT+OiKxXGhlHbED1HiTQItj4gsG1fMGO U87CrT/uqQqSVkcqLk9OAP5/odt7KoO4cSNJ3peQWbLx0eiIlXIImhgVzTG2/GHQyx1E 0dRVfN//cdr6+SfN+leZYYUpMqL0CR8cs8L61UzFhhnrXt2GxaRHenX/J1OZwtN9Sqvv PtKkW9y5wlUONz/0Pu1yXGgTqsvEUS3LnKaD6bXkHxZGhOcn9svUUCUohvfmeLm2wO9m OSag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YrDb+TI/"; 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 z12sor2954913ljb.2.2019.05.13.12.23.28 for (Google Transport Security); Mon, 13 May 2019 12:23:28 -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="YrDb+TI/"; 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; bh=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=YrDb+TI/qptrO7/5RXe8SeC+HyCzsJJl8ml3Jr2kE2brTGKdFR7/IJ+N4lXVtKfgGo NAHroyR3jEv97wAFOv1N3DRBDosPKmtXcn1hEpIBtK5wsOrvMlCDRGJxZwA8Y/CGP+8R ab2aAEL3gSBOsIHFKZCpimEz0v0pvvsft17f2AvJ1ojeV6J8wLK4ixd+AfhWKPZ/c7ZC sQLCc6Vgosbnw6yG7ZCHQQ1u7R7deMgYPyyYMCopM3U1unF1AFl5Ap4t5OT1xuDe8t5f uoNBPb8pfj6ZvLWRNfIZPJf9225Y1ujm2szcS0/1CCTN+KdvBfR2+owHypKzCboaNJCY oIXg== 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; bh=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=bxnlJKGLYvrW5p+0wqgRFvxLKQhKWrdmB5ZjY2ItMTtL8JqIz5fNT3ilK7ydZamlk9 7AaNT+n9WulopeT4tKQc30aHjwO4kTnKZDtELcfI05yAYHRtpjDHe+qDodX2qcXIGAnn /wmZ2eRF9NJgtcwPKzMXGqIs44BElK3o6WjnxXZhecpSroTRF/2vhMo0k3TvTuB4Qxqr mmPnnq7I3wl54Ml5GOXZMGGi47BQMFUXSMOq+UQsJY0gkK9Md61/O5Z7OWwo34HAkqWZ CQLRXELcfn/bqQ0OzVBdPt5aVmXkRp0bJVjjPHPx7Zbwau339BvufuJ70PPYXzf55Hyf I9PQ== X-Gm-Message-State: APjAAAUGCbIF717Moc6ul/rDfJBQyn6ljNS9RJ6zl3abvm9dmZ8A1wuy O78ksBHM+NvDkLsLiWdEqblr1gqc X-Google-Smtp-Source: APXvYqxhImmrN+c//ITxcw8U+57BeFavH+R85RVOLDvIyx6W8pcBzSGLx1AMwoyfzWMRSAkXmhUcdQ== X-Received: by 2002:a2e:206:: with SMTP id 6mr13170535ljc.59.1557775408048; Mon, 13 May 2019 12:23:28 -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 q21sm3449365lfa.84.2019.05.13.12.23.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:27 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 12/18] drivers: firmware: psci: Add a helper to attach a CPU to its PM domain Date: Mon, 13 May 2019 21:22:54 +0200 Message-Id: <20190513192300.653-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> Introduce a new PSCI DT helper function, psci_dt_attach_cpu(), which takes a CPU number as an in-parameter and tries to attach the CPU's struct device to its corresponding PM domain. Let's use dev_pm_domain_attach_by_name(), as to be able to specify "psci" as the required "power-domain-names". Additionally, let the helper prepare the CPU to be power managed via runtime PM. Signed-off-by: Ulf Hansson --- Changes: - Take into account whether the CPU is online/offline. - Convert from dev_pm_domain_attach() into using the more future proof dev_pm_domain_attach_by_name(). --- drivers/firmware/psci/psci.h | 3 +++ drivers/firmware/psci/psci_pm_domain.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index c36e0e6649e9..b4254405b8ef 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -4,6 +4,7 @@ #define __PSCI_H struct cpuidle_driver; +struct device; struct device_node; int psci_set_osi_mode(void); @@ -16,10 +17,12 @@ int psci_dt_parse_state_node(struct device_node *np, u32 *state); int psci_dt_init_pm_domains(struct device_node *np); int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, struct device_node *cpu_node, u32 *psci_states); +struct device *psci_dt_attach_cpu(int cpu); #else static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } static inline int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, struct device_node *cpu_node, u32 *psci_states) { return 0; } +static inline struct device *psci_dt_attach_cpu(int cpu) { return NULL; } #endif #endif diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c index 3aa645dba81b..1cbe745ee001 100644 --- a/drivers/firmware/psci/psci_pm_domain.c +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -383,4 +385,19 @@ int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, return 0; } + +struct device *psci_dt_attach_cpu(int cpu) +{ + struct device *dev, *cpu_dev = get_cpu_device(cpu); + + dev = dev_pm_domain_attach_by_name(cpu_dev, "psci"); + if (IS_ERR_OR_NULL(dev)) + return dev; + + pm_runtime_irq_safe(dev); + if (cpu_online(cpu)) + pm_runtime_get_sync(dev); + + return dev; +} #endif From patchwork Mon May 13 19:22:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164062 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728532ili; Mon, 13 May 2019 12:23:30 -0700 (PDT) X-Received: by 2002:a2e:9ec6:: with SMTP id h6mr12343388ljk.169.1557775410269; Mon, 13 May 2019 12:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775410; cv=none; d=google.com; s=arc-20160816; b=UeQ/xnMsAVoDROH5qG1GNzTPaeanNQLvOFzEaLJYccq9yjv3UuQ09oAJrs7UuVK9qe N8mCcQiZRnQd5HSo1ZlrkkF9kGyKXNU4EIGJqOuro4FMllYCnw6MothOIi1uu71FPkgw cvoaZTFpAXB3RkofdhDmvQraKwmoZ4lJXZGlOQwCe0f49t6ayOe/Z6+O8K1kXPgZifvh AHUWI898p6rdMBe9ijwjgd3Qlv5kUhZXl5Q8v9CAhsVutmKmKCgd2wRM7V/Q64Cwg6Od j3pnwGkUT60mmQZSixGQnEJv8hf5RS4JMktJen+K5aHYib4/lltqIJkjk9obM3xJCpEW zRiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7mMRJh0gRWk8jRKSu7vpJTGJ6ww/FK+bFoVvoMzjgck=; b=L1TwBIlzJ+3+pWQEAg+3DLsGOOSGO8jC4AO3MdhTTc6YcfXMMkQqeWwt0n/lsSawcE bmJs9K0oHu0FCWrl+0HAToNoVkPgh4yb8VnS8JKpHOClRbK2zlvvMaYl6JXeyJntIUoj zYrLCN9lHejI5mBXq4ZPTsnaGJSs3jF/JMEgEfyLbbwiBQDWI3sLOenpA+MStZz2AVGk cXNERDc63VQe5B8OppAjZKuUFgpMLemqyqZ9ogVb+MCgP4qbswR2nl4ytgnCV3fwad1b uo3LOUWFrElNuU6thoaiIpARV4pXkEysqwoJCZ99zPA/MEn7IR+BmKUDhpcdKzH+4aXy d6iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A5Wrb60x; 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 t6sor2987506ljj.15.2019.05.13.12.23.30 for (Google Transport Security); Mon, 13 May 2019 12:23:30 -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=A5Wrb60x; 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; bh=7mMRJh0gRWk8jRKSu7vpJTGJ6ww/FK+bFoVvoMzjgck=; b=A5Wrb60xziILjw5xMgQgTTamMl9xJY2MhOSpDPLTAf/3EQCP+lf+7yig/Ph/N48Hs+ 5eISRFo4PakItBUPivivio9sRWxxOcKf9wZko/ylG4GFm+PHhBbtsOQFhs6a2EYmk6cf d08V0bhI77Ip2AT10wAzzGYunJYYv1Xq6bLSZK+0AvF8kKHSnNeeoT7ASAv0aJjZ/uXa pAh3Vd1UJMx+yB0pcoGTGuiTiECq7yRcyQftboHCRgguQn1fjPxSH/PuwhRrzWxMWrOP vkkAGabM1BZQ68YI0gr+vhbHfVr1udpWSAPl8raFY3py7bW24MK4MzWkC91WgHCON7Du frtw== 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; bh=7mMRJh0gRWk8jRKSu7vpJTGJ6ww/FK+bFoVvoMzjgck=; b=EXBL3xrugSXTqUuR4SdJ3nx4A8npmGqcJJmg9TwZ3Htkuf2UuX92mLez/z9sKdqbzR 3ZqnjnwI2Nf/VyGrOUjVbzcXM+I6ny4HwfTlU4XwrJnYKszTP7bn/U0mKibNtYev0MlK fSf8A+WEBlpaxD9U9Emv1yrDKhA3f04iqj+UGGzCBQNFtLL/uzrtkV8IdI/2PNgd6JuO H5lCQ0nr8afC5FRaZ1viMxeos+WWJGicoemj3aVi5DHe1mRPxecTeGElM6Fn8RutfEmc z2ZQYAZoHVM8g8QhG39GZObXExLDTVZZmwlHid8eaCroe2ApBDvYPCW9sQXzeOhbQjKq HVXw== X-Gm-Message-State: APjAAAXl3l+d/Jeu06IoOgtfaN1Llweep7MeL4htc2RLhthl7uglytSr afw+DmwbIJ7UGS3OQmFDO2LPZeEe X-Google-Smtp-Source: APXvYqxf9UXPo2PbATF2Ej4O/JEKsCNTcYfsKPhGKIQE6BXSznQnuXwlAcye5xuHinSMJfMHW3VIvg== X-Received: by 2002:a2e:8954:: with SMTP id b20mr4530759ljk.10.1557775409921; Mon, 13 May 2019 12:23:29 -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 q21sm3449365lfa.84.2019.05.13.12.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:29 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 13/18] drivers: firmware: psci: Attach the CPU's device to its PM domain Date: Mon, 13 May 2019 21:22:55 +0200 Message-Id: <20190513192300.653-14-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> In order to allow the CPU to be power managed through a potential PM domain and the corresponding topology, it needs to be attached to it. For that reason, check if the PM domain data structures have been initiated for PSCI and if so, let's try to attach the CPU device to its PM domain. However, before attaching the CPU to its PM domain, we need to check whether the PSCI firmware supports OS initiated mode or not. If that isn't the case, we rely solely on the cpuidle framework to deal with the idle state selection, which means we need to parse DT and convert the hierarchical described domain idle states into regular cpuidle states, hence let's do that. Signed-off-by: Ulf Hansson --- Changes: - Adapt to updated psci_dt_attach_cpu() helper, as it now returns a struct device * instead of an int. - Create a per CPU struct, to store the relevant PSCI cpuidle data. --- drivers/firmware/psci/psci.c | 46 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 28745234b53f..54e23d4ed0ea 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -295,7 +295,13 @@ static int __init psci_features(u32 psci_func_id) } #ifdef CONFIG_CPU_IDLE -static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); + +struct psci_cpuidle_data { + u32 *psci_states; + struct device *dev; +}; + +static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static DEFINE_PER_CPU(u32, domain_state); static bool psci_dt_topology; @@ -332,8 +338,9 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, int i, ret = 0, num_state_nodes = drv->state_count - 1; u32 *psci_states; struct device_node *state_node; + struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); - psci_states = kcalloc(num_state_nodes, sizeof(*psci_states), + psci_states = kcalloc(CPUIDLE_STATE_MAX, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) return -ENOMEM; @@ -357,8 +364,31 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; } - /* Idle states parsed correctly, initialize per-cpu pointer */ - per_cpu(psci_power_state, cpu) = psci_states; + /* + * If the hierarchical CPU topology is used, let's attach the CPU device + * to its corresponding PM domain. If OSI mode isn't supported, convert + * the additional domain idle states from the hierarchical DT layout + * into regular flattened cpuidle states, as to let cpuidle manage them. + */ + if (psci_dt_topology) { + struct device *dev; + + if (!psci_has_osi_support()) { + ret = psci_dt_pm_domains_parse_states(drv, cpu_node, + psci_states); + if (ret) + goto free_mem; + } + + dev = psci_dt_attach_cpu(cpu); + if (IS_ERR_OR_NULL(dev)) + goto free_mem; + + data->dev = dev; + } + + /* Idle states parsed correctly, store them in the per-cpu struct. */ + data->psci_states = psci_states; return 0; free_mem: @@ -403,8 +433,8 @@ static int __maybe_unused psci_acpi_cpu_init_idle(unsigned int cpu) } psci_states[i] = state; } - /* Idle states parsed correctly, initialize per-cpu pointer */ - per_cpu(psci_power_state, cpu) = psci_states; + /* Idle states parsed correctly, store them in the per-cpu struct. */ + per_cpu(psci_cpuidle_data.psci_states, cpu) = psci_states; return 0; } #else @@ -442,7 +472,7 @@ int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu) static int psci_suspend_finisher(unsigned long index) { - u32 *state = __this_cpu_read(psci_power_state); + u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); u32 composite_state = state[index - 1] | psci_get_domain_state(); return psci_ops.cpu_suspend(composite_state, __pa_symbol(cpu_resume)); @@ -451,7 +481,7 @@ static int psci_suspend_finisher(unsigned long index) int psci_cpu_suspend_enter(unsigned long index) { int ret; - u32 *state = __this_cpu_read(psci_power_state); + u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); u32 composite_state = state[index - 1] | psci_get_domain_state(); /* From patchwork Mon May 13 19:22:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164063 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728573ili; Mon, 13 May 2019 12:23:32 -0700 (PDT) X-Received: by 2002:a2e:8154:: with SMTP id t20mr2256ljg.180.1557775412060; Mon, 13 May 2019 12:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775412; cv=none; d=google.com; s=arc-20160816; b=AuFHxk4OCUYE00ObS8ASwJw6LZ52e2oEXD1DjKUVYGTWwxtieEYjndW5gp/bydg+S8 mWHBnxYx3/dyuHVVw6HAG9JuBJTjx17Q/FG5+clK86kxJj6wnSrWN3QTkyN96z6Cqbun U+6xwCeuHg6B86AItWzTFBYmaghuky5hdKSZNA+wJsqieT7rv+vmK0x/RoXA+OpVQoZY VRQygZ5BE6guVGoEorDBcxP07jBUtHoRXYu3gR5qyhV2ffkVcUUQW3+nr9opiQM5a1sk ldcpF4wW68UzfjDJqfXqzT+pBosariaklGD/lEEbgSHzViPD/bpnjnmw97YE4O0rgWmB dL8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5L3+w8hUR6giXqb5Tz84iJ3SS/PuntIOYwjCkJwPh9s=; b=HhbFgCmCBXnRAGbYYk5BB+918BtLWRdnXh3nwDvsrJmAqKo1FBVKsHcMI9X0pZ+6GD sgjZkJGQ/R50vG+ppl9NyBZ9jUrv5b3HSTXLmD8Fkmu3VaOsA+9WQxprIxSSZj3zE6HA yYIKxK4FkCRRarDU3bg9qoC+rBh8EfDAjo5ndHbK8F5PTW0k16iC+s7SG6QxNfVkA6VU /+M6oa9dsHf6cv6WPIcBljzpynmhEi5qUr7BmoXg4N3Q0kLVI7IygyuNMQL0lA8Tx1JJ ywcvLhItYb5HvKqxDEFy+zPHf5ZpR2QHwAMMe8O5TNYZbKZ1QIJrDu+vXnbvk06YAIwH tSsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nuEds6uq; 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 n25sor2983409ljg.30.2019.05.13.12.23.31 for (Google Transport Security); Mon, 13 May 2019 12:23:32 -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=nuEds6uq; 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; bh=5L3+w8hUR6giXqb5Tz84iJ3SS/PuntIOYwjCkJwPh9s=; b=nuEds6uqvSvhzFgPN0xx4WrLj+8Aq5wMne2aRP4Hl30ysRHF3JwffRDwh2I/w4NkhA ruqtjGmeavnUC5G6t1+5vD7jYhWzIibj7v8eKj+D5BqywqtbMj4VlBzc5f+oeCC7YVZr gMQJv7sBlyWAqagmqVCdQx6ievkrgzxp6P6VXhi+yjAzjEClLL/IUaPqLF+XdiUzD+wB PoZRlnXLRxkuWULBDbbLIts79BiF1YdM5kTUelzfYB3F6IWAddBJ1onCo4N+i653uveS lhlUL6q4MSOpQOYlAnyDByOwere/dmOdnrZOjhSfSGK/7nMJMIUGdCEIfOTBMbYwDCev MmjA== 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; bh=5L3+w8hUR6giXqb5Tz84iJ3SS/PuntIOYwjCkJwPh9s=; b=q6Vkefv2NU1rw71huycM/ELiKPwxcd/OmFEtZe3Y3c0iDyPM5jyGL+rg6a0K4PcQBM JfNs6CKWFR5dRdgc/kSFtsbxbHSCue5fF208kqfdcQaEJ3jQhf0SlenNNDcb66HcVNYG tp1KCoUG+stEoAkd6r+M7tu3ECa5I9YmGqP1qvYlzxW68o4mQ0tqB0c63eHPnJK7+6S0 CAtzlLZru/Q5bdDATENTAbL47fCts7nkctVBwPi39pL0/3ZRxwJR/TMTqfSan8k15cJH xXlDiI9SLQW+ohKbjNXOYc3d9XPqhB0WzJCZGk1zYPiVnX8IAcTx2X7EUbmikcO521bL a/aw== X-Gm-Message-State: APjAAAUmrAsCZZPJd6L+VVbscT69vtvdISGUHTSrpbNookTm5MV0KiLS YoTgs/3ifTVHx4Z3nw7DRiVt2BIy X-Google-Smtp-Source: APXvYqwhviRoSbMrrPulC15a2Em5gq4bwlntBmk6fP/23jtstN9Z1J324DMrQRo3VkPOVmz3QA57og== X-Received: by 2002:a2e:9141:: with SMTP id q1mr14833265ljg.84.1557775411722; Mon, 13 May 2019 12:23:31 -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 q21sm3449365lfa.84.2019.05.13.12.23.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:31 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 14/18] drivers: firmware: psci: Manage runtime PM in the idle path for CPUs Date: Mon, 13 May 2019 21:22:56 +0200 Message-Id: <20190513192300.653-15-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> When the hierarchical CPU topology layout is used in DT, let's allow the CPU to be power managed through its PM domain, via deploying runtime PM support. To know for which idle states runtime PM reference counting is needed, let's store the index of deepest idle state for the CPU, in a per CPU variable. This allows psci_cpu_suspend_enter() to compare this index with the requested idle state index and then act accordingly. Signed-off-by: Ulf Hansson --- Changes: - Simplify the code by using the new per CPU struct, that stores the needed struct device*. --- drivers/firmware/psci/psci.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 54e23d4ed0ea..2c4157d3a616 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -298,6 +299,7 @@ static int __init psci_features(u32 psci_func_id) struct psci_cpuidle_data { u32 *psci_states; + u32 rpm_state_id; struct device *dev; }; @@ -385,6 +387,7 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; data->dev = dev; + data->rpm_state_id = drv->state_count - 1; } /* Idle states parsed correctly, store them in the per-cpu struct. */ @@ -481,8 +484,11 @@ static int psci_suspend_finisher(unsigned long index) int psci_cpu_suspend_enter(unsigned long index) { int ret; - u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); - u32 composite_state = state[index - 1] | psci_get_domain_state(); + struct psci_cpuidle_data *data = this_cpu_ptr(&psci_cpuidle_data); + u32 *states = data->psci_states; + struct device *dev = data->dev; + bool runtime_pm = (dev && data->rpm_state_id == index); + u32 composite_state; /* * idle state index 0 corresponds to wfi, should never be called @@ -491,11 +497,23 @@ int psci_cpu_suspend_enter(unsigned long index) if (WARN_ON_ONCE(!index)) return -EINVAL; + /* + * Do runtime PM if we are using the hierarchical CPU toplogy, but only + * when cpuidle have selected the deepest idle state for the CPU. + */ + if (runtime_pm) + pm_runtime_put_sync_suspend(dev); + + composite_state = states[index - 1] | psci_get_domain_state(); + if (!psci_power_state_loses_context(composite_state)) ret = psci_ops.cpu_suspend(composite_state, 0); else ret = cpu_suspend(index, psci_suspend_finisher); + if (runtime_pm) + pm_runtime_get_sync(dev); + /* Clear the domain state to start fresh when back from idle. */ psci_set_domain_state(0); From patchwork Mon May 13 19:22:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164064 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728609ili; Mon, 13 May 2019 12:23:34 -0700 (PDT) X-Received: by 2002:a19:ae14:: with SMTP id f20mr14035876lfc.49.1557775413920; Mon, 13 May 2019 12:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775413; cv=none; d=google.com; s=arc-20160816; b=mmxjcr4n3Yef8R6FVCufYfOOtvSo/j2svwwPgD5KMJG23YM89dhRmQwnccvDQ+klLs soSTYbN5E1htfzIxcNVMf8BWtAUrlUyb+kYCpLcUInUheNZWWgQ+K174hGzcWtylzmiv 6X+M9s0t1sSrXadqE2HAXI25uhuC2BmuyDmkV9sHuhuzaARO5cKgyLQd6Fy4LWpqWtE+ ijL2K02GmP7ZMseil7UoLqz5W1Q2GFnyTE6hu/j6unBoZHcvQ8vcpSEqlKCRDCQmGPDO GacW8HGODWjC5A/EXrtYvePpx0DYjslQ7buj/6+xiWtd/sRYES3dGa6MfSsQppYGwYF8 B0OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WrUBlQWQzfbgrdk7klxniFTaW91XaiQj55o38mlFd9s=; b=nmbq62Xd/rY6cegKHA5btKadfxzXxOk2vuum7r60O7sTZspoyF71N/twiJQAGApynt 5Hc0gO9eUPtwJTBaBmBiHlrMQs8Bw34RyHl6f7H5/qrTLLASY5DUP90MgE3Z5QxgFpMo 1LdN/unHN2ZZHiRF3beQ25AR6mgnS7naaAbq7JSH5tAQh/1g5UtgUljWZ0AIYcTtdTqA gwMAaKgfd8lOXlW/rEUjGDGm93Mt3y4HKy+tcaon/SE0qUbAnF0OHnPPQoW0BC3tt0D3 UhQiab/OUoH/omCZccDW60Ln32oTK3FgXL0i5yZBGW3ANx9H8bMGjTq9wLVcK65LBbh6 bD+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sPy1xWva; 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 y18sor2971875lji.38.2019.05.13.12.23.33 for (Google Transport Security); Mon, 13 May 2019 12:23:33 -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=sPy1xWva; 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; bh=WrUBlQWQzfbgrdk7klxniFTaW91XaiQj55o38mlFd9s=; b=sPy1xWvat53hABQ29ElA2SDvZnqfRV5oZCv6u9/BoxR2ZPqFXvyAG3a5TqRkJY1a78 ViroHIx+ON0jQRU/3UrEYHgnwsRgfEfK1eI6rvzBvxBl01A+l0VD3RNQr/pCLeiGgll5 oZk8WImmrSosBLIL5WDY5HKxk6DoQYAY3hOyay9Zaekc0Qx48OBqfoEIU9LOQbcuUzO9 y21fdWLhr9sVngZjVbZUtziI2z+WwnXK05qOJ7jaN6FqE68r4gmG+pebrx9IRchSta0X VzfAclg9EtvAhwIfrDB0k8yyetyh5giqMkUfQdSjeFYl6oWMRIbrHygy50HEN/rtT2Ov JANw== 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; bh=WrUBlQWQzfbgrdk7klxniFTaW91XaiQj55o38mlFd9s=; b=l9PZKbi/NzvmseD4HW0zLNUzMEc+ElYCJUl/x1935VXWd2K4NLUPo6Wq5+YxsVUt7p H062zEuH3v6xSQuEUnFgD/1WA3+xVNUdbOgVcjkDFr+GWcX3MV3fXLjGm6R4SrrEWb/p b0P+jo8PDcNd3F+oPPteLex/qDPoJlyOo0LrIDBFy1G7ovxmuxWRsy82zykF/peD7/1A Lvc2oiDMgQ/evq8zpLlC0E1/laVOvbm3pZFMnsc9FLkvYLLyO4QfRxu2Lfxmtsl4MXxP 4lfRiYnbn6+Fp+3Um1sdhUB+7nTgD6++32yXIiGY5as+zZIhVn8lMCVzdoRJ5tgn2YPP haaA== X-Gm-Message-State: APjAAAUR/7O2DmV0wSr9q0scdiAUwpx/TikYxJYs3Nnj/t+gfU+IXwJI 9qaKF9INW6KMS2/CbGqdXAz8B7MN X-Google-Smtp-Source: APXvYqwd8hFjFHeIWZMZf2tJMuRrNt9YuVmMQEmung/qTBri+UbFr4ziejpMmn/ZiqWmeUdPeQNSbw== X-Received: by 2002:a2e:2b58:: with SMTP id q85mr14768159lje.179.1557775413538; Mon, 13 May 2019 12:23:33 -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 q21sm3449365lfa.84.2019.05.13.12.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:32 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 15/18] drivers: firmware: psci: Support CPU hotplug for the hierarchical model Date: Mon, 13 May 2019 21:22:57 +0200 Message-Id: <20190513192300.653-16-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> When the hierarchical CPU topology is used and when a CPU has been put offline (hotplug), that same CPU prevents its PM domain and thus also potential master PM domains, from being powered off. This is because genpd observes the CPU's attached device as being active from a runtime PM point of view. To deal with this, let's decrease the runtime PM usage count by calling pm_runtime_put_sync_suspend() of the attached struct device when putting the CPU offline. Consequentially, we must then increase the runtime PM usage count, while putting the CPU online again. Signed-off-by: Ulf Hansson --- Changes: - Use get_logical_index() to find the CPU number. - Verify that a corresponding struct device* has been attached to the PM domain before doing runtime PM refrence counting. - Clear the domain state when the CPU goes offline, to start fresh. - Move code to internal helper functions and move them inside "ifdef CONFIG_CPU_IDLE. --- drivers/firmware/psci/psci.c | 47 +++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 2c4157d3a616..5ad93c3694b5 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -93,6 +94,9 @@ static u32 psci_function_id[PSCI_FN_MAX]; static u32 psci_cpu_suspend_feature; static bool psci_system_reset2_supported; +static void psci_cpuidle_cpu_off(void); +static void psci_cpuidle_cpu_on(unsigned long cpuid); + static inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature & @@ -188,6 +192,8 @@ static int psci_cpu_off(u32 state) int err; u32 fn; + psci_cpuidle_cpu_off(); + fn = psci_function_id[PSCI_FN_CPU_OFF]; err = invoke_psci_fn(fn, state, 0, 0); return psci_to_linux_errno(err); @@ -200,7 +206,13 @@ static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) fn = psci_function_id[PSCI_FN_CPU_ON]; err = invoke_psci_fn(fn, cpuid, entry_point, 0); - return psci_to_linux_errno(err); + err = psci_to_linux_errno(err); + if (err) + return err; + + psci_cpuidle_cpu_on(cpuid); + + return 0; } static int psci_migrate(unsigned long cpuid) @@ -540,8 +552,41 @@ static int __init _psci_dt_topology_init(struct device_node *np) return ret; } + +static void psci_cpuidle_cpu_off(void) +{ + struct device *dev = __this_cpu_read(psci_cpuidle_data.dev); + + /* + * Drop the runtime PM usage count if the CPU has been attached to a + * CPU PM domain. This is needed to, for example, not prevent other + * master domains in the hierarchy to remain powered on. + */ + if (dev) + pm_runtime_put_sync_suspend(dev); +} + +static void psci_cpuidle_cpu_on(unsigned long cpuid) +{ + struct device *dev; + int cpu; + + if (!psci_dt_topology) + return; + + cpu = get_logical_index(cpuid); + if (cpu < 0) + return; + + dev = per_cpu(psci_cpuidle_data.dev, cpu); + if (dev) + pm_runtime_get_sync(dev); +} + #else static inline int _psci_dt_topology_init(struct device_node *np) { return 0; } +static void psci_cpuidle_cpu_off(void) {} +static void psci_cpuidle_cpu_on(unsigned long cpuid) {} #endif static int psci_system_suspend(unsigned long unused) From patchwork Mon May 13 19:22:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164065 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728644ili; Mon, 13 May 2019 12:23:35 -0700 (PDT) X-Received: by 2002:a2e:8555:: with SMTP id u21mr7418846ljj.133.1557775415773; Mon, 13 May 2019 12:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775415; cv=none; d=google.com; s=arc-20160816; b=fTS7p5ytDYZG+PG58CDNz9kl65Vmke0FAeqTgpciXCKWRCkeSF10zDN+ashCN5D5OE sfyEKN0j6s0nYwzIPiRBx2SLvrlBXZBi0sHlmPmkfr1bMoMD54zxihsyzvLWV/swstxv dmuvfoez0BioML/RleQGPrM9WKV4aBlRl581VxrKFFQJwyNKoY1UlMorh5Bwza7LF0Pg MWHuvPjFRxvKnQDyoskAfrbUhaFN0D7jFldxg/uaCLMINvCi7dRSpbzPFOOriJaByGLU wZC3ibbYh8YMCBk7rLS4zYnBMp3gpFGLOgtSkkhNIHyCJBEd/cG4QuIZ9xabHEUiOcvP b+og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FS9Zs+3LWO+O30HH4l9Kk8Vdize9BSzeQBpadzl2HYA=; b=LeUhrtLwnQNHUGeNcq42+4JWxSsgy4QkyxyZNTVxx/0LI2vX/q5zIYMix3rjDycqn8 F9A1XyAeDB0Fr3lpRFXZcIQqjJx32ZICADYEN2tVHXpGDYmmbuHySELtWeY+6CfO34/g m8oWAq8mqMNzbq4IutbcNec9zPxqAEWdZABYWCcHrgySV40vcRL0IoHRaIJyzqN7xwZY wm1YRbvyJXLwq+HJXpM+jqyJ5SX8+CcpjGOLUdhvV1gNE3Z1WU95yys14ENbL9pKzphY WfRldjyJfEmNEbsZPRFTkgTVf5y34BBl0+3F1Atbe6UqssQErX2cOzlDaKZWJ46uWeTS AZdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t15nWHPm; 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 8sor1678706lfz.14.2019.05.13.12.23.35 for (Google Transport Security); Mon, 13 May 2019 12:23:35 -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=t15nWHPm; 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; bh=FS9Zs+3LWO+O30HH4l9Kk8Vdize9BSzeQBpadzl2HYA=; b=t15nWHPmFlGF4Hk/qXkWtGd6P4khoapB58QJFxrQ0ZNQUXmlHvGcZXvn8hgr3rc7X+ eE/ASRA8k1AQG0DdZLyF3FiUVQKz9AjKmneEG4iuBy5DWguCj44rHUGww8VoLC14kkpV TAmsE70nTuh+vkyVTcFflq1Ihtv15Gjs6lN28RnAdyk6YEKe1sk82sQKEFoOgzZS1j0g ppmAaYnj4FwI7sFWE7rhWAusai9maT6zhjqYzXhVMTt9rwMyhTPogRZF82iPBQdLTLL8 e41snlmZNXFO0Bqj9yPBVHA/mzxQ87IGeFK04GazkTYlofyN2rCzQMCISOTnU4Ay1zIY C4YA== 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; bh=FS9Zs+3LWO+O30HH4l9Kk8Vdize9BSzeQBpadzl2HYA=; b=QYtDLmeSTbcNPY4fjSACWcbC+wH+5hSAdBCrjoAPMmW2qzzG5iDJLNFrBoRq8glly8 V5OsePtNK+Tm1sEYwHdhCHdoNHidLq7eNM6FFKvp2Y42jJhO0BqVZDKGn9A/ksitYuIp IQS7O18BTJEUXINp51+tNYAhvWwwcqKwDO6BD26DOwMtW1h+JOlxqKAaFEQIr8xE/fZ1 5+mLNOKC6ABfgj5/+hAULT9Sn/GV+jzoQGwuvRCGYcrQMYPieq1Y+pJbtc2CBpvtz5bd YA+TAwPoDVC+/0yv+fS3N4xaf2t/2F3rv0V6a+z57qJ2X2YVrxgiYwDPiPqpYkUPRWAQ XJOg== X-Gm-Message-State: APjAAAWqDWfUWlVejFFyy8T6miLyJ2r6brDL0Xib+QhaRb52Q3HKcHrY Qb2NWc+1JVUcuIMzkFQ1aiOPSmjc X-Google-Smtp-Source: APXvYqwf7I+vqyV1oY+DdOoP8eb7s+6VlIHVgf1KVMJaduN8GSRO4HLl7ruL91VI1qfgG8O6PtC3NA== X-Received: by 2002:a19:ae14:: with SMTP id f20mr14035921lfc.49.1557775415444; Mon, 13 May 2019 12:23:35 -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 q21sm3449365lfa.84.2019.05.13.12.23.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:34 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Catalin Marinas , Will Deacon , Lina Iyer Subject: [PATCH 16/18] arm64: kernel: Respect the hierarchical CPU topology in DT for PSCI Date: Mon, 13 May 2019 21:22:58 +0200 Message-Id: <20190513192300.653-17-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> To let the PSCI driver parse for the hierarchical CPU topology in DT and thus potentially initiate the corresponding PM domain data structures, let's call psci_dt_topology_init() from the existing topology_init() subsys_initcall. Cc: Catalin Marinas Cc: Will Deacon Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - None. --- arch/arm64/kernel/setup.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 413d566405d1..f1559223c55b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -367,6 +367,9 @@ static int __init topology_init(void) { int i; + if (acpi_disabled) + psci_dt_topology_init(); + for_each_online_node(i) register_one_node(i); From patchwork Mon May 13 19:22:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164066 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728674ili; Mon, 13 May 2019 12:23:37 -0700 (PDT) X-Received: by 2002:a2e:9241:: with SMTP id v1mr14738234ljg.6.1557775417702; Mon, 13 May 2019 12:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775417; cv=none; d=google.com; s=arc-20160816; b=yYshbEOSk/mcf/zR/QC9CvO+90r6JAa3Y5tnMwXSRdoVUj7rVcyk6r2K/Yjy4LbGsg S/5zFc5mUtmou6QFhhr+L4RXoA1BAa7sd9tNDRyaq1mA5++BdUT78tBOIrlDf4ToKvup e7YHak/AI2I1SIVKOvF7wMsi2Z/r2E4BUdZR/czkxF7YfqBssGkYPdvll0984O3J4V/t kqaoe0cBBXZb90Gbo39F2rcSC+gkt8z0V3z8mN/bQk+bq0GE4YhADj7703xIEUkrq/2E P0BrguYWyeSToieuC3c/X8ZICdd/Hqx4Wu6nWkKjL7ziN7T6MmzKZCnczHl7ByR5lYVm EJOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PDEUjjOBUJS5iHQaBAG+Z33WI0zFNAprAtoJyuCQ0PY=; b=O0Mn0U1YXxeGR3XZ7tml1mF9yiHcdxIAjDlpNY5As0R6/rGG4H2fla2uQuBXuKhRpz PX+jWNYbKbQ2iGaQlF8w/448Tmmpxa2UKdwSV2yNnLmj1sWdy7qHRJfUDhsWLf9wkR1o fEYaX4UazIVjX8PgZP9r78mE+KCBLqqjW0Q1xSe+rDOlt0oeVHP2KlZ34xjlyCd+YwK9 wRkCntmDkjsvAKaafVvbTJOUwwvnd5eVXOgsqQlzoPKQAXrE/N52r5hjF7LAlJheTKkD XQiekynlRW5U4mVdcVYs8lEh9xhboYwyUiEIUXwLMej9Ic5AbmLhXyk0AOAXUJCpRRWu plcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M21k49y1; 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 k10sor1317500lfm.39.2019.05.13.12.23.37 for (Google Transport Security); Mon, 13 May 2019 12:23:37 -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=M21k49y1; 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; bh=PDEUjjOBUJS5iHQaBAG+Z33WI0zFNAprAtoJyuCQ0PY=; b=M21k49y1eNn330/lF5JvreEZChjrS2M6ynm3TqPbbn/Q9xiZAzxNCYtv/EuxrqqtMM QGsNsvmFxgy9sSC46EshhJEpWH5Pz4ZTv2l1DCMYxEhHs7XqE1HQbPYe5KlbUPpZoz1u CROTIRFp0MmW7feCctSmkdf9rvOLpD1AHPnKXgEBya6wH+hN4dttUD8c/NIeoCMp+8G5 7LZjDpnxdIB9RSMG00FALVcyBAhvnwEyA3AsG5QE2IRgu2aE+wNxXs4Clt22/rk1KpRQ w4c/YO/4ShYOv7C674P9egAkOJOTIQ8CMoR5T4g9Bnk7vkufWL1z+GXWXR2K+l22GP4M zUnw== 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; bh=PDEUjjOBUJS5iHQaBAG+Z33WI0zFNAprAtoJyuCQ0PY=; b=XIJPB8ltIwIZ2l6+OlOlXlaUhCGAVbkqUCn2Kg5RrIxfKmsS+026J8/U3WFazcXC// KxE9lxHtKbkUpIaZScA/FcZcJJyX1mQNRndoZx/ds480oIP5it4oLVSdR8kFi00haiHJ YWWXq0M1gZ+LUdCAXH4mK7LbDDiLhLcUZLknRGfbxT4m4uXhMZug+vfkaefPbWLNX1lh u51FZvIUQhNSizSS4zajmD+iKeDMdcMJNuUGzPPmZaYEHsFaDY6NSqVlkSi6ZjW4WLum j7ntSjJOh6vXg/CD1M55Tvp8OJ15JimcvQ/2ZXJerb+mDwUSQ0gJMAxHLWh1m/zWdViq l7NA== X-Gm-Message-State: APjAAAXhoFfaFtsj/F/RfFkI4xE6Op70iYJIY/vpp8EJ8nGjmdwB6ii8 PczQPAIpGSj0JloX8G+lBEJs1OB3 X-Google-Smtp-Source: APXvYqzkkltCyacB6OrKhqu88JBHdO9W+dZpAtceJBpmMRPPTu1skXnjUWJRxuUbEzEFar3+9FUfjQ== X-Received: by 2002:a19:e002:: with SMTP id x2mr15509153lfg.16.1557775417282; Mon, 13 May 2019 12:23:37 -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 q21sm3449365lfa.84.2019.05.13.12.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:36 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer , Andy Gross , David Brown , Ulf Hansson Subject: [PATCH 17/18] arm64: dts: Convert to the hierarchical CPU topology layout for MSM8916 Date: Mon, 13 May 2019 21:22:59 +0200 Message-Id: <20190513192300.653-18-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> From: Lina Iyer In the hierarchical layout, we are creating power domains around each CPU and describes the idle states for them inside the power domain provider node. Note that, the CPU's idle states still needs to be compatible with "arm,idle-state". Furthermore, represent the CPU cluster as a separate master power domain, powering the CPU's power domains. The cluster node, contains the idle states for the cluster and each idle state needs to be compatible with the "domain-idle-state". If the running platform is using a PSCI FW that supports the OS initiated CPU suspend mode, which likely should be the case unless the PSCI FW is very old, this change triggers the PSCI driver to enable it. Cc: Andy Gross Cc: David Brown Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes: - None. --- arch/arm64/boot/dts/qcom/msm8916.dtsi | 57 +++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi index 0803ca8c02da..1bb33f0326b5 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -110,10 +110,11 @@ reg = <0x0>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; }; CPU1: cpu@1 { @@ -122,10 +123,11 @@ reg = <0x1>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; }; CPU2: cpu@2 { @@ -134,10 +136,11 @@ reg = <0x2>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; }; CPU3: cpu@3 { @@ -146,10 +149,11 @@ reg = <0x3>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; }; L2_0: l2-cache { @@ -166,12 +170,57 @@ min-residency-us = <2000>; local-timer-stop; }; + + CLUSTER_RET: cluster-retention { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000010>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-gdhs { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000030>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; }; }; psci { compatible = "arm,psci-1.0"; method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD2: cpu-pd2 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD3: cpu-pd3 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CLUSTER_PD: cluster-pd { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_RET>, <&CLUSTER_PWRDN>; + }; }; pmu { From patchwork Mon May 13 19:23:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164067 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728704ili; Mon, 13 May 2019 12:23:39 -0700 (PDT) X-Received: by 2002:a2e:d1a:: with SMTP id 26mr14573506ljn.147.1557775419724; Mon, 13 May 2019 12:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775419; cv=none; d=google.com; s=arc-20160816; b=A89g4cwC6Ev6/x3uxFi6TIYgHLmosXuN60RMZV0teG39rqiZOzBMecZGVHzmfaVbvJ Agwf223BYMBuDgWxWxz0ms5D0auWKKpVpkJwdtD+NQQnzlJ6OWM0EPWYY4UjKrxEIqGh 5b3169zGDbqJ3XTR9x7qlmFQXOZcZ3yTvahEfSyRTwnRgj0c2jb8sqR4iTMeGGvAnOF9 Gy3V2BlB9ElhnRA5PwuZJK0PndyrMjKT217cgB5rcWBFQOdeZqG/TbAZQGaYuGLwpYsq Klk5oFGlMjjuWQwKVi774aK+ehWFzzfN1T0Q84m6rDPJsMjdp/f+cA+KyEyw+DDxQ0NQ n0LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7AxPd/WiAkEtzi6eC4zcfxrPuKGzl2d+dQ6Z4/Ng9yA=; b=YFCndf+Vq5lSS9NoBuus47O8dHNltDIHsYzZWe03pruG5X/3K2SWhpkM6UYk0mn5WR fk/DnAhk1YjUlV/u5+UangjxEHV0N8F+zi4qLFAeh1ov7vIrolAEwdgD+jLKrTMcubcG ppT85giwGlnH/eMKNuzA04sJdzhsz+3UGyJ07F0cmy5wxizmz+6bCFpGvgWNzuBXuXTR 79Rrr6sY1XtG0rEpn7hHiF3j23cNYEImRFsrJHMiu2JB0lKW1YxPAMLvkVhNns6iwJpP E9dMK8nBBRYrAZmvaY6QdnccVHmovgS8pEwGI8XarFO77XXS+/NDvNFbuVwDlCGcXk9u vyQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iguEcn8d; 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 d20sor2956404lji.12.2019.05.13.12.23.39 for (Google Transport Security); Mon, 13 May 2019 12:23:39 -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=iguEcn8d; 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; bh=7AxPd/WiAkEtzi6eC4zcfxrPuKGzl2d+dQ6Z4/Ng9yA=; b=iguEcn8d2UHmA1BdPS+ybI3lkwBDS3Ab7tjgLTOWKG6wZ7qEdUTtbHKOqgM2Pnvm4B Xofw8r8SJPdY+sJxTtVFiOGqhI6kONaT2HlWPLlUPTFxNHUtX5OLL4bifccr+S/yXa3L 1874f/2ZGLG1PlPpnMLUejT0OAYu+L+O/+Tjquwfhc9n4SfDn/aZgcGK8cGVd1V0uzUf PPof97i8Xu9/kDaXfsu5Hm2b0l3KZKU/pEG+zdRjUSm4VqyLizf/dMOcOLG7wEsnVQ0t p+FWaZl+/zA11ABliZ+oXMfD7J1aEnNIpgO0Q9nWUTv9CRs6+XpZ0/jLRxkxzf+u27O2 FmAQ== 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; bh=7AxPd/WiAkEtzi6eC4zcfxrPuKGzl2d+dQ6Z4/Ng9yA=; b=mNSsTKMdR7iN1p9a4BLxaHy0W0rg15BzEOnQY28y7RKI6hfZA9SpOEEMIbRWvIffd/ 6ZaxOaS6VDbgIP4CUakoYxS5eMIp0haoGTw48bBb2JAy4chxSPy+/1/szHR4fSJfODXt SU0150wD4BrGFQ2470eBGmKKrmZ2NKqsvqZLxqu2q/R1wC06G1r05NlvjgoDimLTXvpx dP4kIzL5ec59+B4iBnA4Lw4zwHyAXQDh+2vmyfhOoLXg1SEujlmAtBXvB+qzhCHJbmva SporvnGpTzUO7wDWibLXjPgeSNYOuloewjsf2iYX5O9W8iMXm7ypbW8Quy8Rx5V1LuqV n94w== X-Gm-Message-State: APjAAAWmvX8k0v1UovLaZgVrUTKIzAKeLpMU2p2fx3CpvZ7A06SNUD5h bdT0FusSig4AILbWzgwmJVtuy6KW X-Google-Smtp-Source: APXvYqwxMWB7/4WyFA59ijUF+6dp1ja8lpTuNpIG+hVBnaOO/pbLdkkOZsUgbqrpPxXYczj1YuOnIA== X-Received: by 2002:a2e:309:: with SMTP id 9mr15762950ljd.114.1557775419346; Mon, 13 May 2019 12:23:39 -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 q21sm3449365lfa.84.2019.05.13.12.23.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:38 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Wei Xu Subject: [PATCH 18/18] arm64: dts: hikey: Convert to the hierarchical CPU topology layout Date: Mon, 13 May 2019 21:23:00 +0200 Message-Id: <20190513192300.653-19-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> To enable the OS to manage last-man standing activities for a CPU, while an idle state for a group of CPUs is selected, let's convert the Hikey platform into using the hierarchical CPU topology layout. Cc: Wei Xu Signed-off-by: Ulf Hansson --- Changes: - None. --- arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 87 ++++++++++++++++++++--- 1 file changed, 76 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi index 108e2a4227f6..36ff460f428f 100644 --- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi @@ -20,6 +20,64 @@ psci { compatible = "arm,psci-0.2"; method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD2: cpu-pd2 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD3: cpu-pd3 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD4: cpu-pd4 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD5: cpu-pd5 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD6: cpu-pd6 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD7: cpu-pd7 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CLUSTER_PD0: cluster-pd0 { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_SLEEP>; + }; + + CLUSTER_PD1: cluster-pd1 { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_SLEEP>; + }; }; cpus { @@ -70,9 +128,8 @@ }; CLUSTER_SLEEP: cluster-sleep { - compatible = "arm,idle-state"; - local-timer-stop; - arm,psci-suspend-param = <0x1010000>; + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000000>; entry-latency-us = <1000>; exit-latency-us = <700>; min-residency-us = <2700>; @@ -88,9 +145,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; }; cpu1: cpu@1 { @@ -101,9 +159,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; }; cpu2: cpu@2 { @@ -114,9 +173,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; }; cpu3: cpu@3 { @@ -127,9 +187,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; }; cpu4: cpu@100 { @@ -140,9 +201,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD4>; + power-domain-names = "psci"; }; cpu5: cpu@101 { @@ -153,9 +215,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD5>; + power-domain-names = "psci"; }; cpu6: cpu@102 { @@ -166,9 +229,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD6>; + power-domain-names = "psci"; }; cpu7: cpu@103 { @@ -179,9 +243,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD7>; + power-domain-names = "psci"; }; CLUSTER0_L2: l2-cache0 {