From patchwork Thu Aug 1 08:15:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11070263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9BF913AC for ; Thu, 1 Aug 2019 08:20:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC607283A6 for ; Thu, 1 Aug 2019 08:20:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0219283AF; Thu, 1 Aug 2019 08:20:59 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 58008283A6 for ; Thu, 1 Aug 2019 08:20:59 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=HNx7+VLLYM9naswiHW8erBj+S6i3EnRSZLR37q7YcEA=; b=CqC4MSaVPNnslC w5wUxBCT2V7TcVNvjBMNiPZkJtPeh4QPXwRe5Y/3FtewgIDdm69kAu08CuUM08hpt87F2C+c2e2nW 7Zln9TssLSDvMHv78iVJjmrid86PdRheJMi7MHeDStjhyfi9Hh0qf+AqPA5OIuQMgNrNpCtTbjrJT ZMLStVtOCGtNuk48pvq4vpt4kkckdBw44GW3AYd4TLJAA16LIFaWbUEzEyBJCYMwHU4WhaPBAOig+ q9F49FRDWLu3w+MB47NY1SwoKPAzQYrPjNJRz3GQZBcgU3oLTSdk3QDVT/y8T2AyrSuXQrMMDT1l4 FecyAxUaxdbf4tyOS1gA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1ht6KY-0002xO-BN; Thu, 01 Aug 2019 08:20:58 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1ht6JU-0000OU-C6 for linux-arm-kernel@lists.infradead.org; Thu, 01 Aug 2019 08:19:54 +0000 Received: by mail-pl1-x641.google.com with SMTP id b3so31882446plr.4 for ; Thu, 01 Aug 2019 01:19:51 -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=U2pFy8zplP29YpsCH8W5CImqW9kDRTXequpz5TZjdTd/cKjWqInrw3Uwd1AL2uD6lU qbZ/TwswNmotIc7tfzAT06bNLn3+R8t/4ayZ3lv6smnADiIqJ77U8FH5+ntKrSwXrMCf XkgfLzlAC8TJa9x6Elq24iJrBFMA2SC0pp/liR93dQ4TUU8E2GuBBHp6WlVS6LSJhNao ImLUvMYM8Id3R/lKhgjC7TaPnfvasBP4OyyrDRFHP8oH957QYy7TLvliiwmwD+dQAitC aEVWiulUEAtHO7t4spHHwYrNSMz+RgEFMpvh3JV3t4gQZMGjxPO20KwIbAnbo9bsihGo c+7A== 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=TskpWY11/SkFPW8eNkkSolZqCDdO+d/+I0aUisc7Vbqo0qafxHUaClH1+DQpX4EfgK IDurxJi9D4bvbocJVAJ15KwFs8Idnu1pXU7nS1h4GY3barARzHkWQy3C5MCcWH5kMcLi 2nv1dWQQ25k8Akl00/yl4BBlAyzzsgVgiDneN6Vm+lXMXsMue2QD4XVJba+7flgqNdDZ 4KtLauMlxGTviS3YEyZoS08NF1we68CuzUDv8N1LcFYSSYmQcRGysTybWDWlN8OBJ/te 8Q/Xb47Sy0mAkUuTuPYyuGq+6Xk6BqmzBNS4ZZ0yzqAxMx5FGaPwZsNSVQFyqttFjdHY FkaA== X-Gm-Message-State: APjAAAW1oPVhomAWL/WwEg6PA5Mh0iJg8XNbFBSSQX5cX8MQcX2S7Ymf +a5bqKFDr5amIzjGcYcsdrOMaw== X-Google-Smtp-Source: APXvYqzSgtxQ3JDCBf442PLtZn52NA1MhiDih6RwxeLZMFxUsFnDqNuIiXEcBuC3C4LEZKGa4aagUQ== X-Received: by 2002:a17:902:ff05:: with SMTP id f5mr120452352plj.116.1564647591056; Thu, 01 Aug 2019 01:19:51 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id l6sm71842795pga.72.2019.08.01.01.19.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 01:19:50 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org Subject: [PATCH ARM32 v4.4 V2 06/47] firmware/psci: Expose SMCCC version through psci_ops Date: Thu, 1 Aug 2019 13:45:50 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190801_011952_522830_D4A01C20 X-CRM114-Status: GOOD ( 14.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Julien Thierry , Marc Zyngier , Viresh Kumar , guohanjun@huawei.com, Will Deacon , mark.brown@arm.com, Catalin Marinas , Russell King , linux-arm-kernel@lists.infradead.org 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 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(+) 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;