Received: by 10.223.176.5 with SMTP id f5csp3179214wra; Mon, 29 Jan 2018 09:56:09 -0800 (PST) X-Google-Smtp-Source: AH8x224Vf5nALMLFX/0N0XOMAcykRNsZI7jVCgW5fL1UUzJ+vLZPbT9+gvw4YNZSkmKzII5pg6PY X-Received: by 10.101.64.74 with SMTP id h10mr21200233pgp.200.1517248569351; Mon, 29 Jan 2018 09:56:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517248569; cv=none; d=google.com; s=arc-20160816; b=Fe/nM55iH2cXtw95dRa0vDZrllrFmiafvwkj+jMDd5xzps/VuMzw9wWu4+3V2Hcjyp uGV6YeufpqwbhL5JFtEvU1fEyc9gwbzgyjfg4QYYZ8PNeMeQ71DaPQJdzdtgxEc2aDOE xxNxbx3XtR11LLBtkMrOyGxmRwg1GlfhVetTnr1eRK5HqBNAzPZdKWD3CYvjneH01kVm ozyUopyUaiqgX8d/YtNSXtqhc2B9Xu2smd68UPxb4ScZpdlBTqqas2voYhaEXEv13Be5 iR92aZf+QPdZcqIrup/Hg8UWgBiJLMp9IK1AiUqMNKOnVPGYPYwl9aLOKWOh8Aq106HO 27Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=6gtLtusOEmc4KM0cQ0u5a6AHvb1tB36mUFb2bESo/lw=; b=yXC5c+SamLgVGhL4uEfFR/+mmpQ+7+wG8DRJWb6ZoSEFhYWwvH+fFqC6JJ/1FHOFuF Vs1fg+9dD/foRu0GNsd98nbg6BXYQlAWY1zwlukhti2J/xIqQS/bCD5JFWEJfdIKhuIL RdeLn0Ae47kCLSpLQ2lWM8/VHIH4UHocGd9aDWjtxE7Fif4t3q36b4DOtz0hBhk3XL41 /FBpSxfYqreMAuMB0VN4AmSmOliWl6Ix1p4GHvjs66UxH/KR6o0zth3TawpuoRC4q+PF 3WfcR/pVZjCHNYophwGUF8bNDYQiWa2G/xMGVSx9PFXc9WTy87SSpYEo6G06JTGR2Qgb MZ8g== 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 b6-v6si1826308pls.65.2018.01.29.09.55.54; Mon, 29 Jan 2018 09:56:09 -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; 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 S1751485AbeA2Rzb (ORCPT + 99 others); Mon, 29 Jan 2018 12:55:31 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43986 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751262AbeA2Rza (ORCPT ); Mon, 29 Jan 2018 12:55:30 -0500 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 6849F15AB; Mon, 29 Jan 2018 09:55:30 -0800 (PST) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.207.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 543B73F487; Mon, 29 Jan 2018 09:55:28 -0800 (PST) Date: Mon, 29 Jan 2018 17:55:23 +0000 From: Lorenzo Pieralisi To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Catalin Marinas , Will Deacon , Peter Maydell , Christoffer Dall , Mark Rutland , Robin Murphy , Ard Biesheuvel , Jon Masters Subject: Re: [PATCH v2 12/16] firmware/psci: Expose PSCI conduit Message-ID: <20180129175523.GA24577@e107981-ln.cambridge.arm.com> References: <20180129174559.1866-1-marc.zyngier@arm.com> <20180129174559.1866-13-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180129174559.1866-13-marc.zyngier@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 29, 2018 at 05:45:55PM +0000, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier > --- > drivers/firmware/psci.c | 28 +++++++++++++++++++++++----- > include/linux/psci.h | 7 +++++++ > 2 files changed, 30 insertions(+), 5 deletions(-) Acked-by: Lorenzo Pieralisi > diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c > index 8b25d31e8401..e9493da2b111 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 f724fd8c78e8..f2679e5faa4f 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; > -- > 2.14.2 >