From patchwork Mon Feb 26 08:20:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 129593 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3359067lja; Mon, 26 Feb 2018 00:26:41 -0800 (PST) X-Google-Smtp-Source: AH8x227NlVOD9fB8QSGp2+Qa9+xlM47Iz94CwMZFY/eJXjEM6fDZoXqzeIAwkXesFOIHBU6DY3xk X-Received: by 2002:a17:902:aa5:: with SMTP id 34-v6mr9997049plp.429.1519633601001; Mon, 26 Feb 2018 00:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633600; cv=none; d=google.com; s=arc-20160816; b=LrIIa7EFEazazbIzPhaCT/341mR6wCKdqKzfc28xSSu7iR6EWL/dGesBf8AOMHygyv hXpqJepXUUAnMKQ6/icrZQveSyRfCJOA1EYJ9of+6xwu5mFnAcIR5UvC2ziJzbGJ5ix1 x6JjoBNlt5LVnaUTan/e7LZWItK7jrntlWQXz1YxIn2lX7yIF4dUoSRAykDpI2f1mhpT seIu4G5CUSebVOB8MHKjYyPr/7dqjnzth3aZ4d77xZOSQe6yFEw7o0aUYeiOZGzwPEco Asl3djP9zNpvXzZ3z8dq/fUaEDvcGVM8/O1rkHj71AhGI0ul7tk0UCErZjAELXuNUoCe Cn2Q== 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:to:from:dkim-signature:arc-authentication-results; bh=HEY4UErd4E33sLr2mfE4fjyOkfyGVz0DVWFLdDXHqoI=; b=j1BnvQ0hBytA/2nSeRonzFBlZKHBS/29gQNxhNpVw2DIdrKuHj06ZQgHdOE86z8TF5 MYjbs8eH1WLwpo90Pqaq/GCSDdVs0AvcMNVePkaRW/Q6uO4VLr7FR3fISSaqa2t6qpzM Oc1eOUVHdeSH1X+5HoMQ+SaIrIUKpMS58Sx/d3mUafl/xfHQSOZkIFEeGJfKqyeSM58A bDZ1EpZt+X5MrVy8zu9GyttxB7oleRboCz7NTPVIX23e2XbwRFy8ErAmwvycFI1sASbu Nu216CDn4wDIjvdF5EAJKaSuD19fDPzCv9t/JBM/9wRjoykFxEUxOQmXTQFfdD8aNYUF ZJog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OLo4f6AI; 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 a22-v6si5233862plm.773.2018.02.26.00.26.40; Mon, 26 Feb 2018 00:26:40 -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=OLo4f6AI; 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 S1752759AbeBZI0h (ORCPT + 28 others); Mon, 26 Feb 2018 03:26:37 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35366 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752749AbeBZI0a (ORCPT ); Mon, 26 Feb 2018 03:26:30 -0500 Received: by mail-pf0-f194.google.com with SMTP id y186so5539910pfb.2 for ; Mon, 26 Feb 2018 00:26:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=HEY4UErd4E33sLr2mfE4fjyOkfyGVz0DVWFLdDXHqoI=; b=OLo4f6AIJid1kE3t0Y+Wej9HWk22PABGTv5XIJNAZqU98RIJgtNa4CYF2c+HNsNzJB qlrchuxEBU/QJp/6Wz3X/2DXKcq3CRBo1yLgGQsk5dbMvQs7UEYPyAC/YV3N9GNBCqIX IeDWsDSrvhWJIHrywoQVodGECoLJCawx/zu5s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HEY4UErd4E33sLr2mfE4fjyOkfyGVz0DVWFLdDXHqoI=; b=b4wQjNnCWfENtHtumiE11DIpAot4z96rzklak3oZ67V3KBvHrsNTG7Lvk0tND8zF/r rNfSObb6tk/zp0uOAtCjS39+KIOtr9tDnzIt7qCuYPjsi9x9norEq9o3Nz9D9DhbtSX5 1xvtnB6hUSIo+wyrTPCv9XiItNMxJIl4gQa9T/SbvO1+oecZECOFDhPQPXq3xM6Pzb7P Ln7Rh8Ewt9Ly7x0yEa7iqhOFAwo+YFku31MCw2+nA9dzluMbVUdYkTCerjb6umRAtnZW KrdC95TJ9pQ6o842HaqqdwtTClf/iBouhjr/A90dRDIoX6ZNRQRvb1j3536L3dyjU3FY 1O7g== X-Gm-Message-State: APf1xPAyc6UZ7/J3thmn/jlwTkmuwDRsI9irc6P7LSpa4HI9FrzxkuhR XRvGUjcDELnUqFwUgsSnpCy5IA== X-Received: by 10.99.150.2 with SMTP id c2mr7979547pge.424.1519633589367; Mon, 26 Feb 2018 00:26:29 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.26.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:26:28 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, Mark Rutland , Lorenzo Pieralisi , linux-arm-kernel@lists.infradead.org (open list:POWER STATE COORDINATION INTERFACE (PSCI)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 41/52] firmware/psci: Expose SMCCC version through psci_ops Date: Mon, 26 Feb 2018 16:20:15 +0800 Message-Id: <1519633227-29832-42-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-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;