Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2764140imu; Thu, 29 Nov 2018 09:50:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/U37Jacd6mvjSgxzYwQcXYTSjREDMk0mbgR7jF1Xe8j/KY0ouqIW4HYvf2ahydcGiwdD3DH X-Received: by 2002:a17:902:8306:: with SMTP id bd6mr2403297plb.217.1543513853196; Thu, 29 Nov 2018 09:50:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513853; cv=none; d=google.com; s=arc-20160816; b=PTXDtQhKjIaLNfGWCV3I/GQek2hQAqGza8xDjju6XqBQ+lk+SWZANx7vxEsw2KW4gE 2ZsG8589PEHd+ijyiah7YSQHwhXtVdr/f4ixSKFKX8XEl9dXuoN+yfZHf9zeyDXc20By YbvzdCVUtwp3CXGamNy9Fy3qAN7XtKeR/rmr2fKHJL2ZZvIDxh4hZVc3hNyR+TW4zFwu gxw4mOjuVHGkB+HFw3+fWKAV6vHK8eX4CMQ2jEV6Q5+Gu/Yx+/wBYQwz7ES84H5EetWl j/1K1vXb6YB5XmO7bCCYQVgH/GadZ3f16zIxYZBUCmOP6lj4JgtqOscas249OoFLgtaf RP/Q== 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=RFaG8cXFhArmCpS6rP1BJYuJ7tPHpHBulh3EEudBMoM=; b=AKUP70iw/8WXB6jmOzkr0SnXpj1SrUO1sis9qXWiZBbVIs7jgDsEe4YjCJ2e2MB5nW 70QciHX6XL51JXAMFA8PeojIvAlL6DQC8Th3+g9oQmLepBwEcT3cEPD+gjfxdr30U9kr 74I49O0gSODjObMRF8Vq+NXfr8JXXpPSOjze7TUk0sHPHOheqac3dn5sy4jProXB/OoL Eqdl77Jz80RGlqvRubsTXpGpkVcHzAs8qGa0y7WPhHoPP1gR3Hd8RpXJiLhU3GEU5+uT l8qI3I4uDTK79ZJ9txAF8MFKcKaUe9vI1yq6QEg/T7KKUhUwRWlJ1dAB1Pn0AzDhTHOt H4iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YsyItLbV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 w8si2605887pgm.467.2018.11.29.09.50.38; Thu, 29 Nov 2018 09:50:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=YsyItLbV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1731126AbeK3EyA (ORCPT + 99 others); Thu, 29 Nov 2018 23:54:00 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43758 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731109AbeK3Ex7 (ORCPT ); Thu, 29 Nov 2018 23:53:59 -0500 Received: by mail-lj1-f195.google.com with SMTP id 83-v6so2519736ljf.10 for ; Thu, 29 Nov 2018 09:47:48 -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=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=ipXi5JO1yFMty67vP9VhJE0KU86Pq2wg8B8koO3/SXRfvjTY/IOrbBwUZdE3qj272P kSSI0e/ahMLFZQAKd1e93w/kBG7eWD6VusoZcInqGrEwtSG5cGthCKKgB82nphifeTmy rpS3mbsGj7SlMt+mVoIuOMKCVK5kxsQBT+6ZGUyLzAl4Bm7cWJt9qZBqQ+5erkF6XEog E+WWPt4widD0avBCFkEngNMZ7y48J6srH9BH9T86KhvcxB3EYUNCWKfi7uJaDWVmnhXV IVBwCntmsyt8ALl2LkOWib/eRZhrBc3VEYOtV/L65x/7OMEJ7TH0O+azdULxbaASX71a ksOw== X-Gm-Message-State: AA+aEWYUSkDlZk3EgW8Op/tIMRPRsTq8hZurOUg6B19TZ1peCls55Mki kH897qXA2GbVx9hvcDKSW6QD1Q== X-Received: by 2002:a2e:e02:: with SMTP id 2-v6mr1536589ljo.10.1543513666911; Thu, 29 Nov 2018 09:47:46 -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 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(-) 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; -- 2.17.1