From patchwork Mon Feb 26 08:20:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 129592 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3358973lja; Mon, 26 Feb 2018 00:26:32 -0800 (PST) X-Google-Smtp-Source: AH8x224Pt5x4McBBcY43LgKz7XI6vmgI0zk9AxRx9xS0uz2Le73IH+Ghu8XaHVGQgDhj7ANoRLON X-Received: by 2002:a17:902:7c11:: with SMTP id x17-v6mr9978446pll.59.1519633592546; Mon, 26 Feb 2018 00:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633592; cv=none; d=google.com; s=arc-20160816; b=y64HNw5iIHrx4kevlGA6GbXqdQQOoxaU0U7K5cU8WUSRsBHWNYXfpbjMcjuY4JC4TR jE4PLmY76KJLDJ5mBlh3C4UZuAPPCv5OWt0aBTGv5mPiFUsL6yEzrnfVBE6O5CaQZQ+D dRk2fPGsx2IpxMxfeUvYpw+QDqEx+jdqWhJWipGZ4fFo8vd2WzZQlCKaioEQ6icdhbR5 TabRIJiO3h9hSxdGo+O6trTX69UUy/xkJZBkxUyI3XhQJrJ849JO7XkESkzDlTI/RiqD F8MTYG5Fo3JYTSGs1PyNbVaSSETBhAEhXgGmqLSXpesPPTYCYVUrEkz4n7Fvd4yJGsQu BNMg== 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:to:from:dkim-signature:arc-authentication-results; bh=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=Qm210QJuFHqjPuX+iWCgb/h+u5I8X1I/zEsPf+RDTJq/2W+VCO0I1/SPbLzJml2r1z D0rZibu9lH4lE2tIC8177Bezq9fHcrDWIhEfs30ZAsncFJrSyB1OvgXJhjiOtBDq46S/ LSU6CrYbPi+lWI10NT4pYwsBpMJY4Xd/EdLPEPvgJ+dMFw9i1AL32Llh+rOWMsuT4Qkd sRbh1jP/VDS5hedMdNMxTo/BuW0bfnLJ0R0LyscyveRt9IRCmVIzW/BrPy5ofNsnabzw TAM79ZrFb7zfh1VStNIlq2dpsArrJgjfkpIALo4J1o7tGEzzhKYTzDxV4yW3ZluHnsI+ ZCkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=huHrpEo6; 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 l14si5214459pgc.615.2018.02.26.00.26.32; Mon, 26 Feb 2018 00:26:32 -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=huHrpEo6; 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 S1752747AbeBZI03 (ORCPT + 28 others); Mon, 26 Feb 2018 03:26:29 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:41326 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752567AbeBZI0V (ORCPT ); Mon, 26 Feb 2018 03:26:21 -0500 Received: by mail-pf0-f196.google.com with SMTP id f80so1122149pfa.8 for ; Mon, 26 Feb 2018 00:26:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=huHrpEo6HLIOd/KCc5P5goXLlPyVPKyl03CHY/finVtxl91PHNnKqPl1/1YP2WqAsm NjdQMb7k5FS24kD+aFBkl9E5Mj/OfUQUs32hPUlH3OeRuMeUITA0wu0ISkHiNuH9Gevb LGTstrvHqEnLSBwKPgo7TG+lM+9ekuPdvnG34= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=mlKD1HasmXV+iqWfbqTaYvsmBP6+S6jjrVZowh8/3C9MhhW5feE7RzfQ1LPq3JuL7/ ohxFy+Mtl5zu5JwHKnxHOfoKHsud5FMvsn4r2OW3wH08J2TvIYIxydBo/I76QuHKXfYs hGlqrIy6BRdWFr4jNnW6MdshNeWOifdjaPmx0gW9zNyodsgjf5jnujDrtSETnT0xFaSt vMVX1xXbJBzYjk4ltx92c1jjKCohCdmbxpS1u9TF9cR02EBAywHuLVlCLzE50yG1EO4s v5C0mdRp5YQ3VJCAgFPeyOyT/SbY6hAkUU9P6dd9F/gQItGm/mqS22ZLiMfWv2poy4nI 73pQ== X-Gm-Message-State: APf1xPCGSqgKjeQM/o1ICQSIF0vwswc4aOZjFgDi04Pyal8Ma3uoFkoO 3KarEJkZjrBu+4k/MB4dyGz/IQ== X-Received: by 10.167.131.135 with SMTP id u7mr9827489pfm.50.1519633581094; Mon, 26 Feb 2018 00:26:21 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:26:20 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, Mark Rutland , Lorenzo Pieralisi , linux-arm-kernel@lists.infradead.org (open list:POWER STATE COORDINATION INTERFACE (PSCI)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 40/52] firmware/psci: Expose PSCI conduit Date: Mon, 26 Feb 2018 16:20:14 +0800 Message-Id: <1519633227-29832-41-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 09a8d6d48499 upstream. In order to call into the firmware to apply workarounds, it is useful to find out whether we're using HVC or SMC. Let's expose this through the psci_ops. Acked-by: Lorenzo Pieralisi Reviewed-by: Robin Murphy Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Will Deacon Signed-off-by: Alex Shi --- drivers/firmware/psci.c | 28 +++++++++++++++++++++++----- include/linux/psci.h | 7 +++++++ 2 files changed, 30 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 9a3ce76..a49196a 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -59,7 +59,9 @@ bool psci_tos_resident_on(int cpu) return cpu == resident_cpu; } -struct psci_operations psci_ops; +struct psci_operations psci_ops = { + .conduit = PSCI_CONDUIT_NONE, +}; typedef unsigned long (psci_fn)(unsigned long, unsigned long, unsigned long, unsigned long); @@ -210,6 +212,22 @@ static unsigned long psci_migrate_info_up_cpu(void) 0, 0, 0); } +static void set_conduit(enum psci_conduit conduit) +{ + switch (conduit) { + case PSCI_CONDUIT_HVC: + invoke_psci_fn = __invoke_psci_fn_hvc; + break; + case PSCI_CONDUIT_SMC: + invoke_psci_fn = __invoke_psci_fn_smc; + break; + default: + WARN(1, "Unexpected PSCI conduit %d\n", conduit); + } + + psci_ops.conduit = conduit; +} + static int get_set_conduit_method(struct device_node *np) { const char *method; @@ -222,9 +240,9 @@ static int get_set_conduit_method(struct device_node *np) } if (!strcmp("hvc", method)) { - invoke_psci_fn = __invoke_psci_fn_hvc; + set_conduit(PSCI_CONDUIT_HVC); } else if (!strcmp("smc", method)) { - invoke_psci_fn = __invoke_psci_fn_smc; + set_conduit(PSCI_CONDUIT_SMC); } else { pr_warn("invalid \"method\" property: %s\n", method); return -EINVAL; @@ -654,9 +672,9 @@ int __init psci_acpi_init(void) pr_info("probing for conduit method from ACPI.\n"); if (acpi_psci_use_hvc()) - invoke_psci_fn = __invoke_psci_fn_hvc; + set_conduit(PSCI_CONDUIT_HVC); else - invoke_psci_fn = __invoke_psci_fn_smc; + set_conduit(PSCI_CONDUIT_SMC); return psci_probe(); } diff --git a/include/linux/psci.h b/include/linux/psci.h index 6306ab1..66ff547 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -25,6 +25,12 @@ bool psci_tos_resident_on(int cpu); int psci_cpu_init_idle(unsigned int cpu); int psci_cpu_suspend_enter(unsigned long index); +enum psci_conduit { + PSCI_CONDUIT_NONE, + PSCI_CONDUIT_SMC, + PSCI_CONDUIT_HVC, +}; + struct psci_operations { u32 (*get_version)(void); int (*cpu_suspend)(u32 state, unsigned long entry_point); @@ -34,6 +40,7 @@ struct psci_operations { int (*affinity_info)(unsigned long target_affinity, unsigned long lowest_affinity_level); int (*migrate_info_type)(void); + enum psci_conduit conduit; }; extern struct psci_operations psci_ops;