From patchwork Thu Apr 30 11:48:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 11519935 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C6F8912 for ; Thu, 30 Apr 2020 11:49:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F55520757 for ; Thu, 30 Apr 2020 11:49:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TKrLNIp6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F55520757 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=INHIQXGbeKwKfIo7Tns4WEMUrfUEyMjWK376zpO96xU=; b=TKrLNIp697XURWu99kRCIdvBOm XlmEkO3GCsZOViltqbmj6sBWGiSVHzmajEIMQkUzWz9SrX/9j+5YZaVvhv88o3yxR7HKOQyPq4dkF GzfsoVw2hvkXtqfM0YISeQ+HMNnyXDFxP2PE8yjYuRrEKto2K+l4N7BFzOtN8JKUwMwIxib7TJAXA kUopnTuiqRuxZt7QFTbfb2JBEmPuUm7mYqZ27lHlDgCa0hmsR0VwR1VWMo/p2ogo1Yg3u7BRq7csr 7F7MvJfpqtn9gI/CLS2VyYHfhbIkftIrFVeh6qK5mRrm0M1uSKkn/OIEad32p3oAWbwh0YCTji+ST fyMhUYKg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7gq-00072H-Aw; Thu, 30 Apr 2020 11:49:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7gG-0006Xp-CZ for linux-arm-kernel@lists.infradead.org; Thu, 30 Apr 2020 11:48:42 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 60EDB106F; Thu, 30 Apr 2020 04:48:38 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 23B8A3F305; Thu, 30 Apr 2020 04:48:37 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/5] arm/arm64: smccc: Update link to latest SMCCC specification Date: Thu, 30 Apr 2020 12:48:10 +0100 Message-Id: <20200430114814.14116-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430114814.14116-1-sudeep.holla@arm.com> References: <20200430114814.14116-1-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200430_044840_474124_C0B886A6 X-CRM114-Status: GOOD ( 12.26 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 , Lorenzo Pieralisi , Catalin Marinas , linux-kernel@vger.kernel.org, Steven Price , harb@amperecomputing.com, Sudeep Holla , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The current link gets redirected to the revision B published in November 2016 though it actually points to the original revision A published in June 2013. Let us update the link to point to the latest version, so that it doesn't get stal anytime soon. Currently it points to v1.2 published in March 2020. Signed-off-by: Sudeep Holla Reviewed-by: Steven Price --- include/linux/arm-smccc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index 59494df0f55b..6c1d1eda3be4 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -10,7 +10,7 @@ /* * This file provides common defines for ARM SMC Calling Convention as * specified in - * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html + * https://developer.arm.com/docs/den0028/latest */ #define ARM_SMCCC_STD_CALL _AC(0,U) From patchwork Thu Apr 30 11:48:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 11519933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 833E6912 for ; Thu, 30 Apr 2020 11:49:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2F81A2078D for ; Thu, 30 Apr 2020 11:49:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Nu3GJNPb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F81A2078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=897qN7opJ2gdUTU8jDCqGrMdvnfBePTFEI7GHZGOb2w=; b=Nu3GJNPbZqIIfGNkyhL2mjBRAh iEB3ay3duAVB1hKinOO8WReJkT2xS5yZGsYk1526YamDmJRCUMB3r6akly9M2idhB6jCWfzo5OJwl QXLZJckyXjrqt4LED6TINsyadBWVKLwRQcTqg9oKmoZtL1WbZsO1PLIxIE2l04LuYR9uds7VD2r6D L41m7Vi2ZYdXr7Bit7R9W++UQxqxxdKLabbnC97tAMgW0xi15PN/xnWxGloc9y0rcV4C+o2nchnrM y1xt5BhRWiXXgf0IHdx2UaEUd/+NK+MY9rvCrWzRdmyjJa+/aKFGyLSql64BY8015ljtuQem4EHUx WGs1i4fw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7gW-0006mI-T0; Thu, 30 Apr 2020 11:48:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7gG-0006YM-8p for linux-arm-kernel@lists.infradead.org; Thu, 30 Apr 2020 11:48:41 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C8ECA11D4; Thu, 30 Apr 2020 04:48:39 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 94ECF3F305; Thu, 30 Apr 2020 04:48:38 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/5] arm/arm64: smccc: Add the definition for SMCCCv1.2 version/error codes Date: Thu, 30 Apr 2020 12:48:11 +0100 Message-Id: <20200430114814.14116-3-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430114814.14116-1-sudeep.holla@arm.com> References: <20200430114814.14116-1-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200430_044840_362202_BAB1C03F X-CRM114-Status: GOOD ( 10.10 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 , Lorenzo Pieralisi , Catalin Marinas , linux-kernel@vger.kernel.org, Steven Price , harb@amperecomputing.com, Sudeep Holla , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add the definition for SMCCC v1.2 version and new error code added. While at it, also add a note that ARM DEN 0070A is deprecated and is now merged into the main SMCCC specification(ARM DEN 0028C). Signed-off-by: Sudeep Holla Reviewed-by: Steven Price --- include/linux/arm-smccc.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index 6c1d1eda3be4..9d9a2e42e919 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -56,6 +56,7 @@ #define ARM_SMCCC_VERSION_1_0 0x10000 #define ARM_SMCCC_VERSION_1_1 0x10001 +#define ARM_SMCCC_VERSION_1_2 0x10002 #define ARM_SMCCC_VERSION_FUNC_ID \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ @@ -314,10 +315,14 @@ asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1, */ #define arm_smccc_1_1_hvc(...) __arm_smccc_1_1(SMCCC_HVC_INST, __VA_ARGS__) -/* Return codes defined in ARM DEN 0070A */ +/* + * Return codes defined in ARM DEN 0070A + * ARM DEN 0070A is now merged/consolidated into ARM DEN 0028C + */ #define SMCCC_RET_SUCCESS 0 #define SMCCC_RET_NOT_SUPPORTED -1 #define SMCCC_RET_NOT_REQUIRED -2 +#define SMCCC_RET_INVALID_PARAMETER -3 /* * Like arm_smccc_1_1* but always returns SMCCC_RET_NOT_SUPPORTED. From patchwork Thu Apr 30 11:48:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 11519939 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0107F912 for ; Thu, 30 Apr 2020 11:49:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC4EB20757 for ; Thu, 30 Apr 2020 11:49:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BP7sewQQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC4EB20757 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=alNyS+HyCrhld/ltRrfXkzzhcAdjziJV4zANG5dsYx8=; b=BP7sewQQ8xOAvgfsH0KUlkGloo XMjSyCVPnIV1LzyX3+uPgqSFi39f6Lby7xh1AnoEW03kXWqxnx1oI+6WRaw9ks0BmpNlIVMIcBcCU 6kI1mcqL0nnOaXDyAE5/NUXt9S9RL1N4rh6EhJjtR2myPMbJ0hbtRNfHiSd6kld5tx2oIOUdc8C0n vvnQDiQni1bHic1513LgUG+Fxv5zsqCPzcOOYqYTSuS9A9LNNokIYPET3HDe05oZzoRj1O3acPsLy K6qi32XS6dbUgefl7ei8nAfPorCLd8ylGKl/NMMva9E4DFsCd2Gs6R74nMDryljR0Boq1WJvkpw8F ayUQuTvA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7hP-0007da-Lf; Thu, 30 Apr 2020 11:49:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7gI-0006ZN-Ar for linux-arm-kernel@lists.infradead.org; Thu, 30 Apr 2020 11:48:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 408391045; Thu, 30 Apr 2020 04:48:41 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0940D3F305; Thu, 30 Apr 2020 04:48:39 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/5] arm/arm64: smccc: Drop smccc_version enum and use ARM_SMCCC_VERSION_1_x instead Date: Thu, 30 Apr 2020 12:48:12 +0100 Message-Id: <20200430114814.14116-4-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430114814.14116-1-sudeep.holla@arm.com> References: <20200430114814.14116-1-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200430_044842_415607_DD34DA4A X-CRM114-Status: GOOD ( 13.03 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 , Lorenzo Pieralisi , Catalin Marinas , linux-kernel@vger.kernel.org, Steven Price , harb@amperecomputing.com, Sudeep Holla , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Instead of maintaining 2 sets of enums/macros for tracking SMCCC version, let us drop smccc_version enum and use ARM_SMCCC_VERSION_1_x directly instead. Signed-off-by: Sudeep Holla Reviewed-by: Steven Price --- arch/arm64/kernel/paravirt.c | 2 +- drivers/firmware/psci/psci.c | 8 ++++---- include/linux/psci.h | 7 +------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c index 1ef702b0be2d..295d66490584 100644 --- a/arch/arm64/kernel/paravirt.c +++ b/arch/arm64/kernel/paravirt.c @@ -120,7 +120,7 @@ static bool has_pv_steal_clock(void) struct arm_smccc_res res; /* To detect the presence of PV time support we require SMCCC 1.1+ */ - if (psci_ops.smccc_version < SMCCC_VERSION_1_1) + if (arm_smccc_1_1_get_conduit() == SMCCC_CONDUIT_NONE) return false; arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 2937d44b5df4..6a56d7196697 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -54,12 +54,12 @@ bool psci_tos_resident_on(int cpu) struct psci_operations psci_ops = { .conduit = SMCCC_CONDUIT_NONE, - .smccc_version = SMCCC_VERSION_1_0, + .smccc_version = ARM_SMCCC_VERSION_1_0, }; enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void) { - if (psci_ops.smccc_version < SMCCC_VERSION_1_1) + if (psci_ops.smccc_version < ARM_SMCCC_VERSION_1_1) return SMCCC_CONDUIT_NONE; return psci_ops.conduit; @@ -411,8 +411,8 @@ static void __init psci_init_smccc(void) 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; + if (ret >= ARM_SMCCC_VERSION_1_1) { + psci_ops.smccc_version = ret; ver = ret; } } diff --git a/include/linux/psci.h b/include/linux/psci.h index a67712b73b6c..29bd0671e5bb 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -21,11 +21,6 @@ bool psci_power_state_is_valid(u32 state); int psci_set_osi_mode(void); bool psci_has_osi_support(void); -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); @@ -36,7 +31,7 @@ struct psci_operations { unsigned long lowest_affinity_level); int (*migrate_info_type)(void); enum arm_smccc_conduit conduit; - enum smccc_version smccc_version; + u32 smccc_version; }; extern struct psci_operations psci_ops; From patchwork Thu Apr 30 11:48:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 11519937 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E72F9913 for ; Thu, 30 Apr 2020 11:49:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE91120757 for ; Thu, 30 Apr 2020 11:49:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="u/peUKIr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE91120757 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=obmFxcHPlKTprPtFzGIFqNUYT5jhNyLM8bKoayr53rs=; b=u/peUKIrvTZf/MC2xB4bYcxs6U oXVhcwRi3PvmZ9RMsa5BANGK5YRyagIOuIq+9V8GI+lfVujOzBIdpnHVy+yXUGbOPWFVtRdbGPcAl 5PSTMUlCZgMPBuj+ZrYky08BXbqdri4mD9TqNAxf9HWnP7uLiMclT7y2ACIQXrhi/fcmSrk6A1isr it0x3/CkEGvQk1/McyhbJCv+paIdS5kWEb3PsExsyvv4zS4xbXrMHwcrhJPB8Q5cajepX79lVJRlr rgE6CltNZjtlFif5G6M4nn/7gRmBb7L8DtfI9g+8ZpTCjr3AHa8OGKNK9UhFdQyZUdhYW7srD4aTo r2TtsRMQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7hC-0007PU-1G; Thu, 30 Apr 2020 11:49:38 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7gJ-0006aQ-Dh for linux-arm-kernel@lists.infradead.org; Thu, 30 Apr 2020 11:48:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A91B6106F; Thu, 30 Apr 2020 04:48:42 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 74E6F3F305; Thu, 30 Apr 2020 04:48:41 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/5] firmware: psci: Add function to fetch SMCCC version Date: Thu, 30 Apr 2020 12:48:13 +0100 Message-Id: <20200430114814.14116-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430114814.14116-1-sudeep.holla@arm.com> References: <20200430114814.14116-1-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200430_044843_516136_2B9377DB X-CRM114-Status: GOOD ( 10.12 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 , Lorenzo Pieralisi , Catalin Marinas , linux-kernel@vger.kernel.org, Steven Price , harb@amperecomputing.com, Sudeep Holla , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For backward compatibility reasons, PSCI maintains SMCCC version as SMCCC didn't provide ARM_SMCCC_VERSION_FUNC_ID until v1.1 Let us provide accessors to fetch the SMCCC version in PSCI so that other SMCCC v1.1+ features can use it. Signed-off-by: Sudeep Holla --- drivers/firmware/psci/psci.c | 5 +++++ include/linux/arm-smccc.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 6a56d7196697..04426e16fee6 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -65,6 +65,11 @@ enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void) return psci_ops.conduit; } +u32 arm_smccc_get_version(void) +{ + return psci_ops.smccc_version; +} + typedef unsigned long (psci_fn)(unsigned long, unsigned long, unsigned long, unsigned long); static psci_fn *invoke_psci_fn; diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index 9d9a2e42e919..d6b0f4acc707 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -98,6 +98,15 @@ enum arm_smccc_conduit { */ enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void); +/** + * arm_smccc_get_version() + * + * Returns the version to be used for SMCCCv1.1 or later. + * + * When SMCCCv1.1 or above is not present, assumes and returns SMCCCv1.0. + */ +u32 arm_smccc_get_version(void); + /** * struct arm_smccc_res - Result from SMC/HVC call * @a0-a3 result values from registers 0 to 3 From patchwork Thu Apr 30 11:48:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 11519941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E293913 for ; Thu, 30 Apr 2020 11:50:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4547C2078D for ; Thu, 30 Apr 2020 11:50:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rlwP5Lem" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4547C2078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=OWTIRSZTqmew47ClFCgJ5uy3fD6v0Zv3npTmZfXggYA=; b=rlwP5Lemi4dex1lEaI4NCybpyN JIeVQ4vQVPLK5q+pY0ZYpPSssUEpGiD3RnGaWXRiv71BDm6yLGneGbXs43eNA7/O1WdDOnzpBdJSY W8yFVejkwx2Me4MqxBWO7U36XVyts8MMJ6kDhZJc8f4wF8v+lLuFR+PiZuYYANv/CEo3n5t/Gs/q6 9XMq3IO9tK6WljDkuILPHAF5U6x/KkX1hZsCIkb/TSDcLwDBASuCO7VPBvVwaMGjWm+xCo2UKSfkW Y1q9CA8vrd4bVx6rGoSEg0CXwFDixV6Kh3lxPvb9fBIFVai7Lps5ahxA2iPY7CsesoCzbyd1qAmsi 1SR5G4tA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7hs-0001te-Ik; Thu, 30 Apr 2020 11:50:20 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jU7gK-0006ZN-ER for linux-arm-kernel@lists.infradead.org; Thu, 30 Apr 2020 11:48:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D1811045; Thu, 30 Apr 2020 04:48:44 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DD5293F305; Thu, 30 Apr 2020 04:48:42 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/5] arm/arm64: smccc: Add ARCH_SOC_ID support Date: Thu, 30 Apr 2020 12:48:14 +0100 Message-Id: <20200430114814.14116-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430114814.14116-1-sudeep.holla@arm.com> References: <20200430114814.14116-1-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200430_044844_589686_D7111596 X-CRM114-Status: GOOD ( 16.23 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 , Lorenzo Pieralisi , Catalin Marinas , linux-kernel@vger.kernel.org, Steven Price , harb@amperecomputing.com, Sudeep Holla , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org SMCCC v1.2 adds a new optional function SMCCC_ARCH_SOC_ID to obtain a SiP defined SoC identification value. Add support for the same. Also using the SoC bus infrastructure, let us expose the platform specific SoC atrributes under sysfs. We also provide custom sysfs for the vendor ID as JEP-106 bank and identification code. Signed-off-by: Sudeep Holla --- drivers/firmware/psci/Makefile | 2 +- drivers/firmware/psci/soc_id.c | 148 +++++++++++++++++++++++++++++++++ include/linux/arm-smccc.h | 5 ++ 3 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/psci/soc_id.c diff --git a/drivers/firmware/psci/Makefile b/drivers/firmware/psci/Makefile index 1956b882470f..c0b0c9ca57e4 100644 --- a/drivers/firmware/psci/Makefile +++ b/drivers/firmware/psci/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 # -obj-$(CONFIG_ARM_PSCI_FW) += psci.o +obj-$(CONFIG_ARM_PSCI_FW) += psci.o soc_id.o obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o diff --git a/drivers/firmware/psci/soc_id.c b/drivers/firmware/psci/soc_id.c new file mode 100644 index 000000000000..820f69dad7f5 --- /dev/null +++ b/drivers/firmware/psci/soc_id.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2020 Arm Limited + */ + +#include +#include +#include +#include +#include +#include +#include + +#define SOCID_JEP106_BANK_IDX_MASK GENMASK(30, 24) +#define SOCID_JEP106_ID_CODE_MASK GENMASK(23, 16) +#define SOCID_IMP_DEF_SOC_ID_MASK GENMASK(15, 0) +#define JEP106_BANK_IDX(x) (u8)(FIELD_GET(SOCID_JEP106_BANK_IDX_MASK, (x))) +#define JEP106_ID_CODE(x) (u8)(FIELD_GET(SOCID_JEP106_ID_CODE_MASK, (x))) +#define IMP_DEF_SOC_ID(x) (u16)(FIELD_GET(SOCID_IMP_DEF_SOC_ID_MASK, (x))) + +static int soc_id_version; +static struct soc_device *soc_dev; +static struct soc_device_attribute *soc_dev_attr; + +static int smccc_map_error_codes(unsigned long a0) +{ + if (a0 == SMCCC_RET_INVALID_PARAMETER) + return -EINVAL; + if (a0 == SMCCC_RET_NOT_SUPPORTED) + return -EOPNOTSUPP; + return 0; +} + +static int smccc_soc_id_support_check(void) +{ + struct arm_smccc_res res; + + if (arm_smccc_1_1_get_conduit() == SMCCC_CONDUIT_NONE) { + pr_err("%s: invalid SMCCC conduit\n", __func__); + return -EOPNOTSUPP; + } + + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, + ARM_SMCCC_ARCH_SOC_ID, &res); + + return smccc_map_error_codes(res.a0); +} + +static ssize_t +jep106_cont_bank_code_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%02x\n", JEP106_BANK_IDX(soc_id_version) + 1); +} + +static DEVICE_ATTR_RO(jep106_cont_bank_code); + +static ssize_t +jep106_identification_code_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%02x\n", JEP106_ID_CODE(soc_id_version) & 0x7F); +} + +static DEVICE_ATTR_RO(jep106_identification_code); + +static struct attribute *jep106_id_attrs[] = { + &dev_attr_jep106_cont_bank_code.attr, + &dev_attr_jep106_identification_code.attr, + NULL +}; + +ATTRIBUTE_GROUPS(jep106_id); + +static int __init smccc_soc_init(void) +{ + struct device *dev; + int ret, soc_id_rev; + struct arm_smccc_res res; + static char soc_id_str[8], soc_id_rev_str[12]; + + if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2) + return 0; + + ret = smccc_soc_id_support_check(); + if (ret) + return ret; + + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_SOC_ID, 0, &res); + + ret = smccc_map_error_codes(res.a0); + if (ret) + return ret; + + soc_id_version = res.a0; + + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_SOC_ID, 1, &res); + + ret = smccc_map_error_codes(res.a0); + if (ret) + return ret; + + soc_id_rev = res.a0; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + sprintf(soc_id_str, "0x%04x", IMP_DEF_SOC_ID(soc_id_version)); + sprintf(soc_id_rev_str, "0x%08x", soc_id_rev); + + soc_dev_attr->soc_id = soc_id_str; + soc_dev_attr->revision = soc_id_rev_str; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + ret = PTR_ERR(soc_dev); + goto free_soc; + } + + dev = soc_device_to_device(soc_dev); + + ret = devm_device_add_groups(dev, jep106_id_groups); + if (ret) { + dev_err(dev, "sysfs create failed: %d\n", ret); + goto unregister_soc; + } + + pr_info("SMCCC SoC ID: %s Revision %s\n", soc_dev_attr->soc_id, + soc_dev_attr->revision); + + return 0; + +unregister_soc: + soc_device_unregister(soc_dev); +free_soc: + kfree(soc_dev_attr); + return ret; +} +module_init(smccc_soc_init); + +static void __exit smccc_soc_exit(void) +{ + if (soc_dev) + soc_device_unregister(soc_dev); + kfree(soc_dev_attr); +} +module_exit(smccc_soc_exit); diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index d6b0f4acc707..04414fc2000f 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -68,6 +68,11 @@ ARM_SMCCC_SMC_32, \ 0, 1) +#define ARM_SMCCC_ARCH_SOC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + 0, 2) + #define ARM_SMCCC_ARCH_WORKAROUND_1 \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ ARM_SMCCC_SMC_32, \