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: 11285455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F020E188B for ; Wed, 11 Dec 2019 15:44:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEBCD24685 for ; Wed, 11 Dec 2019 15:44:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="crgggGsC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388755AbfLKPoJ (ORCPT ); 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-Google-Smtp-Source: APXvYqz6G0V9w/CiBy3QQqH4g4H8jB9GpTQH6XahhQT/gJ+INB0/yKI1QY+9Pl+Z9bTJ0xaRV6xGag== 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 Reviewed-by: Sudeep Holla --- 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(-) 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: