Received: by 10.223.176.5 with SMTP id f5csp2678153wra; Thu, 1 Feb 2018 04:26:45 -0800 (PST) X-Google-Smtp-Source: AH8x226K9uGcoCFAX6vkhb5LMpBol3s0CzED6o6HmdEDfp7Bk+yjmg652WMDRMDSUjFW5tUhPtcj X-Received: by 2002:a17:902:9895:: with SMTP id s21-v6mr31449548plp.297.1517488005121; Thu, 01 Feb 2018 04:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517488005; cv=none; d=google.com; s=arc-20160816; b=KrSpjCVPZ87HqepAjgXNCelPsXAvaky/0k7xvZ9tCAtnaoZaAsTK+bdrunzByYW4ex U6pjOu4jasgRz1KMAuZml5kD/1q3IaoUF2MBRvVSOW87UPj7QEnnSBg/71QqnodKrTf+ aDriM3SIMR/oUqvI6I1+xszlU0Z70evfXTavxHHQ/PzYAQirbi8NwDoAySOuRx3PdE12 Sdcudrz0X9US1E3RynOaXyzN50FX0glR/2oYyhsn819slo+9Skn93+YZS9wdJNT6QWKL Ua4/fZ/6Pge50dTK0MK6CJCQC+Kvxb0atfmZnSvKWlWuFAgpdTyuUjYCnBGvRoVOTPLU qXtQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=xq08L20llplsjiNrtuEZdWoKx7EgExuJ6VSaFEP+YAU=; b=EcVU+msmQUI8pOqOgxixvGZ6IQixy2ocH/FApgqeuoYDmJXhfvV1R/FxvD71Mh0azB JE/QGkF7DQSptS+CHjd0YJvvKBNc68QFbOuaVetBEX22ixlx1Q/qxjbjDijbcPmOxxFp PwPg06BKvee77+H9QRZbGr3oAqRDvix5BGM/PCEKPY8n287LHaLXVbFy95wEsTvXb+ax shnW+Yue1IpCRodHejAIHfeAdxigoKHM1681EM9lIo3Fbtjjgpmjlq9XEYliLB5VjfCK Y1zxW9qEZcVb4SGhQb2fn9ZMladz8hITFpMlbOD/5eRRxm8aT5IBGPG4TWMkiBnlk9Hz lNNg== 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 h20si6409488pfh.395.2018.02.01.04.26.30; Thu, 01 Feb 2018 04:26:45 -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 S1752538AbeBAMZH (ORCPT + 99 others); Thu, 1 Feb 2018 07:25:07 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49366 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752189AbeBAMZG (ORCPT ); Thu, 1 Feb 2018 07:25:06 -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 31C2180D; Thu, 1 Feb 2018 04:25:06 -0800 (PST) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7C2AF3F25C; Thu, 1 Feb 2018 04:25:03 -0800 (PST) Subject: Re: [PATCH v3 13/18] firmware/psci: Expose PSCI conduit To: Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: Catalin Marinas , Will Deacon , Peter Maydell , Christoffer Dall , Lorenzo Pieralisi , Mark Rutland , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux References: <20180201114657.7323-1-marc.zyngier@arm.com> <20180201114657.7323-14-marc.zyngier@arm.com> From: Robin Murphy Message-ID: <434a53f3-0109-8a5f-414b-0f697bc153d6@arm.com> Date: Thu, 1 Feb 2018 12:25:01 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180201114657.7323-14-marc.zyngier@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/02/18 11:46, 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. Reviewed-by: Robin Murphy > Acked-by: Lorenzo Pieralisi > Signed-off-by: Marc Zyngier > --- > drivers/firmware/psci.c | 28 +++++++++++++++++++++++----- > include/linux/psci.h | 7 +++++++ > 2 files changed, 30 insertions(+), 5 deletions(-) > > 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; >