From patchwork Fri Nov 8 18:49:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 178929 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3122944ilf; Fri, 8 Nov 2019 10:53:25 -0800 (PST) X-Google-Smtp-Source: APXvYqwIuTojZcPXmAaw/cP9DWvFrgeoF1UawD3/kSH4EIiawPmK67PEXJ5/U78nAmN4KPYSHYDL X-Received: by 2002:aa7:d499:: with SMTP id b25mr12046258edr.64.1573239205314; Fri, 08 Nov 2019 10:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573239205; cv=none; d=google.com; s=arc-20160816; b=llWXj5EDAXIZod7g+TsdV1o1m/wBWVni5f1Dylo0t+k4D4ShjOv8tEpufrL9xBAZzq ItYsAXcWlYBdqdMO8hcuplTrtFfw9qLJYqFLt7pnFlyrSlZY4ctcuZDCsVXK6xocXLlT SHc/+U6jgsYZTp0hiAznLLZmM96y39AaRFPnb0/Mqha4Pap0xLsJ/rNQoliG/l/Zjl7T zjJXrRZgR7GOoHBhoORRthLRasOqf2qBQSrFmf5V5JqjC9Ks7HT7mAt/v9yU5mmib5hW BTj8MpeV3s8g0zgXx9qF8lxRAsWBCPmcEk23CgaXYnjuD/bYZKMUZHiiZgwSO2WAyBjE aOeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mfR/rlp/NEM+swxuWpS4bY3bWzKmPznWF1/gb4vYD7k=; b=a4T47IxNKQk4i0HZqiO/MMgAl4V0NOiKPHNW/e6d5Oy27vetpEUWr9TpMiB+3QhRps QER5+qLFsOGUyuA6oQoFuNV1zL8++Ron1xyjAL7zeL/ZEpDNvk6YqqfK5MPYw4y0lhly hJecFToIDVLj5lBJ2HW9HHUaxycOD870E8+nWFBcCOrg3vwm7/w716xnY6H3bADt0Dxb 4MEJJAKB0Cjc73Kimn/2ANePPuczB5cgUKHMEK6c1uR/ZmzEKK7Wk47a339IPXrncWjW X27/rdtjDvWMQwJVxELZUFXnmEWobSpatfU/1U/yQ6EOaCHDvxJkHqHV1pDI+2AbETK7 cEGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QFpJYXS9; 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 t17si4617768ejg.44.2019.11.08.10.53.25; Fri, 08 Nov 2019 10:53:25 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=QFpJYXS9; 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 S1732304AbfKHSxY (ORCPT + 14 others); Fri, 8 Nov 2019 13:53:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:49990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732293AbfKHSxX (ORCPT ); Fri, 8 Nov 2019 13:53:23 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BE5E21924; Fri, 8 Nov 2019 18:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239202; bh=uzsmDvzuczXlA0AHuxY816KKdpnievb3gfSuNS9tpm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QFpJYXS9OzobqDbti3T9sPaW3iuKT1/kRG3gXv27CR1uHd5YVq2xZIYvgyrjUqDk3 B1HjTewpBfKPcFnhYsPRuC3KNp3/mXVUkzEo+DkWkAr8/9sJLSYiqp0/hvN4b8d5DL NlqyrCc7p20PXXsyb/MGKcGCKFbf+vxE1tMYqUb0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , Robin Murphy , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Greg Hackmann , Ard Biesheuvel , Mark Rutland Subject: [PATCH 4.4 33/75] firmware/psci: Expose PSCI conduit Date: Fri, 8 Nov 2019 19:49:50 +0100 Message-Id: <20191108174742.289495161@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174708.135680837@linuxfoundation.org> References: <20191108174708.135680837@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 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] Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/psci.c | 28 +++++++++++++++++++++++----- include/linux/psci.h | 7 +++++++ 2 files changed, 30 insertions(+), 5 deletions(-) --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -55,7 +55,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); @@ -206,6 +208,22 @@ static unsigned long psci_migrate_info_u 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; @@ -218,9 +236,9 @@ static int get_set_conduit_method(struct } 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; @@ -480,9 +498,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(); } --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -24,6 +24,12 @@ bool psci_tos_resident_on(int cpu); bool psci_power_state_loses_context(u32 state); bool psci_power_state_is_valid(u32 state); +enum psci_conduit { + PSCI_CONDUIT_NONE, + PSCI_CONDUIT_SMC, + PSCI_CONDUIT_HVC, +}; + struct psci_operations { int (*cpu_suspend)(u32 state, unsigned long entry_point); int (*cpu_off)(u32 state); @@ -32,6 +38,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;