From patchwork Thu Mar 1 12:54:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 130219 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2765756edc; Thu, 1 Mar 2018 05:01:01 -0800 (PST) X-Google-Smtp-Source: AG47ELuXIud6X1IgrrHNHq7ET00btz/o09UGquRXKB9SSD6aIPXsuagHM1HQQieGDcH3m4wODCJ8 X-Received: by 2002:a17:902:59d3:: with SMTP id d19-v6mr1856601plj.356.1519909261701; Thu, 01 Mar 2018 05:01:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909261; cv=none; d=google.com; s=arc-20160816; b=QQzuckZrrORp2uhbK0amcr47/gtAZCZl4IBWGERiacFxaE/lgNjhRvv3VT/hAC6PkV /fu0EQQRqafZoPJTiueirOgsmHdhXwVzhxJ7QrkUp0hfV2EqzKR3/tjuW9UN02GlCbjR N5KcDoGtjGq11sZDz8lsQAZbHynj13Bwa92AnVDRE14j8RTsQYAaVHBEZ9AhyLA/y/He LRCm08LrIiT84IODBM5P2uObsCCd1o/fSdmh5AIsS4if0LrheZCwpj4ZOhcCrdPrR8pb H6jHHbP4XhxTbLqVn16byxfnz2xJmy2r0QAfyeJ7e7lUuSz2CwcLsETztJCCjkoZ82re nGUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=HEY4UErd4E33sLr2mfE4fjyOkfyGVz0DVWFLdDXHqoI=; b=to++RE3UVRzX7YkjlXZWF3EzB1Mcs0jLPWZXz88HJk/Vm4PqfdBrpC6rmbyNGuqlge xMX1QvNJyg+jgHqDAWHIAqmS53TNIp0lqaaTd8V9PVqj915gzUvPK1dEgBAA/vkNJI9d 4vOmYi9UOEGjoHQjVzVu1sldx+1TyWBVPP/DQcohYAy3/+9UGzruoHXxzX53ArmzyMxv Isp4kIH7nX9bSAafrjeinwPYMWlLnB49mdjfy6gWoXu6iLvgi4BfE2Ip6qJopl1vZ+LK yVpH4APxltLV0kDRo6vLiH25gJ47cuJF1H9DBxq9/aUt18iofJu//kDjB3q8fNgGXN4s JTig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OsId/04A; 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 7-v6si3032649ple.721.2018.03.01.05.00.55; Thu, 01 Mar 2018 05:01:01 -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=OsId/04A; 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 S1031152AbeCANAw (ORCPT + 28 others); Thu, 1 Mar 2018 08:00:52 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43546 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030312AbeCANAu (ORCPT ); Thu, 1 Mar 2018 08:00:50 -0500 Received: by mail-pl0-f66.google.com with SMTP id f23-v6so3589240plr.10 for ; Thu, 01 Mar 2018 05:00:50 -0800 (PST) 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; bh=HEY4UErd4E33sLr2mfE4fjyOkfyGVz0DVWFLdDXHqoI=; b=OsId/04AGQ27DlnpR64S/j77k57uAdPQFgXDPf14JyXeFKZxkiVyT9nhHiNMcafSi1 tqOR7MQ7KrO67uAcXwK2E220CyikDhZezJnPbzDDiYq6S3ZmHqx05VINlQL5MvqILVQ9 8C42EuIgMKlqy2cMOnnnZ5KzgEtddRKOiNwsc= 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; bh=HEY4UErd4E33sLr2mfE4fjyOkfyGVz0DVWFLdDXHqoI=; b=XIwvfpjwTfxIErgydXs86/Q34+WQ6Y5QBRVAtAl6ZYodbj6agiMlEiBKtMaGDpM/85 D2oQ8KeRrZwenNTtOhvJ1xXDJFhIYIyhIsoz55fic17rV0Av2+FOJm6pGlvncQo+/9RU IetIbdY2fdH9n3RySrlGioECoXPqZhTWYGXrZVSrnp8ebW9SHDTuEVT/wnq6hnkeK5ac zxUMbejoDqsGgfXTmddm71apIP0BS7Yds+gUwSbMXgHwzDo9f7pxufNfoaQ/Hbsk0yzW g6bjiW4J09C4Lq3+jpmAU5Q3V0F4iO+mrpvSuEdH+q3v0M/3YMZCJ/6UpPKIzICtFYGa fViA== X-Gm-Message-State: APf1xPBHwGhFZXTRNlfhwD0cGHjFkG1Mb1B5QT/j5Jv0xjBQtLFuEq+U A7GzRsb2iNo2gHeUrq5TC/lSaw== X-Received: by 2002:a17:902:27:: with SMTP id 36-v6mr1885686pla.128.1519909249536; Thu, 01 Mar 2018 05:00:49 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.05.00.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 05:00:49 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 41/45] firmware/psci: Expose SMCCC version through psci_ops Date: Thu, 1 Mar 2018 20:54:18 +0800 Message-Id: <1519908862-11425-42-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit e78eef554a91 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 Signed-off-by: Will Deacon Signed-off-by: Alex Shi --- drivers/firmware/psci.c | 27 +++++++++++++++++++++++++++ include/linux/psci.h | 6 ++++++ 2 files changed, 33 insertions(+) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index a49196a..79a48c3 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,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"); @@ -559,6 +585,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 66ff547..347077c 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;