Received: by 10.192.165.156 with SMTP id m28csp244146imm; Tue, 17 Apr 2018 09:24:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx48iN7g0SFASF2apbtGwwigyTfpL1OWCKqJ7gdTKe1pFdX8xrASdYYH46wvMQkppWyYAbb9k X-Received: by 2002:a17:902:b212:: with SMTP id t18-v6mr2607051plr.137.1523982275276; Tue, 17 Apr 2018 09:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982275; cv=none; d=google.com; s=arc-20160816; b=RgSrKV2cnWp7e8nVSx+0GoEVAbsNkKQMvS09EUO/xE7VV5dutoR0c3mLQ2wIp0j3cs /yJN+QIzSI4mU8z9QJ2PdiF6dDnuYx1RrjPzaHYGErDqiNG0ZwtlQDrLhpbPG3vQ+2Na DiruxhK3Z6SHaolFIRyY/XFbDt+W24kAtsGH62blGRoedLaEEprHaPfnTGySvFouJmUn 77GIBUiP8BGhqeUmerIq90kqnRHuF0nJ5u2rKsS0ddxOBmyZLrBvJafT28LAkqnk+WhQ LeTznaHWxLb6sJKi0caKJ4t9GvxvMEFIDQbkz8LVzd43mCrFGKMWoN+3I8QxxQ8DZRLr ZJfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+7sDUBiUD7ST5ztSGAxtuj4l6tJDlbwPbyLmw4a13xk=; b=uJaTDHJwCtfC53MFWE8TLGiGPdT/LO6qV0lOSDVPTdhYEgST03PbZ7lIQSeD4hK02N FRkoCTWACLNi3hjaW26++hS58Eh5gR+CsuoE4jQ/FGQFnMEeILkRLckZP3WMcycjjSWj BhGpK1WeKTIi/6SC9Yd/P3dk8CPj0DA7QfVA9H9w8cpGzyINw+FcKHmNkYSXVT9fJp3N C+fBStuLpXsel3G2Fmslb6GxTLPaWtWVjtIUrtqKZe21ZjWJqGKRjF60EobjUngP/L4d oEQuqTPNxvwquIRi40oz+/fDaBoHMyQgSQ/QTgcgSnUR6tbF9pb4Uc+ZWt7f2ssfENq9 9WHg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a73si13252350pfe.23.2018.04.17.09.24.21; Tue, 17 Apr 2018 09:24:35 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755666AbeDQQJp (ORCPT + 99 others); Tue, 17 Apr 2018 12:09:45 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36182 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753931AbeDQQJn (ORCPT ); Tue, 17 Apr 2018 12:09:43 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3C71DBC4; Tue, 17 Apr 2018 16:09:42 +0000 (UTC) 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 , Mark Rutland Subject: [PATCH 4.9 45/66] firmware/psci: Expose PSCI conduit Date: Tue, 17 Apr 2018 17:59:18 +0200 Message-Id: <20180417155647.836926132@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ 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 --- 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 @@ -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_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; @@ -222,9 +240,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; @@ -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(); } --- 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;