From patchwork Thu Apr 12 11:14:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133239 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573387ljb; Thu, 12 Apr 2018 04:14:40 -0700 (PDT) X-Received: by 10.46.135.214 with SMTP id v22mr404916ljj.94.1523531680156; Thu, 12 Apr 2018 04:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531680; cv=none; d=google.com; s=arc-20160816; b=sRBJ26to6aCce8DGiCBljILdQuI5Tc2IWpbgr9mJirlaoqR4jBsK31QtwVlk4cD7jX iTcdrhfjEN9O5q+y/IoFZ/GxGrE4XyWTjZlIQmIPAsn+dTEZVyl7DvX0b13IdtEq1k5M 82EOcY03yRx2HPTg6Li/flXghfFkb9tYzayMkwXpg/vvR1Kpc7oAxINSydDCC1E7FRTb vKY68gqRkTSMJT+qe6gDnsUfNRUT5xLIkHWNkbmG5m7rWXJHaIjqzgr6eeLiy/S5m+cz qQ5xwiAsxlJ3QQ0JLw5xBu2oJH74vr71UaZ5Sdn105utY/+/eA7GQol88Y3y3zgHYH6X vJ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XHPVBb922TA1uGb222Hxlm4AdEoDZBjgQ2Eka3bpJ8w=; b=zXcPiojGMoud11rnBwyLO5mFbuqjy8Ni5xd5HOfJB6+LmNX1I5Q0w2lg8VTXa69zqv jUfzr8tyX2pEX0bp1Yx9444clFJTrfQoyimm0UhVh3PA0xDB1iZ9fo5OEQKLlOdtj8BJ LQEnSGzf2kefwbcYczJz/Yw6uAJWXk2wVrg309yq8y/FoDPnGjWdkydVp1tYiNZ8xJ3K nQERRGUq0DMuQdMCQFhoMHxF9XxykEpMEPVWRZR6S/dJdGXuxfnEaUvXyClOwULjIyTz g5cwpyIizdVBV8fVnIveM+ZZ64G1FfE4hfKtMOp/3O5oulOB2UIOab0DyhrHm0mtVKdV +q4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fS8hsvGo; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s22sor905225lji.78.2018.04.12.04.14.40 for (Google Transport Security); Thu, 12 Apr 2018 04:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fS8hsvGo; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XHPVBb922TA1uGb222Hxlm4AdEoDZBjgQ2Eka3bpJ8w=; b=fS8hsvGop8Bsgb6yQEOWHBdFib6VPln3gzYgN0qi9klYlzUTxc0Bbs0J2+cmm43CIY lbTICJOy5TaFMxBjyEu8DN3ba7i6KdcIkbVNkTLqtBTcONL9qXjeBlDtIB4tAUdzMgao mwZmOdktzkihRJOL6g+dD75DxivvmSIMzfgYo= 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=XHPVBb922TA1uGb222Hxlm4AdEoDZBjgQ2Eka3bpJ8w=; b=aJ7F3NrVdwx9CDNa11gkClnuLyyWTMgpfiHk3vxtjqlnNGdq/emcu07BTGjBxwQNBF YwtOI4TXm/uDJjWSI5umFt3yqNxrjKvCp0gTTbXzMFx0utN1RCOa2fgoPjW1GAM4Er1P OWOdcrPUNcUTcFaM9L5hw1rWK9jiz7fjRQ7y8YyKYjEuJ33ZsLhnW4NnStfX6Xb0njVf FFvN8x3DyhUhkIHVydKhwDw2cv3hxK7UX+aD3WudbcrSMr6eoWKdOT2QX8WWrzcEztq+ 5n2R0uL1kBvjXrODQsHOE508jlACHrrfJi+smkPXooyX7NQqMaBvvLZTc5XrayXGrLak jmFQ== X-Gm-Message-State: ALQs6tA6uq/pSjTe6g1XT6eSDMgyAHODtugKtqOQoZWaG0u0w44qmKmY Yz1XW7P887uId3qAQ4BA9s8umXNj X-Google-Smtp-Source: AIpwx4+yvJ6j8ntmMX+75QrNZFlmH+qcQJuhMtQko+JV/cz0dhHPv7NLifnykMzBkUg4kXpwCOE28Q== X-Received: by 10.46.144.72 with SMTP id n8mr411094ljg.96.1523531679941; Thu, 12 Apr 2018 04:14:39 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:39 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 01/26] PM / Domains: Don't treat zero found compatible idle states as an error Date: Thu, 12 Apr 2018 13:14:06 +0200 Message-Id: <1523531671-27491-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Instead of returning -EINVAL from of_genpd_parse_idle_states() in case none compatible states was found, let's return 0 to indicate success. Assign also the out-parameter *states to NULL and *n to 0, to indicate to the caller that zero states have been found/allocated. This enables the caller of of_genpd_parse_idle_states() to easier act on the returned error code. Cc: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 1ea0e25..c2ef944 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2331,8 +2331,8 @@ static int genpd_iterate_idle_states(struct device_node *dn, * * Returns the device states parsed from the OF node. The memory for the states * is allocated by this function and is the responsibility of the caller to - * free the memory after use. If no domain idle states is found it returns - * -EINVAL and in case of errors, a negative error code. + * free the memory after use. If any or zero compatible domain idle states is + * found it returns 0 and in case of errors, a negative error code is returned. */ int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n) @@ -2341,8 +2341,14 @@ int of_genpd_parse_idle_states(struct device_node *dn, int ret; ret = genpd_iterate_idle_states(dn, NULL); - if (ret <= 0) - return ret < 0 ? ret : -EINVAL; + if (ret < 0) + return ret; + + if (!ret) { + *states = NULL; + *n = 0; + return 0; + } st = kcalloc(ret, sizeof(*st), GFP_KERNEL); if (!st) From patchwork Thu Apr 12 11:14:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133240 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573414ljb; Thu, 12 Apr 2018 04:14:42 -0700 (PDT) X-Received: by 10.46.136.77 with SMTP id z13mr377662ljj.126.1523531682030; Thu, 12 Apr 2018 04:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531682; cv=none; d=google.com; s=arc-20160816; b=03aRvVB4QWBplFk7Iwk7Qe1EYXdNpOVh1Dd42AJ6GKsgwr8B98Z4CLJkP5iLLs4ZkN PohpYR89gzrN64XCcT1Y50u0td2afqXEeowctBB1ctz8iN7OhXPXWpb+p5zONc6+L82V 2FhOXiueVXPOFJZf71AqyftPl/q7OKuduRgUWjRbcsUUft9iCKfNYjUiAF2FY1nQUOQ5 K0RFnx+7bMp74jLNzhUJLSWOo9yiK14maGLpBBRwg0UamSlMITrmVq9qjZ66sQ0x6Yso n8Tu5nFYCRuYIMxEvJ/CPRcEWalkMgyxFyVYVpQHeFYHWlOfbh1s3defUGLckj305rmp 0AqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hSa1vuv7p5LGnqIFGONCS9906USFez9Y+cts+oPVryk=; b=MhxsbHkZ7YjPxXrmWMyglIY+ACtAH7qs2bgcGDjX7PBosY3oDSinp8rqPkFd248LDh uMCAqAYUlEXJGj1JGcEPPXVDJftIBgQomO3dvWwKbM3JK9SkkdIktXoyC6Oa5X0AhWg2 tSTmv/bupaZU+t0oC4Cg1s5eRFTRIOGah2re8isu7wvxEKeUIfiedLuW9aXjNSNLfE23 cBsm3jHWiSXmJEz33pnNiCFxV+GoKZZ6A03lH8VM3lLs5fjMcE6VHLSYPw7Ei16Sxdlg 9qFMn2/7F0dM2MWcdg8Ic32LM+kl9do/qRggN0Gf+gwgezh3XvezCyG7XpgSbtPt71NC 3K4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RbtSddt9; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g141-v6sor936398lfg.20.2018.04.12.04.14.41 for (Google Transport Security); Thu, 12 Apr 2018 04:14:42 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RbtSddt9; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hSa1vuv7p5LGnqIFGONCS9906USFez9Y+cts+oPVryk=; b=RbtSddt9aHlgmWnazYvtL7cFKdvDagqywsqLjl7uFpgohSHcX8p/1vctI8RvPIxGRv 3pOhGhr+rY2q4lfbNTvTdSJrhJgnf+KYPGUyKvQ3XhI3ihELb1H+vAGg+95ylzRaFbF+ NnlKY7mtB4l8YpCTC65BLYKg2AihPyX9xX8zU= 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=hSa1vuv7p5LGnqIFGONCS9906USFez9Y+cts+oPVryk=; b=i6NJNXsU5e/DJUdrceJKgwex7d8KiwHio1vChmoRrYrxc3SS2m5h+V5n5BqMXl8nMI mLrQ/JiWe9gUsh0YZt3+4tY+J6AY/sBnss2bRR3GPgSKicdeiE2AFFXCs85jHCn72zv+ 6XabxsjfZ8i1iPqHn3kTt3LmfZsVZ1R0huFR5cap1zs3YtubQtucSA6elml749gpt5CJ AnIuh0nlfmqhDRv4zXO2MavvjfqPR0kcOILbrqaqTk49Db8KkP58Wd+d5wf3fbs2BBkn f3K3hyXbOCDCAYclALkZqwHDNc/XbGYIYLWwMN02+B7B+HVFroLcrRw4L5oAaRMQMT3K Hr+g== X-Gm-Message-State: ALQs6tDR/bRDMZk1xHdo96vCAbSkPVSZzb7o0Kb2LTH5fGPxFlBE0Nh/ zCGJPisN+RP6gmoEpkmtTZlbyxrJ X-Google-Smtp-Source: AIpwx4/kN3Zg2iIgfZ3XjIm1cwk0RfPJetxKc63A1N0ZfQcHynNv8b1DqqOStnQesU8Bl4L01LJeDw== X-Received: by 2002:a19:7390:: with SMTP id h16-v6mr508362lfk.67.1523531681797; Thu, 12 Apr 2018 04:14:41 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:41 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 02/26] PM / Domains: Deal with multiple states but no governor in genpd Date: Thu, 12 Apr 2018 13:14:07 +0200 Message-Id: <1523531671-27491-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> A caller of pm_genpd_init() that provides some states for the genpd via the ->states pointer in the struct generic_pm_domain, should also provide a governor. This because it's the job of the governor to pick a state that satisfies the constraints. Therefore, let's print a warning to inform the user about such bogus configuration and avoid to bail out, by instead picking the shallowest state before genpd invokes the ->power_off() callback. Cc: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index c2ef944..9aff79d 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -466,6 +466,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, return -EAGAIN; } + /* Default to shallowest state. */ + if (!genpd->gov) + genpd->state_idx = 0; + if (genpd->power_off) { int ret; @@ -1694,6 +1698,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd, ret = genpd_set_default_power_state(genpd); if (ret) return ret; + } else if (!gov) { + pr_warn("%s : no governor for states\n", genpd->name); } mutex_lock(&gpd_list_lock); From patchwork Thu Apr 12 11:14:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133241 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573435ljb; Thu, 12 Apr 2018 04:14:43 -0700 (PDT) X-Received: by 2002:a19:e501:: with SMTP id c1-v6mr5482641lfh.65.1523531683574; Thu, 12 Apr 2018 04:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531683; cv=none; d=google.com; s=arc-20160816; b=uFNg/CPsWmD9Erd92SB59FoHGxNdO2KQuR7H+VzcM0rGGd15m+4RgFogs35i5qmO3r qaXSo/2mh0d25J/Pce6HwanbGNKRDg2SyQc02SJTzj4UjiC/70U2DnD5hUPWPJw13lQL vH8DqB4qaavsjSpq0F98WtKhjHsG5bi2pghkUs0TJcsJda33Ns5FFwU4faDheetyv2gY 8w2xBF0m1rN4DCZKJz1x3Zh1UTMwZHXNJ+TzcJ9EdHQQLeNWk3o8evTMelQpqlE+cGvn N9Hb4ZvkZyTmQNTqXPjArfdqV32Xy1TzakjPS8pVCtDIN+kJ96CPaqMUYngRpl/b5SVt QMCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=sRgwaO0IKgB9yJSI19b85yPVQXQE5lDtfI6PCW5MVn4=; b=QwGi4qNpXUbo0dxSPfuC8f2ww+XZpKqnzx5JWVTBwaGvWzVua5ixMnTqfDVvhpejjD //KO3dCI/ohCm0nysrjLXk8sIfWXUv5tLJjfVuqbZla47bNqTCSETyPNJZI1Q1uEq7se /KmxA4bbOsbcy3ZE3gE86rqtEEOdufAQanLEpEQe2E41YOy4wsTflTMzzplx3ZE/SGIP elFbVqmUKnvpZIM8UF/2yTZOvXYPcUjR/FRKQ7QoOIH9mPPr2DkLZsMrRceYoD/M9Fwy C0rT6620/7jNeN64XKGLH3F1T9J6AbvBx5W/BsCg+hrfARYmxI2gQ0eYEGlJrjyBxCuv UnLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kKdDBWuM; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a6-v6sor843192lfg.90.2018.04.12.04.14.43 for (Google Transport Security); Thu, 12 Apr 2018 04:14:43 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kKdDBWuM; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sRgwaO0IKgB9yJSI19b85yPVQXQE5lDtfI6PCW5MVn4=; b=kKdDBWuMfqDzhDLpyWAFj4ZgRwYG6gqEGasHavhuFRxKCN6/DhOaFn+uFN7+bZ6DuD gz4XxRQrkYzK1jv650IkIPEEse1aKej6sDcY61TitGic1C2fO2lxDzw9RTQtyS5lNQMc ZGpaA52Xvy3WydbuSVblmol0RfJfTC68GfwV4= 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=sRgwaO0IKgB9yJSI19b85yPVQXQE5lDtfI6PCW5MVn4=; b=EpBlvUOso3FcJivfZZPMl7/TNBpYpx6LfozOlA/o5ktfqAlnDP/SXp5kSk6i7zzLzF eZtpr6GV3gbBjUec40XEzOWZb5pMnsJGhAzcuNFUlSM49W7vxSFPI/zkWfxFf5S4zIiZ FmC+g2M81s0KzBP/Jp8PFBHwXRttguiacFXd7EI/4ECyJ9IrYuGsj8NRESLtDapKzGlv R0XwJFOB4i8k3JHtzDy7CqEe9gpStuyWguBm45/U/nLUzCzmx7PeO9rhRueHkPhYUtqB Wecz1QcO1CU4mIGURhwL5mlFjiYfjGzf8qgpV3mzodD+o4qPnq2rqvZhuRF11BY1zZeR 3yOA== X-Gm-Message-State: ALQs6tDmuZRnlfoWDXyZ4wbuq1TSOOMkqxxINpsXIWpp6jrNHQMygyhM M1RKzQv1opuKiIQfGf8G/FmB0GfT X-Google-Smtp-Source: AIpwx48H62O5dUfhKHlajxQOos/EtNVvtFiFfb7RPckZpxTZwjIs6/wBKV+cFUm3e8TRgfq6sEKk4g== X-Received: by 2002:a19:12c1:: with SMTP id 62-v6mr3041076lfs.21.1523531683377; Thu, 12 Apr 2018 04:14:43 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:42 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 03/26] PM / Domains: Add generic data pointer to genpd_power_state struct Date: Thu, 12 Apr 2018 13:14:08 +0200 Message-Id: <1523531671-27491-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> From: Lina Iyer Let's add a data pointer to the genpd_power_state struct, to allow platforms to store per state specific data. Cc: Lina Iyer Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- include/linux/pm_domain.h | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 04dbef9..55ad34d 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -44,6 +44,7 @@ struct genpd_power_state { s64 residency_ns; struct fwnode_handle *fwnode; ktime_t idle_time; + void *data; }; struct genpd_lock_ops; From patchwork Thu Apr 12 11:14:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133242 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573466ljb; Thu, 12 Apr 2018 04:14:45 -0700 (PDT) X-Received: by 2002:a19:d9d4:: with SMTP id s81-v6mr5175370lfi.49.1523531685741; Thu, 12 Apr 2018 04:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531685; cv=none; d=google.com; s=arc-20160816; b=wsyMV+pf+BMD05HtS5CcumMMvxqg08XbxWClc5GoaJGPP6Z6NlnYcn6K1dQruoX/Ll VrLHRcNk6uRb2G2Opa6mEDdE5aXlDiygysj0pFYFY0WLjoZUlK6fKAKKcw1sh4Vsaw5v YREOV+lG68eCn9NbQoMbuJEbJvvq0YAjGncfM+giocCVtQmpYu6EW9G1FR/bOWG1SYHR 6Bz9F9mchggbDPl/OJwbqLaMRKDEyYVqNhPigD3SuP0uVGC0+WG346ycaTVZpw4mXt0O g/jUkQBGhB5CWhze70l6ZoKJacdQi/p4T5B1WhJXXWXOZoEmk098YyQfGHyrw7jMxh2e 2VrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ep8w3XyIku7Xg7WOU6YAHfRgEUqb1IPra7Q7nLKsmvU=; b=JWnNnsMSgSC2poFkvqQM9DR1Try+GRYpQQXR1ypIqZQHFcFK+sWg0DGh7P1WqLIhzj YIL058VLmZ+fXb/m+PdoNNAe74PthhBSpIF1+okYqnJtH/oMQzyifdV68PT+gKSk/Y4E CLNqOD+jyOyQ9N5o2ju5M0dZnkDjF8JYe73lhpj7EWEOAYYFgFcEPyTeyO86Gmmba0hZ puYDLCPwJhU9GojA6OPNPeko2a4Xj9FzbbZ9BaSikrYHWEp81EJ1Pidh6v5F6IIYRhwz L/noSzlvT9fkVEWF1qEK4nM/n1QQ/P69Fnnzfw/uNgAKiZ4HheFCf2/OQqEW8rDjQ3aW otvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Im7e88Z0; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g77-v6sor949959lfl.87.2018.04.12.04.14.45 for (Google Transport Security); Thu, 12 Apr 2018 04:14:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Im7e88Z0; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ep8w3XyIku7Xg7WOU6YAHfRgEUqb1IPra7Q7nLKsmvU=; b=Im7e88Z0gYEuCCSqRUgOqQIckI7CnYMmK/eZljGPSP6xOVZ7lkHd4A+fbaXcagqqap ZGLCkR8YX0FPRQDiFtkDb+wFMiUaBLYpcELL+EkiQ6Zzb0qfdgQQEeoHhT4/oeHnABqp B7SKq8RBsEtspg0kOfdCoZ0P8UUFTkTmmeyo8= 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=ep8w3XyIku7Xg7WOU6YAHfRgEUqb1IPra7Q7nLKsmvU=; b=OJpSet9lYZe5pFBpuM9BBVI48kgIm3RM9ira7uZBXJBjF/l2zG+5eiOICFYcKLRlOd tBg987q6g1pF2HPsorQVX4hcEsld7ePZ1IP0bTTPESkDM0l1CAZ4RxGVQsVINveI0D9k hmMlSyE7j7WA2B/D27iaAl9iSxCYfBHiAfdFlAm1ewOTyzpNCmSyMaBCc35ZG3wgDi8I lbYeG4ANKVZGfUgADMYx6Z90ee2HtUWqQyPn3hE2RqqI1HSUHnaWk0EvX4i/zgytJGYf RZLW0dJmMhASe3CxJhLOhq8bquveCYvRP+dJzprZrgGkT/O8maoP+TBioQlSvBjnmdOe zq/w== X-Gm-Message-State: ALQs6tAwou5T2KUZAHsotw3tzOnhwGBKSG6Dmn2gZhjGvebmMwGlDHH6 NKjRUeqo+nEngRO7nAkxEmGgjv5C X-Google-Smtp-Source: AIpwx4/G3bzENOcM0wSL0k6p8UtTUOq0ZuHsbaScpkrZ+HbXKFLWaTBLGXJdNbaCGXQNaJCN7LRXRg== X-Received: by 2002:a19:5308:: with SMTP id h8-v6mr2914230lfb.85.1523531685345; Thu, 12 Apr 2018 04:14:45 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:44 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 04/26] PM / Domains: Add support for CPU devices to genpd Date: Thu, 12 Apr 2018 13:14:09 +0200 Message-Id: <1523531671-27491-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> To enable a device belonging to a CPU to be attached to a PM domain managed by genpd, let's do a few changes to genpd as to make it convenient to manage the specifics around CPUs. First, as to be able to quickly find out what CPUs that are attached to a genpd, which typically becomes useful from a genpd governor as following changes is about to show, let's add a cpumask 'cpus' to the struct generic_pm_domain. At the point when a device that belongs to a CPU, is attached/detached to its corresponding PM domain via genpd_add_device(), let's update the cpumask in genpd->cpus. Moreover, propagate the update of the cpumask to the master domains, which makes the genpd->cpus to contain a cpumask that hierarchically reflect all CPUs for a genpd, including CPUs attached to subdomains. Second, to unconditionally manage CPUs and the cpumask in genpd->cpus, is unnecessary for cases when only non-CPU devices are parts of a genpd. Let's avoid this by adding a new configuration bit, GENPD_FLAG_CPU_DOMAIN. Clients must set the bit before they call pm_genpd_init(), as to instruct genpd that it shall deal with CPUs and thus manage the cpumask in genpd->cpus. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 69 ++++++++++++++++++++++++++++++++++++++++++++- include/linux/pm_domain.h | 3 ++ 2 files changed, 71 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 9aff79d..e178521 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "power.h" @@ -125,6 +126,7 @@ static const struct genpd_lock_ops genpd_spin_ops = { #define genpd_is_irq_safe(genpd) (genpd->flags & GENPD_FLAG_IRQ_SAFE) #define genpd_is_always_on(genpd) (genpd->flags & GENPD_FLAG_ALWAYS_ON) #define genpd_is_active_wakeup(genpd) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP) +#define genpd_is_cpu_domain(genpd) (genpd->flags & GENPD_FLAG_CPU_DOMAIN) static inline bool irq_safe_dev_in_no_sleep_domain(struct device *dev, const struct generic_pm_domain *genpd) @@ -1377,6 +1379,62 @@ static void genpd_free_dev_data(struct device *dev, dev_pm_put_subsys_data(dev); } +static void __genpd_update_cpumask(struct generic_pm_domain *genpd, + int cpu, bool set, unsigned int depth) +{ + struct gpd_link *link; + + if (!genpd_is_cpu_domain(genpd)) + return; + + list_for_each_entry(link, &genpd->slave_links, slave_node) { + struct generic_pm_domain *master = link->master; + + genpd_lock_nested(master, depth + 1); + __genpd_update_cpumask(master, cpu, set, depth + 1); + genpd_unlock(master); + } + + if (set) + cpumask_set_cpu(cpu, genpd->cpus); + else + cpumask_clear_cpu(cpu, genpd->cpus); +} + +static void genpd_update_cpumask(struct generic_pm_domain *genpd, + struct device *dev, bool set) +{ + bool is_cpu = false; + int cpu; + + if (!genpd_is_cpu_domain(genpd)) + return; + + for_each_possible_cpu(cpu) { + if (get_cpu_device(cpu) == dev) { + is_cpu = true; + break; + } + } + + if (!is_cpu) + return; + + __genpd_update_cpumask(genpd, cpu, set, 0); +} + +static void genpd_set_cpumask(struct generic_pm_domain *genpd, + struct device *dev) +{ + genpd_update_cpumask(genpd, dev, true); +} + +static void genpd_clear_cpumask(struct generic_pm_domain *genpd, + struct device *dev) +{ + genpd_update_cpumask(genpd, dev, false); +} + static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, struct gpd_timing_data *td) { @@ -1403,6 +1461,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (ret) goto out; + genpd_set_cpumask(genpd, dev); + dev_pm_domain_set(dev, &genpd->domain); genpd->device_count++; @@ -1466,6 +1526,7 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, if (genpd->detach_dev) genpd->detach_dev(genpd, dev); + genpd_clear_cpumask(genpd, dev); dev_pm_domain_set(dev, NULL); list_del_init(&pdd->list_node); @@ -1693,11 +1754,16 @@ int pm_genpd_init(struct generic_pm_domain *genpd, if (genpd_is_always_on(genpd) && !genpd_status_on(genpd)) return -EINVAL; + if (!zalloc_cpumask_var(&genpd->cpus, GFP_KERNEL)) + return -ENOMEM; + /* Use only one "off" state if there were no states declared */ if (genpd->state_count == 0) { ret = genpd_set_default_power_state(genpd); - if (ret) + if (ret) { + free_cpumask_var(genpd->cpus); return ret; + } } else if (!gov) { pr_warn("%s : no governor for states\n", genpd->name); } @@ -1740,6 +1806,7 @@ static int genpd_remove(struct generic_pm_domain *genpd) list_del(&genpd->gpd_list_node); genpd_unlock(genpd); cancel_work_sync(&genpd->power_off_work); + free_cpumask_var(genpd->cpus); kfree(genpd->free); pr_debug("%s: removed %s\n", __func__, genpd->name); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 55ad34d..29ab00c 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -16,12 +16,14 @@ #include #include #include +#include /* Defines used for the flags field in the struct generic_pm_domain */ #define GENPD_FLAG_PM_CLK (1U << 0) /* PM domain uses PM clk */ #define GENPD_FLAG_IRQ_SAFE (1U << 1) /* PM domain operates in atomic */ #define GENPD_FLAG_ALWAYS_ON (1U << 2) /* PM domain is always powered on */ #define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3) /* Keep devices active if wakeup */ +#define GENPD_FLAG_CPU_DOMAIN (1U << 4) /* PM domain manages CPUs */ enum gpd_status { GPD_STATE_ACTIVE = 0, /* PM domain is active */ @@ -66,6 +68,7 @@ struct generic_pm_domain { unsigned int suspended_count; /* System suspend device counter */ unsigned int prepared_count; /* Suspend counter of prepared devices */ unsigned int performance_state; /* Aggregated max performance state */ + cpumask_var_t cpus; /* A cpumask of the attached CPUs */ int (*power_off)(struct generic_pm_domain *domain); int (*power_on)(struct generic_pm_domain *domain); int (*set_performance_state)(struct generic_pm_domain *genpd, From patchwork Thu Apr 12 11:14:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133243 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573492ljb; Thu, 12 Apr 2018 04:14:47 -0700 (PDT) X-Received: by 10.46.115.8 with SMTP id o8mr385341ljc.99.1523531687340; Thu, 12 Apr 2018 04:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531687; cv=none; d=google.com; s=arc-20160816; b=wvPAp4qu7zshMDPE+pN1NEQxUAFuRdgp5K+NHdEIlsCbyIVnBD9ani5qxPg8/yFS9Y EZl6PLDS1mfhABELypsurz3YzJdSp+TX/fg/ULsRKyXjwFNHzw5wvqSgBNR+E7eKXLsB zp9yi8QwrKqszlNLPtzhQNnpRNXwu/vW+FLd6XyWU5KH12d13J3ejB8sa10DjRwfM87Q 9/0Z22DoBaO+IHR3pSG0Rzw102xf5OsvW88R1tOsjFTX6KPnDx6p8kuII69/qKhrYsQ4 ZRzaeWT8qQOk1tftl50+XlJzduwquo9LxDl+1tzgnxzBgIua6wnuBsQ+U98ChlYnynde PplA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=1O11apE6tR+MdI607Y0iNJFhJF3NsEpjqwr8dBVhhK4=; b=q0+tm9zVYNsZqrvy7JJ5Z7aKT6d4MXgB3Qn4tUzPm4qZzektkuzHKCYh8yTMj38TH3 qGNapGzCmHmwR5lssdkQTzsMECbzqSXUtHm1wceDuuZC6WJsh0rrcGvOXCJ3LOHxfZiU 8Ctnwbn61OHyR6drpF9/z4D1FPw1HfRAoEIJ4Pl9eWtJUDlkz9UAFQAUnpoOcD0aEwwe xBJeQGIwcvb0yvqJNDh9y6DKYZu2JoKhPzC+VvnTDHL+idZHLxNwaYXqC8Brd4Ctw/ow 2JE9r9L2Zr2Pyq4ACml1zUvyD3JTmtMrP+RLqigBECo1F30yg9auaeS/+gzWmntiuHjL 2N7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VZfh+xXH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c8sor873983lji.23.2018.04.12.04.14.47 for (Google Transport Security); Thu, 12 Apr 2018 04:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VZfh+xXH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1O11apE6tR+MdI607Y0iNJFhJF3NsEpjqwr8dBVhhK4=; b=VZfh+xXHn0dlNDSUDSmubXn13syh5V6LnILJj5xoBMJ/neglG7/+/mn9fvW4wv6smD GaAQGwqbZpp5DbQuN8EAyMJ2mmwKk1jj9CSHB3oWVljxA/CyBUDYaUbFyNY7RquYAfbS ofhvnv3WPd8hZTeu+fyV/RljksUMHmJ/9kr3o= 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=1O11apE6tR+MdI607Y0iNJFhJF3NsEpjqwr8dBVhhK4=; b=EqZFcDo9P5fP+6cUc1KVREjUpgas6AVAI2DelxfTurWKMPl4YSPnwAe1Jk2SUN+3bg wodtvjwhqgPkryX2mZFya0y2BQccVwsNh5cnEyCqcpxlqj6KOoqdv2a3lv3lGeqzisYF rnNL67/ytkEYnU6XdPRvlKclf5xfMxMtB63oJysVSgHIP8lnwksAWEIwrXZed/8tf10Q XLKtrrigssOzKlMmA8Jp8gejefiVK9cuRCogBi2lKo9vv1374lOWZOMbTPwp5o1b4WrE j+uS45XmAoFKvClkCe0EsqGajFcxwDnS3Wyu3X6ZNIJvY6WYCN2uRXcKWsLH/kTzu8gV plZQ== X-Gm-Message-State: ALQs6tDAb2POHkVoSdpUElh5mmWEpZwXR5juI7S3YM9M572vQ8quk7Up umBrx/yKp5fZrQsPRzTVFSBLoCnD X-Google-Smtp-Source: AIpwx4/0V8HZN70rL8Fj2S07bx6mTOUose1TvpSMjV9sifAFsQzQaJ36wminW7+TuUo7tGGarCYssQ== X-Received: by 10.46.128.132 with SMTP id i4mr364037ljg.51.1523531687073; Thu, 12 Apr 2018 04:14:47 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:46 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 05/26] PM / Domains: Add helper functions to attach/detach CPUs to/from genpd Date: Thu, 12 Apr 2018 13:14:10 +0200 Message-Id: <1523531671-27491-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Introduce two new genpd helper functions, of_genpd_attach|detach_cpu(), which takes the CPU-number as an in-parameter. To attach a CPU to a genpd, of_genpd_attach_cpu() starts by fetching the struct device belonging to the CPU. Then it calls genpd_dev_pm_attach(), which via DT tries to hook up the CPU device to its corresponding PM domain. If it succeeds, of_genpd_attach_cpu() continues to prepare/enable runtime PM of the device. To detach a CPU from its PM domain, of_genpd_attach_cpu() reverse the operations made from of_genpd_attach_cpu(). However, first it checks that the CPU device has a valid PM domain pointer assigned, as to make sure it belongs to genpd. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 9 ++++++ 2 files changed, 76 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e178521..91ea9b2 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2324,6 +2324,73 @@ int genpd_dev_pm_attach(struct device *dev) } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); +/** + * of_genpd_attach_cpu() - Attach a CPU to its PM domain + * @cpu: The CPU to be attached. + * + * Try to find the corresponding PM domain provider for the CPU's device. Use + * it to attach the CPU's device to its PM domain. If attaching is completed + * successfully, we enable runtime PM for the CPU's device. + * + * Returns zero on success else a negative error code. + */ +int of_genpd_attach_cpu(int cpu) +{ + struct device *dev = get_cpu_device(cpu); + int ret; + + if (!dev) { + pr_warn("genpd: no dev for cpu%d\n", cpu); + return -ENODEV; + } + + ret = genpd_dev_pm_attach(dev); + if (ret) { + dev_warn(dev, "genpd: attach cpu failed %d\n", ret); + return ret; + } + + pm_runtime_irq_safe(dev); + pm_runtime_get_noresume(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + dev_info(dev, "genpd: attached cpu\n"); + return 0; +} +EXPORT_SYMBOL(of_genpd_attach_cpu); + +/** + * of_genpd_detach_cpu() - Detach a CPU from its PM domain + * @cpu: The CPU to be detached. + * + * Detach the CPU's device from its corresponding PM domain. If detaching is + * completed successfully, disable runtime PM and restore the runtime PM usage + * count for the CPU's device. + */ +void of_genpd_detach_cpu(int cpu) +{ + struct device *dev = get_cpu_device(cpu); + + if (!dev) { + pr_warn("genpd: no dev for cpu%d\n", cpu); + return; + } + + /* Check that the device is attached to a genpd. */ + if (!(dev->pm_domain && dev->pm_domain->detach == genpd_dev_pm_detach)) + return; + + genpd_dev_pm_detach(dev, true); + + pm_runtime_disable(dev); + pm_runtime_put_noidle(dev); + pm_runtime_reinit(dev); + + dev_info(dev, "genpd: detached cpu\n"); +} +EXPORT_SYMBOL(of_genpd_detach_cpu); + static const struct of_device_id idle_state_match[] = { { .compatible = "domain-idle-state", }, { } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 29ab00c..ccd7c94 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -249,6 +249,8 @@ extern int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n); int genpd_dev_pm_attach(struct device *dev); +int of_genpd_attach_cpu(int cpu); +void of_genpd_detach_cpu(int cpu); #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ static inline int of_genpd_add_provider_simple(struct device_node *np, struct generic_pm_domain *genpd) @@ -287,6 +289,13 @@ static inline int genpd_dev_pm_attach(struct device *dev) return -ENODEV; } +static inline int of_genpd_attach_cpu(int cpu) +{ + return -ENODEV; +} + +static inline void of_genpd_detach_cpu(int cpu) {} + static inline struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) { From patchwork Thu Apr 12 11:14:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133244 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573534ljb; Thu, 12 Apr 2018 04:14:49 -0700 (PDT) X-Received: by 10.46.144.2 with SMTP id h2mr367718ljg.37.1523531689201; Thu, 12 Apr 2018 04:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531689; cv=none; d=google.com; s=arc-20160816; b=mtDfxSl0IAA4wrUbPmLyTnRzkPkiwojS1p678nMeOP2c/gERB7E2vtO3dJvOXq5YNC vYNBtVyu/z5VNdsX91KyfiGa7VQmiiAFSHLt53sF9CyWWA9inOxJ7DeCOgb6MGPjtJcC S+DbAN46IZPSQiFoRF/IvHQFRZ+42rMjcZD3rz+fzZingiNGONXCKS7NavuxLS+a7183 XK4tDbkG2Q9IppQhAPlXZLOhL77qyIuLffJPgV/EpWO0PFWaXu4hpA4voVl9gBGQ+JLm 7SdSpcACLXJANzRX8J59kYOyGf4olVh1wvnyg5W1K1PYTDaLlb73LLKDShOHJnFbE+Pd cvcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=VN7v+B4AGDaJ9ZxTUGLB9zWuv/2axGua2g5DbB4+qJo=; b=kvhvN67MABlZoCPFfDHQr7nOilS7m2uSXhNTY3WqmpiwmtT0QKCJ/YHY3r9JRIULom LC85UxbKy4PWu8VfR/G3PQv6lOmvajJpyLkrGrwB0/IY9N2g93Ls2onVV/1cZIyHbId2 Pnls3BSwLPrpfBszL3Pjb/90kjMFrslxyQ9MzA/rNn/YaFwGHjY1CuwgB+LUV2Kjj9Ke 0vw0NL7ptrdPbKD8AmTM83KTkKLVy3bZVjbAvMFjZdwaheY9dWbgJop0l4YBPI49txqL lBe7/mfD1cvohy4m73d+9gC9iH71adWiSHQzwWuy5N/jfMHWgwAqFmuX/wITKhO7L5Px 2nFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrECZnYd; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x13sor892034ljj.87.2018.04.12.04.14.49 for (Google Transport Security); Thu, 12 Apr 2018 04:14:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrECZnYd; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VN7v+B4AGDaJ9ZxTUGLB9zWuv/2axGua2g5DbB4+qJo=; b=LrECZnYdgZ/2TmHf7jVrqc/fy5ZNRPebc9lVJniSXt3y4ekCcN3sD8U5b9q0xVxGyn KXALMYR1RfD0xwQFJXvIZzvcvs2W+0BV0cbGOawdtrONqYT0OcQVKXotAlOci/XmzH+A SZTOB/R51ax7CMsrvSjQulMt6fABENzAjDry4= 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=VN7v+B4AGDaJ9ZxTUGLB9zWuv/2axGua2g5DbB4+qJo=; b=tMB/YyNNBlIvBLCQ2ehxSZQOlVqEQckLfWr5LmJ+h9dXEgXVveRjuudaMg3mQvEH5w 3hOPLLSJNGefXkLNnWUkD55ThfSrpJ+3yoIF6RX0MDeiO29AFF4MSuSM1ojGuTAD3mOH JYxeXE+13Iw6xLhhH7/eRJAVJF0Y5lOPhFtZ5t90WETZKtxvEbHQZ9zwu5H/x9jnAoLI pqKgBmbNwCQt7h30UENCT1IV3gJbY9Cnq9cePGeVaponIO1eDB/Hav3J3aOfXFXgbLzg vgAu3dzrw/W3bnxDws5udKiSW9i//Cbyu3KWber4dKmGjUrOwK90gpql8vmRZZQ23Sxw o7lw== X-Gm-Message-State: ALQs6tDn124XT4zcYtb/Jwys+Y7ZmHKmFCw2Y1AoSxNGYiOncKkOF+y8 bWx/t1rWshYnh1TvgEKeIKuIDna2 X-Google-Smtp-Source: AIpwx4+tslMe9H1Owe/SLKdwUAGqpACQFO7hh60OKOG8TltPrcb7bNklVj/aRKOUyLZmDNM34b3KOg== X-Received: by 10.46.32.154 with SMTP id g26mr365887lji.71.1523531688934; Thu, 12 Apr 2018 04:14:48 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:48 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Frederic Weisbecker , Ingo Molnar Subject: [PATCH v7 06/26] timer: Export next wakeup time of a CPU Date: Thu, 12 Apr 2018 13:14:11 +0200 Message-Id: <1523531671-27491-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> From: Lina Iyer Knowing the sleep duration of CPUs, is known to be needed while selecting the most energy efficient idle state for a CPU or a group of CPUs. However, to be able to compute the sleep duration, we need to know at what time the next expected wakeup is for the CPU. Therefore, let's export this information via a new function, tick_nohz_get_next_wakeup(). Following changes make use of it. Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Lina Iyer Cc: Frederic Weisbecker Cc: Ingo Molnar Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- include/linux/tick.h | 10 ++++++++++ kernel/time/tick-sched.c | 11 +++++++++++ 2 files changed, 21 insertions(+) -- 2.7.4 diff --git a/include/linux/tick.h b/include/linux/tick.h index 389aa25..d341811 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -125,6 +125,7 @@ extern bool tick_nohz_idle_got_tick(void); extern ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next); extern unsigned long tick_nohz_get_idle_calls(void); extern unsigned long tick_nohz_get_idle_calls_cpu(int cpu); +extern ktime_t tick_nohz_get_next_wakeup(int cpu); extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time); extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time); @@ -151,6 +152,15 @@ static inline ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next) *delta_next = TICK_NSEC; return *delta_next; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + ktime_t t; + + /* Next wake up is the tick period, assume it starts now */ + return ktime_add(tick_nohz_get_sleep_length(&t), ktime_get()); +} + static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; } static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; } diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 646645e..08db7f3 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1098,6 +1098,17 @@ unsigned long tick_nohz_get_idle_calls(void) return ts->idle_calls; } +/** + * tick_nohz_get_next_wakeup - return the next wake up of the CPU + */ +ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + struct clock_event_device *dev = + per_cpu(tick_cpu_device.evtdev, cpu); + + return dev->next_event; +} + static void tick_nohz_account_idle_ticks(struct tick_sched *ts) { #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE From patchwork Thu Apr 12 11:14:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133245 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573567ljb; Thu, 12 Apr 2018 04:14:51 -0700 (PDT) X-Received: by 2002:a19:a60a:: with SMTP id p10-v6mr5494749lfe.41.1523531691019; Thu, 12 Apr 2018 04:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531691; cv=none; d=google.com; s=arc-20160816; b=dFJKYRicxCQmNPiCxq0iMtHD0u7irS8wh1MnxgTSvXIva6u6uSYGahMcluW8k6bw3w BBGENJLveOSewjATEW5C+U96ssDnWebQdFMMj96ytr3cAXnLb+Dyirdy04uMAdetJlgY XCAXemBELox5JBRkWPzjQkUGLfG4lpzREl8zOmJ96Q8PLUQHnK36cBVCmoBaD0XO1jKx jJI4E24q9Vllb6NXeQAacHs2HoNvLKNkIiQAFTGko6rHJW+HsJlAmQDAdLZv4sZ68Z9Y 6i4ZF+Fy1TyiuwHoPRGpTDInn0OXBzcZGxu2dXBl6gZdo+W0TBWxLCAr3qSvCxO2booz giWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=dN7b+VCYcHRLXpkthbq+AxfhjyxNYYcuJarkBPvH/ts=; b=aXfb2zcQ7jK26EGYGX/XXPiRTG1pbxjryDsjSIYETqjLfdnSMoZEFGKKrKpD74YLxw AyGo9yw5HlNyPzhucNZNRlvlBFTLKhzUOCykuA2xczRaGxYN4cR7bhDCO1jLouiLpkw9 jEjDrHkzuF1/QUE7cBC5YDK+LO7t41KHm+W//yncCFwUicnS/D2mjziMMJY+60Gn/hz5 h4OuQDTxapjMcfiCxDh1RXdJBIlB1+wIgQKcEsLEHOfl3PZvg2vT/moCth1qgZruYdRb bncs4gXWoOFAPuqCiY+5/nK71ClWX+v3fSpU5eg/DCzfKw+XCT3k30P9NbI8l3uqPE8j cBLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SSkopJfU; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f188-v6sor893076lfg.25.2018.04.12.04.14.50 for (Google Transport Security); Thu, 12 Apr 2018 04:14:51 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SSkopJfU; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dN7b+VCYcHRLXpkthbq+AxfhjyxNYYcuJarkBPvH/ts=; b=SSkopJfU95HZRWwvULJXYOb3EvODW3hVojnyu8zCyP6bIFp2WL4VJ4HB0nGsP6o9At NXYpXWfQYuElrvjKAufAggwUXzmjRA8BLza8h5K5XPZ+bATYP0VbdIFfT3WqynVUZr/E WlZ0vhPjwjnxbpAkTmwmoW3lpSf/RbOiLgorI= 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=dN7b+VCYcHRLXpkthbq+AxfhjyxNYYcuJarkBPvH/ts=; b=XoSSOSdyBIkBPXNxFItT+YA6EwkgEOJYdWJ0LWJMOnD4f+o6GIfy3aDXWVVWP+tGf8 zGhjcCxTSNeJPqubkPzb7wMPORTNxm8bxB+U2BNwizV1UeIQ5/anLVlRm2bzEnnuatyC GMnHkKR0SftM3EKFzkHp1gJ6EQGxakAgr806gdkc6KfEEuY5guOVLfMChrsVsCHIx9NI a64q0upT+5xS1QphW6QAws66jO63f1fNwDIKg/wkLrLSRCkmeh9eVUEzdh8ljsj7PTBZ Utx/Ys0Inx1w8UxSBUv4LoLNkGDO4x+K52edsMkqMbaxopML7TL/t7KBBqdzGAS5XGvg eDaQ== X-Gm-Message-State: ALQs6tC3H+9gDrHEMN23cjyARhfr51oY1mVnSNHxlFlAC2nGTEHau74v wpYT1fgb7vnopTQmvhG1JFt+qWr6 X-Google-Smtp-Source: AIpwx49leVkWeY/kz02qHj5PfVRAjjZpMnPXBQxGhbQDKTczzkoUEB+B34QFgu3WcwiWcR9UHiDR0w== X-Received: by 2002:a19:d911:: with SMTP id q17-v6mr4693438lfg.99.1523531690741; Thu, 12 Apr 2018 04:14:50 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:50 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Frederic Weisbecker , Ingo Molnar Subject: [PATCH v7 07/26] PM / Domains: Add genpd governor for CPUs Date: Thu, 12 Apr 2018 13:14:12 +0200 Message-Id: <1523531671-27491-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> As it's now perfectly possible that a PM domain managed by genpd contains devices belonging to CPUs, we should start to take into account the residency values for the idle states during the state selection process. The residency value specifies the minimum duration of time, the CPU or a group of CPUs, needs to spend in an idle state to not waste energy entering it. To deal with this, let's add a new genpd governor, pm_domain_cpu_gov, that may be used for a PM domain that have CPU devices attached or if the CPUs are attached through subdomains. The new governor computes the minimum expected idle duration time for the online CPUs being attached to the PM domain and its subdomains. Then in the state selection process, trying the deepest state first, it verifies that the idle duration time satisfies the state's residency value. It should be noted that, when computing the minimum expected idle duration time, we use the information from tick_nohz_get_next_wakeup(), to find the next wakeup for the related CPUs. Future wise, this may deserve to be improved, as there are more reasons to why a CPU may be woken up from idle. Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Lina Iyer Cc: Frederic Weisbecker Cc: Ingo Molnar Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain_governor.c | 58 ++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 2 ++ 2 files changed, 60 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 99896fb..1aad557 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include static int dev_update_qos_constraint(struct device *dev, void *data) { @@ -245,6 +248,56 @@ static bool always_on_power_down_ok(struct dev_pm_domain *domain) return false; } +static bool cpu_power_down_ok(struct dev_pm_domain *pd) +{ + struct generic_pm_domain *genpd = pd_to_genpd(pd); + ktime_t domain_wakeup, cpu_wakeup; + s64 idle_duration_ns; + int cpu, i; + + if (!(genpd->flags & GENPD_FLAG_CPU_DOMAIN)) + return true; + + /* + * Find the next wakeup for any of the online CPUs within the PM domain + * and its subdomains. Note, we only need the genpd->cpus, as it already + * contains a mask of all CPUs from subdomains. + */ + domain_wakeup = ktime_set(KTIME_SEC_MAX, 0); + for_each_cpu_and(cpu, genpd->cpus, cpu_online_mask) { + cpu_wakeup = tick_nohz_get_next_wakeup(cpu); + if (ktime_before(cpu_wakeup, domain_wakeup)) + domain_wakeup = cpu_wakeup; + } + + /* The minimum idle duration is from now - until the next wakeup. */ + idle_duration_ns = ktime_to_ns(ktime_sub(domain_wakeup, ktime_get())); + + /* + * Find the deepest idle state that has its residency value satisfied + * and by also taking into account the power off latency for the state. + * Start at the deepest supported state. + */ + i = genpd->state_count - 1; + do { + if (!genpd->states[i].residency_ns) + break; + + /* Check idle_duration_ns >= 0 to compare signed/unsigned. */ + if (idle_duration_ns >= 0 && idle_duration_ns >= + (genpd->states[i].residency_ns + + genpd->states[i].power_off_latency_ns)) + break; + i--; + } while (i >= 0); + + if (i < 0) + return false; + + genpd->state_idx = i; + return true; +} + struct dev_power_governor simple_qos_governor = { .suspend_ok = default_suspend_ok, .power_down_ok = default_power_down_ok, @@ -257,3 +310,8 @@ struct dev_power_governor pm_domain_always_on_gov = { .power_down_ok = always_on_power_down_ok, .suspend_ok = default_suspend_ok, }; + +struct dev_power_governor pm_domain_cpu_gov = { + .suspend_ok = NULL, + .power_down_ok = cpu_power_down_ok, +}; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index ccd7c94..8f60181 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -161,6 +161,7 @@ extern int dev_pm_genpd_set_performance_state(struct device *dev, extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; +extern struct dev_power_governor pm_domain_cpu_gov; #else static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) @@ -206,6 +207,7 @@ static inline int dev_pm_genpd_set_performance_state(struct device *dev, #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) +#define pm_domain_cpu_gov (*(struct dev_power_governor *)(NULL)) #endif static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, From patchwork Thu Apr 12 11:14:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133246 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573586ljb; Thu, 12 Apr 2018 04:14:52 -0700 (PDT) X-Received: by 10.46.135.214 with SMTP id v22mr405413ljj.94.1523531692619; Thu, 12 Apr 2018 04:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531692; cv=none; d=google.com; s=arc-20160816; b=F3NtewmvUXEgBfCSIKeO3HKXT4y1BMSLTH9PanQvMe5LpzHqE0EcYVV9OOR40qH16W EexFY8zjUhKQnKj9E64Cbmyy8lNe4PREgVIzkyQLz7SvIY8jYy7iKLLC47ess7khxH6W SGI28etINxQTVD/JSr/sBBmWbnGRUnGm+YEvtl/NxLq6ElcgoeI42vp35E5o6w9epPeA SAbHHN3Ita1+LCluG7ue8dswrGXwqrLY7WYcYH+f0zyia0wBY0mRB7uXE3f29a2/RYuu KNYO169++JgyKIlC9k26eDCneAWdSqw3HG0tJkznfiXaHoDXhl+6FUwnW7ajSdFlwHP6 4Xkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Mx+RGhiRqfre3W/WyaHvY+aHcTyzCVXc3AJ3mbA+OgY=; b=xNeSPI1PhoGRyrb7ehhHvJCjpzfhHVeBQvP78V3h2H5S/iVq8x75XPTqiRr9tlJ/9N jaY4tG5SgZjaR7mWeZ35ayQNcH5PoJqMM0fSH6HY4XfeIE1XnybPEds6Eg8mvL+O6pvt ajtSLr28Z7j1oWvRAhenT8sjWH3oE1tiW52FrZPCWn/ikJOKXlhhOoeAAQq9Ha/rGTi1 WN2vBk4wZ4OvJcXAu3+gPPWXCxOFp0SaZlokTEaNPAcJjJr/kLdPDJ7bEYUNeodeBaV7 TuFGm7/vYhmEVlQNcNi7iTy/xy/ty1WCJgq6nlAdoYadkpkGovYpPXd2EE0UuJS3pilB nN4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PTq6GgbV; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a10-v6sor906398lfc.54.2018.04.12.04.14.52 for (Google Transport Security); Thu, 12 Apr 2018 04:14:52 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PTq6GgbV; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mx+RGhiRqfre3W/WyaHvY+aHcTyzCVXc3AJ3mbA+OgY=; b=PTq6GgbViTeFVVmnU/gnK5B1RilQtrROzeTEE45l5QqAB1Ui6nCKvHr/5wjt0zzeHd MSiPk0EmztBplhxIreT7AN+CYUwphjoU4SasKbjZLjnATSsxXuCcnjyCpF1Ko0gpZPDB 7K8gcRMnCJjcczpaIfDJ8c4cYS94bspXGWs8s= 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=Mx+RGhiRqfre3W/WyaHvY+aHcTyzCVXc3AJ3mbA+OgY=; b=dsFWDqHDVYcQ6bW05R8pi9s9pOJmC+bYn3vTbS7diMRsTP6NfHfjDr9uyHKUrtoj61 B9Ofyzdl6wqKcq8N++JzYVnfD+7FUqFZuwCMqlQJJR9STboNGTqTFyhdW9QrvvZKxu6y ADLU5SgBBGqwDUjXxxmUxvik/NxRISZP0l+yVAXzFeCm6eQh7f0deHls8/GESmRHLOjE BIv1j1m534AM99fQMlQGPTkUZ2KlIPB3ZQ4VmmLEbK5w/pcyfkG1G/15U1N0lZHuS31J oeO+zm8C6BV+kqONWVCO5KwhdySr6ohZTa0hmTl8Mz06Vn+6ILVaetBsZB9QWoGsYOf2 4rrg== X-Gm-Message-State: ALQs6tBkRpohcNPhz+rNBSpW/Z/hAKITbG+g5MufpLM5RUetuoJ49hcz BPVHWEEmqk04Mp5RBEzlrlk+idF3 X-Google-Smtp-Source: AIpwx49RR0120qo7r+xtTtooCM+h7X0fKOvKwAAexpC7j0K2cFxogxpk/X7ED5M1b2fJ/wsxP25PZA== X-Received: by 2002:a19:7dc4:: with SMTP id y187-v6mr5083167lfc.2.1523531692350; Thu, 12 Apr 2018 04:14:52 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:51 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 08/26] PM / Domains: Extend genpd CPU governor to cope with QoS constraints Date: Thu, 12 Apr 2018 13:14:13 +0200 Message-Id: <1523531671-27491-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> CPU devices and other regular devices may share the same PM domain and may also be hierarchically related via subdomains. In either case, all devices including CPUs, may be attached to a PM domain managed by genpd, that has an idle state with an enter/exit latency. Let's take these latencies into account in the state selection process by genpd's governor for CPUs. This means the governor, pm_domain_cpu_gov, becomes extended to satisfy both a state's residency and a potential dev PM QoS constraint. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain_governor.c | 15 +++++++++++---- include/linux/pm_domain.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 1aad557..03d4e94 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -214,8 +214,10 @@ static bool default_power_down_ok(struct dev_pm_domain *pd) struct generic_pm_domain *genpd = pd_to_genpd(pd); struct gpd_link *link; - if (!genpd->max_off_time_changed) + if (!genpd->max_off_time_changed) { + genpd->state_idx = genpd->cached_power_down_state_idx; return genpd->cached_power_down_ok; + } /* * We have to invalidate the cached results for the masters, so @@ -240,6 +242,7 @@ static bool default_power_down_ok(struct dev_pm_domain *pd) genpd->state_idx--; } + genpd->cached_power_down_state_idx = genpd->state_idx; return genpd->cached_power_down_ok; } @@ -255,6 +258,10 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) s64 idle_duration_ns; int cpu, i; + /* Validate dev PM QoS constraints. */ + if (!default_power_down_ok(pd)) + return false; + if (!(genpd->flags & GENPD_FLAG_CPU_DOMAIN)) return true; @@ -276,9 +283,9 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) /* * Find the deepest idle state that has its residency value satisfied * and by also taking into account the power off latency for the state. - * Start at the deepest supported state. + * Start at the state picked by the dev PM QoS constraint validation. */ - i = genpd->state_count - 1; + i = genpd->state_idx; do { if (!genpd->states[i].residency_ns) break; @@ -312,6 +319,6 @@ struct dev_power_governor pm_domain_always_on_gov = { }; struct dev_power_governor pm_domain_cpu_gov = { - .suspend_ok = NULL, + .suspend_ok = default_suspend_ok, .power_down_ok = cpu_power_down_ok, }; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 8f60181..e7910d2 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -77,6 +77,7 @@ struct generic_pm_domain { s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ bool max_off_time_changed; bool cached_power_down_ok; + bool cached_power_down_state_idx; int (*attach_dev)(struct generic_pm_domain *domain, struct device *dev); void (*detach_dev)(struct generic_pm_domain *domain, From patchwork Thu Apr 12 11:14:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133247 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573617ljb; Thu, 12 Apr 2018 04:14:54 -0700 (PDT) X-Received: by 10.46.101.16 with SMTP id z16mr389539ljb.72.1523531694415; Thu, 12 Apr 2018 04:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531694; cv=none; d=google.com; s=arc-20160816; b=rrs2A170tX09BToe4Ic8ihfgAqLlZhJ5FOZOiqIqjXsjIe69gokrfI1We9L/Zf8qtP eJN3dI5QVmjBUWwDoiMIHjBSH5widpUraQIPUxIKD7L/mN8vjgnsHcpzgmCy4B3PZFHe wWs2odOuDNNyL0z6I9MkWrbzzBbE/UF1/gGXNpTrnWb0EugPQnK1UsdD8RY/IleQmXEp T2AYc0RumBkgIuhNN21SQJhhAFoi6dCvvEaDI+YZwZM89+QRp6UR6jO6Wpr73p0KWje6 8ndqz4Tnazlf5zhfjtvZ86G00tjx+A9myAs3Rf4vZtw25/Gp6bEnaJrPffNRTTiT0Vlj q2lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=3/F6tv2h3FNcd/Gi/Phy9kHc/BZznWra5waqp09Zxaw=; b=pN2/GpaflLLieyQ1pr27noQo/dpHTDofMpAFeAn5geIie+Ud6VzLnHaQq90hhlkHod GvbWNsLzYTBUln00M2soTYnBTh2U6/YIkdt4UAZPeOUOAUtNPURhdwMXL7wYubLBGBBF bJ9VZ7Ka9KMckK0k2cLZET102anUrHu8ItvWZ/5AuDKkeJH3SpMNBWlaOqt3blvGRPFQ 7pU/31XPHKKHQbB3PjzXKW0XbRQ2OL+pSl+hK96FLIorc1A3F6ESgVo/Y0vn4JxEYApZ KOvx1Hync7diC5pshPSd82XUJEt23ZO3F2CLsYFXTQbAw9r59dv+MZuyr2feM0dfRuQn DWmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OPzMN2wB; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 73-v6sor922466lfz.85.2018.04.12.04.14.54 for (Google Transport Security); Thu, 12 Apr 2018 04:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OPzMN2wB; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3/F6tv2h3FNcd/Gi/Phy9kHc/BZznWra5waqp09Zxaw=; b=OPzMN2wBKjEx5I4b4BZ5k9aBPrH3R56Ykx0mfQuR5qkhFXuPfX32xINdUNDszDnPZe 65TbgkpZXh430TxYbVGPsHzZXfEK7+o8BtmTRSbBwN+NQKVsNBhhYgFX7OD50O5crA98 3MVCdFTowyPX4TnFX9G/O/THvITArB2on3BOY= 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=3/F6tv2h3FNcd/Gi/Phy9kHc/BZznWra5waqp09Zxaw=; b=ug/45Th1FNq+5sKH9wctb5X9OZ9aWAsjpmJRw01uDikEvuAel67JMo4sr0nJT1OwM6 znKa/Wmek67ut7oPojYAZWoHAuOlU6zp0tG7MITbnUwfnC/3B2CfCdozNFTWrU+D9ELW IgS81+ef1rsvDj+mfoRuw60IdFoKmSIGPJSfrSmu+wYmHPhHuA9cJOy9Brkg3x0xn8fe gQVCQiCmfm4dkXErjD5gkQefYmm5DvtLYDfguBmjEAIllstU05xT0Z8vxB9MramiXr2s PCcrrurCe4Ay9CfJINPqLg+651ijqYCCcMbW8xw6WEfHn6T/bs0trF+JnQlzqRhSZXam bXMw== X-Gm-Message-State: ALQs6tBAlYsQ76lXa+/AcrcmEDBumCQtz7HmsD9f7RZMLZjbQwNtsqU6 wamEIZI3SLxFhJORjJUyJhBoWZxY X-Google-Smtp-Source: AIpwx4/tP4nAMUxM3HEPkP+qVLfV0fd/5tP+cN+B79UG1TH5FvaY4a2n6IYPvp5hG5+pxSdt2amqRA== X-Received: by 2002:a19:1a86:: with SMTP id a128-v6mr5476616lfa.80.1523531694189; Thu, 12 Apr 2018 04:14:54 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:53 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 09/26] kernel/cpu_pm: Manage runtime PM in the idle path for CPUs Date: Thu, 12 Apr 2018 13:14:14 +0200 Message-Id: <1523531671-27491-10-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> To allow CPUs being power managed by PM domains, let's deploy support for runtime PM for the CPU's corresponding struct device. More precisely, at the point when the CPU is about to enter an idle state, decrease the runtime PM usage count for its corresponding struct device, via calling pm_runtime_put_sync_suspend(). Then, at the point when the CPU resumes from idle, let's increase the runtime PM usage count, via calling pm_runtime_get_sync(). Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- kernel/cpu_pm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.7.4 diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c index 67b02e1..492d4a8 100644 --- a/kernel/cpu_pm.c +++ b/kernel/cpu_pm.c @@ -16,9 +16,11 @@ */ #include +#include #include #include #include +#include #include #include @@ -91,6 +93,7 @@ int cpu_pm_enter(void) { int nr_calls; int ret = 0; + struct device *dev = get_cpu_device(smp_processor_id()); ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls); if (ret) @@ -100,6 +103,9 @@ int cpu_pm_enter(void) */ cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL); + if (!ret && dev && dev->pm_domain) + pm_runtime_put_sync_suspend(dev); + return ret; } EXPORT_SYMBOL_GPL(cpu_pm_enter); @@ -118,6 +124,11 @@ EXPORT_SYMBOL_GPL(cpu_pm_enter); */ int cpu_pm_exit(void) { + struct device *dev = get_cpu_device(smp_processor_id()); + + if (dev && dev->pm_domain) + pm_runtime_get_sync(dev); + return cpu_pm_notify(CPU_PM_EXIT, -1, NULL); } EXPORT_SYMBOL_GPL(cpu_pm_exit); From patchwork Thu Apr 12 11:14:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133248 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573642ljb; Thu, 12 Apr 2018 04:14:56 -0700 (PDT) X-Received: by 10.46.150.135 with SMTP id q7mr361988lji.67.1523531696384; Thu, 12 Apr 2018 04:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531696; cv=none; d=google.com; s=arc-20160816; b=MChdkW8PMDc/CudkWpKDx+X6JrpXroW3F3qD7oPXo2UWbDUxFmdPe9Y27/WDGQek78 zvtNPwu3I4ITdx/XHUaD0yOEwTCzA7t5yJxhIwP8dyCYF6w3SB+P6FVqt6rTRO34wrRY 5pLZVLJb6rgXQfkSh/w7MWQggIykv2VU8Rkt62/VXfW92NxAs+Pm0r/Bmln81J1mLNTt ANGQpcmWNpkVlAQ1z82noWZjRp5Xvjr+98DAPyS8iGWBkcdifuoY08t+uhwfJzi/11BR rZOzD3Pb9gyIGMd/Mi/rvIhm7dkdjZIjnarWAJm1TwkdWve6261HQeXqsH5nag/Bvpr/ MB3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=9Rk0XsmJ8ZMwWIgsjyCup4TjKqspAVxuol9gCIzu2NQ=; b=uPemeg1VlA1TYRnKEgDa8rUQgtaL/kId2F90k+RBwKZvkx0tu0WD+0ir8a17MBNA1I aAsOYaaKK4fK5FRJRjn5Gm9Ys3DQJuuLCqZixPkovORfee5j1VvwTz79FB6u3pRitNau k+wjQbXFLrekp4Ogi03r0GyKTVVQ5WviEfG3tMFq8C47yvbZWe/cEHBah6VZ4KX5ROkt yFw3hvWg5cfWqObYiPm86TGqTQTUZbyT4jt4jr8LZI92B/OTnvGw+B3PUA/hpjUNLauP OJDRdHhb5+egLzo3WPXAn1KmaXmmYshjfyRrn0PKt9Ff86ZQbe0BD1Ap5rXWWml5pZ1G UE6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JRbxE9yF; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e71-v6sor176753lfi.56.2018.04.12.04.14.56 for (Google Transport Security); Thu, 12 Apr 2018 04:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JRbxE9yF; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9Rk0XsmJ8ZMwWIgsjyCup4TjKqspAVxuol9gCIzu2NQ=; b=JRbxE9yFGrussWZVzas77uzKIy3uK/7X73UhBafaLhxHxj5+sg9V2Ln0d1aHyajUcQ 41CtxwQ5InTewVjIZNhKBXOZt704N8kHK55icz9jYBcSuxOYptW9EbKzbc7VFPxR38RY 1wkfjTcTiqJv1dSSvY5oF71NOMF+1Y5hHrLds= 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=9Rk0XsmJ8ZMwWIgsjyCup4TjKqspAVxuol9gCIzu2NQ=; b=IuYlo0OyGcF+npGMoVZ3/wnkfciNhbVdbBZEIe6/W8NCJiC9iXPlxPP36qr15ETsgX 30fYrVrBAtyTRRCrg8+Hdxbo7+nqzNOxt2aAZAKrYS5Lug0pGcQb1UVMFu0OumLUISe0 xyqXe2iOsS1r0kl0FdgFT+K92d45S5qaGK6ARM38ysv18Yxxtv8OsWM+bvApVQnFY98a 92mhlGSn+7/a2hAqIlVMOFEM5D/Ty+rru3QZtk10ATPB2l3TaRyDxDW4aGWhse7g59WY 2crWxul+AS+lXVw8e2/wm+/EMiwzdGg/wI4Q7U9f1QqmDVYpSXsShk5ayJvD+Ba+pZNQ +v+w== X-Gm-Message-State: ALQs6tCjq6vpB1PEUPyeWGNa17gvTSKJXfae+dLpgILzLXPK7/RN/jGm EThMAWweozZ8ch2A9ejzEHTEwY1D X-Google-Smtp-Source: AIpwx4+oizIAQjwuqY4opZcQAGIRiVpy20nn0UkfcUZiZkNEjgsnl5wrvpLQXQQt2Khn3T4TdIa29Q== X-Received: by 2002:a19:e917:: with SMTP id g23-v6mr5081151lfh.71.1523531696075; Thu, 12 Apr 2018 04:14:56 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:55 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 10/26] dt: psci: Update DT bindings to support hierarchical PSCI states Date: Thu, 12 Apr 2018 13:14:15 +0200 Message-Id: <1523531671-27491-11-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> From: Lina Iyer Update DT bindings to represent hierarchical CPU and CPU PM domain idle states for PSCI. Also update the PSCI examples to clearly show how flattened and hierarchical idle states can be represented in DT. Cc: Lina Iyer Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson Reviewed-by: Rob Herring Reviewed-by: Sudeep Holla --- Documentation/devicetree/bindings/arm/psci.txt | 156 +++++++++++++++++++++++++ 1 file changed, 156 insertions(+) -- 2.7.4 diff --git a/Documentation/devicetree/bindings/arm/psci.txt b/Documentation/devicetree/bindings/arm/psci.txt index a2c4f1d..17aa3d3 100644 --- a/Documentation/devicetree/bindings/arm/psci.txt +++ b/Documentation/devicetree/bindings/arm/psci.txt @@ -105,7 +105,163 @@ 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". + +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. + +In PSCI firmware v1.0, the OS-Initiated mode is introduced. In order to use it, +the hierarchical representation must be used. + +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 = <0x000001>; + entry-latency-us = <10>; + exit-latency-us = <10>; + min-residency-us = <100>; + }; + + CLUSTER_RET: cluster-retention { + compatible = "arm,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 = "arm,idle-state"; + arm,psci-suspend-param = <0x1000030>; + 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>; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a57", "arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + power-domains = <&CPU_PD1>; + }; + + idle-states { + CPU_PWRDN: cpu-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x000001>; + 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 Thu Apr 12 11:14:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133249 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573669ljb; Thu, 12 Apr 2018 04:14:58 -0700 (PDT) X-Received: by 2002:a19:23c5:: with SMTP id j188-v6mr5072381lfj.122.1523531698051; Thu, 12 Apr 2018 04:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531698; cv=none; d=google.com; s=arc-20160816; b=QLjSlrPrIJaLVd5L3iNrIfDmZLx+Q+T5tlvTbHmB5PfBhO2LCXNb5ELcmfJdfGKwHn NWxz0q5WlLHLFgrexoLDRiYFt/Q0tO04+TtfBxvJJF6sYBAwZOBQiRQdZ69N7QcW9+oE 9fZntl8RQEQAwXRW0laO4Hp9zYyy8mFmcAUML2B4ZzPxHnAIHtH1kvhqyshjrh0gN+2+ HJELVk9B9vgwxvV1THMd8Q6ZL42undJofA65+mvNZlSiEkE4QfFPFPpkZsC1hUMBiBwq NyIdMfANd/ReMKI7akiOxCJJV0PqO/8o4Jnfb/wPHQ/U55u18oWi0gycX9MTcgOcluRc hu4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Q8CKCINBtP8hfFNpVArvLjHKLRPd0Kn9ZUGR2WlDOW0=; b=LMyN/Xqsm5Gke/2gs/pK9vIEoVwZR3LCFYT4XejyFS5hmZ/eFbuaxgr5Gpyowvy8aQ KCHxPj6dwiJkJqqjVkD+sS14VcBFYpqQaFY5t1yhRUW6RG4FLhw0S9MVtvQduoBVG2XZ /YpGz+SXa0YPteoRyjAH2XxZ7TeWbzTsQAQNASimsNyD9vsnbxuoWxZ1TP5drReAec56 HykbfwcBZh1hSdjX0n87CAZa2xZVOHDB59yj0HWWqBmUJk+9H53flbT0tLdMvRhSHGJn EkPK8AQeXZwEDlf2H1DI72Rm7Jvnpgwmf77WtHhiKhwSwAD0hDb4KjHNe6/L2XwTCeVH wgSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BjhIoC2/; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j19-v6sor882788lfk.58.2018.04.12.04.14.58 for (Google Transport Security); Thu, 12 Apr 2018 04:14:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BjhIoC2/; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q8CKCINBtP8hfFNpVArvLjHKLRPd0Kn9ZUGR2WlDOW0=; b=BjhIoC2/wslgVNTKVW8HPq2Mv0pNJDZm1C2IQkI8ETfRPHMrc0xheHU7gPoG7EPxo8 oXaM0TFJYdSdabmhqOXhISz1rm66SZK4WzDwte0YiRCr1Zqk32UJ2y36VVPly0prKcMB zxCebtCeF3W6WzpgTP7XuW9gC1HsOrMI5cIUw= 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=Q8CKCINBtP8hfFNpVArvLjHKLRPd0Kn9ZUGR2WlDOW0=; b=jHMxJv3aVLX1QJxCz4cOh23Wp46b6piBEID/tGEVJN/3ehCXEYP2+U5dLUudkDrMpK ZQ6hNEjVO1V/CwKCnrGC0dtEKPizY4XT9IDotZYtCFqPQNINWCy7+TjE2aTQs6PSrHys LlqOmLNt2jzMDZ94I8bDMHble/35MGWAOqyPvRvQNMh0GMFpanPD6+6C47yttRVxfWoX HihJbrDR7TvNJURL46447KikF6EIXWDBtfPMPMspi+8oev9Gkmimjv/UL/r1vwZurnQ8 KZ422ypPpn28eVqXWyJOcrovlfRbM9ic0QvSLJ++xvvEvTIQwbHM9386F99g0X06oxDq SpaA== X-Gm-Message-State: ALQs6tD+xuDRc9Ad3HRpsvf4imBl0vFAXZsasYeLj4yIxWMeHmUUnOqO j0ONVZ500Z4gl7LjlPr8DD1Whic6 X-Google-Smtp-Source: AIpwx48Z+Ekp57qDUNM9ouFDrsP6foIHTjb1W5Fbj5jEEg730hrWSccVqo1qNC3tBjioqU4J83wgxw== X-Received: by 2002:a19:5750:: with SMTP id l77-v6mr5578338lfb.10.1523531697790; Thu, 12 Apr 2018 04:14:57 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:57 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v7 11/26] of: base: Add of_get_cpu_state_node() to get idle states for a CPU node Date: Thu, 12 Apr 2018 13:14:16 +0200 Message-Id: <1523531671-27491-12-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> The CPU's idle state nodes are currently parsed at the common cpuidle DT library, but also when initializing back-end data for the arch specific CPU operations, as in the PSCI driver case. To avoid open-coding, let's introduce of_get_cpu_state_node(), which takes the device node for the CPU and the index to the requested idle state node, as in-parameters. In case a corresponding idle state node is found, it returns the node with the refcount incremented for it, else it returns NULL. Moreover, for ARM, there are two generic methods, to describe the CPU's idle states, either via the flattened description through the "cpu-idle-states" binding [1] or via the hierarchical layout, using the "power-domains" and the "domain-idle-states" bindings [2]. Hence, let's take both options into account. [1] Documentation/devicetree/bindings/arm/idle-states.txt [2] Documentation/devicetree/bindings/arm/psci.txt Cc: Rob Herring Cc: devicetree@vger.kernel.org Cc: Lina Iyer Suggested-by: Sudeep Holla Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/of/base.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/of.h | 8 ++++++++ 2 files changed, 43 insertions(+) -- 2.7.4 diff --git a/drivers/of/base.c b/drivers/of/base.c index 848f549..97350cc 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -400,6 +400,41 @@ 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 and idle state node is found at index, the refcount 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); + 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 * @compat: required compatible string, NULL or "" for any match diff --git a/include/linux/of.h b/include/linux/of.h index 4d25e4f..15072b1 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -348,6 +348,8 @@ extern const void *of_get_property(const struct device_node *node, const char *name, int *lenp); extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); +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) @@ -733,6 +735,12 @@ static inline struct device_node *of_get_cpu_node(int cpu, 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 Thu Apr 12 11:14:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133250 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573694ljb; Thu, 12 Apr 2018 04:14:59 -0700 (PDT) X-Received: by 2002:a19:c3c3:: with SMTP id t186-v6mr816494lff.110.1523531699921; Thu, 12 Apr 2018 04:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531699; cv=none; d=google.com; s=arc-20160816; b=hJfzWU37ka+mHtw8Bgnzj9230DmEZ8/LSdUj8o2JKxFXb2NQwtQa6/iiQnCYAiuLc1 edEQg+V0FFlEOQuqKN94fWGbJqpwUErnUJxDYlrrj8qgCwceljqnJoXffEKXwkUawH7x tkDuxJcphie6b0gBNFax8pGxgcT90PxzfOCCaKHNFIcVKIkXvYb4tCg6aWZgblnqfXlo 5tUML2tAWcodZsLHD2x74aY556N/ByD9UHN3Tqxh3ZOFomNR1e0rB6cTrSY4PLP2vFJX MrYoPaLN8wiZBhMOe4rflCyuTIYGemtDyt8uy8+NprDS3sX3rq8I0NUxBniQfCnGXrfv 7m7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=wNxOIumF5VO8wdO7axQyrg1Yf0ybJeBuC4ybXh+k+I4=; b=e2/4W08JNdvnb28EfVXfFMZzsW0xjh5cZKYjMYRwODWti3HzQHp32jAUPoBciLsBZ+ RYyHKPml3IjP2Ue6PSHBhTOv47XpY0ELZMXN9tmsp5QHDSEbxE2n3L0co0bB2bFrjngl GVfxYRdg2QW2YDrnaQZ/8cHWtoIGj8ppEy0N9aX73FWYaS9pUeEKReihjQErVbUQ+2gJ hCRExe7sVXu0ZUm7vViTOGkk44qu1MB8D9nFm3R0B2t2dHUI1Ui/IQO0zR89YA0FLUcO CEj/ZBPtMgwuIMDeekugvApmPcmxCUBDQ2d96J2QAdCuHnDS8EIMYyj0GFecC/Rb1x6m p8wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O8WhQWRG; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j86-v6sor927334lfi.64.2018.04.12.04.14.59 for (Google Transport Security); Thu, 12 Apr 2018 04:14:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O8WhQWRG; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wNxOIumF5VO8wdO7axQyrg1Yf0ybJeBuC4ybXh+k+I4=; b=O8WhQWRGFjMZMMxvRJen+/XKvYxf1lramgnS/wOTD+s+mrxlzym3vrs4iggBF7XCk3 Z51YnM1Efs2PtSV8PwlHPzXmT2JfjZkpiXCnJlSdGlNP3wFNm7xbTZJ/hYuod6826Wqk r7i2T5YHCQyST5ZosDeSf4ozleHNcclvSZR0A= 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=wNxOIumF5VO8wdO7axQyrg1Yf0ybJeBuC4ybXh+k+I4=; b=dpG+BJdfNG/QHkJvbVk6nK18eOJV/nYtvrQzdmJOXIhcaULOkNdWwTAM0KaROAQaTT oX4asSs/ExgBUircT3AC+NcB6FA2DrmlaKS9Q+y70jXiuW4Z+fjiEZZBsjPpR591iXzG KD81dnRNe91zCLQv6g8OaXWCUpBV9dLxn1kXm1l3ttRqzt+EedSrFEqlLF1OAVvJGbPY XkGten8L08XXxHnL4sW1vmc3cQmLtD7Go65qcu/7fHj7DGU74Rko7lCPpI0nS/I7Vlcc w2+cyfN91EpWC3qDZBIDV+dpO5M92L6ILjYgai6CcFpeFOSUfAfpSkS4ECh23eLtKD4u tIzA== X-Gm-Message-State: ALQs6tBxkZuRrorv2hk77xcsBjhg2HjlY35Z/zgnZCepTJ+SYhZxvTfK Ot1Zsq6i1dPopJjKSBno91labk8M X-Google-Smtp-Source: AIpwx48GaNnT5e3GV0a9rQWEJscn1nPnaNBvVRYAnMX3FRt/15zQ2JdYvvA27MWv1/axsn2WI6n0Ew== X-Received: by 2002:a19:1122:: with SMTP id g34-v6mr4714707lfi.6.1523531699615; Thu, 12 Apr 2018 04:14:59 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:58 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 12/26] cpuidle: dt: Support hierarchical CPU idle states Date: Thu, 12 Apr 2018 13:14:17 +0200 Message-Id: <1523531671-27491-13-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> From: Lina Iyer Currently CPU's idle states are represented in a flattened model, via the "cpu-idle-states" binding from within the CPU's device nodes. Support the hierarchical layout during parsing and validating of the CPU's idle states. This is simply done by calling the new OF helper, of_get_cpu_state_node(). Cc: Lina Iyer Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- drivers/cpuidle/dt_idle_states.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c index 53342b7..13f9b7c 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -118,8 +118,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; @@ -176,7 +175,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 Thu Apr 12 11:14:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133251 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573713ljb; Thu, 12 Apr 2018 04:15:01 -0700 (PDT) X-Received: by 2002:a19:11da:: with SMTP id 87-v6mr1134731lfr.125.1523531701383; Thu, 12 Apr 2018 04:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531701; cv=none; d=google.com; s=arc-20160816; b=zbeGIAnrPmon2KtPdU6cdkgJVDlnVVjGfSd7fAocfjx0yr0E1FOW8vG7vXRhHViUbM iYyXiK5YinCkEvn6mz1WilyXgfXZhlxzqjGicEeMonYk471dl3+pAqIrzATHHNEH7OhJ FAiPM2W3YmlHv5FLPYHavPx4dHwTiC89hNqAPU5gmmLfRwwfZJGCzKaXG1N44WbbI+1L Jq3A1Z9EEeBTH5WEHcTveqqPfkrEm5B6wJkyA4VxlLMHmmUl4HSpixO+2NMSNqcZmEwT gP2jcz3CkeJOZEq+PAdjcVKS22SlJi6LRymAHleDaOl7uV2VWAN+hAjsUZwQfQIkRjH6 oXNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=q7j10IC1zjnJs92+EIKWbkY/MkZoxDQiB++DZObbzzI=; b=rRB167PhdfnwZE+amO+i9IWW8vTrd30VrWCpOVqgFU9LhOPEjen7SZqGz66vOMsRbo PqLRDH7EFNKFz5brDJIJ9tu2UUuXaP3MpUpp5+DJdUNBVlrJdz+y6BpfoScAV7GwvJwm /x3tZVO6HGyvrp6pCppoDqexiqAc/mNR8uf6+/cuc7XPVJde8YwF3PNQfZMaFlOCYtkn DZnBn8/QC4v4GSvtu6BmoPyDtAQUlUV47c0ucpk+uxzmJw/jQqQY/iuV61bfWjufUJzo JNVWL/YWfPXug2hPD5E9BFB+xnlOzSpYEu35nY+Ld4DWi4RJTo0KXwtiLvBocMJ8jH5P C0kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g9JPzETf; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b16sor874930ljk.65.2018.04.12.04.15.01 for (Google Transport Security); Thu, 12 Apr 2018 04:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g9JPzETf; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q7j10IC1zjnJs92+EIKWbkY/MkZoxDQiB++DZObbzzI=; b=g9JPzETfdkOJnuUETtwoPLwWANLdkn/0F+9Y2jI7OFabQYJcxqyZ1p5i1otvTPBYE8 3E/+VRHT6oVmlByGQZFwzYWa1dnrU9YAW5DvA5Ki51RvtrWc7a+/PgwSCFgi5ALT2I13 Rk0IULkYa/7Uwl99/mJeoD88JPmI8RwFV/+HY= 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=q7j10IC1zjnJs92+EIKWbkY/MkZoxDQiB++DZObbzzI=; b=pJYcSD2PQbsr5nrTovLlDI3iGR8SAH+1A6iTbXSYwapOddSqiT/gA2Jb42w9oKISYI 1zJnlfBsvHIiV5n1asY5ljVhFh0ebX5zud23MYHMo++tYLHoefOeiGT4fT0zKUwvpjo8 h0aXX5RdaAhHb/rmrUwLrQiFM5QL6lFhOv+H/McpTIFP96RR6CnS/XXwhO4f43T7DFvF ihTfXyJ5UYooSbq1EIluEctllU0hbV0okRzvhKiDYQFp7QxGRN0E7nYjy1GXaH7BEHxh T1DOBWpsOqSqyNFlJ840fjgnA/43eqlMcVl/bPXiHfE08O6JBBXhPwzVyHeiFiVyPItu tNHg== X-Gm-Message-State: ALQs6tAclmfyNy3X2aQ/D0xFXTmbYEdaJgrggiYiMyePvf7k7F/cy6FA EQw0ECdLwDuxGt5xDmvsBkEE6Frl X-Google-Smtp-Source: AIpwx49laUzMVJQeR8LP7VdhgyGpGDG2yXLZKZ6L5VkNDnt4g57/zMUkaFtMk8/nptWRaXUDInIvjQ== X-Received: by 10.46.135.6 with SMTP id m6mr379811lji.124.1523531701130; Thu, 12 Apr 2018 04:15:01 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:00 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 13/26] drivers: firmware: psci: Move psci to separate directory Date: Thu, 12 Apr 2018 13:14:18 +0200 Message-Id: <1523531671-27491-14-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Some following changes extends the PSCI driver with some additional new files. Let's avoid to continue cluttering the toplevel firmware directory and first move the PSCI files into a PSCI sub-directory. Suggested-by: Mark Rutland Signed-off-by: Ulf Hansson --- drivers/firmware/Kconfig | 15 +-------------- drivers/firmware/Makefile | 3 +-- drivers/firmware/psci/Kconfig | 13 +++++++++++++ drivers/firmware/psci/Makefile | 4 ++++ drivers/firmware/{ => psci}/psci.c | 0 drivers/firmware/{ => psci}/psci_checker.c | 0 6 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 drivers/firmware/psci/Kconfig create mode 100644 drivers/firmware/psci/Makefile rename drivers/firmware/{ => psci}/psci.c (100%) rename drivers/firmware/{ => psci}/psci_checker.c (100%) -- 2.7.4 diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 6e83880..923c42d 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -5,20 +5,6 @@ menu "Firmware Drivers" -config ARM_PSCI_FW - bool - -config ARM_PSCI_CHECKER - bool "ARM PSCI checker" - depends on ARM_PSCI_FW && HOTPLUG_CPU && CPU_IDLE && !TORTURE_TEST - help - Run the PSCI checker during startup. This checks that hotplug and - suspend operations work correctly when using PSCI. - - The torture tests may interfere with the PSCI checker by turning CPUs - on and off through hotplug, so for now torture tests and PSCI checker - are mutually exclusive. - config ARM_SCMI_PROTOCOL bool "ARM System Control and Management Interface (SCMI) Message Protocol" depends on ARM || ARM64 || COMPILE_TEST @@ -286,6 +272,7 @@ config TI_SCI_PROTOCOL config HAVE_ARM_SMCCC bool +source "drivers/firmware/psci/Kconfig" source "drivers/firmware/broadcom/Kconfig" source "drivers/firmware/google/Kconfig" source "drivers/firmware/efi/Kconfig" diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index e18a041..ea284e5 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -2,8 +2,6 @@ # # Makefile for the linux kernel. # -obj-$(CONFIG_ARM_PSCI_FW) += psci.o -obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o obj-$(CONFIG_ARM_SCPI_PROTOCOL) += arm_scpi.o obj-$(CONFIG_ARM_SCPI_POWER_DOMAIN) += scpi_pm_domain.o obj-$(CONFIG_ARM_SDE_INTERFACE) += arm_sdei.o @@ -26,6 +24,7 @@ CFLAGS_qcom_scm-32.o :=$(call as-instr,.arch armv7-a\n.arch_extension sec,-DREQU obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_ARM_SCMI_PROTOCOL) += arm_scmi/ +obj-y += psci/ obj-y += broadcom/ obj-y += meson/ obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ diff --git a/drivers/firmware/psci/Kconfig b/drivers/firmware/psci/Kconfig new file mode 100644 index 0000000..26a3b32 --- /dev/null +++ b/drivers/firmware/psci/Kconfig @@ -0,0 +1,13 @@ +config ARM_PSCI_FW + bool + +config ARM_PSCI_CHECKER + bool "ARM PSCI checker" + depends on ARM_PSCI_FW && HOTPLUG_CPU && CPU_IDLE && !TORTURE_TEST + help + Run the PSCI checker during startup. This checks that hotplug and + suspend operations work correctly when using PSCI. + + The torture tests may interfere with the PSCI checker by turning CPUs + on and off through hotplug, so for now torture tests and PSCI checker + are mutually exclusive. diff --git a/drivers/firmware/psci/Makefile b/drivers/firmware/psci/Makefile new file mode 100644 index 0000000..1956b88 --- /dev/null +++ b/drivers/firmware/psci/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 +# +obj-$(CONFIG_ARM_PSCI_FW) += psci.o +obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci/psci.c similarity index 100% rename from drivers/firmware/psci.c rename to drivers/firmware/psci/psci.c diff --git a/drivers/firmware/psci_checker.c b/drivers/firmware/psci/psci_checker.c similarity index 100% rename from drivers/firmware/psci_checker.c rename to drivers/firmware/psci/psci_checker.c From patchwork Thu Apr 12 11:14:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133252 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573737ljb; Thu, 12 Apr 2018 04:15:03 -0700 (PDT) X-Received: by 10.46.99.93 with SMTP id x90mr429927ljb.2.1523531703197; Thu, 12 Apr 2018 04:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531703; cv=none; d=google.com; s=arc-20160816; b=NnbFvDYwJlDFgNWZTIOndKOHEnN5CsH/HeQyfEBPp8LCjSXVr6eKuwnO7eXQ4uFyRF bfPY6vua7/Jscf73Pio19hkPXo0HQWacC5unFDtd0igNA/9l/Zg7XTjiaLM//wat8Mjg TlTuKa1fd2ccarAZ7GOvGq9/vkgj0OOA3w2GmCg7YktxCgVkJv9i3X1hS3HUI4PKBcm8 ONU/v5+QBSIzPztI9AlV6JLlisXUHqpex1/Eq5u0B6x5/IWyi5xEQ7V8L6oJwBhCR7Tg JMg5v15xQ9Q+3jp3UidVnAbQGu5Gr/mzGbcqRcKpHjveNqH60BbggvVGu1HFvcFBIB03 nvWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=n34SBzMwtp7Xpo2KemYKd5kVksT+yOzwwvRgN6z868s=; b=Mi7n5qRtP0ocvdpKBcJwpx0dHq5nBSzGr75pMelBmnbv0BMOn0a6zQQ39vvY27wgHQ 9iGsjW4fHRb1Tsrmgv2H2k4cxVaY1y+ttKdSXMK2YljhHQQv5fyf0Bkin2ZwLUDljuHB UVjgVZhaK7wVTLxzOpD17FP6/GHc6uthMmaVLq2uy0yJ/zphzxwV2ZLbJCfYp5VF+Ax9 xXFYyhVp60tJEF0sqmGzBtjqJLFzTZ1tfHekQpr/CHZfQhDJEtg6SfNN5q48FpQiwOCm o3WiBIdY38al97nvhMRkBHR09v4JbgVOpdSm0wiWf1YF7oQIfkQXl4my8u1xQJzXBV8C ZACA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F+MUiHOU; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z11sor923365ljc.52.2018.04.12.04.15.03 for (Google Transport Security); Thu, 12 Apr 2018 04:15:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F+MUiHOU; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n34SBzMwtp7Xpo2KemYKd5kVksT+yOzwwvRgN6z868s=; b=F+MUiHOUxMOPafstxqz1qaRxqwz69RMd3wDLowLDmGrhz1RGsjgg7kVXdWB8yzEoN3 Moui/QVyVfNnQBHJTBCVCasnuxEH+n7n1RRKZw0KEAH5nlzY6aygmXa+7gRKUy8uFmIZ umzjso87wdMaX/nQQbtmIW8vtqqgoCZCloaas= 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=n34SBzMwtp7Xpo2KemYKd5kVksT+yOzwwvRgN6z868s=; b=AYDiNhWVpwINEmfooPrcac54WfKmHjpiNdOP9O6KMN1spf6Qg9qmefBqDTUPYi1ZGV +gsZjwxTehcO45tCwldLuoFeoOClHougdR4+GffUImLcq5CNn4tUVu2pT0s3knRfdENX wARnAKX6PyJbdfFavAFInNw1eElfLyRCbWtqRdMZxSQi3ny/avyrxdFV94alXZmXhfXo x+2XWcx75k1RIdz/u3Cf5/mdeaM2fxiZLIxmtNXehE1efbxxSkXgG0ChCnAxtoXgwVJy xiM7ogCi25RwT7Xq8/hbWg3Q7CDeG3hY+LZ3xcizIruA2Y0v6utmy3OvJ0lYo6Ky3Wzi 3pIw== X-Gm-Message-State: ALQs6tDTYqxNLARtpDlQn38TOM5H5k70S5qSLvXOceeZOMXrPMfuwzvK HktwLx/KjaM7P7w8Fxn66oIsd4Du X-Google-Smtp-Source: AIpwx4+aHkNd6b0PPd6xfViEKe3vXXrbFVyNRVRLRYRom7yhE4ClGFf99aZpafKmQMmCGTTuMmYcKA== X-Received: by 10.46.153.147 with SMTP id w19mr378232lji.93.1523531703020; Thu, 12 Apr 2018 04:15:03 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:02 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 14/26] MAINTAINERS: Update files for PSCI Date: Thu, 12 Apr 2018 13:14:19 +0200 Message-Id: <1523531671-27491-15-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> The files for the PSCI firmware driver were moved to a sub-directory, let's update MAINTAINERS to reflect that. Suggested-by: Mark Rutland Signed-off-by: Ulf Hansson --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/MAINTAINERS b/MAINTAINERS index b60179d..4579e29 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11219,7 +11219,7 @@ M: Mark Rutland M: Lorenzo Pieralisi L: linux-arm-kernel@lists.infradead.org S: Maintained -F: drivers/firmware/psci*.c +F: drivers/firmware/psci/ F: include/linux/psci.h F: include/uapi/linux/psci.h From patchwork Thu Apr 12 11:14:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133253 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573757ljb; Thu, 12 Apr 2018 04:15:05 -0700 (PDT) X-Received: by 10.46.112.24 with SMTP id l24mr410290ljc.104.1523531705023; Thu, 12 Apr 2018 04:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531705; cv=none; d=google.com; s=arc-20160816; b=Z3a/Z9gspEx6PYJ7erGWDhaKAAOOlx4mG2ksg2SURlz/tjsnIUNQvyTv2VIaQF+LQ2 qe7oPb0VveLWfO1ogrclFTmKqWVOxNXpvqPwN9KjHAVo+keU8AVyRbH8KUSNXkb5mMLK Ag5ZtEz+Cem7IR1zw4Hwmikm8p+klKzkw9e+QBywTmQMD7zIK6DUMJvXW+vcij5kPCW1 lI40A/f7n21CDX3cNbDwGkngKcINXsayVIOWNWXntIwCBykdg0/rsk+XxlokU7QmXUld TMzYUqhzKgE0xdlHwLNo9P7nkumJCyQ79ALyr/+iOtup9SXIZMVrtK6lPlRCqUv8yRpp AMIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=UAxfvOZVLs+uiO996nUO+MUMq3F8v5WP14P/MYRhXP8=; b=bB9l9VTzqsQBOvX4C5CLm3LHkrM4g15GBqo0+3/mjHvcq3TvItN1wwQfULCs3nvHQI 8LHHI+j8KdRw7Ic72KCTrTCOcpv+2EcLTNomNKBw6YkDhVY7M3Ab1h5wR9vS+efdnrya KYaEoFVbSfpq0HHfbvolvigj5yx/Zcvd+ciXb+nzNu2lJKHlvZl1hoP6E0B0zemEjl3Z 6W8FzqSKj7s5zdefi0IBac24/H9q34tOo5uXDFjE6FL8LX18+50cHPVijyR1hkr8a4ku wOvYRp2rwnePoA54uCXMvUwVsXV4u5okoZ66cImTaFxqxbdn/RA3NpqMoIuecVqvGz3A 0eww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cBjSjV5P; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y25sor872676ljc.105.2018.04.12.04.15.04 for (Google Transport Security); Thu, 12 Apr 2018 04:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cBjSjV5P; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UAxfvOZVLs+uiO996nUO+MUMq3F8v5WP14P/MYRhXP8=; b=cBjSjV5PFnD07h1O6LvsK2itl23RxL65cjFIgieNsawqWbvb7yi1AzU81SLXaNh7EY DBSYxG4mP28jav9kJtKAsJ/BAk7+Jlv8kbPNso5zCNfrnL8wfj+Qii5PBnXjOfYGpE3M jPP/wvA2v+RF9jhIYw844gNURAugVixGf8zf4= 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=UAxfvOZVLs+uiO996nUO+MUMq3F8v5WP14P/MYRhXP8=; b=BTOdvwLATyN/UdfZBI9hK7QbVHpcy8jR/GHRuEUyUWUUIKi2kcRnzw4TM4PzksA450 qW80GT9b/tQ2ujfki2IT8NZFvR66/fDieDp6tLuG/zEFgfbbdgaSVHZcQzD7w3+Ub5dF M+wtua6o9d0ZwUYXq80I0JnGicko5qmcgVP4ntxQpjHSgKnyVNMOE6p1TiuLEg0g7bzR UqAjzGvrWPUCP0gk6dCWBpnxpGHEB4RWRjg7BDy6y+7qb1DHzkbGf09VS5ggclNMTP+m Ro6yVaqeQVxfz11u6SMziuWhQ8kN+N95Y6doWSb8cX5q1wCN9bpVxwjdRT68oJ/oM5NH aj8Q== X-Gm-Message-State: ALQs6tCjWPYgpHyeQXawH16R4q1x098u4UWQrJxn7m6yOcC8unJI6qz3 q83SX7l6is2BPmRVHnbFsPqqh6lF X-Google-Smtp-Source: AIpwx4+j5+eSgEk0LXcdiOH0Et0QWH2XgEfLgDNuqtd4+zHQIzO4F1fLM5+KKgKgVKAZMAWW5H1tYQ== X-Received: by 10.46.158.19 with SMTP id e19mr391628ljk.47.1523531704817; Thu, 12 Apr 2018 04:15:04 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:04 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 15/26] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Thu, 12 Apr 2018 13:14:20 +0200 Message-Id: <1523531671-27491-16-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Let's split psci_dt_cpu_init_idle() function into two functions, as to allow following changes to re-use some of the code. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index c80ec1d..9788bfc 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -270,9 +270,26 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +static int psci_dt_parse_state_node(struct device_node *np, u32 *state) +{ + int err = of_property_read_u32(np, "arm,psci-suspend-param", state); + + if (err) { + pr_warn("%pOF missing arm,psci-suspend-param property\n", np); + return err; + } + + if (!psci_power_state_is_valid(*state)) { + pr_warn("Invalid PSCI power state %#x\n", *state); + return -EINVAL; + } + + return 0; +} + static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) { - int i, ret, count = 0; + int i, ret = 0, count = 0; u32 *psci_states; struct device_node *state_node; @@ -291,29 +308,16 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) return -ENOMEM; for (i = 0; i < count; i++) { - u32 state; - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + ret = psci_dt_parse_state_node(state_node, &psci_states[i]); + of_node_put(state_node); - ret = of_property_read_u32(state_node, - "arm,psci-suspend-param", - &state); - if (ret) { - pr_warn(" * %pOF missing arm,psci-suspend-param property\n", - state_node); - of_node_put(state_node); + if (ret) goto free_mem; - } - of_node_put(state_node); - pr_debug("psci-power-state %#x index %d\n", state, i); - if (!psci_power_state_is_valid(state)) { - pr_warn("Invalid PSCI power state %#x\n", state); - ret = -EINVAL; - goto free_mem; - } - psci_states[i] = state; + pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0; From patchwork Thu Apr 12 11:14:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133254 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573787ljb; Thu, 12 Apr 2018 04:15:06 -0700 (PDT) X-Received: by 10.46.50.11 with SMTP id y11mr378639ljy.149.1523531706928; Thu, 12 Apr 2018 04:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531706; cv=none; d=google.com; s=arc-20160816; b=QZ1yUEGR9euVlv4C+fJJRbcw+OQrQvoNvN5Rbr3INgI4eSwD8UdEYGXuigqAnBtyN8 u0ObYeVj9XqoTEbVcB6uDAynKn8Kq3spjxVgWkevvUpOHsxUHF4OV/SX/qHDfWFoyGqM mC5h7fBgO0drJFrdpUj8n+jyjGWiEek0ZOJ1tGCG7E+6Kl/ljTBHFi35G5ZlTezgirz2 DZRD9eF5n+a+SAEHVC/5/+b3Du4dNLVn65S1DaYYuiwovqTj4jYKlsOxWabzJNqXmIv7 j5eVeF0m0EzjPcNd4L4Ai9Qc8bmbBDs2hC7s1+tfWIh6cBuGichoi2CN1r/w3tbGlZJR 9A+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=2LpY14KKtV2T2Pymd99d2r4VUa+0CGWSlM2NsNRxYZk=; b=snDJEBV3F1yy46owI+EzOu2I6WMJkO5u8vdZ/1c8oAjpql3CeczXaGwiJhtWKKka71 dy/8zU4WFUtBs/hSwD+SXXNUReQCzOiWOgSe29eoW9eVtbsXK2Cxv13OKw90qPGIIMLC sQitwBPxBlxhVDEo0ncVKGFolSBREAfRLYttcpusPmGb5GUnhowZWk3QLRoZXSrpNdWj AcS7/rQ/VCRfgKnxnoc8M6ITVhKi7LZfKSDyjSNNjxBtu96U9PpXk1JAzbhHF8yJbVeA BHMFFegTTIT2+l+RwQvUvE3Fk2hdyB9mthm4c7JcBEzuRK4EGGWeyo96O3frDPRmo8OQ chpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F+PrMGzP; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n5sor906827ljj.80.2018.04.12.04.15.06 for (Google Transport Security); Thu, 12 Apr 2018 04:15:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F+PrMGzP; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2LpY14KKtV2T2Pymd99d2r4VUa+0CGWSlM2NsNRxYZk=; b=F+PrMGzPM0c59NpwIkVVRgJZsDbtLvyWLGfI1iQFyctYpNN7zLpP7DueH3aPDpbYhv 6NBcl06puVrFm63vo47Cx2nuCiVojwRFwhDUnLIML+I/SsPtk4PQf23NOJMTEcChm3jt IT+Fk3nodp91ZSrKmmmS+Yoj9dI4eoAMD5ZtA= 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=2LpY14KKtV2T2Pymd99d2r4VUa+0CGWSlM2NsNRxYZk=; b=MWNTlC048qBL4b5V0ktKMQjODMo5P6htkFV7ySozVo/0mL+gDTCFU/dIAGng4SpoZ4 K28Td72IDpXBo/cjG5xaj5CEWPBFSlCw1L6Fg2wVWagdBoJYOJteyjgmNTCoOh3hUJMJ oc3PBgD+7fXgl8dBtwhoeNO186/wQzDMEp+iSps30gdM2iY0aNZkBhzHIhMEAIORz8Ic p8zxQj2orBxkWotD5TiuD1e2W0Fiu387jG0EQrorZBnXYv22nxoSBWuMxJnC0vEGUPtT dCCJN4l9KBl++lUvXOKVBemXNoQoS9zYekS8MC+2g7YcoHzj+k1OFmrzjMhDNM78bXYM sr/A== X-Gm-Message-State: ALQs6tD7M8foWa5dhujCTUK2GM+nmo4HNu/kH0ZUSYUMfCUBJpNoMPmR PML7P1Rj0P5yLMeenzkLdvcjRupS X-Google-Smtp-Source: AIpwx48q+0SbjQGtw8GIqDgvRWNy9Kw89bB4FSX5hRuftijbVRAEPwlor5gujE4rj0Olxae+55DTBQ== X-Received: by 10.46.65.73 with SMTP id o70mr403882lja.140.1523531706720; Thu, 12 Apr 2018 04:15:06 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:06 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 16/26] drivers: firmware: psci: Support hierarchical CPU idle states Date: Thu, 12 Apr 2018 13:14:21 +0200 Message-Id: <1523531671-27491-17-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> From: Lina Iyer Currently CPU's idle states are represented in a flattened model, via the "cpu-idle-states" binding from within the CPU's device nodes. Support the hierarchical layout, simply by converting to calling the new OF helper, of_get_cpu_state_node(). Cc: Lina Iyer Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 9788bfc..256b4ed 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -294,8 +294,7 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) struct device_node *state_node; /* Count idle states */ - while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - count))) { + while ((state_node = of_get_cpu_state_node(cpu_node, count))) { count++; of_node_put(state_node); } @@ -308,7 +307,7 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) return -ENOMEM; for (i = 0; i < count; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_get_cpu_state_node(cpu_node, i); ret = psci_dt_parse_state_node(state_node, &psci_states[i]); of_node_put(state_node); From patchwork Thu Apr 12 11:14:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133255 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573824ljb; Thu, 12 Apr 2018 04:15:08 -0700 (PDT) X-Received: by 10.46.23.70 with SMTP id l67mr377777lje.132.1523531708418; Thu, 12 Apr 2018 04:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531708; cv=none; d=google.com; s=arc-20160816; b=iC1LGQWh+Cq0esFBnjxankLCPVe46KEjQiAU5f3553yJ5WZNMQChZNp2IxbRnOZQ1F 6BHIoEIJnbAxxfgumNDZY3IfFAI3mXC/HBoBo36cz3b/74RjS3Hp9UE1o8TLPMD/CHL+ gh1X/quNKyusVfalKsjiMysyj01NwuPjEHPkITi7FMrqyYMABjFf7HQ1YPSiUxF8QzLJ T6UxKYTWwhDx0AYxt4iR6NQhVHkPWvX354iKoWN6EEyHzAkJ8vNLRhF+cl1bId5FcfdW cMzqPj2UrZYHMRb8aLAQd+EObGIZfBMWxLsTZriDlniReidGUGSa/OO08aeHKm+yAg27 ERaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PYhBtjezaaEmZ0eR+XM1owcIpoWo9JIYuOj1ACA+7+s=; b=BIy3vwPgta0fH3jjRzj0jOnn2ABC93yG0cOX7V1kcRqEQKeSujtA9niP7XouNTC4dl ZR5B0uj6LsLU6MNKojsbIbxwqoeY5Hl4LHbQKQVK6N1+6kmwsDVeyGuTS0M17Va3Posf d8bthhpPfqBWD96dXYZWZHDdpa2gJotYoZWKk/TXSqXNHC5sBIj3j/S5/83CrMubMccw 4czPzfgBqdvmb9wU66GbGt52ltnVSAXOYPHG5QcEJakrzQiZt7I2PN6lhCXQNuutHZ7s +0EcfGQNPTxf2uNJQ+3MJckXZn1oXl5iw1Lli/MbKxas/Hw12vzvvFPjoapeTfDKjARR QrHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AmksM3vK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r2sor895606ljg.15.2018.04.12.04.15.08 for (Google Transport Security); Thu, 12 Apr 2018 04:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AmksM3vK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PYhBtjezaaEmZ0eR+XM1owcIpoWo9JIYuOj1ACA+7+s=; b=AmksM3vKIKxcaI1989QRGc1s0rL3cuveCZnPP1Q/5sNV9Au+FELWq7Wd8JRBrNf3pE itANAQKacs3r3NvniX0BXF74J9KxeRL8IxiEpgHKToQCo4fIAbDk0JD0KT4P6p+kpd5x n9ovGA/hFDxdUgDC62BUwHnO0yyKWTmHtAfBc= 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=PYhBtjezaaEmZ0eR+XM1owcIpoWo9JIYuOj1ACA+7+s=; b=qbEGNzut3OEtAiQLXfOpV240Q72SAmw9oCqS24bRbG7EyXzYGX2MG+omTyRr39Pk3e hTf81AAg4TdqbaPHLUGe9t9k6Im+/1lj8dQBJrBD1bAgfc8ohJq0DjseS/q/enexTXrL xXIcJuGAP9uMSVxwXgti2o37kCmZlcLIcPdpRV9stulvBLbURCKUXJLVbIOMcafY+ev5 NnleCwOofScvCHL2muJnRs30aMx0Qv6sPeoVc+LP4rLKDXmvadovIq3o/0xHf/7xDWEN 5aZI2UkJGsXRwxgSFlYQ7fL8+/thES7b2fuhvry/+ZI/zJn427ifzWUqQhhPWbYlB8+g /HEQ== X-Gm-Message-State: ALQs6tD8U3sDb2EMGb+4YphQN/jZOUBqiw/9fJvKQVFgUzVcdqz87Rg9 SC0D9UiXqLwDIQliPYBEWgJW0Vtj X-Google-Smtp-Source: AIpwx4+jqCTSrlYsj/+p7GfLrjP0akYXKPREuOGasYM4FsAiageLrYjJgIpS8DVsOXZrYoTNezMwow== X-Received: by 10.46.5.200 with SMTP id 191mr429354ljf.8.1523531708214; Thu, 12 Apr 2018 04:15:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:07 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 17/26] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Thu, 12 Apr 2018 13:14:22 +0200 Message-Id: <1523531671-27491-18-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Instead of having each psci init function taking care of the of_node_put(), let's deal with that from psci_dt_init(), as this enables a bit simpler error path for each psci init function. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson Acked-by: Mark Rutland --- drivers/firmware/psci/psci.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 256b4ed..3888100 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -608,9 +608,9 @@ static int __init psci_0_2_init(struct device_node *np) int err; err = get_set_conduit_method(np); - if (err) - goto out_put_node; + return err; + /* * Starting with v0.2, the PSCI specification introduced a call * (PSCI_VERSION) that allows probing the firmware version, so @@ -618,11 +618,7 @@ static int __init psci_0_2_init(struct device_node *np) * can be carried out according to the specific version reported * by firmware */ - err = psci_probe(); - -out_put_node: - of_node_put(np); - return err; + return psci_probe(); } /* @@ -634,9 +630,8 @@ static int __init psci_0_1_init(struct device_node *np) int err; err = get_set_conduit_method(np); - if (err) - goto out_put_node; + return err; pr_info("Using PSCI v0.1 Function IDs from DT\n"); @@ -660,9 +655,7 @@ static int __init psci_0_1_init(struct device_node *np) psci_ops.migrate = psci_migrate; } -out_put_node: - of_node_put(np); - return err; + return 0; } static const struct of_device_id psci_of_match[] __initconst = { @@ -677,6 +670,7 @@ int __init psci_dt_init(void) struct device_node *np; const struct of_device_id *matched_np; psci_initcall_t init_fn; + int ret; np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np); @@ -684,7 +678,10 @@ int __init psci_dt_init(void) return -ENODEV; init_fn = (psci_initcall_t)matched_np->data; - return init_fn(np); + ret = init_fn(np); + + of_node_put(np); + return ret; } #ifdef CONFIG_ACPI From patchwork Thu Apr 12 11:14:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133256 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573861ljb; Thu, 12 Apr 2018 04:15:10 -0700 (PDT) X-Received: by 10.46.135.7 with SMTP id m7mr409211lji.106.1523531710330; Thu, 12 Apr 2018 04:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531710; cv=none; d=google.com; s=arc-20160816; b=z4t97xRRr+72n8PjiU/mUgmTobKsYmRiJ4PVwfKOJIDF7qMGhAVp8o6/XQLGNPDOpP 7Xb64qZeLbLYR/ti3Umnf4ZfG6QUFjE4lDttOlvhlKNSvoiItygpACHwxMBbEHEJHopY N+ZiiSSaYWuSul3Kh7HW4vimaQSulG43oJj2x9sny7IQ+rAAk2ZY65BCqZDOzC9dvCin Oe8dPro2pJ6CNNhBtKshl0SQRopBKPwrtrEdLUdc019CgHM5mJ9oMugWnUx8yy6WekO9 tPtRLO6BXKoXxH8IOsE9Al6bIJJNulu5fhYBSdOijlNJc/2rIm5brznh/GptrMjC96t8 RI3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=1DBONOHXXjX8Kaigqhj/3cmJ8OlitzG5zYoiAvHZb/g=; b=ANoUL16UAta9SqxCK4DAT9hyKJw9Umfo9i/VVwikKwx7wLjUZ585uFzFtP0exgAKyw dOc1F62nmR1XHWAg6Nh2+7lxBmKYEoB3QY7UwIE2YW4I2P4IFvpc1ocxdq8RgQ/1Sn46 +mLk2v3cKt2J2NIhGk7EzcnUH8UsVIUoFHyVW0uBuzs6k/R3ipuQwuW9fyz0ff2RRU+o lW7WzvePYkfUIsvR2CIVQZ11zhoKdOGQNm1+nQo3ARgjD5YZtiGYJkQzP0QUvKzRFX3P rd8WEg626ArBy1AskzpEQXeQQQkoiycB+gUy8mr1qm/QRjWuHrcsAHCWDHnM3+qeVWh6 kXSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U/r3NZCa; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v13sor886749ljj.66.2018.04.12.04.15.10 for (Google Transport Security); Thu, 12 Apr 2018 04:15:10 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U/r3NZCa; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1DBONOHXXjX8Kaigqhj/3cmJ8OlitzG5zYoiAvHZb/g=; b=U/r3NZCa8C12Vf+V2Y2qSJLRsq0st4u+0Qx0lsIRU8x8Vm1luctSw+eJ3gPaGTcLSd TOTI29yOiI/e3UxFMTk/1QrydsLBBglFduaENCpCVgn1SIlU0APEY65uskvtbuHIOLFx g4yxfbdPrRO8ykq3EYCUGFS8g2EHhdxeTtvd4= 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=1DBONOHXXjX8Kaigqhj/3cmJ8OlitzG5zYoiAvHZb/g=; b=Y9bcYif5X4OywN4Z76AKRNSru5ETE1wgrTTsDAy4+wbXRVYRjpwTdO/PjIBsBYh8r3 0CGevvgLXlZ8bl/6IvZefLRSWfVufSzi3F3tz57V7DOKJKnk+wF46wkHYWvL2al57BK2 YGcjUklPa0lxVdaAiHBrlHZrR05HTn4rR2upDuVTrmDADRPE9STDvgmEkWSJP3VKUj6X kOTtUncWD7zz1K1iHUNZQLbhKWeiUo/iyDbA7KolqfKuK8rQ9Yd62rV2Up9B+Q5vQ8mA J/Rhm/LIi79IWVdxa30DHdLI5ZpvETgsZSHqo1qiOrqsbaWG/3CVjn6dB9wcfMd+SZ+9 /r+w== X-Gm-Message-State: ALQs6tACk7nPCZ1jpaqAsVeQ8HfZbwiDmCezvQs51raIg3a0jzEiS6jA +liR8JkMs7YHv4Ggra1hX9YrgOFP X-Google-Smtp-Source: AIpwx48Sp/tWcEjzQqkAvrBqtKm9Rg/ZeTNvMLFDQdCNp6JnMaDEqmLfajm7tK3Pe3AwidGQ9kBB/w== X-Received: by 10.46.131.86 with SMTP id l22mr387680ljh.82.1523531710097; Thu, 12 Apr 2018 04:15:10 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:09 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 18/26] drivers: firmware: psci: Announce support for OS initiated suspend mode Date: Thu, 12 Apr 2018 13:14:23 +0200 Message-Id: <1523531671-27491-19-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> PSCI firmware v1.0+, supports two different modes for CPU_SUSPEND. The Platform Coordinated mode, which is the default and mandatory mode, while support for the OS initiated mode is optional. This change introduces initial support for the OS initiated mode, in way that it adds the related PSCI bits from the spec and prints a message in the log to inform whether the mode is supported by the PSCI FW. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 21 ++++++++++++++++++++- include/uapi/linux/psci.h | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 3888100..e8f4f84 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -95,6 +95,11 @@ 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) +{ + return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; +} + static inline bool psci_power_state_loses_context(u32 state) { const u32 mask = psci_has_ext_power_state() ? @@ -658,10 +663,24 @@ static int __init psci_0_1_init(struct device_node *np) return 0; } +static int __init psci_1_0_init(struct device_node *np) +{ + int err; + + err = psci_0_2_init(np); + if (err) + return err; + + if (psci_has_osi_support()) + pr_info("OSI mode supported.\n"); + + return 0; +} + static const struct of_device_id psci_of_match[] __initconst = { { .compatible = "arm,psci", .data = psci_0_1_init}, { .compatible = "arm,psci-0.2", .data = psci_0_2_init}, - { .compatible = "arm,psci-1.0", .data = psci_0_2_init}, + { .compatible = "arm,psci-1.0", .data = psci_1_0_init}, {}, }; diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index b3bcabe..581f720 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -49,6 +49,7 @@ #define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10) #define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14) +#define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15) #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) @@ -97,6 +98,10 @@ #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK \ (0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT) +#define PSCI_1_0_OS_INITIATED BIT(0) +#define PSCI_1_0_SUSPEND_MODE_PC 0 +#define PSCI_1_0_SUSPEND_MODE_OSI 1 + /* PSCI return values (inclusive of all PSCI versions) */ #define PSCI_RET_SUCCESS 0 #define PSCI_RET_NOT_SUPPORTED -1 From patchwork Thu Apr 12 11:14:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133257 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573888ljb; Thu, 12 Apr 2018 04:15:12 -0700 (PDT) X-Received: by 10.46.54.20 with SMTP id d20mr381466lja.114.1523531712131; Thu, 12 Apr 2018 04:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531712; cv=none; d=google.com; s=arc-20160816; b=g5dMmBByLT2AMN9pg2rBHkCorJLWW2kMqpGhxLUhIpMZRy3K9/0mJn2RdCMsUW9QWT R43iq9ybAimBTnh+mrmITM7jyE2doDrWelw1+ZFf3Slz4jKWOwHhwZKqOZivKa5vBi0U XHs/oXTPUWKfx011FZJghM0e1I+NDfcx5CvzKu2x+AZ4sr5arhXeNcuzAuZLsbqeQis0 TA6LhxwjCrAF2jYhvQ1H+38y/OGgzuTXWhljUh28oO2Oc2UrcTdl+/Or0aH85xshV3cG skLagZluE/tUKK0Z1KWlW5JrvDt0I4vdVpubF4uk5cQxbEBQwyIthgp6BnUPlOHY6b1m WUDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=CLZv/6uOiw9vI+wQv3ueZ/LLuTM3aRhla8SPqP5AgTg=; b=KDTwQhYTK0cinf7DaicT654VPyCiL3pff/UxK5s8rGvJHHSsJRRZj25ElDfXVD0sBO XMqKAuJVgjZXxQxPq1Q71NiU6dp3sSqzhbdXWTq21LxB3eZm8aQS9GaZUSXhAD9a512G zEAXVXc55dPu1bQEoc1STCLhydj66N19HIZ9+NLwQsHDgonbPrT9TdG/WgueM8oNJeC4 edGq12j8ApgnH7uUst9PwzYqZWcSPC7+lfwL3U/lDxPhZwMRzDF0YN3jOUGC1kUlr9TH 7m6XMmnoACbj56ef26s3vdMP//FuwJLSm9QbvL9aqNHU2+IEwXPnjG59AYM6+XHjVd0A cKmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G0+Jh59u; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p22sor897494ljg.12.2018.04.12.04.15.12 for (Google Transport Security); Thu, 12 Apr 2018 04:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G0+Jh59u; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CLZv/6uOiw9vI+wQv3ueZ/LLuTM3aRhla8SPqP5AgTg=; b=G0+Jh59umkwJB698c2RB2If9ZKDrVHtAZJJ9hiEz8/AkLQGSrhuVT+RlUjxhVAOh6L pfxiY4BdeBJK8EOWO9pQzVleBnDliJ0aeIlC6oVBxNaV3x2J8KvyqKOinx3E8G2jIA/R BPpB6lHGYj001AEiAcq9Onb+m07GbhBlSIWMY= 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=CLZv/6uOiw9vI+wQv3ueZ/LLuTM3aRhla8SPqP5AgTg=; b=QEO5KVmqQl6DYN/Iv3phS6Amznlcex4fccbhF4a4e1ZJN9zsJAC7j6nTgaCrG8FWZF V/Ls/P0M1Fu4uYjAl7EQd6MPShe22l/bByFnkVGCBu/4u5Cq6PypTItHfd45FQPa2EGD a4ukYZY1Jxo6BNbUf4lwwo+LkDxMs6IlFeTZluAUqwCPYF1dL0BoY645O736QpZH8EJ9 CmZu7hJFxi9XXoiaqT3zN0ZUvs041AxJYOq315XQoUrs3byWpECHkDDSm2OMMiClZb24 RuYKdLIWff5ZgMbD18YBFhw8JFCsMfrgfkXrebNLhZHdOwkTkHvgBynAbuBh+bmhcvvK rXKg== X-Gm-Message-State: ALQs6tD0isnt7eaRPot9POF/77aGzFy12yu/tGB6wNW0mAX/rRxnKmrV 1kiWWB4vS9irdsTZFYDi4C5X1m6h X-Google-Smtp-Source: AIpwx49a8s23MUX5vh6XozH+RnJhKfmqz1q6V2EcaUj79apwzrfUBotIEY1uyL6zbmdGN3PviPm8hA== X-Received: by 10.46.41.19 with SMTP id u19mr415801lje.62.1523531711875; Thu, 12 Apr 2018 04:15:11 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:11 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 19/26] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Thu, 12 Apr 2018 13:14:24 +0200 Message-Id: <1523531671-27491-20-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> To enable the OS initiated mode, the CPU topology needs to be described using the hierarchical model in DT. When used, the idle state bits for the CPU needs to be created by ORing the bits for CPU's selected idle state with the bits for CPU's PM domain (CPU's cluster) idle state. Let's prepare the PSCI driver to deal with this, via introducing a per CPU variable called domain_state and by adding internal helpers to read/write the value of variable. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index e8f4f84..40b2b89 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -87,8 +87,19 @@ static u32 psci_function_id[PSCI_FN_MAX]; (PSCI_1_0_EXT_POWER_STATE_ID_MASK | \ PSCI_1_0_EXT_POWER_STATE_TYPE_MASK) +static DEFINE_PER_CPU(u32, domain_state); static u32 psci_cpu_suspend_feature; +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 inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature & @@ -187,6 +198,8 @@ 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); + /* Clear the domain state to start fresh. */ + psci_set_domain_state(0); return psci_to_linux_errno(err); } @@ -408,15 +421,17 @@ int psci_cpu_init_idle(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 @@ -424,11 +439,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 Thu Apr 12 11:14:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133258 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573906ljb; Thu, 12 Apr 2018 04:15:13 -0700 (PDT) X-Received: by 10.46.152.18 with SMTP id a18mr391665ljj.34.1523531713702; Thu, 12 Apr 2018 04:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531713; cv=none; d=google.com; s=arc-20160816; b=GtRF8/Gzx2r8zxEsIXdOpCDKAVVA+yyg5HBrDkSJPMiuNVTQS1Kaxj348TOcQwg2tw rAkmz+/gfESkVLcF4F1wcC09n+IFg54LhR/vQUFX066FVWpOvbloe5pZrq9BTLvIaN56 QxxbV+ta5UtYYt/JZtNCdJuvscakGl30KHJKsg1Rqz6bXwc7BCLh1tdHxq6lA3/9D3UP iEzhhbe0cnI3+uN8My34Og7W/RZ9ECOqSnKD1Jk98kd0gFYpFvH1UwtJg1IalrMNmQxe dcXQ76YSyvcM3QxNhfhQ1aSiLFjq2epZm2JEji/l2b0h/nLPO6/EbTYanAvR628P6Ai2 +fPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hseTtS2KhZHQ1K7w2clWbOmk4nomnwkr9RlA+X+mFa0=; b=oSnEL2Zc0vt4RmtuuxQm3XkxkNgsX+PFU0WoZsDIu5t4vE3apnDziPZtn316CtPvOd YzfViJeOxxSVtVpB5GiPrc1X5voJlOv81dcaqqgYeLTrwG7WFBOICp93vXKXL+dG3jIS eEQM0UAqMNWqCfqEMqauO1RHTqU8/6yHsYEo79eyC9+444KvV2H5bjaToryL2m00abut fSNEzgd1J70RVnJoCGbVPFbci3W69I4J++MXPlnym9jQywm3zQMaEqtc/EWO8Rity8mC DzsNb0I/GIYrgriltMF22gqWuzCl3eYH06IztStKsIwHSgEOB1+ckEHfP0WVG9v3wTQj uoWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ba+amFVy; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f17sor394217ljf.76.2018.04.12.04.15.13 for (Google Transport Security); Thu, 12 Apr 2018 04:15:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ba+amFVy; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hseTtS2KhZHQ1K7w2clWbOmk4nomnwkr9RlA+X+mFa0=; b=Ba+amFVyj1BjfIC/JrvwvMCgEZ3dH2j6k5u4kCYiXFSRYSoY8Lbmcsa3AOwTUvUCiS Z+CTcbdp3asiIu86iuIsLb4slrOTVBNedTtfVUzPOSNGNFIDV/w5MVbaQhe2nL+6+RqJ NO37I4NmPHBMFUXOgxrDS6zn4IreMg44M+RBc= 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=hseTtS2KhZHQ1K7w2clWbOmk4nomnwkr9RlA+X+mFa0=; b=ZTL6Zee2jny++hBH07lKsGbx5n9jxrIdmuLGli/jXkD+6i5SSpgaX5BqGEZhvxgelZ h1g210tomv5WrS/2XhbirPgneNvAAEfb0doMvfKenSCjhk7jzA8rzQqdW/8BQGE5cQmp 8boQoLdXC2PMLxjlj8WVXOv8mdGj/gd/tkln5M2Hp/oOrWqQJZuC+BnPLx/Mz/yKwF/E DyMfZXpZ67AU9Ke4Y62FoVdAhn0WNODygVwY6o8KmXFC0Go6IiSEJPbkk2au60W0DZPR XW87mSIGDV1oz3Kp2Sp50xpVhUeNQLv2ln/rffimCqygCqJkeIoRJbEYt02kFKTOnXu1 rR/Q== X-Gm-Message-State: ALQs6tAxIDZ5u54a//t4K21dZnUwhwyrG42u/CDEG7bOU0l6YnwqY7X9 e12c0S29PpIJ4zy1XVOqrjSK1vxh X-Google-Smtp-Source: AIpwx4929jwOgOcZ9uB9kCN5AUTbzC9jMcjlBRjqKXfP5bbtB6BTeE9gFg9uAdDhCxZT0LHETDHqAg== X-Received: by 10.46.115.8 with SMTP id o8mr386413ljc.99.1523531713483; Thu, 12 Apr 2018 04:15:13 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:12 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 20/26] drivers: firmware: psci: Share a few internal PSCI functions Date: Thu, 12 Apr 2018 13:14:25 +0200 Message-Id: <1523531671-27491-21-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Following changes needs to be able to call psci_get|set_domain_state() and psci_dt_parse_state_node(), but from a separate file. Let's make that possible by sharing them via a new internal PSCI header file. Cc: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 14 ++++++++------ drivers/firmware/psci/psci.h | 13 +++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 drivers/firmware/psci/psci.h -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 40b2b89..463f78c 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. @@ -90,12 +92,12 @@ static u32 psci_function_id[PSCI_FN_MAX]; static DEFINE_PER_CPU(u32, domain_state); static u32 psci_cpu_suspend_feature; -static inline u32 psci_get_domain_state(void) +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); } @@ -285,10 +287,7 @@ static int __init psci_features(u32 psci_func_id) psci_func_id, 0, 0); } -#ifdef CONFIG_CPU_IDLE -static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_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); @@ -305,6 +304,9 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } +#ifdef CONFIG_CPU_IDLE +static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); + static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) { int i, ret = 0, count = 0; diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h new file mode 100644 index 0000000..a2b4be5 --- /dev/null +++ b/drivers/firmware/psci/psci.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +#ifndef __PSCI_H +#define __PSCI_H + +struct device_node; + +u32 psci_get_domain_state(void); +void psci_set_domain_state(u32 state); + +int psci_dt_parse_state_node(struct device_node *np, u32 *state); + +#endif /* __PSCI_H */ From patchwork Thu Apr 12 11:14:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133259 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573941ljb; Thu, 12 Apr 2018 04:15:15 -0700 (PDT) X-Received: by 10.46.154.71 with SMTP id k7mr391516ljj.42.1523531715722; Thu, 12 Apr 2018 04:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531715; cv=none; d=google.com; s=arc-20160816; b=z4pNWm+Guq8zs7l59+bZkeYe4P1LLXpohJ8k8ERwqgijD0+NL4a/JBY9Dduvinh479 LoxxtRH4yrrVfylozqNucKI/XZ89DIoeI0qbW7FzLNPBWcu8x/wN52EF5pb9hMA3j5M9 403J8Dydd2glV+eoFvAkcWpWeveN+zzkAv2cPxMSVm/QE5Ve5zKEBamFEtmw0RY4Ta32 5v+aFT1ajJmI1dyuBRWDxq2xeybn33O9PpsQUAutu2jzJeks7BcRG5mAN6algu8HN3qs xKkPbGCmR1AdUuzpl6ZBdwDPi1pQSRH7qHmHVzUqBWO3u7jLZDxpd1H4vFgSHs/BjhYc s6kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=sUDYgpzj5UEmCSSCZ9crCjUGiIscG774f2rkxIW5KB4=; b=p41B3VLJEv2f1n7/g/p60B7m+KCs3oWg1fPmkKBqNKKH2xDarU4o+VlnopzUfgJpj7 aeSJf3IQKTgNBbaSCofYElC7hBpl61ZRx2MnM7gZ8Is1ujEjbHrr6vGZLzXLhZm3Kbxe qPFMcSPYP8WRmqoPbvjxWS1GjKOph2XrFeaLknkUMIZafwM2p72iAiegueEaiqxW7705 QROSTjQ5dq+jAFJ3KOhbahS94AVp4HX5MKWlKxLB63V31Ae8aq0svahNnTyQ8F+hJtCb pqm1zqsWtvqWtSlSymt75Z6oYU/Ip8spLnjO6AtHZlAaet7VOQXzfTNMdIxq7bUm7JBb Rg0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YlhQTWH8; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e21sor903100ljg.69.2018.04.12.04.15.15 for (Google Transport Security); Thu, 12 Apr 2018 04:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YlhQTWH8; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sUDYgpzj5UEmCSSCZ9crCjUGiIscG774f2rkxIW5KB4=; b=YlhQTWH8cln8qYjbcsgLR/SNd5P/HvcUQHKLvJtPfdLxF16O6UxC5Pmlmae6mOXFed in0xdh846+EH2TrpIhMljitdh13P6X01+XeatB6IPLnTaYMqP4o/hiNSiK4nlxVFMPE5 Kk6V+GNngd1lSS20oh/X+39CH2JXgoq8KEV1c= 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=sUDYgpzj5UEmCSSCZ9crCjUGiIscG774f2rkxIW5KB4=; b=HHnkrIWgP+ubBFz/xmPHUZNSYJF0++16xXCpymFR5qTECW4JQnYl30AyyN5IPfHiYR /ZugiMbda3nuUFJoHf05KHkWPyLVCF/UqcjdudIDdcBh7M3Jkc4unTikYcwMuShxFJAS ZWoAOHPxiQeXxaFopZBZ21HiVhloWcpnptaCanrOdRbLsppxzw9Safjoc3tZH3sD70j/ CCqvU3Qq6WBr6sAmBIPR8C4gwkhtVE3du858+fXwFUPibHNmhKL1WFIo9Zq6Dbzxb92c VhfBIyNsiHRA3/JeUlqf1x722BHWN5YDoYUjlxMp0biCh4cxk2gjjnbu/P7ty0tUFJ2G seDw== X-Gm-Message-State: ALQs6tDCuyM5oRtLmVbTCirrAszwNnlm8mdjmJ6AV/qWv0xfJnr8neAD 67RAaC1Y7jMDlLcmFGIiTHBISHd7 X-Google-Smtp-Source: AIpwx4/8ymmQwjHjuavmhtWzR0YzoPugxpuzJRCkBA/y9gVfbnzt2+5U24v02c77GQXeFHvn0IbT1g== X-Received: by 10.46.137.71 with SMTP id b7mr365006ljk.39.1523531715432; Thu, 12 Apr 2018 04:15:15 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:14 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 21/26] drivers: firmware: psci: Add support for PM domains using genpd Date: Thu, 12 Apr 2018 13:14:26 +0200 Message-Id: <1523531671-27491-22-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> When the hierarchical layout is used in DT, as to describe the PM topology for the CPUs, which are managed by PSCI, we want to be able to initialize and setup the corresponding PM domain data structures. Let's make this possible via adding a new file, psci_pm_domains.c and implement the needed interface towards the generic PM domain (aka genpd). Share a helper function, psci_dt_init_pm_domains(), which the regular PSCI firmware driver may call when it needs to initialize the PM topology using genpd. In principle, the implementation consists of allocating/initializing the genpd data structures, parsing the domain-idle states DT bindings via calling of_genpd_parse_idle_states() and to call pm_genpd_init() for the allocated genpds. Finally, one genpd OF provider is added per genpd. Via DT, this enables devices, including CPU devices, to be attached to the created genpds. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/Makefile | 2 +- drivers/firmware/psci/psci.h | 6 ++ drivers/firmware/psci/psci_pm_domain.c | 180 +++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/psci/psci_pm_domain.c -- 2.7.4 diff --git a/drivers/firmware/psci/Makefile b/drivers/firmware/psci/Makefile index 1956b88..ff300f1 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.h b/drivers/firmware/psci/psci.h index a2b4be5..8b6fe51 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -10,4 +10,10 @@ 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 /* __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 0000000..f54819e --- /dev/null +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PM domains for CPUs via genpd - managed by PSCI. + * + * Copyright (C) 2018 Linaro Ltd. + * Author: Ulf Hansson + * + */ + +#define pr_fmt(fmt) "psci: " fmt + +#include +#include +#include +#include +#include + +#include "psci.h" + +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF +static int psci_pd_power_off(struct generic_pm_domain *pd) +{ + struct genpd_power_state *state = &pd->states[pd->state_idx]; + u32 *pd_state; + u32 composite_pd_state; + + if (!state->data) + return 0; + + pd_state = state->data; + composite_pd_state = *pd_state | psci_get_domain_state(); + psci_set_domain_state(composite_pd_state); + + return 0; +} + +static int psci_dt_parse_pd_states(struct genpd_power_state *states, + int state_count) +{ + int i, err; + u32 *psci_states; + + if (!state_count) + return 0; + + psci_states = kcalloc(state_count, sizeof(psci_states), GFP_KERNEL); + if (!psci_states) + return -ENOMEM; + + for (i = 0; i < state_count; i++) { + err = psci_dt_parse_state_node(to_of_node(states[i].fwnode), + &psci_states[i]); + if (err) { + kfree(psci_states); + return err; + } + } + + for (i = 0; i < state_count; i++) + states[i].data = &psci_states[i]; + + return 0; +} + +static int psci_dt_init_genpd(struct device_node *np, + struct genpd_power_state *states, + unsigned int state_count) +{ + struct generic_pm_domain *pd; + struct dev_power_governor *pd_gov; + int ret = -ENOMEM; + + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) + return -ENOMEM; + + pd->name = kasprintf(GFP_KERNEL, "%pOF", np); + if (!pd->name) + goto free_pd; + + 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) + goto free_name; + + ret = of_genpd_add_provider_simple(np, pd); + if (ret) + goto remove_pd; + + pr_info("init PM domain %s\n", pd->name); + return 0; + +remove_pd: + pm_genpd_remove(pd); +free_name: + kfree(pd->name); +free_pd: + kfree(pd); + pr_err("failed to init PM domain ret=%d %pOF\n", ret, np); + return ret; +} + +static int psci_dt_set_genpd_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; + struct genpd_power_state *states; + int state_count; + int pd_count = 0; + int ret; + + /* Parse child nodes for "#power-domain-cells". */ + for_each_child_of_node(np, node) { + if (!of_find_property(node, "#power-domain-cells", NULL)) + continue; + + ret = of_genpd_parse_idle_states(node, &states, &state_count); + if (ret) + goto err_put; + + ret = psci_dt_parse_pd_states(states, state_count); + if (ret) + goto err_put; + + ret = psci_dt_init_genpd(node, states, state_count); + if (ret) + goto err_put; + + pd_count++; + } + + if (!pd_count) + return 0; + + ret = psci_dt_set_genpd_topology(np); + if (ret) + goto err_msg; + + return pd_count; + +err_put: + of_node_put(node); +err_msg: + pr_err("failed to create PM domains ret=%d\n", ret); + return ret; +} +#endif From patchwork Thu Apr 12 11:14:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133260 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573970ljb; Thu, 12 Apr 2018 04:15:17 -0700 (PDT) X-Received: by 2002:a19:1f4a:: with SMTP id f71-v6mr5128110lff.12.1523531717590; Thu, 12 Apr 2018 04:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531717; cv=none; d=google.com; s=arc-20160816; b=SyE8eF53Yyg/Q7rTHJxazGo+1edxL5jv9wJNsBALvrnwjJl3j1AEK3RxKxSQIEzhKp 6cJPEjk/2wsSyGnC2c3Z0N6Q1cdouqYvm4uvv2emmtcau1BJTkOaXC8k/G2KOtv7oH4S eOoN8Dx3rcT/vetjGo8l4B0svvFnbPf7QU3e5OPv4pWJY7b/l5XgxVZaE+NduPadHMAy YSAgsrG3ayvoo0toIo5rxNAUhrQ4RdXMojNKW48Or+KBASlqAvBY9YLW0oHErKiwkA61 d/YQ7OXHlogq87qyzUkIZvobEw/yFF802tak6W4H1q2xgqnJ+Xpcnqn/VoaSRpilXNpN XkXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=lZist5inIuwEEJSIxPuSJiISOfPfHnqhezws3XCN9lc=; b=bBHt/mGSJve0RWrDHeEti5a2m/2N7jLE3Y0i35Uk2F1HT6/R2XfMoylW7kklaxH7sv ve3Eqq+p0ROQMrIVR3zsSNxJSEEMNZ0xSQ7o+EaOdB44xD/2NyAYCwdnbfMcw6BtTXNX B+vEy3m7VG6o8c1CaNbA4FJSOLm4pwe5yleBzogNA4YEBdVT+tKr86pJwrTs6Lm/DPTO RqSyEAjswGmOoTT04TAi7PqrENkMh9x6NOgfewPqrfkb35hAD8MXmuqT85J+ID8PhOll 33c0L656vTI4/KDK3e7UPeJ/aWxt4AlIfSr4L5pP5u9CrJ0hSUmPwF9LcXw4hxFzxbGJ XlNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WN9dcA8v; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g77-v6sor950256lfl.87.2018.04.12.04.15.17 for (Google Transport Security); Thu, 12 Apr 2018 04:15:17 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WN9dcA8v; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lZist5inIuwEEJSIxPuSJiISOfPfHnqhezws3XCN9lc=; b=WN9dcA8vguQOooj6w8FPqwlbVFl3avmSvgi73nSPSzIzPMt8tyGkFI0Aiby80guIfU YGdl2aAYZKkJ6NQjpXEKOXtFwGgPwNn3MdrB9os5ALVKnpLGbDKQVwxOO6LS/G7aIWdR VxD1XqQdMweeUzk6WjzD3vsYD/hdI/Dw7HslA= 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=lZist5inIuwEEJSIxPuSJiISOfPfHnqhezws3XCN9lc=; b=SvHVQPE+6WLoR1/5aupSZDyH/6scjJeQ1tOBqMNsXJUVX3jb8QzHVbu9zyOJ9mv0O1 6+oOLrM04Y0xI0+nzRavFlOPtqnNXU6aL2sNDytUJ/nMS/ovbEV0zL0gzqb6oBxeOTRu pliSNIWAU1Q4TLCpx1J04+MRDmv4UT4hkOQ/Xt8aViXtfizhful64QeraYq47EnX2+XX v4XDTN5fX0NUTYz5y3YE4edk/OJI5ZCITXIe3W/uXWPiL5mZmtwg4EbjRWxIgiQ+KolZ NfabkieldkgoV6NulOzIJ8IY5zlaxIBghH0wBA+8vVDSiUc/f3d0QEwV+mhBOGOwWyvn 09lg== X-Gm-Message-State: ALQs6tDeBoUjz8/dP9XwLq6Or9zMVVAN6XwZt5IXjs4Aydnu6N0uFmRA +KjRqj1sZOgbG/o3VLn2z06Cghzr X-Google-Smtp-Source: AIpwx4+C7PjClXuqUwftpnZzR/2DE/kVp24K5WNvnaedGYhtjGzgPg/0lnI2ea4EpLYSZwN/+7h93w== X-Received: by 2002:a19:9c0d:: with SMTP id f13-v6mr5201837lfe.9.1523531717327; Thu, 12 Apr 2018 04:15:17 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:16 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 22/26] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Thu, 12 Apr 2018 13:14:27 +0200 Message-Id: <1523531671-27491-23-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> In case the hierarchical layout is used in DT, we want to initialize the corresponding PM domain topology for the CPUs, by using the generic PM domain (aka genpd) infrastructure. At first glance, it may seem feasible to hook into the existing psci_dt_init() function, although because it's called quite early in the boot sequence, allocating the dynamic data structure for a genpd doesn't work. Therefore, let's export a new init function for PSCI, psci_dt_topology_init(), which the ARM machine code should call from a suitable initcall. Succeeding to initialize the PM domain topology, which means at least one instance of a genpd becomes created, allows us to continue to enable the PSCI OS initiated mode for the platform. If everything turns out fine, let's print a message in log to inform the user about the changed mode. In case of any failures, we stick to the default PSCI Platform Coordinated mode. Moreover, in case the kernel started from a kexec call, let's make sure to explicitly default to this mode during boot, in case the previous kernel changed the mode. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 38 +++++++++++++++++++++++++++++++++++++- include/linux/psci.h | 2 ++ 2 files changed, 39 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 463f78c..80c286d 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -691,9 +691,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; } @@ -723,6 +728,37 @@ int __init psci_dt_init(void) return ret; } +int __init psci_dt_topology_init(void) +{ + struct device_node *np; + int ret; + + if (!psci_has_osi_support()) + return 0; + + np = of_find_matching_node_and_match(NULL, psci_of_match, NULL); + if (!np) + return -ENODEV; + + /* Initialize the CPU PM domains based on topology described in DT. */ + ret = psci_dt_init_pm_domains(np); + if (ret <= 0) + goto out; + + /* Enable OSI mode. */ + ret = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + if (ret) { + pr_info("failed to enable OSI mode: %d\n", ret); + goto out; + } + + pr_info("OSI mode enabled.\n"); +out: + 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 8b1b3b5..298a044 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -53,8 +53,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 Thu Apr 12 11:14:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133261 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573997ljb; Thu, 12 Apr 2018 04:15:19 -0700 (PDT) X-Received: by 10.46.158.199 with SMTP id h7mr381116ljk.103.1523531719195; Thu, 12 Apr 2018 04:15:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531719; cv=none; d=google.com; s=arc-20160816; b=wPPyavgC/jlChOD8dS/Tua8Zc/lc/YLBW02fvfOR+xFl6XEjInvRrY0KehVTMZb+6F Gre9RKOG1iuTCgc5b+rYyYoq6N7czIkiayL1jJ27zNgeFi2HscYzzY+O+30gC3dn8wNf iIILAVVrBttboUR4hGYyVFfDrs4kIWbCLBeCOmwN/gVj23I3X8tgVn56vTyPdvgm0Al3 j8LIvyoUOIU2j9I9ernj3ww+4GpgrBb1E9llAv0G5OtzrdODn5xvZ+wWqu4Pw3ZAWWEp andi1cH3eJSLyUVwHDw68xdN+CZAkAPTrCAribGeaXQRSItiATUAXIhUgpYGrM2XczSz My+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/gTZrll8xrDqP3b3gZj5ZKm+3pAu9Ck4XPU4WG+9or8=; b=kcuHI5CIGbPzCWMBy9amqqmaEl133dhppENWo6UalLv16LPk7AKExw4J6RW/p4BPQw ARrTRS06Wr8+gB6FZPEVBAFStSGQm87g+vQfO3pSs3e3B/ecnMSnJrTRWd0BaZeryENe dbGafohnTZwbH8VjfFlkIvROyeDH8riex6L+r0KpFr/8zLQB/kLtoHXO3J4h1VdoMeVx 4iwjV+Flo0zRYynrWNU4ltVgmczCvPqO6M8+N+3zvqCMC9aTbbFo1q8TARJJUgSRegDe Mx8V4NxPinhnbGP4NHasYpst4KPSv500UELO6fPI93Zxk729h3JsGWO/4fc/KgGYTViL kTbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f1G401pn; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h2-v6sor901104lfl.99.2018.04.12.04.15.19 for (Google Transport Security); Thu, 12 Apr 2018 04:15:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f1G401pn; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/gTZrll8xrDqP3b3gZj5ZKm+3pAu9Ck4XPU4WG+9or8=; b=f1G401pncmeFYFtKQuzH8K8t05naTjxSVaBI9Fj8ifS6XLsschLFT65k8Hx4DUYXiJ D1V/3Uv0rU3Vm5VCCxttYmNYr6U7uT1VsKgbPBwpQAOraI6wTi759C+IGpTWhz+yW0i3 dyHaLus68gao6VOQzWgSL3TQ8riNSpVzuNmfw= 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=/gTZrll8xrDqP3b3gZj5ZKm+3pAu9Ck4XPU4WG+9or8=; b=rzAs1mpXH1rfFnSMx5PKuR7RXygO+7fGXkr9+wpY+hOtUtV9s+bRiv0EKf7b3utDqi 1kxjiNg3RTwpE8Vic8cgamYkPLV+worYh/oeOfk775xep+o35X7NIyH18oa8Uw80Z3NB oNXFLCVbTYvLWKm4i9UXuxiFPx9xRw0FgCNErtI42r2DN3Cu38mazSICmh38AgzZq66+ cLoA1bq8VOcFHpvOaTyEkUpK++kMGPf1F9j8VFYkKs+kr/Aes/bZXHC6OdbvRmHWTXgW eoVtU+G7xUgjUuLbgO8CCnCAcBwhXnd41v9QeC9iyqipl4OR+bKFxqDKMREeXH6ujxSV NsfQ== X-Gm-Message-State: ALQs6tCmhXEsDdSAilqfJcltfcxil0yV0+7uPRdMGWc8d7UbR25/MfaU 9VChGiBn/U/kViB4qgu9VIcRZyb9 X-Google-Smtp-Source: AIpwx4/uTTN5AvO/Hwr//Fa5h2ts6SpaXnnQR+qdf1ZCqoguXw4aahiYj9568CGl3R9FgJFTfFXQyg== X-Received: by 2002:a19:4b43:: with SMTP id y64-v6mr5413798lfa.11.1523531718944; Thu, 12 Apr 2018 04:15:18 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:18 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 23/26] drivers: firmware: psci: Try to attach CPU devices to their PM domains Date: Thu, 12 Apr 2018 13:14:28 +0200 Message-Id: <1523531671-27491-24-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> In case the OS initiated CPU suspend mode have been enabled, the PM domain topology for CPUs have earlier been created by PSCI. Let's use this information in psci_dt_cpu_init_idle() as a condition for when it makes sense to try to attach the CPU to its corresponding PM domain, via calling of_genpd_attach_cpu(). If the CPU is attached successfully to its PM domain, idle management is now fully prepared to be controlled through runtime PM for the CPU. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 80c286d..700e0e9 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -91,6 +92,7 @@ static u32 psci_function_id[PSCI_FN_MAX]; static DEFINE_PER_CPU(u32, domain_state); static u32 psci_cpu_suspend_feature; +static bool psci_osi_mode_enabled; u32 psci_get_domain_state(void) { @@ -339,6 +341,14 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; + + /* If running OSI mode, attach the CPU device to its PM domain. */ + if (psci_osi_mode_enabled) { + ret = of_genpd_attach_cpu(cpu); + if (ret) + goto free_mem; + } + return 0; free_mem: @@ -753,6 +763,7 @@ int __init psci_dt_topology_init(void) goto out; } + psci_osi_mode_enabled = true; pr_info("OSI mode enabled.\n"); out: of_node_put(np); From patchwork Thu Apr 12 11:14:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133262 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1574018ljb; Thu, 12 Apr 2018 04:15:21 -0700 (PDT) X-Received: by 10.46.51.2 with SMTP id d2mr344788ljc.131.1523531721007; Thu, 12 Apr 2018 04:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531721; cv=none; d=google.com; s=arc-20160816; b=kv4FBpSuEAZcUM8S61MJLN+13wuRpesgK9sUVFKMykS1ogNahMv8fsGorVPZ6Nk51b 6EYzt5eFAgQvH+JvEe3Ew50y7OxkA0cW/n38MapZvpwc/Zz9yKP0Nle04qvxwlme4UQ5 D5+9Oku8TSbFB9MPDiZEdbPIjL58KlRKJy7zm1BbQlIR/69CV/gwlUBkjBa6DA1sFxB7 W7oRstUYRE8ko9tmfWp4Frk8vXuZ31HujWZsUUODjUoiRFpnJjVjNyEhRz1gLhTJeKBs s1Xxv7IBqRuojnjS7hCaVkWHpcAYA3/RuQ+buMiXuT+2uVOTxQSq/KxEhg+QnCsWF5Wn tLqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=GmFusUm4IUgl6U995YtZ2yCefkzhvUqg/9MbDJuHTvE=; b=GlGxov4B4ZiNA/NTxnjrEPYjje52AG4sU/uVhqzEtRSkAoQN9R6DyD23u6q9+IpmHu iG7VH/vVLELf7LhsUdb5nLTU8sBoAUPe5MsthBZyhTkBvpaGWxHJZGew04d6K45D3SvP mtreeUa4+UrKdyjngiQ++nXChfNHSY0x60mRkUKTtRaETFeT8fH2qbqUjmAJWteT00kc H9ccoVjYxa+li7UmBnxJyuIXkUAtmDimsibTMt1HZUo+kPd+bis2XsawdtFNgLFD8zoG 4bsPIInFSqTPM3HzN4Q0zKq8FI+8Azdw/ct7rRB7oUu87M9EizOJqRcexhv1NhYS0k3t kM8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hpSnQinm; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j8-v6sor914214lfe.7.2018.04.12.04.15.20 for (Google Transport Security); Thu, 12 Apr 2018 04:15:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hpSnQinm; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GmFusUm4IUgl6U995YtZ2yCefkzhvUqg/9MbDJuHTvE=; b=hpSnQinm9rhHxF9ssMlB1eUFo8LtYJhbp7Q7T6bZYbOl1XOlYqkDVCzQs2JAa3bGe4 OsQCr2LUoL33iDda5Vv4GMH454RpU+mji3kbu0GO/ahXZnfgnXQ8Ug4rAaeJU8/n8HyO srQiit8nc+WO9nnoehxNybEsg4jOhKleFlPV0= 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=GmFusUm4IUgl6U995YtZ2yCefkzhvUqg/9MbDJuHTvE=; b=DpFJaVek5ySsDaAyCdR6t/HGOlDqFiVj/K9qNj6ESycXMnjE1vruWxh2eK5dDOVcV9 ZeyYO81oYcI/RwBMeR7XeFqW0nGVCko3Oq8zAYyjO36WmGkKrpcf2mMQDUOgEsyim1Pa Gir8Pnc3wH6xbiVIUIC1O7WbwFQI7CIXebz5sz2qj90etyvoKcs2yPSCg59F3naNW4eS hrZc3lb8ZixFbMzeFaIp12QxJY0ZINK2mwE9cndOIVRRBHP7ABrauuypaIoWqyciBNNV VgO3vyJDnhLq4zZbj5kpS+SXLlxxkogjpP52TIEjcBgwjtkF+tRkMCUcjRUY48ZK5cmz cr1Q== X-Gm-Message-State: ALQs6tAI7W09uL7Jk0fZQ6OnaO5E/JmzhIxUkQdniyM69d9uyDWO07YH 6ISiwDYf/JlrMNIJESVUZ5zF4/KV X-Google-Smtp-Source: AIpwx48DMW7SKu3ka7LBXwAn5XSccfZ7zs+GShxh82BTMXqVldxkvXiNqH51Uu3HgtAcy/E6ssWl+w== X-Received: by 2002:a19:9b08:: with SMTP id d8-v6mr5591185lfe.66.1523531720780; Thu, 12 Apr 2018 04:15:20 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:20 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 24/26] drivers: firmware: psci: Deal with CPU hotplug when using OSI mode Date: Thu, 12 Apr 2018 13:14:29 +0200 Message-Id: <1523531671-27491-25-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> To deal with CPU hotplug when OSI mode is used, the CPU device needs to be detached from its PM domain (genpd) when putting it offline, otherwise the CPU becomes considered as being in use from genpd and runtime PM point of view. Obviously, then we also need to re-attach the CPU device when bring the CPU back online, so let's do this. Cc: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 700e0e9..e649673 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -190,6 +190,10 @@ static int psci_cpu_off(u32 state) int err; u32 fn; + /* If running OSI mode, detach the CPU device from its PM domain. */ + if (psci_osi_mode_enabled) + of_genpd_detach_cpu(smp_processor_id()); + fn = psci_function_id[PSCI_FN_CPU_OFF]; err = invoke_psci_fn(fn, state, 0, 0); return psci_to_linux_errno(err); @@ -204,6 +208,10 @@ static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) err = invoke_psci_fn(fn, cpuid, entry_point, 0); /* Clear the domain state to start fresh. */ psci_set_domain_state(0); + + if (!err && psci_osi_mode_enabled) + of_genpd_attach_cpu(cpuid); + return psci_to_linux_errno(err); } From patchwork Thu Apr 12 11:14:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133263 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1574039ljb; Thu, 12 Apr 2018 04:15:22 -0700 (PDT) X-Received: by 10.46.115.8 with SMTP id o8mr386865ljc.99.1523531722735; Thu, 12 Apr 2018 04:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531722; cv=none; d=google.com; s=arc-20160816; b=h9qwtgOyDzCqN2ml3PqE35dXSC6LeqQzaITClsGTl8G0MBmBHUqDOmz9YEcljJN/kl g890BRnaT66s592o+S/5DWNUs7NzRM+qXqbWuYY8csVad+A2QbKud2CuQYur/mc6n0y3 PUk2CLL2VYCfF8z4SLWxCk7rf5lj+AJRtM/yU5l+USRMrlw+K6zTjHzJD/s2i4rZKL26 8HBDgZ85hdG4R//k6KxnSgl2xgX5eXduk0kf6q+vXgLlAjv8Xcqj/sQE/BTDG+ccbyKD K4PIaRMLst5ZlSVhvhkYq+0HdBqxjM+VdjjQ2r0vfGHOIIlha4TOnXtG5nrIWv9yhROS 031w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=yNE497aPz9W7UIFPW6KZihJP9jsgHg4yN9657mM9uu8=; b=eRg7B+H+sJ7mTbiEzImCN8oSYoNrCmCLKD4Zq5QIAfVXfq56awR3BfZfIFA3TXDYmJ F+8esLbPQQ9KdVROVDHqvFSHUruAegS2S5olaVTEmvr4DxRHI8qG0sANGda26ooc1VWj 1sf17s4aQSF5qdQeGfIhXf6SxF3kzklaGI2ExxZLIDVqQRqrs0g6sR/LIg2C5qzMP/F9 5lUl1YpLVZ4Y068IHMbsjFmVBEip6iynPYadIPrFaSe+uISmDeNyVu/8TRixFVIBxAle zbDIuD+LQ4HFAuAVmVtOjlklb43VhUzKZ+tqrNzw7tUWw85/8ok8tquOvOyGgo/74lAs +E3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cnba7ECu; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i84-v6sor293562lfl.10.2018.04.12.04.15.22 for (Google Transport Security); Thu, 12 Apr 2018 04:15:22 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cnba7ECu; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yNE497aPz9W7UIFPW6KZihJP9jsgHg4yN9657mM9uu8=; b=cnba7ECuwcjsQqGPGMf2qzrwzWe73bxAYgwJTcIqxZ46YracDBKBiGbd9OX3PGhdWW FGhNBmfdqROjt2C3SizH3gNKvTnIXb517Sq5k7ww57QVqAqw7qT12cg7tx+3/F5TXGr0 nrbflIzRM9EMLGkGlxPzMAd0CT9+pjRC5pMVE= 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=yNE497aPz9W7UIFPW6KZihJP9jsgHg4yN9657mM9uu8=; b=o1xjvUW4RH5yLWAx+T1u66YetAwg8T+tUQXlBSzzBN8dn5Ea7W6fJjzbhcVavZB5Xg bCcwqGKqiE3JBMvdqW0XGw94/bX0u30emaVNyaTUwTSENwcr4i0qlwJftNUHo+B1nJQ/ UfSBZu2p9GvIsyl8F0AhbjSoj1553Y4StJ5QgiHJ36eh5eD/BVmVwfthAbdWYppekVmV Qstm4OTrfacOcKCArK+aw1KEyZc0V2YMlMm7eT1gsl/E6p59KXqY2Vcq63pFrcHTuHwS aHyLJoGc+esYi+mOj6RE7/yu1aq1obkyvglzHTfeN0DHFPL5lhQX2WQquwTTPbVkBi/o /b+w== X-Gm-Message-State: ALQs6tAdGOo2leO3Z2Xx3KEq+MbrVQan6eJOtRAbEtVq3GeYT4H2aN/i Qoqjavzl50XpkUbofR0o3+88BrVR X-Google-Smtp-Source: AIpwx49DG9EYClDMCIUPwXQrZhmdbQ6jmm3aGvxM2QAaSkhHv3X60DWSDOY0nMnuH++zjcwbcCOKGw== X-Received: by 2002:a19:d720:: with SMTP id o32-v6mr5110601lfg.89.1523531722532; Thu, 12 Apr 2018 04:15:22 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:21 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon Subject: [PATCH v7 25/26] arm64: kernel: Respect the hierarchical CPU topology in DT for PSCI Date: Thu, 12 Apr 2018 13:14:30 +0200 Message-Id: <1523531671-27491-26-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> To let the PSCI driver to parse the CPU topology in DT, as to create CPU PM domains in case the hierarchical layout is used, let's call psci_dt_topology_init() from the existing topology_init() subsys_initcall. Cc: Catalin Marinas Cc: Will Deacon Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- arch/arm64/kernel/setup.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 30ad2f0..574a504 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -331,6 +331,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 Thu Apr 12 11:14:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133264 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1574076ljb; Thu, 12 Apr 2018 04:15:24 -0700 (PDT) X-Received: by 10.46.131.80 with SMTP id l16mr378275ljh.133.1523531724496; Thu, 12 Apr 2018 04:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531724; cv=none; d=google.com; s=arc-20160816; b=D9VvHboW1NKXIjgUeQ9wFiBTBkG36vENkZLQOBXrat5p15evK0qEokw/no+l2NVo2z oI+nwWA0ChpD7eNEFVmdnA5Wop5oMa49ko3+Nwug24oYdz7VGdpVq/5kGv3j5AclaPnI 7GDPwYnBRFXDf3Gtl7WMyll6Zq4FAvvNLHlVhDPXXwQQNdGyml3rDGP6QmolqtWV/l8e 1c+t9xVSiDYCitIm7H44ZtXE03ftvkx9XZ6llrmgOs04/K8uU4IG2+s0mdT6noKILM4R VsiDPnSlPNk4SW/GxsTW62PUcug2FEjfPPuR1arhEpyOnMJPv/rolyp6W2YCdYPJhB9a IBqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=IIHiCEQkHG1b/nIuCHEJ9c4Cvzg0QwX/XRz1/Yv43Ow=; b=SkfU7tUN2HWiF25qctrbtgJ90kSTaqrAIefgFFxOxDiAV2wsaJEi276rRpu6RsQLg8 R8TycX/GbbY3/u6cOKfxmiFGb2JGI6poBkPp+tQ7TkFnUnMaQ6c8gL42sOEzw5IpAqxE rGQku6JtIr7wMnWKu/EwuJIzD2HKyYcAhXXr6Vh0A/kFgaie1WlhAlkH3ZQoARU4SKqS 1axWv1Ej0bzSqn5DiOMQtc58geT3C1E5FeXZDb6pN9139HBq76zjnmu0lrT3v+H3TLZE QuK2Fhdl0nnyKd4R3fUlHIdcDT7JK4Lt5A2Zj9H4xUkMsIJT01q5qY3VorSGYrUAYhN0 7Fcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ip2YcZ4b; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y194-v6sor899336lfd.95.2018.04.12.04.15.24 for (Google Transport Security); Thu, 12 Apr 2018 04:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ip2YcZ4b; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IIHiCEQkHG1b/nIuCHEJ9c4Cvzg0QwX/XRz1/Yv43Ow=; b=Ip2YcZ4baT7qIUsN3y5QR0iqBIc7WSISvJ2BuTL6zkjcNl1PJr2JXhTXxByHsHgKoA 3J3dCCgHYsWa45OHiNAbt3zf9el5yuaBVI1YX6a5ALLDDdhRWxlNBWuKu/mukgEKsh7o +rQOjas24jYwavIa+vvsrZu1sz+cWBsU9j+tM= 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=IIHiCEQkHG1b/nIuCHEJ9c4Cvzg0QwX/XRz1/Yv43Ow=; b=BKFsZeEDYbp4pB16GKgeuoanBGha9U5CmweVkgoQLlQ3/D++c0htiMWt/g3VRFFOyL Wb34v7oxryviz4JcdOKVjoHbvFhuDAwQWuGQZv/1LrbgdrghH1gE0ZAqE8yV21mwMAix 343EP/UT53gY+5Xd5dAWffpzH3fsMx14hUNLRpzR71e5eLrcT+zpwlJACpYtpn/aer2j lDg9DaEFQbUGzhLR6b7W1MULwDpp5VwX/VwTHUDMiJnYk0F/MTj7vbcDxkNJKe5DkldX rVhU0AWCwRS8FYOI6hcErMrB1L1EDnEhluOP5KI9bmIhM79/o5dnhrwAOrz8yN1joHuM 4uzw== X-Gm-Message-State: ALQs6tDGyDw1/cBmGDp9dJaS6lrIrjfvM3ZcKRADbDYy+0jmOWrFRGhl VkC/9BBwc+fC6yBREX75Iv4DS2Bp X-Google-Smtp-Source: AIpwx48n2Bo1GT2Uhv/dWp+TpReoUUIrsjVRGJeZw6qAx/G6Cj/OS0dFxxp4OLGlDYGnNWOwQsCEhQ== X-Received: by 2002:a19:6a16:: with SMTP id u22-v6mr5000049lfu.123.1523531724219; Thu, 12 Apr 2018 04:15:24 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:23 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Gross , David Brown Subject: [PATCH v7 26/26] arm64: dts: Convert to the hierarchical CPU topology layout for MSM8916 Date: Thu, 12 Apr 2018 13:14:31 +0200 Message-Id: <1523531671-27491-27-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> From: Lina Iyer In the hierarchical layout, we are creating power domains around each CPU and describes the idle states for them inside the power domain provider node. Note that, the CPU's idle states still needs to be compatible with "arm,idle-state". Furthermore, represent the CPU cluster as a separate master power domain, powering the CPU's power domains. The cluster node, contains the idle states for the cluster and each idle state needs to be compatible with the "domain-idle-state". If the running platform is using a PSCI FW that supports the OS initiated CPU suspend mode, which likely should be the case unless the PSCI FW is very old, this change makes the PSCI driver to enable it. Cc: Andy Gross Cc: David Brown Cc: Lina Iyer Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- arch/arm64/boot/dts/qcom/msm8916.dtsi | 53 ++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi index 66b318e..aff4b91 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -113,10 +113,10 @@ reg = <0x0>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs 0>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD0>; }; CPU1: cpu@1 { @@ -125,10 +125,10 @@ reg = <0x1>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs 0>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD1>; }; CPU2: cpu@2 { @@ -137,10 +137,10 @@ reg = <0x2>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs 0>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD2>; }; CPU3: cpu@3 { @@ -149,10 +149,10 @@ reg = <0x3>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs 0>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD3>; }; L2_0: l2-cache { @@ -169,12 +169,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 {