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: 10251347 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 55581602B5 for ; Thu, 1 Mar 2018 13:23:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F33B22380 for ; Thu, 1 Mar 2018 13:23:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BAAE2239C; Thu, 1 Mar 2018 13:23:46 +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 CE28C223A1 for ; Thu, 1 Mar 2018 13:23:45 +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:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To: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=fP+8CqQ3ObWHxHaY0JcvRtNZ6x D5s4a/aXpX8yuXJLsOiIGCldGkVMcYMPp1ieUxrBfsPfXSTiiO+nxcLFhi7xKXM3qzCgNIFkks7iJ Wc8uQHQ7QtgtcT4ykgjuIdR/uwrqjzQs8Qemglu8Vj79IxiUKjwGRFXOcyog/NaOxJgu/sVDTPvhz mO2yt+V3SIOURdRu1cJXYPtucZNmmEEm78aYSLYYBfrWqjPqJ8YfTsBsmdI1T2m0ihqMBTOe6kp14 Sa21vWhCX/i4DXuXPBuvSkbSZuRYmVLY9AUEXpJVPfFKNFCe4aAh8u2v7NGHNkwFpBvJlxrZ3s/+g yqzNAbRw==; 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 1erOBO-0005Yh-6P; Thu, 01 Mar 2018 13:23:38 +0000 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erNpU-0005FT-7W for linux-arm-kernel@lists.infradead.org; Thu, 01 Mar 2018 13:02:41 +0000 Received: by mail-pl0-x244.google.com with SMTP id w21-v6so3586146plp.11 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=U7yLm15h+FWtz+60T9gbBLaOe5D1ivr9NLwOGhZ/1NE4cMXEry1mCN5JySTOpbdTtJ PqRcm31pKeV/sxO8cDy+Mvn1lUrRdOzrjMOgQpFtpr3+p/Lot7x5IIWz/4WfBPiYCGrP /efZd7qsgux2cJSMpdIY7i+CIJfUpeY1H1D1bIFRGd1BIMcKueUopeBtk37fyoXGNCEC E4S1qR1Zt9iSehOrXNeN6VDDdpGtGw3sCKPnoyxFP/xss7Z6lgFxzaw+G2o58XJvYZzi LWZdZ8fAogpSEjcmATMNFcVgPVmmaTvdadP0sOKRlf+/z+cOfcg+je4nroplTiLL8elX lCzg== X-Gm-Message-State: APf1xPAcOOJtR6aeveL9oVyYA43YW0CJNdBnYIq5BerhPlOxcvu9HMxs 8ELmvX0LbQoqmXube83p76r8Pw== X-Google-Smtp-Source: AG47ELvQqnGqop2TBN8hv8AWjq4YbCsz4i+AuqmSvTMEN2TFxuw7Q/KfIRkMsDsPnJ55jXJhZeLDFg== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180301_050101_253234_E94FE6F3 X-CRM114-Status: GOOD ( 15.87 ) 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: , Cc: Alex Shi 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;