From patchwork Wed Mar 14 16:58:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10283213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE07F602C2 for ; Wed, 14 Mar 2018 18:13:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD3382851E for ; Wed, 14 Mar 2018 18:13:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C17C728574; Wed, 14 Mar 2018 18:13:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 30E3D2851E for ; Wed, 14 Mar 2018 18:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=L35J8TiphpmipIzvVB/LMEr3gnMryDprF9k/Ltr1TG4=; b=bW6T7+rAR2U8vlOAsRaLpRpl5n ingqd1Jb1JjYceWJGAsL3FTBuEwAR3Dtui9sUxhdLT5pL0aISsyMpQN+hXcG8YFOYpYjESGi95zTW ISc4hO+i03CDshnAHQjAIjumYjdm020X5+xs8Ft4EUmQgOqiXZXJrmVWEHl8CkmARLuTDZ9lnpicF 7MchEsN7e+sF/sRTPfPaq8pukGr1paDJAVoylBEH+N2Jwlpk3v/8yfMs1p1w8MrrQ2o2eIyvu009m gxxnKVNyPrlWdOnGwcVQbsWulxhgPJq4IqknywzYMs+pn/1JheA5HlbxmC8CEuTToxcvh3zQzRWYv litTuH5g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewAtl-00017p-Pz; Wed, 14 Mar 2018 18:13:13 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewAqa-00064J-M3 for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Mar 2018 18:09:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=FUG68ZJ6FfPg09HHbhiLKvCZ+ axDZEkKv/pnUihW6Zf+1UsfELwE2LE7+cq3FD/2Bh/Q/Ic1UY1YBIN8u4LqIif7VjMv43m18aZOOL 8bRZUNApnn5AIi3bXrwYafc5gDGRENld1UFJqcM2/easxy5uRKRhawcC2jyzZv3JEjnV1zAzkZjAE kjwloevolaj1FjqmsEJdHZTzjfwLhvtTlFZuYtgQ8L1Y+9ZGXxztqCnvvqQ4OANQBIsTg3JMv6x6e kICcG/6njf5w29f/nQrZgUwa8Y995/7tYo6f0wpkUrDmYqKOPMuW+A17UiIKzdMbILNACe8Bo04UT NllmEXI2A==; Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ew9kY-0003S1-9W for linux-arm-kernel@lists.infradead.org; Wed, 14 Mar 2018 16:59:39 +0000 Received: by mail-lf0-x244.google.com with SMTP id t132-v6so5888427lfe.2 for ; Wed, 14 Mar 2018 09:59:35 -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=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=CaeSA93BsScWtu8p5IOaQ0fm29LZN5DKKFnYPsr84B2ub3UNz5SeYD84PyLjQWGtCO q0Q+1U6249+40h3L892EwlhuyPANDqdInPcGuqQCdpOityf/7dVyl/2tN+iFJOHQHd5G dikyFyKcKHdmLGhAl3KuZbCck7Xvkm78WNJes= 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=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=VvTAh3fhQQjppF1G7YNAV/9T+rl7aoMYZhWa5PXn1HcPSNplvtPBbcHWXEAVoL5XhE lwRJwdQXblaq1GwJcbbVyJZbJyIzqp74N4aNeh8wnrb2KVICcMdXqWe5FHvfHDyAMWap n5VrSnt3i+no+26R87RyfHl8FN52IruuWVtu5UoZ+AI1WXUKieJENnUbhofGgzFQb1Om zvMLLLQMp0cmFswAaWAOhwpswJvt3TJqyvOPZy+w3GLtZGaUSY1YdRyYehIbPp1a3EkF dYZ7SApyxZJtflGC2IOKWWW8VJFt9NbgAA5yBof8n/d9GmN+SNIzAB1fKw4HOJHjjbyl lLYA== X-Gm-Message-State: AElRT7EO9cM1YYgKWEShxBCaPobUUyrx6G/nalPkzb28jki6Jpw/J7Su J7Y15mU63RrHd/8f3r8IpCXhsopo1eY= X-Google-Smtp-Source: AG47ELsgpEr+HeYvWnb00y9+Rtp/YotOd6fahqWc/Jart3CXWlZSScHMjYs80FMUIODF9ogAllH0Pw== X-Received: by 2002:a19:d945:: with SMTP id q66-v6mr4136366lfg.62.1521046773371; Wed, 14 Mar 2018 09:59:33 -0700 (PDT) Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:32 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v6 17/25] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Wed, 14 Mar 2018 17:58:27 +0100 Message-Id: <1521046715-30683-18-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180314_125938_436049_A4793277 X-CRM114-Status: GOOD ( 17.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Juri Lelli , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , linux-arm-msm@vger.kernel.org, Daniel Lezcano , linux-kernel@vger.kernel.org, Lina Iyer , Rob Herring , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index e8f4f84..40b2b89 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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; }