From patchwork Thu Nov 14 03:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Benoit X-Patchwork-Id: 13874505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E4376D637DB for ; Thu, 14 Nov 2024 03:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=O8ofHZM4LnpBHCc2JRZSOooilZ4MsUAsGxJK7VAHWWc=; b=hcTM5i7W4LwlpVUvVrWY+i8SmU zvJprqNKilXdmngVYZNDDIKQM0ezMpyvgz29M2TYr4p5WmKpinVhXFCP5GqFbOGeK8VzyZg/Krop2 sYWBLuFDzvsE+WDeLpIlJwauhIq2oONwoh4v2waDsT6snmScVdQ2D8xsJIG2E9xFwvhn7RJq+RPNC ymwOqeo5bp03J8l61fBLmOv0n1amObTcO1U7ThR20MSkeoSJXZMSnNRYfYMS9IFlJ/laJymjGosK+ qdCkm50Poc+MKVIHEegsCBAU/aSzxcK94mj3uJy9FHDbLapEGmJMqYAROV4aOmk4JPi14LVLbAO0L qI1mGwPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tBQQ0-00000008fEa-2Qq2; Thu, 14 Nov 2024 03:21:16 +0000 Received: from mail-northcentralusazlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c105::1] helo=CH1PR05CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tBQOB-00000008ewI-1EIK for linux-arm-kernel@lists.infradead.org; Thu, 14 Nov 2024 03:19:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xocD6REg+Xi23pYWiGxl8qXN7SjoBKRD77V9H0o3k2LOg/gMUjbANV0mzc9SBsJkKhGRbWwzrog2Jq0EY7PCfBrgT0FrM8bE+OHFzptqHt/bWAXkMqB0qWPe9u5kCKP5vmHO8m9/gSZRMqdoq6ntKKRF8cmQsrPMM5Kr2knfekOTkEntGhNIuWqVpa21Kmc0sUfpR3WXnY939fUnugxkfm0GYrMoLpLn7Ha5GL2N9255vMQWfPb0h5/OolMcjpOo6aiFo3CHrdFhx9U2xRbzeP0oKKql6RgIm4J4YzDenX43PyDM4Htmx7cbw93F0G4s7LR1kfCnROLJZhI7zSs9hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O8ofHZM4LnpBHCc2JRZSOooilZ4MsUAsGxJK7VAHWWc=; b=JblsVCGX2RsszMPgUAzqOXmucOKU+fMUWvsvB0pE1OP7DaXI+AHvn7WYjax9QL0jLurnZ7jYpkk3u0zxySEjBBDdvlOAoX+LdtQLL8M8xtZtVTnNPxW2msKtZMBhlC5TFyBT4gUfnrV/pPOzzW6vjQN1t8rs7Zp+hyrZuCLV4ARC7p3kKi7JRejbbgKwKE4SOcv3CcDinegej9CjGm7hurYHE2I9u7hQ7aGe3WxybACSAhp9TdDNPGWRf1W4te8hcpI7Cf9YLQEM2cW2vbYAfk+1pBcRNhUwAq6YNYgWsbB2rYvIVP9P3AGaP5d2FLT+rNHc12mWmkhuDTvdlySV4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O8ofHZM4LnpBHCc2JRZSOooilZ4MsUAsGxJK7VAHWWc=; b=YmM7VPmtlOm9aV7nJqlGwq+45agRJ/PEGoflE/kgskFWnUNOwbYWECTyvvgs50fel6wiko7/J2NsmiG/zhGn2zRak7gbmcjOULSHKBfvNG+BzogUDFU/98J9ZHmZ9V3caGDLmnj4vV0FeoyAb7opng+k9Y9F7cjpILS2V+I9LhI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SA3PR01MB8501.prod.exchangelabs.com (2603:10b6:806:39e::18) by PH7PR01MB7584.prod.exchangelabs.com (2603:10b6:510:1d0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Thu, 14 Nov 2024 03:19:15 +0000 Received: from SA3PR01MB8501.prod.exchangelabs.com ([fe80::f7ae:9cc3:b435:c49d]) by SA3PR01MB8501.prod.exchangelabs.com ([fe80::f7ae:9cc3:b435:c49d%4]) with mapi id 15.20.8158.013; Thu, 14 Nov 2024 03:19:15 +0000 From: Paul Benoit To: linux-kernel@vger.kernel.org Cc: Paul Benoit , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , linux-arm-kernel@lists.infradead.org Subject: [PATCH] firmware: smccc: Support optional Arm SMC SOC_ID name Date: Wed, 13 Nov 2024 19:04:52 -0800 Message-ID: <20241114030452.10149-1-paul@os.amperecomputing.com> X-Mailer: git-send-email 2.46.2 X-ClientProxiedBy: BYAPR02CA0027.namprd02.prod.outlook.com (2603:10b6:a02:ee::40) To SA3PR01MB8501.prod.exchangelabs.com (2603:10b6:806:39e::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA3PR01MB8501:EE_|PH7PR01MB7584:EE_ X-MS-Office365-Filtering-Correlation-Id: 8db10019-5a6d-46d4-b964-08dd045b1e19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: ItYWJiv4H0WhQPIMYuiXUwFkbGODowmqDg6o0oE+Iee8MzSEoZ1GB1/U85B6o7o5qSooJXqJ9Yo85VG3PFSO1xuhtmDu+sSzDRW4/O0fq8SmjW7mn2ECLFPrNqAQQbnaewPjWFVKSxoy/Nn59LGWLwpiP1snQ59Gn70VXbFuyzsAzr1qRHL9tfx6L9hpTO3u2Gf3lx4QC5fYX/wNjdL/ufqnPNDhGsVv0mTPNrWPGErhy2mHSqGNs4zB9VduVFJ7jUOOVhKpH8hex76jV1nRmasjGsvjzLI37FqT6x4udeGf0JnEzrRXX1mx6hubE5GyHtgjW4dQ736ruytBLjJbfdUnHrfuSkVF3/L9/YIPPso9W4FTyPdTxvNziTdsJWt9xgusbmwKYu8sUpiDtt6ygvxq3Ti0c3/hhy3BotPPFmPkOe53SHH83Fu2JaShXByAOOwo3xnmFnihLNmkD2yGjl8Q/8XtGxPEhhkL+dcJALBbn3v3cKVscJ4BQg5bs22kKIN2nGtLzfQF/GuWfgs/u9MalVBh8ClzFOH1uFmPgdp4ul6mQlxHvS/rQKhveYCF2HSuDDe1MQHbAj/KIVjnPCdMssh9YziJe+AT13NDw77aPgC/T49sBK3n8fP4dzrDZ/H8EFrCjFrlJhWg2LaJE9VZwogB3wg/ZVVSMRmeqaDurw+Vf3HCbZMKWIe34rcMwrnqZTgdbrqh9xihLwp9796wJQQXDIop2BeepdaL3MXarG+gv/BaYnfHAJqk+snl9/A7lWBm5B9XBHWiAkn094I0N6DmKJQup9hIiDljwNX287g3Ov59xeIUR44FJ5li1bL0RWHzinpIQwezwqbQwYl9HW1ITsXMq6Uh4ZwKUW/NiS65cibC/PaXPYynEfm1MOIOtxhOG+ffjYmHNdillRwzrTv9+41kqK1HyIfl1O7mQf9uWHrhuVo/G4/BO+f61DM1PI1EfWkmhEGuml6f83YeDeDhFbD6yOYOnOqulqc6hKlx+1RUd/+/2pzOkF6paLeRVwhBbbf6THplhNL4rP+Zl75I2SXZ3tP0XNeWUffEgIBIKg8reYIdZtTrfFc37lL/CO3o6rjAbeDxJ8JA8+I/eXU0OJWa4Fb+3vCXTLOPqSvds8sP+gFADg5jSvYvAGiwf1fQqOESZGnlRN1Yb/qY/EscWKTsR5HtbNnX+G9WgTHlF2zHEK4ecu9myDJbgqAiocqVaYF8YDohOXCRtdOXZ3JS5jNkll5il8h2Yoafai7mZRM4DFbr26PBoi+MZR22Z7NlVac2Aue/Mll3io7rx43jrEjFv0epS60yjNB+79zoacleC48hhMRy3etxxJtl/HzlLYPVC31ZXMqiLZmS9qr7cAW+o0G+uZ9rt9A= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA3PR01MB8501.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UJlFqLcm1oV6ERGfI3yUEf35vMJSWlTA5cOVa3JQFeSWy6O8fY/UoHZ/PcuWpQftoNpQWA5y8SARl0CArzt4gggtMnfOAVj+Ni5zZzCfaVNDa34Opx8d0iF8bqq/RMVa+JTsOpsv8iEH2YYUC7ZYP8Cq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EEWGBfAfYPvosxevnI9y6YKFRPUPnSfo55PuLPW887dPDmykaSUPSa4VQNk2MbJ4aAUcyPB6x2KjkdSEG2xL99sejFoKhvb+JRC29DH1Or0kRZ1RbPQFzWJdJrltPSOSkchGOZg+KoizGxxXLsP7stGHupUkZrdSWhk+JAg/qE3jLneIfMLvw3qQQcyPXP0Wm4X4esQyjSz1BSzqUte02ztwfVS6V4cFGzj7RhPu5WzL3HKdVHy+PLmAUqj7BQwdyWOTfdRdZNXQVD4WdcLvvE/YBF7JQmhoEFEl0RLhEPw80pEQByBr3I4KpGO9PcaPIh0G2mxRRFMUIj7AKkvuNJwDpfWLxIOEJ9ltresA3bQ6fxyWQS0ZWbO8XLfVyvLON01eQVkgn0b84zh8= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8db10019-5a6d-46d4-b964-08dd045b1e19 X-MS-Exchange-CrossTenant-AuthSource: SA3PR01MB8501.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2024 03:19:15.1649 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JlHolizQaLIzaG3TwplzBM91VJ0WyfpV7mqmN0T2wb2xIsxkMdJu37owHjI5XCflWMyu52VoW8drKDoltG4qeuThMiFvTlfhsqPKZbFElFY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR01MB7584 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241113_191923_361167_9C10391E X-CRM114-Status: GOOD ( 15.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Issue Number 1.6 of the Arm SMC Calling Convention introduces an optional SOC_ID name string. If available, point the 'machine' field of the SoC Device Attributes at this string so that it will appear under /sys/bus/soc/devices/soc0/machine. On Arm SMC compliant SoCs, this will allow things like 'lscpu' to eventually get a SoC provider model name from there rather than each tool/utility needing to get a possibly inconsistent, obsolete, or incorrect model/machine name from its own hardcoded model/machine name table. Signed-off-by: Paul Benoit Cc: Mark Rutland Cc: Lorenzo Pieralisi Cc: Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org --- drivers/firmware/smccc/smccc.c | 70 +++++++++++++++++++++++++++++++++ drivers/firmware/smccc/soc_id.c | 1 + include/linux/arm-smccc.h | 10 +++++ 3 files changed, 81 insertions(+) diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c index a74600d9f2d7..1c7084b0b8d7 100644 --- a/drivers/firmware/smccc/smccc.c +++ b/drivers/firmware/smccc/smccc.c @@ -18,10 +18,12 @@ static enum arm_smccc_conduit smccc_conduit = SMCCC_CONDUIT_NONE; bool __ro_after_init smccc_trng_available = false; s32 __ro_after_init smccc_soc_id_version = SMCCC_RET_NOT_SUPPORTED; s32 __ro_after_init smccc_soc_id_revision = SMCCC_RET_NOT_SUPPORTED; +char __ro_after_init smccc_soc_id_name[136] = ""; void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit) { struct arm_smccc_res res; + struct arm_smccc_1_2_regs regs_1_2; smccc_version = version; smccc_conduit = conduit; @@ -37,6 +39,66 @@ void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit) smccc_soc_id_version = (s32)res.a0; arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_SOC_ID, 1, &res); smccc_soc_id_revision = (s32)res.a0; + + /* Issue Number 1.6 of the Arm SMC Calling Convention + * specification introduces an optional "name" string + * to the ARM_SMCCC_ARCH_SOC_ID function. Fetch it if + * available. + */ + regs_1_2.a0 = ARM_SMCCC_ARCH_SOC_ID; + regs_1_2.a1 = 2; /* SOC_ID name */ + arm_smccc_1_2_smc( + (const struct arm_smccc_1_2_regs *)®s_1_2, + (struct arm_smccc_1_2_regs *)®s_1_2); + + if ((u32)regs_1_2.a0 == 0) { + unsigned long *destination = + (unsigned long *)smccc_soc_id_name; + + /* + * Copy regs_1_2.a1..regs_1_2.a17 to the + * smccc_soc_id_name string with consideration + * to the endianness of the values in a1..a17. + * As per Issue 1.6 of the Arm SMC Calling + * Convention, the string will be NUL terminated + * and padded, from the end of the string to + * the end of the 136 byte buffer, with NULs. + */ + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a1); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a2); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a3); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a4); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a5); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a6); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a7); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a8); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a9); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a10); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a11); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a12); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a13); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a14); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a15); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a16); + *destination++ = + cpu_to_le64p((const __u64 *)®s_1_2.a17); + } } } } @@ -67,6 +129,14 @@ s32 arm_smccc_get_soc_id_revision(void) } EXPORT_SYMBOL_GPL(arm_smccc_get_soc_id_revision); +char *arm_smccc_get_soc_id_name(void) +{ + if (strnlen(smccc_soc_id_name, sizeof(smccc_soc_id_name))) + return smccc_soc_id_name; + + return NULL; +} + static int __init smccc_devices_init(void) { struct platform_device *pdev; diff --git a/drivers/firmware/smccc/soc_id.c b/drivers/firmware/smccc/soc_id.c index 1990263fbba0..6f698c703868 100644 --- a/drivers/firmware/smccc/soc_id.c +++ b/drivers/firmware/smccc/soc_id.c @@ -72,6 +72,7 @@ static int __init smccc_soc_init(void) soc_dev_attr->soc_id = soc_id_str; soc_dev_attr->revision = soc_id_rev_str; soc_dev_attr->family = soc_id_jep106_id_str; + soc_dev_attr->machine = arm_smccc_get_soc_id_name(); soc_dev = soc_device_register(soc_dev_attr); if (IS_ERR(soc_dev)) { diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index 67f6fdf2e7cd..5935cf636135 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -333,6 +333,16 @@ s32 arm_smccc_get_soc_id_version(void); */ s32 arm_smccc_get_soc_id_revision(void); +/** + * arm_smccc_get_soc_id_name() + * + * Returns the SOC ID name. + * + * When ARM_SMCCC_ARCH_SOC_ID name is not present, returns NULL. + */ +char *arm_smccc_get_soc_id_name(void); + + /** * struct arm_smccc_res - Result from SMC/HVC call * @a0-a3 result values from registers 0 to 3