Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2763425imu; Thu, 29 Nov 2018 09:50:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/UirgBvPpJPK2F2+YPands4fl3cI51oYeRGqXV7z3iOAqRlQboOlf1Qv64biWer/CAqGkp/ X-Received: by 2002:a62:5ec5:: with SMTP id s188mr2247800pfb.145.1543513813068; Thu, 29 Nov 2018 09:50:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513813; cv=none; d=google.com; s=arc-20160816; b=VSbphR8GUCmaUS7AqpGTpRfQkSlosezOcCdDoF6eRmZ4F2clm3pPIx4kHlOZ5lxcw/ kjbQJd+O+++CQkLV0J24CN2VjZ6RVBLv9IeSnt2DeXkBy4veZXcXDqOfWnWrcU04zALa ZgCBveAqkYHY3iAemghBrAtNoFEnrZc1csiv8c/M9SAQGISDlVPRCS6uXBxBLt4X9f/g ePo+sPE3EL9BNqsM4Q0HBMcevJI4IXsujw4ByFyzd+5OheWCb7BKniwWKcAjupx+tOZC xInObKUJf0AOYIfBdDjPiZ6VXppfc92E3nS0ntdUAKNeVN6Ims4B0O7zFA2eRfCY5GVl dOoQ== 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=PgU1c1CxxtqSBW5JefCvIK+xCW7iLG8npYRcb1HuKE4=; b=DmheJ5n9C2GKVcPp7RaTPyAO4dm57axpZHDTwl6ONvOXN/9rNDXYfgVkBF4apGc+8h 1T/8uuCp7Y1cdCBD5GSGHti/ERFBmMeebcGoJCumnqk2pQFIfazWLYX4uhAZHQrSTLCf A3yhJ8URFe9MkaLOzU1pUiMnGydddmsEoLtEafPzZgwj/nDfQMKF/kgDELD4cFLpgpCe B/vs79t7LUoloy3+IV86fUqnAJgvoQVgvwLyYf/xSaoEFXFfdiVpTxFyFQsZIbpS51iB CBTn3QBog+u8lKWW4kKxBKvRxF2zEcFdMhZGjTcHAIoLwa7sZeTWJ9fBVl/mg3GEj52Z n+ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/5EWbX/"; 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 e129si2454620pgc.333.2018.11.29.09.49.57; Thu, 29 Nov 2018 09:50:13 -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="B/5EWbX/"; 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 S1731027AbeK3Ext (ORCPT + 99 others); Thu, 29 Nov 2018 23:53:49 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:41310 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730999AbeK3Exs (ORCPT ); Thu, 29 Nov 2018 23:53:48 -0500 Received: by mail-lj1-f195.google.com with SMTP id z80-v6so2520955ljb.8 for ; Thu, 29 Nov 2018 09:47:37 -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=PgU1c1CxxtqSBW5JefCvIK+xCW7iLG8npYRcb1HuKE4=; b=B/5EWbX/4pIf3Oc3G2zdHEoTEbgIGKaLe3sWcikr1JnH0hv2gk3BnxwQr4TUdob0pS GBHcOVwcErj08YkbJF+3nI8Qeiz3paCDoblCXvk3zQCosYDQzVJJ3Zu2ag+TMhbtAuwy JVyxj/mbnkShjM0JtEpEnU0awLd8+vHoqWDi4= 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=PgU1c1CxxtqSBW5JefCvIK+xCW7iLG8npYRcb1HuKE4=; b=hyMFMyYMmcsZwah+Ip/5rAE6onG3sZKyOs5jwTov2HS6+GBXkz+/2q7U1i5Pb6Zuwr TSRzHI16861XZWLOmmMOVKCZJuRGczZFfaA+gDEN9VpvW1IMPky3dryNnV0Z/qVXwgMr KHpqbovACXDMBXWVCbkIookY+qYn3mVzuHd7Zwl05ATz0XnQ6EZ3tqZQIzuQt0KQXVhG FUn2miaMS1zwokAP28z70/BVSe93Jr2JnB2WenXOJJ5syq8XbdohghdFgEEC4jaECDIK /FP17U1ohhxfKoMpTCwBCwIE+KRhsp1x/AqUZTJq+Rha7iFSYXSZGQML92/gL8K4V2rt CV5Q== X-Gm-Message-State: AA+aEWaGrm5PzkJqXtC8blOQU71TpGnlPJFd/OHv0SYOppFRAp7cYg6b 1FIg83MqXFAdGZ9f1aYv9sVjPA== X-Received: by 2002:a2e:85d3:: with SMTP id h19-v6mr1678736ljj.82.1543513656433; Thu, 29 Nov 2018 09:47:36 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:35 -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 16/27] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Thu, 29 Nov 2018 18:46:49 +0100 Message-Id: <20181129174700.16585-17-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 To enable the OS initiated mode, the CPU topology needs to be described using the hierarchical model in DT. When used, the idle state bits for the CPU are created by ORing the bits for PM domain's idle state. Let's prepare the PSCI driver to deal with this, via introducing a per CPU variable called domain_state and by adding internal helpers to read/write the value of the variable. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - Use __this_cpu_read|write() rather than this_cpu_read|write(). --- drivers/firmware/psci/psci.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 4f0cbc95e41b..8dbcdecc2ae4 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -87,8 +87,19 @@ static u32 psci_function_id[PSCI_FN_MAX]; (PSCI_1_0_EXT_POWER_STATE_ID_MASK | \ PSCI_1_0_EXT_POWER_STATE_TYPE_MASK) +static DEFINE_PER_CPU(u32, domain_state); static u32 psci_cpu_suspend_feature; +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 inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature & @@ -187,6 +198,8 @@ static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) fn = psci_function_id[PSCI_FN_CPU_ON]; err = invoke_psci_fn(fn, cpuid, entry_point, 0); + /* Clear the domain state to start fresh. */ + psci_set_domain_state(0); return psci_to_linux_errno(err); } @@ -409,15 +422,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 @@ -425,11 +440,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