From patchwork Thu Apr 12 11:11:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 133232 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1572685ljb; Thu, 12 Apr 2018 04:13:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+LWA+tZktoKTOG7hkWEJVw2uokGMxvSImSEeYSMyYNvvV/ZPOM0I2ew9b06rtJJW1XqTw2 X-Received: by 2002:a17:902:b2c7:: with SMTP id x7-v6mr568635plw.124.1523531628576; Thu, 12 Apr 2018 04:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531628; cv=none; d=google.com; s=arc-20160816; b=tnlPNEt2cYly6qgnsUKyHIR4wNDHm8VB1XV0WWZYNxmBeh6Rj+cXDSIlb5SF83NWYX 3igxm/rwiNJwpKCxZrEtuc1NZmHEPhR7sVdc0XcU39Pc3YcNdT+/PMgSXcJPreGK/92y Jn2CxMnqSLS4g5Gtm1Q0RefQ/P2c7igQ9+ilFELe0HX6ZPSGvY5De8KSGMV2jOTSk6wq wVdYpVd6xtfdzdVozwjyqRJ+9El0ufvL2mBiTaNJI8JWvlHQruBF8b9hYQXtKfOPcUF3 bnDmVBIUlyNuI4xHW5FDoyNsXS1HXgM8nLksTfv87fPqs0RFxZSPLJHiqVW4TqzQG7nY tCSQ== 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:arc-authentication-results; bh=4aOdzKGELvIbhTahzDKrXqcD9+Oa7SgwUVzaBtKRhcM=; b=Gu79Ie1H6mAnV8xibE8UG38rRgwyYWjYY4WWIOlDoxcto2HuU3KEsPYnaJ5pbR1FwC F7+HYMcE8q17KfMCNizWZo/2W3qaQ/ExBx8Zb/9fWDtFjGUsIzpE9clJvV/NIkP6ecJo jwG6ootbLYt43MB5l0wKdipyPuZNOmlaO07IuyekRnhXPDo/pcRtn3kbPZ5DbAErJjTG zuJ564xVutfZktPBxiHmtetTMAnctCcZa0gYH0/3jHTbwxANHf954e6FdjQD+4fB8Ejd DzXY5YXAqwKVYTYJWQ/kh+E6GihBMYhTDFOWWRFg8KB+s5R2YRkSPObRFGeB178IaiRc eD7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v23si2494850pfk.116.2018.04.12.04.13.48; Thu, 12 Apr 2018 04:13:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752972AbeDLLNr (ORCPT + 11 others); Thu, 12 Apr 2018 07:13:47 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59654 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752813AbeDLLNr (ORCPT ); Thu, 12 Apr 2018 07:13:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0BADB80D; Thu, 12 Apr 2018 04:13:47 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 53E1B3F24A; Thu, 12 Apr 2018 04:13:45 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, ghackmann@google.com, shankerd@codeaurora.org Subject: [PATCH v4.9.y 37/42] firmware/psci: Expose PSCI conduit Date: Thu, 12 Apr 2018 12:11:33 +0100 Message-Id: <20180412111138.40990-38-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180412111138.40990-1-mark.rutland@arm.com> References: <20180412111138.40990-1-mark.rutland@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 09a8d6d48499f93e2abde691f5800081cd858726 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: Mark Rutland [v4.9 backport] --- drivers/firmware/psci.c | 28 +++++++++++++++++++++++----- include/linux/psci.h | 7 +++++++ 2 files changed, 30 insertions(+), 5 deletions(-) -- 2.11.0 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 9a3ce76304b6..a49196ae0840 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 6306ab10af18..66ff54787d3e 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;