From patchwork Mon Dec 30 14:43: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: 182615 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422087ild; Mon, 30 Dec 2019 06:44:10 -0800 (PST) X-Received: by 2002:a05:651c:111a:: with SMTP id d26mr35085289ljo.153.1577717050474; Mon, 30 Dec 2019 06:44:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717050; cv=none; d=google.com; s=arc-20160816; b=EbekAn1xlfxxL6zEDTvT87B2gWRkNdbNAnIX0t2LT8P/FeP6YHBEUNDw2vUg/uwbcX 0MVpQHMNyECxRU8GHOgcRwqDlNZv72su4/Ru7NL52kU//PA9+mCDo6Ub7C0ogdcOh6ii 9it/mS3+L7YYXl0AhFECRgxY7m+eKv3XODAh2I174nvWUxpU48KI2Zr8D8gOaKpBExdX q3bojMcjYvrKB6k8H2qoaiyizDTgQKXLfvqilzEsaFTyTnXmh6W72hq1Xd82oqXvpVfd HGWhgPjdZbom9xhNdesZToN90O92SofDMGtNeuUNTH/0ZLOhBgu84fdA8HXUvR05WiS0 38tA== 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=yJwsi3DMV/pwzB8sWAmHjBjjwOzOWtOVx10q5OKc/Qg=; b=atdoFNYllxEpEA2uXNMZkKUvfAqHDW/HTh4TzndEGjloBZqRcxVAhIUnr55iFhrnSQ J9Fcr4+/cy8sDk3V/01B2JrGgvjXSV0bS27UsLm1howkCD8gOGQYZoSuqDojTkJlYXBy tu7e3gXcFtaXpkGuo8SENTmDXTeX1YpRiVTistBkhL0B8p4CpD/EX5h50djYt+KfXT7r Yr1hnR0PrajY/dkdrTfGpmkB0jZay9SViL2shSWspwOy+k1MQcfS19koyTy/JqvvcKuf 8Rujxu1raY6ODWq4A4SWCv5fuOeS7Zplq45FlVcnaTa09FuFmCgvKVjA0pg4wVywJrpO QIFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VLgbT14a; 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 s20sor11101131ljs.24.2019.12.30.06.44.10 for (Google Transport Security); Mon, 30 Dec 2019 06:44:10 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VLgbT14a; 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=yJwsi3DMV/pwzB8sWAmHjBjjwOzOWtOVx10q5OKc/Qg=; b=VLgbT14aKbIweXjePyokMcXGIZ6qb6kWlnLdbU2O9QNBikijGUeMsDJ5BerDOGJVyP hT/gOq3EcoVXwl4kpM8e3733iP90YILT3RaXDUM2AuU9KGQt4qYTgy6f6jabQM8o6m0z f2Dw+FKT/VwRq6dj/Q+Mb4OPmk5DBWeU3Am8tGUkQkau5kdcLudikh879SjNbyZlbktm lKJi0S1dkLtuKh4sR51iIzOPusJcnwu9cu+P1Mbyr5xhvb7FvMb2wY+1GVhDzNKRCsz4 LDcl7o0n0E5yYOD6GEMWIYriiQq1ppx9SFRSm2kbu+C3hWO2xWy6bgqtGzmp6tbF8BLn M+Kw== 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=yJwsi3DMV/pwzB8sWAmHjBjjwOzOWtOVx10q5OKc/Qg=; b=sf1aZSNVY025Z0gBlOc9HZDVkE0ANp7XrsZJAITnWnMy+YekcPv0S3qxDJiUqbBK2n Vk/49P8pSH8rhc3sFDQPs7Nc8KnJW96WvEQXD+oPYNVqjHvRocb4DDXSdTLxfcbavuqD 29wFKBWlZN58BlLy35nB14lUfPVzgSKUNerVhX/STHrFO9YPug0hc5Yb+Hr0ysO43xxv n80kSmomiIAffrQCS6hTszMlRgHdHXLU1kT6E0Jx4tDwATA+iqNK0LnK5Tz/BK5bf9h7 BweULIkuTrcOP1UlneLL0H95xDp/mjBKL4j9h3Jo6kXnRx3EeY6qwdLOQtyTFcRNgSUZ xmXg== X-Gm-Message-State: APjAAAVfTYV9FeQo71QsOv3c0NDqlTlLBZyYDmW37DMv1/wvWG8a0QE5 j6EWwIWbWAl3zG+jIMnwv/LiWkvb X-Google-Smtp-Source: APXvYqwN0EAf9bCeoE9MhNqvKtGj6Kuzpeq236RUFu+VyIzagp3j7CmYdCtkZY/sNNfmqJXTyE+Ieg== X-Received: by 2002:a2e:9e43:: with SMTP id g3mr23393509ljk.37.1577717050174; Mon, 30 Dec 2019 06:44:10 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:09 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 01/15] cpuidle: psci: Align psci_power_state count with idle state count Date: Mon, 30 Dec 2019 15:43:48 +0100 Message-Id: <20191230144402.30195-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> From: Sudeep Holla Instead of allocating 'n-1' states in psci_power_state to manage 'n' idle states which include "ARM WFI" state, it would be simpler to have 1:1 mapping between psci_power_state and cpuidle driver states. ARM WFI state(i.e. idx == 0) is handled specially in the generic macro CPU_PM_CPU_IDLE_ENTER_PARAM and hence state[-1] is not possible. However for sake of code readability, it is better to have 1:1 mapping and not use [idx - 1] to access psci_power_state corresponding to driver cpuidle state for idx. psci_power_state[0] is default initialised to 0 and is never accessed while entering WFI state. Reported-by: Ulf Hansson Signed-off-by: Sudeep Holla Reviewed-by: Ulf Hansson --- Changes in v5: - None. --- drivers/cpuidle/cpuidle-psci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index f3c1a2396f98..361985f52ddd 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -30,7 +30,7 @@ static int psci_enter_idle_state(struct cpuidle_device *dev, u32 *state = __this_cpu_read(psci_power_state); return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, - idx, state[idx - 1]); + idx, state[idx]); } static struct cpuidle_driver psci_idle_driver __initdata = { @@ -89,12 +89,14 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) if (!count) return -ENODEV; + count++; /* Add WFI state too */ psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) return -ENOMEM; - for (i = 0; i < count; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + for (i = 1; i < count; i++) { + state_node = of_parse_phandle(cpu_node, "cpu-idle-states", + i - 1); ret = psci_dt_parse_state_node(state_node, &psci_states[i]); of_node_put(state_node); From patchwork Mon Dec 30 14:43: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: 182617 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422162ild; Mon, 30 Dec 2019 06:44:14 -0800 (PST) X-Received: by 2002:a2e:571d:: with SMTP id l29mr37733971ljb.193.1577717052194; Mon, 30 Dec 2019 06:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717052; cv=none; d=google.com; s=arc-20160816; b=TBCoLmShYTERTfa3K86oSNGB7r6oT+PIGKmwWvjP+DKQ/ovuFtv7wtOhnGI4ooQ7I3 RbziB5jegdbZ33Dvy60UpbgWzUaNRsqOst2HzXJTDRo9pjwcKAKt6xO7tukyetQl1/YC AgRCHvGo1NFv9NeoS3YYq0fumMlcAcHFKcFMUa00RxaA/ibm+JMPqc5WsHfd+hx+qll5 uxIiaxVerjpbXZYzxeGRJDjJFtniSprqld/6z9CRF5yH3ARekV+2aAYFK3WHzJPK3Mlm wW33IEF4MDGmMdIQKw/QoRecvzPC+tMJ4V2oH3bTdxZZXhbZ92uRmatUAwu3DTXc5iC6 ZAQA== 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=r9qPRcXLVOFWseww0rJCrR4g4TyPzQrzTBExN2uOHy4=; b=oaE9YObKsr7lkS265Rc5hkvn99ZVZx9ScbjPigfoMBHau4IMaWqhnoOTUr21qu/PjI xShIlKkM4UNLPOl+azp94/mTH1AzdY6qzMvwHcv4+0GzizDB3u47RwdPO2mrIm36IAZf W8ewn5/WewMkRNDT7fw2cRuc1kBEcNxPtm0LWNaC6ZIqGYZpCXc6u6SF+e+vKs2swv1b daZCm7QMQM9s+ziF45KcteJio5cbG6qFjatrCHrys2l7GDI+UOg0SJ1e/IFnvFbc7+o3 KzSLfPG74iIRJzSCcUp+ft95pvJqkpb2SysirZCIknTRJtz2/0M+tp0Lk20btlSBviVP /8Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OnI4QS8N; 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 r22sor9749440lfm.21.2019.12.30.06.44.12 for (Google Transport Security); Mon, 30 Dec 2019 06:44:12 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OnI4QS8N; 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=r9qPRcXLVOFWseww0rJCrR4g4TyPzQrzTBExN2uOHy4=; b=OnI4QS8Nt6994mhUQcx1kQDuaQevESKsLPc8rxKnbqqWftkt+E1r46HY0dBwrhzkpc H44CDiCqlg8smjWuD0yvyE73+wlqhZc7C8QG6ZehqRlD8J9XekP0rDHcA7B/g56ltIWP bUEM5q0EiJK7TVg2z5KRi0Ltrl9DEgg9ggy0kBGFijfO1eRRqdLhKdOwo3W0oLE9mdvU IV2uouMDvacrdHlIGkvYikscyBPs4Ze+hKxYJ18DKMGMOCJzo3RqTCKiA+j/+So2dVSC VuJUrQz0V43p/P4mfxlsXrh58XgBede12nLo8nQeizi9nLDVu4UzH46v6abiJ65zZvgL fi5w== 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=r9qPRcXLVOFWseww0rJCrR4g4TyPzQrzTBExN2uOHy4=; b=hdNaOsi7EXTl3F09GELVKzcxLNP5yix3GghSG/f/T+qQ3zSuD4hBs5DyzMxVNZW2wT 2XHewvITjwHDP0ygnEEbdsaD6f6g4qL1jPbC5GB64QCwji1jJ+C/kExgXWE3rBluv7Fe 0zOvJP6Wu/uEdVLQLZK9OfPGsUYoNMXL6hq6SJntsnU79nLnYX5SYX5SL8bSyijJYtH8 sTEzjaY9/B2x8VbgvGRFSGZyzs0UvjQM44flhYzBVyEyklEz8BAiDGdAgnX3XsKTA1Rs svwWJ/Q8riiR+CyE9Ne8421sMQr1aS00nKAKvB0/Q+V/xGSu5LjP5UHwD+k34//GYiul S3aA== X-Gm-Message-State: APjAAAWWlUQsqfYvTXOOcv0Gv7TGU4z/u1HjCacVfxMxMc5yI7FuM87R 36uaqu06NtOB/l/NatfRiUGyWqAl X-Google-Smtp-Source: APXvYqxzJBNjO1k6tBVSulP2pdf1igj0eM/c41xEG/qNA1Roj4AVOwV30PiEM9CDLX06bl+IWvOITg== X-Received: by 2002:a19:cc49:: with SMTP id c70mr38777845lfg.73.1577717051716; Mon, 30 Dec 2019 06:44:11 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:11 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lina Iyer Subject: [PATCH v5 02/15] dt: psci: Update DT bindings to support hierarchical PSCI states Date: Mon, 30 Dec 2019 15:43:49 +0100 Message-Id: <20191230144402.30195-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> Update PSCI DT bindings to allow to represent idle states for CPUs and the CPU topology, by using a hierarchical layout. Primarily this is done by re-using the existing DT bindings for PM domains [1] and for PM domain idle states [2]. Let's also add an example into the document for the PSCI DT bindings, to clearly show the new hierarchical based layout. The currently supported flattened layout, is already described in the ARM idle states bindings [3], so let's leave that as is. [1] Documentation/devicetree/bindings/power/power_domain.txt [2] Documentation/devicetree/bindings/power/domain-idle-state.txt [3] Documentation/devicetree/bindings/arm/idle-states.txt Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Reviewed-by: Sudeep Holla Signed-off-by: Ulf Hansson --- Changes in v5: - None. --- .../devicetree/bindings/arm/cpus.yaml | 15 +++ .../devicetree/bindings/arm/psci.yaml | 104 ++++++++++++++++++ 2 files changed, 119 insertions(+) -- 2.17.1 diff --git a/Documentation/devicetree/bindings/arm/cpus.yaml b/Documentation/devicetree/bindings/arm/cpus.yaml index c23c24ff7575..7a9c3ce2dbef 100644 --- a/Documentation/devicetree/bindings/arm/cpus.yaml +++ b/Documentation/devicetree/bindings/arm/cpus.yaml @@ -242,6 +242,21 @@ properties: where voltage is in V, frequency is in MHz. + power-domains: + $ref: '/schemas/types.yaml#/definitions/phandle-array' + description: + List of phandles and PM domain specifiers, as defined by bindings of the + PM domain provider (see also ../power_domain.txt). + + power-domain-names: + $ref: '/schemas/types.yaml#/definitions/string-array' + description: + A list of power domain name strings sorted in the same order as the + power-domains property. + + For PSCI based platforms, the name corresponding to the index of the PSCI + PM domain provider, must be "psci". + qcom,saw: $ref: '/schemas/types.yaml#/definitions/phandle' description: | diff --git a/Documentation/devicetree/bindings/arm/psci.yaml b/Documentation/devicetree/bindings/arm/psci.yaml index 7abdf58b335e..8ef85420b2ab 100644 --- a/Documentation/devicetree/bindings/arm/psci.yaml +++ b/Documentation/devicetree/bindings/arm/psci.yaml @@ -102,6 +102,34 @@ properties: [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/arm/idle-states.txt + "#power-domain-cells": + description: + The number of cells in a PM domain specifier as per binding in [3]. + Must be 0 as to represent a single PM domain. + + ARM systems can have multiple cores, sometimes in an 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 hierarchically. + + For these cases, the definitions of the idle states for the CPUs and the + CPU topology, must conform to the binding in [3]. The idle states + themselves must conform to the binding in [4] and must specify the + arm,psci-suspend-param property. + + It should also be noted that, in PSCI firmware v1.0 the OS-Initiated + (OSI) CPU suspend mode is introduced. Using a hierarchical representation + helps to implement support for OSI mode and OS implementations may choose + to mandate it. + + [3] Documentation/devicetree/bindings/power/power_domain.txt + [4] Documentation/devicetree/bindings/power/domain-idle-state.txt + + power-domains: + $ref: '/schemas/types.yaml#/definitions/phandle-array' + description: + List of phandles and PM domain specifiers, as defined by bindings of the + PM domain provider. required: - compatible @@ -160,4 +188,80 @@ examples: cpu_on = <0x95c10002>; cpu_off = <0x95c10001>; }; + + - |+ + + // Case 4: CPUs and CPU idle states described using the hierarchical model. + + cpus { + #size-cells = <0>; + #address-cells = <1>; + + 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 = <0x1000011>; + 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 = <0x1000031>; + 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>; + }; + }; ... From patchwork Mon Dec 30 14:43: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: 182616 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422155ild; Mon, 30 Dec 2019 06:44:14 -0800 (PST) X-Received: by 2002:a2e:88d6:: with SMTP id a22mr37870413ljk.163.1577717054061; Mon, 30 Dec 2019 06:44:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717054; cv=none; d=google.com; s=arc-20160816; b=X/fFZNXk4fX9AFAkN6NnWMh+8OaC5FKUWQn7z5iDFlWO4alZqpl6OPFq/S0x+An2vQ ebWf5xc39sKXPLdFYAK7rVGJZg0v/c8hWEFyi6ELcuBLOi/S2BOkhkMKcmRFA94JCP9V FqhTXxtTVTFndkjrgY6taM/GHYvayvc0u40t3QYNpYrCn1UzhHxtcc+MT9Kd6iwZKRu+ wXnbrt2ew2zW804UW8lOFnWN/7dwwCDnTvCIcI7jqhMQbqZnz6sSCEDxWigzabhDryv1 e2Us69YP8dUTDqpComNGnpBba7Aiyz+W3X8/lUjiFMv4OTwHB7/KGHa88m3Ub9yyHExg SL6g== 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=krY1+EzVUJ6sQ3sUZo42Ne6/cEpafTpvxV4MO9ew0Qs=; b=xeSKBB76PBHNHjt+MeuPj3h498R+gbwXJ5GN1CkqF2a2/ynBCIWCz6NbiIyPyR1cO5 J3wdMx/Z7y0pRjmPgL48g3GuUN5f0gs53l0iX1jvAIMoFjCUCXkYv2AOf4XbNNFC2PAP pvvAduxph7Eip6PNubSVyazJoVwJq01Uvu9ndr/T94dguuy5luJphAUKSNCqNvJfjkc+ XOWPDJYUV83c/48wjyFh+WaxIccSO05rrogk8O3ty7gf7zTe6OMpmzsJMuAoLukrQ/le LiLGoJi3PZFO2SegzRHq3jzTndE3xLe2RQvlF5SfUHTQQGQCGc9Xjz1LU/pvFuneg5e6 Xt3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gc+Fg4Tm; 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 s14sor9813171lfp.52.2019.12.30.06.44.13 for (Google Transport Security); Mon, 30 Dec 2019 06:44:14 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gc+Fg4Tm; 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=krY1+EzVUJ6sQ3sUZo42Ne6/cEpafTpvxV4MO9ew0Qs=; b=Gc+Fg4TmSoUG1xWh3kAAiPa4hscTTHTe6IdrmSqns5W0W+f7yJrWKqBYznZ+x0PfgH NXbjsuw2UWFrmRxEtu+ztS7HJpjnO0pQMsTaHMpUkWCneB+VdUs4fpaxwI4jqRs1A/0h HmWRvjF8FTPMxeZXibm2xawvWvneqvZysoeI74fqb3JuHPQ6wc9t52l/qvM9Xi1BIGbr Xm2ICKSM+SPWCTmZkaqkmasmkFKPO744rJ8SrsfKkjQQpjcXbjzrdM+UBEz2ONQJv4hM Eue69/Oc3VVQtL6NLjIDPyUe3oBQcFFKMow3ZJ7rP0IwzTXPWtSqWDS1snHLUYOL6hAG YM5A== 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=krY1+EzVUJ6sQ3sUZo42Ne6/cEpafTpvxV4MO9ew0Qs=; b=fb4PAO7khz8gBqCZj5wwNFzy9ldVCHxpouuN0vc/pERLpKN9fVJx95RKAp26NqaJNE uMEgqiHa5TcQubB/3n2hOgk8NQT4wiRRQb2SUvYmVFoffWjoN+LeI8GwQ9Y2m22bH2g0 sQBcW7kWrDMLg94IxIgh2GDB9p1e1HeiU+O9N06ErNu4rLjCv+S//oLi7g4B8FEl1yyF WQAaRf3+984nWA/DunyJxmu68vbNegc5ClrQByKJOxuir6efRHBmd/CondXHMlxw46kV /u/f9ndRkkAn84wplTjpGX+ivwbSuyDDlBWKXTeeGCxWig3NPvXijrePcu9iA+UHZ2MR owLw== X-Gm-Message-State: APjAAAXzGZmMb9GgpHQwiw7+rvs+RPu567Y46rO/nBXk7aNDcS+JtMKO IINgpCbtJsJU7IMtvhnom/soJQVA X-Google-Smtp-Source: APXvYqwJxfxFlD3Cgmg6BuZVIx15qUnVkISMIx+ar2b16DDxv2vUZ23t0kZT/+jP5v39VcqlR5CAmQ== X-Received: by 2002:a19:8a06:: with SMTP id m6mr35878357lfd.99.1577717053708; Mon, 30 Dec 2019 06:44:13 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:13 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 03/15] firmware: psci: Export functions to manage the OSI mode Date: Mon, 30 Dec 2019 15:43:50 +0100 Message-Id: <20191230144402.30195-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> To allow subsequent changes to implement support for OSI mode through the cpuidle-psci driver, export the existing psci_has_osi_support(). Export also a new function, psci_set_osi_mode(), that allows its caller to enable the OS-initiated CPU-suspend mode in the PSCI FW. To deal with backwards compatibility for a kernel started through a kexec call, default to set the CPU-suspend mode to the Platform Coordinated mode during boot. Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v5: - None. --- drivers/firmware/psci/psci.c | 18 ++++++++++++++++-- include/linux/psci.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index b3b6c15e7b36..2937d44b5df4 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -97,7 +97,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; } @@ -162,6 +162,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; @@ -544,9 +553,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"); + /* 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/include/linux/psci.h b/include/linux/psci.h index ebe0a881d13d..a67712b73b6c 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -18,6 +18,8 @@ bool psci_tos_resident_on(int cpu); int psci_cpu_suspend_enter(u32 state); bool psci_power_state_is_valid(u32 state); +int psci_set_osi_mode(void); +bool psci_has_osi_support(void); enum smccc_version { SMCCC_VERSION_1_0, From patchwork Mon Dec 30 14:43: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: 182618 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422188ild; Mon, 30 Dec 2019 06:44:15 -0800 (PST) X-Received: by 2002:a2e:b054:: with SMTP id d20mr25710844ljl.190.1577717055590; Mon, 30 Dec 2019 06:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717055; cv=none; d=google.com; s=arc-20160816; b=UzqWxftu6Tg3huu6YUUjjKoV7+zrjBa9eYXDu+w2CEcZtCD6mI2kQvLa/vxGEZUKd3 YA458MnL/aKd8b8f8fRXfs+dogPaEf377IxxlxcaeGpn8/YFfWEXWNVWYxLFJlPlvFnr lypEvBzJ3UFBb2OqHUkoD4anbMFwm0nSJQOEjj8A9uYszBSLnU6oo/ezR48/mcnH/kFR FB7EeFFrzcg4rzJmA/XE/lL88/vzRWgBGNulQHDqDbX2qF9CxpI8J3i1zPrAD/f5jFhV xc3Aza5yw0CXEIrsY9MNKIo0thqRx1Fi3XiOt8KCOAR6/8BVe3ra3S+8sc2eh6xGiyU0 OBXA== 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=2SSEC2vfb168IYWIDWdargmVpZp+vFDhT4s2aSCvbsQ=; b=lxqZz6XukHXFPzMcmMaG3x8V6N/a0bWI4UoFC+HwnVvgyrx3MJi6icnKBCg7axEbe9 GWrXx5x/d1kDgYibRg5m3tbv1Y4eiHMMOprjs0rN5FS+CoEAiBoiRG4lZDQutdY6RzRI CKIEmuxiAOaU4kj4Y2RTOzBR3M/5zHr8p4EweCuMyxAOKz2XxtAjzjas1y56mOdUJrhl BXokOz6PgNc0Grz0Ra7dG1uL7KL8y7ovUVvOFwUbpnwLBTB55uunH9EKX1MMGSpxFrFM Zxcjw0eGsvWMJDm4IxYn+/nFC/mihcRYbDLgyrjVwX7r4IHYaoekpGvc7EWYlFmRIW9k yLmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cy2p709J; 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 u26sor19093688ljj.0.2019.12.30.06.44.15 for (Google Transport Security); Mon, 30 Dec 2019 06:44:15 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cy2p709J; 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=2SSEC2vfb168IYWIDWdargmVpZp+vFDhT4s2aSCvbsQ=; b=cy2p709JggRMYRuxWxFdSksTT9ddyA6a1dDrdu8q9fW1P86WFtSDw9ag8hPz6ZKNOQ kDbXHnK228dLnG1KkaVAm6OI3xR1KKNURB+OdJgoUO+EiSNZF9dXv9l9daoRmOzkGs2T 00+SgiucRmVEWbLY4IJz3gvwOyuL+S4e/7NiYFsWBMHBQDyjcT3EK2SkrWpoLwFdaPEg nBYjSUKXhhEzxyGYCZqZGc1kKT070puW5yjAnE/b9zsWciGHXcg8kN8xdQ5cmJzfHNmh R1vZZc3iISEj4NHiP3JQ70DFnvqLZX4hOO/+R8BfI/n3NfeJoC1NKuqgI8O5xUoMKVij T5qA== 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=2SSEC2vfb168IYWIDWdargmVpZp+vFDhT4s2aSCvbsQ=; b=MZSD5yK2Lx738MCI1bEwQLgEc0dGPUiA6EmR5amEksYRQYg/Djnsy/ipYKEysaRaIw qDrjbUBKhXS/zkYn74FDp+x2ZcJewDVJ+fe5CrfMrY4ilRQs3AVep36UGm1y7ZEOVGqe 62W2bhM6ycGc8swM9RZdcEEWR0/tmmIGu84zRTVwP+6JjQ2+moAdu4saBkVl6AV2YuKe w+r+7Sm/sfUhlE3ti/XyK70rfcrLUZ4mEUYS4dmp2zgg+5NKyToqUAUPot7nqXVZwoDw /yu7ogGsIgYd9qlpRQVKKTz/1LHOT8sXm7QNejWAKw7qZB9m9eKof+abWYIZhEaqByhh YU+Q== X-Gm-Message-State: APjAAAVXJGboNCvsIBUCG0c4z9rjl4prVjOIrA1hC0ctU7Aj7n4kopIQ 1KAvGVN88Oye7o9KKVdzhStSPD/h X-Google-Smtp-Source: APXvYqwKhyGXfftma4hgJ9/As4lgMAp1G9DT6skACgdPUdlDaDw5umtQpzwwdtRkeXNe5nNxtRZmUQ== X-Received: by 2002:a2e:88c4:: with SMTP id a4mr10783373ljk.174.1577717055205; Mon, 30 Dec 2019 06:44:15 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:14 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lina Iyer Subject: [PATCH v5 04/15] of: base: Add of_get_cpu_state_node() to get idle states for a CPU node Date: Mon, 30 Dec 2019 15:43:51 +0100 Message-Id: <20191230144402.30195-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> The CPU's idle state nodes are currently parsed at the common cpuidle DT library, but also when initializing data for specific CPU idle operations, as in the PSCI cpuidle driver case and qcom-spm cpuidle 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 PSCI there are two options to describe the CPU's idle states [1], either via a flattened description or a hierarchical layout. Hence, let's take both options into account. [1] Documentation/devicetree/bindings/arm/psci.yaml 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 Reviewed-by: Sudeep Holla --- Changes in v5: - None. --- 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 db7fbc0c0893..614f0c674995 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -489,6 +489,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 844f89e1b039..c669c0a4732f 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 Dec 30 14:43: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: 182619 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422216ild; Mon, 30 Dec 2019 06:44:17 -0800 (PST) X-Received: by 2002:a2e:7009:: with SMTP id l9mr39088881ljc.96.1577717057128; Mon, 30 Dec 2019 06:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717057; cv=none; d=google.com; s=arc-20160816; b=qzZ2U7lwtvmBu7ipOvvPty7vxksxv1VYKHVdlnLxT+KU+NKNU6YAev/4dd/BhYlVfG BKDoyV/GtFx9XC8dNBPA/wgxL3ZB04C5wXnopJiond9QJdz/Up/Zma4630VDEmSIsufJ OU1cHEp73AXJPEcJ/38cW5zrEvhiSoMxoL6+wXRNDZgB44zUA3+5kznPyyVvPiWoZx82 u9eTx7NdIn1USBLyKGE40VP2vU6ghvc8cjMY73Dk54a2sZXBqREdbfI6bN8o6FiyFX0c FhwYAW9mC7nl5kUqVQLcynWZBwmBIGWyXLEmBNOk3iwbMNsSCqhktNwvbO99JdkmHBu9 IkSg== 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=owx+SloUf8pds6VPSlJapJq+5ymBBPQ7iA/SKJJgwjU=; b=poT5pFlXSz4NcddEBLj4dD6ljDm8svEXTdckkKh80SJy6fEmyKaQRuy/G7hMJbmsrv BjwMkkTyLdnrx4Uu3/vK3jJGxVTvIpWiwLHCF+2ort7LmoSFoZJ/oaeeYSoq+/XZYu3T CZmnx7WMoWXY4HBBsWZUSkPv0qxQzjl+jmN9OqL6WOUmAcH3cEFvcJ+CoKjK9WZw1otW MglOu1hj/q7292kPCE6zX0mwrOdDYityFojRqqOHWOrIJK7mdSAfdhdpv6WyTrnwOxqO 5PeRFXc4mOWegCezM6ZAE12gWqBtuvvSGe89EoWjrFGM2LSpcu3xVkp7BBqtNBzenDwI +FAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOMMern6; 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 o25sor9673274lfi.16.2019.12.30.06.44.16 for (Google Transport Security); Mon, 30 Dec 2019 06:44:17 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOMMern6; 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=owx+SloUf8pds6VPSlJapJq+5ymBBPQ7iA/SKJJgwjU=; b=jOMMern6T7wiWE4/ufEPrcYPooLKd4g26VuETKc7rFkMRNBi7vRvt8RFhBr0UOWAnN wp11vcK5R9zGy6To03gCj2b0edl6KenBOw1Y+Jb4/Xv8ZSsYJBbEM/iOOcAndEOhUKDf t5WQq15GFK32RuJCD0MERQBiYIJz4eWhazo3dx3TlfMiVG41xKuXddbILMfHTxh9gzpj MQ64gwbw5YmhfRQDHZIZQzHQm7Gx93y0GfcirJquGCLKb31azdub1BUAwNDJhfvmnPwQ y1TQ1/1HmlOhpvbbHmNj8AVinJ+THuhmX6qe2QprHuwKGNVBuuPFIbtj7RLGpelLTurU VQIA== 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=owx+SloUf8pds6VPSlJapJq+5ymBBPQ7iA/SKJJgwjU=; b=XstzxkWPuQK2EoKeTzw5M1ZcwG54fwEBCONdegdfROK63ocStLxuWHYXex1flCdckR Ly4KvV4R62KmX/6Ml3QSSFcHv7QUBAZG/pJ+rtLatkt8mKDfqytivspAQaxfuI82MZ1S OR15W0CIzMgn+m5c40cOxjixd0OEP5A6Uwt+I3tuzEnXMovfrX5ciDN8RPyfZGYXkp7b 2xTgxuPAtrvffSbSoUXRnJYCRIXVw6hhVS3pLGRieQiCjYlW7w2ziSqzBbaVN0dqI8S8 +BihCaue5hEFbK4uFF/HYkalEGU6wwTFjH51Exi479MdRb4rninN/XbNlcAdZkv7SyNc 6gmA== X-Gm-Message-State: APjAAAW46PrtQR86oaGuo0CVfgD1ysN7glhRGwK61aYcjkd1ffGt5Jly pL9SYJAPXMRFn20p1JPZXKnHmFqB X-Google-Smtp-Source: APXvYqxp/iitD6O/NdUA06r9/yZSgghJqfhQcVQLOvvXc32vodyNVAkq4131RInkIiKGlrJereqGvg== X-Received: by 2002:a19:f006:: with SMTP id p6mr37770832lfc.94.1577717056795; Mon, 30 Dec 2019 06:44:16 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:16 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lina Iyer Subject: [PATCH v5 05/15] cpuidle: dt: Support hierarchical CPU idle states Date: Mon, 30 Dec 2019 15:43:52 +0100 Message-Id: <20191230144402.30195-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> From: Lina Iyer Currently CPU's idle states are represented using the flattened model. Let's add support for the hierarchical layout, via converting to use 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 Reviewed-by: Sudeep Holla --- Changes in v5: - 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 d06d21a9525d..252f2a9686a6 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -111,8 +111,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; @@ -170,7 +169,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 Dec 30 14:43: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: 182620 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422245ild; Mon, 30 Dec 2019 06:44:18 -0800 (PST) X-Received: by 2002:a2e:8eda:: with SMTP id e26mr37484761ljl.65.1577717058732; Mon, 30 Dec 2019 06:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717058; cv=none; d=google.com; s=arc-20160816; b=yOX+3UCQ52bogdXkZ92vOm8Be4HcCLBm22CGmBFuYW5OVJbYPfTVjzSwCINUChWgzd ZKhLnuuVGGKaaooaowFx/NM3FfWzIqwBEvoAtzlRlKv0j9gJ1T+T0sTeszM68RPs8sjs +TlRprFhgc1Qi0D7DDOckGEFUQ2IPlc1TgFs29u4WbOolXiNQRxQbrTyK8V9ETAa9KdJ iAxV5h9LIbLNPoAGdUVDDdO+pgFB+dtfVgcelexq43elVvvYYUIErQ3bp44dAspXYsvJ uEf/Qv95rN+aS0fsxF3iPDQWy4wWLiORXtrbwBtmrb5rcQX/wM/WKTk+bUc3AVGKX1X5 NScQ== 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=6qhaKAOOwBUfphZITjOkaySj3WTdBaYmHNTmS8ilyv4=; b=DXfl9MYrs3HJ/wkpShcOmaBpFie8p/vYxcuSWp0IhEP2UfpF5FPr7mHV6YNYLcrRsy IWRjHCloGwqh9bzoUZE3CgC6cUFAI/ByO2suH6tuOWOTf1bFIJafgwhLfajW+0zBCSlV 50AiH7wL9ZAg4r+pttP2amuxuw4xWEGUUOrBQpfSR+fooe5vgiQl2zBIVsmTmCGbSRC7 dgvX/dqGKAKuJamoUQx7Jl9Rr+byXhQI84j3FzI6DkXwijUBHbwAZSTc81CCH7GhOWIp zpsohHhJUqDkhFzRCAk97jOvqGsDSRT3YRkWbUJlSLxi2nyYvjRLZ89gOoI8EiNizvO1 4/1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wG7mQUko; 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 v15sor19667923ljh.7.2019.12.30.06.44.18 for (Google Transport Security); Mon, 30 Dec 2019 06:44:18 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wG7mQUko; 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=6qhaKAOOwBUfphZITjOkaySj3WTdBaYmHNTmS8ilyv4=; b=wG7mQUkoPejsVwzXXOR08qaX/pB5VvQfRie7bMqeCEZDWX6/8m1lt3cS7XNawUn2xu XMe4fcnuL8f9C0vHRJKGysck8qxoOMC50DHral3znLUFRh4dFzTa7cBTRvdiBY9RGsiJ 2uMf3PGS38C96bB3TAoX/OpgAVZDIus7XktEp05Y0clIcfD4bxDP0Vyj8HEq4lIKuzdy TDUIRxVUXm/kzgxN6BVIPqMzTYHNg4QmGEfyfbaruTVN5RulSwBpkD3XhfpD0ynnicdb MFoEgkcs0R0oX04FnDByktNiRwyDuiGeA7Ndor1L21m4KpMXcfjf60XZ3kXh3pc/fE9n YROg== 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=6qhaKAOOwBUfphZITjOkaySj3WTdBaYmHNTmS8ilyv4=; b=TR3aznVRIXw7o4GBuKCypg/rkWOudPX3LyzuDYQbvLeRAOB8UPIgPrqkkfxpeEReRM qhf6FteCA28p58ttjU1JuaOOrn4aDcV1HljfCGemUmhScloJgYVB8rkX+USgS+MiBQN/ eVIvR4tn2n0WXKP0KRoDmLggLkdLRKz7ag2TL1clD7bhprFSH+HZ0spUTULKx80pPSsx kua9JKCX0Zg4gMF7NEPvjsVQf31C2fGIB3vFS46bK5hyO+hTL+/k17j55lX21aGwSn+3 IBaot6cq4d61G+E6gX9G7+KKsKMd4pl6pFpyXvle68jReVTSpKtXLl2+ZIXipYQYDH5o TiVw== X-Gm-Message-State: APjAAAXyd+f7E+pXs/4SXp/YSFOUqECPDhmQk5PyEwImyhsyzCPYITnf Rd/FMTLrveAuUszYQVb+aiYpfX7F X-Google-Smtp-Source: APXvYqzo7w+nzPjrwX/azlK6JCTeEG0nxZOnfsmsZ5aML/2fh5jWYLvgMQF5SaNVyXhNasLRLg8J8Q== X-Received: by 2002:a05:651c:327:: with SMTP id b7mr37221036ljp.22.1577717058420; Mon, 30 Dec 2019 06:44:18 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:17 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 06/15] cpuidle: psci: Simplify OF parsing of CPU idle state nodes Date: Mon, 30 Dec 2019 15:43:53 +0100 Message-Id: <20191230144402.30195-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> Iterating through the idle state nodes in DT, to find out the number of states that needs to be allocated is unnecessary, as it has already been done from dt_init_idle_driver(). Therefore, drop the iteration and use the number we already have at hand. Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v5: - None. --- drivers/cpuidle/cpuidle-psci.c | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 361985f52ddd..761359be50f2 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -73,30 +73,24 @@ static int __init psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } -static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) +static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, + unsigned int state_count, int cpu) { - int i, ret = 0, count = 0; + int i, ret = 0; 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; - - count++; /* Add WFI state too */ - psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL); + state_count++; /* Add WFI state too */ + psci_states = kcalloc(state_count, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) return -ENOMEM; - for (i = 1; i < count; i++) { + for (i = 1; i < state_count; i++) { state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i - 1); + if (!state_node) + break; + ret = psci_dt_parse_state_node(state_node, &psci_states[i]); of_node_put(state_node); @@ -106,6 +100,11 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); } + if (i != state_count) { + ret = -ENODEV; + goto free_mem; + } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0; @@ -115,7 +114,7 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) return ret; } -static __init int psci_cpu_init_idle(unsigned int cpu) +static __init int psci_cpu_init_idle(unsigned int cpu, unsigned int state_count) { struct device_node *cpu_node; int ret; @@ -131,7 +130,7 @@ static __init 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(cpu_node, state_count, cpu); of_node_put(cpu_node); @@ -187,7 +186,7 @@ static int __init psci_idle_init_cpu(int cpu) /* * Initialize PSCI idle states. */ - ret = psci_cpu_init_idle(cpu); + ret = psci_cpu_init_idle(cpu, ret); if (ret) { pr_err("CPU %d failed to PSCI idle\n", cpu); goto out_kfree_drv; From patchwork Mon Dec 30 14:43: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: 182621 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422289ild; Mon, 30 Dec 2019 06:44:20 -0800 (PST) X-Received: by 2002:a2e:9095:: with SMTP id l21mr37935092ljg.175.1577717060389; Mon, 30 Dec 2019 06:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717060; cv=none; d=google.com; s=arc-20160816; b=nWrg0cbIpWI/1vrzQetQxvOFzB9mI5sw4YbG/pixK6TZTWZGVWKqHJ80CG+AvYRFTL PKWnWzmb1hmYkXXP7iBSgVG1nelff/wNM1CsC1KrzWdk+GXZubpJxOducUKZBxd6CNV+ O90xvwxw8aUAfr5haMeg/pGd5gDHHvUxpm19VJ8Ns5++sht+Z0KzKPLG5hkszcJs4V7q QmQoc29o4lw266ogFUGjlBfGpuDGSrOEKMNgS1EuvE65tgixs4etDA6MqwWhcM8OaS/8 XXCqDs0dWOjwts6gYZSbhe3KBTqa607d9MJVKq9Dxbhl9Nv1pZZaZWF4lwYlmllJmd0k czaw== 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=8v5xuPr2EJ9DSJyEgwYWHNaPW3NhmJIKXs9ahA/QI14=; b=S5KdFXrlUuoH0vktzbYxgd8isA0sXwpbxSiDe8atGM9Iq/YvVZleoQgqFeTdW5LZZT AuNeJ87vHQeOVfWhqyxp18WOfi/NB19xBLWK2DQrW9LLpE0Bc9nvnKsPKLGqnpjkOEtf DXo2FJ/pAd96w1ij0jEfwxVn4RflPmvvXpmRKQ+tS8yGRovStHONsylA6AUHPW65zwSc dAoo7QuUYq4JMPtKHhdMJW1hEmpxw4xEHYWUsZC0yXbtUjE75hRVni9LfOVqvaccBEr2 DBmfu4VvNQqh0fn6v+E0rXr4GSOQkTwP9H4QyAr8HuNOn2eAlD945Wm9CXJdbueB1Zli xt4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gaWhEs8b; 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 e26sor19379997ljl.37.2019.12.30.06.44.20 for (Google Transport Security); Mon, 30 Dec 2019 06:44:20 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gaWhEs8b; 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=8v5xuPr2EJ9DSJyEgwYWHNaPW3NhmJIKXs9ahA/QI14=; b=gaWhEs8bCTWDjEkiGpFUqwqn0GmNDQFWOkn0x0TuUvrI5mbmBk//3DIZtLQXKs5geY qZOvtle3WhKIeLFP4Jf/SaYuFwlcYSLHPyMWs99zDm1lmL1hR/5wxeqoI69Ti0korIh5 PmfFnwSLudQzFF1yugoRk7BpHN/tfDHzC9mmEwDiapNhF41HUTHdedRqODqM7S96A6uG bt7yFtA39kFLXZA+CCjihGvjyrxenBf/EJsQG9XvkaoZqTB4ZRdiGl0cms+egMgnp6W9 3zvKcfSuVKP3GLgFldKd0Ef/fh2TRxoLjaDsk8sD4a993+4iZ9mAKuW783awGHt96mi7 Mcuw== 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=8v5xuPr2EJ9DSJyEgwYWHNaPW3NhmJIKXs9ahA/QI14=; b=dgJ0LoD5bLddFTimgrnHz6ihNjoWV/ojNb36RMTW+NQeer6kWY8cPCpIZRT+0nYN9q Y0c2XwgzMzSHh61L7qKd4XgqMVVumqWf8jnlULLGapYSCtNKBz0SZNiQAE//QWakGysX /5GHmyarZ8zqXFFOCPei4XeLuYSibRW2AyCOynzgsaZ3PTyx2se67yHyaG5Hoc2cnkdk aHc/u60om42Fs4uTSIznxeHYFbyDbaMOeEtexs2qQEZOdau4pLKZ2QPjhx071O10ayT0 rQbUbNmevqFWAfKquy+9sQmqKMwp4vorIqpB99gVYfZoHVkkg066IJpwIndSS9H4bosd XTeQ== X-Gm-Message-State: APjAAAVDEMRsKJwbx+C26ydQtMYe4Z4rDdQ+jY/XurdOeLx6lVqEy55G phFqUOWp5QPK/qt4esasbwMBGUxI X-Google-Smtp-Source: APXvYqy2psF+SHAkdnmFnQHEnt8nfdz54W8h3uR+uQcrYtNUivkQ5xNld+aRPQg4nCP0yfXDA3vZcA== X-Received: by 2002:a2e:b1c3:: with SMTP id e3mr38270940lja.137.1577717060097; Mon, 30 Dec 2019 06:44:20 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:19 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 07/15] cpuidle: psci: Support hierarchical CPU idle states Date: Mon, 30 Dec 2019 15:43:54 +0100 Message-Id: <20191230144402.30195-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> Currently CPU's idle states are represented using the flattened model. Let's add support for the hierarchical layout, via converting to use of_get_cpu_state_node(). Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v5: - None. --- drivers/cpuidle/cpuidle-psci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 761359be50f2..830995b8a56f 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -86,8 +86,7 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, return -ENOMEM; for (i = 1; i < state_count; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - i - 1); + state_node = of_get_cpu_state_node(cpu_node, i - 1); if (!state_node) break; From patchwork Mon Dec 30 14:43: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: 182622 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422315ild; Mon, 30 Dec 2019 06:44:22 -0800 (PST) X-Received: by 2002:a2e:a0d5:: with SMTP id f21mr39441325ljm.106.1577717062571; Mon, 30 Dec 2019 06:44:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717062; cv=none; d=google.com; s=arc-20160816; b=BOoFigacAC6gFOytJh9zgJeTzQ4BQjqusofx4TelqtX1Yh5WxIKhp2JRSUzHebwDDU AH5kuPOAKryfN9/jKCuqesR8FUXpIUx+aMwMoPYf8UC2epEbxhJpvLO4D8ERUmziU0IC F0RR+HN+TVAsrO8BCeJ+gxt+qIwJ3bX38MOcAO7G84WmDZoYfoHOfNMzBxBCbLG6FiJo RlKui8an+DAl5GcM3vWNGgLPzrOACrPK57ESiTvV++CB429T3+RSk9raseuMiMyr8ZQJ QT6wtYTBlBXx3pFqU/MmmrgTAO21DeHoCanNhGA35PdLNXk+30zHV62rqjvaQVwyrwIv PtxA== 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=neea4kQTvG+Bpgec4NpbRFMjAla+zHuzZZgjs6GRGkc=; b=oIiuoC9LWX0ZX3FAR1HwTkyNh/XAyvzm4/H7yeym10vsdhi5h6+vRxDlzZ1LzbmpsC TJuzCfn7EZM/WM9BnLCQZQmHMlEfgkXkXp1TEaecc8st9nKKnp+QkEQf5SLwdZX3BWua Vb/Yqiqy9gP9DFCAfjUW3TQn7U2Gni7CMLIByLp7Bw6L8iaLJnMG7J5mJQWaRJ/9TlgZ D5W5yFgOzjWg8zsiBaHy281B7Kap5W2gW8CHAZtPFjjngawfjwokr/D4lolTZTjmvix5 DnqznrNXTRV0S4Ev6Fs5694P3PayhTJ969xM2DzQtcvsyelXAYDiV/E6PLmm4L+GjxXS qFvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CY8w9n0q; 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 f1sor19641306ljf.31.2019.12.30.06.44.22 for (Google Transport Security); Mon, 30 Dec 2019 06:44:22 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CY8w9n0q; 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=neea4kQTvG+Bpgec4NpbRFMjAla+zHuzZZgjs6GRGkc=; b=CY8w9n0qANi3pwpse5njlfUuAXhBW7I2P8v6T8Momocn6zaJyS9eUNpXR6rklTo6dg sq+oD3qSYMqB0wdHlDpE3jkyYaDDnJHCkfrXPBz1GfhmtlV7apr9LScWjde4LbAIiZx0 RLOWOqpMSJiQcd3lmVt5H67wYDzWg+AdVC9P1T20yfcXI8ABlEREGNiOd4yO4jG7QCUI bkADMMLprTLR0eR+X7OmdFXwjGSeYM0Ngk65Ev77A+7MtvMrv27NP0obM/n5DvFCWGYy 5z7X2a5X9oYhJZ3SAkZHCYhKtbgKBoaNCtXSM71AdSInmuszfBFuZrl7vxgoyZ5wjZ4m 6I+g== 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=neea4kQTvG+Bpgec4NpbRFMjAla+zHuzZZgjs6GRGkc=; b=pIA5/93KwQGQ7d0UJU8M4qAV4o74koHI7tMari7+SZJcxs79gQikZ5V1DzJDV3wPDe f68TstvCSx+KgMOQYnFPcoa4vCK++0exIRp/U8dqekGoQcw+6aC2C4pszX4XHjfqfaAY /iapCf8gQN/ieoyvybRqyQlPNFpOBw7JhKle1w3Qt09IeZXR6auxsyIJp5Y4sWBX81Wv e1uwcPjzbnn2ueJmU1OWnugJH6ZCyAnovLB3mXgSsIyFepGuijkBEdlt5xds9Fp5HBZo UVAqtHmtEvtKWxRV0Eij5lWJS0ltqH5/VK4hMcRmtQhOGOd3E5E+D4jFHz64Y4vQ5gjX txJg== X-Gm-Message-State: APjAAAUOj6SrfO+J2PV1VT6c9BLE7WlNFqJBRN6O3fPydmrDk6585cRh Eiw5c897BejzY0W6jBdAwfKyi13I X-Google-Smtp-Source: APXvYqz4pHdrSZYvR9LPkn6aBxofeWRY+5WpuR/T2iFRqr3dH9alwMysRzcX9iPHqQj6c18Apu+KPg== X-Received: by 2002:a2e:93d5:: with SMTP id p21mr40357019ljh.50.1577717061929; Mon, 30 Dec 2019 06:44:21 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:21 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 08/15] cpuidle: psci: Add a helper to attach a CPU to its PM domain Date: Mon, 30 Dec 2019 15:43:55 +0100 Message-Id: <20191230144402.30195-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> Introduce a 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 makes use of dev_pm_domain_attach_by_name(), as it allows us to specify "psci" as the "name" of the PM domain to attach to. Additionally, let's also prepare the attached device to be power managed via runtime PM. Note that, the implementation of the new helper function is in a new separate c-file, which may seems a bit too much at this point. However, subsequent changes that implements the remaining part of the PM domain support for cpuidle-psci, helps to justify this split. Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v5: - Declare psci_dt_attach_cpu() as __init. --- drivers/cpuidle/Makefile | 4 +++- drivers/cpuidle/cpuidle-psci-domain.c | 31 +++++++++++++++++++++++++++ drivers/cpuidle/cpuidle-psci.h | 12 +++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 drivers/cpuidle/cpuidle-psci-domain.c create mode 100644 drivers/cpuidle/cpuidle-psci.h -- 2.17.1 diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index ee70d5cc5b99..cc8c769d7fa9 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile @@ -21,7 +21,9 @@ obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o obj-$(CONFIG_ARM_EXYNOS_CPUIDLE) += cpuidle-exynos.o obj-$(CONFIG_ARM_CPUIDLE) += cpuidle-arm.o -obj-$(CONFIG_ARM_PSCI_CPUIDLE) += cpuidle-psci.o +obj-$(CONFIG_ARM_PSCI_CPUIDLE) += cpuidle_psci.o +cpuidle_psci-y := cpuidle-psci.o +cpuidle_psci-$(CONFIG_PM_GENERIC_DOMAINS_OF) += cpuidle-psci-domain.o ############################################################################### # MIPS drivers diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c new file mode 100644 index 000000000000..87f881c21af1 --- /dev/null +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PM domains for CPUs via genpd - managed by cpuidle-psci. + * + * Copyright (C) 2019 Linaro Ltd. + * Author: Ulf Hansson + * + */ + +#include +#include +#include +#include +#include + +#include "cpuidle-psci.h" + +struct device __init *psci_dt_attach_cpu(int cpu) +{ + struct device *dev; + + dev = dev_pm_domain_attach_by_name(get_cpu_device(cpu), "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; +} diff --git a/drivers/cpuidle/cpuidle-psci.h b/drivers/cpuidle/cpuidle-psci.h new file mode 100644 index 000000000000..8609482cf490 --- /dev/null +++ b/drivers/cpuidle/cpuidle-psci.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __CPUIDLE_PSCI_H +#define __CPUIDLE_PSCI_H + +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF +struct device __init *psci_dt_attach_cpu(int cpu); +#else +static inline struct device __init *psci_dt_attach_cpu(int cpu) { return NULL; } +#endif + +#endif /* __CPUIDLE_PSCI_H */ From patchwork Mon Dec 30 14:43: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: 182623 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422358ild; Mon, 30 Dec 2019 06:44:24 -0800 (PST) X-Received: by 2002:a2e:88c5:: with SMTP id a5mr39088358ljk.201.1577717064265; Mon, 30 Dec 2019 06:44:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717064; cv=none; d=google.com; s=arc-20160816; b=apGHj7ZtUqWGeeAg1nCFin4sKZ5LeIRoxqFO4zqHLzCmbd0ok7299mATsT1I2D15TV XKWK8JK3IyFzNCsP/OcMQULiNbvTLieCL9bhqh2IX4RELq+V8u4O5RtrS8QavpRd5WXF w6x1dCkdLi57EYNxbnKhAbWjiisliwfDg3yyTSslJoVv+Kg9UqUwcqFcKc1RC3C5O/8K 82wK9auSOuubE2ZJ0VmNhXlU1JE0wACbmMmP3b9E7CL2zjGGaWJPiD6VQ6VEQ7YaN8We Y1GjszEi5fKD53tEFr2Skvv9j3iG0TbMLmNtVG71MdE2uNmaMN9NhDpm/qtzijHOIj9a 2b/A== 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=F62eMHvAlv7nF3GieiDqKuJt4z4o+7t76tdVx5DtOc8=; b=FxY91FVgOZUHZf1wXJ4K4oS0DU6PO475zdKDY/XDswgYYOl3gRKCOeY/QrV67PygG1 bHzJNGtSVbNLFmlslTVGNhPFneCo3U2AKipVhTS0Qq7TVRC4QmfkkqKYgKgZXJnYkQH+ B6Gj4apwrsxiyJIJggQvqzFbiQFs9Z8OY1u91AWVtlSeyLSKsW/xK5iEgFAyl/NTAG/7 rwMJGfm6DwYpY1punyjqxrGjZ/IS2ZZlCTN650sx3gU5JcxDz7VYyAZRocxwgNXz80Um Gws2GgWx/Ysl4rSf2BrZNDGM4ARHEuh1qHVZ2MFeoyl9jMwwoEzSJagvlD9VyJlOginh DytA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKKUKeIO; 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 v25sor15752379ljc.16.2019.12.30.06.44.23 for (Google Transport Security); Mon, 30 Dec 2019 06:44:24 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKKUKeIO; 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=F62eMHvAlv7nF3GieiDqKuJt4z4o+7t76tdVx5DtOc8=; b=xKKUKeIOyuo2s2W+neuN/sbW173fQNrou3tC+j6v7Ko/GuV217MXietDZKhjA3Uskq +oGLDtucefGKWLnVAkdy0EhggOa4EVlAW3GgnRf3Q///TpMXhcvS47NgjBgaWEZcvHEa sNPyCIaZTNdpqI7KOnRBwON5a3hrpogrN9d9Ws+HKMrAubG/J+RRvvjmiuXp2X5RAeLx 6xSd9DNxkiJYPcmnO5P1a2Ljaf0kWX0Uv0AmAJhO8VjFrwyPTyVlJYM0h5cT5tIv0xYm DOGryt9AIk3n2s3w+VoyOqVcAFEb685q0iz4QCXHyot3S9+MEpZiMmxb1W2IxQea5VsV oLOg== 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=F62eMHvAlv7nF3GieiDqKuJt4z4o+7t76tdVx5DtOc8=; b=uEBdO12h9kzLRdlgfDxtJSSt5gjLozkeupd01U3vzYcoHt6AyXpZzCnkScOk8xjv1+ 1sWOFeUpeR7lW4jLu4DqiYFC4YeFFz7JRlM4X51K3jiER65sGayrKSJck7nydf6kNRWH pNWYm3uJyDtw+Ds/rFg1iDJYEB4pFppuWesaaauvtNy8PfiU8egmLH5E5yAs1qObDJCv Lq8n8B8WBJASQYogPJ9aLeTbCrIumV1VgysAyU2/SrsRhZkebrCeqlt5Ad6jDyt9YCBC 0ypkUsHPn+cdEqxKlSG8FHCkA19ExXM+a7KTDOCxVAbRoKYhweLKHIHWjvIHbKpc7HLB pOTw== X-Gm-Message-State: APjAAAV94iyiLEi43yAXcUprS5CE4USM232zTitR3O3Ac8y4u42QA5hI bB50pcKHSunpezDoriEgiD9opRdN X-Google-Smtp-Source: APXvYqx5ku6KI9MfPdQZ+SWjpmvOotL42D1PWyIwc9k7LE5GzctpSfHSXBO4s15SrZ/WJeAsBlX0Ug== X-Received: by 2002:a2e:8e22:: with SMTP id r2mr32224867ljk.51.1577717063226; Mon, 30 Dec 2019 06:44:23 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:22 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 09/15] cpuidle: psci: Attach CPU devices to their PM domains Date: Mon, 30 Dec 2019 15:43:56 +0100 Message-Id: <20191230144402.30195-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> In order to enable a CPU to be power managed through its PM domain, let's try to attach it by calling psci_dt_attach_cpu() during the cpuidle initialization. psci_dt_attach_cpu() returns a pointer to the attached struct device, which later should be used for runtime PM, hence we need to store it somewhere. Rather than adding yet another per CPU variable, let's create a per CPU struct to collect the relevant per CPU variables. Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v5: - None. --- drivers/cpuidle/cpuidle-psci.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 830995b8a56f..6a87848be3c3 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -20,14 +20,20 @@ #include +#include "cpuidle-psci.h" #include "dt_idle_states.h" -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 int psci_enter_idle_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int idx) { - u32 *state = __this_cpu_read(psci_power_state); + u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, idx, state[idx]); @@ -79,6 +85,7 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, int i, ret = 0; u32 *psci_states; struct device_node *state_node; + struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); state_count++; /* Add WFI state too */ psci_states = kcalloc(state_count, sizeof(*psci_states), GFP_KERNEL); @@ -104,8 +111,17 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, goto free_mem; } - /* Idle states parsed correctly, initialize per-cpu pointer */ - per_cpu(psci_power_state, cpu) = psci_states; + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (psci_has_osi_support()) { + data->dev = psci_dt_attach_cpu(cpu); + if (IS_ERR(data->dev)) { + ret = PTR_ERR(data->dev); + goto free_mem; + } + } + + /* Idle states parsed correctly, store them in the per-cpu struct. */ + data->psci_states = psci_states; return 0; free_mem: From patchwork Mon Dec 30 14:43: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: 182624 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422423ild; Mon, 30 Dec 2019 06:44:27 -0800 (PST) X-Received: by 2002:a2e:9942:: with SMTP id r2mr39582051ljj.182.1577717067814; Mon, 30 Dec 2019 06:44:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717067; cv=none; d=google.com; s=arc-20160816; b=X0Aa2tSGfUuKBf3BNrbzercfwhUWIoba7L3g0Jikuzt5CcN3cp24aXqM9gZlx42vAR fDEC7mxJmXUCDUsf/eY143BrCYS9PuyCvFJ96kGwpIaeoQ7+T/BooqfDLrnrACzPd8kL dyXpiCZbUNUyi4wxssKYzUrM1a1RwyA/hZMXzgilnFbYK1gKTi7+B/efJU9SCUAGkug3 b7Ja0BgNfx68K5LqLSOmC8w4xJitmmHMy6IxYniv02zSiPYzWUt5/F6dHb6V9xfbBkMs 81D4r/H9tCaXrHLBsWJZ/U9CExXNbpBLQGhaO1hfoDwPyN+UMl4XV0TVY0MHah3RGZcO thNg== 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=iP0q67cVa7joTIBbxM/rB2PXgLYhwll7Ud0Qeuw7uE4=; b=LZH9jXN9YyzUTOuVD+M5EgQ8PvhHd8NJZUXXWtjOJwRDk23jheVPGHluqZRJD3mQlG ug1g/yyGvRyiXRiuxPlbrCv67+rs2Vp8TvrINEUmZCbxkFc3TQ+TT49+xQdT/1hVMqjW g1F9vAQ8Q/j9qCBgWvjnSt5we5vNjCtgQhfq+uZ6WZSTdOcAYLRtB5maABOCBcgZO6wA CaD3Wkv+0EDZ0l2XLgiBGOin7YTLYayRieL9i/dhBCQzVZY9qpFngCpj7AM01/TOkltF /VrrB8MUI4i9ROF7/piKxE8T0izODPp1DAEqUSpYzx4aNXOW9/caPFDHa4b3Gfb/UXNX 8xwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cZDkTeTB; 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 h18sor19591466ljj.14.2019.12.30.06.44.27 for (Google Transport Security); Mon, 30 Dec 2019 06:44:27 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cZDkTeTB; 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=iP0q67cVa7joTIBbxM/rB2PXgLYhwll7Ud0Qeuw7uE4=; b=cZDkTeTBaAAlRRZrP1XLtXSbuzbscAVY8zmWFyVTHUO5xJzFNqhSGbfNaVWsCH1AuX 4rT40nwkm1sYOV87tQsTVNYOpKm/XQgnTfubKy97NWJGHyYGyJ+cykHyuBuzwg1e4vI+ dP2uBSyDD85o+XaR8nCem4voDrHfRNDwol6CbGAaupD5x1CDQNr/ejTTClgbNp+xnOmR 2Bybqk0ajXhcvXbxyM51KKuqO7Pq9KUok4Z20H1s3n3ChONQsVe8t0SEdohf+xd9LlR9 TwQyqLl/Nqa3iyclS4fQCNrW5jt9RzhUB79qF7nkaemxrQzWOlFc+6vmMc74MtPky/iM eUnQ== 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=iP0q67cVa7joTIBbxM/rB2PXgLYhwll7Ud0Qeuw7uE4=; b=Lj4jKuh2/4efUAslaf8RWCUZSp1QV/2ugusRyR+EIRcxoHf+s2PXsxUl6ux1bl0oke j8pWVTfa29dCkyF4S6hQkG4/g7L9kYYSvBqxBhdSCqfpnngazWrwT9FkIORtodO8ssSC 2EEI//S8quf53E5WMB60N9FFEV6doccqdG5wX88+skDyZ+FMWh+PlnhvT6tu5/n4Stzz 4M4rE6ILfdXgafIWYEVrGpuqJzOLshB6wA5HPY4NpwQJXFtil6NTtWbumbiqY4hyQQE/ 0+v/kpySQrYuwDQ38Yg4MKFJs/HfcdRD3qXWxtn4hfriPo5HifevfhWWenVUMgcoKMks ksYg== X-Gm-Message-State: APjAAAVohnSpnhrq9qFKmskNKjgHI0fQ17vBvxLk3lNokHStfOyCezMF We16L0LANngDdbSEbrnt/0ouQ9gcw96bhA== X-Google-Smtp-Source: APXvYqzBs/tiWnncxKxVYy6elFVnD48Lxju0cyn1aR3gEPXIkZtrCY33Ut1F1NTu0L4H0jjmnQTcwg== X-Received: by 2002:a2e:8090:: with SMTP id i16mr39630757ljg.88.1577717067493; Mon, 30 Dec 2019 06:44:27 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:26 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 12/15] cpuidle: psci: Support CPU hotplug for the hierarchical model Date: Mon, 30 Dec 2019 15:43:59 +0100 Message-Id: <20191230144402.30195-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> When the hierarchical CPU topology is used and when a CPU is put offline, that CPU prevents its PM domain from being powered off, which is because genpd observes the corresponding attached device as being active from a runtime PM point of view. Furthermore, any potential master PM domains are also prevented from being powered off. To address this limitation, let's add add a new CPU hotplug state (CPUHP_AP_CPU_PM_STARTING) and register up/down callbacks for it, which allows us to deal with runtime PM accordingly. Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v5: - Make CPUHP function/variable initdata. --- drivers/cpuidle/cpuidle-psci.c | 45 +++++++++++++++++++++++++++++++++- include/linux/cpuhotplug.h | 1 + 2 files changed, 45 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 6e7804e697ed..9d779be27071 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "CPUidle PSCI: " fmt +#include #include #include #include @@ -31,6 +32,7 @@ struct psci_cpuidle_data { static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static DEFINE_PER_CPU(u32, domain_state); +static bool psci_cpuidle_use_cpuhp __initdata; static inline void psci_set_domain_state(u32 state) { @@ -72,6 +74,44 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev, return ret; } +static int psci_idle_cpuhp_up(unsigned int cpu) +{ + struct device *pd_dev = __this_cpu_read(psci_cpuidle_data.dev); + + if (pd_dev) + pm_runtime_get_sync(pd_dev); + + return 0; +} + +static int psci_idle_cpuhp_down(unsigned int cpu) +{ + struct device *pd_dev = __this_cpu_read(psci_cpuidle_data.dev); + + if (pd_dev) { + pm_runtime_put_sync(pd_dev); + /* Clear domain state to start fresh at next online. */ + psci_set_domain_state(0); + } + + return 0; +} + +static void __init psci_idle_init_cpuhp(void) +{ + int err; + + if (!psci_cpuidle_use_cpuhp) + return; + + err = cpuhp_setup_state_nocalls(CPUHP_AP_CPU_PM_STARTING, + "cpuidle/psci:online", + psci_idle_cpuhp_up, + psci_idle_cpuhp_down); + if (err) + pr_warn("Failed %d while setup cpuhp state\n", err); +} + static int psci_enter_idle_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int idx) { @@ -166,9 +206,11 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, * selection of a shared state for the domain, assumes the * domain states are all deeper states. */ - if (data->dev) + if (data->dev) { drv->states[state_count - 1].enter = psci_enter_domain_idle_state; + psci_cpuidle_use_cpuhp = true; + } } /* Idle states parsed correctly, store them in the per-cpu struct. */ @@ -289,6 +331,7 @@ static int __init psci_idle_init(void) goto out_fail; } + psci_idle_init_cpuhp(); return 0; out_fail: diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index e51ee772b9f5..01f04ed6ad92 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -95,6 +95,7 @@ enum cpuhp_state { CPUHP_AP_OFFLINE, CPUHP_AP_SCHED_STARTING, CPUHP_AP_RCUTREE_DYING, + CPUHP_AP_CPU_PM_STARTING, CPUHP_AP_IRQ_GIC_STARTING, CPUHP_AP_IRQ_HIP04_STARTING, CPUHP_AP_IRQ_ARMADA_XP_STARTING, From patchwork Mon Dec 30 14:44: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: 182627 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422511ild; Mon, 30 Dec 2019 06:44:32 -0800 (PST) X-Google-Smtp-Source: APXvYqxD922N5+Yhe9Y2GwCihoiloWzQkTo5vgDHaTANnH+ONlKwP+Z9CnNHm7iokx9mj19pxazd X-Received: by 2002:a9d:5545:: with SMTP id h5mr18038991oti.296.1577717072156; Mon, 30 Dec 2019 06:44:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717072; cv=none; d=google.com; s=arc-20160816; b=gnImul6/3zd1O8yn+LxXR7gBZLtGMGoP1CsK97UsYPJDljM0d8WRtpb+QPr7rYk9MR 5TpmREdpCzJ95DZbQWoICLxJJTHE1w5HZZoU6ODNQHvX4bYFP8v1XD+zA2GPrTPm+q9x e9JzPW87Bi79pFZ7kB/wKyYtlue0M1adJpk9//YWBnwGiBZfQM8eP3jQEZCVHF9LGny6 PUopS8iTjYshfdDS11Kc7jMniOKEcHF4VLwxdi0EFLwzUptrOR+yrr0GmzEDCludYG23 hxIeYKDa4kf9V7Y8vfNhIeP4Ao+I+d2DPBUKxfqWkqk1d3FlRAu8UWKLmGJLC4ic0tc1 7k0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=+SgAM3h033e/MLAOZ0d/dorO2oxTfoGPJAEbgrUK1sA=; b=p5mLFg/+RSVbPW+Ru2YQQW+vGMG/R4q8a7DnlIrpi3Y2rpfrAo5xL8to5qRx+rsP2Y vML4UmKpTiC6dIlItjn7MtK+9Z+UaLzi+1w2vLkrcFdNXFojpCkZliDYC5FdLmiTa2Wk IYkJKg3Zat1uX8vVZBQuuFxsm+AbjtXJP+MER3zMdYsaAtGhq4WW1bNPmSE7qQwlM02z 4hOdtIZvHnI+C3P14gZVH6UKDy7MD1EDaXBDMuitZ5aaSYFXOYHtD10EmEQSwlwdZdub duZHxYyjp0GOP0EuFx3y9Fn+NjU3vL3I825HSVfXU5KZIH3EWlOD0h85EVxx+2cFB5JJ 702g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TZ7puyOx; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si28512433otj.235.2019.12.30.06.44.31; Mon, 30 Dec 2019 06:44:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TZ7puyOx; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727577AbfL3Oob (ORCPT + 9 others); Mon, 30 Dec 2019 09:44:31 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36627 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727597AbfL3Oob (ORCPT ); Mon, 30 Dec 2019 09:44:31 -0500 Received: by mail-lj1-f193.google.com with SMTP id r19so33512290ljg.3 for ; Mon, 30 Dec 2019 06:44:29 -0800 (PST) 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=+SgAM3h033e/MLAOZ0d/dorO2oxTfoGPJAEbgrUK1sA=; b=TZ7puyOxM+yGMbc3OGs6XvJX2K3hv/kDgeQIRnULYOGBMEJf7MAYGjYEzFkRBHtmQq IPa0AzJ36KUXkdzKzwmlplSKsccO970rx5ZZ3m9v+Upw5gJBovxtKLmxzrx/oYtAF/6J D5OXvUSkffHvEGQQ77aW9k1QG8eGDi3q1Z9xZH7gNWN4Xo/Bk1SqhvBHZ+HySpzZN2Hh jvljaarakC0NGmGNMx/Of1925O2nOinjCd93Ysjf4/e5zhvKfsHScC7nur/jO5RHXC6X Fz2b4o+zUWUZR4UhN6WTDZvrWliv8ykVC5+1UMsGrQqKV6Yf8KbR8laDQKfoDH4ozQ44 HCNA== 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=+SgAM3h033e/MLAOZ0d/dorO2oxTfoGPJAEbgrUK1sA=; b=pZalyND+L9+rD2hs9ob/Fd1UdO9KWzv/lF6IDj35fiMRDgV9ov/SAUkhWkx7KHukgA u6b1zwF7yvt0aafALdKGjAeRasf2aadt6LoeEhYDYZaHHgj6PlXFZU+YruAsrA+J0Vne BP76Q6BCO6ln+79hivaxjX98OH6y2JwhuZU0mz7lLm3IrZK8r3YYYctFuwAc3nG2rWqt YMT/vnum1zrKXfzJgtjHdYIXwb9HvBuJVDC2Q7a+6VqwURM/0eBvzh3AAZ1bJMUFv1fr obpOvvq5+XjTGNVIQORXCBEK9t7h7Q1A4ogRaC0XMbIxTEgOloWUaGFaD/WyRV7zi7DM deTA== X-Gm-Message-State: APjAAAVeZUVedk4M9xPj6s29zq5Bmmc7fINpu0Ha2fzsYO0m6yILev3e IC9OE/+8X9EayCGharP3hisDFQ== X-Received: by 2002:a05:651c:1077:: with SMTP id y23mr38549803ljm.79.1577717069205; Mon, 30 Dec 2019 06:44:29 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id a21sm18744931lfg.44.2019.12.30.06.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:28 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 13/15] PM / Domains: Introduce a genpd OF helper that removes a subdomain Date: Mon, 30 Dec 2019 15:44:00 +0100 Message-Id: <20191230144402.30195-14-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We already have the of_genpd_add_subdomain() helper, but no corresponding of_genpd_remove_subdomain(), so let's add it. Subsequent changes starts to make use of it. Signed-off-by: Ulf Hansson --- Changes in v5: - New patch. --- drivers/base/power/domain.c | 38 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 8 ++++++++ 2 files changed, 46 insertions(+) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 8e5725b11ee8..959d6d5eb000 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2302,6 +2302,44 @@ int of_genpd_add_subdomain(struct of_phandle_args *parent_spec, } EXPORT_SYMBOL_GPL(of_genpd_add_subdomain); +/** + * of_genpd_remove_subdomain - Remove a subdomain from an I/O PM domain. + * @parent_spec: OF phandle args to use for parent PM domain look-up + * @subdomain_spec: OF phandle args to use for subdomain look-up + * + * Looks-up a parent PM domain and subdomain based upon phandle args + * provided and removes the subdomain from the parent PM domain. Returns a + * negative error code on failure. + */ +int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec, + struct of_phandle_args *subdomain_spec) +{ + struct generic_pm_domain *parent, *subdomain; + int ret; + + mutex_lock(&gpd_list_lock); + + parent = genpd_get_from_provider(parent_spec); + if (IS_ERR(parent)) { + ret = PTR_ERR(parent); + goto out; + } + + subdomain = genpd_get_from_provider(subdomain_spec); + if (IS_ERR(subdomain)) { + ret = PTR_ERR(subdomain); + goto out; + } + + ret = pm_genpd_remove_subdomain(parent, subdomain); + +out: + mutex_unlock(&gpd_list_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(of_genpd_remove_subdomain); + /** * of_genpd_remove_last - Remove the last PM domain registered for a provider * @provider: Pointer to device structure associated with provider diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 5a31c711b896..9ec78ee53652 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -284,6 +284,8 @@ void of_genpd_del_provider(struct device_node *np); int of_genpd_add_device(struct of_phandle_args *args, struct device *dev); int of_genpd_add_subdomain(struct of_phandle_args *parent_spec, struct of_phandle_args *subdomain_spec); +int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec, + struct of_phandle_args *subdomain_spec); struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n); @@ -322,6 +324,12 @@ static inline int of_genpd_add_subdomain(struct of_phandle_args *parent_spec, return -ENODEV; } +static inline int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec, + struct of_phandle_args *subdomain_spec) +{ + return -ENODEV; +} + static inline int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n) { From patchwork Mon Dec 30 14:44:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 182626 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422488ild; Mon, 30 Dec 2019 06:44:31 -0800 (PST) X-Received: by 2002:a2e:9e03:: with SMTP id e3mr39054468ljk.186.1577717071247; Mon, 30 Dec 2019 06:44:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717071; cv=none; d=google.com; s=arc-20160816; b=1ApF+7TIkX5dP/e1IZxhgCiGDUZvBukNOH+pWnSFbEuJKVsSY8domGQavytbOuy+OC oPWbefVmKGoXtmpL7WM6VQrJn662j5SeLibgpMrxXjp0NDFyZqiYoFRPnzKGQgZUw3ll Qzo1MV5ZdMDFVqo9TWKizxNAdVsxIJsxpBQTRh1UaM27AZ6MYJyCFjGeHt3pEUSOwaIp +6qkh4kpkyf+Z9bhALgkJDHWpCSUqTxCWc0EdXuMvyPeG1DewZ/fkRuVZCckg75AsGrm avuBa6cJickeAVPC8Rrp20Y4z6qM4paSQ5fQ7NSzr5zYegZSGuBfG7OLSa1VDFA8q28j ixtA== 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=JE02hg+B/QTwsutbOnDGGVXBmAWIdmulkW5XXOokyFg=; b=q6kHefKGw/YvfV9P7cRiFQKrUdSrLPeKRcEDY/bUaVeoO27+FdTnlmpeMUb56/qp2L fxX+DGIlYAjQBvQUajp+9AoS8Y75dr6pLCPeo4XsAKSUgj/SrLu6cFHXHYX2YwoY/D+p QTxKhh8qVZfLFD/5naSVvBOco0GEbZw1qsRGYcyp3uduprfAdIfFpLzG1hYnPTvXTWhh R8e0IbICzhtCAKEuTFtgOuCJb5zqY4wSGIk2AZkOEl2ttWg82knjs6OHmCu1f2sUIFEY EMxYAIE0uN/gAImU432THrQk/USICBJsdU/ZG+W9SXOA8nFrPpqdG3YhECeuOTKel4og Zn9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bq8UOsEy; 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 e26sor19380240ljl.37.2019.12.30.06.44.31 for (Google Transport Security); Mon, 30 Dec 2019 06:44:31 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bq8UOsEy; 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=JE02hg+B/QTwsutbOnDGGVXBmAWIdmulkW5XXOokyFg=; b=bq8UOsEy5KNKYrvHMWGaqWZ68Sfn+QSB+7EMXo87GY8qcpokHDVGNL0g8LQzlG3TUa iHq7wMHzM6xfxl4g+CUFhuroSyZ8D5ATOOQKNyJ1ZiUpCKnK6+HlAYgKIIyJ3/lCwWZD WKyyJSQ1KVtS9oQvWMWmf5PoWKI72gVd0qy/TaEkLKlULWCVBJd2+t9icgFEXhqDE/tY U/MwKlZQQEwBChSqnsXI4vnGBYF1Fy8nh2lvAkNq20IVEVQ4wiBsVq5WuoW5b5NqrhsL l1VZQVJsMazw72SdH2MOTb1veYU09g/Cnln4kWtP2LIlg5Hf/1Z5+r1Jk1d5dillWCgg vXyA== 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=JE02hg+B/QTwsutbOnDGGVXBmAWIdmulkW5XXOokyFg=; b=VHFo3vx2eYoeZTVIS6YFTc6tc41JEfZNCBFZ95zM9KnlqsEjSllt7ktlubDE0R4zpP xmXWqxWMVgCUqpohfl1O99vYIxYZ7f5ySGQE/M300d86VOtPLLh2/Qh2PduQJ/OzIJWw Xvm+IcYupWNgjss6ENig7lSsKXGpPzIoNMS2u8IPeKKgptwixeah3oC4ucqN8YtpjCv9 dqKot3ZV6EBTwCN5t08pnS/Qgbxwd2nEvxEU0hZ4uDV1maz+7/21WIIJEJnYHZ7syWGy KCAJxaEwFpdqh7u2wDzvX0PLZeSA1uJi/l84YMcULcA70/BY/GJYDxSnWkf3IvNXrRcP u3SA== X-Gm-Message-State: APjAAAWrM+mwLkW+2POh5CRldaEM6SUmWKLbp1QoFMsfBuUjYZ3eyqqh 4FkEGddhVDzLDn1ANlXSB0/fG8G+ X-Google-Smtp-Source: APXvYqxlZUOpxfdTpvoCwyEmOCNS8buNKqm5CxY2aI9/cFZSf6+MMktwDWVj+F4tZG5LbvzgPyNSAA== X-Received: by 2002:a05:651c:1b3:: with SMTP id c19mr34481451ljn.115.1577717070811; Mon, 30 Dec 2019 06:44:30 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:30 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lina Iyer Subject: [PATCH v5 14/15] cpuidle: psci: Add support for PM domains by using genpd Date: Mon, 30 Dec 2019 15:44:01 +0100 Message-Id: <20191230144402.30195-15-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> When the hierarchical CPU topology layout is used in DT and the PSCI OSI mode is supported by the PSCI FW, let's initialize a corresponding PM domain topology by using genpd. This enables a CPU and a group of CPUs, when attached to the topology, to be power-managed accordingly. To trigger the attempt to initialize the genpd data structures let's use a subsys_initcall, which should be early enough to allow CPUs, but also other devices to be attached. The initialization consists of parsing the PSCI OF node for the topology and the "domain idle states" DT bindings. In case the idle states are compatible with "domain-idle-state", the initialized genpd becomes responsible of selecting an idle state for the PM domain, via assigning it a genpd governor. Note that, a successful initialization of the genpd data structures, is followed by a call to psci_set_osi_mode(), as to try to enable the OSI mode in the PSCI FW. In case this fails, we fall back into a degraded mode rather than bailing out and returning error codes. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v5: - Remove genpds in the error path, when enabling OSI failed. - Let psci_dt_attach_cpu() return NULL if OSI mode isn't enabled. - Make the osi_mode_enabled variable __initdata. - Drop some DT compatible strings, as PSCI v1.0 introduces OSI. --- drivers/cpuidle/cpuidle-psci-domain.c | 277 ++++++++++++++++++++++++++ drivers/cpuidle/cpuidle-psci.c | 4 +- drivers/cpuidle/cpuidle-psci.h | 5 + 3 files changed, 284 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Sudeep Holla diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index 87f881c21af1..423f03bbeb74 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -7,18 +7,295 @@ * */ +#define pr_fmt(fmt) "CPUidle PSCI: " fmt + #include #include #include #include #include +#include +#include +#include #include "cpuidle-psci.h" +struct psci_pd_provider { + struct list_head link; + struct device_node *node; +}; + +static LIST_HEAD(psci_pd_providers); +static bool osi_mode_enabled __initdata; + +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 (!state->data) + return 0; + + /* OSI mode is enabled, set the corresponding domain state. */ + pd_state = state->data; + psci_set_domain_state(*pd_state); + + return 0; +} + +static int __init 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 __init 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 __init 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; + + /* + * Parse the domain idle states and let genpd manage the state selection + * for those being compatible with "domain-idle-state". + */ + 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 __init 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 __init psci_pd_init_topology(struct device_node *np, bool add) +{ + 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 = add ? of_genpd_add_subdomain(&parent, &child) : + of_genpd_remove_subdomain(&parent, &child); + of_node_put(parent.np); + if (ret) { + of_node_put(node); + return ret; + } + } + + return 0; +} + +static int __init psci_pd_add_topology(struct device_node *np) +{ + return psci_pd_init_topology(np, true); +} + +static void __init psci_pd_remove_topology(struct device_node *np) +{ + psci_pd_init_topology(np, false); +} + +static const struct of_device_id psci_of_match[] __initconst = { + { .compatible = "arm,psci-1.0" }, + {} +}; + +static int __init psci_idle_init_domains(void) +{ + struct device_node *np = of_find_matching_node(NULL, psci_of_match); + struct device_node *node; + int ret = 0, pd_count = 0; + + if (!np) + return -ENODEV; + + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (!psci_has_osi_support()) + goto out; + + /* + * 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) + goto out; + + /* Link genpd masters/subdomains to model the CPU topology. */ + ret = psci_pd_add_topology(np); + if (ret) + goto remove_pd; + + /* Try to enable OSI mode. */ + ret = psci_set_osi_mode(); + if (ret) { + pr_warn("failed to enable OSI mode: %d\n", ret); + psci_pd_remove_topology(np); + goto remove_pd; + } + + osi_mode_enabled = true; + of_node_put(np); + 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); +out: + of_node_put(np); + return ret; +} +subsys_initcall(psci_idle_init_domains); + struct device __init *psci_dt_attach_cpu(int cpu) { struct device *dev; + if (!osi_mode_enabled) + return NULL; + dev = dev_pm_domain_attach_by_name(get_cpu_device(cpu), "psci"); if (IS_ERR_OR_NULL(dev)) return dev; diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 9d779be27071..edd7a54ef0d3 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -34,7 +34,7 @@ static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static DEFINE_PER_CPU(u32, domain_state); static bool psci_cpuidle_use_cpuhp __initdata; -static inline void psci_set_domain_state(u32 state) +void psci_set_domain_state(u32 state) { __this_cpu_write(domain_state, state); } @@ -143,7 +143,7 @@ static const struct of_device_id psci_idle_state_match[] __initconst = { { }, }; -static int __init psci_dt_parse_state_node(struct device_node *np, u32 *state) +int __init 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/cpuidle/cpuidle-psci.h b/drivers/cpuidle/cpuidle-psci.h index 8609482cf490..7299a04dd467 100644 --- a/drivers/cpuidle/cpuidle-psci.h +++ b/drivers/cpuidle/cpuidle-psci.h @@ -3,6 +3,11 @@ #ifndef __CPUIDLE_PSCI_H #define __CPUIDLE_PSCI_H +struct device_node; + +void psci_set_domain_state(u32 state); +int __init psci_dt_parse_state_node(struct device_node *np, u32 *state); + #ifdef CONFIG_PM_GENERIC_DOMAINS_OF struct device __init *psci_dt_attach_cpu(int cpu); #else From patchwork Mon Dec 30 14:44:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 182628 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422583ild; Mon, 30 Dec 2019 06:44:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxGZ+Hv14E9RUbi/V0zK3Ibe/pl8ciSdXdmmvoW1WW4lVFM5MLr0uRsOULwJpMmQj+XBkMs X-Received: by 2002:a05:6830:1cd3:: with SMTP id p19mr70627488otg.118.1577717076561; Mon, 30 Dec 2019 06:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717076; cv=none; d=google.com; s=arc-20160816; b=H/beTVK/YrEW9i7dMtt0P4d5MTZ+DfNuVKB0387t9c8N9eHG6jCvL6pY7/x3eLFAAz hdUo4mqQuXa9ChE8tUc/g3opUb1Q5EnxhtqHKcZ7EencVQJ0b0EFdhBPfTOs+aypM0HG W7iaQDt3UdOhr/9KWv2xIlhnFVrXgFFyztp36eB2LryVTFN9ZFHlrsbODy6WfCYUbwit u7dQ0X2thhNXh8f0S3+clqurb13iImUOyUdJ69mxaZXBjZmHG4ualZjgmE5EdJ6588SH bY3XA+Qt7eVUfxVPrdWrcvJg21UOX9R//HyVkHpvJiiAwQj9qoN4sLSRxONkBobS0v0X LIBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=pFHyotJ6IeS0NnPGUwSrCQs8d27XE2yrJ5nxr3VtYic=; b=gVSu24RLWIqVnqQUPlOgb76cy3PTgKLwXdRDvqhdmfwGWINebysgmtoC7L+8JTWIef 4w4FpIXEQz2+GPUDAMrDH12e4A3Tf2tjxlJycL8ogt+sj/Xu7hdPuYIwuzE72li66L1X om3xr509c62sfI7eh/Sq55ggDMPH1iur+TeG1QFAWsSc4a++tdyebdJc+j5RXKFeUYdr EjQQnFMwHOAZtEC4hbzRljuTN/FS07qweUjaAQhovPSt9Vllu63DKyAryr70825PGP/m Tl8Rc8hs/abLbhlVDvBKO7ZVg14kIxFWpzDt1x6hMTTrA/MxoJvFcoF2EIlAVlrB4L1O fLGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s5zzc4Lz; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si28512433otj.235.2019.12.30.06.44.36; Mon, 30 Dec 2019 06:44:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s5zzc4Lz; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727630AbfL3Oog (ORCPT + 9 others); Mon, 30 Dec 2019 09:44:36 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40860 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727543AbfL3Oof (ORCPT ); Mon, 30 Dec 2019 09:44:35 -0500 Received: by mail-lj1-f193.google.com with SMTP id u1so33494975ljk.7 for ; Mon, 30 Dec 2019 06:44:33 -0800 (PST) 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=pFHyotJ6IeS0NnPGUwSrCQs8d27XE2yrJ5nxr3VtYic=; b=s5zzc4Lzvw9BL4eBPMqCkzI1609Ctjtx+HMMegsZzrLbvJR3PQGlrle85pbQIAjvQv spD0gMVv3McQxNFa9n7sHSB0CtaQvF20UZS6K5kWhrw/1n0QclJEHvtiB5eSVvJ3yfWG lTg1kc+5OHIy3eladTvA82JxUYopI+/UzQCz8HJiivLaVAl3CPevey+/gcyxcbXuu4lo Ae882oP6a3qVoJHFFKttCYL4xHchd0e9DRbh+BmiqVAJGnXrXoajVof6Mep88AChD8nP bMhjSjVl8YnbU5WlaYGRh8onvQMHN7Gi3m37K1wv4IZidNEBKaAgQzZaK9dNoDXCyQtA EXtw== 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=pFHyotJ6IeS0NnPGUwSrCQs8d27XE2yrJ5nxr3VtYic=; b=BQtfEKVlVKXh8Rk9z2N2jdgmAtnUyvnWdIAHgbxhfeMu9+bZOS67PaCYLyd7CL1hSF apYMtT3BC1+owF3xRuSrvfnvdcGpmJOkfYiEbuWuhhdqTy8t12nP+4S+PAwR6Suu+Sg3 gdlGMQfYWHvwe/aSj/lz5hORuQ/0L68XtO8Heek8XzUypreD0Pgsn8XActMNjDt4VxjW mj92+VPEQLGlanxdOWjwwGWqXeGbCSFN9uq7tTCKhOjA9koUDJRTQ9SN5eQsLjXWOeVv qZMak/B6+wUm2m2w5pxody1N56qobrzXpGYh0C/obCw/dHYUumMKdCeyFZCBEr606Rx0 cbPw== X-Gm-Message-State: APjAAAXCBD+8OXwcGGURBAwcxtSzHDmbD0KXcVY+Szc8nLuYw+TfsXqa FQurgxcYGFQMdnGiP8yTKUMDeA== X-Received: by 2002:a2e:9a01:: with SMTP id o1mr37050340lji.247.1577717072600; Mon, 30 Dec 2019 06:44:32 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id a21sm18744931lfg.44.2019.12.30.06.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:32 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lina Iyer Subject: [PATCH v5 15/15] arm64: dts: Convert to the hierarchical CPU topology layout for MSM8916 Date: Mon, 30 Dec 2019 15:44:02 +0100 Message-Id: <20191230144402.30195-16-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-1-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org To enable the OS to better support PSCI OS initiated CPU suspend mode, let's convert from the flattened layout to the hierarchical layout. In the hierarchical layout, let's create a power domain provider per CPU and describe the idle states for each CPU inside the power domain provider node. To group the CPUs into a cluster, let's add another power domain provider and make it act as the master domain. Note that, the CPU's idle states remains compatible with "arm,idle-state", while the cluster's idle state becomes compatible with "domain-idle-state". Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v5: - 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 8686e101905c..282c36c8fa3b 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -102,10 +102,11 @@ reg = <0x0>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SLEEP_0>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; }; CPU1: cpu@1 { @@ -114,10 +115,11 @@ reg = <0x1>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SLEEP_0>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; }; CPU2: cpu@2 { @@ -126,10 +128,11 @@ reg = <0x2>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SLEEP_0>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; }; CPU3: cpu@3 { @@ -138,10 +141,11 @@ reg = <0x3>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SLEEP_0>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; }; L2_0: l2-cache { @@ -161,12 +165,57 @@ min-residency-us = <2000>; local-timer-stop; }; + + CLUSTER_RET: cluster-retention { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x41000012>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-gdhs { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x41000032>; + 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_SLEEP_0>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SLEEP_0>; + }; + + CPU_PD2: cpu-pd2 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SLEEP_0>; + }; + + CPU_PD3: cpu-pd3 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SLEEP_0>; + }; + + CLUSTER_PD: cluster-pd { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_RET>, <&CLUSTER_PWRDN>; + }; }; pmu {