From patchwork Mon May 13 19:22:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B7F71395 for ; Mon, 13 May 2019 19:23:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09C7E283B0 for ; Mon, 13 May 2019 19:23:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F114728421; Mon, 13 May 2019 19:23:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6E37F283B0 for ; Mon, 13 May 2019 19:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=R1gGCFx99nyKCvGWOCjfVqov2jsq0hgZUh1CHZpNwvY=; b=Vy4OcJPxKwEG/PgZjKCmobTlVT UvHUVWa6GQ/aCoLq8m1TDvBSqcHOfNKcFmVF3BPXernSv0O0QbV8dljNA9qgt/Eax81IXQ9q+1tnf aWhhqJywS2zvQur7GcF/wwGy8/79FKUa91hrHLGqrAj+n4QvjA5Mn1ltDCmn+/uPeXIIupMKTq4f6 JnxtBf5sEk56EmBVghju4ApaqBVFh0d/nrcEZpeUJsYKPNp3rfYIzxoPHrAC5e0NCJBe7chEZc3fs xXKEdpg1FhRHJt31e4dMjez0GBCJe5vAj41uTpRqORJBNpba0W43Kia1pBt0CSDeXfAV9D1L9Kjtv bvRLa6Mw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXg-00013n-7x; Mon, 13 May 2019 19:23:20 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXV-0000qI-1S for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:11 +0000 Received: by mail-lj1-x243.google.com with SMTP id a10so4095817ljf.6 for ; Mon, 13 May 2019 12:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PRL03ayf+3gKTw6ZyGNmbuvOXDVJf1omVj5w82VYj+c=; b=Znmj+Rap5uWxgIXFcTCRFXUCBeWlHqU14s7GfponHlIVTdIN7IzEc61HXMm4h5nMBl pijn+Gtm6cLPHDMK+OyeGhMq851kXOyT9eVvz5Eyww1m2u+MiAMZ1ZmxhMmNVVYT67kD mS34rNa0TU+vC/QIphSceYIH1L6a0ZvjhvREogDJycRMkS+Rs2TfV8eY8m+0ZbMStq5P dk5lfkFlLuy6i4z/FJSh7h6pWspZbXExojy+vKqzYVKfbdd54IxWPB6JsuTVRCSLt0ye MCtEkLESrZG/lkG0+OyQr8OvzGk5uYyHT8MItOwqjKlbO+fTi4c83DsDsSQhdL3amg2j JoKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PRL03ayf+3gKTw6ZyGNmbuvOXDVJf1omVj5w82VYj+c=; b=RpgeD5DAp7G2nit/wQPAr0ps60oHVh49H6l+J7zATqM5QW1n4ep3yi1zx2h4SFiuDQ qeZTpOHpYXJlUVpTwZzqkCWbYVHhuscQn8inCGaWZM7NCw2/6t6uYGzZvXEgROLXHIsQ 25EPbQwR49BCUCN/y+WstqX3/fkDKK7i18NeBH7Vq6x6r9eyopAoNdl2HjayIFE1wtmg TP14OiW6OgL0jzyqcJ0X3JAvTdP9Ylh3zaJv+MaeGqDVD7umxbC47GibG38HpFb2pQ5I QcHq3v2i6T3D8/6zo7uNK6iKMvtzsVWOf+TWdWweXmtyv9hdqDCNUErD6nKOztCVxpbc QlUw== X-Gm-Message-State: APjAAAX7yw+qmlWwLCbnadDd0biQlLLb5ckkGRwJJ0jqnMOoQQyGyYDn 1feEzN4qIqA2TiOPg1VdzrP8tQ== X-Google-Smtp-Source: APXvYqw+k+LeWintu25cglIZU1CDGNn5D+9RA2OiP0AoKwBrDnOS5hnqd/Xey6gfGS2F/GmEje2j4w== X-Received: by 2002:a2e:86c5:: with SMTP id n5mr14855773ljj.184.1557775387446; Mon, 13 May 2019 12:23:07 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:06 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 01/18] dt: psci: Update DT bindings to support hierarchical PSCI states Date: Mon, 13 May 2019 21:22:43 +0200 Message-Id: <20190513192300.653-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122309_243370_208FEF28 X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer Update DT bindings to represent hierarchical CPU and CPU PM domain idle states for PSCI. Also update the PSCI examples to clearly show how flattened and hierarchical idle states can be represented in DT. Signed-off-by: Lina Iyer Reviewed-by: Rob Herring Reviewed-by: Sudeep Holla Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes: - None. --- .../devicetree/bindings/arm/psci.txt | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/psci.txt b/Documentation/devicetree/bindings/arm/psci.txt index a2c4f1d52492..e6d3553c8df8 100644 --- a/Documentation/devicetree/bindings/arm/psci.txt +++ b/Documentation/devicetree/bindings/arm/psci.txt @@ -105,7 +105,173 @@ Case 3: PSCI v0.2 and PSCI v0.1. ... }; +ARM systems can have multiple cores sometimes in hierarchical arrangement. +This often, but not always, maps directly to the processor power topology of +the system. Individual nodes in a topology have their own specific power states +and can be better represented in DT hierarchically. + +For these cases, the definitions of the idle states for the CPUs and the CPU +topology, must conform to the domain idle state specification [3]. The domain +idle states themselves, must be compatible with the defined 'domain-idle-state' +binding [1], and also need to specify the arm,psci-suspend-param property for +each idle state. + +DT allows representing CPUs and CPU idle states in two different ways - + +The flattened model as given in Example 1, lists CPU's idle states followed by +the domain idle state that the CPUs may choose. Note that the idle states are +all compatible with "arm,idle-state". Additionally, for the domain idle state +the "arm,psci-suspend-param" represents a superset of the CPU's idle state. + +Example 2 represents the hierarchical model of CPUs and domain idle states. +CPUs define their domain provider in their psci DT node. The domain controls +the power to the CPU and possibly other h/w blocks that would enter an idle +state along with the CPU. The CPU's idle states may therefore be considered as +the domain's idle states and have the compatible "arm,idle-state". Such domains +may also be embedded within another domain that may represent common h/w blocks +between these CPUs. The idle states of the CPU topology shall be represented as +the domain's idle states. Note that for the domain idle state, the +"arm,psci-suspend-param" represents idle states hierarchically. + +In PSCI firmware v1.0, the OS-Initiated mode is introduced. However, the +flattened vs hierarchical DT representation is orthogonal to the OS-Initiated +vs the platform-coordinated PSCI CPU suspend modes, thus should be considered +independent of each other. + +The hierarchical representation helps and makes it easy to implement OSI mode +and OS implementations may choose to mandate it. For the default platform- +coordinated mode, both representations are viable options. + +Example 1: Flattened representation of CPU and domain idle states + cpus { + #address-cells = <1>; + #size-cells = <0>; + + CPU0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53", "arm,armv8"; + reg = <0x0>; + enable-method = "psci"; + cpu-idle-states = <&CPU_PWRDN>, <&CLUSTER_RET>, + <&CLUSTER_PWRDN>; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a57", "arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + cpu-idle-states = <&CPU_PWRDN>, <&CLUSTER_RET>, + <&CLUSTER_PWRDN>; + }; + + idle-states { + CPU_PWRDN: cpu-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x0000001>; + entry-latency-us = <10>; + exit-latency-us = <10>; + min-residency-us = <100>; + }; + + CLUSTER_RET: cluster-retention { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x1000011>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x1000031>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; + }; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +Example 2: Hierarchical representation of CPU and domain idle states + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + CPU0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53", "arm,armv8"; + reg = <0x0>; + enable-method = "psci"; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a57", "arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; + }; + + idle-states { + CPU_PWRDN: cpu-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x0000001>; + entry-latency-us = <10>; + exit-latency-us = <10>; + min-residency-us = <100>; + }; + + CLUSTER_RET: cluster-retention { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000010>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-power-down { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000030>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; + }; + }; + + psci { + compatible = "arm,psci-1.0"; + method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + domain-idle-states = <&CPU_PWRDN>; + power-domains = <&CLUSTER_PD>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + domain-idle-states = <&CPU_PWRDN>; + power-domains = <&CLUSTER_PD>; + }; + + CLUSTER_PD: cluster-pd { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_RET>, <&CLUSTER_PWRDN>; + }; + }; + [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/arm/idle-states.txt [2] Power State Coordination Interface (PSCI) specification http://infocenter.arm.com/help/topic/com.arm.doc.den0022c/DEN0022C_Power_State_Coordination_Interface.pdf +[3]. PM Domains description + Documentation/devicetree/bindings/power/power_domain.txt From patchwork Mon May 13 19:22:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50B4A1398 for ; Mon, 13 May 2019 19:23:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EFE9283B0 for ; Mon, 13 May 2019 19:23:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 333A628421; Mon, 13 May 2019 19:23:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B4037283B0 for ; Mon, 13 May 2019 19:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=sFJbzTcj8mIsTtOZ0AsHLcEAxjNpIwIEtI4ty1sVK9g=; b=dsZjmpc93ANXKvy3/divlwX7Cv S8TbJuZ2maqM2sDmjnj2GRKgR+9vP+Ly/4qeIz5/dYvjnT35929/vUPXDR4LLyA9diXZGVPisPRA7 8aAdNe0W9XRpEJ5t4zoyL6PLi3UChrV7b3UGfgaeoTZKjE1w1V46YcSV8qp1NG164Tdva+/wdeCnW gWhs74/GeID1hmC8I34TT677ZJen8NH5fKTqCMEBqGyQNEc6ufsvQ5tkJs38YR4Uf7Y3xX9BhgiVe 4YfvOTcELEwvfol1vBHfLLP+93iJkhdOmvRcIFIdaFB3u1JFgYpvIsxy6rkPQwPQnR7r+L8AzMRpD ljC8Ndeg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXr-0001H3-PW; Mon, 13 May 2019 19:23:31 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXX-0000qt-9t for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:14 +0000 Received: by mail-lf1-x144.google.com with SMTP id y10so9946999lfl.3 for ; Mon, 13 May 2019 12:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y7css3ZNjj71s6qH3VZ02Gz19f8ZGlmnEuYgt6KvYro=; b=JQDERog4rov3X+DqEg2H7/3Odpqc2zC02GWbC2dA3cdRByYxi61kDxumi6NKwfVrRo MthcOUmpimuvOLKrvD0vrkrnD69QBrGcqvLE2ekX0Ag1GhHhK8CeFO3PPP/rY48StudY uvMfjdjZJgcj/HMAcKg56hIjoXHwqFwxeas8Q/zJXHNh/9VUNbu2dAIaiKo7Pc+MwALa 9SWhEPexpgP2e3ql1zXtp3jydNVwmcUGR79PdmwSfMGqrslIYLqcKywJk7qgkw396soe HPSSW/N9cuYmE47cwNMWq0RyVq2SCoJKdaaGjnwEZbeXCXeUlh1q2N/e+59FIltHYDFZ Milg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Y7css3ZNjj71s6qH3VZ02Gz19f8ZGlmnEuYgt6KvYro=; b=lFjD72qRmemY7UnWhpqokTWW7CK9rmlHoTEx+GgT6MBgkvN3m42/ChSGOUBnwqVk2M zATaaBIC88jzJ1v4GNhbRkW5cm6pRjHXR6Rc2okQt2y2NY4CAqsWmFxD4aXgd7Lp+hn9 8N3iZM/dIO0iIxCmHH3JpQAkRSrxOwsmQPsm0rYF6JUF6n/IVSzMgfPVEQToz1VnN+ID ZiuWgeT2mxEAokNLsiWqh+/v1IAEx9noFPfUxaVOa4t1CtsUJArzA2p4pkL67zwMGlbs yHjW2kjetCUwFe8lSQ3ChFbq3h4GrN7/7guptc5paBbea6WR9SfapIsxOk5oYLm04g7n p57A== X-Gm-Message-State: APjAAAUajK6SilQ4lows6xUs/GYlTewB/1Np/5+CcacYul6v+DTfL1wF CqojoVMB88rIS1Q11JmL+uGWiA== X-Google-Smtp-Source: APXvYqwTyaAA0SKlYfwt/EkTngvPeOt4VBe6xlPqr7JTEF8fvJF80/c14TQZyy9mXnggagGHR0SUYw== X-Received: by 2002:ac2:457a:: with SMTP id k26mr14042867lfm.161.1557775389309; Mon, 13 May 2019 12:23:09 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:08 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/18] of: base: Add of_get_cpu_state_node() to get idle states for a CPU node Date: Mon, 13 May 2019 21:22:44 +0200 Message-Id: <20190513192300.653-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122311_590589_BDB71E1F X-CRM114-Status: GOOD ( 20.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The CPU's idle state nodes are currently parsed at the common cpuidle DT library, but also when initializing back-end data for the arch specific CPU operations, as in the PSCI driver case. To avoid open-coding, let's introduce of_get_cpu_state_node(), which takes the device node for the CPU and the index to the requested idle state node, as in-parameters. In case a corresponding idle state node is found, it returns the node with the refcount incremented for it, else it returns NULL. Moreover, for ARM, there are two generic methods, to describe the CPU's idle states, either via the flattened description through the "cpu-idle-states" binding [1] or via the hierarchical layout, using the "power-domains" and the "domain-idle-states" bindings [2]. Hence, let's take both options into account. [1] Documentation/devicetree/bindings/arm/idle-states.txt [2] Documentation/devicetree/bindings/arm/psci.txt Suggested-by: Sudeep Holla Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Reviewed-by: Rob Herring Reviewed-by: Daniel Lezcano Signed-off-by: Ulf Hansson --- Changes: - Fixed some kernel docs typos. - Fall-back to use "cpu-idle-states" when "power-domains" is present but "domain-idle-states" is missing. --- drivers/of/base.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/of.h | 8 ++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 20e0e7ee4edf..05866f0c65b4 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -477,6 +477,42 @@ int of_cpu_node_to_id(struct device_node *cpu_node) } EXPORT_SYMBOL(of_cpu_node_to_id); +/** + * of_get_cpu_state_node - Get CPU's idle state node at the given index + * + * @cpu_node: The device node for the CPU + * @index: The index in the list of the idle states + * + * Two generic methods can be used to describe a CPU's idle states, either via + * a flattened description through the "cpu-idle-states" binding or via the + * hierarchical layout, using the "power-domains" and the "domain-idle-states" + * bindings. This function check for both and returns the idle state node for + * the requested index. + * + * In case an idle state node is found at @index, the refcount is incremented + * for it, so call of_node_put() on it when done. Returns NULL if not found. + */ +struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index) +{ + struct of_phandle_args args; + int err; + + err = of_parse_phandle_with_args(cpu_node, "power-domains", + "#power-domain-cells", 0, &args); + if (!err) { + struct device_node *state_node = + of_parse_phandle(args.np, "domain-idle-states", index); + + of_node_put(args.np); + if (state_node) + return state_node; + } + + return of_parse_phandle(cpu_node, "cpu-idle-states", index); +} +EXPORT_SYMBOL(of_get_cpu_state_node); + /** * __of_device_is_compatible() - Check if the node matches given constraints * @device: pointer to node diff --git a/include/linux/of.h b/include/linux/of.h index 0cf857012f11..6ae5c2c4b104 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -351,6 +351,8 @@ extern const void *of_get_property(const struct device_node *node, int *lenp); extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); extern struct device_node *of_get_next_cpu_node(struct device_node *prev); +extern struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index); #define for_each_property_of_node(dn, pp) \ for (pp = dn->properties; pp != NULL; pp = pp->next) @@ -765,6 +767,12 @@ static inline struct device_node *of_get_next_cpu_node(struct device_node *prev) return NULL; } +static inline struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index) +{ + return NULL; +} + static inline int of_n_addr_cells(struct device_node *np) { return 0; From patchwork Mon May 13 19:22:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BBDD1398 for ; Mon, 13 May 2019 19:23:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 490FE2838F for ; Mon, 13 May 2019 19:23:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CA1F28415; Mon, 13 May 2019 19:23:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CFA992838F for ; Mon, 13 May 2019 19:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fJdmelHuNS+H60mzqEmLLRCJeX1DpDetpmtXjXtqvdE=; b=c/mVUmDpZg+fhlna4UhQoc0IUk dqvbjy1KKPskaBbIVsl3aU02VpbmXLj9oLXBtJ1F+Q6koAy4zBk4kRBzP05+2XRZO3sFURbCft2Si xFR2SisJSJi+lyMx1FMkj2rwr5RBE0siGizRAOER+FuC5llAfoyWP0npkIqzeOg+eTAvW/LtFL7lm Hxca8Nbyesv59kav35SOs4r+QxW5o9ss267emgTRMbSt/dekz43s6Dbkxa0oXH9ntvb2+ef15H9Hx IKfO7yms8sYtf0bQqLaerWHYug2fLrsPwL9e8ncbyoKskXDjg4UFtGm7BNgnA67mOErhr5nzwS6cz CwcLtBqQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGY1-0001WH-BF; Mon, 13 May 2019 19:23:41 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXY-0000s0-MP for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:16 +0000 Received: by mail-lj1-x243.google.com with SMTP id d15so12061788ljc.7 for ; Mon, 13 May 2019 12:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F5AEltUKfed5w7dHNisHSX8S1wBzU63rf2dZ2cHwfSs=; b=ihwtaKGHm5HWQDkvQkty6/m7be/aDE2Ue2EF8h2aUL7J5q3dbOjBQl/7riCd7391Bk 6mt4yavZncehbr1dqBkKzd5+XE6F5UVYInUI/aMbhArbPszaqyttf3MVOOEailuYdP3R fucpydZkU9Xe7taVXR0KfQZCmk+WPepu9Fz5czOMEkZzxq0cyv/O9xzdwPbelTwhxiAt AgLFcBQz4OuHsSIHPRYM79Mx2eXRaijBK738WDXPRnaM8wcxzwaXGNHAtjVqh3N6NVfn PALPweQK2a7Hw+qtF1599CtdwmhaZJP3Loxm6jMlG87c2/LPW1b4sxzN22fBdrGhOVkv xgGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F5AEltUKfed5w7dHNisHSX8S1wBzU63rf2dZ2cHwfSs=; b=kPyBRSi7vh2skwpTURkJtYF7dyAqc3IoiNYMRlLKFFbBxT0r7ANGn1ei6Q6bQJwiTE bMwqwbtrQkK1TmPbpCUQ6R7X51gg9ugZmjJaul/mYnrFpwlf/6elVGcZ/Zq1ifKh/1bM UtZ5wzl2hBdn8LAZJNnR68BxS8PWaGBg5zQGOiEZcHq5DUOng9I9tCZfBG3DnYDpMbxE FJK7xGddMDFqVRQBuq8vTkCIatdC5atIUsSiT+BbA8m2bT8zZD/f97YLWWoqnnYoDtiR DyAFz3UrEKp1W/36mrbTZIZ8HN/Cr4pEEAthdozXzB0hVGohXvuWJbvSyCTwGPsDiXXv zjAw== X-Gm-Message-State: APjAAAUWMt6NZNZAzaZeXPPlpyG0yJKAtc8Gu+xdhKUNwLEHFIB5jXOY EMYtvpdohFvOgyNxmzPkp1nUZA== X-Google-Smtp-Source: APXvYqxS293Cibnm8BvM4OA/7mePaZMMHGVjPn5T9aLCXEe34R5mqSI/nCjgK/Ib9ssZWuTZNP1Trw== X-Received: by 2002:a2e:c41:: with SMTP id o1mr8693546ljd.23.1557775391156; Mon, 13 May 2019 12:23:11 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:10 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 03/18] cpuidle: dt: Support hierarchical CPU idle states Date: Mon, 13 May 2019 21:22:45 +0200 Message-Id: <20190513192300.653-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122313_052499_7C7C04C7 X-CRM114-Status: GOOD ( 12.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer Currently CPU's idle states are represented in a flattened model, via the "cpu-idle-states" binding from within the CPU's device nodes. Support the hierarchical layout during parsing and validating of the CPU's idle states. This is simply done by calling the new OF helper, of_get_cpu_state_node(). Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer Reviewed-by: Daniel Lezcano Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes: - None. --- drivers/cpuidle/dt_idle_states.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c index add9569636b5..97ad25399ca8 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -114,8 +114,7 @@ static bool idle_state_valid(struct device_node *state_node, unsigned int idx, for (cpu = cpumask_next(cpumask_first(cpumask), cpumask); cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpumask)) { cpu_node = of_cpu_device_node_get(cpu); - curr_state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - idx); + curr_state_node = of_get_cpu_state_node(cpu_node, idx); if (state_node != curr_state_node) valid = false; @@ -173,7 +172,7 @@ int dt_init_idle_driver(struct cpuidle_driver *drv, cpu_node = of_cpu_device_node_get(cpumask_first(cpumask)); for (i = 0; ; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_get_cpu_state_node(cpu_node, i); if (!state_node) break; From patchwork Mon May 13 19:22:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 499231395 for ; Mon, 13 May 2019 19:24:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36E962838F for ; Mon, 13 May 2019 19:24:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AC50283C9; Mon, 13 May 2019 19:24:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 590E92838F for ; Mon, 13 May 2019 19:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hn5OcUaMvvDc7qfF8RqLvHyfRF+473W6uXoZa8NwwW8=; b=MIfpk7qA2Bg3WoTbdrK0aMtPnq ZuAxM/mHeESzx4wU41qKnZW2YGkXm5kvuSS7POANaSUiwpbK04CsTXtL/sIDLmWffl3bzGS/OyI3/ dT/5enx/wQxsqfomIKuVLkI0lkJO3AM6rAQ2cE9dw4P5W/8L/SKiGIWiFIp8b2CQZ5xgEMtysIsbs Bq98eXC6JaS8IL3QqoEZUC5QMMDlklAz/ifB9+XpxldAq5s7ZP0nZo9LKtDuQkuI4OIrTxXgDwPwn SDBfjolOW2wHHRrj1bkOX6u5I7C4998fuqL9QtOsU2rJGS5jr9zb12uj/PXOMXMa+CGhooXfYwnRJ jkJTKLWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGYL-0001tG-7X; Mon, 13 May 2019 19:24:01 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXb-0000vV-BT for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:19 +0000 Received: by mail-lf1-x141.google.com with SMTP id d8so9912587lfb.8 for ; Mon, 13 May 2019 12:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HHIW4beg1Jo/n8yn03ZEmR2mqH0MtY+zTbuMOhYgiNI=; b=anVw6Y6EzHqSNxrL6pGJpo0scx6tqJdSTeUKkDH1VoRuqz97rmscnr3deHcKsbcTF9 KBUeSJS+GoswseXScGGlJTy0SXat8ZH2YEchgAhGyniX/PXerb1jLyWkPb9fOUxfu0Lw IUL2YhhLknbWKObj+AdmWeg4lbExhFib0lAuxr50jWg5yFgGkT0hrzvCnBhiv+cBPeZP 2EMMNN28h8myMwiax1VcJt7Y/V2t3O/wZnNuc61AwrUov8LMgRP4C601bVL3eyn/P31r R81H8S2BAi5piWYLe8XXYPuZgg59NszI1sA3l2CVOpIAXy6JNGqLYmyGqsFRZ5tCJK6G StRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HHIW4beg1Jo/n8yn03ZEmR2mqH0MtY+zTbuMOhYgiNI=; b=EQ982Q0+eGWkTWc8u3S36/glwEEd/q7P3oyW/fF45UPlJxMnGlBiP7+5s+PBopZxBS oTC5dOfFubLJvEp6nrU6RusgPyWNoSGh9MgLu6OdN+LOPbD/3vwrnV14GIGlQiXHtxvV eoYNC8YdeFK/kXljQ99FQ2I+XTAifySx+9r6ssJAm4kHML9ajI/BwbUEbC0ROznwpT3G WhSVefVs3e75lceQBDXH4MDwquOnDmoZlbK1t0ALLpxDGgJzUc8ixMy+fXR0PQLo42VB 8K/I8bL8xguzLujZBb1FldG4kAN8sgANzwttILqqqAsFNEoSjOOYRcB9I4jdQx90Auy4 BHqw== X-Gm-Message-State: APjAAAVQnCzcISTtYU6uMMYQXNydwYYRLGt7vqmmWlS0UeR+Z7Zr9lfD aTQOVgo0Weta2aFurnVMFssurQ== X-Google-Smtp-Source: APXvYqxRt2bTvjgwV68tXj3LgqrAAbaA1jPCgVPYT0nHrhupILypGycEOanmCUjC0XjwqBqYOWLpQg== X-Received: by 2002:ac2:593a:: with SMTP id v26mr14391804lfi.64.1557775393399; Mon, 13 May 2019 12:23:13 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:12 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 04/18] ARM/ARM64: cpuidle: Let back-end init ops take the driver as input Date: Mon, 13 May 2019 21:22:46 +0200 Message-Id: <20190513192300.653-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122315_639760_BC9DA4D7 X-CRM114-Status: GOOD ( 23.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Geert Uytterhoeven , Tony Lindgren , Viresh Kumar , Will Deacon , Bjorn Andersson , David Brown , Lina Iyer , Vincent Guittot , Kevin Hilman , Daniel Lezcano , Russell King , Catalin Marinas , Andy Gross , "Raju P . L . S . S . S . N" , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stephen Boyd , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Niklas Cassel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To allow arch back-end init ops to operate on the cpuidle driver for the corresponding CPU, let's pass along a pointer to the struct cpuidle_driver* and forward it the relevant layers of callbacks for ARM/ARM64. Following changes for the PSCI firmware driver starts making use of this. Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: David Brown Signed-off-by: Ulf Hansson Acked-by: Daniel Lezcano --- Changes: - None. Note: - This patch is needed by the subsequent patch, but more importantly, also by "[PATCH 10/18] drivers: firmware: psci: Add hierarchical domain idle states converter". --- arch/arm/include/asm/cpuidle.h | 4 ++-- arch/arm/kernel/cpuidle.c | 5 +++-- arch/arm64/include/asm/cpu_ops.h | 4 +++- arch/arm64/include/asm/cpuidle.h | 6 ++++-- arch/arm64/kernel/cpuidle.c | 6 +++--- drivers/cpuidle/cpuidle-arm.c | 2 +- drivers/firmware/psci/psci.c | 7 ++++--- drivers/soc/qcom/spm.c | 3 ++- include/linux/psci.h | 4 +++- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h index 6b2ff7243b4b..bee0a7847733 100644 --- a/arch/arm/include/asm/cpuidle.h +++ b/arch/arm/include/asm/cpuidle.h @@ -32,7 +32,7 @@ struct device_node; struct cpuidle_ops { int (*suspend)(unsigned long arg); - int (*init)(struct device_node *, int cpu); + int (*init)(struct cpuidle_driver *, struct device_node *, int cpu); }; struct of_cpuidle_method { @@ -47,6 +47,6 @@ struct of_cpuidle_method { extern int arm_cpuidle_suspend(int index); -extern int arm_cpuidle_init(int cpu); +extern int arm_cpuidle_init(struct cpuidle_driver *drv, int cpu); #endif diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c index fda5579123a8..43778c9b373d 100644 --- a/arch/arm/kernel/cpuidle.c +++ b/arch/arm/kernel/cpuidle.c @@ -122,6 +122,7 @@ static int __init arm_cpuidle_read_ops(struct device_node *dn, int cpu) /** * arm_cpuidle_init() - Initialize cpuidle_ops for a specific cpu + * @drv: the drv to be initialized * @cpu: the cpu to be initialized * * Initialize the cpuidle ops with the device for the cpu and then call @@ -137,7 +138,7 @@ static int __init arm_cpuidle_read_ops(struct device_node *dn, int cpu) * -ENXIO if the HW reports a failure or a misconfiguration, * -ENOMEM if the HW report an memory allocation failure */ -int __init arm_cpuidle_init(int cpu) +int __init arm_cpuidle_init(struct cpuidle_driver *drv, int cpu) { struct device_node *cpu_node = of_cpu_device_node_get(cpu); int ret; @@ -147,7 +148,7 @@ int __init arm_cpuidle_init(int cpu) ret = arm_cpuidle_read_ops(cpu_node, cpu); if (!ret) - ret = cpuidle_ops[cpu].init(cpu_node, cpu); + ret = cpuidle_ops[cpu].init(drv, cpu_node, cpu); of_node_put(cpu_node); diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index 8f03446cf89f..8db870c29f1b 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -19,6 +19,8 @@ #include #include +struct cpuidle_driver; + /** * struct cpu_operations - Callback operations for hotplugging CPUs. * @@ -58,7 +60,7 @@ struct cpu_operations { int (*cpu_kill)(unsigned int cpu); #endif #ifdef CONFIG_CPU_IDLE - int (*cpu_init_idle)(unsigned int); + int (*cpu_init_idle)(struct cpuidle_driver *, unsigned int); int (*cpu_suspend)(unsigned long); #endif }; diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h index 3c5ddb429ea2..3fd3efb61649 100644 --- a/arch/arm64/include/asm/cpuidle.h +++ b/arch/arm64/include/asm/cpuidle.h @@ -4,11 +4,13 @@ #include +struct cpuidle_driver; + #ifdef CONFIG_CPU_IDLE -extern int arm_cpuidle_init(unsigned int cpu); +extern int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu); extern int arm_cpuidle_suspend(int index); #else -static inline int arm_cpuidle_init(unsigned int cpu) +static inline int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu) { return -EOPNOTSUPP; } diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c index f2d13810daa8..aaf9dc5cb87a 100644 --- a/arch/arm64/kernel/cpuidle.c +++ b/arch/arm64/kernel/cpuidle.c @@ -18,13 +18,13 @@ #include #include -int arm_cpuidle_init(unsigned int cpu) +int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu) { int ret = -EOPNOTSUPP; if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_suspend && cpu_ops[cpu]->cpu_init_idle) - ret = cpu_ops[cpu]->cpu_init_idle(cpu); + ret = cpu_ops[cpu]->cpu_init_idle(drv, cpu); return ret; } @@ -51,7 +51,7 @@ int arm_cpuidle_suspend(int index) int acpi_processor_ffh_lpi_probe(unsigned int cpu) { - return arm_cpuidle_init(cpu); + return arm_cpuidle_init(NULL, cpu); } int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi) diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 3a407a3ef22b..39413973b21d 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -106,7 +106,7 @@ static int __init arm_idle_init_cpu(int cpu) * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ - ret = arm_cpuidle_init(cpu); + ret = arm_cpuidle_init(drv, cpu); /* * Allow the initialization to continue for other CPUs, if the reported diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index fe090ef43d28..88e90e0f06b9 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -303,7 +303,8 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } -static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) +static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, + struct device_node *cpu_node, int cpu) { int i, ret = 0, count = 0; u32 *psci_states; @@ -391,7 +392,7 @@ static int __maybe_unused psci_acpi_cpu_init_idle(unsigned int cpu) } #endif -int psci_cpu_init_idle(unsigned int cpu) +int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu) { struct device_node *cpu_node; int ret; @@ -410,7 +411,7 @@ int psci_cpu_init_idle(unsigned int cpu) if (!cpu_node) return -ENODEV; - ret = psci_dt_cpu_init_idle(cpu_node, cpu); + ret = psci_dt_cpu_init_idle(drv, cpu_node, cpu); of_node_put(cpu_node); diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c index 53807e839664..6e967f0a8608 100644 --- a/drivers/soc/qcom/spm.c +++ b/drivers/soc/qcom/spm.c @@ -208,7 +208,8 @@ static const struct of_device_id qcom_idle_state_match[] __initconst = { { }, }; -static int __init qcom_cpuidle_init(struct device_node *cpu_node, int cpu) +static int __init qcom_cpuidle_init(struct cpuidle_driver *drv, + struct device_node *cpu_node, int cpu) { const struct of_device_id *match_id; struct device_node *state_node; diff --git a/include/linux/psci.h b/include/linux/psci.h index 8b1b3b5935ab..4f29a3bff379 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -20,9 +20,11 @@ #define PSCI_POWER_STATE_TYPE_STANDBY 0 #define PSCI_POWER_STATE_TYPE_POWER_DOWN 1 +struct cpuidle_driver; + bool psci_tos_resident_on(int cpu); -int psci_cpu_init_idle(unsigned int cpu); +int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu); int psci_cpu_suspend_enter(unsigned long index); enum psci_conduit { From patchwork Mon May 13 19:22:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B8841398 for ; Mon, 13 May 2019 19:24:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B648283C9 for ; Mon, 13 May 2019 19:24:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F61728421; Mon, 13 May 2019 19:24:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC1C8283B0 for ; Mon, 13 May 2019 19:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xJCcoDoNGu218edz5jZ2BmOqWqmnQ8ght1LbbY2Lh3k=; b=DXbOsxqIzBPf25L2ku1BugN1nT srfXkXT0tSZdpCakaJqSZ2LNW4AQg3SUq5Jwy17K1ndv28zQUbm196u5TTLDhdAZawfceHw1C+t8g P+7Azm3FQgAux/nzQxoIEL/hWCU9A7J+/khsTNyZq2Smahe1ersWANOiu5TAwqxobW9d3y1hwmIy4 eUOiofyJIegRxJsml+79/s0hMlBe/L0h+ysgCgWLFEgxbzsy7/Ve9huJYlAec5rc9tNVSFMQ76Rrw 9zoEzUwThyOHawol3877GSa23NOPfrL+1Mt0z/BHydVbxxoDAWNRd/5v+/h6aJVb35IJPwi0QYXue VEtv4fkg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGYf-0002MB-BN; Mon, 13 May 2019 19:24:21 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXd-0000xh-75 for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:19 +0000 Received: by mail-lj1-x241.google.com with SMTP id 14so12078190ljj.5 for ; Mon, 13 May 2019 12:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h+mBrphGE8r6kKGvHPN2hwwjlulIBItsLgwHs6HK8tw=; b=z1qwoOxfxP8ws6K0eXeqsi0M8rg4AiA8aC+/rjIVQbuJPoKSAquEg4iySw4L3cN5x8 jjlTDZuSJciHj+R09dPL+gALzrtUwcXOVPCSnr1zV5JjUxXC+jTH/bs1uFkycg9wYG8L 3ilSYwaJ4Q/40soKA1mrFGCJYk6E1a5pkxpihVokTsS7TPrP5nTxTdm7Jw+QAnCFWTxO uSmb50ZRpi0pFqGue364kuAdvMUhtO582nHQ8c2OptpkJde/IrOfk1AUVO3SIIewRV7N vt3h/dJVN+5qmhzobmOPYqBY1Id026c5O41E9qZf/leKI1FYytDGLpKNJm1MNCm4XpMm 8yxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h+mBrphGE8r6kKGvHPN2hwwjlulIBItsLgwHs6HK8tw=; b=PWVs+mTc9rqsmrOiXtCul/TP6BFIhcKXOXjZm95VI7bo7jVZT9ouSLG6dJPEqfnntV TpondbPc/s5pMA4nJrlCS2Ygl47KrVbE8339iOTPfluKjFAZTHRaXFwARPuHdeEXsjEj +HFMTOcA6JvGC+Vt3swCggnrqbAVrh47q0PfY01zmLBVOK5s1zTsU0gkszj8IncVUD5J n9Vk9znpEfK9eVq229bNP1xHqtFuBSEGVgNqgUfsS1BOVsou5WYKba2QEng4aWqPx46i yuXbfqvrmHu43zvXwbnG08f/l+AezxEmszrPRtd2WKtW4xevjGAfGAvgVWF2AXwf+2pF qggA== X-Gm-Message-State: APjAAAVldSdyCh9vifS0aXph80yLWpk2LxvEDRzW2IOF6zs08MtdZ/3r r5hjSBF5Maf1owbb3idr6/YBzg== X-Google-Smtp-Source: APXvYqyeVfJKdGokU/doivXzmlRxtYYG8D4KXKrSzXVVKA9wCQvIkwAm3xVkfpldRQZcHwdKpXbyIA== X-Received: by 2002:a2e:9241:: with SMTP id v1mr14737256ljg.6.1557775395160; Mon, 13 May 2019 12:23:15 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:14 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 05/18] drivers: firmware: psci: Simplify state node parsing Date: Mon, 13 May 2019 21:22:47 +0200 Message-Id: <20190513192300.653-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122317_425293_03C42913 X-CRM114-Status: GOOD ( 16.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of iterating through all the state nodes in DT, to find out how many states that needs to be allocated, let's use the number already known by the cpuidle driver. In this way we can drop the iteration altogether. Signed-off-by: Ulf Hansson Acked-by: Daniel Lezcano --- Changes: - None. --- drivers/firmware/psci/psci.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 88e90e0f06b9..9c2180bcee4c 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -306,26 +306,20 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state) static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, int cpu) { - int i, ret = 0, count = 0; + int i, ret = 0, num_state_nodes = drv->state_count - 1; u32 *psci_states; struct device_node *state_node; - /* Count idle states */ - while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - count))) { - count++; - of_node_put(state_node); - } - - if (!count) - return -ENODEV; - - psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL); + psci_states = kcalloc(num_state_nodes, sizeof(*psci_states), + GFP_KERNEL); if (!psci_states) return -ENOMEM; - for (i = 0; i < count; i++) { + for (i = 0; i < num_state_nodes; i++) { state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + if (!state_node) + break; + ret = psci_dt_parse_state_node(state_node, &psci_states[i]); of_node_put(state_node); @@ -335,6 +329,11 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); } + if (i != num_state_nodes) { + ret = -ENODEV; + goto free_mem; + } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0; From patchwork Mon May 13 19:22:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86DE71395 for ; Mon, 13 May 2019 19:24:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76F24283B0 for ; Mon, 13 May 2019 19:24:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ABEE2841D; Mon, 13 May 2019 19:24:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F37F228415 for ; Mon, 13 May 2019 19:24:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=feym2BX+0M5RSmafRRS6QsOLeplu/SeakXdfGEjy8d8=; b=sckS0KISESs9E2xWLmw2XLwOFL EEkJylOzWo62mzmXFgKK+sR/RYuX09XgNLbt9/mhBuiKgtPcqM2oDUnE/MkoMllDQPKgPRT3MbL6i 7Dlg1Eg/uV0mueuUeHRSLCFvFYcr2xaHP6s1WFOwXDuK/8VXZInTjAYEylPSpr/vw2N3jtc4cd1Yt 2DF+C7nCO1q+Jm+4Wv0HoEYS36acb3O6gpr3KjtiTNrm1CYLbHroKBF5Ks6X+58ZVvyMXXkrhHYAM B/0jTThT/t8Zyzfq7ceB+yH9dc7MBQMioATCTc96c+jqmy6rxJMu0zZ7L134wRO/yXIWDzeotTbGI QbcVi/eA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGYV-000236-E6; Mon, 13 May 2019 19:24:11 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXf-00010l-03 for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:21 +0000 Received: by mail-lj1-x244.google.com with SMTP id w1so9505922ljw.0 for ; Mon, 13 May 2019 12:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Nbt/R0uZX9P8HTLZOOX7O4bQjSSh3KmuxEw/gJfnJ0w=; b=c9ATK+kF7r7EPNbGkGdt7Bm63ADC4YHAW78L6XgGCewkxmYTEtG+L0LG2PjuZOY9P6 GIc/wvpLNy0UH3lkOe6ZFzROaxSq6yzGyHcvnwD2CRd7HZc2KPc2eU2Qqjw/+V6Y/odG 8g1QUs5Jnsr58ljysRy+9dUb1w4F/dykHejwWNEfEpnjahvDUevoLs2Q6KSLe41qv/kt 0zP1wQEuDypoCPrKTbmlS2icrt04INJA7iFSJ5TpXPM+7IfemYXsH5ks1f1TIKzK3DDH bHfdYw7ILT8JPAFLDWe6W30v1tHH6XaC6WnzwDnPcwbc/4E0bjVz5MHKP4astQUCxbqu Hwvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Nbt/R0uZX9P8HTLZOOX7O4bQjSSh3KmuxEw/gJfnJ0w=; b=jOhFy2PdSzQS7lZ4KJCriS+G+zlqEw018iVbYScdXrRPut354nULD0meNiVcHMqBkk 4zKwKUox5bn2Lq5icJc7hrRZoXBU9hfnCa0dI3YcHY3K/LDA/76YBrgRBE+Ccp+cdhml PQTOqmRrw9qrVCIMvtf0dkqUciyyHZcBXJyhaad6cnqCnm7Rl+Lfey+62gRESS7lWZ+S DRV2GpCof4ppOTNOY8KRtPb4Fj7QsvCS8QWWbyX6YMdWTXD1m9WZJgylK5C22hiCnt21 jqZofxwKpGjP6NOnsJYdVQOp22SmOcZYMS6DH9R2ayAcbj5BYctYBq50gGSW6QKwIow6 GhYA== X-Gm-Message-State: APjAAAU6NZIm0+gHUEJ2WTXmIHzg1yNl8YBHFDLPogFOObtuZYv4N0wX 778uyFQYTNNpIXjHTT/XncLe6g== X-Google-Smtp-Source: APXvYqw/K4DSr+T5mHbidlXB09i9OsKjJE0jmVRY6GRi9vogaHyD5Mxz5/BfqSTiLW4LknGP/8Tf2g== X-Received: by 2002:a2e:1312:: with SMTP id 18mr4211531ljt.79.1557775397083; Mon, 13 May 2019 12:23:17 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:16 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 06/18] drivers: firmware: psci: Support hierarchical CPU idle states Date: Mon, 13 May 2019 21:22:48 +0200 Message-Id: <20190513192300.653-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122319_045430_E26F9F6B X-CRM114-Status: GOOD ( 13.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer Currently CPU's idle states are represented in a flattened model, via the "cpu-idle-states" binding from within the CPU's device nodes. Support the hierarchical layout, simply by converting to calling the new OF helper, of_get_cpu_state_node(). Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes: - None. --- drivers/firmware/psci/psci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 9c2180bcee4c..b11560f7c4b9 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -316,7 +316,7 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, return -ENOMEM; for (i = 0; i < num_state_nodes; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_get_cpu_state_node(cpu_node, i); if (!state_node) break; From patchwork Mon May 13 19:22:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B52251398 for ; Mon, 13 May 2019 19:24:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1944283B0 for ; Mon, 13 May 2019 19:24:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 918E428415; Mon, 13 May 2019 19:24:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,TVD_PH_BODY_ACCOUNTS_PRE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 24F95283B0 for ; Mon, 13 May 2019 19:24:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=C8LH10oQAFGapTMPurta41i2ant0Z8SOd7sBoNyJ1r4=; b=Z5MFLPFfUgxJdVgXJQEnpTtfGh T7idRprLkruG9MfmWK2imTweOeNLi6nPBqRMianMiM8Cd1w++kMVr0JdX6fwZGYBpJFZPfUHu3BeL tfdcZK/f++dCOcfQDq7VfLlKsXDjKWgtCWEf/P6oBc5/O0T7JWLlRt3WkLmqpPHA0qsliBWiBQD6+ hDQgNWojYXdhcpSLOoq3a3KG8130Di3MtMOjLLHSIg6X2a7t8yNax+ZnPnKoo80OSTmXgQS1fWJ8R 97MvHlZZblybcYaDJJslRpKlfmvJfNT8NXWtNwVGFU57qdVZaoa2XC9OCMOUTjnwvYOWzzKIX4RsD liKopbLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGYp-0002ZV-0s; Mon, 13 May 2019 19:24:31 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXg-000136-U7 for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:26 +0000 Received: by mail-lf1-x142.google.com with SMTP id l26so4284390lfh.13 for ; Mon, 13 May 2019 12:23:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=FV//hyoMnEuhzttuAwy+3IjGHtAXZchGsvSZSUyMAJmSDn6Qk/tkPJX+DlL6/5jYzf jjMWLRDOaqPCtvzv2sKC48W9o1aofdOROz4I4viJvVGZPZnvq+pyPn3BVrwCJB/hIPhj xoxPevY6gXOnHpj09x2OwoTmPkocCKVcE7Z93ckD9UyadrfNo3LJ7pOTKkOK+xuf6SLV Afnne5GeWsYyFeQRUOEE13gZvwjrLN5xx482cgJ/AFWRxxE3zyhRueMlyLJa7HIuxd+d tSoTPkin1gaqwGLGobS1zs6UV3QuJLhH0X8bHUVoBjRumtVozN5vQTbZ8hJpt19iAGq+ W/Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=AR97T2pynv2/E2qSuwL0kgEMnEqItRxT/hBslGA0kxwV9PuZZIEeaUE0snvSJTPLfr +yXCnblYjgZUB5Yv+wr0p/lDKl7CF3TXASjZlorKpa5fz9CN7troxsdbN53EKq70cagN N6MHQpi6m9z5kzJ5cQnSp9SvWWsMb0OPVL99PksvQSlagaceuHJtfOlp1IPPoDanErim CX/1Evk/uQT4ucpWhGxlKxgzzkI3G0o0C3Y8m9T/WG0BzNeH/7OnfddORAUnANKc/EVf iRMcLBWx2YdXOX+DAxUERx2qOgjlJZ6ZMRw7vQyH4n5Yye+Y75d1Sztx6DSOV2hTY8qG m9Rg== X-Gm-Message-State: APjAAAXYjnA2VPOFsqXTm0NSl5Kc6coC7qPeeMBW+bn5W7qpkqx0v65a rcPze6CYuubEjBnVoV1K7s1nZw== X-Google-Smtp-Source: APXvYqw2t+LdElc4Xj4e0QzMBJlLjpK3q+ffxnx73kmsSfuwHRWHbqmUdPJVxZsVxNzXZK8vAzoQbQ== X-Received: by 2002:a19:4a04:: with SMTP id x4mr14103234lfa.124.1557775398769; Mon, 13 May 2019 12:23:18 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:18 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 07/18] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Mon, 13 May 2019 21:22:49 +0200 Message-Id: <20190513192300.653-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122321_448766_45D8E227 X-CRM114-Status: GOOD ( 18.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The per CPU variable psci_power_state, contains an array of fixed values, which reflects the corresponding arm,psci-suspend-param parsed from DT, for each of the available CPU idle states. This isn't sufficient when using the hierarchical CPU topology in DT in combination with having PSCI OS initiated (OSI) mode enabled. More precisely, in OSI mode, Linux is responsible of telling the PSCI FW what idle state the cluster (a group of CPUs) should enter, while in PSCI Platform Coordinated (PC) mode, each CPU independently votes for an idle state of the cluster. For this reason, let's introduce an additional per CPU variable called domain_state and implement two helper functions to read/write its values. Following patches, which implements PM domain support for PSCI, will use the domain_state variable and set it to corresponding bits that represents the selected idle state for the cluster. Finally, in psci_cpu_suspend_enter() and psci_suspend_finisher(), let's take into account the values in the domain_state, as to get the complete suspend parameter. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - Clarify changelog. - Drop changes in psci_cpu_on() as it belongs in the patch for hotplug. - Move some code inside "#ifdef CONFIG_CPU_IDLE". --- drivers/firmware/psci/psci.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index b11560f7c4b9..4aec513136e4 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -285,6 +285,17 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +static DEFINE_PER_CPU(u32, domain_state); + +static inline u32 psci_get_domain_state(void) +{ + return __this_cpu_read(domain_state); +} + +static inline void psci_set_domain_state(u32 state) +{ + __this_cpu_write(domain_state, state); +} static int psci_dt_parse_state_node(struct device_node *np, u32 *state) { @@ -420,15 +431,17 @@ int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu) static int psci_suspend_finisher(unsigned long index) { u32 *state = __this_cpu_read(psci_power_state); + u32 composite_state = state[index - 1] | psci_get_domain_state(); - return psci_ops.cpu_suspend(state[index - 1], - __pa_symbol(cpu_resume)); + return psci_ops.cpu_suspend(composite_state, __pa_symbol(cpu_resume)); } int psci_cpu_suspend_enter(unsigned long index) { int ret; u32 *state = __this_cpu_read(psci_power_state); + u32 composite_state = state[index - 1] | psci_get_domain_state(); + /* * idle state index 0 corresponds to wfi, should never be called * from the cpu_suspend operations @@ -436,11 +449,14 @@ int psci_cpu_suspend_enter(unsigned long index) if (WARN_ON_ONCE(!index)) return -EINVAL; - if (!psci_power_state_loses_context(state[index - 1])) - ret = psci_ops.cpu_suspend(state[index - 1], 0); + if (!psci_power_state_loses_context(composite_state)) + ret = psci_ops.cpu_suspend(composite_state, 0); else ret = cpu_suspend(index, psci_suspend_finisher); + /* Clear the domain state to start fresh when back from idle. */ + psci_set_domain_state(0); + return ret; } From patchwork Mon May 13 19:22:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B0A611395 for ; Mon, 13 May 2019 19:24:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D348283B0 for ; Mon, 13 May 2019 19:24:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F19B28415; Mon, 13 May 2019 19:24:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E8DD1283B0 for ; Mon, 13 May 2019 19:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=u/h2PulhPqZfo2ntr7vCtkaHi4HecknvlKAMwaRAHlg=; b=FmT9NxAeUFGl9oBuHwSu8dgUiN S0m+IX6OKo9FjKtAOjwoo2CpTIYizKuCIkupwMm3aAv5Qw/aDUOlvqsznRxGROWnXtguJxq1GExRe UKzCJ+tRlRCQqd6hLufPnhRMqILxp1PUFcUrcCvh6n/3X5YEvish/AA/Dj8P4ZImWY7lHqqg6VYKS MvI6ntBJRM7AhUeGX2TcdNRdRSeUV88ELA4c5kC7+kYH91SKcPO8gmj/ObCC1ZAbATtwZNaeuT4wO OSaw3TeTHNJYH6Ul8jySF5GTuB8wDfvNlnwdl28TT/Fx3q6ETotFYuq5tsZ7/JzkmBC4RFY0nlwD5 AYl1vQaA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGZ0-0002oy-P1; Mon, 13 May 2019 19:24:42 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXi-00015a-DU for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:30 +0000 Received: by mail-lj1-x244.google.com with SMTP id k8so12054142lja.8 for ; Mon, 13 May 2019 12:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tL+sK5pEBsAoCFopnPPwt4es9T7EwxPGgYEkm8O7IBI=; b=PleXZ03XqpXkNBmDfAycSfGQdOAnwKcgjPE/yvddT6ahyVQYQIimbvzlM0ZT24i2e5 LUFZWo+Tdttrv0PhN9+zyZsiyAIl0piyFql/WuOFoJwf6rT/ApfowwA2yVJk5ycqSnHJ tVjZQ/8bSIufYfq7D+pcmCxP7awzaUFp1ndubavu4Rg3LGgEgIDKhT1v5im0eJXErzwM yeE7sM0FGOsZqtCWMwGXPx4qW6dtJwALcEcJrbDFKC6sEY00Uvvm8/vcCf8KVozLm45m GNwRj8IB28P/Qgq9gd8i2bHXXGget+HBMR2KuUq4pUtz49trTZoVO+c/X53DLD2flOHv U9zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tL+sK5pEBsAoCFopnPPwt4es9T7EwxPGgYEkm8O7IBI=; b=GdsKHvlIYtORrftUTGOKT6QWybpetlNAo5hyHCWtnRWPEPSd8ZICe1RQyTBRDrY79w qZIbHYJuDERzqtHP0BgGi9UY0R5o/mv2qjnUJq6rKUfSIPh5GKqdKVkMSA3Yvhejt39K nWu0B+LGkhnqoAnGMpdMeLyYq4aXhYiKL+VQBZiwJ70+O8WCoNYIcqOJjoYgT+9Or7kg RzJ4L8AKXIDIaQfRm9fGsFLQn23U6Vy6d2rJLK8zN9Zj6a12pL2cgDVEKIMWyhB/86cN mongG1Nh4gxzn2B5rMc83xKGPzzh3Xig321B4B69BfeVQAWZEcGjZFJ0qnp+3Zhf1Ziz a5BA== X-Gm-Message-State: APjAAAWdh4xJ9wqVxM7u7vGB3oHPbYqt2j3UYZ5fFQdGJswocyros1Jz 8laA1GYDGbAIP/qgUU7v5GmfTg== X-Google-Smtp-Source: APXvYqx4whMnRpTm4m80h2xmvQbwZJE+FnBv/f7E0p3WgnHRPkfQ9mN1Bj/AUSzvNa+UTmcvCbPkvw== X-Received: by 2002:a2e:81cf:: with SMTP id s15mr14626643ljg.193.1557775400776; Mon, 13 May 2019 12:23:20 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:19 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/18] drivers: firmware: psci: Prepare to support PM domains Date: Mon, 13 May 2019 21:22:50 +0200 Message-Id: <20190513192300.653-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122323_215015_F41A7553 X-CRM114-Status: GOOD ( 16.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Subsequent changes implements support for PM domains to PSCI. Those changes are mainly implemented in a new separate c-file, hence a couple of the internal PSCI functions needs to be shared to be accessible. Let's do that via adding a new PSCI header file. Moreover, to implement support for PM domains, switching the PSCI FW into the OS initiated mode is sometimes needed. Therefore, let's share a new function that implement this. Signed-off-by: Ulf Hansson --- Changes: - Convert psci_set_osi_mode() to return an int. - Don't share psci_get_domain_state() as that's no longer needed. - Update changelog. --- drivers/firmware/psci/psci.c | 17 ++++++++++++++--- drivers/firmware/psci/psci.h | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 drivers/firmware/psci/psci.h diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 4aec513136e4..0e91d864e346 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -34,6 +34,8 @@ #include #include +#include "psci.h" + /* * While a 64-bit OS can make calls with SMC32 calling conventions, for some * calls it is necessary to use SMC64 to pass or return 64-bit values. @@ -96,7 +98,7 @@ static inline bool psci_has_ext_power_state(void) PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; } -static inline bool psci_has_osi_support(void) +bool psci_has_osi_support(void) { return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; } @@ -161,6 +163,15 @@ static u32 psci_get_version(void) return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); } +int psci_set_osi_mode(void) +{ + int err; + + err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + return psci_to_linux_errno(err); +} + static int psci_cpu_suspend(u32 state, unsigned long entry_point) { int err; @@ -292,12 +303,12 @@ static inline u32 psci_get_domain_state(void) return __this_cpu_read(domain_state); } -static inline void psci_set_domain_state(u32 state) +void psci_set_domain_state(u32 state) { __this_cpu_write(domain_state, state); } -static int psci_dt_parse_state_node(struct device_node *np, u32 *state) +int psci_dt_parse_state_node(struct device_node *np, u32 *state) { int err = of_property_read_u32(np, "arm,psci-suspend-param", state); diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h new file mode 100644 index 000000000000..f2277c3ad405 --- /dev/null +++ b/drivers/firmware/psci/psci.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PSCI_H +#define __PSCI_H + +struct device_node; + +int psci_set_osi_mode(void); +bool psci_has_osi_support(void); + +#ifdef CONFIG_CPU_IDLE +void psci_set_domain_state(u32 state); +int psci_dt_parse_state_node(struct device_node *np, u32 *state); +#endif + +#endif /* __PSCI_H */ From patchwork Mon May 13 19:22:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DEAC1395 for ; Mon, 13 May 2019 19:25:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B48127F94 for ; Mon, 13 May 2019 19:25:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F14E72841D; Mon, 13 May 2019 19:24:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1506C27F94 for ; Mon, 13 May 2019 19:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ZDwO1o/h3w6vY7pyBX0CaMAS6imo2gdxztugwhVRIdM=; b=jW9ntHbjYs4hyqkiSZwTYlKQ0I lUITZHusdUZJrZvXA1Fni2ppdAHqapGTfwvZUg4EiipNgQf+9McAFjXn2CVpxN+/IqVkLCFoJ3PRf Az0LlKo2Htad+vcDeT7h3DzIOzK/Ecib6LypDZDASxuMEN58C9eJadC4mJgdTHri05Zuq5suYDjBf clyjnFKYiegYsh59uOR1PO018pQDw/FR3Sl37D9IUbUh3FfClPruCqrVaz8Z/KYWz80zmgvCp19l8 iy+jDOVd1kQb2i1VTObMjmZkFBZaD/kljdAD45BX12icSsMprguLrxOs7hKOFqqqaqn4Pi/uQC3mi 7YtlphqQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGZA-00032P-Om; Mon, 13 May 2019 19:24:52 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXk-00018f-70 for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:40 +0000 Received: by mail-lj1-x241.google.com with SMTP id a10so4096481ljf.6 for ; Mon, 13 May 2019 12:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Bq5498AOcSF9nWVNbhGQT9xwPiaFsmcqnV/fxv1rlk=; b=W4GhQnl8ZsdBUVqc7l5KLussGmwg71kqOstSI+0Ph1Lr8vtPu9C8+icwujP0k7qwj9 5TvlopE+qiKZV7fIhJrr2LcsOWK4knRqcbjI3G606AbC5uurrDPc2GBqBm2Z8X7wFqcb xuy2+GAFpVZPm3a4PgV1+kuQcOFBsu5X8EQf3CLRm/NY65JX12Jphpgy0BQ+ErCA8MCX XsgxxvmN9Z8ltKyBNnDzlSHpbzkBWLl35VLjd/y7Rf4k97Vd2ckc3dCg4vydyK0sZ/nj C2KJHlpK/BuH7Z72z3Gs9vGq81hQW/3d8xcMAg7uKl8L8MYlYOGjQS9YqTX6hTirdBD6 +zBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0Bq5498AOcSF9nWVNbhGQT9xwPiaFsmcqnV/fxv1rlk=; b=KUfhQZfazFafLkRyB86KjcyPJTOR5YTPGiyhivupau+lXSI9/yaxfc2kNwo6J++lir cPNnrZiad1+1GCz2sVNFu6E+0mKjKrJirVB6F97sGAPHgsnj/6fhYmQnXx2v/b6QWPJY sBrsmSKzFkmOpz46ILAc3atY6PVqj4zn84q5comn76DlSuUI6sPCPF4ASZ/EjHZK3TCf mlbx0hEQiYCaB5yLNvAmxH5pcKiusUv4KxbfO6KvZr7H6r+TOVXnpHI4DI/qwGUHv3nj J2Xgw3QPEt0OiAC6cYYw59404puXUJiKMvsgG40DX7A2Y21q+YHWxBvqIdGKQCP5Frqh RjhQ== X-Gm-Message-State: APjAAAUreWECcm7hvB93z1xzOoEaxS2kzXj5ERuEzYDp8IPHeGCc0EmW KFgwsjLlDW//Dm8kdd+csF6mmw== X-Google-Smtp-Source: APXvYqw7+OiJXxfFee31pCrymAeYS08U5pee+00MkBLRYZuV1nu61St5Md6HOWASXzRRprmmKqAw5g== X-Received: by 2002:a2e:92ce:: with SMTP id k14mr14559128ljh.83.1557775402543; Mon, 13 May 2019 12:23:22 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:21 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 09/18] drivers: firmware: psci: Add support for PM domains using genpd Date: Mon, 13 May 2019 21:22:51 +0200 Message-Id: <20190513192300.653-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122324_913331_8A491B3B X-CRM114-Status: GOOD ( 28.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When the hierarchical CPU topology layout is used in DT, we need to setup the corresponding PM domain data structures, as to allow a CPU and a group of CPUs to be power managed accordingly. Let's enable this by deploying support through the genpd interface. Additionally, when the OS initiated mode is supported by the PSCI FW, let's also parse the domain idle states DT bindings as to make genpd responsible for the state selection, when the states are compatible with "domain-idle-state". Otherwise, when only Platform Coordinated mode is supported, we rely solely on the state selection to be managed through the regular cpuidle framework. If the initialization of the PM domain data structures succeeds and the OS initiated mode is supported, we try to switch to it. In case it fails, let's fall back into a degraded mode, rather than bailing out and returning an error code. Due to that the OS initiated mode may become enabled, we need to adjust to maintain backwards compatibility for a kernel started through a kexec call. Do this by explicitly switch to Platform Coordinated mode during boot. Finally, the actual initialization of the PM domain data structures, is done via calling the new shared function, psci_dt_init_pm_domains(). However, this is implemented by subsequent changes. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - Simplify code setting domain_state at power off. - Use the genpd ->free_state() callback to manage freeing of states. - Fixup a bogus while loop. --- drivers/firmware/psci/Makefile | 2 +- drivers/firmware/psci/psci.c | 7 +- drivers/firmware/psci/psci.h | 5 + drivers/firmware/psci/psci_pm_domain.c | 268 +++++++++++++++++++++++++ 4 files changed, 280 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/psci/psci_pm_domain.c diff --git a/drivers/firmware/psci/Makefile b/drivers/firmware/psci/Makefile index 1956b882470f..ff300f1fec86 100644 --- a/drivers/firmware/psci/Makefile +++ b/drivers/firmware/psci/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 # -obj-$(CONFIG_ARM_PSCI_FW) += psci.o +obj-$(CONFIG_ARM_PSCI_FW) += psci.o psci_pm_domain.o obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 0e91d864e346..bfef300b7ebe 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -721,9 +721,14 @@ static int __init psci_1_0_init(struct device_node *np) if (err) return err; - if (psci_has_osi_support()) + if (psci_has_osi_support()) { pr_info("OSI mode supported.\n"); + /* Make sure we default to PC mode. */ + invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_PC, 0, 0); + } + return 0; } diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index f2277c3ad405..00d2e3dcef49 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -11,6 +11,11 @@ bool psci_has_osi_support(void); #ifdef CONFIG_CPU_IDLE void psci_set_domain_state(u32 state); int psci_dt_parse_state_node(struct device_node *np, u32 *state); +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF +int psci_dt_init_pm_domains(struct device_node *np); +#else +static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } +#endif #endif #endif /* __PSCI_H */ diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c new file mode 100644 index 000000000000..3c6ca846caf4 --- /dev/null +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PM domains for CPUs via genpd - managed by PSCI. + * + * Copyright (C) 2019 Linaro Ltd. + * Author: Ulf Hansson + * + */ + +#define pr_fmt(fmt) "psci: " fmt + +#include +#include +#include +#include +#include + +#include "psci.h" + +#if defined(CONFIG_CPU_IDLE) && defined(CONFIG_PM_GENERIC_DOMAINS_OF) + +struct psci_pd_provider { + struct list_head link; + struct device_node *node; +}; + +static LIST_HEAD(psci_pd_providers); +static bool osi_mode_enabled; + +static int psci_pd_power_off(struct generic_pm_domain *pd) +{ + struct genpd_power_state *state = &pd->states[pd->state_idx]; + u32 *pd_state; + + /* If we have failed to enable OSI mode, then abort power off. */ + if (psci_has_osi_support() && !osi_mode_enabled) + return -EBUSY; + + if (!state->data) + return 0; + + /* When OSI mode is enabled, set the corresponding domain state. */ + pd_state = state->data; + psci_set_domain_state(*pd_state); + + return 0; +} + +static int psci_pd_parse_state_nodes(struct genpd_power_state *states, + int state_count) +{ + int i, ret; + u32 psci_state, *psci_state_buf; + + for (i = 0; i < state_count; i++) { + ret = psci_dt_parse_state_node(to_of_node(states[i].fwnode), + &psci_state); + if (ret) + goto free_state; + + psci_state_buf = kmalloc(sizeof(u32), GFP_KERNEL); + if (!psci_state_buf) { + ret = -ENOMEM; + goto free_state; + } + *psci_state_buf = psci_state; + states[i].data = psci_state_buf; + } + + return 0; + +free_state: + i--; + for (; i >= 0; i--) + kfree(states[i].data); + return ret; +} + +static int psci_pd_parse_states(struct device_node *np, + struct genpd_power_state **states, int *state_count) +{ + int ret; + + /* Parse the domain idle states. */ + ret = of_genpd_parse_idle_states(np, states, state_count); + if (ret) + return ret; + + /* Fill out the PSCI specifics for each found state. */ + ret = psci_pd_parse_state_nodes(*states, *state_count); + if (ret) + kfree(*states); + + return ret; +} + +static void psci_pd_free_states(struct genpd_power_state *states, + unsigned int state_count) +{ + int i; + + for (i = 0; i < state_count; i++) + kfree(states[i].data); + kfree(states); +} + +static int psci_pd_init(struct device_node *np) +{ + struct generic_pm_domain *pd; + struct psci_pd_provider *pd_provider; + struct dev_power_governor *pd_gov; + struct genpd_power_state *states = NULL; + int ret = -ENOMEM, state_count = 0; + + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) + goto out; + + pd_provider = kzalloc(sizeof(*pd_provider), GFP_KERNEL); + if (!pd_provider) + goto free_pd; + + pd->name = kasprintf(GFP_KERNEL, "%pOF", np); + if (!pd->name) + goto free_pd_prov; + + /* + * For OSI mode, parse the domain idle states and let genpd manage the + * state selection for those being compatible with "domain-idle-state". + */ + if (psci_has_osi_support()) { + ret = psci_pd_parse_states(np, &states, &state_count); + if (ret) + goto free_name; + pd->free_states = psci_pd_free_states; + } + + pd->name = kbasename(pd->name); + pd->power_off = psci_pd_power_off; + pd->states = states; + pd->state_count = state_count; + pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN; + + /* Use governor for CPU PM domains if it has some states to manage. */ + pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL; + + ret = pm_genpd_init(pd, pd_gov, false); + if (ret) { + psci_pd_free_states(states, state_count); + goto free_name; + } + + ret = of_genpd_add_provider_simple(np, pd); + if (ret) + goto remove_pd; + + pd_provider->node = of_node_get(np); + list_add(&pd_provider->link, &psci_pd_providers); + + pr_debug("init PM domain %s\n", pd->name); + return 0; + +remove_pd: + pm_genpd_remove(pd); +free_name: + kfree(pd->name); +free_pd_prov: + kfree(pd_provider); +free_pd: + kfree(pd); +out: + pr_err("failed to init PM domain ret=%d %pOF\n", ret, np); + return ret; +} + +static void psci_pd_remove(void) +{ + struct psci_pd_provider *pd_provider, *it; + struct generic_pm_domain *genpd; + + list_for_each_entry_safe(pd_provider, it, &psci_pd_providers, link) { + of_genpd_del_provider(pd_provider->node); + + genpd = of_genpd_remove_last(pd_provider->node); + if (!IS_ERR(genpd)) + kfree(genpd); + + of_node_put(pd_provider->node); + list_del(&pd_provider->link); + kfree(pd_provider); + } +} + +static int psci_pd_init_topology(struct device_node *np) +{ + struct device_node *node; + struct of_phandle_args child, parent; + int ret; + + for_each_child_of_node(np, node) { + if (of_parse_phandle_with_args(node, "power-domains", + "#power-domain-cells", 0, &parent)) + continue; + + child.np = node; + child.args_count = 0; + + ret = of_genpd_add_subdomain(&parent, &child); + of_node_put(parent.np); + if (ret) { + of_node_put(node); + return ret; + } + } + + return 0; +} + +int psci_dt_init_pm_domains(struct device_node *np) +{ + struct device_node *node; + int ret, pd_count = 0; + + /* + * Parse child nodes for the "#power-domain-cells" property and + * initialize a genpd/genpd-of-provider pair when it's found. + */ + for_each_child_of_node(np, node) { + if (!of_find_property(node, "#power-domain-cells", NULL)) + continue; + + ret = psci_pd_init(node); + if (ret) + goto put_node; + + pd_count++; + } + + /* Bail out if not using the hierarchical CPU topology. */ + if (!pd_count) + return 0; + + /* Link genpd masters/subdomains to model the CPU topology. */ + ret = psci_pd_init_topology(np); + if (ret) + goto remove_pd; + + /* Try to enable OSI mode if supported. */ + if (psci_has_osi_support()) { + ret = psci_set_osi_mode(); + if (ret) + pr_warn("failed to enable OSI mode: %d\n", ret); + else + osi_mode_enabled = true; + } + + pr_info("Initialized CPU PM domain topology\n"); + return pd_count; + +put_node: + of_node_put(node); +remove_pd: + if (pd_count) + psci_pd_remove(); + pr_err("failed to create CPU PM domains ret=%d\n", ret); + return ret; +} +#endif From patchwork Mon May 13 19:22:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50E501398 for ; Mon, 13 May 2019 19:25:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FA762841D for ; Mon, 13 May 2019 19:25:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3361228426; Mon, 13 May 2019 19:25:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8F23B2841D for ; Mon, 13 May 2019 19:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KibJNXMSRbtJXFIGgsPbOcrlCIsnoycxVbXGr0ebpWM=; b=TjdM3JlTZS3lyFBtpAIkZkExxb nhjEhKDRf9EUc70mbBdeHOVw1A8tSYj6aVo/kB6A6Z+a1qizxyvAriVRVPiGDKQDbEZa0j1br6fnf vm5xAPeZF87TB6iheo91e2TE08291JHhp/zxldLPtpkoqeXwXqhkwFwes8lEMygKFwkFhkJubCb1S /WMUyq1M7Icl/VOL70zVdwnvF6gKvAqxxwIOdGKL9RPF6O/jjxRzeuiXCAPI5rbNv4CnYk3/sq3DN LHPVnBmU51/k2ewOGhaJerCUcIaQVmQ6zw2c76IniYmfQIK9fNb3sm/EYwaZ15a5ptSAIar05DYXw 00BfsoxQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGZM-0003IQ-3g; Mon, 13 May 2019 19:25:04 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXm-0001BE-0D for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:42 +0000 Received: by mail-lj1-x241.google.com with SMTP id m20so315773lji.2 for ; Mon, 13 May 2019 12:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v5R43yf4/qed6bgDurPjUl3jOQa4Rl4O09rX4nZosQI=; b=n1vBqM2Wy+eX7IIQwl58KXauTGw8VuTEGAX0h49n6Y7x7DeOz7yckXoyzuskCHuZba 1xAff9sl5Pn24Ww5EjGImQxE+Xjp0ZlEpFiRP2XtesR7J79ntNXSjy5FeLhv2J8vZg+s HvwlRlO1bFAQ2/iSrQsGbnUzYubUQ1MND9xOUp8qstnZys3tixpffazhGjpJm2B4Cs0K +wZIkTKzjh7afvMrsGBeVFajOFnWn4D56sbRZOF7ZTR2lA4wT3bBpQp+eeoG2HSjPOm7 jEERqEEeDnlsjbgODSFVGzARt+Jknp8L9nxIOXc38jr5PsMUb8Vm3lVE80bFETDWU2ua nuzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v5R43yf4/qed6bgDurPjUl3jOQa4Rl4O09rX4nZosQI=; b=e8dwYmnK8dD6ZcTIkvD29hTn17tUQOB7oJuzFBoHLYNr/0X/8Ep5Fc8YtRdLZ7Fxrn rt4mIedpJ9i2UngkI/lPbY7KrY2Q68YY6PTgLswHW+mIeQ8vZ8jXRiUs5aByKpYWe0eu oKF5u4Yrh5oEHuX9ahf4hPD6oNg4q1QSM7aDv6WXJS7CcTNsWzSqxSFUL5bcXNebBZIc /fFFbOsLvDpQixvOYc+gMyeKc64gia/c06YyBwh8DSY/Y9EjnoXNgFeoVqtiE4OsfdL5 d53QJjenEJLoNVYb7DNDrUjYWRCEgZeBxT+B7DT0ovjsGuo4oh5sPH27GUHBRaDqK/VI E6bQ== X-Gm-Message-State: APjAAAWbPnrgwq9GrTWxhcSZvBmhsHbz+lXzpzsXS4bXbxWKO93+OUBb K7JM0XCiKiw31/kaC0X2OcwjSA== X-Google-Smtp-Source: APXvYqx2Vh1KSuzK1Is/V87g7ZsLmQej7M/ZhTd5zzA/N3YXZQ+9NtPLtW9JLqQfxVA+I0oz+0bQLw== X-Received: by 2002:a2e:4701:: with SMTP id u1mr10153531lja.38.1557775404368; Mon, 13 May 2019 12:23:24 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:23 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 10/18] drivers: firmware: psci: Add hierarchical domain idle states converter Date: Mon, 13 May 2019 21:22:52 +0200 Message-Id: <20190513192300.653-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122326_701329_B6767C5E X-CRM114-Status: GOOD ( 18.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the hierarchical CPU topology is used, but the OS initiated mode isn't supported, we need to rely solely on the regular cpuidle framework to manage the idle state selection, rather than using genpd and its governor. For this reason, introduce a new PSCI DT helper function, psci_dt_pm_domains_parse_states(), which parses and converts the hierarchically described domain idle states from DT, into regular flattened cpuidle states. The converted states are added to the existing cpuidle driver's array of idle states, which make them available for cpuidle. Signed-off-by: Ulf Hansson --- Changes: - Some simplification of the code. --- drivers/firmware/psci/psci.h | 5 ++ drivers/firmware/psci/psci_pm_domain.c | 118 +++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index 00d2e3dcef49..c36e0e6649e9 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -3,6 +3,7 @@ #ifndef __PSCI_H #define __PSCI_H +struct cpuidle_driver; struct device_node; int psci_set_osi_mode(void); @@ -13,8 +14,12 @@ void psci_set_domain_state(u32 state); int psci_dt_parse_state_node(struct device_node *np, u32 *state); #ifdef CONFIG_PM_GENERIC_DOMAINS_OF int psci_dt_init_pm_domains(struct device_node *np); +int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, + struct device_node *cpu_node, u32 *psci_states); #else static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } +static inline int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, + struct device_node *cpu_node, u32 *psci_states) { return 0; } #endif #endif diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c index 3c6ca846caf4..3aa645dba81b 100644 --- a/drivers/firmware/psci/psci_pm_domain.c +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -14,6 +14,10 @@ #include #include #include +#include +#include + +#include #include "psci.h" @@ -104,6 +108,53 @@ static void psci_pd_free_states(struct genpd_power_state *states, kfree(states); } +static int psci_pd_enter_pc(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx); +} + +static void psci_pd_enter_s2idle_pc(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + psci_pd_enter_pc(dev, drv, idx); +} + +static void psci_pd_convert_states(struct cpuidle_state *idle_state, + u32 *psci_state, struct genpd_power_state *state) +{ + u32 *state_data = state->data; + u64 target_residency_us = state->residency_ns; + u64 exit_latency_us = state->power_on_latency_ns + + state->power_off_latency_ns; + + *psci_state = *state_data; + do_div(target_residency_us, 1000); + idle_state->target_residency = target_residency_us; + do_div(exit_latency_us, 1000); + idle_state->exit_latency = exit_latency_us; + idle_state->enter = &psci_pd_enter_pc; + idle_state->enter_s2idle = &psci_pd_enter_s2idle_pc; + idle_state->flags |= CPUIDLE_FLAG_TIMER_STOP; + + strncpy(idle_state->name, to_of_node(state->fwnode)->name, + CPUIDLE_NAME_LEN - 1); + strncpy(idle_state->desc, to_of_node(state->fwnode)->name, + CPUIDLE_NAME_LEN - 1); +} + +static bool psci_pd_is_provider(struct device_node *np) +{ + struct psci_pd_provider *pd_prov, *it; + + list_for_each_entry_safe(pd_prov, it, &psci_pd_providers, link) { + if (pd_prov->node == np) + return true; + } + + return false; +} + static int psci_pd_init(struct device_node *np) { struct generic_pm_domain *pd; @@ -265,4 +316,71 @@ int psci_dt_init_pm_domains(struct device_node *np) pr_err("failed to create CPU PM domains ret=%d\n", ret); return ret; } + +int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, + struct device_node *cpu_node, u32 *psci_states) +{ + struct genpd_power_state *pd_states; + struct of_phandle_args args; + int ret, pd_state_count, i, state_idx, psci_idx; + u32 cpu_psci_state = psci_states[drv->state_count - 2]; + struct device_node *np = of_node_get(cpu_node); + + + /* Walk the CPU topology to find compatible domain idle states. */ + while (np) { + ret = of_parse_phandle_with_args(np, "power-domains", + "#power-domain-cells", 0, &args); + of_node_put(np); + if (ret) + return 0; + + np = args.np; + + /* Verify that the node represents a psci pd provider. */ + if (!psci_pd_is_provider(np)) { + of_node_put(np); + return 0; + } + + /* Parse for compatible domain idle states. */ + ret = psci_pd_parse_states(np, &pd_states, &pd_state_count); + if (ret) { + of_node_put(np); + return ret; + } + + i = 0; + while (i < pd_state_count) { + + state_idx = drv->state_count; + if (state_idx >= CPUIDLE_STATE_MAX) { + pr_warn("exceeding max cpuidle states\n"); + of_node_put(np); + return 0; + } + + /* WFI state is not part of psci_states. */ + psci_idx = state_idx - 1 + i; + psci_pd_convert_states(&drv->states[state_idx + i], + &psci_states[psci_idx], &pd_states[i]); + + /* + * In the hierarchical CPU topology the master PM domain + * idle state's DT property, "arm,psci-suspend-param", + * don't contain the bits for the idle state of the CPU, + * let's add those here. + */ + psci_states[psci_idx] |= cpu_psci_state; + pr_debug("psci-power-state %#x index %d\n", + psci_states[psci_idx], psci_idx); + + drv->state_count++; + i++; + } + psci_pd_free_states(pd_states, pd_state_count); + } + + return 0; +} #endif From patchwork Mon May 13 19:22:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E3BD912 for ; Mon, 13 May 2019 19:38:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DA3427FA8 for ; Mon, 13 May 2019 19:38:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6139C2841D; Mon, 13 May 2019 19:38:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F354B27FA8 for ; Mon, 13 May 2019 19:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=utqVynMMW2q9SXvmK9qb3eJnSKthHI7pfE+o1qDKIt8=; b=aQ/OIJVJoZzBo9jIlnXXxf4p5x TbP/XVqH3qfwFuRkW6DgmWRByblm7gU+OMzfS1mAmKJB2gDh6mCoxS33tWgt48XhkEUuFMObCPkCM UV2fu54UKAQtLYA6ryd+M/pC/XBmy+rSs7nj8NOd4QZwHBr5rqxOYJLEzHB10lVRAq/8hTc+ml4QD dmqDhSRk1haz6Mw+qwY4Zq0ql69/BIlbLkUQz2Qdcb4QWRLtXLH36jPpcGMkrxdsNmDJhdw9N8BiS 6sj9es183R36O/LX955HsJgEBAtOFjYOPfwwypUi5yGJzQl28kiFgJQScfCHqFiJjF7xfFIBxTE0N nfbjD7GA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGmF-0001le-0Q; Mon, 13 May 2019 19:38:23 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXn-0001Df-Np for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:42 +0000 Received: by mail-lf1-x144.google.com with SMTP id h126so9929688lfh.4 for ; Mon, 13 May 2019 12:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XTy06JPjF+Flbr9WT5p68Fa18r9/HEAcUQNjh0fiSxI=; b=xNwX3XNe/fEpvPHbUQrZ5x+LqEpdA/RH0mdOzfdRzVQASPFEcNy/mFD0OfHWCToaZ0 PrLL4rnH27RSud7LIy378Wj4Wj8Hh9/Xt0I8VfOlVZRAh/O3hbwv62GHEi7+LF8SOLO2 tt3BCSJoO1lX0RHEpuYlTM6SspGottirXeynSYFliz9YP8Y+Zzt7m+A613Qa7wbd7vf9 9Bq4pR31rg1WKJVhfAuJ5QPRwmYRPdi4ueAQ4ADAi0B9GO8o48sWaERmDbLHwHzGEjEy 1VAPQLLEoIZKP/kHIeO1MNUF7XhwAH5ChUeHgtbVhjw8ggkBEECcBqw/N9bFX+WErUR/ 8B/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XTy06JPjF+Flbr9WT5p68Fa18r9/HEAcUQNjh0fiSxI=; b=qeVm0E+uX1VxyFwzmbbMTKBMUaq+UCNvzZzy5rgxmVAgTISaYROmpGHfmACi/Cj/J0 8Gm9tmae7bHj0BF+4TiNRwuubANodXIBKeO+jOKTEFkiEq4rRktM00cI+e1BwmdW/69J MXBSBBfBP4IRyMc28wKeAlX6Dny+nPDWBq4OWy01/HoNAcJW3Vu9edOxaJnAvoWaWiCD cm5mhdxm/8VKf2PDsXb+7Fc3q6jAc01DeJ3FQPxLgxqqkaxSL/6jtL1D4iUti3xBbqOH 7NlzZw2dLiLa6/+OcDWsYskYC8p8aeBszjP4m/pvyYsnNU7nC+N1MqlC4rLMG6a5wYEV D1VA== X-Gm-Message-State: APjAAAVRkMKle5ZQ427XV8tfY/RLGxkeg7Wslt2CkPFmuBMoDGfZn30w L7ySGVyMSst5AAfRIoEfRDUFTA== X-Google-Smtp-Source: APXvYqy6lylq/7RbTmCodW9mEbVCUkckcxopczjrEblxG06MxFPhpTcYSizZjnHDtDbPl63l4lZbOw== X-Received: by 2002:ac2:410e:: with SMTP id b14mr7738149lfi.100.1557775406156; Mon, 13 May 2019 12:23:26 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:25 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 11/18] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Mon, 13 May 2019 21:22:53 +0200 Message-Id: <20190513192300.653-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122328_299861_13EF9A64 X-CRM114-Status: GOOD ( 16.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To be able to initiate the PM domain data structures for PSCI at a specific point during boot, let's export a new init function, psci_dt_topology_init(). If CONFIG_CPU_IDLE is set, it calls psci_dt_init_pm_domains(), which performs the actual initialization. Note that, it may seem like feasible idea to hook into the existing psci_dt_init() function, rather than adding a new separate init function. However, this doesn't work because psci_dt_init() is called early in the boot sequence, when allocating dynamic data structures isn't yet possible. Subsequent changes calls this new init function. Finally, following changes on top needs to know whether the hierarchical PM domain topology is used or not. Therefore, let's store this information in an internal PSCI flag. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - Moved some code inside "#ifdef CONFIG_CPU_IDLE". - Updated changelog. --- drivers/firmware/psci/psci.c | 30 ++++++++++++++++++++++++++++++ include/linux/psci.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index bfef300b7ebe..28745234b53f 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -297,6 +297,7 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); static DEFINE_PER_CPU(u32, domain_state); +static bool psci_dt_topology; static inline u32 psci_get_domain_state(void) { @@ -480,6 +481,19 @@ static const struct cpuidle_ops psci_cpuidle_ops __initconst = { CPUIDLE_METHOD_OF_DECLARE(psci, "psci", &psci_cpuidle_ops); #endif + +static int __init _psci_dt_topology_init(struct device_node *np) +{ + int ret; + + /* Initialize the CPU PM domains based on topology described in DT. */ + ret = psci_dt_init_pm_domains(np); + psci_dt_topology = ret > 0; + + return ret; +} +#else +static inline int _psci_dt_topology_init(struct device_node *np) { return 0; } #endif static int psci_system_suspend(unsigned long unused) @@ -758,6 +772,22 @@ int __init psci_dt_init(void) return ret; } +int __init psci_dt_topology_init(void) +{ + struct device_node *np; + int ret; + + np = of_find_matching_node_and_match(NULL, psci_of_match, NULL); + if (!np) + return -ENODEV; + + /* Initialize the topology described in DT. */ + ret = _psci_dt_topology_init(np); + + of_node_put(np); + return ret; +} + #ifdef CONFIG_ACPI /* * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's diff --git a/include/linux/psci.h b/include/linux/psci.h index 4f29a3bff379..16beccccbbcc 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -55,8 +55,10 @@ extern struct psci_operations psci_ops; #if defined(CONFIG_ARM_PSCI_FW) int __init psci_dt_init(void); +int __init psci_dt_topology_init(void); #else static inline int psci_dt_init(void) { return 0; } +static inline int psci_dt_topology_init(void) { return 0; } #endif #if defined(CONFIG_ARM_PSCI_FW) && defined(CONFIG_ACPI) From patchwork Mon May 13 19:22:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88D151398 for ; Mon, 13 May 2019 19:25:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78E7628415 for ; Mon, 13 May 2019 19:25:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C3A62841D; Mon, 13 May 2019 19:25:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0678B27F94 for ; Mon, 13 May 2019 19:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HP4rtZbLBOWYGrGq65Mm0MppI4Bsf9USGmOy3i1rGlI=; b=DvDYFcd0TdZ+b7YMWVoYHynyk5 JcEebT1RY7BLmTfm7r+ZVHhwu3OLGzFWlHatgZZv4pCYGbYG1yNfxQOpJVbc8v8752RwxEyahNYQE 4hd5/0zTv5zGZF4DPN2bj0dLXVGY3hIW6i8lg9Wzc9oVaj9OWPdxkUKcOLmg4LCTCFV31lc+OBxOZ s7+oTFevU5DjUg/zm9WZbwBxIigwfyBVqCmbx7Zxmh+NMiuy803OdljmOLhU5vIuAeKZGjkfOMOlJ EB7LMxoZ2DbyS14VX0rXcyUkG9TI3Qx2Mn1Wk+W+5Cpi4jJ7Z/WrEd4Ae/DwxHdHVob/TYM7EsJ0e Pdv/2QtQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGZv-0005Dt-7w; Mon, 13 May 2019 19:25:39 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXq-0001GD-3R for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:45 +0000 Received: by mail-lj1-x244.google.com with SMTP id w1so9506389ljw.0 for ; Mon, 13 May 2019 12:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=YrDb+TI/qptrO7/5RXe8SeC+HyCzsJJl8ml3Jr2kE2brTGKdFR7/IJ+N4lXVtKfgGo NAHroyR3jEv97wAFOv1N3DRBDosPKmtXcn1hEpIBtK5wsOrvMlCDRGJxZwA8Y/CGP+8R ab2aAEL3gSBOsIHFKZCpimEz0v0pvvsft17f2AvJ1ojeV6J8wLK4ixd+AfhWKPZ/c7ZC sQLCc6Vgosbnw6yG7ZCHQQ1u7R7deMgYPyyYMCopM3U1unF1AFl5Ap4t5OT1xuDe8t5f uoNBPb8pfj6ZvLWRNfIZPJf9225Y1ujm2szcS0/1CCTN+KdvBfR2+owHypKzCboaNJCY oIXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x3HZaV7vcbo/XhlaM1d9i+kdcoQHiHqHOKB8XCuJnJg=; b=PbdEqTrZXMIImQou17a+7JFj95BOH+ikAzgYLW0TeXJua/GIJSIVhVFV0LtMeJqx8v DCqroZiTW534cwFna3Qg4AvSGQdzbzDQvTKPL52aEBJRqIYpst/RsbZ7Vfck2CHx83UA fm7FjpLtnOZSHmbH5zI/UBKkxJUttEE0uwACy2AAXUrYetlfLETOMQ1DUTiWhAJ8I2bP Dl+3aiYhmnR2XciPtr7kx/SPGuAaalDQCYeRS+W0pbXbI9zp+gD2IxTi9okDKRMFcC2f grWk1fYTrIpNsWRoWWWzNvEYWOngZ+A6LmK7unin3wrndTAc7xg+KFE3R3oIG1oOK2Pe f1AQ== X-Gm-Message-State: APjAAAVbVgrf7tfKF+f/WB9B0erBs+0rQyJajYUILPPK96zpENwudApG ZmSFSSbQgVQC1Gs5ua8Ed5Hdmg== X-Google-Smtp-Source: APXvYqxhImmrN+c//ITxcw8U+57BeFavH+R85RVOLDvIyx6W8pcBzSGLx1AMwoyfzWMRSAkXmhUcdQ== X-Received: by 2002:a2e:206:: with SMTP id 6mr13170535ljc.59.1557775408048; Mon, 13 May 2019 12:23:28 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:27 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 12/18] drivers: firmware: psci: Add a helper to attach a CPU to its PM domain Date: Mon, 13 May 2019 21:22:54 +0200 Message-Id: <20190513192300.653-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122330_575416_B56A542E X-CRM114-Status: GOOD ( 14.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new PSCI DT helper function, psci_dt_attach_cpu(), which takes a CPU number as an in-parameter and tries to attach the CPU's struct device to its corresponding PM domain. Let's use dev_pm_domain_attach_by_name(), as to be able to specify "psci" as the required "power-domain-names". Additionally, let the helper prepare the CPU to be power managed via runtime PM. Signed-off-by: Ulf Hansson --- Changes: - Take into account whether the CPU is online/offline. - Convert from dev_pm_domain_attach() into using the more future proof dev_pm_domain_attach_by_name(). --- drivers/firmware/psci/psci.h | 3 +++ drivers/firmware/psci/psci_pm_domain.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index c36e0e6649e9..b4254405b8ef 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -4,6 +4,7 @@ #define __PSCI_H struct cpuidle_driver; +struct device; struct device_node; int psci_set_osi_mode(void); @@ -16,10 +17,12 @@ int psci_dt_parse_state_node(struct device_node *np, u32 *state); int psci_dt_init_pm_domains(struct device_node *np); int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, struct device_node *cpu_node, u32 *psci_states); +struct device *psci_dt_attach_cpu(int cpu); #else static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } static inline int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, struct device_node *cpu_node, u32 *psci_states) { return 0; } +static inline struct device *psci_dt_attach_cpu(int cpu) { return NULL; } #endif #endif diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c index 3aa645dba81b..1cbe745ee001 100644 --- a/drivers/firmware/psci/psci_pm_domain.c +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -383,4 +385,19 @@ int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, return 0; } + +struct device *psci_dt_attach_cpu(int cpu) +{ + struct device *dev, *cpu_dev = get_cpu_device(cpu); + + dev = dev_pm_domain_attach_by_name(cpu_dev, "psci"); + if (IS_ERR_OR_NULL(dev)) + return dev; + + pm_runtime_irq_safe(dev); + if (cpu_online(cpu)) + pm_runtime_get_sync(dev); + + return dev; +} #endif From patchwork Mon May 13 19:22:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DD871395 for ; Mon, 13 May 2019 19:25:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D31127F94 for ; Mon, 13 May 2019 19:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 013DD2841D; Mon, 13 May 2019 19:25:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 81A9727F94 for ; Mon, 13 May 2019 19:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=tabuPsMk7jjBAd7zmtxn7OwX/8otAkXpt5h/BuXylCU=; b=bAkMCMtR4+zyp+6RlMYUcwpz7+ LAvMMOyscocfl4kPBooEj4mfnX1ulilo27E6m3Yb1jMR7F+7vW5vKr9jfKHdWkdALF+KP01hcony5 pLK5mwoQv7STcNON0wUuvxygWbfJM21YmomnSwB+m7xi4vGxeEUOZoXRoOTMeNCPCVh5wOyIszSlT Vm73Rtl4aoNfdKkdClxlTk5A5kX4WRa/2y2ufAVfQOX2slaWouMR4tMr75TbAgJrHx7gBEcjRRhGf LJ+RPVw1RzxvK/BVOJaJhx8oTcqcx/6ivamjgwywwg7tyz8uHpYEEKzhCeNsr+QBes1AawK075dHV qZObTfyA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGa5-0005SA-5L; Mon, 13 May 2019 19:25:49 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXr-0001Ia-EY for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:49 +0000 Received: by mail-lj1-x244.google.com with SMTP id r76so12043232lja.12 for ; Mon, 13 May 2019 12:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7mMRJh0gRWk8jRKSu7vpJTGJ6ww/FK+bFoVvoMzjgck=; b=A5Wrb60xziILjw5xMgQgTTamMl9xJY2MhOSpDPLTAf/3EQCP+lf+7yig/Ph/N48Hs+ 5eISRFo4PakItBUPivivio9sRWxxOcKf9wZko/ylG4GFm+PHhBbtsOQFhs6a2EYmk6cf d08V0bhI77Ip2AT10wAzzGYunJYYv1Xq6bLSZK+0AvF8kKHSnNeeoT7ASAv0aJjZ/uXa pAh3Vd1UJMx+yB0pcoGTGuiTiECq7yRcyQftboHCRgguQn1fjPxSH/PuwhRrzWxMWrOP vkkAGabM1BZQ68YI0gr+vhbHfVr1udpWSAPl8raFY3py7bW24MK4MzWkC91WgHCON7Du frtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7mMRJh0gRWk8jRKSu7vpJTGJ6ww/FK+bFoVvoMzjgck=; b=JfG9u/r/NbVdsejX/3CfV+67MdfQXytkGBUVEEe0c7pC5eYkE0u8ng5QZCg6TSKBj1 sMh6xRmtwbnJs6qe7ToivkmCQzPpOlx62AdWyQpNwTXpHMhcI/yYL+BwiZSslJ2PoWLG g04E5RDTp74Mnmjt5NT9t9EujmdN8LAdBsgRsajxznKVIGqLzWgds+XBHx5+sXJ5di55 w/5455tFiSPHtl9gapdRgvFgv8KDshdWYxWTQN8YIEwv5ZAP/0qeijpHqdrRLqH0nMUk ksC75cuo+ZvknviTK0LFBMHV5WazsIPhrDAomMupxSJyl2hJcAzQIr3sYFFgRbjlblu7 AB9g== X-Gm-Message-State: APjAAAV3ugoLC0hXKYAYfIu+8tqfFW6X9e625OaIWUJ8cHp/ni1UXzVA 3E9NXah2sGMq+YXuDLRQOA4PoA== X-Google-Smtp-Source: APXvYqxf9UXPo2PbATF2Ej4O/JEKsCNTcYfsKPhGKIQE6BXSznQnuXwlAcye5xuHinSMJfMHW3VIvg== X-Received: by 2002:a2e:8954:: with SMTP id b20mr4530759ljk.10.1557775409921; Mon, 13 May 2019 12:23:29 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:29 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 13/18] drivers: firmware: psci: Attach the CPU's device to its PM domain Date: Mon, 13 May 2019 21:22:55 +0200 Message-Id: <20190513192300.653-14-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122331_868888_42CD755B X-CRM114-Status: GOOD ( 19.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to allow the CPU to be power managed through a potential PM domain and the corresponding topology, it needs to be attached to it. For that reason, check if the PM domain data structures have been initiated for PSCI and if so, let's try to attach the CPU device to its PM domain. However, before attaching the CPU to its PM domain, we need to check whether the PSCI firmware supports OS initiated mode or not. If that isn't the case, we rely solely on the cpuidle framework to deal with the idle state selection, which means we need to parse DT and convert the hierarchical described domain idle states into regular cpuidle states, hence let's do that. Signed-off-by: Ulf Hansson --- Changes: - Adapt to updated psci_dt_attach_cpu() helper, as it now returns a struct device * instead of an int. - Create a per CPU struct, to store the relevant PSCI cpuidle data. --- drivers/firmware/psci/psci.c | 46 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 28745234b53f..54e23d4ed0ea 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -295,7 +295,13 @@ static int __init psci_features(u32 psci_func_id) } #ifdef CONFIG_CPU_IDLE -static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); + +struct psci_cpuidle_data { + u32 *psci_states; + struct device *dev; +}; + +static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static DEFINE_PER_CPU(u32, domain_state); static bool psci_dt_topology; @@ -332,8 +338,9 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, int i, ret = 0, num_state_nodes = drv->state_count - 1; u32 *psci_states; struct device_node *state_node; + struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); - psci_states = kcalloc(num_state_nodes, sizeof(*psci_states), + psci_states = kcalloc(CPUIDLE_STATE_MAX, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) return -ENOMEM; @@ -357,8 +364,31 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; } - /* Idle states parsed correctly, initialize per-cpu pointer */ - per_cpu(psci_power_state, cpu) = psci_states; + /* + * If the hierarchical CPU topology is used, let's attach the CPU device + * to its corresponding PM domain. If OSI mode isn't supported, convert + * the additional domain idle states from the hierarchical DT layout + * into regular flattened cpuidle states, as to let cpuidle manage them. + */ + if (psci_dt_topology) { + struct device *dev; + + if (!psci_has_osi_support()) { + ret = psci_dt_pm_domains_parse_states(drv, cpu_node, + psci_states); + if (ret) + goto free_mem; + } + + dev = psci_dt_attach_cpu(cpu); + if (IS_ERR_OR_NULL(dev)) + goto free_mem; + + data->dev = dev; + } + + /* Idle states parsed correctly, store them in the per-cpu struct. */ + data->psci_states = psci_states; return 0; free_mem: @@ -403,8 +433,8 @@ static int __maybe_unused psci_acpi_cpu_init_idle(unsigned int cpu) } psci_states[i] = state; } - /* Idle states parsed correctly, initialize per-cpu pointer */ - per_cpu(psci_power_state, cpu) = psci_states; + /* Idle states parsed correctly, store them in the per-cpu struct. */ + per_cpu(psci_cpuidle_data.psci_states, cpu) = psci_states; return 0; } #else @@ -442,7 +472,7 @@ int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu) static int psci_suspend_finisher(unsigned long index) { - u32 *state = __this_cpu_read(psci_power_state); + u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); u32 composite_state = state[index - 1] | psci_get_domain_state(); return psci_ops.cpu_suspend(composite_state, __pa_symbol(cpu_resume)); @@ -451,7 +481,7 @@ static int psci_suspend_finisher(unsigned long index) int psci_cpu_suspend_enter(unsigned long index) { int ret; - u32 *state = __this_cpu_read(psci_power_state); + u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); u32 composite_state = state[index - 1] | psci_get_domain_state(); /* From patchwork Mon May 13 19:22:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81FAB1395 for ; Mon, 13 May 2019 19:26:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7205127F94 for ; Mon, 13 May 2019 19:26:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6529428415; Mon, 13 May 2019 19:26:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 03D1A28421 for ; Mon, 13 May 2019 19:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=H4Q+wwDYZzPMayQ0d8u4SDWktG+rkkUchoXqn0Ba2Gs=; b=GDpXZXCFAaH+huAUN3U+tKqpin v6Bjd5R3Ls6IP+Cp2/mjzNveDSlQNvf0M3HXmkvrJhkJCHD3gHIyRGpuS+KgdRGawAC9/qGZ0hhCJ rczD87x9YkXe7ByGoE3eKLJ/r+NZb5diupynKZnNlbivzFo96wJEUu3abttQPYaYs+v/Wdq0d9Gty r/TbdEfv4LNsedSicOd8Br90nCusPGXn7+kLJcWfZZOzaL+3+RxkGhB9mNcBGXHHv+1HHLb7Mw3LT DdenHJiJccwBaofch/fTL0RJ1SJFYN5csB+ImWL/orBBg8uzoLhXt0Po71dJqzpaVOpdcHz/iZ+HM JViFS8vg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGaG-0005fw-9x; Mon, 13 May 2019 19:26:00 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXt-0001LC-Ed for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:50 +0000 Received: by mail-lj1-x241.google.com with SMTP id d15so12062721ljc.7 for ; Mon, 13 May 2019 12:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5L3+w8hUR6giXqb5Tz84iJ3SS/PuntIOYwjCkJwPh9s=; b=nuEds6uqvSvhzFgPN0xx4WrLj+8Aq5wMne2aRP4Hl30ysRHF3JwffRDwh2I/w4NkhA ruqtjGmeavnUC5G6t1+5vD7jYhWzIibj7v8eKj+D5BqywqtbMj4VlBzc5f+oeCC7YVZr gMQJv7sBlyWAqagmqVCdQx6ievkrgzxp6P6VXhi+yjAzjEClLL/IUaPqLF+XdiUzD+wB PoZRlnXLRxkuWULBDbbLIts79BiF1YdM5kTUelzfYB3F6IWAddBJ1onCo4N+i653uveS lhlUL6q4MSOpQOYlAnyDByOwere/dmOdnrZOjhSfSGK/7nMJMIUGdCEIfOTBMbYwDCev MmjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5L3+w8hUR6giXqb5Tz84iJ3SS/PuntIOYwjCkJwPh9s=; b=lsUMIsVYEg8kMaR78mC/yzcWa1kkz6pDgiMaOII7s5rI/hvNBMYH9Gw5VoiVSoMJTZ nuVIdSCwj/fV//ifDErFUSm7J5IAr3tna30aJz4Lo4ve1XvTb8/iMH4w0qw50K/+IN5Z nwEaix85CVmtLlJTtMwQpbcKmnEDw6P+5Wr7K/8RK7PODBjSv0b60E9b3VvePjNsTW4G qVWmZN7mpmAuUUeC/9rjm0M+BvT/lX6E0sto0TjQwtvb3xTzgPip1yLVksaO5g4aRGIX Wy0SDB9V5ZBDuv7gcD/Zhbg8tfDGC1tNGkNrIzUCGPrcScpiDz9iktiZULWQyANtLjoR INWQ== X-Gm-Message-State: APjAAAUbqC/WL56o+3EBc/x/eqqgBAepUgqfIbMkbF7DCN1hC8CzKTye lgRkRqp9P+M7fQXrKsLEi/Xt0w== X-Google-Smtp-Source: APXvYqwhviRoSbMrrPulC15a2Em5gq4bwlntBmk6fP/23jtstN9Z1J324DMrQRo3VkPOVmz3QA57og== X-Received: by 2002:a2e:9141:: with SMTP id q1mr14833265ljg.84.1557775411722; Mon, 13 May 2019 12:23:31 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:31 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 14/18] drivers: firmware: psci: Manage runtime PM in the idle path for CPUs Date: Mon, 13 May 2019 21:22:56 +0200 Message-Id: <20190513192300.653-15-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122333_930368_F64BCB4F X-CRM114-Status: GOOD ( 18.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When the hierarchical CPU topology layout is used in DT, let's allow the CPU to be power managed through its PM domain, via deploying runtime PM support. To know for which idle states runtime PM reference counting is needed, let's store the index of deepest idle state for the CPU, in a per CPU variable. This allows psci_cpu_suspend_enter() to compare this index with the requested idle state index and then act accordingly. Signed-off-by: Ulf Hansson --- Changes: - Simplify the code by using the new per CPU struct, that stores the needed struct device*. --- drivers/firmware/psci/psci.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 54e23d4ed0ea..2c4157d3a616 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -298,6 +299,7 @@ static int __init psci_features(u32 psci_func_id) struct psci_cpuidle_data { u32 *psci_states; + u32 rpm_state_id; struct device *dev; }; @@ -385,6 +387,7 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; data->dev = dev; + data->rpm_state_id = drv->state_count - 1; } /* Idle states parsed correctly, store them in the per-cpu struct. */ @@ -481,8 +484,11 @@ static int psci_suspend_finisher(unsigned long index) int psci_cpu_suspend_enter(unsigned long index) { int ret; - u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); - u32 composite_state = state[index - 1] | psci_get_domain_state(); + struct psci_cpuidle_data *data = this_cpu_ptr(&psci_cpuidle_data); + u32 *states = data->psci_states; + struct device *dev = data->dev; + bool runtime_pm = (dev && data->rpm_state_id == index); + u32 composite_state; /* * idle state index 0 corresponds to wfi, should never be called @@ -491,11 +497,23 @@ int psci_cpu_suspend_enter(unsigned long index) if (WARN_ON_ONCE(!index)) return -EINVAL; + /* + * Do runtime PM if we are using the hierarchical CPU toplogy, but only + * when cpuidle have selected the deepest idle state for the CPU. + */ + if (runtime_pm) + pm_runtime_put_sync_suspend(dev); + + composite_state = states[index - 1] | psci_get_domain_state(); + if (!psci_power_state_loses_context(composite_state)) ret = psci_ops.cpu_suspend(composite_state, 0); else ret = cpu_suspend(index, psci_suspend_finisher); + if (runtime_pm) + pm_runtime_get_sync(dev); + /* Clear the domain state to start fresh when back from idle. */ psci_set_domain_state(0); From patchwork Mon May 13 19:22:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFF321395 for ; Mon, 13 May 2019 19:26:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E051527F94 for ; Mon, 13 May 2019 19:26:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D380C2841D; Mon, 13 May 2019 19:26:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5998827F94 for ; Mon, 13 May 2019 19:26:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Yn8VGG8kcnAtO0PsbYKcX369+IoM8uvSx6tIHaR0cEE=; b=CRWTvPjGKS2NXj7S63W+VrGzJl S3ti/8UG5si7ZSwGwLv6m+XPJTN7/lK77DviUe6XRSEgjRWcck++5ORzVUKPeXp+PFxzkhaTI/y5q Tfc/XTypcNu+bMvieNzA97YGanGvgCB1CoHPjWf+SdU8yc04NAp41N6lXFNv8PWUNmEpMMLwquFUr kGpSAAr67m75itoxGUl4W2PLOEUbNVcHDfpHuA+bq09lh3RZka2IJSgw81vgMGDU5WizeSchw4G26 cRbsAs1+fV/uTo70x3CTK2e6rhhY5tOLVixqoT2uHeZq1RtWtwDg+gKaoYGnRKeihmHsKWYBZFfhF 3jUAxJgg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGae-0006DM-VY; Mon, 13 May 2019 19:26:25 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXv-0001NW-5D for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:24:00 +0000 Received: by mail-lj1-x244.google.com with SMTP id e13so12044685ljl.11 for ; Mon, 13 May 2019 12:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WrUBlQWQzfbgrdk7klxniFTaW91XaiQj55o38mlFd9s=; b=sPy1xWvat53hABQ29ElA2SDvZnqfRV5oZCv6u9/BoxR2ZPqFXvyAG3a5TqRkJY1a78 ViroHIx+ON0jQRU/3UrEYHgnwsRgfEfK1eI6rvzBvxBl01A+l0VD3RNQr/pCLeiGgll5 oZk8WImmrSosBLIL5WDY5HKxk6DoQYAY3hOyay9Zaekc0Qx48OBqfoEIU9LOQbcuUzO9 y21fdWLhr9sVngZjVbZUtziI2z+WwnXK05qOJ7jaN6FqE68r4gmG+pebrx9IRchSta0X VzfAclg9EtvAhwIfrDB0k8yyetyh5giqMkUfQdSjeFYl6oWMRIbrHygy50HEN/rtT2Ov JANw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WrUBlQWQzfbgrdk7klxniFTaW91XaiQj55o38mlFd9s=; b=No+GxlAm/vI1zG4ProVS+tdQq+yFZfMSOWjMFOIczenQEqiRq5KJxg3X8lhtFlaRAR QAXsof2LncsbBMZ8sGm9q39zVCXSowXRcQGqOTL8OFr4nRfkyqwf35zTgappFjuHOPY4 RqPybMqoI6JnDeZrAnk0/d6vG3C9awf2i+ueBsIg9KBb10jzihQQKOA7C5hGUoq/4hK2 QRI3DAMsv5NSdj9slN/Q3rbZOCvKZxKP7m8sKxskDu2gEseV3W0AfYfQMWwcsQk3geat MFSYBhwTxZK930KHL6kec2OSxbE0hGkb1Ehame7jYcb2lkQ2namYj3WTiCP1OdYCV45l gjLA== X-Gm-Message-State: APjAAAXMRBoeKQkF72TlDhgLiXKC3EmIrEb3SrLsUWuLSuBqPZpDJr5h w0POuUFETfF03HmCRrPxwJoLNg== X-Google-Smtp-Source: APXvYqwd8hFjFHeIWZMZf2tJMuRrNt9YuVmMQEmung/qTBri+UbFr4ziejpMmn/ZiqWmeUdPeQNSbw== X-Received: by 2002:a2e:2b58:: with SMTP id q85mr14768159lje.179.1557775413538; Mon, 13 May 2019 12:23:33 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:32 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 15/18] drivers: firmware: psci: Support CPU hotplug for the hierarchical model Date: Mon, 13 May 2019 21:22:57 +0200 Message-Id: <20190513192300.653-16-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122335_497177_4A3E0CA3 X-CRM114-Status: GOOD ( 17.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When the hierarchical CPU topology is used and when a CPU has been put offline (hotplug), that same CPU prevents its PM domain and thus also potential master PM domains, from being powered off. This is because genpd observes the CPU's attached device as being active from a runtime PM point of view. To deal with this, let's decrease the runtime PM usage count by calling pm_runtime_put_sync_suspend() of the attached struct device when putting the CPU offline. Consequentially, we must then increase the runtime PM usage count, while putting the CPU online again. Signed-off-by: Ulf Hansson --- Changes: - Use get_logical_index() to find the CPU number. - Verify that a corresponding struct device* has been attached to the PM domain before doing runtime PM refrence counting. - Clear the domain state when the CPU goes offline, to start fresh. - Move code to internal helper functions and move them inside "ifdef CONFIG_CPU_IDLE. --- drivers/firmware/psci/psci.c | 47 +++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 2c4157d3a616..5ad93c3694b5 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -93,6 +94,9 @@ static u32 psci_function_id[PSCI_FN_MAX]; static u32 psci_cpu_suspend_feature; static bool psci_system_reset2_supported; +static void psci_cpuidle_cpu_off(void); +static void psci_cpuidle_cpu_on(unsigned long cpuid); + static inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature & @@ -188,6 +192,8 @@ static int psci_cpu_off(u32 state) int err; u32 fn; + psci_cpuidle_cpu_off(); + fn = psci_function_id[PSCI_FN_CPU_OFF]; err = invoke_psci_fn(fn, state, 0, 0); return psci_to_linux_errno(err); @@ -200,7 +206,13 @@ static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) fn = psci_function_id[PSCI_FN_CPU_ON]; err = invoke_psci_fn(fn, cpuid, entry_point, 0); - return psci_to_linux_errno(err); + err = psci_to_linux_errno(err); + if (err) + return err; + + psci_cpuidle_cpu_on(cpuid); + + return 0; } static int psci_migrate(unsigned long cpuid) @@ -540,8 +552,41 @@ static int __init _psci_dt_topology_init(struct device_node *np) return ret; } + +static void psci_cpuidle_cpu_off(void) +{ + struct device *dev = __this_cpu_read(psci_cpuidle_data.dev); + + /* + * Drop the runtime PM usage count if the CPU has been attached to a + * CPU PM domain. This is needed to, for example, not prevent other + * master domains in the hierarchy to remain powered on. + */ + if (dev) + pm_runtime_put_sync_suspend(dev); +} + +static void psci_cpuidle_cpu_on(unsigned long cpuid) +{ + struct device *dev; + int cpu; + + if (!psci_dt_topology) + return; + + cpu = get_logical_index(cpuid); + if (cpu < 0) + return; + + dev = per_cpu(psci_cpuidle_data.dev, cpu); + if (dev) + pm_runtime_get_sync(dev); +} + #else static inline int _psci_dt_topology_init(struct device_node *np) { return 0; } +static void psci_cpuidle_cpu_off(void) {} +static void psci_cpuidle_cpu_on(unsigned long cpuid) {} #endif static int psci_system_suspend(unsigned long unused) From patchwork Mon May 13 19:22:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83D5C1395 for ; Mon, 13 May 2019 19:25:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7001E27F94 for ; Mon, 13 May 2019 19:25:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6121D2841D; Mon, 13 May 2019 19:25:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 03B8227F94 for ; Mon, 13 May 2019 19:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=r/6302iXQW/pHZaB3loPAAWx2sAt7oUn9QSPYY9zfBc=; b=o8DnufzB05Xn6UA8GjTylZnHqo YUO8n2igj0lz7hHySg0fZT8eHm1IqyOJDRCZpXVlCep3kwqbUSSqXv0KtH8CwGuE633WUO4LLFNe4 7vd4Bezc+T/FptNHp3WbQNCdtMCg9tpqwTXQtsu1yhfp/NihBc3mCUr47lfpWRlxuedp2qK8wksmZ Ng6kgmDqICLQbH8oXiQp5h+NlsvBkWLDzurRj0GQS1jwiX9/6Z8qsW7WAkUn5eZKhI1q+p15ZA/Ll B3JgAeJiL4d+YDWMiEkEroPkVO58KKKYfpBqKQoD71enZt26Jc7BxJJF9LoSEMxfCzdOtyFVG1Yau wGuz7vIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGZj-0004zs-TI; Mon, 13 May 2019 19:25:27 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGY3-0001Z0-J2 for linux-arm-kernel@bombadil.infradead.org; Mon, 13 May 2019 19:23:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FS9Zs+3LWO+O30HH4l9Kk8Vdize9BSzeQBpadzl2HYA=; b=VOJx8lPrfz9B2SSORVz9X/o+y GmwqOmG4yPV7Ndc037zu51ouDZPchubGZca6uQ3gXmAuUbKwbbrmxgNVez3uQ7DrI79kq+GT+mOCN 0nQ1Fhafgj1vo/yPqnNzwDRZuIeEIHJDIZmBC54jXs8QE1E5MJkuBTFt/RNOtXOCekSeoy9guDI+9 +zH5J0pAfAZKJHQN6QOnQb+wJjg2aY7aeoiAFN1FBlIvs003LAySaKrZGPYla38qjWsvaI8frh/aE r5im0SHdtNsuWPCdqSIB77z1yXwNHUyTg86AwYEKPqIk92qYIz3VAwrYcVFo+8m14sLiCbW/gEEj5 QaXbIoNbw==; Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGY0-0004Ic-5n for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:42 +0000 Received: by mail-lf1-x142.google.com with SMTP id y19so9930035lfy.5 for ; Mon, 13 May 2019 12:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FS9Zs+3LWO+O30HH4l9Kk8Vdize9BSzeQBpadzl2HYA=; b=t15nWHPmFlGF4Hk/qXkWtGd6P4khoapB58QJFxrQ0ZNQUXmlHvGcZXvn8hgr3rc7X+ eE/ASRA8k1AQG0DdZLyF3FiUVQKz9AjKmneEG4iuBy5DWguCj44rHUGww8VoLC14kkpV TAmsE70nTuh+vkyVTcFflq1Ihtv15Gjs6lN28RnAdyk6YEKe1sk82sQKEFoOgzZS1j0g ppmAaYnj4FwI7sFWE7rhWAusai9maT6zhjqYzXhVMTt9rwMyhTPogRZF82iPBQdLTLL8 e41snlmZNXFO0Bqj9yPBVHA/mzxQ87IGeFK04GazkTYlofyN2rCzQMCISOTnU4Ay1zIY C4YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FS9Zs+3LWO+O30HH4l9Kk8Vdize9BSzeQBpadzl2HYA=; b=Tfsune+8SFYm5AYWRD15KvXeqL2BEXrqfo53H/77U7KjtW+Iwv37wjNhXXdpoWFZCh 1ZPsdsuKeVCBTDPOBy/+q6xCDfaMF67HG+sdJqApyt6sL7Xji+S+dsVfrwIAyyl0i4FP TobLveLzBumQ06MloUnHLOoxoQ5/237eY7IYQP4IaUJK0iGcpwMjclQnlmQSLQ2YUz0N ViqePzIbbBxq5rc6z967vcq5ejcUBzYDGoLLUjslCGo6qQZey3Q7bqqFlkJbihitipbH qP87p2wBWygdZC8cLW7KK59Cb718AbgXqT90DCfWLet0Eoh0RitQXdRfzkqG+gdMiC53 nquQ== X-Gm-Message-State: APjAAAWciyH0wxBh7vg27uYCLWMVfieeIMbUZEVrBaS3fLZBVYKVH8/W FqHT8aDxFQwBbdrIG4gQihti4Q== X-Google-Smtp-Source: APXvYqwf7I+vqyV1oY+DdOoP8eb7s+6VlIHVgf1KVMJaduN8GSRO4HLl7ruL91VI1qfgG8O6PtC3NA== X-Received: by 2002:a19:ae14:: with SMTP id f20mr14035921lfc.49.1557775415444; Mon, 13 May 2019 12:23:35 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:34 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 16/18] arm64: kernel: Respect the hierarchical CPU topology in DT for PSCI Date: Mon, 13 May 2019 21:22:58 +0200 Message-Id: <20190513192300.653-17-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_202340_231159_C6E4B2E2 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Will Deacon , Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , "Raju P . L . S . S . S . N" , Lina Iyer , Catalin Marinas MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To let the PSCI driver parse for the hierarchical CPU topology in DT and thus potentially initiate the corresponding PM domain data structures, let's call psci_dt_topology_init() from the existing topology_init() subsys_initcall. Cc: Catalin Marinas Cc: Will Deacon Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - None. --- arch/arm64/kernel/setup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 413d566405d1..f1559223c55b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -367,6 +367,9 @@ static int __init topology_init(void) { int i; + if (acpi_disabled) + psci_dt_topology_init(); + for_each_online_node(i) register_one_node(i); From patchwork Mon May 13 19:22:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05C371398 for ; Mon, 13 May 2019 19:26:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8E8C27F94 for ; Mon, 13 May 2019 19:26:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC3C32841D; Mon, 13 May 2019 19:26:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6BA6427F94 for ; Mon, 13 May 2019 19:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lnKZe88ms20n0L6Os5D0uOacZRiShcBfWdO5iNg/r5Y=; b=L2/c+SngrJllpOnYYxFmURax9f 2jJsMqdZe+9V/yAIpImvI+utHJXMfch5l2yuEFOboxX5PjeTEerWJ88d/tclHWZuGFoVbAP+wlhqx uuTBA9rKBKiW0MdN6CyuxCa7e2jv3Sc07Mwgz/KMjLAr9EYHDR09KMxQ2BWaLf8KA8IslvFZWi7K/ fxmQVYM/HP6diALkhySSE1yiEilcIwbwet0n/RRGqeBK5dkfnqr8hxJmbkr+pK7h2cSJtF6WW5KLF D5GVGAw/mlVAG5Daqulunje54ooyqnj2yUrC/B+xbw01qvNM3vBjxdVashhd7A5l3LDwC/D9KIhSu V2VAJk1g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGar-0006Yg-6p; Mon, 13 May 2019 19:26:37 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGXy-0001So-Sp for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:24:01 +0000 Received: by mail-lf1-x144.google.com with SMTP id x132so9959539lfd.0 for ; Mon, 13 May 2019 12:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PDEUjjOBUJS5iHQaBAG+Z33WI0zFNAprAtoJyuCQ0PY=; b=M21k49y1eNn330/lF5JvreEZChjrS2M6ynm3TqPbbn/Q9xiZAzxNCYtv/EuxrqqtMM QGsNsvmFxgy9sSC46EshhJEpWH5Pz4ZTv2l1DCMYxEhHs7XqE1HQbPYe5KlbUPpZoz1u CROTIRFp0MmW7feCctSmkdf9rvOLpD1AHPnKXgEBya6wH+hN4dttUD8c/NIeoCMp+8G5 7LZjDpnxdIB9RSMG00FALVcyBAhvnwEyA3AsG5QE2IRgu2aE+wNxXs4Clt22/rk1KpRQ w4c/YO/4ShYOv7C674P9egAkOJOTIQ8CMoR5T4g9Bnk7vkufWL1z+GXWXR2K+l22GP4M zUnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PDEUjjOBUJS5iHQaBAG+Z33WI0zFNAprAtoJyuCQ0PY=; b=jjw7lh7GntYJiREvancqIkeS1e1lVIutkRFONfOArFVWNK/LPNEXnioCV9Pu9yPMYM ZRpYipWvC3piaNi1VQ2UNHktIkHOJmwXfGkyud8Cy7/W89c0uj4t+aNOYc0SHQtaEwWV Us86ydlKWtDDJ8og8UOgjhfFUUmOaqrVIz68P/aeXkXg6pX8ioN97i2Gvw1qlWYl75vP 2wfZPNUJlVXDrcy8fgfuS3zR1Lia77qDhaeFMT2bbX34BqhjrxDF6wHoeGD3oQY+uTpY p5QGUaF3nIa8IBk/DnmVUTbyzNRcGxLFlwBkusXHwkV3VfGzy39gGCyG562ogIUwI41T g0Ew== X-Gm-Message-State: APjAAAUPs/84zooq+94V7sHc+EXmNY8Tg3K9KvLv/Vn6kstfSFVXd99V KvDVo9Ol42Au6BVwb8WdVjHT6A== X-Google-Smtp-Source: APXvYqzkkltCyacB6OrKhqu88JBHdO9W+dZpAtceJBpmMRPPTu1skXnjUWJRxuUbEzEFar3+9FUfjQ== X-Received: by 2002:a19:e002:: with SMTP id x2mr15509153lfg.16.1557775417282; Mon, 13 May 2019 12:23:37 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:36 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 17/18] arm64: dts: Convert to the hierarchical CPU topology layout for MSM8916 Date: Mon, 13 May 2019 21:22:59 +0200 Message-Id: <20190513192300.653-18-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_122339_156243_4703CEDE X-CRM114-Status: GOOD ( 14.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Brown , Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , Andy Gross , "Raju P . L . S . S . S . N" , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer In the hierarchical layout, we are creating power domains around each CPU and describes the idle states for them inside the power domain provider node. Note that, the CPU's idle states still needs to be compatible with "arm,idle-state". Furthermore, represent the CPU cluster as a separate master power domain, powering the CPU's power domains. The cluster node, contains the idle states for the cluster and each idle state needs to be compatible with the "domain-idle-state". If the running platform is using a PSCI FW that supports the OS initiated CPU suspend mode, which likely should be the case unless the PSCI FW is very old, this change triggers the PSCI driver to enable it. Cc: Andy Gross Cc: David Brown Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes: - None. --- arch/arm64/boot/dts/qcom/msm8916.dtsi | 57 +++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi index 0803ca8c02da..1bb33f0326b5 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -110,10 +110,11 @@ reg = <0x0>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; }; CPU1: cpu@1 { @@ -122,10 +123,11 @@ reg = <0x1>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; }; CPU2: cpu@2 { @@ -134,10 +136,11 @@ reg = <0x2>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; }; CPU3: cpu@3 { @@ -146,10 +149,11 @@ reg = <0x3>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; }; L2_0: l2-cache { @@ -166,12 +170,57 @@ min-residency-us = <2000>; local-timer-stop; }; + + CLUSTER_RET: cluster-retention { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000010>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-gdhs { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000030>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; }; }; psci { compatible = "arm,psci-1.0"; method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD2: cpu-pd2 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD3: cpu-pd3 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CLUSTER_PD: cluster-pd { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_RET>, <&CLUSTER_PWRDN>; + }; }; pmu { From patchwork Mon May 13 19:23:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10941643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EAD81398 for ; Mon, 13 May 2019 19:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7044527F94 for ; Mon, 13 May 2019 19:26:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6259C28421; Mon, 13 May 2019 19:26:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CCC5B27F94 for ; Mon, 13 May 2019 19:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2ah3CS5VSHddnGF+7kzkaGD/xnPjrOaa0UMck1fx+sA=; b=o1cUwkGf3Igtgq1rll+FC7H6+3 shG7ns0J4I3ACDPp+efgnYXBvt4KzufQ4EagtsgY65uTaSyNEIysyFmHuqyUy44IrpGAgR41l0Q5L DFMy3qjUIpA5hIBATRahtKB4/gRLQ0ZvFJtk2+13hHDuYtVmDO9feOZLT6CYADuR37w6VJlP+o649 XX8cSh/5mfDFaDuPnW+6gpDfslttrFLzTdbvumimBc/JZ8CkMRd6wi57APG8g0b+t0CrfCBjWmEh/ wUn8FcS1IRhB2luPoiNa18Q0uby5/ck8EKojW63Md9k1BieJkTwjrNeK+cA3tHb4BrswbOMYX0pQA IBsCL7eA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGaP-0005tu-Aj; Mon, 13 May 2019 19:26:09 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGYC-0001jr-G3 for linux-arm-kernel@bombadil.infradead.org; Mon, 13 May 2019 19:23:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7AxPd/WiAkEtzi6eC4zcfxrPuKGzl2d+dQ6Z4/Ng9yA=; b=MTrbaEznbgf+H98qWLvM7EzEI 6RQxReJ8+oGQR6XekYwEd+my2aSbzIwxtUyUeKAx2m8DF1VUgOASB9Q36diBB8b8+iRTHIqWMJWyo 4dEEIsvKKZOuO0f6rKQYdKSWpbijj6N6//ZBEsXvwPO0W5+5ufs3PxTA6vbLq+AVmocn9X9ZiUGfS jnKLFCfoquqLKpM6bm/9U1D/mu6h+mKYmbCHBmXji5n3g+ECPVlVVpzP6KG/VjGRla9Uq1Df5y4FM k6mjQWdVKK7Vn99hQfcoXtau2geWjcw+AimjiVBlXCJamlsHZw/DhNTYTVDwSqB26zUeHyxznmvDb 5DXwuGV3A==; Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQGY8-00010b-Sk for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 19:23:50 +0000 Received: by mail-lj1-x243.google.com with SMTP id m20so316428lji.2 for ; Mon, 13 May 2019 12:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7AxPd/WiAkEtzi6eC4zcfxrPuKGzl2d+dQ6Z4/Ng9yA=; b=iguEcn8d2UHmA1BdPS+ybI3lkwBDS3Ab7tjgLTOWKG6wZ7qEdUTtbHKOqgM2Pnvm4B Xofw8r8SJPdY+sJxTtVFiOGqhI6kONaT2HlWPLlUPTFxNHUtX5OLL4bifccr+S/yXa3L 1874f/2ZGLG1PlPpnMLUejT0OAYu+L+O/+Tjquwfhc9n4SfDn/aZgcGK8cGVd1V0uzUf PPof97i8Xu9/kDaXfsu5Hm2b0l3KZKU/pEG+zdRjUSm4VqyLizf/dMOcOLG7wEsnVQ0t p+FWaZl+/zA11ABliZ+oXMfD7J1aEnNIpgO0Q9nWUTv9CRs6+XpZ0/jLRxkxzf+u27O2 FmAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7AxPd/WiAkEtzi6eC4zcfxrPuKGzl2d+dQ6Z4/Ng9yA=; b=JCYv9nbmxTo0snKnFPza9FviWbQTxU/Lxe4MiiFJk/nB+m/lRBa7AGuThBqBLEIdiz x8zYVoCXOpmrd2DJ3VfmugXx/p/Bnz+sdea7SGkcfj4zMTji57/AfAyvfVI4ob9OIcF5 QGnPIw3zNbQQYZqTW79aQCmCItEGWt5qSSG2Pwgcn66w+XZsz8hsuKDB6vR1k3Q/TpzY VeOzSc3PmVR2zD/M3aE48EJF4F8KB+EpIpLQzYZtTdxC0qqABqrs5OkvjOhOjpkWNOfU X19Y/gRPtwG7hgKfCTRvZxfoUCVFJEce7SeET/m3UMqiEIJORNy+0hLe2gvGYVTS+n22 zTcQ== X-Gm-Message-State: APjAAAVKT7SRdE5y/HqEEbe1C9Xz7tgsEVO+aCXL+YAdD4AAfAWz5Wcc XLVGsj2J6+SjG7pVs/eIAeP9OA== X-Google-Smtp-Source: APXvYqwxMWB7/4WyFA59ijUF+6dp1ja8lpTuNpIG+hVBnaOO/pbLdkkOZsUgbqrpPxXYczj1YuOnIA== X-Received: by 2002:a2e:309:: with SMTP id 9mr15762950ljd.114.1557775419346; Mon, 13 May 2019 12:23:39 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:38 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 18/18] arm64: dts: hikey: Convert to the hierarchical CPU topology layout Date: Mon, 13 May 2019 21:23:00 +0200 Message-Id: <20190513192300.653-19-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_152348_942937_D9E08B7D X-CRM114-Status: GOOD ( 13.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Amit Kucheria , Bjorn Andersson , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Niklas Cassel , Souvik Chakravarty , Wei Xu , "Raju P . L . S . S . S . N" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To enable the OS to manage last-man standing activities for a CPU, while an idle state for a group of CPUs is selected, let's convert the Hikey platform into using the hierarchical CPU topology layout. Cc: Wei Xu Signed-off-by: Ulf Hansson --- Changes: - None. --- arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 87 ++++++++++++++++++++--- 1 file changed, 76 insertions(+), 11 deletions(-) diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi index 108e2a4227f6..36ff460f428f 100644 --- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi @@ -20,6 +20,64 @@ psci { compatible = "arm,psci-0.2"; method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD2: cpu-pd2 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD3: cpu-pd3 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD4: cpu-pd4 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD5: cpu-pd5 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD6: cpu-pd6 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD7: cpu-pd7 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CLUSTER_PD0: cluster-pd0 { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_SLEEP>; + }; + + CLUSTER_PD1: cluster-pd1 { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_SLEEP>; + }; }; cpus { @@ -70,9 +128,8 @@ }; CLUSTER_SLEEP: cluster-sleep { - compatible = "arm,idle-state"; - local-timer-stop; - arm,psci-suspend-param = <0x1010000>; + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000000>; entry-latency-us = <1000>; exit-latency-us = <700>; min-residency-us = <2700>; @@ -88,9 +145,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; }; cpu1: cpu@1 { @@ -101,9 +159,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; }; cpu2: cpu@2 { @@ -114,9 +173,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; }; cpu3: cpu@3 { @@ -127,9 +187,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; }; cpu4: cpu@100 { @@ -140,9 +201,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD4>; + power-domain-names = "psci"; }; cpu5: cpu@101 { @@ -153,9 +215,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD5>; + power-domain-names = "psci"; }; cpu6: cpu@102 { @@ -166,9 +229,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD6>; + power-domain-names = "psci"; }; cpu7: cpu@103 { @@ -179,9 +243,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD7>; + power-domain-names = "psci"; }; CLUSTER0_L2: l2-cache0 {