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: 10241603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 99F8160386 for ; Mon, 26 Feb 2018 08:41:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8899929D2C for ; Mon, 26 Feb 2018 08:41:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D13229D66; Mon, 26 Feb 2018 08:41:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0C17529D5E for ; Mon, 26 Feb 2018 08:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+IEhP/Vpq9bLhyr+b28eAjKM0nK/5RZuaNttMv8tp2U=; b=aLiSOHUtTgfm+x WgGVL4r+bjkvjaSYzW5N/bsXmcIc+LSjR3j+qzw1SUeBY7zM9ViMJVQUldMY9a/jHs8OFzhcylmmP k/dchu9VItDgWVS/SPJg3nY/tultcIeE7NP92SzRtVNmIITj3UZv+MN/udEVkUXTrC4+ATgsRFT+i F10Jzop52IyeCweloJGXk2tG+b3JQIclj84r/LM9nVlMOcyGv1oPsPiksUIB7GdaW2lj8KPb/obff xMmd5He6maCPaLud0kJ4Z2gFpH1stvNKqBwAyJh+fOK6//i2YsY4rMKf2enP7W2X5l+kKrkkgyt4l CWTUtTo1FhXLMaKxUqbw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqELK-0008FG-KB; Mon, 26 Feb 2018 08:41:06 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqE7M-0004ab-6t for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2018 08:26:46 +0000 Received: by mail-pf0-x242.google.com with SMTP id z10so1883982pfh.13 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=DM5U0b1b1V1qhAVq2TL++jTfvb+2ZOKMW5vadRXZY1YCwzWo/BUAot3F45E0tcxDwY CwSk0Eh9g7z8W9qoNH6nzBPXqMLKM/xWwCHEgFvZjY3Uq8e6kKjGWpDc17FdFWgmvO2s /6+NowBVgsPWNRFLYl9xOGHlQhtTU5TVVRreAtOedtea4rEwXi92z6AXvqL1wdP0Mf5e XV1P0GnZR886FIO5k2lwh7kmhgR63LBNaLuaBqUcH0AtOfzb9TyWr61PT3HM34Y9CXo/ ya7ji3FyUDG4o0IWDO37xRzjnwgsNAnQe4ykIr7yijtyYW/R6KWHd/i5M40GuR/qTlJV tufw== X-Gm-Message-State: APf1xPC8MQy6ElEYDCgVLpqk5lRdIdQaNiDukFC1d/aZfgXU0Ah/LzIs 7PWJfrg4y4pZre8Htd64bupg2g== X-Google-Smtp-Source: AH8x225Nlcn9kjGfhN2dcctlnysKneCTjojfkrFpwvRzRctJvdzRLcT5odsNIkMic99NeOsGi7Mlsw== 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180226_002640_438900_1EEE3E4E X-CRM114-Status: GOOD ( 15.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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;