From patchwork Mon May 13 19:22:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164056 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728343ili; Mon, 13 May 2019 12:23:19 -0700 (PDT) X-Received: by 2002:ac2:4246:: with SMTP id m6mr82886lfl.0.1557775399146; Mon, 13 May 2019 12:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775399; cv=none; d=google.com; s=arc-20160816; b=a9kYRvrMKrQPeY7BE7puYLMcU60CBfxUPXq4GV1SeQE9HYbPbANxz1L5uFWlkjTDeF BrLtRbLBFcUIFZ9EL980ZgXC53omnSp03ivafGaZsaF2F0q2lKRLrtqOcV/Te6p6Xkfk JTXd3SqoLjFrWwSEziVYy+CVPee/wB/+mIeVTRvWqC5MPHVYY/WMen2VjZquefPBCWMc UeOqKcLvE+96LUPEuxDLBUK3JzMUYNemIQqj0n8c/Zj0b/OvBKm8BQ01Q0LdKR5U8dj7 hW/WEii7hATgBPcrMriJwHclXQIdKeekR+xOUujcCKWbk11EAsNMuT8eqZhDcZqG0VD/ kVyw== 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=o5+9luZ7sCLYkQQCN67HXS68IdQpduZUcgaX5OCzqos=; b=Gu7mAuS/u5uDDBWQ3Acq4H8oICjlppPNWwOJj+8NaQ+i1pdJ6qjO99aXFV/PRz97St Nyh/tBpLeLY1IbReJK7IjkbbrF1oQtGgS/qvKpy1avxbxlsn/HHtuo1kJo9QbrrOX0uZ TfXrA5eGhlaaSaZ3Xp2IEkJgngqAwIBkLqodcpRgvZSreStetcFz8/4O8HE1dOiFQyBi 6BsjcsLoYo5rzOXUyWKl/qL5oLNcq4yiS2WpcNcYt/FL0IZlugKfwXiN9JqkeoObWA3x jD74puYvTePpJsSIurqkqDHIdURmVufmH3z7Cr8nPfwKJqWO7Byw07NPnSmBtletFnxy SvUA== 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: 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 l24sor3955074lfh.64.2019.05.13.12.23.18 for (Google Transport Security); Mon, 13 May 2019 12:23:19 -0700 (PDT) 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="FV//hyoM"; 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=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=meBVEyk8T2zqyst1gvlEh74hgLkKcKxMREe2PFmNnOQJfHx3tBBhgxIsxHe+AER2nW 5hebIBynOl59+IRg1bSVfdzxFLYEQoqNOqVmPWTaoxezdo/pDWdDwFhoJV4t+56gSNIp eNjdvspbCqAw1vGUj9xI9/NH4/PZernGQYmrPz3bCytv5RfIrmxTxytUPJsPBZTmd81d TOcDCBzoQTFahjhdMt79psWY5d+TmF2UuqjnmNnlKwb6Xf9yT2xSKuWZX7eTq0kITQwR 15d8lKftlxQ16SdoFhVu+b9NjUT0rSJ49m1/Qwcn+fFlQ16F4Pfz5HPRx9FWgUWQfcLZ w2kw== X-Gm-Message-State: APjAAAWoRPuTmXb2C3Td+GEdY3RmGuXPJb4MTDDA0Bf1JnLs8iKXosUw d0hDPchIaW0BsDtGU11yvijd9VD1 X-Google-Smtp-Source: APXvYqw2t+LdElc4Xj4e0QzMBJlLjpK3q+ffxnx73kmsSfuwHRWHbqmUdPJVxZsVxNzXZK8vAzoQbQ== X-Received: by 2002:a19:4a04:: with SMTP id x4mr14103234lfa.124.1557775398769; Mon, 13 May 2019 12:23:18 -0700 (PDT) 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 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> 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(-) -- 2.17.1 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; }