Received: by 10.192.165.156 with SMTP id m28csp1829465imm; Thu, 12 Apr 2018 04:21:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mgnRGWI2TvNDYTqIZtgK7SgOHOZ3TMIjNpfoN5kKcrMZ4cmg1EwsAF0AzpCmDHBGL9yXO X-Received: by 10.98.214.152 with SMTP id a24mr7263827pfl.159.1523532099195; Thu, 12 Apr 2018 04:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523532099; cv=none; d=google.com; s=arc-20160816; b=kKDAxsCqNfsWzS4S7YhcycoUAQG8YkBJb18XBbSRT1xtEQ2WlQik6MxzM3CbhENjor B6Gj0+Z2VUzF5Y7wT0vnPz51ABxewYMetgaGMKPQ669Y0j81lct7ppbHdnJD4/bobBZp fWYsKsboHS+OV2+mX1ohJEQidUQBNK6AlpVBlb2tL8P7KIp3FszttR8BwpZ/y6FepFEa P6uRqzU3ZD1Y1m37uvVspOalihOizQ/Tgc96IRRBHMKPq0YB95nJQGVhH/g9JDMjGkPp qdnK26EoxyfIUHqVh6Y7vpG/HM3zrUoQiD1meNwfPPXqVaWX0fWt9U6BWGIzBCpvqbAS +xOA== 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:arc-authentication-results; bh=CLZv/6uOiw9vI+wQv3ueZ/LLuTM3aRhla8SPqP5AgTg=; b=sWNWo70isM9osOr/oae3Jn7JmsHPcjamtr47gh6iFw49t1FG9dTT4rtp0XPaE7Zqi/ CvtWRQT/Z/IwYIPl5Yw6taEcve71GULAEV8hbHcdM/h/Bl87xIuAign0fJG1COH1+xZq deTa30zYX78UQhyHdrKGH7hVsRhEXUpBatZFahGRzOnZpAXpbb+gETXnaQonMa9+y2OL 6+nxGHV+b7+cS/QIEHssYsLtD3wYa/V1KGsZU8+zoqAnTQb8IZlGxLU80OLJsZneCYBo bU7v+9Qt6rqWjm0u6nA6r0wlP+rPGkvCAFmJVP4mpjuM8T0isQnAx2ILmakswt/LH+Aa QGcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G0+Jh59u; 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 p1si2419740pfp.72.2018.04.12.04.21.02; Thu, 12 Apr 2018 04:21:39 -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=G0+Jh59u; 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 S1753107AbeDLLRL (ORCPT + 99 others); Thu, 12 Apr 2018 07:17:11 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:44302 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752621AbeDLLPN (ORCPT ); Thu, 12 Apr 2018 07:15:13 -0400 Received: by mail-lf0-f65.google.com with SMTP id g203-v6so7097329lfg.11 for ; Thu, 12 Apr 2018 04:15:12 -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=CLZv/6uOiw9vI+wQv3ueZ/LLuTM3aRhla8SPqP5AgTg=; b=G0+Jh59umkwJB698c2RB2If9ZKDrVHtAZJJ9hiEz8/AkLQGSrhuVT+RlUjxhVAOh6L pfxiY4BdeBJK8EOWO9pQzVleBnDliJ0aeIlC6oVBxNaV3x2J8KvyqKOinx3E8G2jIA/R BPpB6lHGYj001AEiAcq9Onb+m07GbhBlSIWMY= 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=CLZv/6uOiw9vI+wQv3ueZ/LLuTM3aRhla8SPqP5AgTg=; b=LwfnGymhylWvtxi0LCJ2RuuDTCNbTz9nzQJESgFomyC+Q6LwLm95x/jLJMdbWYp4HU SNY20zXuwjGTFHNLmqMedlUmPVkl0TqEVsbZoZAyjnLtxiIH9+qR9ry2Dt/1OsDt/yBC yfO9LXpxi5sNYYN/9Pqr6XoDsa8Zb75Jix/QxNZzoCRsSwoH5xecjEFRUOViHId88/ye ZrN6bsszly9slD44XvKVkV+iLsbom45dZdebPNLKQFHqLBufjv4erLtlO6UaABQvEzvj D31kKFhSpIyTpTmKL0WLjdTwtkVSeJ589Tz+iQMcU+9muJq/bRsjkqrkvHtdNL4lNIv9 1EMg== X-Gm-Message-State: ALQs6tAnLF21/rm6YcP8N/kHl9EvbE8GdGVpxNgl2oYWt6KIvgiVkbJL dKUV7YZbVehQJ15HqC1j0Lw1gw== X-Received: by 10.46.41.19 with SMTP id u19mr415801lje.62.1523531711875; Thu, 12 Apr 2018 04:15:11 -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 r29sm543187lje.72.2018.04.12.04.15.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:11 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 19/26] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Thu, 12 Apr 2018 13:14:24 +0200 Message-Id: <1523531671-27491-20-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-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 needs to be created by ORing the bits for CPU's selected idle state with the bits for CPU's PM domain (CPU's cluster) 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 variable. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- 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 e8f4f84..40b2b89 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); } @@ -408,15 +421,17 @@ int psci_cpu_init_idle(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 @@ -424,11 +439,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.7.4