Received: by 10.223.176.5 with SMTP id f5csp3250369wra; Thu, 1 Feb 2018 13:19:43 -0800 (PST) X-Google-Smtp-Source: AH8x227rLB5ugjkVnylrJMMHscymBKWO6dbTsuHxbcwveln21JakxB13lBvzgV8voJ/sbuQ/XyiF X-Received: by 10.99.117.74 with SMTP id f10mr29439843pgn.385.1517519983073; Thu, 01 Feb 2018 13:19:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517519983; cv=none; d=google.com; s=arc-20160816; b=WQTHbbCC6uFlBcSxklPOeKzQtcUh+egYZzCQU50v4w20Iyk/KMIZrMgrwzqu7BbNPX xytLNEOu3kFBNnLNuut5fv9sJx5Ttnpw4D9y8zrXSSRzF7y5z8djE71YgXx5AIIkXh33 0MFuOzoLg2h2Fkv75QlihtaSmeIZIwjsyF698cY/stOzO9a9o8XjTYru0549UUbLIRAm R0hx4MvB+12YgHKaXP+EI5/GHJnsqIHxLEMzj5Ejt7mzQTv7FhMUZlg6RP9xm+D+ZcQQ SZPqkddY2DbqlHrdc6qBYOHC+IHVTpnPFL6cYKHsv/4s08NDDn3PgXsjodZTtLLGh2mb yWrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=U3eQyA5xa9S44dyYRI8G9kBQjgFjQLHvlZcvf/5IDXY=; b=Xst5JXduD5zlDqDcbVr+rsJA+g0mBJFg8zTcynzLbwTEruVstyzPkU5hzB7aeDZrRh P57CzfA6jXiBTJ7QPlDvv1k7Uk9EIfC9i9qaBI0nXaTDRxAAg47AQBuTVwtWIAgSNtAA 44hHC6lIHXJgpIOkFjCj4LhfZBPv7F6K9JZdFbob1yuMmi/5QQSMniUORE4XaYHz6qiG wQ7g80lW6Cu3pN2kVam2DevX8TJ6CDBeIe5uv1tu5M9K0ORlxMn+xvvCfZsX4ivCWLN+ s+kQfyU9e/ZKrWVkBYgqx3fNVe9nEQuiQxy7bFroepmQiqfMVsjiTz9cLUa90pTXdADr EHjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N3b8XyJH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20-v6si379239plr.660.2018.02.01.13.19.27; Thu, 01 Feb 2018 13:19:43 -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; dkim=pass header.i=@linaro.org header.s=google header.b=N3b8XyJH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751936AbeBAVRc (ORCPT + 99 others); Thu, 1 Feb 2018 16:17:32 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:55456 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751710AbeBAVR1 (ORCPT ); Thu, 1 Feb 2018 16:17:27 -0500 Received: by mail-it0-f66.google.com with SMTP id c16so5956994itc.5 for ; Thu, 01 Feb 2018 13:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=U3eQyA5xa9S44dyYRI8G9kBQjgFjQLHvlZcvf/5IDXY=; b=N3b8XyJH40O6gXNJ+34UZeBfMx/5M8l6U+evBfWgiWdkybaRsq8J+9POxS27gTH9X+ dvH0wkoazu1zlT7vue3C/jythFyhEhaWSBGTWVRSJkCEl4ZxxZd17hCqOqR5LEtt93yE DhV+QRCriIeHBWbJg3ugGZrNSrW8/cgsBb1OY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=U3eQyA5xa9S44dyYRI8G9kBQjgFjQLHvlZcvf/5IDXY=; b=q5rKwKdwIw8dsdfICBDThtQ/4fuYDq8fkY8bGDLlR+jIJqaHV7RMrM99Ku0SX5FTkV 2l9jExKNrrSZkVSxe29mzzhebUNevkchxrmGuDST4EbMfymwSYAqWDALQWbH+MaaJdMb A9isRLKAzYjBY10P7Ma7V2SGZam7hYlwZ4sTv+0rxzWyAcq6ByKSW/UgrEFaSwvBIgZL 0OfG8dYa0LPySyBaJd7EX7nr3B+nbQ36LWU5BeMv1Mt9tkt3Ox78y1Kgsd8q7TUrqC2F UpH/mxCedYA2L6RwePvFoDP1L2UtZOyYGfU76GX7QObrHnj65zp0c5bAIuB8PsprEEB+ MCMA== X-Gm-Message-State: AKwxytcmvsvswSQVd1ueDLF6M7ln5kuu0+dGIy08KETRgq97njh3oOxA qASFq00PiaRLF5uzrmZxHwHjtFfEqqVP56jBws3JnTNJWMI= X-Received: by 10.36.39.215 with SMTP id g206mr40090100ita.17.1517519846315; Thu, 01 Feb 2018 13:17:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.112.13 with HTTP; Thu, 1 Feb 2018 13:17:25 -0800 (PST) In-Reply-To: <20180201114657.7323-15-marc.zyngier@arm.com> References: <20180201114657.7323-1-marc.zyngier@arm.com> <20180201114657.7323-15-marc.zyngier@arm.com> From: Ard Biesheuvel Date: Thu, 1 Feb 2018 21:17:25 +0000 Message-ID: Subject: Re: [PATCH v3 14/18] firmware/psci: Expose SMCCC version through psci_ops To: Marc Zyngier Cc: Linux Kernel Mailing List , linux-arm-kernel , kvmarm , Catalin Marinas , Will Deacon , Peter Maydell , Christoffer Dall , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux 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 On 1 February 2018 at 11:46, Marc Zyngier wrote: > Since PSCI 1.0 allows the SMCCC version to be (indirectly) probed, > let's do that at boot time, and expose the version of the calling > convention as part of the psci_ops structure. > > Acked-by: Lorenzo Pieralisi > Signed-off-by: Marc Zyngier > --- > drivers/firmware/psci.c | 19 +++++++++++++++++++ > include/linux/psci.h | 6 ++++++ > 2 files changed, 25 insertions(+) > > diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c > index e9493da2b111..8631906c414c 100644 > --- a/drivers/firmware/psci.c > +++ b/drivers/firmware/psci.c > @@ -61,6 +61,7 @@ bool psci_tos_resident_on(int cpu) > > struct psci_operations psci_ops = { > .conduit = PSCI_CONDUIT_NONE, > + .smccc_version = SMCCC_VERSION_1_0, > }; > > typedef unsigned long (psci_fn)(unsigned long, unsigned long, > @@ -511,6 +512,23 @@ static void __init psci_init_migrate(void) > pr_info("Trusted OS resident on physical CPU 0x%lx\n", cpuid); > } > > +static void __init psci_init_smccc(u32 ver) > +{ > + int feature; > + > + feature = psci_features(ARM_SMCCC_VERSION_FUNC_ID); > + > + if (feature != PSCI_RET_NOT_SUPPORTED) { > + ver = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); > + if (ver != ARM_SMCCC_VERSION_1_1) > + psci_ops.smccc_version = SMCCC_VERSION_1_0; > + else > + psci_ops.smccc_version = SMCCC_VERSION_1_1; > + } > + > + pr_info("SMC Calling Convention v1.%d\n", psci_ops.smccc_version); This is a bit nasty: you are returning the numeric value of the enum as the minor number, and hardcoding the major version number as 1, while the return value of ARM_SMCCC_VERSION_FUNC_ID gives you the exact numbers. I assume nobody is expecting SMCCC v2.3 anytime soon, but it would still be a lot nicer to simply decode the value of 'ver' (and make it default to ARM_SMCCC_VERSION_1_0 if the PSCI feature call fails) > +} > + > static void __init psci_0_2_set_functions(void) > { > pr_info("Using standard PSCI v0.2 function IDs\n"); > @@ -559,6 +577,7 @@ static int __init psci_probe(void) > psci_init_migrate(); > > if (PSCI_VERSION_MAJOR(ver) >= 1) { > + psci_init_smccc(ver); > psci_init_cpu_suspend(); > psci_init_system_suspend(); > } > diff --git a/include/linux/psci.h b/include/linux/psci.h > index f2679e5faa4f..8b1b3b5935ab 100644 > --- a/include/linux/psci.h > +++ b/include/linux/psci.h > @@ -31,6 +31,11 @@ enum psci_conduit { > PSCI_CONDUIT_HVC, > }; > > +enum smccc_version { > + SMCCC_VERSION_1_0, > + SMCCC_VERSION_1_1, > +}; > + > struct psci_operations { > u32 (*get_version)(void); > int (*cpu_suspend)(u32 state, unsigned long entry_point); > @@ -41,6 +46,7 @@ struct psci_operations { > unsigned long lowest_affinity_level); > int (*migrate_info_type)(void); > enum psci_conduit conduit; > + enum smccc_version smccc_version; > }; > > extern struct psci_operations psci_ops; > -- > 2.14.2 >