From patchwork Mon Oct 31 16:18:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asmaa Mnebhi X-Patchwork-Id: 1697425 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=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (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 4N1JJ13Zd2z23lZ for ; Tue, 1 Nov 2022 03:19:13 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1opXVB-00079C-0L; Mon, 31 Oct 2022 16:19:05 +0000 Received: from mail-il-dmz.mellanox.com ([193.47.165.129] helo=mellanox.co.il) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1opXV8-00078a-Vl for kernel-team@lists.ubuntu.com; Mon, 31 Oct 2022 16:19:03 +0000 Received: from Internal Mail-Server by MTLPINE1 (envelope-from asmaa@mellanox.com) with SMTP; 31 Oct 2022 18:18:58 +0200 Received: from bu-vnc02.mtbu.labs.mlnx (bu-vnc02.mtbu.labs.mlnx [10.15.2.65]) by mtbu-labmailer.labs.mlnx (8.14.4/8.14.4) with ESMTP id 29VGIvC9029047; Mon, 31 Oct 2022 12:18:57 -0400 Received: (from asmaa@localhost) by bu-vnc02.mtbu.labs.mlnx (8.14.7/8.13.8/Submit) id 29VGIvZC031619; Mon, 31 Oct 2022 12:18:57 -0400 From: Asmaa Mnebhi To: kernel-team@lists.ubuntu.com Subject: [SRU][J:linux-bluefield][PATCH v1 1/1] UBUNTU: SAUCE: mlx-bootctl: support icm carveout eeprom region read/write Date: Mon, 31 Oct 2022 12:18:52 -0400 Message-Id: <20221031161852.31538-2-asmaa@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20221031161852.31538-1-asmaa@nvidia.com> References: <20221031161852.31538-1-asmaa@nvidia.com> MIME-Version: 1.0 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/1995296 The BlueField-3 ICM carveout feature will enable NIC FW to bypass the SMMU block to access DRAM memory. The amount of memory accessible by FW will be controlled by ARM. This patch enables setting the size of the large ICM carveout from userspace. The max size is 1TB, has a granularity of 128MB and will be passed and printed in hex. The size unit is MB. Signed-off-by: Asmaa Mnebhi --- drivers/platform/mellanox/mlxbf-bootctl.c | 40 +++++++++++++++++++++++ drivers/platform/mellanox/mlxbf-bootctl.h | 9 +++++ 2 files changed, 49 insertions(+) diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c index 2302e1e09c7e..e8877a19dda9 100644 --- a/drivers/platform/mellanox/mlxbf-bootctl.c +++ b/drivers/platform/mellanox/mlxbf-bootctl.c @@ -104,6 +104,7 @@ enum { /* This mutex is used to serialize MFG write and lock operations. */ static DEFINE_MUTEX(mfg_ops_lock); +static DEFINE_MUTEX(icm_ops_lock); #define MLNX_MFG_OOB_MAC_LEN ETH_ALEN #define MLNX_MFG_OPN_VAL_LEN 24 @@ -383,6 +384,43 @@ static ssize_t oob_mac_store(struct device_driver *drv, const char *buf, return res.a0 ? -EPERM : count; } +static ssize_t large_icm_show(struct device_driver *drv, char *buf) +{ + char icm_str[MAX_ICM_BUFFER_SIZE] = { 0 }; + struct arm_smccc_res res; + + arm_smccc_smc(MLNX_HANDLE_GET_ICM_INFO, 0, 0, 0, 0, + 0, 0, 0, &res); + if (res.a0) + return -EPERM; + + sprintf(icm_str, "0x%lx", res.a1); + + return snprintf(buf, sizeof(icm_str), "%s", icm_str); +} + +static ssize_t large_icm_store(struct device_driver *drv, const char *buf, + size_t count) +{ + struct arm_smccc_res res; + unsigned long icm_data; + int err; + + err = kstrtoul(buf, 16, &icm_data); + if (err) + return err; + + if (((icm_data != 0) && (icm_data < 0x80)) || + (icm_data > 0x100000) || (icm_data % 128)) + return -EPERM; + + mutex_lock(&icm_ops_lock); + arm_smccc_smc(MLNX_HANDLE_SET_ICM_INFO, icm_data, 0, 0, 0, 0, 0, 0, &res); + mutex_unlock(&icm_ops_lock); + + return res.a0 ? -EPERM : count; +} + static ssize_t opn_show(struct device_driver *drv, char *buf) { u64 opn_data[MLNX_MFG_VAL_QWORD_CNT(OPN)] = { 0 }; @@ -1170,6 +1208,7 @@ static DRIVER_ATTR_RW(uuid); static DRIVER_ATTR_RW(rev); static DRIVER_ATTR_WO(mfg_lock); static DRIVER_ATTR_RW(rsh_log); +static DRIVER_ATTR_RW(large_icm); static struct attribute *mbc_dev_attrs[] = { &driver_attr_post_reset_wdog.attr, @@ -1187,6 +1226,7 @@ static struct attribute *mbc_dev_attrs[] = { &driver_attr_rev.attr, &driver_attr_mfg_lock.attr, &driver_attr_rsh_log.attr, + &driver_attr_large_icm.attr, NULL }; diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h index 3e9dda829d6d..c70204770af3 100644 --- a/drivers/platform/mellanox/mlxbf-bootctl.h +++ b/drivers/platform/mellanox/mlxbf-bootctl.h @@ -95,6 +95,15 @@ #define MLNX_HANDLE_GET_MFG_INFO 0x8200000F #define MLNX_HANDLE_LOCK_MFG_INFO 0x82000011 +/* + * SMC function IDs to set and get the large ICM carveout size + * stored in the eeprom. + */ +#define MLNX_HANDLE_SET_ICM_INFO 0x82000012 +#define MLNX_HANDLE_GET_ICM_INFO 0x82000013 + +#define MAX_ICM_BUFFER_SIZE 10 + /* SMC function IDs for SiP Service queries */ #define MLNX_SIP_SVC_CALL_COUNT 0x8200ff00 #define MLNX_SIP_SVC_UID 0x8200ff01