From patchwork Thu Aug 29 11:34:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 172616 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2092769ily; Thu, 29 Aug 2019 04:36:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyInW+JpQL9JF7H6SnnaeT9usjp+z3N5+Kb/UZUJ9jFhNV/22UNiXb1ai4AUIMie2SdxPf7 X-Received: by 2002:a17:902:1a4:: with SMTP id b33mr9187303plb.141.1567078597968; Thu, 29 Aug 2019 04:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567078597; cv=none; d=google.com; s=arc-20160816; b=sGFpOtIkLDhBVnvQM+hmevUCjpB5JYjRd0GwTUpUvda7o+iMrAgP90ONVoEyLrmQre QZQkKuqSbeGAJn/71APWtqTAZ7cyD0R9WKj9DXWOEP6Wy35ggnUMuzskkNSE292R4B4E TVee4GDjV/WWFR6nk/tGsNVE2n5OK2cuwVh89Ub4EK4KCFweB32Lk2uB42W857V0B4uH quPdR/EdIybUvyPD0WWhAeoE9E2t6jaofN3jArFxTADkBOdpo+8TZCAFY2X4j124VYgO KvCLMJAlLHreLr8QM3v8d9t5ZCBSr4/qtJ0ek8Eofsdcrtiyq+5dckquRdUBORwqJnqJ WJDg== 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=8FgYZ0lVoh76yEFRGdkiTuXxRHgDjc15a9Db0UAG0RM=; b=Z8T6x2mXZyDmUMaa4M+cJeLJfv0HuVEKS37c9NIJsLEZhO47FwvO4bX+pHuXDsrOSD MkdK7JecATISgiS0Bmv5Hs5KFG67xUBb09Dg/jF1QLwovpZ5zTRT+hyN6h1C22J7Ug1z 5Sesffbu9G0nraejvi2MIs2vmCuKEBAQukSa5OebSuCR8WvF4Gnx9aZDCoaTIUNur7/P iHcABdv6533DQm+zL9g1a7njeuUn4hOw00wD2zIZVwMY97l77+Wv6xS6xZ4je/F+mjHX SZ+f3H+QzurgKvuc6s2zLc2SSp1aOoefBLBzBPFe6MZWuC4FD62vZ3U2IR4ZphmQk+wY uo1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UeOn1W6g; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c67si2276378pfb.211.2019.08.29.04.36.37; Thu, 29 Aug 2019 04:36:37 -0700 (PDT) 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=@linaro.org header.s=google header.b=UeOn1W6g; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727600AbfH2Lgh (ORCPT + 14 others); Thu, 29 Aug 2019 07:36:37 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36392 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727066AbfH2Lgh (ORCPT ); Thu, 29 Aug 2019 07:36:37 -0400 Received: by mail-pf1-f193.google.com with SMTP id w2so1874231pfi.3 for ; Thu, 29 Aug 2019 04:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8FgYZ0lVoh76yEFRGdkiTuXxRHgDjc15a9Db0UAG0RM=; b=UeOn1W6gwCyzjiugPXX9SymT/iYCvcguyV59792moJTQ0odoPIXAPUDBRV5S7/ZGnz 5LmJ2aoVZ/BH5zX3UM7Ot5Lvj1GLHlfSQJ6y85yEiGvj8gY4+jMYcqFv3DdEcGOHmy14 XlJiiVT+m8VhZHrXTyIxObNjygZVYGrCro+uaz9h1Nw4FZwmGpU8iQO2yRB4vS67itrA odn9Yw5LwC5AG45CtUY5g1U0UpM09fMOAWj5qZnweKbY1hvLI/B9FIRY/TO4GRichLyn ttyQVfv0rgHThUXWTw2ZKzW4Eesi+LQpVES7ypKaKBsu99fp3xAjjtmXwy27fSV2A7co wkVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8FgYZ0lVoh76yEFRGdkiTuXxRHgDjc15a9Db0UAG0RM=; b=sZpowqV5ZT9aiPkt96GZyzqSBtry2e1SLSpZ2R7dgAsqsZ6JFAsJotax6NzLy3E5FO 9tkZfHuaonwNsS0EeC+yiEbdxXmG3hUkZl+6CFa8I86sPC7bQ2tBNNtQGh0jNRl/gXBv xabU6RBua+uFdaB1Ln3Om2NIgnKACpXefRpKYrJELs3jaj60lIyE/1IJP9mFePx34ig3 nXBb7xAU0+HunrF0CbMIyC4uNsu4UncWx708kxndmz+/ndt4EfTYoAi/JmVpY8/IYuNP raD8QzH+YuBwCZ1ffnRVX0uoa4VGbZZAxyD9KLkUGxfZ5E2PQL5avzebwa26J3VL9Pnk sufA== X-Gm-Message-State: APjAAAV6H6QOJ9V8uy34Ex5WCJTT8WaD8/4kloQDFeGjYyYWifkaTFAv JA2Qc0PjDpgX6qboToPj91rzjE/6pxk= X-Received: by 2002:a65:5144:: with SMTP id g4mr7940524pgq.202.1567078596132; Thu, 29 Aug 2019 04:36:36 -0700 (PDT) Received: from localhost ([122.167.132.221]) by smtp.gmail.com with ESMTPSA id m145sm2667406pfd.68.2019.08.29.04.36.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 04:36:35 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org, Julien Thierry , Mark Rutland Cc: Viresh Kumar , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Marc Zyngier , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com Subject: [PATCH ARM64 v4.4 V3 39/44] firmware/psci: Expose SMCCC version through psci_ops Date: Thu, 29 Aug 2019 17:04:24 +0530 Message-Id: <0e4f990741cd3607fbdf1fc46dc7f47c598b199a.1567077734.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit e78eef554a912ef6c1e0bbf97619dafbeae3339f upstream. 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 Reviewed-by: Robin Murphy Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas [ v4.4: Included arm-smccc.h ] Signed-off-by: Viresh Kumar --- drivers/firmware/psci.c | 28 ++++++++++++++++++++++++++++ include/linux/psci.h | 6 ++++++ 2 files changed, 34 insertions(+) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 7b2665f6b38d..0809a48e8089 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -13,6 +13,7 @@ #define pr_fmt(fmt) "psci: " fmt +#include #include #include #include @@ -56,6 +57,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, @@ -320,6 +322,31 @@ 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(void) +{ + u32 ver = ARM_SMCCC_VERSION_1_0; + int feature; + + feature = psci_features(ARM_SMCCC_VERSION_FUNC_ID); + + if (feature != PSCI_RET_NOT_SUPPORTED) { + u32 ret; + ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); + if (ret == ARM_SMCCC_VERSION_1_1) { + psci_ops.smccc_version = SMCCC_VERSION_1_1; + ver = ret; + } + } + + /* + * Conveniently, the SMCCC and PSCI versions are encoded the + * same way. No, this isn't accidental. + */ + pr_info("SMC Calling Convention v%d.%d\n", + PSCI_VERSION_MAJOR(ver), PSCI_VERSION_MINOR(ver)); + +} + static void __init psci_0_2_set_functions(void) { pr_info("Using standard PSCI v0.2 function IDs\n"); @@ -368,6 +395,7 @@ static int __init psci_probe(void) psci_init_migrate(); if (PSCI_VERSION_MAJOR(ver) >= 1) { + psci_init_smccc(); psci_init_cpu_suspend(); psci_init_system_suspend(); } diff --git a/include/linux/psci.h b/include/linux/psci.h index e071a1b8ddb5..e5c3277bfd78 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -30,6 +30,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); @@ -40,6 +45,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;