From patchwork Fri Nov 8 12:35:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 178896 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2636452ilf; Fri, 8 Nov 2019 04:36:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyir5LSuC8f7L2lJjJy58vhMmuXgtbi6CZtD38sxqDnQTS9IWPKB0u2hG9TYjYzzJEF2Wn+ X-Received: by 2002:a17:906:386:: with SMTP id b6mr8330012eja.148.1573216590395; Fri, 08 Nov 2019 04:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573216590; cv=none; d=google.com; s=arc-20160816; b=L8yGUrVDJgwB4qitTkNvsnYnxwAikBpO50L0Fh3h7zMFqN7grK2Gk12NERy3CP/tY7 gxnxkkUA00Q6MT8Vx+m2k3WIrftRpJ1ODe5WlDa3P7F7Kzpnjw3QYOOheZPImqKr+Vax f4B0LUK3Tt722wwlLp9V47gddPYWVSEQaYmbrJQlOjbnbspyi7mSzd5k55/n3g7yz1wf aAEdW/CGVsioj1KvZdv/rIjgEVJpxAxca4awX8nJSCdboxUVtyUgQEtVa9rl2+SN5/Si ob243IMoEAAw/oYlSV8giTorVYWW32Pmoj1rSnU+cI+v8PfHISA2lNq7ofJqGE2WKJJA HXHA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Cd1pQJx2yWbUxhIZC3VadDc8DTgfKl5X9bZ8zV4FMr8=; b=vauUfD6LWwOqYdP4lOtO0KYiXA3KMxc0ZFIfRpDBtBVrmuKYAudB0qraT7w86//MOu uTgGxrb7AmDyJXWJPmxSIXxbR18g6PJX2e+iuEFVBUn1fp0/tswb5FVIpd4EI4gPkSEh sKSPuEMEk95HP2IIPnZvUmUrNQkmO9wELiqM+X7ost131oMO6ebibD0cWD/QzyuP7a8B 0BsudXxz1mwfvAuBdgLe9LjWN0SQspjkHTzTK0jNvEepatG8M4rZYsKSe/FQHJQKcJjz kcw1gqfXmiZdyNf4pte6kMT2xkAP5pp8cP17DOgwa+r7mgSWED1ozbLfeR81JC2DqRh2 alsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qUnpISO7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si3411305ejc.315.2019.11.08.04.36.30; Fri, 08 Nov 2019 04:36:30 -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=qUnpISO7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726959AbfKHMg3 (ORCPT + 14 others); Fri, 8 Nov 2019 07:36:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:44018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbfKHMg3 (ORCPT ); Fri, 8 Nov 2019 07:36:29 -0500 Received: from localhost.localdomain (lfbn-mar-1-550-151.w90-118.abo.wanadoo.fr [90.118.131.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 92F7E22459; Fri, 8 Nov 2019 12:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573216588; bh=inb/cqMT+oShP3jVH33yG8lEW3vWYc4DlUhG+Dmlb08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qUnpISO7D6Dm8xiLb+F+c385GkQ4ZfoyytCyFE/gbd9ZnSxuE3HvJhQGLtMgJgtKq i6+DYsrQh85MKBfOUygCJ+MKJ25C8JvD9wDnrMMuNmqjQkX6TipdNcMyRqAFv01sK4 uWpfzPC2Cujy6N+3KH74SYxjGB8k1GzAg+jsQ7q8= From: Ard Biesheuvel To: stable@vger.kernel.org Cc: linus.walleij@linaro.org, rmk+kernel@armlinux.org.uk, Mark Rutland , Ard Biesheuvel Subject: [PATCH for-stable-4.4 10/50] firmware/psci: Expose PSCI conduit Date: Fri, 8 Nov 2019 13:35:14 +0100 Message-Id: <20191108123554.29004-11-ardb@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191108123554.29004-1-ardb@kernel.org> References: <20191108123554.29004-1-ardb@kernel.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Rutland 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 --- drivers/firmware/psci.c | 28 ++++++++++++++++---- include/linux/psci.h | 7 +++++ 2 files changed, 30 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index b38305ba0965..eb5f9161ff10 100644 --- 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_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; @@ -218,9 +236,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; @@ -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(); } diff --git a/include/linux/psci.h b/include/linux/psci.h index 12c4865457ad..864cdede8d15 100644 --- 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;