From patchwork Wed Mar 14 16:58: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: 131670 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410119edg; Wed, 14 Mar 2018 09:59:04 -0700 (PDT) X-Received: by 10.46.145.131 with SMTP id f3mr3961708ljg.134.1521046744259; Wed, 14 Mar 2018 09:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046744; cv=none; d=google.com; s=arc-20160816; b=Koq8APHLAXe/XNe/c0SPqoWQZNooTcp+KkKs7tQ/ljFUH6u0cDWuOQpICrJQVWQ1fs Wgm9a7pXkFzrlpGoETEmZWglKkswAIRovySRXAJT3VBBEptKzvoMyR/CLHPsOGF9VYtw ArWGWuTrQjbovMw33XJUjmzXxoSyODL6bj6CMoJWCtnagZ27UdXPDeA7l3VQcmEY0SSR iAmbkQw9nyjpwJ5gMe66cmWY8czUTSijfq8sXjXRWoeQbrOa0Fp/M6QGtdGW8zjBxCgq e5aXkj6OEtoftp2x5Ua/51xxB2353MItpSjKpko/8VKGV3yTZcEKMMxT5l0rGawZbzLV O0QA== 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=YaMnfkFEmbN3EN+784vXetI6vdxnfXNMmaATuL7xpWLKdkKkur3iYh0x2FziySjh6w RK/H8FO0q9iLKhfn8pxszPGCxhpCIBHfQYIr/Pdh7n9xEdr4yjETxosFxV8PK7xlpCD5 w3iT/UU+DlhhoYQ83QKSvFYekxcoIMqtSwucopU4c5xaVYjHAezxHumm6tqy5BccbQAe bsGAN/WeuhtLCfLvQKWdm2dVxvtA87Zo1kttZtX98DGpOz2hmP/4prsx4VNmNCK78stW 1lXc00iTnXwXge6F786aqv3fZec0W11gMHlZX9E72jnPEwgz0ssX5eiBfc3yRUxTBWWA 3NlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VmtvPYm3; 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 y1-v6sor868993lfg.23.2018.03.14.09.59.04 for (Google Transport Security); Wed, 14 Mar 2018 09:59:04 -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=VmtvPYm3; 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=VmtvPYm3ZVkInfG6i5xbFtKCRH4INgwWQGX1yVKFjsPcf/Q+EZY7x5k6EAaLyesW9K MOWYc7hrV0xpM2zKNdlj9jNjlpB+e9DJobq8hdhbe1SZ3bB6LYA/dd7RBXszndDQ2BBq pbbWKr2wfXXQH9u6tJ8nCmOHUVCX9DAlHx20Y= 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=EbVMxDiaRyoVFa7k69xhskS5JgfaIDbBmLgsIDwbX2mIn6HOqoOo49Mn5d/8IEqeap 9dmh7k69AVJbLPTPjbALZW0J9XPbw66iNImV3QpWr5Qx7gtqbgrsx5zXgcmnRPbig9Tq 000JOpWM6FTwLuawMOpGJ0uy1NvUJfoCPWUdngMm+rM2ytuuzSfUNfAyqnWg0UJWhBp8 Jyu0FPUejwIxNDQ5JSkwsyGi1stVbTMa41DWoCC2Di65ERSRXwxR8tNCgz0jF8U9TTFp 4F1QPh8OLJy5bcmaFLMj7oR3DAWINoP7EeF2mBmknYgojLTu0DaC3ebTSz2XuF2rKeEO wVFA== X-Gm-Message-State: AElRT7H2CQ3YiM4RlNFqAxwd4vcEB5hM1hRiPFCcy/WtOQZ92Y7ubSVk ZIIuHq71GKIYZ/PMCVD0w+gGwYHz X-Google-Smtp-Source: AG47ELs3eF+sBpGB/98M1eL8koIYYSgfJ8k9SzJ/PsYUCz/rGNZvzdFkTJJ6vff7P+ksq/Ou7ZusOg== X-Received: by 2002:a19:2ad5:: with SMTP id q82-v6mr3886353lfq.79.1521046743907; Wed, 14 Mar 2018 09:59:03 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:03 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 01/25] PM / Domains: Don't treat zero found compatible idle states as an error Date: Wed, 14 Mar 2018 17:58:11 +0100 Message-Id: <1521046715-30683-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Wed Mar 14 16:58: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: 131671 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410170edg; Wed, 14 Mar 2018 09:59:06 -0700 (PDT) X-Received: by 2002:a19:53cf:: with SMTP id h76-v6mr3882319lfl.87.1521046746056; Wed, 14 Mar 2018 09:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046746; cv=none; d=google.com; s=arc-20160816; b=Z7pXWKXMMScvFPk3NkpSjbZZUPij/LD7NNt3u71fhD7EcRwaAk3l+jpyATGqy0lYMB BcPdVItGRElZU0jzQSBjgdxw0z5sAIMJvGF8Wj/bkZl9ZZ9R/lh0DITKWcWfFZX32uWy YBf2at9IOm6t2sRb+T/iWFCiEEiTO9w4hSmt2IlA74ghTsmuwjCsDkePWVM86Z/6TOky 1Q19tO7YfkHxeHzGl1UVKSudOhLNcK4rJcCpHdMwnzbmbKaPIYpJQ/V9y+WH1frThwqc nD/23XCYVQWDn4fg2cgqLw+7MavwFCy+5rETIHf53IDfuDEgf9xY7b1gBkTHazVnQbZf ovow== 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=tkYmuiHQhYktC1HKnhSUkaiCsxM/JANs8MX1XX/TDdVaDU8iJiE8mh5puZYm6eubto fSSHEvfweB6rQjqqF3mfHsHpYIZ5AT7ts81yoyI6T6qlaM65oRmAQAZVN6mZ0Hr58sut qVELjP4X4DjxI8cfaNPZ0B7ZGiPpp4VGfX7XAHmnn+naRSzTe2yjWfQnNhyZUMT+l4A1 pVuH6mlFMwItUHZLq35zbAnJ0lyjSkoJJR5a8orlmWZUo2ZPnCDyWe/cRBIoAlEGLf55 ExY0JmNUkbazfVMOkIpemK7Q42zojRdKgq9iS3m58JiYSTp5T+E6Xgut8tBKlQEA7i11 Kx2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P0CiJn70; 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 c5-v6sor836377lfh.103.2018.03.14.09.59.05 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=P0CiJn70; 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=P0CiJn705qOhcjGca5bz8eUBHXn3meODQ6jYF+/kEeYFDblxGO3p/417IMjroSoStO JJNMnudAop4Rz7lqUhmcj+ns3kU8b8nRBtRLsEGUTyPNmczz62PTNi4i1rWSoyKi6Agt VHR9VZ4+E6R9jQaIq8lUNSEjv/lfsCc5V5YjY= 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=bfq3V4mf+RoiDzU5sGiMIn7j+GNW2SONpLamQMG3gOAbyg3DUcNbbZkb6ysjAC5luG oNiDUFhmY/TX1+KAn+wTguv80d/qOu55n49lQS9yx9nD+QAeJguUbz4/I7u+Hxa9g07M yMggls2wLjq+5w9f6x0DsTPZ83TxAIOnRgSmjz6jNmCRKfgwS0xBrUQ5PlMzyLDVisRv GFIoRZfsOH6eFzMyHQyyS2XtFfFM/J2nPJ4OSIlBqXCY8uv9E1+Yr3BLzMMwlOR1Ca/I 2MksfcSX78++8wDl2VuDCykVeGgmS7C6Zg4l8rPHGlhla+HsF9leHfmx2XSjHALqlasg jkcQ== X-Gm-Message-State: AElRT7Gq9TaC9bp/1Zgb2gHcF3WvTQC8GWwN7kxFYchVx32TuDzw8Y/i 0hD+Cc17PCw5UYgE/Ui/zjDxSXiH X-Google-Smtp-Source: AG47ELuusa1xbv/nmnv+1O9CYgqmdmemWUivDZQt/P0urbSTvY6vZy+jc7jw+c9OW1ah26aI4+hJTA== X-Received: by 2002:a19:48c7:: with SMTP id v190-v6mr1361194lfa.26.1521046745790; Wed, 14 Mar 2018 09:59:05 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:04 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 02/25] PM / Domains: Deal with multiple states but no governor in genpd Date: Wed, 14 Mar 2018 17:58:12 +0100 Message-Id: <1521046715-30683-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Wed Mar 14 16:58: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: 131672 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410210edg; Wed, 14 Mar 2018 09:59:08 -0700 (PDT) X-Received: by 10.46.112.21 with SMTP id l21mr3720567ljc.45.1521046747934; Wed, 14 Mar 2018 09:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046747; cv=none; d=google.com; s=arc-20160816; b=dRu3mS+Vqs3ixY1h0AqkUzpZ8gpp0J0E2wf7CQjMl6naPiUE8Qj+bJpccjIkUIiFXz RhHnOoSA406JxTiw0d8wXLhYNKldFOpo0qFSMzN9U/vfZbArpI89s3i1e2Gh+66Tmgk4 zza5X1NODzw3ZXwrexSvz5B4fEatR5ClxTBUHtrrrPTc/6KS2e95gyHfWzrJo01fj9pv zcfiYESGJuOmjk3zVz2BXbvrWLu4U1R4rHAMFob9p9B09YW5Oi8+aeUYl/a5kBQQ72UV 6Gn82Ik6iBlKJCwbgDI4bs30MW6yFysa3gt4N22SLpRGMH8pJXyk5ZFax/Q7SyXpsQIr ppPQ== 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=MlfqWbypds5Za6Cw8+bPwcWAP1aSfoKXqALQuoqPjQ1yNcYH6rCWobVO7KMJ2GdSLh UnDztWg8V5TUR4b23BU1cQLz7Uvb1sDzN9mR+zy9S8GDoUBrCRcgB/RETKAEt4FwGznJ 39xXt5UBkqYPY9qp7CJjH12DPVC/m50V2vfQInGvJlRzXfZYjkG+TwpMHm76xEPWbfcL Q7fMDzW5HJ4/Hz2JPOhdxkqACd6nmnaU5MdYcDWpMl11t2n68RuZBafwpd40fb+HHB4+ pjJPwW6u91tKoDlilO63tFQg+N/PivlK7GOv9P0edruvTAu13+MkUAUpZHclYJiN7NaB G0LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gtRqEGmS; 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 j190-v6sor868698lfe.19.2018.03.14.09.59.07 for (Google Transport Security); Wed, 14 Mar 2018 09:59:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gtRqEGmS; 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=gtRqEGmS0b0hXoDxE3Mj0RJdbC184Q1WMbciIhpC8Ck26yYP7kgEBBie50Iq2ztcEA QR2bVwJjy37fR0PCNbw+/f+wOMG7AXHXiQRrjoqSknMc0bPpCEgCbUCTT+sKUVTb8GXt EAdP3twCUSXdszKxQ1AumIxiskanfq3uGsFQQ= 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=rlZMkvqBSZMCQaSONo4TjzQNhOschbqmbghXMLCClW/9b1doppbqi9sguj//n2I9CA oZIuK9eNZ//IVPVx72NhlnJUeDvvqWB+d8GYmiT3af7AF5R38Pi6yqKXNJvCQbIUZ/zq 4roDw2eooT2FtGdbMUfTFOoscyyDCBseeY0Q1bM/r4Fcs3IVXBX9ZXYX8ZEDriKSr8dk A2RIp37lYdoxv71GbNmBGlctpD634Ip3ePkYpany+sY4I2LwJzJ3mikkR/U5DOu21QLr mRH1+aShTNvPGHKVhNmpMXpYrft9Qx9xg6kZbHDz7d35omomhAKyEHXWL5rfofYYQ+Xw 6k0w== X-Gm-Message-State: AElRT7FOg+7fhi8zGngY+qGoSom1JGRV4m5GkRCCaJJaXl/UyIx4hHAo SkCTu58OrX0vvRxfW/tGv47xhNyA X-Google-Smtp-Source: AG47ELsaN+OYArM4e6wd9t+LSqqsc4wUWKc6zcaDjFTzEp8+vtKq1FRHwqj2Na6QWUmQQ0EtSqT+1A== X-Received: by 2002:a19:7b12:: with SMTP id w18-v6mr4094333lfc.104.1521046747682; Wed, 14 Mar 2018 09:59:07 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:06 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 03/25] PM / Domains: Add generic data pointer to genpd_power_state struct Date: Wed, 14 Mar 2018 17:58:13 +0100 Message-Id: <1521046715-30683-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Wed Mar 14 16:58: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: 131673 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410245edg; Wed, 14 Mar 2018 09:59:09 -0700 (PDT) X-Received: by 2002:a19:ea16:: with SMTP id i22-v6mr4103065lfh.65.1521046749720; Wed, 14 Mar 2018 09:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046749; cv=none; d=google.com; s=arc-20160816; b=gFBjcDCdcEgiZKaLOa2DqiboC3u+poFvv5MqijtIQZxTJu8nP94hB8fkvTc1jaRTzT GL6QtXUPjOnK0HxGRAvIC/Xw7q/ycsHIc8v0RRiIss2nk4fV7e8dlbRDCr52qX0Mstt3 VNisvW33E+0T5hasdeCehVWEEJCtUoBbKE8Gjo+WJxYgIC1AG+kihudP+BIHGx9wqfB9 tpIek1MWMvu4BkLL0epKkpsAqjlyADR8lpPrKdZX0vlcs/0QwWZWn4l56l82WX/OPAY0 oLNnsgOTD+W+XDhc/vk/6XJ/s+VholwU9GCtdTllTfWcfCREiP51ZmshzABNEkIGiF2p 6cbg== 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=ayArtu8am9gvbpCTPBw5Ffd1hdmx2bodys+M0eMWq9iigc9/66HlbwjsT05ny5F0m5 S4SSurk/btzO9tN1TEAtrniMGJOFAUbfNTL3GY4hrQ4juypJNrH86S2CKU2B9Vp5dwhT MMlB1GurXMgM2zpnLFmqXv3vruKxDem3lezlqJojC7Reh3exC4B0FI/tVQEexnKfIQIy cGZvZ14NhJWBS/9+c4K5WToC+dQhnt9VxDC/KJe6eBq6ExCnMOiybrID6b+fQfuNTSdi 2bzqeCLUo8oOLndHul9kbNKj/MLLF7rSW39rZN8EFdhFPBPfpdZSGpa1JQDU2w3s/uSk ft+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UeiOYzcZ; 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 r24sor511136ljg.3.2018.03.14.09.59.09 for (Google Transport Security); Wed, 14 Mar 2018 09:59:09 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UeiOYzcZ; 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=UeiOYzcZyDdldntzu2cL9UN5MvhxWIwj13xNr3nzHxzR/XkuNDlK/ad7KLvAlEvIp/ KRS5pPVOVUdSZB8lwn2FArHUP0KkeRQyK5zAxctnjzqeZrGi9CEtMzHr2kaH6wovqPR6 VErpmi0uWPOr0Jlynv67VIr+qrMOlTRTXS3r4= 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=JfJ29B7/uAUm+Uv7sPTkTf3E/Xrq+5it9jxxkXH0m2z5I+wRMmkjynI/paYnr3JN0n EwnCZsosgx32B0Crp4BHomG0nuAA2GhKcLAwR6SzBnhxhi3qTf7tmHXSmo8mARbBTSJV yXS2DbZqD7UHucuo+EfgJ3Zhq+VHy/r1pOBaN27LgooNjrW9z1od+EddVcc8vK8Z9rn7 l5Vn2bmcPNIvRF4aYX3Ia957Dt383HwEuOi/rHKjWyqLnZIfULoE/7KUP9zDtFAZ5l3U isDUOzTgbdgrOJ0dwegNZTpMJVppTNdgdT9Uz/7B2Pws2bOxwgotG3I9dM3xRHkUaU5R AvuQ== X-Gm-Message-State: AElRT7EOfbfuPIkfbI7cV6F7CrvGKt4D2ckNscQAITIeITjzG/fVQIpz mMEGG0ExyN8RV7Vpzz3eNHHd73y5 X-Google-Smtp-Source: AG47ELuKRkw7LTQZg9PXR7QKopdFRb3z4832E7ayuPVtyIvLfd3xGGzeMUWiN+4Fl3EjtStk6uFmbw== X-Received: by 10.46.68.78 with SMTP id r75mr3779893lja.13.1521046749347; Wed, 14 Mar 2018 09:59:09 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:08 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 04/25] PM / Domains: Add support for CPU devices to genpd Date: Wed, 14 Mar 2018 17:58:14 +0100 Message-Id: <1521046715-30683-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Wed Mar 14 16:58: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: 131674 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410301edg; Wed, 14 Mar 2018 09:59:11 -0700 (PDT) X-Received: by 2002:a19:730d:: with SMTP id o13-v6mr4100825lfc.88.1521046751776; Wed, 14 Mar 2018 09:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046751; cv=none; d=google.com; s=arc-20160816; b=H2oDhDbrSm0thihdBmlbJ04FlV/DVwLwueXgUqFBant1MDB07AVHiYlxvFNWyJsiHh sfETD4A43nYFqw1NYxWkxzOaGhOxAkMAKse3v1GEIn3mINEiTSEfwwLCCEJjffrd1W7J rj6oFIdc2XUGHOD5AUdDXuAxVZEw1gQfQmThhmNMKlbHgwRdzlxnxzeh9B3c1Wvo45ct zb6eDoi4rnpLeiQSngH9ORCWXP7foLVExKLpsV7/nXzTag5QAUCb57T6co5GrTPTgpjv relDOCxxpU02OMaDKsGZ6B+OxuIHM18WRyOlP/ZBapTP9VZq10yrbMB68cW+JoQiCVkd gHuA== 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=bZvrw8pC+k3f/FYH1hCWdID/PssUb+AzgpIqJ5q8DXA1knJo9/AatXAX8m49uUmp3L Kl8BGvi5sgzBHbPiHKQMvhXRnSnCBjNKexeQvvEBGoDPE//1bHpuG2vWUh0Um3SrkKUB vIl3BicOjEzHumNKG4TU9bleBXQufno/ENV79ud0kkZiDGASqk190FHZA27ZzrvuGDGG xmGFIxe5gthI7Wu/xORKwQhzHHINicIqdJjft14PnhcVcc1pLaox8qU559KemA80Yfw6 O+nB3L7BcCxmPD0onFVGUx5tTchIniN7UIRrHQDqjGkt3ToJ+OG9WxjTRgB4OU9p50bM QgvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LxD04/+t; 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 r86sor820092lja.24.2018.03.14.09.59.11 for (Google Transport Security); Wed, 14 Mar 2018 09:59:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LxD04/+t; 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=LxD04/+tvmTN2FGUbQRbG0w+J8iLObYFKSIdPUH2f0jPCNOkXl1n2mfgbG0K2A/N9a zdTSy9oV2laYm1++0zKmpZbtMyrmyFwGnz/QSVzqP6M501Aus4FRbIc88s5CFnPyNiXC TFj04l2foXSAIhstN3GA9mh/MRFr97qh9qCGQ= 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=F5I3ylZTs9QLQ7Li+KuEX8Xhtn7JsgvKKRMB9sjDwTfvwPm/1NhPdfywRbsKdC/2Vp Z7yBFZ5ma/cdQx+mBx72IWxa4+x5NLMTzeCLuliKAKRwoYyK8+qwbZ/ZXX7EG+r4DtKY Uov9tQnkBLRChRMxpeRbrVGeJS2cqqZLeWhOX9XPi0CxlykZ6ULzQNQ/9hrQFjIxiXcz wNil+tetccbcc5paO73CNUzPeRUqTh7Xn3p4YTPHJbNzGfflJ4uvdu+TWM3cFBfMUD3L EapdOIp89kNl9xqh9wnkQfHgoweENbMKJR0WfHQ9QBU5rB6RX5n1oHpPXntscpEOuBQS uUHQ== X-Gm-Message-State: AElRT7GA+y3EWCGdEr+zalf1hCNpwzICmxD+R5CeiSHrE0cCp3JP6VuH RwJ2F+qNfGNWoXZ9nmwaxNEVX5iV X-Google-Smtp-Source: AG47ELu6V3o4QSZEKsC/gCA9hVXoP+X1ZZ88qcB0ICIf8m5nnn08S4yV/5ggDgdWhWY98cvedFhmRA== X-Received: by 10.46.12.73 with SMTP id o9mr4010439ljd.68.1521046751472; Wed, 14 Mar 2018 09:59:11 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:10 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 05/25] PM / Domains: Add helper functions to attach/detach CPUs to/from genpd Date: Wed, 14 Mar 2018 17:58:15 +0100 Message-Id: <1521046715-30683-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Wed Mar 14 16:58: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: 131675 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410344edg; Wed, 14 Mar 2018 09:59:13 -0700 (PDT) X-Received: by 2002:a19:5789:: with SMTP id l131-v6mr2876369lfb.135.1521046753553; Wed, 14 Mar 2018 09:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046753; cv=none; d=google.com; s=arc-20160816; b=lforj6fvwJ+nQyDDgXLTc3H7l6ojGZgjb/GyNjwE8RYDdMjVYbULSKlfofZdRulMRH RwjXNhYfgKx7nPkfvGvZxfG5ly1AhG9reCN9iTcIozmZamkfnAtWCqcAkm378DPlBVnP UHTWlxHckgbjS/r5df1XrAzTVwo9ZM3HWIC92O2DmpCxvCBtuDVy6/fJN8qAVC9tYK4h KmesmQn58MtARjL/N1QMAU6OTUbv+DHwIAmIJG5fP332KvJVsg5nlGiPXnXb/1A8R1gk EjO4rywYZhpy4I+iytuRX0W6m8Ooq92LTKUQB3bF4WbLOzIA+CQSDjh2dOtylfR8WkPv yxpw== 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=8UBUtn8CbnkSkAYxAysp6BLgCShK7n+FPP5Gf9WxSFY=; b=qblA4YlWWh28kxJYgBcCKT4voi9HmcRaj+tbKnP/4fTY3JA7S7EaM3RkwX1wdwq17f E8s5wvlU4jYO6/ynxNRNF0q3o9a8QuuI8bHoAKAVye04pw3CidHQjaTbvZDhuaoaKth9 r9as3DGQCChBuYXBHqCs4TTVBMSAD7iLSG4i/bkfazok6u/a2F+J4YZabdhMMfIIaECv B4NoznllANYlfpIxHYn+QAlODieNObjfaPxO/4jvcPKHZldTh/CWcf9fs3d3X6FrgCcx xrQWR+VtQbBqiYUD1v+puZgdg0iOx3L/3olcaYFAlINWcUr78f06I5RhbNGDK+92ZZPG jjVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MlAVsbGl; 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 w21-v6sor65911lfd.86.2018.03.14.09.59.13 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=MlAVsbGl; 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=8UBUtn8CbnkSkAYxAysp6BLgCShK7n+FPP5Gf9WxSFY=; b=MlAVsbGlspSKYxylbRnZrgNpygb0RAeARjinzHmTVmXz8Wkhn37/EMdXiUGEKBa1D0 AH3RfrBYspPr2CN8sIdi97fUONChoDR+Zoman3O2rLneegu9n4dksD3naUvWvTB5Ua4X KOBJejRVpMEygQKvKKx2iY+KU7Y94WBDDZn0A= 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=8UBUtn8CbnkSkAYxAysp6BLgCShK7n+FPP5Gf9WxSFY=; b=XRZZPO5+HOBT9PMBmcP/q8r5cdfKY32ki2hhz6vWDIgGIhoRaV9Rb1WMceI1Pbdlmd GFjbwHpQ7hqiqiQD+Eu53G2lNeRnPlksc4JCu9TClkYstPjF96PyZtzcYUMd1aID12Tm lpZTCzzvQ+koNN+9JcMlz3SZJElAz52djOzhrBCnsElU81pehjaxj0tIDNMWXhrnTU76 TC7KovxFi+YVniB7H1SfHUnGGh5zyipWYA7y9voqBr+6Ib6QzYy8wNmwPVOMaCFKJ3pV 5EvJZDKu+CLDB8j8OWG37TrCcKD435xrhHbtc7LulxF2OjPBoazEjTryoM0u2jw7qSG5 elJA== X-Gm-Message-State: AElRT7FKHYu/hw3k/gRyKoUT20aTDCSEtTXskpJTC0eccPkgWB2A/0vO 54kpkxKJ7p619HlWqR6HQ0zrGuFh X-Google-Smtp-Source: AG47ELta2xPQQqOJ4ft2qVMM/qrfsr9FGkw9wauIscYNQrkxUVDFxvnwmS4WS3QxkP0Jby2ISTjrwQ== X-Received: by 2002:a19:5317:: with SMTP id h23-v6mr3524615lfb.6.1521046753203; Wed, 14 Mar 2018 09:59:13 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:12 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 06/25] timer: Export next wakeup time of a CPU Date: Wed, 14 Mar 2018 17:58:16 +0100 Message-Id: <1521046715-30683-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 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 7cc3592..e51cf2c 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -120,6 +120,7 @@ extern void tick_nohz_irq_exit(void); extern ktime_t tick_nohz_get_sleep_length(void); 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); #else /* !CONFIG_NO_HZ_COMMON */ @@ -132,6 +133,15 @@ static inline ktime_t tick_nohz_get_sleep_length(void) { return NSEC_PER_SEC / HZ; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + ktime_t len = NSEC_PER_SEC/HZ; + + /* Next wake up is the tick period, assume it starts now */ + return ktime_add(len, 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; } #endif /* !CONFIG_NO_HZ_COMMON */ diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 29a5733..da1bff3 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1025,6 +1025,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 Wed Mar 14 16:58: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: 131676 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410385edg; Wed, 14 Mar 2018 09:59:15 -0700 (PDT) X-Received: by 2002:a19:e59d:: with SMTP id i29-v6mr4252251lfk.66.1521046755317; Wed, 14 Mar 2018 09:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046755; cv=none; d=google.com; s=arc-20160816; b=OMURVzKP1rXeBWMKXl5smgDDuFlvIlUAaDCz4C0mggPLf+DskBF0Xjc4ZdyKasOX/w oytBl7GkTAQjLBnjwefYcg5vZw16f3UKGJiDXfvI+nIUJ7M0AgngAhVeaZ1WwmErqqLT 1uEzUcjk9qYmde1zirOhK6wB0ProNwRR90jP5ZIyfJH2N2ZyerrfbYXJR54dgRS5EQTX +MopCVh7iyJ7WT7BX0naenb5elBdDBEmWhZ9vV5LOiK9GV+h3hepk9M0wpWM7/OgVHd0 CrqSRdQZwwYMssgjtkV+sINMPUKmpXoOh5V6je7nxeiaq8VMip3oORW6CMQt1UnjbJBT UNng== 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=01VUm08eQQhxupMLWKqsGfmqGDt6OKm4OXTCGEljJ30=; b=P8CJ7hwV+lOBRDF9vC15AZrtAO1NPzWFoKGWD7j87bu9ZF4OXYzF/q1xvD6cwUuM4f 3sq0KClj3RHj3wh52kgP4ZZX7NzLQmG30YF8B24JBOR3uc6Co3FPVd11At/4s0Pw0rd6 8gik8gq2KVcrGyLkXXibceJhRhQFQ6HtxOGPg9bz5t50C/WoSJQ7b+cPTMUPt7TymnFt gI/VNxujm98aWX7IPuWSUCKHDCS3IehiC/OexVezViCHjQcp8Oo6outP2okHB2X49FLR uVxDwG6JUgINpg1+AENrNy6yUVR+s6A+/hIIR5hFeuLY1PzV/l6+cIVSxzr0DBbcVh9Z W9qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jRoZ38D9; 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 d202-v6sor862400lfg.51.2018.03.14.09.59.15 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=jRoZ38D9; 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=01VUm08eQQhxupMLWKqsGfmqGDt6OKm4OXTCGEljJ30=; b=jRoZ38D9HpPRHeBcADqrCG3WPFYk6M7wFlk/XuO7+Yi6lNB98S47ZCWhQHFExukspF XyaxdIa6jl5P5y7/T9EtLIzp8NV7WKA+Mk4SxLnIBgmeEXW6xevaQC+/wLmCBioDb/40 vV4jRYegxNegvDFar8sJFicJAz/gixn30CKEg= 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=01VUm08eQQhxupMLWKqsGfmqGDt6OKm4OXTCGEljJ30=; b=qypaXKjR97dcoq9K3tF6O2xLN2OAcZAph7ySMxeRrjJMwDHQ5DZ/gNbHWW+G/hikBl ELuY2/I/+IFvnAKPslnOMBtOg4eRFIxO00LmBlc24kPxoW7GJuP7JFPJQIge/KEkjTA7 /npG3UqHeW/qrPVJmFKaHeurefkAS1D7O3RhmVWhgOwS3JgyfUd+R5fRDCra2e3KqLbA n8bf31EvuSDAND+S3ZkVSp8Iz9LSf+Ej8AQzhyrT6mkQL6vUIPVR3XxHuQXPlNonjBb+ 8+t3OqL/+up45iQxyaH3OfZ77cefdOygckc0zogWFhS2BrlyVw7mVQbfSHgXW9NFS80U DRnQ== X-Gm-Message-State: AElRT7Glizgxb3nxU8KLu/NOjlqPSNMWDGIGsZlavkz27VzbA4ddXO1M 6+3BrVXP2nDmOF+/ot9ZWHj8C+90 X-Google-Smtp-Source: AG47ELs/RDCKZ4OvMKXyMvmsGYrv6A27Wj+EihblUhR5Wr4e8/We9ZLGX9W1457J0PRoGUUd80q4gA== X-Received: by 2002:a19:cd4c:: with SMTP id d73-v6mr3838508lfg.12.1521046754984; Wed, 14 Mar 2018 09:59:14 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:14 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 07/25] PM / Domains: Add genpd governor for CPUs Date: Wed, 14 Mar 2018 17:58:17 +0100 Message-Id: <1521046715-30683-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain_governor.c | 56 ++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 2 ++ 2 files changed, 58 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 99896fb..70565a8 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,54 @@ 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. + * 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) + 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 +308,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 Wed Mar 14 16:58: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: 131677 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410407edg; Wed, 14 Mar 2018 09:59:17 -0700 (PDT) X-Received: by 2002:a19:7dd4:: with SMTP id y203-v6mr4165857lfc.32.1521046757026; Wed, 14 Mar 2018 09:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046757; cv=none; d=google.com; s=arc-20160816; b=t8OClHVspD769hv1ZPGCuwRKFa4akU8O7cW8TN0ZmSy7wc7eBBNU69LDqhNILqRIO6 y6pu8qXCRBg6644q8Wl22PvkbIlNtdoI6NZS3uYg33+ft2yWXAlP+f/bt9rLd+swtDJQ 2qWsjFADxUTJmcfDMIpnRgm9TjqHsG8+6nQL7ah+j1sI3Cz9+plwFk+Z/JBimZ2Vq/v4 A5Y5nfroDsr9M5fV6RfaGqtlACBILvjcC6ap/k8FvJpP7kn9rjhuyKojXE+bUTxBM1y8 EWi6EB6OUPOaJojoohXI+p626XpJwfXlZnaLyQXhmAwygipNJf/HziN+Mnv/HwWeP4GT boXA== 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=qJ5foxI1lz7tFzUTVz3PNndWcphNzNOcxqj0edilI7A=; b=nDavT/kQsVtcpTnLzMJJPk/uzGkQgZ2cBK8zs5TabGiBZgqcp552ZlV23ArD9zkzdU 1VReFiH8syJTvaO0/6l/qlNlKr8pnFdVQGjmX69sdNpvg/m+4/W8dbGR6xWgi7EA+Bo3 sgdnNNuWvPiKtwG9g1LuM84hbGHMdtvQEFjFsZqYdW4R+od/qRGSkh4S1KbpqmQQkr4j zvDf3RKXyzdUV7ewLVmKrwQ+4EyjTqBlBiRKZNdrlF5RfzUlB/ZfFa4QYdIrZv48KFwN YPnTmBIw2kV6WXSMN/TL9t6f2onUlIfkvWqtGAWUgnXkDVUxNl0q70+z5s0nRv7TD/n1 DP2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A28n0O+6; 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 e24-v6sor863948lfb.64.2018.03.14.09.59.16 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=A28n0O+6; 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=qJ5foxI1lz7tFzUTVz3PNndWcphNzNOcxqj0edilI7A=; b=A28n0O+6B5GtByYBN3+Hn0H/Uzq6Hl6EdlwLOaWEoDXUlm1iIW+9rLQQnavBvbuuAB xWhpEt4d2EvABN++oX5aL/lUBckI+llkMrT0mHvWb78siH9P1tvdamT+GLSRhtImc434 qWAeX39IWr5jjCqaJMCiOygCIYUyD7zfDeNPA= 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=qJ5foxI1lz7tFzUTVz3PNndWcphNzNOcxqj0edilI7A=; b=NHLEEyHnTWN3e3t79Zfzrr06JJGF0J6QFBhVT0v8LKcNgXDn1SSmM5HgZvlPmDh+bv atjtOJXOwUcpzCDmg0xD3aZW+Tf1EM4EMQVjjNkW1GnQH7JEc1g5YeVW2mukHlQQRSzB XxApfglUZNx72fiuWEmypbpoDVz+5l8H0fM7N/pR4jHRZVq822C7lDO92vEmep7uIELJ 6NVwwFsFjeix5+oore1mFZFtz0QAXC3CtwSkXRCa2uY6DvQ8YgYGKwkpllYrt+4sEWuh sA5sTtbGsex7gYPqS47A2NluN96jqLhNF94PCc/hQUsE7mX1XroUeSAoLHWYg75fn2Ih RJZw== X-Gm-Message-State: AElRT7HlBhQUleWL8hBmJrlyih8cWLha+xAqJyf4XHmTJaphrW6LqFEi KoN+PhXMIGjrwysEMh/IughSaR6A X-Google-Smtp-Source: AG47ELuhxqVYigt32oLkl5ebTYlGhgNzggotEhXyoY3DbQdXkNXTX/6QxkO6Ee9XNVFiWF0S8J+VdQ== X-Received: by 2002:a19:181b:: with SMTP id o27-v6mr3776139lfi.132.1521046756692; Wed, 14 Mar 2018 09:59:16 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:16 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 08/25] PM / Domains: Extend genpd CPU governor to cope with QoS constraints Date: Wed, 14 Mar 2018 17:58:18 +0100 Message-Id: <1521046715-30683-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 70565a8..2f162bc 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; @@ -275,9 +282,9 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) /* * Find the deepest idle state, that has its residency value satisfied. - * 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; @@ -310,6 +317,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 Wed Mar 14 16:58: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: 131678 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410436edg; Wed, 14 Mar 2018 09:59:18 -0700 (PDT) X-Received: by 2002:a19:57c1:: with SMTP id l184-v6mr3837349lfb.2.1521046758737; Wed, 14 Mar 2018 09:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046758; cv=none; d=google.com; s=arc-20160816; b=LMn6Lvm3FGq26RxzjDQPGlJz1Va7XuT3urGkS99AFEMWtYVef5h/C6Y8wE+iI601v7 RsARuvy0GebT+6hQIGW+5VmADX8eYvJo7Y8wl8ceURFo5dSfG2TQAdwAYV6DM/pZ3tYb 79xWFp2udRPb1UhJ2W/wpE+zPgUNObU4dBRWt/+WPWtc8FY2eBlque3JxwsxpFuIAYXB 8d2DrkflTFnFAOAGjVP5BKFkptR7Zkrntq35ZZ5aFQTf+vDnahlozpYI6m2yaDH0aIVK cDaZNqCh6J4VljvYPnLkQ+jj4XRvRbAFEu+N0YMFbIK8t1MNJlvCRBguuLwuImDNs5P9 HDpw== 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=JW7egLf3y2HcSk/A1UhronrOVsVD2i1fr+JMe/QaNq8=; b=mF2XH/lHH8vCDxBCDouDzhqecuJCwRvdtEIOdjMeWEuG2X6kcmV5+sLMUKDVU5e6n2 Ge45IDgdQ4BPIy0jCGTA2baYraMlRfhfYDtT3KRFJQwzbZ6M//ZL0EWhGFrS7D4BIXue eX4zmgvRddT63EmWCtmRLvyEwtZhYlUHURXSSoJOLtXtOKMaL3iAe5//lHYQLudVi+dC BRhn5mI4seGDJW+9pMjGy6d6a+5aDvWtBW7rU06xmqSH4gwa34cNfejouL+WgjHgFoqd eMuftaDj1IArifxF+nTCk5BXVbYSziT+AVcCpt5oKzVGYwJpuYUmNeIL6WhX4bUDvGMt DIiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPIor21g; 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 b86-v6sor890369lfl.4.2018.03.14.09.59.18 for (Google Transport Security); Wed, 14 Mar 2018 09:59:18 -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=WPIor21g; 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=JW7egLf3y2HcSk/A1UhronrOVsVD2i1fr+JMe/QaNq8=; b=WPIor21g1FbZWjThDqR4x4IYnjw7Tf2CotV6jsMalrryNJewfS2rMqlnaLqJyESmwW M0N4anTr2EtsQSYgBKEAxIatt4w6wZkEKbS54S8DfWcJ7BlzGDZSwqdjWCgdg6PL5/c5 GYVf3XCvL/x1+WSH2RtUdV3oA3r5tzXmv3SrE= 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=JW7egLf3y2HcSk/A1UhronrOVsVD2i1fr+JMe/QaNq8=; b=CXB55f0lbHPpvxP7Gm81ekMGGTWSEZL3yceRhVoQG4vy1TNo6XOarkZwlWCz0c9k3q WJu5qI0xDgf8Ulht7SYFx0IM++293XE6d0vREmPiXES2XJvKWlZIVe6WtKUs2EQvvq/4 kKVQ9T6kPY9Ss50rCMc1Fvry50708HyED4lMLqOLQwcVCxrjywg3eZT//YSQ86p5T2AW EHPY+X72Ic26oWeNbOUZr8BO+7EIdlCpvRxNRI2lI2i5+XNADdH1070ryZzTbU5i7tfK S8uNR+hfV4Wk9s+OtNyaROkyu9izpcDrgoYIJ4tj6Kr/PHmpqFliyqSacIIa+h6CrtIy XVug== X-Gm-Message-State: AElRT7EaGkFvtIcspLRxmClxc4JR0rpV9DMWTLdHz3aBn5Wiyl7n6K16 70uf6wq4RM+lPLg6Nb52aElyJuCS X-Google-Smtp-Source: AG47ELvHaaFCQFX++JU99VZySuZCgsiDWNbqHWg72ELY9+wH/mnR8n7FKfxSv8PphX6a4l1vWZIFDQ== X-Received: by 2002:a19:dd89:: with SMTP id w9-v6mr4127272lfi.82.1521046758436; Wed, 14 Mar 2018 09:59:18 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:17 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 09/25] kernel/cpu_pm: Manage runtime PM in the idle path for CPUs Date: Wed, 14 Mar 2018 17:58:19 +0100 Message-Id: <1521046715-30683-10-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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..71317ff 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) + 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) + pm_runtime_get_sync(dev); + return cpu_pm_notify(CPU_PM_EXIT, -1, NULL); } EXPORT_SYMBOL_GPL(cpu_pm_exit); From patchwork Wed Mar 14 16:58: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: 131679 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410475edg; Wed, 14 Mar 2018 09:59:20 -0700 (PDT) X-Received: by 10.46.83.27 with SMTP id h27mr3779894ljb.88.1521046760802; Wed, 14 Mar 2018 09:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046760; cv=none; d=google.com; s=arc-20160816; b=m3ZHHOG4L9/zD4MoE9Iu2Rm/OLyEmoqY236zgYpuTWrBcuU4Mjy9ljPkQ7Sk1H0I7v FRa/dwq2Bug06RWjVk0UyH4LWZX8Na87jsUD/RjUk0Xmq+4wrAbdRvgC9j0pKMvWbHzn PzTeZJvmkHGymKR6AAH44Z+0bGe2tplYOJnc/IyxPJqM+u39+kHpfGfTcPk152KqhTbt DzclAaECMrCBNSqJZ7o801lvQoqGga7ikw2k9Q7h+onzAz1WlyKdzfJIqFn1LStUJwJg nJ09CdhKLgcPMV93GtyXetQhI3ZZPuIRqiyFBRt+aizbpHaAyeejZ2vh199iDPbeo+Gl anew== 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=HTmBQFYsIn07jEcxfZi2dr/+UxPSlBDZyLyljyEp1zf/OkePmuYzhjt3PJBwidKG92 DLLFs3+Xpy5idq6yW7amPQiK97eheYjta16gsuWmAQcgEl0xXyzWohUw0xkfk2rEapCu SkxsQ6Ta0/g/h2EoDvr4Fww54Qsj4G29RS/UWshIPuMYRip6yt0fdawfrhKYqipd7/hB OzLYHkXy5ATx39zUajhBBsPzBUuM9QvCdnP5x628l9itvogqF7S60yp9zmk3h4bRX7Wh vWtLpuF1Cf8By7h9XWRhOVmIx8nuYKZG3cgF1qc5ScWlkg+r+4MXphREIGwUQ3AhwuOj lklQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jhSMCe1W; 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 y6-v6sor888748lfj.60.2018.03.14.09.59.20 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=jhSMCe1W; 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=jhSMCe1WbIOPUQ7T2LR0PUAl+QYZ9Q1MklDq8bJnC0c0krvWfzpJye3QU1N4dwuvB6 E7EM+Dh/wGRva+fyYIw7A1HXV1Cmwrtdb+rxAzu9zK7obWewmBqf+4A7c9cL4KCtXuq3 m520bs94pMw2RoJ7V9n1BUaodrVmM+VN8sRuM= 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=tzTGpMMg/olR+SoPqB6C7000U1fpJYEsHQdKCbMtmv44GH06EWgCPU+5XfOfkrkBEw 5hwM040+afq0yaA2Zd6pSjESDguJGFsRzIIyjwg0p6UOuUCHxqGw1jM8LareP2iseEtC Fct0dH9AcRXa7ZucfOsQ/M93j8ySxrBJn7WioB86GxMJQ69klknptKqY/GhsvwtxdCU2 mkO1rcmwTqIGLL3tPp/5cfNdxXOhRatpK6C1Dzk5rzBkL9w/ML57nmDSGgJnu+uP1n7U qdb9acUdDxohaKwh+Wt1icgzD8mcQQ03mGXWmN+fMMikhPSLpg+5X1ymW4WdXWGMI+q9 F7WA== X-Gm-Message-State: AElRT7E/z9vs8zrIb3G0RNlgmQg5NvFkmgsIR4/K6EMvSkBmnqRCEpvi k0w/ro/xGj11EjkOqP0JSolJkDC0 X-Google-Smtp-Source: AG47ELvGA/2X5mSaZA6j4H5UjXFIntfNALASRbl88bwgrKbBmH9gE4bw4Pcg4X0r9STViA6CoedCJw== X-Received: by 2002:a19:1081:: with SMTP id 1-v6mr4136954lfq.86.1521046760222; Wed, 14 Mar 2018 09:59:20 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:19 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 10/25] dt: psci: Update DT bindings to support hierarchical PSCI states Date: Wed, 14 Mar 2018 17:58:20 +0100 Message-Id: <1521046715-30683-11-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Wed Mar 14 16:58: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: 131680 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410512edg; Wed, 14 Mar 2018 09:59:23 -0700 (PDT) X-Received: by 10.46.42.67 with SMTP id q64mr3967156ljq.133.1521046763351; Wed, 14 Mar 2018 09:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046763; cv=none; d=google.com; s=arc-20160816; b=SBqzXzBSzK5/onJ06v9a6SgPlKxaCx0QN6seSSACqdPKWF/7zD+oQBgOYUXsV2FcjL XuyZwNPoofibkPkgtyjLjh2YS4S0jkW858ZAiVuMTciD6DzsVQDWu9Dxy6VHX5i38U8p 8IZe6PnBMk0XGbL8gJEmXtPO2BHjbu3ejsnGHj2nAMZ+yxdw0pwPnekvrgV9YW9heCbR TUWN+vvqPHSMvWlZS95EJ8G7W2OQ5jugwBcj28Cs2lI9+XX1JtK3fU2AEQYqJdZbIi4e KAs+F4Q78tfdjh5KXsJg8lo0MuQ+OVQDJgdHiUGvlxzOa+dxdiP/A7renAogjUfo9V/p gbww== 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=9Hut8uxV9o4+GGyqitzbiLTfPeq/ETjSQ3OWzL2xcrU=; b=Sbv10tqGyxgABC25hRd8jjGWQmydOMLOLz1ee4wVQZL4l2TEbktxheDYJyyFh0N2oO cBuKuoR1IKV8SJHk1VNcn+T1W63CE2EoNcM6MP9PETPkButo0QBbZ8PVzRBI4JSt7FwC sBM4Qr7tpMX8O0N9477xAkC7RT4gFiwGQNGNENXoY72+yn1tWsTI4C1GeHHspVMUwYZn nezF7vvMoqfgJ/6ltYVjQnUpA2tYtR65ANLsEjO73s8GpshMghmXECumkZDZpBZ70qQs Wq9OxtBdl21fz50trMIoFfA2u5HQO1SDewA5+1oxURVDZpY4bj8OK/LY/36O/msTPBP8 j/cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WElXkpgU; 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 y7-v6sor859551lfd.106.2018.03.14.09.59.23 for (Google Transport Security); Wed, 14 Mar 2018 09:59:23 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WElXkpgU; 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=9Hut8uxV9o4+GGyqitzbiLTfPeq/ETjSQ3OWzL2xcrU=; b=WElXkpgUTZAj1q/q8hJkarTQaWXBTIn6m4bJPQvq9DZ0jV+LgukZJkC8ywZYn4JvJU 8OirnsnOr6P3fPBzjn7r2Ddj3xUmZ4dwSTw7k2CaHeGztQMA/fiRBl7bYacBueZOzCGS xaR99wLurWuYcnDSzS7qnhmjEzz1sZS/hcPAs= 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=9Hut8uxV9o4+GGyqitzbiLTfPeq/ETjSQ3OWzL2xcrU=; b=DREqGeTYpIDiwAfMQIAYCwu/AJAKtQ56DUArYwMgAn/5T8xlFcZWzMcoWmP8tfXWKC Qav2fDm2RHbkFMavpWriuzXBGB06u2y6EeVRnOJvrkWOfDDEm1CzRR++0aROvKJa6wa5 iEfMKYW+80hV4gZkJnsigkV4ajufls9WYAeBalYVDkJ2LgGg3STnj0DtDTd2j2eM54Zx WNdE1/3pBzyP1pb0CmACuI6zM0sCUq7PNYwPiuXmYECNYTnmscICIXxSvnWPSi+kETRU drNFDSdgtv5+qhi8IHoM8Wm/i/Ff5kzGNvBozfvhdKHz4JQqn8nsaspmOD6sPxXrJcq3 o2Sw== X-Gm-Message-State: AElRT7E6hfvNV8MkY1uAYN+NGERXXBKoHxEZcB7CM7rdQGh/6GIx2YR0 V1XT4nJAC4dfyMpS+dbzPlaiHNTq X-Google-Smtp-Source: AG47ELuyhOyJV0EL2V4Xan2c19SvKeNx8mqwbPpPCZuAvuXLzemjeIFlI3fpdg0W1IBJ0ucW26IQXg== X-Received: by 2002:a19:d744:: with SMTP id o65-v6mr4080626lfg.90.1521046762802; Wed, 14 Mar 2018 09:59:22 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:21 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 11/25] of: base: Add of_get_cpu_state_node() to get idle states for a CPU node Date: Wed, 14 Mar 2018 17:58:21 +0100 Message-Id: <1521046715-30683-12-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 ad28de9..88d36a3 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -338,6 +338,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 da1ee95..288233c 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) @@ -730,6 +732,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 Wed Mar 14 16:58: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: 131681 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410544edg; Wed, 14 Mar 2018 09:59:25 -0700 (PDT) X-Received: by 2002:a19:e511:: with SMTP id c17-v6mr4185885lfh.106.1521046764937; Wed, 14 Mar 2018 09:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046764; cv=none; d=google.com; s=arc-20160816; b=SIXp3Wmo21lnbpHJQCMoXWmCMi9g1S74BhbJ9u03A+r8kUrhxIprl93guSlMT9oIVw wy7Ug8XiaP8ojQmSwLAV2EvasDbaWyTxAb4sk5KsZtGQU2U+qJLrubzauf3g6MDgR9Ca UMyX/8g03V7y38980tcpeTzeXLEulU4SlkdJWU8DYdQoxtUDJ8qL8l/juOSmJ3uHi7C4 4oTS7LKq0v3vbP2TOD2htKYTX4hH0eNP9WICq9hmp0t54qwbBMbOoXl8rECZJoSz9mIB qkvaLIOW0CTw6X8R/9qR3fUUIaFeR+8OfMDk49AerbfivPxgRl+CCkL6aA7lrztRM4mc Tcuw== 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=p727qCnTGOLdjJXf8BccG8zlHDHKcveA/6TVh1MSwncoDIczUZakKBSJXMITdNug9R QdOSZOmCDdGQeIXWYbeuc8P7PmfHQyWYU0+UNeydEJ6NDURaQw/PJnOtAOwXe2tpzda/ nVNcGkrkT2N+pbz2YHLh1HoKCKd6qrvT44klMOEp9pTQOBwI3tJ4BvRJlCSQngJx6yHn xNuMOXs1a/U39oy+rhhMw0wn2Scik19iSkwcflh4+udAoXNG+Yhwi+yMCgzHiCeuEh9W 5dSvi1TVoMUP6XocsF4UR98ukodWhZ9grKRyADG9CDfrwQC+Gby2ebp2nij5kkZFJFp3 XlVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fr6/+Ggj; 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 u17sor827500ljd.86.2018.03.14.09.59.24 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=fr6/+Ggj; 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=fr6/+GgjVMM6ONKoT5Y5XD9BgwOLrVVKk8MQov8PpSmU38EY7qJZNpYIKQTxHSlCo0 TK2k+r1XqfA3TcDYPbjfQ2bZTX8LWMoOI5uLv41vd2JVfAQxwm1FqmTvFtYqJ4QJbiwy NoyXnh7qlXFG8kkuWgg3s6RyKbc2+gzR6g/eQ= 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=dc3GXFpNMTtL3V42Vcv8t3h8QQCsBTuNuzaBA6xFVCpTOmbH1zLR+Qw4OcuI+FsyQe 5VsUpu67l9AOdCyzrWdfFLZNuoqT07HjP2DX+VPSw2LeDzAsHlL0QT6P5UZwVAAKspg/ T0qlqF1KUNlGyFSkb8NVCbPK2Vsx221Fe0MpSnLskZcty5kWO+1De40Vhg/f6B00CVhi svgdRnP3Em6AWLAA2RnU8rzQc/u1Fdfw0QdRN37haoVzal+MFj9vmDm/r9UH8UlQFaO0 If8Jd28de+v0GnScM9gb3NTW77rQMOgj9LBgp5hLnNktmxyUsow3i32P1kXEiprboYPg vugg== X-Gm-Message-State: AElRT7G2jI2OjffnAXJoiMSX0GolNJG42ppiuMdfUYvfwDhbG/21KEtC gNGPdQZ3rGdQT3RngaDk+P8YwzZR X-Google-Smtp-Source: AG47ELtzP2YX6t9eBDCncKmPtJu3beW26wv+teg9NbPjAvlfv5znXhcE5XaSWjsURBCxTLLwzXqh9Q== X-Received: by 10.46.84.86 with SMTP id y22mr3780805ljd.36.1521046764681; Wed, 14 Mar 2018 09:59:24 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:23 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 12/25] cpuidle: dt: Support hierarchical CPU idle states Date: Wed, 14 Mar 2018 17:58:22 +0100 Message-Id: <1521046715-30683-13-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Wed Mar 14 16:58: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: 131682 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410573edg; Wed, 14 Mar 2018 09:59:26 -0700 (PDT) X-Received: by 2002:a19:730d:: with SMTP id o13-v6mr4101421lfc.88.1521046766557; Wed, 14 Mar 2018 09:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046766; cv=none; d=google.com; s=arc-20160816; b=XDNPETucd4+cCl5TBcDGja36k7/YWACbVMnmRsi4m5G3s+7ecCZvZaxUKOOu9E1TkM hXe/lgeD2xkM/qvkPkDAIl/snXqaU8Zkh9tcUHORogMQP9FmVEg3RGV3WBgj8u2xZqJO 1PdeiilYrau7LBglbPBQAKkigJN49zOb8UB4Dtm65Oy6Q0q782TknJzsz2MT4EFCRFuv 0kDMXM4xfXImvMdi82AXu6Bnjd1iRN++SjZBcUMd67Lf4h1SZ74GwYe9jeK9Wo/3t8S3 7/0qe11YXaqRYM7PCxpW+t7rKUhCzhqlqnHvsg9UPIH8f8c8LYl+M77VBZ1J2tKKnALK jF6A== 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=YxxZ5uPjaIBiIQcm2tWQDkG05gg7NoPlNRyW9/INWvg=; b=qHpCMlukfjxYOsiyPnC5Cr+n/OTRKipxf5BHQBLAJpgwiNeY8UUoB9VBIE4J9+loOz DoPoc19zy5y1ldxwfW5+z3HfZUvYPjtX9ZEzv2sOodk2oiqLG71w5SkyoMSh2F88cp1K EDOGyh7v1NEZxFfT7FaBrZJJ0nIMc/MN95acnmoeIb8bdio/TwkVg+iWyOSbltzLnTzS kPdGPYXdiX8rC/2j0XlK6UZPl+XwVzfffg6Z9Xsi9Qc0wQA29FYsx4URsDlidkmX3Rw1 bkPA0DEZ/y4368jVILL2mw7Sejngf5dWifrJ7DbdtUcwWMpgeuhpzOmI3qYs5x8w9ngZ JSGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UIRrkp+8; 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 u17sor827513ljd.86.2018.03.14.09.59.26 for (Google Transport Security); Wed, 14 Mar 2018 09:59:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UIRrkp+8; 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=YxxZ5uPjaIBiIQcm2tWQDkG05gg7NoPlNRyW9/INWvg=; b=UIRrkp+8HOIbkUOFVrfvey5G/oT66bKYzAmVV48EqoWjDPn6uP9Zvj7g+87JeUjo8D 5Fy23l09QIMDSH/C9iqsD58zwW/tBYm2wbZATlR8EmnXB0xwU1CBe68ZnX71kHPfidcS 2tPDQmbDX4635hJJx3q+10ksmJVRugbs8aUlk= 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=YxxZ5uPjaIBiIQcm2tWQDkG05gg7NoPlNRyW9/INWvg=; b=kZULAjoF4KSz6I5VgEW07AjaONX64tkjOBx/xM3662ZQo9l6rF3crTbOKXdMmibo2+ 1CBmgyVApRGB3q5PQ0/TTiYc/0kGK5cHb+vNxuh/iIBl+3ttxtqSEF5KSkraUwPS1qtg tfvh+GDnzHSZ0S86DZAb471mD78kg150ZizbL/iaabWK9qH9+F81zlYC0E4G+tp+mi/F 4AMSFqeM4/AkhIOj05pnUyhDCU5gL8yx0bjcMa58T6FcZZSDAoViuL4gjJkoAcUsiFVt F2fKP/38RVnBd6RiDeTu/D/HW/2D2k1oZc6WT0LEQYc5V/vtW4WX3UNAzBboiKxjCsAd wRQg== X-Gm-Message-State: AElRT7G+x1THf5Vh45o2wLdIfcJL0hMcUY9qMTDB57fkR2GxWdhE35Qf wapc3YQdhidSL/Vdu/L8PqeDYnOy X-Google-Smtp-Source: AG47ELvxftcoRlsbuDtI0b+Q1TXFVSCo/lhPm/MiUeSxIaDXUGghRYo55kXjgMklOA7HOuhc0RKVCw== X-Received: by 10.46.20.67 with SMTP id 3mr4029234lju.104.1521046766302; Wed, 14 Mar 2018 09:59:26 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:25 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 13/25] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 14 Mar 2018 17:58:23 +0100 Message-Id: <1521046715-30683-14-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index c80ec1d..9788bfc 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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 Wed Mar 14 16:58: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: 131683 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410600edg; Wed, 14 Mar 2018 09:59:28 -0700 (PDT) X-Received: by 2002:a19:cc58:: with SMTP id c85-v6mr3784445lfg.53.1521046768267; Wed, 14 Mar 2018 09:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046768; cv=none; d=google.com; s=arc-20160816; b=oePAO5m5AWWEb+f/Nc12uyQEJjwrgXgj2P0LsL5uqdN3ZkMXDMrsITHyf5Q/1koQvM c9SpMAvwYrd17f1LcCKIv5dkLCp4TkmwdARRTb1Ex5DhH3LMQRpFVHM2xQBopnduAhr2 OnC+IVR1TamxxeEgIHufJk+V0u3LmR6zLeXQpS+pyBt/7qu9dOuKAnOaOO7Gdy4/7EtZ VLU2XcUuOXl7GwRQVNLQYu+ZbCLor89/kEvOkY9Nw4Qzp+7+6roWeotXjP7X+BlRo9GJ jHqljAu5dj4EE56IXOkjD3w8OoHdkGPpBDUvKoaJFooNSu5SvIP8ydf8JH13cYb2pRmR m6jg== 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=noP03dTVE/dG12N4mOws/4QMhMXSC6OgsTnjw22R1Bg=; b=N69WyYchhlctg7nFJXJz11uOpe4En41dG3kFdCqQRZ6J72v941h7UBwakkES8v49xK QyPTE024usH7RFOgzlz4jHVbA6mO5b4OZL8b9hFIFu9doTBYY0LqSIK9O7fo5/It9tby b5BFrb2ea03IsjLmbMpiIBht7q6uClcxT9cQ6in9RrB3hh270Ep9fAjQrC5J9ZzgF++U mgyfj4dim5FJgX9evDWhFRkGSUnrn+ymoQU6ySsBmybILozU0kvit3vC5BXrQ0ougPkX QRlCuXEHb00xnQoTa8EEcpYscIAEOBPn2m0audXY1c1tF4kT+++VBPNS17mh89mZiG7v Fsbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EmxaaiMm; 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 m9-v6sor874751lfj.8.2018.03.14.09.59.28 for (Google Transport Security); Wed, 14 Mar 2018 09:59:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EmxaaiMm; 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=noP03dTVE/dG12N4mOws/4QMhMXSC6OgsTnjw22R1Bg=; b=EmxaaiMmxZdK7+FI2z2ZfZXXL4BzvOW4ZkDEdDJq5pTUP53KXWFRYCFJJgi/ipweWu wdhtR4rcTm4oEho+QpemCnU7h2N4YFKNOPrvST2kPytvSaPQ3AoBliCYclH8Fw74jVTZ vaNs8+3cjx07W68fNAHXTKhUZsoG6ufcYGBaU= 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=noP03dTVE/dG12N4mOws/4QMhMXSC6OgsTnjw22R1Bg=; b=qtt4c+M4hFxRFmjBplNeNje7HpKrc+Id1yQOA1XPmBDXuJkvCag4tYF+2b1UPBXr0X jMgKIafDi6JutMfDCfjaVjufPzsZOWSrFXLmA+9ahrVN8FvYgpoUFEM8Aw92CYTOjgaF TY1nRFJN+I04g/tID3D/DtsB/Nl+wo8vxkT4N27RcpufXwHcZtHIsyHxlgEFXWqr0Z1Z Q6/huGdKMY7ioEESUTHXWn6wSu9f8HC4bWazd5WamdnGJi+ekm+CfoZn4b2pAK8oONsM BiTzJNLeUf2fm7S+9mJLX9k0x6tferV3fXDsuq5xWSBy0Uh3iPBHZqfJAii13e6DC7fZ iKvg== X-Gm-Message-State: AElRT7FQdfIfFNDrvZeLxz47V/uKjvTWxseIbI7Wmhw0fz49VcAaaos3 1vnESIGmZxDR4myBMBxhvQTKLdPE X-Google-Smtp-Source: AG47ELtwuG3YokhXiELvebmymrYGi8ufIkfwPTNLxSUnbKG3WIjYpOzeaytos8BOox34lTJ09JKEWQ== X-Received: by 2002:a19:1cc4:: with SMTP id c187-v6mr3805279lfc.44.1521046767969; Wed, 14 Mar 2018 09:59:27 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:27 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 14/25] drivers: firmware: psci: Support hierarchical CPU idle states Date: Wed, 14 Mar 2018 17:58:24 +0100 Message-Id: <1521046715-30683-15-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 9788bfc..256b4ed 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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 Wed Mar 14 16:58: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: 131684 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410648edg; Wed, 14 Mar 2018 09:59:30 -0700 (PDT) X-Received: by 2002:a19:5c84:: with SMTP id u4-v6mr3875861lfi.14.1521046770122; Wed, 14 Mar 2018 09:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046770; cv=none; d=google.com; s=arc-20160816; b=yWV1R6EN8yzxji6MTE0K8S/gXYg88rA37ox2DTSauogF8iqE1dNP7BgzIgNHS3A1zU 2XvdV34CEn3/NCwYXRu95YLIlkSJMPxLIUUMe3FbKfFREWb/wrDnYm4c+N/H8lLnBx3H U95wAKVH/I4TupCqmsiNajbroUaALjBoI3Jx1TJEAPLb493w8mX7NcKbquXIAPRwGqJv Tcxoio2xWfnmDzMJt1ABI0FPyFQQ3iMkx44bekxm1g1Bnx1u9Bsscdvlsdu+ppIsafdH Zy7q6zES4Zx2+s6Akkp4cdVyhFOaRnwI+Dv2C9sQj1YGDJ0bJWeBKXGAlLUb//0nIRl+ 6hkQ== 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=g6J+Mt0dxNiE2gvJIR0aa/PVw928eU14k0v88Ig1Q0o=; b=MJAehFOk0FUMiIYsv/6bnVVWgbS/W1NFLJ9gRae/Bpyho5P0X3ufe27Ev0qfU6yV8B N/uyOkR8w5VDHI4EFe5/uAFgchOBN81w5hLVSw4HZ8O3djmofZ2ZkArI3a/UUzQCxy7g 3URBI4AGq5O+q0WqIL3Py2dWm1wu1/ELzXE0XYEfcv7ZwM3i5ceJL0jj8uPT5EYMeMBD FNi7Ds/gfWq+ukkrU2v7T7O8oq6DhisuzuhoRt1OxJninkdrxg8/OAhlpPBWXHaUw54M bWzPTTnuuI/7UfCdNPH+ePlkIXlYvO5wRuQ649ZJNAgrPCAs3qwCNao0UdzEAbmKAzeb le2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CYSNVHww; 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 c5-v6sor836570lfh.103.2018.03.14.09.59.30 for (Google Transport Security); Wed, 14 Mar 2018 09:59:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CYSNVHww; 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=g6J+Mt0dxNiE2gvJIR0aa/PVw928eU14k0v88Ig1Q0o=; b=CYSNVHwwWLQtzkK03Dgssxd1yrghlcrWqI3rCI3Ok/ZY87Lvnut+fwtTlG/5nKtXyl 4t0i6LQMxnOrejUbs6TqRcyjCGogeo8t2JAF+usSQBMelWCuI2QhctPJGCrByU8oKJpC 2jEMPrcQnBSBhHBWV2okjPu4DbhHxbrSieLpY= 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=g6J+Mt0dxNiE2gvJIR0aa/PVw928eU14k0v88Ig1Q0o=; b=pM7Ffc4s8KQi2fl2CD+kap4s7vtFqC8eDQiuiZ+Fq5wIBTsf9kBDBmsSUVWPZabJ6W QZtevZqi/HCBl3TZPiPPVh2IXxT4VtIbQPBb2WejB5vWsma++XktM7hIL869owXoeYQA g03PnfedJpFLHySwadC41UcLTL5kRv8QN3maXjH89NyBdRhU9WFE26M1hcv1M/9xZuwe sAO2vusZMc3gEzyrD2UNWYXb6FWuBn4HuyV5vXj1XQkJ97KCq7dvyo8XYYAdwMXBQjQK 7iRPEMw8XvM0pJdGqPXQXwcR4vhtF/mn9Fk+L09sYkzIv9Fh6H4T55fWaR9JCTJBpOun cfsw== X-Gm-Message-State: AElRT7E5DYPPx+SC+syBBCYt+9oiZXATjKIAmf0Yn0DhqfNBcg8qnlGJ C3/iOQ29nTmnAwg/CgU/F2xN84em X-Google-Smtp-Source: AG47ELu1hIHjEEkW7n3Mgt+GoyhmIf4Xjl4gwwsY2V+IbgyTTjijA1QngaMFXoW2cUBPnSAAH69Nhg== X-Received: by 2002:a19:9a0a:: with SMTP id c10-v6mr4100905lfe.30.1521046769776; Wed, 14 Mar 2018 09:59:29 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:29 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 15/25] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Wed, 14 Mar 2018 17:58:25 +0100 Message-Id: <1521046715-30683-16-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 --- drivers/firmware/psci.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.7.4 Acked-by: Mark Rutland diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 256b4ed..3888100 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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 Wed Mar 14 16:58: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: 131685 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410683edg; Wed, 14 Mar 2018 09:59:31 -0700 (PDT) X-Received: by 10.46.81.73 with SMTP id b9mr3806284lje.9.1521046771644; Wed, 14 Mar 2018 09:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046771; cv=none; d=google.com; s=arc-20160816; b=k2lDS8D/7Pj/jTjCNJ+fqNian/18LVm07mce4tMfgiZqz1KK83gVlr4ocyCGHUcdCJ AXew320au526jCwUvSLWlKzwpMHgmahXBPB214taUaIRSTj0sFVwIuzgnHeqEl+FRpsl VRsnuKmqltDBfJFUPo8l3/Rmhkd4Ek6TpdWaxUJXh2o12JM3Zp+4wvGjXlX+nS9B7X2B wReNk2m7DdT20jh3H2RirMGWwTk6Y+0+/28oFgdBZraBVAyw22P/MxgCiPbZNBVYB5UD hgpynuG3pq37kG1d4bJp+VqiWGjVznqwjX9HdB/lYcG85QVE2drTB227fCStQgKvzxh+ i8Bg== 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=SySSK6DMRtLpXyqRBoBk0LQnN5iJN9xKHJ4VsqkK6dg=; b=NKuXXSAAM7iwGJI+cA3GJS0cehGbBtVmELIFH6QKo1qDwsm7qH8r/T65J8IBlGj3mR i1b1XuL4KCJxJLWe6/wxFOHn6S6VPnCWJuaVSZeTWAhp+8UoRXa/4akrzDUFHJ/0WLuU 1FiYLHA3H8OQ8Rz+0xUZOZK978C/SIrmfrRz0/74ExxHC1c28cThNAmrJnhS3j3fT3l9 dZUa1edMpW7zqdlxm84C2Ns5Zc4FjsfJ3Zs4DOXmFOMV4EfBRvrEVbJasMCKEPIw9Jtz ix4oNhgjnhN5b7mvtXmbE17iCHkzxyNnA+SnfyKz7vh7ZuFUiw0Idjdxma35cApC66Hm mvaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DeF9GBnb; 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 63-v6sor867238lfs.57.2018.03.14.09.59.31 for (Google Transport Security); Wed, 14 Mar 2018 09:59:31 -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=DeF9GBnb; 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=SySSK6DMRtLpXyqRBoBk0LQnN5iJN9xKHJ4VsqkK6dg=; b=DeF9GBnbhyXegN4b0D3/VxRW7yyr/9r+6ByZLHDRLlYlfDjleobyZxBm49lcd++JeV jhoc61gcdqZncLD17+WJDzjrqutDrNd2C8K4ZLabaXt0Xxo68LO6LwOOCugI0hnMQxBu VO5O95DLbShXMmdtZuizcIaDX3/WAM5YKxwc0= 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=SySSK6DMRtLpXyqRBoBk0LQnN5iJN9xKHJ4VsqkK6dg=; b=FPposG8McXQYhbitUNy47xVeMzc8WxEWstm2ovf382oFH6UOtHbXWAXGLJvx8QLIix emoFyGeRhp0rANKY+3y20QUD3NDPaizNxRorVbYTpa6jnSyxuOestw1yxyHDt8Na7HMW VqdTwOw61/qvhsGvNtP0sfk5iq3wwaZ7J33f40w8HhcCBhtctLFkPtsxxAUbKCIgHRtf P6wQIAaZnX5yEfVuPdpdiyXtxBeeV1hE+vDDmzBIPx8ojejRDxzT5/G3uAcQiLFB75Xr n6wu+GAtfST7b3nRNKH96Xy3SnFQOoc+zImuIaujDHTrn9Zx2UFUABKl/fUMpYdXdsSG ZdPA== X-Gm-Message-State: AElRT7GxQAiCirZxYRXY62H5odrfH5A2irE7zAp4XfJJI+Fc8zT8yLvR Fp081MnHUqOcg0x9dCQR+LiYKbda X-Google-Smtp-Source: AG47ELvE116t+UR8Ob2pk1XrYKZ4gudkGLGZ4Pb1UcQV1Cc77C37Rxtx5mz6KzoSE3Z+ZGqEeaSQCA== X-Received: by 2002:a19:de0c:: with SMTP id v12-v6mr3496072lfg.133.1521046771347; Wed, 14 Mar 2018 09:59:31 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:30 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 16/25] drivers: firmware: psci: Announce support for OS initiated suspend mode Date: Wed, 14 Mar 2018 17:58:26 +0100 Message-Id: <1521046715-30683-17-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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.c | 21 ++++++++++++++++++++- include/uapi/linux/psci.h | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 3888100..e8f4f84 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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 Wed Mar 14 16:58: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: 131686 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410712edg; Wed, 14 Mar 2018 09:59:33 -0700 (PDT) X-Received: by 2002:a19:3bc6:: with SMTP id d67-v6mr4125785lfl.100.1521046773704; Wed, 14 Mar 2018 09:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046773; cv=none; d=google.com; s=arc-20160816; b=UuVodTmvDZEG3cp5AVT8M+V9pAQwAuVv/X8ONYpGQWRjNroQcyzGBy32+tgycEQYO8 Kot6OHEjsylm1yQFRJKwJzWi2XSFnVpmKdrVBeC3oXMjzu+SyxPFXz3DMSunhXUEpZYx tPNzQaYdfXczMYKvhvcCqkt5bYndG3KPzXKNxKTTRkg86efJ3grzHn7C7kxzboVKWy62 AJgwHrP3YeOEkcbhPry+SSH4LVurKVsWolBxiqffbK04ETVrilIXGhJ5ew8chJiKlH7t VjRmgari5yWhEMJjijVGGBc+gLwq8qT2TyccqYnpHRxT4LLIZg1E499EX+wx2mrFphKy dAtw== 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=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=gA5abVHZnIsMsaIRFoLcUvXAWPTL8B9IYwKJN0di9osh9K97kuXCKar02s5GsuA6TG CDgVUgdMjMcMeZyRTTSRqM8PQEzH99feLyKv3/DSH0nUBHKSQVUl/oa9phrdQIPg7qip mPsR4R21j9g7qWvHjjT2DmrMY2dTly+jyIUfdyo+i7NuFYhg+aB93GKFqiXXMjiYu+P6 28+lypGKHrJ5hgXS9TyekU9AbhW0elzWVp8FPgtM2DfKiywHKeIwgPuQaWamBM54Dhh4 VdKdmN5VkFlB0tZRNV5VzX/Wm8WaJYLqjbiN6+i4hTnltYKYOCoNyCE0ykdnNXYDHRTT 98Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CaeSA93B; 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 q17-v6sor866998lfd.29.2018.03.14.09.59.33 for (Google Transport Security); Wed, 14 Mar 2018 09:59:33 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CaeSA93B; 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=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=CaeSA93BsScWtu8p5IOaQ0fm29LZN5DKKFnYPsr84B2ub3UNz5SeYD84PyLjQWGtCO q0Q+1U6249+40h3L892EwlhuyPANDqdInPcGuqQCdpOityf/7dVyl/2tN+iFJOHQHd5G dikyFyKcKHdmLGhAl3KuZbCck7Xvkm78WNJes= 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=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=NGulcMb4nlBnSi7dTZHgexHzE+iTNsm+69cU/iC/Sds1ThFNhXpuID0ve/WC5GIorv ystS8BDLfjU2iZLODnweQC1qLmVwFh5cqWITTzKMEwH+tr8D9ij4aDEnwgKqU4401Kjc ekanOD40HV2XhAb6YWUFUoT92BZjjP0ADk4GwDD11vZBp3tYbQvzb3yoh+xmrYCAmsbT x0f003ru4R0tlrIvZOwn2nvl3xsDvTs7AVS1KwY9FoOg7C72wfJXEUwnLQuXsgc7MN73 CPbedCy5PVnofIa6ucbZSkyG72Jb6+SxGl3eINjhPLHn8FJPatVu1Cz0hYKMDJy2eKJ1 DzEw== X-Gm-Message-State: AElRT7HPXJiFPqoibgn2tAWtt0Pu5yW42ehVH74E5VneUM36BVtNdvkp 87EaXYANdcKvI/TneutMsAu35g86 X-Google-Smtp-Source: AG47ELsgpEr+HeYvWnb00y9+Rtp/YotOd6fahqWc/Jart3CXWlZSScHMjYs80FMUIODF9ogAllH0Pw== X-Received: by 2002:a19:d945:: with SMTP id q66-v6mr4136366lfg.62.1521046773371; Wed, 14 Mar 2018 09:59:33 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:32 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 17/25] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Wed, 14 Mar 2018 17:58:27 +0100 Message-Id: <1521046715-30683-18-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index e8f4f84..40b2b89 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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 Wed Mar 14 16:58: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: 131687 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410749edg; Wed, 14 Mar 2018 09:59:35 -0700 (PDT) X-Received: by 2002:a19:d0c4:: with SMTP id h187-v6mr3797775lfg.107.1521046775427; Wed, 14 Mar 2018 09:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046775; cv=none; d=google.com; s=arc-20160816; b=enEfG/zbpXF4vggZpqqzbPKgHazRCz8/R5QPGyruQCJ/7C7FUA9yX4NZm3wDdDaK1R 6oM8uprS4/uWgcHjXGvCnWvuqqiVg9DZUc016AH8V0940uodBE9V07v5c7k+V/0z6t3m YRKTYIT8sj8AQPCUlSf0FveeHkrIBh8XmLHoSNhwSBtrXve69fJ4mbtF6J1+Ri3asRZq 9TiziJx/dDW+TYGgUFmbwSakYtwaEt7/6b6Hn78FTr8WaL/4LtAAuwSqOvfj5RX+khoi L72PDVODhbKzoF2rvmDcztlvz9mdiYhsr9yfwez/rSW9jmvlEkmbMi29UpHCVZKiNS2K +nGg== 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=Yx/3Lk6vPgNgFrquTQIY9p5ijDGeAkDsNUNY9kNSe1E=; b=SyemrL9CRn9yEeYaADawqGZr7yU+liceBYCcm79W1cI7qBF2BaZHf6MsVHF1GNlk5h SQ7MquFPtcg7F+hlzP7Hw1TyMJUDvU9G+EqisNeVRmj3V3KZrirwpxweDoV5vZl0VmSP XUzIBQ55UXiSS4UcaMdp9VdeoQvwSr6B0Y0SxjECyOfFwV4BEz+IrFQO87eoHOVpnbbq hrb5/SKIZ7wViYEXRfdfkBHE6HpeC3puiBNia6Kq0xcqGoWtfFIRqcox2umT6Hy58x2G 4H7RiY3TfSDztZ93F9x9cTEaLxU7PJE2xz+uAFHd5RPzthPmmlhw6kxREGRdypyZwhMg bSLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bpnVv+vt; 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 m139-v6sor875074lfg.85.2018.03.14.09.59.35 for (Google Transport Security); Wed, 14 Mar 2018 09:59:35 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bpnVv+vt; 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=Yx/3Lk6vPgNgFrquTQIY9p5ijDGeAkDsNUNY9kNSe1E=; b=bpnVv+vtfl3PiXgaVc/v0GYbIhuUsSwwwxCc9pEgESCaP3QPxVYRhY5KBufv3ekpc/ CjxoMaf3sJkEydNdLy9xTqdqC0Y1pI+FKnrPURVT5gvqlw8hU3MyBWu6fJy6VCMAK9Rj EOyYzsVkseyM21KNxe5b4SaLKMHJ+1ch/gt8U= 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=Yx/3Lk6vPgNgFrquTQIY9p5ijDGeAkDsNUNY9kNSe1E=; b=q6ntq2E1u5HsaWnhLUeop+5ij+YVaZN74gEWC8Cefp1NYzK0zBRmxI8yNdjZrD7Bjz 44BnlTGQEJcuabC4y54IN8BGiSyLiWPVbVQs1cKC1yGtrWjk+y2Fyb4a7lI8h3Fzwpwp eU4HLJ4MWq4d43vOwoHtEnTOTt+EBb0R1e1mXAreE8+aVSvx3EQTI718XCG3uNeNWRCM purpK60bH7nbG98AJx+rEdz4lic2L7Gdn4O2i7C7yimQJeXfzTGU7lGYBPmNXGTGjqaF WYUDlwZ/aGHdbY3t0Wjb3q3gkS8oYYJtmTMLlPJsljA9g8oiTZKzzolGQrFRS3mWqdel zHKg== X-Gm-Message-State: AElRT7F2XhslmxOy+CPMCrHXCDLXarXRkD1q3gN3I2SyTQcbHrSycEHs w722gVirW1JPvakMXCnWxQAef58z X-Google-Smtp-Source: AG47ELv+z23XoPeIMmVBq1rcJr/GrUIuLDvJDmn+1dRIGmcKopQN4qeH81mb46nd4UBqVNUbG3MyEw== X-Received: by 2002:a19:f20:: with SMTP id e32-v6mr3781092lfi.69.1521046775127; Wed, 14 Mar 2018 09:59:35 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:34 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 18/25] drivers: firmware: psci: Share a few internal PSCI functions Date: Wed, 14 Mar 2018 17:58:28 +0100 Message-Id: <1521046715-30683-19-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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.c | 14 ++++++++------ drivers/firmware/psci.h | 13 +++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 drivers/firmware/psci.h -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 40b2b89..463f78c 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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.h b/drivers/firmware/psci.h new file mode 100644 index 0000000..a2b4be5 --- /dev/null +++ b/drivers/firmware/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 Wed Mar 14 16:58: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: 131688 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410781edg; Wed, 14 Mar 2018 09:59:37 -0700 (PDT) X-Received: by 10.46.0.168 with SMTP id e40mr3726394lji.77.1521046777866; Wed, 14 Mar 2018 09:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046777; cv=none; d=google.com; s=arc-20160816; b=wuJwP2l9PyWxaNBveR8RDdpZSEhFuHjq+dQkV6FvqLUgjOKcYBTs/2iAozcnF38jbA nAz7+EeFxOtNBNFSWydLHhwFpc94YNo31FeenhC82HJ3ClfY7dLei14rvFeG0EwiAqF0 3ih0WKB1LFZR7eItkIj3ieSMw8rCA+4fgvR8q7HoxopB4Tg+qLF1Svqax0eykkkgLFER KqlB1/a5+rR9XsONatH6gyLCq2BA2RhbYKIHfP7qwg9d55Bi5ie7mVz0SZ3dF2mby/l3 VjePjshuQ7e0irbZEF6v6L7+JM8Fh6HyKWLLXLnJtm/SZj4jBR53E+i1Myv8FNnHei8U fffg== 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=baoVvASgwd+2H4g9KqvrNrRIEeGoT2TGHJcb5gqN/9k=; b=HbhAmxaMUdOac8kXi6kV/kn3NPUgLcLKVi0J6JSb4LX+hYDwpgP8Oeza10adsdJjuS 0egdN+0FlkNC1N5brvTNRn7mHkd8prOs0/BgMlxfOqFDYMF4YOXPMHKbvvQHgTGJ5vgl Dn8MAkyqD2aFktxon0XMz0h5HX5aHPgh7kB1kIIfPMKIO2udyUAlToRpcu4dXRUqAeXl MpXCmia6rm01rajVOFHWCb+IQ7l2TS5S86SQIL/4oZ9sfgYnz681R5SbxrWbih0vtcPd uy/RfAz2hKCekL3G3kXhsonA3lX1mZR0Xa5Wl2qr4vB0Am3X5bQdEtb5O7VUr+8MK0wz oB+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QFfTsBvk; 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 b76-v6sor432105lfb.24.2018.03.14.09.59.37 for (Google Transport Security); Wed, 14 Mar 2018 09:59:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QFfTsBvk; 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=baoVvASgwd+2H4g9KqvrNrRIEeGoT2TGHJcb5gqN/9k=; b=QFfTsBvkEoqRltUrONwBdpkpi5SgSXHB7zOdDifuxzWll/UJXz3Lskh5ziPDU+DDm3 ZRLdo8F+tXPVGdjreJgSY5vsMz0ZPMTMHhY9kp+riv7N0hDTk94uRPuLHbnLwuHNQ06B Aa1FiESLXhk8b8R1Of13qfAHOSSYVKay6idvg= 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=baoVvASgwd+2H4g9KqvrNrRIEeGoT2TGHJcb5gqN/9k=; b=VoNa3TowWdCvOiyM5B+KJyEScKKpboy+AdKKY68yGW3SZA+dIVUZxo3Mkkri9vQgmX L1U9rUBc8h2UaYI89nPf2JQBpiA1VgfC3sPzFPa2fYp/35xxbkwMPfFfQ6b9NEyQkI9e Zje4Tb8hpAEIIljfWgfAN8dGp+QU0gUQpry7ZhRTVcFm5oIIDfv0C9LJ4AOV2FjBWkBt 1Q3oaoCXgl5qJEQ9jo7cYlWF07qJewln6VKltxuwjQSX30z0PgFWruMWjk7/r55C4qRf cGRwbeyHzhmKnkN/qsVe/DgrK7TUfAfRNkVSJLKxXXKaOvSJrewfc7VzZwv8prMWDGpd ucvQ== X-Gm-Message-State: AElRT7EpK0kTS7ZmI6KRMsMokqk/3ykn3OAh+IzKxVpOmfImZ+yTAN7Z mTge2QgIQiwm9mOoTcYPZg7VMHzi X-Google-Smtp-Source: AG47ELsq6Bq+2JKmbqM8uWYjtuOYty3bj1VsBUI6Vo7RCmXn0m9B5DAQUy0ddRrDAZC9Ex2+rVPvlA== X-Received: by 2002:a19:d5c2:: with SMTP id m185-v6mr3794214lfg.5.1521046777415; Wed, 14 Mar 2018 09:59:37 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:36 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 19/25] drivers: firmware: psci: Add support for PM domains using genpd Date: Wed, 14 Mar 2018 17:58:29 +0100 Message-Id: <1521046715-30683-20-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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/Makefile | 2 +- drivers/firmware/psci.h | 6 ++ drivers/firmware/psci_pm_domain.c | 180 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/psci_pm_domain.c -- 2.7.4 diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index b248238..877260e 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -2,7 +2,7 @@ # # Makefile for the linux kernel. # -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 obj-$(CONFIG_ARM_SCPI_PROTOCOL) += arm_scpi.o obj-$(CONFIG_ARM_SCPI_POWER_DOMAIN) += scpi_pm_domain.o diff --git a/drivers/firmware/psci.h b/drivers/firmware/psci.h index a2b4be5..8b6fe51 100644 --- a/drivers/firmware/psci.h +++ b/drivers/firmware/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_pm_domain.c b/drivers/firmware/psci_pm_domain.c new file mode 100644 index 0000000..f54819e --- /dev/null +++ b/drivers/firmware/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 Wed Mar 14 16:58: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: 131689 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410824edg; Wed, 14 Mar 2018 09:59:39 -0700 (PDT) X-Received: by 10.46.60.23 with SMTP id j23mr3800935lja.18.1521046779621; Wed, 14 Mar 2018 09:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046779; cv=none; d=google.com; s=arc-20160816; b=XZdlZRMzUkJetNZE1ibLiXH8pRVUXopKmLr2tHixC1tBdxMZiUeGLdNx/N/mwSgJ6m 8KdJEpneaHKBQ7ACOploU0Ol6KgwHHaeD8D7nIHAY1j/EV2OBJLQ0DxusYeHNxIw/2or U1Kh4fGTRoagTb1CJCtSMLf6EgeDmeCzIbineLjenLn7Aii0TYiF0sHSWa50gG/hiS4+ fHQBcnSirYorsvg9LMxTvAdpYB6Y1uEaKZbHs3G5PK3YWTusoFfJ1zXnkdRoM52SxwzJ lySkRmbBQzCmI0kkcYnQ0ziCdC0m9NR81CCxDzj7iszQb+lHYH+aNzfre8f63zXSbrNu VJ+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=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=LqZbJJI3iyobrKwvp0MkA8MLy30is5bF6+Vb9t33KZrTsUwsGreHJxI8q7vXXwnf4H Xx8gQbR3aKXmxrNa4u5cTSMOUKmm0xr8ChGLqonUTXHG/mTOLg8akLKZLi2Je3M2u5k5 +ASl7aMkLoTScUXEhLK/N4Z45sc0F+hoihCig+nFHlSkCilWDmKaeQBBq8vLcYUWzRGP BEI4c0Ys/VpM+24YT2ftZM6qNs/E99waaHb5hB0eJ9r1MYIa9GrSor7WUSxdka+YLpwT S4W0CMBV8Mn5kwE2MIBe+HfsBwgpaYI0jd/bbpYx7U16ioAZTzpxOZ8rYLx9U3mbA5Tq HUEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJsp5eRl; 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 q37-v6sor859929lfi.12.2018.03.14.09.59.39 for (Google Transport Security); Wed, 14 Mar 2018 09:59:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJsp5eRl; 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=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=bJsp5eRlmCMocTNQ0XY0nAB/13CIzu81IWmweUGbKsK8ozyRxYPacnWimkKl48EXPE GAqSWKOQ9UMM3xsRUbOu+JtVAvrmofhA9IHumg6d+AcoEeg7KDO8LwDqEtVchdU6Jl2u /J8NkshQUjwp2swIoGuyQuO+E7Sfth0iRWAKg= 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=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=bkAK2nDabcwwlLSwRQzq+rgg+91DM/q0KMDwZPms7csA4e/3nrpidFGjZE3ctUl5kB H/m35wnxlT+0+EG8suy8UWhdDBUGl8Kai9bdLaHpPZeIhd/PTcDtQoKspCgxzXt2c124 i32zTHA9xlWfKFqYRqELulG7ayIkLLbzQfUUFMmaYz9ugPfZ8/+tg2HhYoa723ALOaJy h+T9cYNhyN5DSpYSYhhqNZKjlQH2yTN+5GnasXubU1rAn3pGba1XLpU89PMsCZZ3O1q0 8EtLk9ufMZY/7omJjVcJuj+hh5NcVd2mj4rJiv3K4HTh9MFr4lcQpw6xQyLg2x7nDSb0 7KCQ== X-Gm-Message-State: AElRT7FFsstQe4lLpoTceq6+UCciF/2Bydb+A1DuHZhc+cy5GjCgtGhy wqoTN+TCaQkbkjIm7Nx1zFzqWiJW X-Google-Smtp-Source: AG47ELvEEHwelkTNoXneR4eZQC4jFrF+I2Vrwl6pGfqZ4XbkGzZEG0okk0FFvlQg9Z1os7B1ZF4dpA== X-Received: by 2002:a19:4f5d:: with SMTP id a29-v6mr3821778lfk.97.1521046779274; Wed, 14 Mar 2018 09:59:39 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:38 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 20/25] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Wed, 14 Mar 2018 17:58:30 +0100 Message-Id: <1521046715-30683-21-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci.c | 31 +++++++++++++++++++++++++++++++ include/linux/psci.h | 2 ++ 2 files changed, 33 insertions(+) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 463f78c..45d55fc 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -723,6 +723,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 Wed Mar 14 16:58: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: 131690 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410849edg; Wed, 14 Mar 2018 09:59:41 -0700 (PDT) X-Received: by 2002:a19:d0d5:: with SMTP id h204-v6mr3787898lfg.124.1521046781255; Wed, 14 Mar 2018 09:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046781; cv=none; d=google.com; s=arc-20160816; b=GRC8FFnka5m/wc3u7KYODyNVAePdGJmKLwnNImnQhN0Izc1zXsja6G4v2UJhLQUxlz sKWhbEeom4odcQc1pNdyxbEw9EMrneySAtthkAwz5WtaDR0rgcDZfq9bWrYTgo3KIRJY vOLlr+FGvb2wxYb56EfdGJ7NKbyJloHWfiymrSinIdrKDimMQ1y7kO8/9NSOZRLAyUJl EpBugXedMO4RwDDOa+TIsWseaH/fBP5QVZcWVriktAgVeIKNmkvrbv5mFonGqmiloPNg ozf6gZH+N2wjLFjcDznqzWEmMc83dZvmnMw7iNBSWfgOmD3qOBIo/z1tBnVoh//hYF41 J0bQ== 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=J6ldBd391MN9+dSovGT58nU3Aete+nPqspX9bPdHUFw=; b=g5deykXgHdEQUQMgLifecq/T7qJhT8TSaHZW7y9m5EPyby1MaC51IN0ouqrRWma8kG Q4bZNCG2Ixc3PoFxNBdmFfvHbLrvMxNs+JXrRLdXh0dnle4GM12uxGIE70OBLDrRIAjA f3JdIeOCNV/1kqF6u7/um5n/QGRI39THTz3TcAXuyn23cZln6jAAFnldAz9h5TTMUCPw Rw+iat1/nn23iTC1OIHywVe7cTbpOEkTsMqKUKzaR0JZIiCv8jrpTk6FisnUQjbnkw32 hlzOm/4i+PPMoAEGC0W0TVR0QmEh4vNBGFkw3N8fVDnjzs+m6w/DTIPRZpUj8ixZedz2 umYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=irW7RLex; 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 d23-v6sor857569lfc.59.2018.03.14.09.59.41 for (Google Transport Security); Wed, 14 Mar 2018 09:59:41 -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=irW7RLex; 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=J6ldBd391MN9+dSovGT58nU3Aete+nPqspX9bPdHUFw=; b=irW7RLexOHZTnPPDGDj/CsdONcshA06y3qB5nzQ2dquT3eG/jVuLDzp9a0bI1qqHwd Yy3ptLilr60T0Dd2h6n8IWy/jzPaIPj2+mT27RX7fAhWQ5RdJQ9U+KwWh33uoZQQXVQ6 BSHGr97/E5PvNsZn3cHHuhHPhTPKvOy+ro3xw= 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=J6ldBd391MN9+dSovGT58nU3Aete+nPqspX9bPdHUFw=; b=mW3/LX0GmKJ6OPak8tdpnXvmRCUFr2iGVcWIHILqcd2SRJNE6cjdJLKOJL54BvJ6YX LxvJjiKMmSFeHeBvZAjDJVmJ82tar+hZhJnEwNE9yMtjioR5PUT8Ab2SclMvswwXzcZi oAgYgfVNTpyZVNnKpXBVbuOzYN+9ZvXDpH01y4R1FNDmqyXsm9KEwUcAGyOHXafgi3Kj NjDi5J/BQnzrSFzqSZR2r6uu2uo5dQtuHTnpMVPFiTIw1nrazJmHAMlg93IwjXxo22bk mhtser2Kp2mAn9fG7QBMqFPpdxLK7wq9Xyq1N9eJM67lpOnEu8602w8cYXg1ilQ3vE3q vMOw== X-Gm-Message-State: AElRT7FIeow7L+bDWkqEyV5J829sbBKrj3vRgmv/sGIUVefcEjlRNc/J Ta2SGPh6bSD7P5Gic8O7ZQdXpx6E X-Google-Smtp-Source: AG47ELuYlZZaBkRXPbOX1Fpim8g97uwbyhYbBN1X56jiw2zEsXIKehlMJoRu8yX9/6I448tp/xIzqw== X-Received: by 2002:a19:a293:: with SMTP id l141-v6mr4146970lfe.38.1521046780943; Wed, 14 Mar 2018 09:59:40 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:40 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 21/25] drivers: firmware: psci: Try to attach CPU devices to their PM domains Date: Wed, 14 Mar 2018 17:58:31 +0100 Message-Id: <1521046715-30683-22-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 45d55fc..944d6f6 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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: @@ -748,6 +758,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 Wed Mar 14 16:58:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131691 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410909edg; Wed, 14 Mar 2018 09:59:43 -0700 (PDT) X-Received: by 2002:a19:6d03:: with SMTP id i3-v6mr1471066lfc.34.1521046783349; Wed, 14 Mar 2018 09:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046783; cv=none; d=google.com; s=arc-20160816; b=k7tJ7Lm9NDbtf89UAhk0qif8afKFzjxhLZJ7gtKR+i00d9v+H/sva5g2I7g4You9lC sDaMLAUJl2U8b1gErjhPtATAIWINAUhZQN/Ivdfs0TLCUP8yQ3iEFPC26PszRgNihtmF F2GE26xveGDtFkYmyBxXUBkt6Jt/ZVVjL+xSULaa8efcf+ePGbMb9yidNI6LNenugN9A EfVZ2cXUqa2KsJZCcTkviaGWtSHDMnd/uza7McBXpl0awHrzonR+ogD7uSVbYl2ONFd3 8uIjLYSiWw6IEwF32BrchV7wELQuTWXdEWU+mMhLSkJLtcE8K+7Y15QJn+Ovb1YFo0DF IUtg== 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=V8T+Aaj2D90miakPHABzG7i+72q2t4QS0xRQy403isQ=; b=KxuLyYZNthRph+J6BoWhafX1TkWet/tRM4gJnn2NQ+vlhd69niMsoQPYBEABt9fHIO UsJD4MfSQmhYs5CZ0mxVgi2Ebt4m1kfBBvJ4x1ukpDtNLgUqwSQypsp1VdwHLkOz4wXy 6KnwDHrOaIKp1uski34Pxt75ZOUVNqmu3mmoffHTJHD2ov6ian+IY819a5ZCYxWT67WT sX2dQqs6NGqZSPxhmRcvLbuDKj0BFtCiM6kYbyYy3k+ohJyVzC+NGwMuSbLffilLEFxe GeBm0NsUSCtMLSdIifSHRqsTY2IFC65BEUa1GfjL2C6/kAf6Mc0Oz63sgu6PPxXdrU5f M7dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fSXiUDNi; 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 a5-v6sor859704lfe.47.2018.03.14.09.59.43 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=fSXiUDNi; 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=V8T+Aaj2D90miakPHABzG7i+72q2t4QS0xRQy403isQ=; b=fSXiUDNiPNUwRmBDehxehFub0OUn3PcIHDy3Z8Q1sWy2ZpGZply6kfDwJjLfQAOv84 NJ7BBruTaodsgwA1E7WALo8DQfOfS9cZ/al149BSoMhzX9Go9Rl8Y7x7HM1XiU9ZO4zj n5u2v7ukl4loY3UYJqHMOtwcIwvM+K2d/MSVU= 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=V8T+Aaj2D90miakPHABzG7i+72q2t4QS0xRQy403isQ=; b=qt8LDoSkYxBJehraN+RM70caZaTnVAT0GVza131juv6P6ORISUfGPOQ2rFt0gOoU5s Cf/VX91A8IY71/SF+hHrebb3bMv3fVQlG1PcnG7Urg3Ch9w3hqzf+I/vy0UPbf9+j6Qe PhNmMRNEbosRLv93KgnqNybIUSJQkewPjMASCcV9jmgtKs4FrP5dFicC1/rJEMUbm36I 75tFoRplhwg3SWYJZcS/7C+MhGanV0+9WWcwjuL6HP17SP1s9JIamVytm3kIzu1rtEbd zpfjVeWCj5XjmbA+4isXtzjJuQvLHa9zyZibigNorSur1kHjAeczTWrXhOqCFLIgy69S onQw== X-Gm-Message-State: AElRT7Gy8FGYqnt5hmodkhF2yGl0TiYQxlxA2dZjSb+/HU0phnbi9Has hSgBq8EG2KL/mAgc6LIxMMZ1+JXQ X-Google-Smtp-Source: AG47ELssIfk3nYMBFM/IdJWMH9O/7jg3r/H9ko7kHjxPMx3GcB/H5MNKeav329Q+3JTtBEmPosRPlw== X-Received: by 2002:a19:fe2:: with SMTP id 95-v6mr4115003lfp.13.1521046782940; Wed, 14 Mar 2018 09:59:42 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:42 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 22/25] drivers: firmware: psci: Deal with CPU hotplug when using OSI mode Date: Wed, 14 Mar 2018 17:58:32 +0100 Message-Id: <1521046715-30683-23-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 944d6f6..06f3916 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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 Wed Mar 14 16:58:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131692 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410946edg; Wed, 14 Mar 2018 09:59:45 -0700 (PDT) X-Received: by 2002:a19:e1c3:: with SMTP id l64-v6mr3915945lfk.110.1521046785222; Wed, 14 Mar 2018 09:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046785; cv=none; d=google.com; s=arc-20160816; b=tKh9PvSk1Vyhd7QDORTGz/++FJMkbCc/ON0sQM01bKkgT1NkFagRFMLc8XzWE1P0HW RPDTSmTIQ/iGBaazGEm24iuomHvGWV2YnUKRVRRFdg90rPCHQt9A/x3WBCo+f6BtTfGN +wZZg0M8c1wyJNV6JV3ZX2YA3Btr+3e8wNZNVhgJh+7Z3tCxXLCcwAQYV7Y59/gO04lV k7fu1ezRV3kbxUTOTHsA2VsGnPTYY/q1aTaRok8LY9b6CUpTgNHaVoppBVQ4B72z/5wr n0Dt209m6/j6TWK7la4BfgyGwWfr1WsFwFxLvdkNNJakx1BgIAKdWw03YlwDOIJ7Lx+Z uc+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=lZ+jRY5+j5DQsEt8O6dR6qZDacsWVoEdtXqv8Lrp+8E=; b=sReJgqVcnuDvHzOxuSTE76X4ukODh5Oseg+zIJyICQYr9R4lDQBf9hIdE6CqbeYybZ 7lq7Li9urSM9UF+vwOijtHPDvJfh7AtL56b8nADaXbANdF3/6jCN5YMKZd2hO1i9BhIl Sz4sK1ncN9TDo58prZaB4tfCxUAWpiGf6ac7n4EK2jkyQzume6QSw9X58lELaE10r7v6 MMvYsjFKqNlQye/apbh/cfOhWpd+Uo3Ns4PKCDBlsp9EwSiKk2aKsV6nl+FXfxSoETyV VFAAPT1AOANFPcy3nW9U8HkTKCSgg7vgZvNVeeCSwZBpuXkYF/G2IvW2Zk09d+B0a084 0g8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZgjjJl9v; 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 102-v6sor814266lft.90.2018.03.14.09.59.45 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=ZgjjJl9v; 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=lZ+jRY5+j5DQsEt8O6dR6qZDacsWVoEdtXqv8Lrp+8E=; b=ZgjjJl9vH7MEixaUEMqOQ8y/H3C1Qn/t3Y80nWZkvDyCK7c33QmnuyZ1ey2UfaZJPO p4+8iHtxhuUFZdRh3DAWDh5R5kgBOY/iENupr2hf03BPjEQ41WZvYKOsOIURB5TzlZQA UgEiOEugA4MxIaEFXI5E67LYvGPAMYHfokeBk= 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=lZ+jRY5+j5DQsEt8O6dR6qZDacsWVoEdtXqv8Lrp+8E=; b=LvlrFCJgHZee+6HmbKDFdsT5mfsVK0zVRRNvTfvNYl/Ny+1PPRMeyzETWwD7pZcsc6 jgsHbwxRPjVVDbu/ilgR56/MQ/fFm5r/r9nzjLJ4MMLexN3hevKxIdn8EZr0AzmFLAKq xg3844mANbj/D5okS0e17rtJSPk+fC0LASUMt7rHI802xx5chh/W523Hz+9iRyjmAziN xRGWKIsjqILYrqIPkCdvCKSmGn6n+oPr0Zc/4Hn1wpb86jiVU6Kj5c6IR8rfAKmoAjGa vIbVlIsfipc8+5VQvQdz/keAsKEcmOQ01iA4STql8dV+8T2qkZHU3xkit5KY4gU6uCR5 kffw== X-Gm-Message-State: AElRT7FQWvOFlGJKSTcDrQ9roOc/RjieyAgjZMzDaa1Qz9xL5x73B34/ Hn/xeNSiyZsQK4Dl8L6U/ILmookm X-Google-Smtp-Source: AG47ELtbzr1KNg6q8KQjCrjXYwXSX6z9nmJgEFXjAOA/0E/JeN+1IzqvPlviOxkMPKUvMVYo2lCkVQ== X-Received: by 2002:a19:48c7:: with SMTP id v190-v6mr1362616lfa.26.1521046784975; Wed, 14 Mar 2018 09:59:44 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:43 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 23/25] MAINTAINERS: Update files for PSCI Date: Wed, 14 Mar 2018 17:58:33 +0100 Message-Id: <1521046715-30683-24-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> Some new files have been for the PSCI firmware driver, let's make the expression more generic to cover them all. Signed-off-by: Ulf Hansson --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/MAINTAINERS b/MAINTAINERS index 4623caf..dda16cf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11082,7 +11082,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 Wed Mar 14 16:58:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131693 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410981edg; Wed, 14 Mar 2018 09:59:47 -0700 (PDT) X-Received: by 2002:a19:8e95:: with SMTP id a21-v6mr4193933lfl.140.1521046787050; Wed, 14 Mar 2018 09:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046787; cv=none; d=google.com; s=arc-20160816; b=gcMgb2/glXHEDJq3HK/Fyt4mHQkTeiP4yvdy2e5fdo3aYrGu42e/TCfW3aQNRM1GBM CT2O+0p9+SHjclERvGfpc1ZqoW76GUASQiyjEZphP7xsfAQYQQgOISyYxUS+reCfuSYA oBXFlXCTfmqfQC4jRvWWAawhvoR368ip4Hba4ZC2KwzXRE1p0TOyx6km0FXNGrntM7Rl LMIlCGyqu0ht/f3XUs5X5OFd7fXiyYpZINkzLKtGp0TWY7ktk9sZ1f8fHQRLBAwo7WWT 8qraooVS9YAj+p3dqbI/0wPpsrXsyfzXDfeSdHJ/6HiigpXqm/+lxKTHguGDhwozcxXL uwIQ== 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=wJC33l/zlBmKmzQgLVd7MIEXNpVnZs+TzZ/YB1phmjURdzGm2oNDIn7e0qE+9713qn AyBfCLk/VIaELn5sw/inimUkS3eDrRKA1EVo4EsQp7cf+P08YS1aheM3p0X6zSdp7iKg AXRdPjsCIbt4GDwlkyWvDd93jTG8eLSZb7fHSbb8xQ1Yq6S0faJv/XFZbdZW1fMoLeb8 PPjhNaUDmU8QYBsf67yCn3WuRlp5djleS+JOVimrIPlA/GpALQN1QaUWZ8Zs669SA9QB UpsnfnaiWkwcS9uLLSSmANoHoqBaKVvdEdNV81W1zP+P/TDIyrkH5ph9Yf9//89+pE9A uGwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ic09qpdC; 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 p28-v6sor856659lfg.42.2018.03.14.09.59.46 for (Google Transport Security); Wed, 14 Mar 2018 09:59: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=Ic09qpdC; 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=Ic09qpdC1/eLYVbhcYOz7+DecrWiCBR6jbpXMDJUom3xvGcUIjm106mQfyOxv8TWaC k1wPXk/0GB74zgPjsGwLyFQiwjdMlBBGgSh1EqMLMSncVhGoBP9yPmQwANX/u8fZEG6e Nikr8U337SBFAmOoK0Ysr7vHHjtY1m35BTE8A= 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=jymiaUAQQ97xEVE84rFxBXt4u6cNxpBswv2GaGosgjHtVpSGaQK4uRhsdSTJVrRGWQ 7VMBprvWDPeQnCUmqEQ6qNwsoMpPlpmi+wnh2vVPccdSuZryZMA4mrL4VEhY7s7VlNC4 MBMUsN1BECjWJtE1BMg1QhVyjdtk8a0fHHRDp8LqTCYNDegvP69Mssy8V9TG7Up5Cthy ntSL9ZDA+egWuE00NoorWTYNabox23STuYz5EHYCet7TQBpEKYwL8vZLXAzf+8Hs50Q/ A0F7bpat51InadhmpriUIEUrkbkTtGuZOMT6+A4LfKJIikIapgQo0j5MetXQjb7ziNMf eC4g== X-Gm-Message-State: AElRT7FtPSrHSZFK42gknuEaRXhPHn9CYw2dRjUEf1Dkl4e9jfQtYDu1 64a95j4gV4Ddv/Irg+hYIoJC1Yyl X-Google-Smtp-Source: AG47ELtroVocYWjrkPQ4P6WWERCPllfN/8m25g8jmfA8KdhmuICrps0L5Y7S8Tna2vwtab3d+AT19w== X-Received: by 2002:a19:7b12:: with SMTP id w18-v6mr4095818lfc.104.1521046786756; Wed, 14 Mar 2018 09:59:46 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:46 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 24/25] arm64: kernel: Respect the hierarchical CPU topology in DT for PSCI Date: Wed, 14 Mar 2018 17:58:34 +0100 Message-Id: <1521046715-30683-25-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 Wed Mar 14 16:58:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131694 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp411007edg; Wed, 14 Mar 2018 09:59:48 -0700 (PDT) X-Received: by 2002:a19:1081:: with SMTP id 1-v6mr4138041lfq.86.1521046788677; Wed, 14 Mar 2018 09:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046788; cv=none; d=google.com; s=arc-20160816; b=AzanabPBmWIyOSrm2PZrstU+12rLe9N+vYDm0O4r9Q9uGKmmMFye/HNiyIl8RpEeoo mjDsW4ijAz6IgRA6pwpk5QCGpoasElAOvXBCx8EaBu94wHms1TCIL2Xt4sih1VUtcIvl 6Z0JmQg9LpJywZuEUeQPA0/nz96cL0qvJi2GUg98JZaNpqGahkPVB8NRl+yZdtpX1+5D lEGfvLoBVEw/OsLYzQiinrm5nSmZ0MszXSNkkcxx7vdYGm6tIJUKEz04UGgXb2fhIlYm xVBGmdCKKYam/+001IyPbX+cioy6ywySjkbFlwsVdHMQVah8L4GYtRQzmuK87+f9Q6zY +Y3Q== 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=a3jkCZvx1U461Q2GeJTWADmT4rq+6YqC8J2+3ScQv1w=; b=xjgBO3Rcomt60s7zbakHpQydMo9RlCLVjlSTxKIX/Y7rPqLTrgDvERFNYFhKnk36IW onHPTW0gwZN8FezvzQOG35gHli8hlOHYFiY7RUactAVjx6jVVpwLj1uILr+OsiulCIYL fsj593Lq4hn0zPPDO7+ktAPjjhomaqcO6mAUWE3rC9xSuwE2Bv0LYlijHPe42ciNEnrK J+c0M34ImqI4ncZ7MBohGoJZNsyr7Eoz1AdGQMOeLBFcF6KhhLp4oiGSxLppobyYAHr4 rE4H1rlHqsEXmRfw3TPtX4p2pzNmUy1WA/M2pSPV9KhqlKsPeN9RYhkSG9WKkdNH/2ZH nuVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e3bZuzOn; 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 x5sor826066ljc.95.2018.03.14.09.59.48 for (Google Transport Security); Wed, 14 Mar 2018 09:59:48 -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=e3bZuzOn; 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=a3jkCZvx1U461Q2GeJTWADmT4rq+6YqC8J2+3ScQv1w=; b=e3bZuzOnUm7xyCPYmuWLgM4bc+VwmCrNXy3CM7L9wifhibIxFZhzryB9aJ9u8wyfdx Y06usBSFRdBekiqjrQOe5WCtYB/J7dmf+B0hmRsb53+4vt/LfTJsI7L8tTBGvI95U6Fb vwusqnC+5Bh2OKwbsfeOKKH2NCKnpS5psLu6w= 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=a3jkCZvx1U461Q2GeJTWADmT4rq+6YqC8J2+3ScQv1w=; b=J8a4lrWWqayuWWpAd4f+ciLBs9ZBe/El5dHuJeqoplBAcbj2K1esjn+Db4Xi5qH9YU 0fuHXaaKzRRFjS5oOVt4opWJ6+uWnRRa1U5wCdGuI0kuAqrAxkU4B9S1jbGx1jh3q/t9 TYErlsjDxZ5upnnItzM/QhayGknh712EPKMPL05bljYmeyWGgF5RH/9GeBIzOqOPHLXQ n9KiWPdRNlcbcNFRD1Cdhh69O8UA3+LYQeFEo8Y7KKyTwQK5M+lkwfx5MOkX9dZgfW6y EBZ/qHBSOUd9MtIBj1nnsCijZ3Lvy4bPDkxpataFEW92Ioogrrkj2BpvDVzkDrurCdvR pKUA== X-Gm-Message-State: AElRT7EOe41z/609sEWKiIDY1EDq++THemcAp2Rq8H+YRcZzTqPrKvA5 zGXvcwMjlFy2coJ5BvJIroY9rB7N X-Google-Smtp-Source: AG47ELvqnPQc3sLZ5QQAMHQbEJspnlvOmyenvWMs/vGnqPmEy/G2BOCGc5Zk1VAyALpybNE2djgQ7g== X-Received: by 10.46.87.8 with SMTP id l8mr3392652ljb.116.1521046788392; Wed, 14 Mar 2018 09:59:48 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:47 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 25/25] arm64: dts: Convert to the hierarchical CPU topology layout for MSM8916 Date: Wed, 14 Mar 2018 17:58:35 +0100 Message-Id: <1521046715-30683-26-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 e51b049..d0bb0b9 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -112,7 +112,7 @@ reg = <0x0>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; + power-domains = <&CPU_PD0>; }; CPU1: cpu@1 { @@ -121,7 +121,7 @@ reg = <0x1>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; + power-domains = <&CPU_PD1>; }; CPU2: cpu@2 { @@ -130,7 +130,7 @@ reg = <0x2>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; + power-domains = <&CPU_PD2>; }; CPU3: cpu@3 { @@ -139,7 +139,7 @@ reg = <0x3>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; + power-domains = <&CPU_PD3>; }; L2_0: l2-cache { @@ -156,12 +156,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 {