From patchwork Thu Nov 29 17:46:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 152446 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2672620ljp; Thu, 29 Nov 2018 09:47:48 -0800 (PST) X-Received: by 2002:a19:4345:: with SMTP id m5mr1608059lfj.142.1543513668168; Thu, 29 Nov 2018 09:47:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513668; cv=none; d=google.com; s=arc-20160816; b=ZS6hV/AgUO/OXMVDtKTAVmzUeTWHbqXq4nn9S4KhFkixQH/hrgKmI0qqPoADfa27Kt W5GWQHx16c8pJ5tBnH2CH/jOdUJ/DN4cloY/pC1mv3JbSZClyqzgV7giVqzmWLrbygjl x3jF2VWIJHmO81ghppdoBKtuq2mpkbT8/9RPgwDFwI6xn6NcLcQgGZKrn3+FXdpmrg1D oBLdcUUVl0UbVn10Y+JNM/sIdgGCcn7DZ9IVlvDN47ptvv0vBDBmarTJaHB4BVfuzHTe 11BYxaqFI6ySSE2AASLhcsH0pkAlsR0ehV0hKUHiAmN2FsnhqrwbKFZR7hp8dvCzHwLN b/5A== 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; bh=RFaG8cXFhArmCpS6rP1BJYuJ7tPHpHBulh3EEudBMoM=; b=wGC0WWVssqSCf0UDllboq2K2VYFu039O+JgDdbDrB03BX/mjxlzYtCOzOFdMonG4hu Vl73ZSR55MTDWmC1b3HYet9kIxI4HtvtZZqLyWQccziAewah0oNv4UXk3O0PvErxjIMA fEVDJYXNdxlaZiNSklhK0b1dUGWKtiXAOAZIO7ye3l0V6i03ElekXir1ZB8o3QLyjbqf 7aFft98IQ+PLhd6xqZW5d0S0DtR5sIT6jwQjSRe1BYhgjm/wsRVNaLGK+BnitzjVFFJ2 m0j5Ob8oj/PJn741SHI03rrx0co4cE5LeYnH5VqY1iTVQbEGFiTwrReGNQTp0yUCAv9h /HoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YsyItLbV; 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 l20-v6sor1761981lji.21.2018.11.29.09.47.48 for (Google Transport Security); Thu, 29 Nov 2018 09:47:48 -0800 (PST) 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=YsyItLbV; 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=RFaG8cXFhArmCpS6rP1BJYuJ7tPHpHBulh3EEudBMoM=; b=YsyItLbVHbH3tNLzCiQMEYnmNZdjcvUx83pMpRN5YHP4Kjmhe6ZXEntFzFIP+AgDbr qJwxSlvke/NW59tkmG9joPEpjGPElE19RUBmi1WUnO9dFz/sBAqaNSjy1xznLW4+AKe/ 4lyBldpmHWjI+AbKgVIYPcICKOGDXesumiTy0= 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=RFaG8cXFhArmCpS6rP1BJYuJ7tPHpHBulh3EEudBMoM=; b=o8gkHcB7X9xZrGuGl7bxhQ/JtbzMkRMVccttyq7JKAgwzWrxcm/LkL+IKn+kCgmwpc IphjBAoy3ZzMwOQxK07glSA4t2QVlgIgPfOY1bNTh4f85ce1Ni5pK8vXkkkrwjGmIjyT UfGXyyktwLsJl9cDkSGKXUk7+Tu32Mjz8hUBqT3EHZbm23v2EoMJfLnj2F7b0s7t1HaR igkSihh3xYw9LEPUngyNt0WXgpKuYFaKdS0WYuR7X4eU8oS5AfdDCtaagGeILW3CzkM6 C7Blxhih1ndwcBMSox9kvT0AZSnW3OwzgnlFK727k4kds7f8yWBHkxTZTdLeT8HHXj+6 lmow== X-Gm-Message-State: AA+aEWaVYbISGn1gHc9kRPNEowklGlwuOfCk9Nj+2AGq6smPnJ/j376f QEuiAjQkioEr9nV/aBsiA8CQ8iXA X-Google-Smtp-Source: AFSGD/WVodyz08Ry3gytrKNYSqfpWR2+qsmxRgCgsjxMAmnxCpSQnymL3the+lKJOkCI1ZjncfMR9g== X-Received: by 2002:a2e:e02:: with SMTP id 2-v6mr1536589ljo.10.1543513666911; Thu, 29 Nov 2018 09:47:46 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:46 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 22/27] drivers: firmware: psci: Attach the CPU's device to its PM domain Date: Thu, 29 Nov 2018 18:46:55 +0100 Message-Id: <20181129174700.16585-23-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> In order to allow the CPU to be power managed through a potential PM domain and the corresponding topology, it needs to be attached to it. For that reason, check if the PM domain data structures have been initiated for PSCI and if so, let's try to attach the CPU device to its PM domain. However, before attaching the CPU to its PM domain, we need to check whether the PSCI firmware supports OS initiated mode or not. If that isn't the case, we rely solely on the cpuidle framework to deal with the idle state selection, which means we need to parse DT and convert the hierarchical described domain idle states into regular cpuidle states, hence let's do that. Signed-off-by: Ulf Hansson --- Changes in v10: - Attach CPU devices to their PM domains, regardless of OSI mode or PC mode. - For PC mode, convert domain idle states to generic cpuidle states to let the cpuidle driver manage them. --- drivers/firmware/psci/psci.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 5b481e91ccab..94cd0431b004 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -327,7 +327,7 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, u32 *psci_states; struct device_node *state_node; - psci_states = kcalloc(num_state_nodes, sizeof(*psci_states), + psci_states = kcalloc(CPUIDLE_STATE_MAX, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) return -ENOMEM; @@ -351,6 +351,26 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; } + /* + * If the hierarchical CPU topology is used, let's attach the CPU device + * to its corresponding PM domain. If OSI mode isn't supported, pick up + * the additional cpuidle states, from the domain idle states described + * in the hierarchical DT layout, as to enable the cpuidle driver to + * manage them. + */ + if (psci_dt_topology) { + if (!psci_has_osi_support()) { + ret = psci_dt_pm_domains_parse_states(drv, cpu_node, + psci_states); + if (ret) + goto free_mem; + } + + ret = psci_dt_attach_cpu(cpu); + if (ret) + goto free_mem; + } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0;