From patchwork Thu Sep 5 23:30:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ron Li X-Patchwork-Id: 1981458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X0FwK5LXhz1yh1 for ; Fri, 6 Sep 2024 09:30:41 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1smLvs-0003jh-03; Thu, 05 Sep 2024 23:30:32 +0000 Received: from mail-dm6nam11on2051.outbound.protection.outlook.com ([40.107.223.51] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1smLvp-0003jG-9D for kernel-team@lists.ubuntu.com; Thu, 05 Sep 2024 23:30:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XZg9R3L+ZLGAug1iQUMzX1JCqd8+Xvq4fp1tCVq6AUq4dm/vsnZFHEuQY/cJk7EksGe2nzhO8x5JrpLbU1KbQSnYEnI0upQu7cLAR3sqr0h7O7TJaHRgETdCpfjEDH8ARwFQ+28h40vEY1fX+9ppfAPlt11+1GisggkEJd1XJ7yhlm4w6VNW/yQwNqiKBFpjBCSEAPULQxixMxxnMFsHEJJKnVuwUbX/lVVADg648Ew6TfuOel/b65ZmtiO14bBgC1A7f1akLn4Mcu+Vbz7scmJrhP0GVM8sbvvEocYdujp32z/ia2s9olN0Uh+m6dkncrPYSU4mVdp6nJhFSNTRFQ== 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=Pp0ksH8Bf4uFkxcrcVPHDWJEgMliB95Pw5vS7DgE6tY=; b=OQl52x1YmfkHuYM8uJXjnfqqPOImU6RlsoLAV3i2CLafR4e/TzFOPvscJELxzGvW0cnJKfRiyKNtKASt9KUvl6W29tPBYQgbQ4K3tEmRH6OwcDoKCreSPWqcbi01iwGHmA3LbvLqc+8skZpEp/KBJRxNpzxvwWETw+nQUOWTYQjLKr7+fWoq/lIDifKHtc5rO05/MsDLb9WRzTXVrxaad/EBL6f9v2FIMWosJtDrjAvNi3whIno9I7QtbVbCc6T7N4KFy4436ooLMBQfryViat4g65pG76/YFsm75SqFse+mWGjiW77FqS0Vu2ypAGBLUOFKX/Au8Z39EXUibADeyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=lists.ubuntu.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) Received: from SJ0PR03CA0029.namprd03.prod.outlook.com (2603:10b6:a03:33a::34) by BL1PR12MB5755.namprd12.prod.outlook.com (2603:10b6:208:392::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Thu, 5 Sep 2024 23:30:22 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:a03:33a:cafe::4c) by SJ0PR03CA0029.outlook.office365.com (2603:10b6:a03:33a::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.14 via Frontend Transport; Thu, 5 Sep 2024 23:30:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Thu, 5 Sep 2024 23:30:22 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 5 Sep 2024 16:30:10 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 5 Sep 2024 16:30:09 -0700 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 5 Sep 2024 16:30:09 -0700 From: Ron Li To: Subject: [SRU][J:linux-bluefield][PATCH 1/1] UBUNTU: SAUCE: mlxbf-bootctl supports RTC battery status read and clear Date: Thu, 5 Sep 2024 19:30:02 -0400 Message-ID: <20240905233002.29281-2-xiangrongl@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20240905233002.29281-1-xiangrongl@nvidia.com> References: <20240905233002.29281-1-xiangrongl@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E7:EE_|BL1PR12MB5755:EE_ X-MS-Office365-Filtering-Correlation-Id: 63e986a5-f142-4ab3-0901-08dcce02b62f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: FDDTuDJrfWZnPDNLp8dWuMeBcuaYQwtuEio8JdblZdUtseOj0pFXyiiBUh2UNBA+MbtGn1jBBXzNHciW5s9hb5n6+elv47dGl3O0+QM/Ia7vgzcoCccILMwnswCOVlSWdRp2tYY3+LsF/SGDWfKUYNZ7rWG6mw5WN6vjlIY8vxWjsNl/Cu2NuvvsfVQALWuq1C+DMsYqgU9CpRBonNbCC6sBduiptQwZ/Cf60GOajRxzhxOAXyIF1SQsPtAXcIUZE5GBrMxSpLPeT/ZP4edNpMJQdsrt+X0HBdjpN51i3fEsUuAudnB7N1i/ng8Dv7DOd1aY1QhUnzkIg0ZYFjT4jnNZBsgIi/JVzLvpxfD9q0GNt8J0wlhU7WgdzNTOdRLCGMzPGtSpOt2lFyIN8IU2QfAG0VZp79W2RGdMcj08p77xBOtzIAG1EssOBjFueo65oKlvo1bcFjOKOb1bBxK4Tyf7uGUE/IpwDuzezCCPd9FpMRfvN+8L3OzoqjhlXYTG7G5oNo3dg67P5OOVUmF3UcesKbsHtJxFDMoBy+gSUNCKaQuRLkOlEKF2KXFtdmYi/lP7j/gp7D/7aLh371/8OFTyEvc2H1ILPqDxatYF9TyxgOfpmo1aIYXCQLnzMyIaIN1oxTbbt/o9OGsQhPGUy2/vjaaMDNZPodgzDculAp4NpVJwQ64LetPP14ks1LKPVPhMWxMuuS+39f06JX2CzwgHHVU4x+KdSfzBYaABtIs6lNstNYNBP53F0si/IrOOpLWm/c1Vaxs442Zakq92L+GUFk6S7ie9h8lBh4+k/7q7+3q3lQtv/h6Uq2KXzFDNFVI2WC28j1qksX6MltXb0d233SFFE5xjBDUQ0PZYEV6iDLopdmatnGB+1nC4OQQxG7x9O4RuiVFA9OUKKt9T8JJ7JGzajOlyR/HjedUSLhiUjBv6bQwWx4ONFpORG8j5M/RpPKe+szCgr6bjcsbFmJqDZEv90m/9DfZfpDq28qfNe9s4o8/5EF4lkCA9a2jBDbqzNBWTN2hZMNh4L3PcRytj9u8E95u1OsEufmwEY4mGTiWKHxCLVjf4eU1WzUFbLcbbatB/G/m3xtDFoEEL3pQrEYxQBGegyaY94Vm+plpwWY7WRq6FNjN9DMiDIMvyzOiOO2dVn/PtyjGLmPIyPM4+pNzGr0g/CFwVoxRByjIQpuUdXkY81UfMlq8gVbUQwwkC2kwnF7sjSlfWlXkgzjtlkdcVY8mYvgU4CKcD/LatbrGe+Cfjikb8sBeL3/rrL5xHTH/SLP4i7a8pQQHG2ZoIwIDfrbn2iVWSGtm94gH4IQhuMjjb+/m4brGUF0dDUKYpDxAwkrrHeMV5hbYaqFqh3zNjxnzwPky+sy9Og+YlG5o3ucIMR6V/vhM+LgxLUJ3850v3K3u4xyTricuW1OCXjjxQBrfJxeJpenNAKg1/qJs78kLfsIkQ04dLzcZ+ X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2024 23:30:22.0622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63e986a5-f142-4ab3-0901-08dcce02b62f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5755 Received-SPF: softfail client-ip=40.107.223.51; envelope-from=xiangrongl@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: asmaa@nvidia.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2078881 Enable read and clear of the RTC battery low voltage status bit from user space. Signed-off-by: Xiangrong Li Reviewed-by: Asmaa Mnebhi --- drivers/platform/mellanox/mlxbf-bootctl.c | 20 ++++++++++++++++++++ drivers/platform/mellanox/mlxbf-bootctl.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c index 99924b0b149f..4a1f1a0e48b5 100644 --- a/drivers/platform/mellanox/mlxbf-bootctl.c +++ b/drivers/platform/mellanox/mlxbf-bootctl.c @@ -253,6 +253,7 @@ static const char * const mlxbf_rsh_log_level[] = { static DEFINE_MUTEX(icm_ops_lock); static DEFINE_MUTEX(os_up_lock); static DEFINE_MUTEX(mfg_ops_lock); +static DEFINE_MUTEX(rtc_ops_lock); /* * Objects are stored within the MFG partition per type. @@ -651,6 +652,23 @@ static ssize_t large_icm_store(struct device *dev, return res.a0 ? -EPERM : count; } +static ssize_t rtc_battery_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct arm_smccc_res res; + + mutex_lock(&rtc_ops_lock); + arm_smccc_smc(MLNX_HANDLE_GET_RTC_LOW_BATT, 0, 0, 0, 0, + 0, 0, 0, &res); + mutex_unlock(&rtc_ops_lock); + + if (res.a0) + return -EPERM; + + return snprintf(buf, PAGE_SIZE, "0x%lx", res.a1); +} + static ssize_t os_up_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1253,6 +1271,7 @@ static DEVICE_ATTR_RW(sn); static DEVICE_ATTR_RW(uuid); static DEVICE_ATTR_RW(rev); static DEVICE_ATTR_WO(mfg_lock); +static DEVICE_ATTR_RO(rtc_battery); static struct attribute *mlxbf_bootctl_attrs[] = { &dev_attr_post_reset_wdog.attr, @@ -1272,6 +1291,7 @@ static struct attribute *mlxbf_bootctl_attrs[] = { &dev_attr_uuid.attr, &dev_attr_rev.attr, &dev_attr_mfg_lock.attr, + &dev_attr_rtc_battery.attr, NULL }; diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h index 1299750a8661..1207e638180e 100644 --- a/drivers/platform/mellanox/mlxbf-bootctl.h +++ b/drivers/platform/mellanox/mlxbf-bootctl.h @@ -103,6 +103,11 @@ */ #define MLNX_HANDLE_OS_UP 0x82000014 +/* + * SMC function ID to get and clear the RTC low voltage bit + */ +#define MLNX_HANDLE_GET_RTC_LOW_BATT 0x82000023 + /* SMC function IDs for SiP Service queries */ #define MLXBF_BOOTCTL_SIP_SVC_CALL_COUNT 0x8200ff00 #define MLXBF_BOOTCTL_SIP_SVC_UID 0x8200ff01