From patchwork Wed Dec 11 15:43:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 181272 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp701968ile; Wed, 11 Dec 2019 07:44:11 -0800 (PST) X-Google-Smtp-Source: APXvYqw2NqC8CTZ0bK0BcgzX924gu6MzIthqnxAMk8klcWmxmKFNCGwntfTNcUIbaWiLOoK8NP0H X-Received: by 2002:a9d:12ea:: with SMTP id g97mr2835177otg.105.1576079051400; Wed, 11 Dec 2019 07:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576079051; cv=none; d=google.com; s=arc-20160816; b=Qy+m4Hzu33og6nS7LDpPwZI0fuTIG/TCvO9ab3HSmbUAWUvl3VXFzwRcEnqIIGgOJq 5TlsywXYxbx0nuRhUjKLQ3CYyomYea1/iAECYit+UlNNc6wR2oFnZRdSwoBI+qRBfpYz UuM4wezzV8NVIWTvsH7xAg8MltEaK+SZeJ+EJcEXN0hGuG1R33EpION/xKNzc/qDWvQv UsUos2ECmSVpBnJ4C+VjFzeSuiswKsIjeCyBZ92TAGvkrPfi/XjImQn7pUFO7dansdD+ agDg4rFy7gtYzHFC1IedLr5CB0AgvqjXy6CBeP968f7FdmwB6sqiaFL6nGeigx6Xv5Sj udqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ZEqQy0QuBsg1TqWJIDaDl2CROKkjokF3ooQD0C47ttQ=; b=r7JWs8oj9I2vdzSX1FfNcFgKvBPq4V9UsPSMPr7TG1AyCZes+KPnE/6XdQWW310HXU QrAucYq/+42EGre+qzzJwPdnP8kofu+TPwswLUD4zt8CCVKjeGHwMTGkosVOymNh5YTb VUIvOtczNYcpt8CQFF402mVVunyd+oI/lhpqvCh1YEFfL/iw9q64Jv4jCgXE4J6/u47t ck9yIW3L0uZaDqFLlFWqehuv3mRjQn2y1upqLF4d3tMOPnobe1F9WtBQtfcyZPTgPY0L dMKU7M+gYvfpVGD0L7qaHkLVO1zQasydOcptbgI4kGXf0lCJg8H4BQBqTxV3yBfMR2qa UYcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=crgggGsC; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si1299064otd.113.2019.12.11.07.44.11; Wed, 11 Dec 2019 07:44:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=crgggGsC; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388755AbfLKPoJ (ORCPT + 15 others); Wed, 11 Dec 2019 10:44:09 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37109 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387474AbfLKPoI (ORCPT ); Wed, 11 Dec 2019 10:44:08 -0500 Received: by mail-lf1-f68.google.com with SMTP id b15so17064156lfc.4 for ; Wed, 11 Dec 2019 07:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZEqQy0QuBsg1TqWJIDaDl2CROKkjokF3ooQD0C47ttQ=; b=crgggGsC3dwf7AJpgrpv7kiGHF0JSSV9L2QDRT6xPS3QwxZWH7sgggU0/LquhhHokm zkco4V/uRz2u/hqibm2QejtHtq4Ir5uj3ArxE/PyRQ0aIkkaTRzgm/KIwgkEvRZkKlM+ cBaNX4NfPKTCSakCdK7opEN0D6LCpsB6Cq/zFgnvyqUWWayJQrvaVPOYLyONQIlIFtnU 5/PvHNppqyW2XqLkgWXRI2iZRezylJ0cOdImrm90k8NP72fDvgO07gNPQabsjcPMhBzt fPCkAiYyGUfyR0ONYMqaTRoqjqGxXWM8qiud4j7NNNGaz3dralBEf1UmqJWYm3cn9x8r 3fLA== 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=ZEqQy0QuBsg1TqWJIDaDl2CROKkjokF3ooQD0C47ttQ=; b=Nldp7F6k/xyw1KPg5nPW2N5TbpdUbfLmL9o/ep7999iWUDjvK51gEJQE9u+g6bYfLt 3wyz6gv8teNYoX69SpJ4sFg7FhocQcJ6kINUITo7k/2g8Znfx8PqN+4w6tHvMS/V/oH8 ZwnYcxX0kWmVN7nqMxLjQfLt7DwIrwTQI1Q43B0FJIiK46q8ZJr9ivRXPpQBKYYvWV6T 8pdEQvj2U81krEbKHNO/G0MEgIcKsxCgXvMYoeT9VjAr4rViC/HTsgYBEk4LlqDEC+Mh 5eCgn17qP8Nade+EkuzIf97xlSKd+J1MQTkcxpbk5pl4NedLQabkGwF6q0U5aApSdaD3 nX8g== X-Gm-Message-State: APjAAAXYayqJ3QZRBsAnL+0BeFbT5CiWPFQmh8eCTjBnV7hGdbP9pCC3 li2DGAmsUSDPmB+Rpk2eoLMhCg== X-Received: by 2002:ac2:5e9b:: with SMTP id b27mr2649079lfq.147.1576079046311; Wed, 11 Dec 2019 07:44:06 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id b14sm1389608lff.68.2019.12.11.07.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 07:44:05 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v4 09/14] cpuidle: psci: Attach CPU devices to their PM domains Date: Wed, 11 Dec 2019 16:43:38 +0100 Message-Id: <20191211154343.29765-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211154343.29765-1-ulf.hansson@linaro.org> References: <20191211154343.29765-1-ulf.hansson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to enable a CPU to be power managed through its PM domain, let's try to attach it by calling psci_dt_attach_cpu() during the cpuidle initialization. psci_dt_attach_cpu() returns a pointer to the attached struct device, which later should be used for runtime PM, hence we need to store it somewhere. Rather than adding yet another per CPU variable, let's create a per CPU struct to collect the relevant per CPU variables. Signed-off-by: Ulf Hansson --- Changes in v4: - Add check for OSI support before calling psci_dt_attach_cpu(). --- drivers/cpuidle/cpuidle-psci.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Sudeep Holla diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 830995b8a56f..6a87848be3c3 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -20,14 +20,20 @@ #include +#include "cpuidle-psci.h" #include "dt_idle_states.h" -static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +struct psci_cpuidle_data { + u32 *psci_states; + struct device *dev; +}; + +static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static int psci_enter_idle_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int idx) { - u32 *state = __this_cpu_read(psci_power_state); + u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, idx, state[idx]); @@ -79,6 +85,7 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, int i, ret = 0; u32 *psci_states; struct device_node *state_node; + struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); state_count++; /* Add WFI state too */ psci_states = kcalloc(state_count, sizeof(*psci_states), GFP_KERNEL); @@ -104,8 +111,17 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, goto free_mem; } - /* Idle states parsed correctly, initialize per-cpu pointer */ - per_cpu(psci_power_state, cpu) = psci_states; + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (psci_has_osi_support()) { + data->dev = psci_dt_attach_cpu(cpu); + if (IS_ERR(data->dev)) { + ret = PTR_ERR(data->dev); + goto free_mem; + } + } + + /* Idle states parsed correctly, store them in the per-cpu struct. */ + data->psci_states = psci_states; return 0; free_mem: