From patchwork Fri Jun 14 03:08:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 166778 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1506454ilk; Thu, 13 Jun 2019 20:13:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBzeVGNLymwH17e2HeFNyp5R9uk1VTZQIukoWioFAQjkFdVIEMWAQWJFCFxXBEkrlDD6rM X-Received: by 2002:a65:56c5:: with SMTP id w5mr33156694pgs.434.1560482020680; Thu, 13 Jun 2019 20:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560482020; cv=none; d=google.com; s=arc-20160816; b=cwRHe6YbbJ5DSXorQAn19+/PIaHZ7VEvgud2h7a7Wxe17xFO9SGq3nTLtZzF96DMAT EXY7aiVpUMVGTlXm2W6gUCPHEceRjkJS9XginEpr50MPPZ1MVeaSIkymGAUO+PbDCgPE 7wNDeq1rwgz+fq9A2aAJbRVKw1y/l1RK5CUKxM86YzrRx1z0u884VLaIX+eKf7YDhVTy 3iCd7bNnU0ebNqqJeTAojrxOHIQ5t9ZqHMGZck+lFO6+3t2Mh/fvpfyLoE0uEZv/j9tb nGU44ZXeUDcJpH0GQRQw0PT3uKi+vEpUHLfTS01QbboU5r6lsSXuxiUf3iFvw301cpgs ZuzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8FgYZ0lVoh76yEFRGdkiTuXxRHgDjc15a9Db0UAG0RM=; b=kw+GDNX5gyLdr9iCuDaeoRgVnpxXw+e1L/lWewMm2YeT1erSNZAd2yDE4hSv5EWQ0A qQ+y5Mm5T6Jk/uB8fqOOXNf2F0kg5PBBXIvD75bj8WDW5d5X2zxuED9464QZSghqDvmD 6SHHt2ahx64pnyBlnUnfWw3MZuUGXOuxt3yYwXvYJHMVxryt9cltLBCQZ2JYIry3LPho UmVblbVmrBS3YMxod/L6yt3tL900gnxRNldm+I8yxWp+YTjLockeWdqqzKJ2M7SJmh+T 7+lLfQ+ycMeI6FaPkyLhMmGzSKp6JbqzEHPjikAZ67aJ51AOGLUQjxNMt1sX90PfrlZU Mvyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lv7ALkok; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 e8si1073936plb.420.2019.06.13.20.13.40; Thu, 13 Jun 2019 20:13:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=lv7ALkok; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1726757AbfFNDNk (ORCPT + 14 others); Thu, 13 Jun 2019 23:13:40 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45459 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbfFNDNj (ORCPT ); Thu, 13 Jun 2019 23:13:39 -0400 Received: by mail-pg1-f195.google.com with SMTP id s21so656762pga.12 for ; Thu, 13 Jun 2019 20:13:39 -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=lv7ALkokBtCxuF0Pb2QGAynH5EmP6+hWl8YTf/8htRpD/JOpxkK1Xua6Q32p3zAcJG MlKJcqsbz1BZt1tqo8tVvOPin1iNWGS1K6vb4+S5DL/w8JwY69CkxhmvsPgybtMSUt2y dX4adwqML14qOFeBbRhLQVBoxwaKNGrAXPQWW/CSQmHOJAznIPzo/P9umTzO4khHXPEd /ElLjLUlWaRKbTTbi6i8H6WoRILdTuSgwWQy5f5rY2018+96HoUsMaCWeV6KsfoEu/uG 6NciLkwwDCxmVny3AZfHRF7pM7QkTQpPdnKJQW9w4ut5rsTLsv63X3Z0VD/EfTN1ypud hTVQ== 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=nHSM7GYLTQc7bmuv66xFCLCbSqprHOrljpu/NYUeeCchWBf3/FuBkIG6IG17oFQxpA O8Qiq37k9j1KZ/WM3z6qZm8hB3pBF1GMDMzC4S5EeOUf9aSYq3VDLPt7koi+kPuqsV/W 0uYZCukBLzk4e8ij2bEE5vQORV4S3YSY+DeNwHVjf04IK/GIl8wJyHQZdsURJk2znC1+ Q8VbByylUcz4aXIiOGfdf7Gj4OWr5ryu2i/sefj3KTfPGq+UtWXRLxzwJOFgxIf79kWq MYkkTKypnOjrLSHQAAbhe7FAXdrCCiPIDzcoQAFxKheplND3uCLzEMh5GgXCi/3tMsrF 9i6g== X-Gm-Message-State: APjAAAUDjf9SlNkuIPTYxHvXIIhuF86Qa6A2ceBXQtucE6+niI1JH8qS NLiZDaCZQWHDcmXaQwfOrxBwSA== X-Received: by 2002:a17:90a:5d0a:: with SMTP id s10mr8696027pji.94.1560482019108; Thu, 13 Jun 2019 20:13:39 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id s15sm1080007pfd.183.2019.06.13.20.13.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 20:13:38 -0700 (PDT) From: Viresh Kumar To: linux-arm-kernel@lists.infradead.org, Julien Thierry Cc: Viresh Kumar , stable@vger.kernel.org, Catalin Marinas , Marc Zyngier , Mark Rutland , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com Subject: [PATCH v4.4 40/45] firmware/psci: Expose SMCCC version through psci_ops Date: Fri, 14 Jun 2019 08:38:23 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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(+) -- 2.21.0.rc0.269.g1a574e7a288b 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;