Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5554591yba; Mon, 13 May 2019 12:55:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyIqukZ1D35aeOwfzezsujU5l9C5Wm0N/NCZ7UeQQm7bbpegdCwxBdjMNm8ZsJ1K0cOWj6 X-Received: by 2002:a65:4802:: with SMTP id h2mr31429210pgs.98.1557777358290; Mon, 13 May 2019 12:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557777358; cv=none; d=google.com; s=arc-20160816; b=g5CJmHcl8CIf9cCd/b5SUMakDNXW7LuZY5VQFXh/lgwnNEEMa5QguocDPdcwcF/bkW hL184hkQcg1rX2oXLpg2ImO0IaYVNLPGucjvzf1URLlNnBE1XjB4Z1E1P2w6XwJiTxc1 lhcBR+rIF9gMaCJf282dMVJ2dzlXVOVwjvgn0FP/K1JLvxxb0yyyuXaXytSCyVamL9nW wstzdBTngpeTtxmJvUn4fmrpLtHhTL1w0JuigNyRiGW7EEE54q7ocSPC4mL7SqVl0c2y CWeKLUmzPYyuiobyz8rCrUyCJp0uIs1u6uJzUABWZmiTSOmBrjO7heb9mBgQ/fY8Eu9E uB6g== 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=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=cEWGGcdmZKyMA3mGFxn7bR1OdYWMkl+mQzMDghWHcQ32BMCExHjiw32IwemXxuXJDW BJqZmdG4gvv75C5BIK8MIhedEsq3FxPjSnC1CEeO0YBzls+6pwpUYhuVhPhTpobcOupL C8EKSR7r1Uu7nZpIzUm9KYoR83hGv5dFIID9qNS4zcS3liElpp7d1w560a/u6DPzlv+o ORU7yb4agChKHQr/MArYKW2zSSkuDpegVtRCosWYBn+J6IC6M06rcemqUbfszmHlsbHY dwo5BJES+ZpljMyzFqFK56zEhRfkuh+By7YkCNi0TXQMQhqN5a0ES135/7e3GDvxNTb1 4JjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FV//hyoM"; 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 e15si17714238pgm.377.2019.05.13.12.55.42; Mon, 13 May 2019 12:55:58 -0700 (PDT) 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="FV//hyoM"; 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 S1726880AbfEMTZP (ORCPT + 99 others); Mon, 13 May 2019 15:25:15 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36616 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729641AbfEMTXV (ORCPT ); Mon, 13 May 2019 15:23:21 -0400 Received: by mail-lf1-f66.google.com with SMTP id y10so9947317lfl.3 for ; Mon, 13 May 2019 12:23:19 -0700 (PDT) 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=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=FV//hyoMnEuhzttuAwy+3IjGHtAXZchGsvSZSUyMAJmSDn6Qk/tkPJX+DlL6/5jYzf jjMWLRDOaqPCtvzv2sKC48W9o1aofdOROz4I4viJvVGZPZnvq+pyPn3BVrwCJB/hIPhj xoxPevY6gXOnHpj09x2OwoTmPkocCKVcE7Z93ckD9UyadrfNo3LJ7pOTKkOK+xuf6SLV Afnne5GeWsYyFeQRUOEE13gZvwjrLN5xx482cgJ/AFWRxxE3zyhRueMlyLJa7HIuxd+d tSoTPkin1gaqwGLGobS1zs6UV3QuJLhH0X8bHUVoBjRumtVozN5vQTbZ8hJpt19iAGq+ W/Ww== 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=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=GvWQ//Iy2fMbHAQ1NUNliaCLc3uqUAtcBtZ2o/bvoIaGiaiLx7YZXZqp0KL3eZtcEb LHKgNN6Cagt9MhpgNumg473Ozq+l9iwXoT40LiZTGKfnIQ807qcca94eNt5XlbtuFi8M /KMsFmlWhy2MJsq7RANe5dUttaApcSMaeQ6as6RwkxRF/A+DNXdl/2PnGqUQ40esqrvo Zow7zB46zi17yVG4FJlNyMoG65WZxT1s80sr/Mk+tjF+C6R94WsIUSAyr4sXggf4rKn+ RuduG9HhYb/k4p0qgVMHP5kiZxwX1DFLSp/hYGIPgnFephZ8QuWNov5PITud0/pomaHk Etzg== X-Gm-Message-State: APjAAAW15kw4EAgq2nZ+WGqL10UubHsdKx6+hiqYJiMQERW8bvgwD3Yk USceSs9l81JIwNcK97GyuDKLfg== X-Received: by 2002:a19:4a04:: with SMTP id x4mr14103234lfa.124.1557775398769; Mon, 13 May 2019 12:23:18 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:18 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Lina Iyer Subject: [PATCH 07/18] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Mon, 13 May 2019 21:22:49 +0200 Message-Id: <20190513192300.653-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The per CPU variable psci_power_state, contains an array of fixed values, which reflects the corresponding arm,psci-suspend-param parsed from DT, for each of the available CPU idle states. This isn't sufficient when using the hierarchical CPU topology in DT in combination with having PSCI OS initiated (OSI) mode enabled. More precisely, in OSI mode, Linux is responsible of telling the PSCI FW what idle state the cluster (a group of CPUs) should enter, while in PSCI Platform Coordinated (PC) mode, each CPU independently votes for an idle state of the cluster. For this reason, let's introduce an additional per CPU variable called domain_state and implement two helper functions to read/write its values. Following patches, which implements PM domain support for PSCI, will use the domain_state variable and set it to corresponding bits that represents the selected idle state for the cluster. Finally, in psci_cpu_suspend_enter() and psci_suspend_finisher(), let's take into account the values in the domain_state, as to get the complete suspend parameter. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - Clarify changelog. - Drop changes in psci_cpu_on() as it belongs in the patch for hotplug. - Move some code inside "#ifdef CONFIG_CPU_IDLE". --- drivers/firmware/psci/psci.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index b11560f7c4b9..4aec513136e4 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -285,6 +285,17 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +static DEFINE_PER_CPU(u32, domain_state); + +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 int psci_dt_parse_state_node(struct device_node *np, u32 *state) { @@ -420,15 +431,17 @@ int psci_cpu_init_idle(struct cpuidle_driver *drv, 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 @@ -436,11 +449,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; } -- 2.17.1