* [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state.
@ 2023-08-09 16:28 Asmaa Mnebhi
2023-08-09 16:28 ` [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read Asmaa Mnebhi
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Asmaa Mnebhi @ 2023-08-09 16:28 UTC (permalink / raw)
To: markgross, vadimp, hdegoede, linux-kernel; +Cc: Asmaa Mnebhi
Support 2 new features for the mlxbf-bootctl driver:
1) Enable reading and writing the size of the memory region
dedicated to the large ICM carveout.
2) Enable setting the BlueField ARM boot state to "os up".
The SMC call involved will handle updating the state in
BlueField registers.
Asmaa Mnebhi (2):
mlxbf-bootctl: Support the large icmc write/read
mlxbf-bootctl: Support setting the ARM boot state to "OS up"
drivers/platform/mellanox/mlxbf-bootctl.c | 67 +++++++++++++++++++++++
drivers/platform/mellanox/mlxbf-bootctl.h | 19 +++++++
2 files changed, 86 insertions(+)
--
2.30.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read
2023-08-09 16:28 [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Asmaa Mnebhi
@ 2023-08-09 16:28 ` Asmaa Mnebhi
2023-08-09 16:40 ` Vadim Pasternak
2023-08-09 16:28 ` [PATCH v2 2/2] mlxbf-bootctl: Support setting the ARM boot state to "OS up" Asmaa Mnebhi
2023-08-09 20:16 ` [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Hans de Goede
2 siblings, 1 reply; 6+ messages in thread
From: Asmaa Mnebhi @ 2023-08-09 16:28 UTC (permalink / raw)
To: markgross, vadimp, hdegoede, linux-kernel; +Cc: Asmaa Mnebhi
Enable reading and writing the size of the memory region associated
with the large ICM carveout.
The max size of the large ICM carveout 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 <asmaa@nvidia.com>
---
v1->v2:
- added defines for icmc related integers
- removed unnecessary parentheses.
drivers/platform/mellanox/mlxbf-bootctl.c | 42 +++++++++++++++++++++++
drivers/platform/mellanox/mlxbf-bootctl.h | 14 ++++++++
2 files changed, 56 insertions(+)
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c
index fb9f7815c6cd..52d1272478a4 100644
--- a/drivers/platform/mellanox/mlxbf-bootctl.c
+++ b/drivers/platform/mellanox/mlxbf-bootctl.c
@@ -79,6 +79,8 @@ static void __iomem *mlxbf_rsh_scratch_buf_data;
static const char * const mlxbf_rsh_log_level[] = {
"INFO", "WARN", "ERR", "ASSERT"};
+static DEFINE_MUTEX(icm_ops_lock);
+
/* ARM SMC call which is atomic and no need for lock. */
static int mlxbf_bootctl_smc(unsigned int smc_op, int smc_arg)
{
@@ -391,6 +393,44 @@ static ssize_t rsh_log_store(struct device *dev,
return count;
}
+static ssize_t large_icm_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct arm_smccc_res res;
+
+ mutex_lock(&icm_ops_lock);
+ arm_smccc_smc(MLNX_HANDLE_GET_ICM_INFO, 0, 0, 0, 0,
+ 0, 0, 0, &res);
+ mutex_unlock(&icm_ops_lock);
+ if (res.a0)
+ return -EPERM;
+
+ return snprintf(buf, PAGE_SIZE, "0x%lx", res.a1);
+}
+
+static ssize_t large_icm_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct arm_smccc_res res;
+ unsigned long icm_data;
+ int err;
+
+ err = kstrtoul(buf, MLXBF_LARGE_ICMC_MAX_STRING_SIZE, &icm_data);
+ if (err)
+ return err;
+
+ if ((icm_data != 0 && icm_data < MLXBF_LARGE_ICMC_SIZE_MIN) ||
+ icm_data > MLXBF_LARGE_ICMC_SIZE_MAX || icm_data % MLXBF_LARGE_ICMC_GRANULARITY)
+ 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 DEVICE_ATTR_RW(post_reset_wdog);
static DEVICE_ATTR_RW(reset_action);
static DEVICE_ATTR_RW(second_reset_action);
@@ -398,6 +438,7 @@ static DEVICE_ATTR_RO(lifecycle_state);
static DEVICE_ATTR_RO(secure_boot_fuse_state);
static DEVICE_ATTR_WO(fw_reset);
static DEVICE_ATTR_WO(rsh_log);
+static DEVICE_ATTR_RW(large_icm);
static struct attribute *mlxbf_bootctl_attrs[] = {
&dev_attr_post_reset_wdog.attr,
@@ -407,6 +448,7 @@ static struct attribute *mlxbf_bootctl_attrs[] = {
&dev_attr_secure_boot_fuse_state.attr,
&dev_attr_fw_reset.attr,
&dev_attr_rsh_log.attr,
+ &dev_attr_large_icm.attr,
NULL
};
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h
index b48243f60a59..fc5019c90fc5 100644
--- a/drivers/platform/mellanox/mlxbf-bootctl.h
+++ b/drivers/platform/mellanox/mlxbf-bootctl.h
@@ -81,6 +81,15 @@
*/
#define MLXBF_BOOTCTL_FW_RESET 0x8200000D
+/*
+ * 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 MLXBF_BOOTCTL_SIP_SVC_CALL_COUNT 0x8200ff00
#define MLXBF_BOOTCTL_SIP_SVC_UID 0x8200ff01
@@ -106,4 +115,9 @@
/* Additional value to disable the MLXBF_BOOTCTL_SET_SECOND_RESET_ACTION. */
#define MLXBF_BOOTCTL_NONE 0x7fffffff /* Don't change next boot action */
+#define MLXBF_LARGE_ICMC_MAX_STRING_SIZE 16
+#define MLXBF_LARGE_ICMC_SIZE_MIN 0x80
+#define MLXBF_LARGE_ICMC_SIZE_MAX 0x100000
+#define MLXBF_LARGE_ICMC_GRANULARITY MLXBF_LARGE_ICMC_SIZE_MIN
+
#endif /* __MLXBF_BOOTCTL_H__ */
--
2.30.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] mlxbf-bootctl: Support setting the ARM boot state to "OS up"
2023-08-09 16:28 [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Asmaa Mnebhi
2023-08-09 16:28 ` [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read Asmaa Mnebhi
@ 2023-08-09 16:28 ` Asmaa Mnebhi
2023-08-09 20:16 ` [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Hans de Goede
2 siblings, 0 replies; 6+ messages in thread
From: Asmaa Mnebhi @ 2023-08-09 16:28 UTC (permalink / raw)
To: markgross, vadimp, hdegoede, linux-kernel; +Cc: Asmaa Mnebhi
The BlueField has internal registers to store the ARM boot states.
Support setting the BlueField ARM boot state to "OS up".
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
---
v1->v2:
- No changes made to this patch. It has already been approved.
This is just to update [PATCH v2 1/2]
drivers/platform/mellanox/mlxbf-bootctl.c | 25 +++++++++++++++++++++++
drivers/platform/mellanox/mlxbf-bootctl.h | 5 +++++
2 files changed, 30 insertions(+)
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c
index 52d1272478a4..0bf29eee1e70 100644
--- a/drivers/platform/mellanox/mlxbf-bootctl.c
+++ b/drivers/platform/mellanox/mlxbf-bootctl.c
@@ -80,6 +80,7 @@ static const char * const mlxbf_rsh_log_level[] = {
"INFO", "WARN", "ERR", "ASSERT"};
static DEFINE_MUTEX(icm_ops_lock);
+static DEFINE_MUTEX(os_up_lock);
/* ARM SMC call which is atomic and no need for lock. */
static int mlxbf_bootctl_smc(unsigned int smc_op, int smc_arg)
@@ -431,6 +432,28 @@ static ssize_t large_icm_store(struct device *dev,
return res.a0 ? -EPERM : count;
}
+static ssize_t os_up_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct arm_smccc_res res;
+ unsigned long val;
+ int err;
+
+ err = kstrtoul(buf, 10, &val);
+ if (err)
+ return err;
+
+ if (val != 1)
+ return -EINVAL;
+
+ mutex_lock(&os_up_lock);
+ arm_smccc_smc(MLNX_HANDLE_OS_UP, 0, 0, 0, 0, 0, 0, 0, &res);
+ mutex_unlock(&os_up_lock);
+
+ return count;
+}
+
static DEVICE_ATTR_RW(post_reset_wdog);
static DEVICE_ATTR_RW(reset_action);
static DEVICE_ATTR_RW(second_reset_action);
@@ -439,6 +462,7 @@ static DEVICE_ATTR_RO(secure_boot_fuse_state);
static DEVICE_ATTR_WO(fw_reset);
static DEVICE_ATTR_WO(rsh_log);
static DEVICE_ATTR_RW(large_icm);
+static DEVICE_ATTR_WO(os_up);
static struct attribute *mlxbf_bootctl_attrs[] = {
&dev_attr_post_reset_wdog.attr,
@@ -449,6 +473,7 @@ static struct attribute *mlxbf_bootctl_attrs[] = {
&dev_attr_fw_reset.attr,
&dev_attr_rsh_log.attr,
&dev_attr_large_icm.attr,
+ &dev_attr_os_up.attr,
NULL
};
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h
index fc5019c90fc5..613963d448f2 100644
--- a/drivers/platform/mellanox/mlxbf-bootctl.h
+++ b/drivers/platform/mellanox/mlxbf-bootctl.h
@@ -90,6 +90,11 @@
#define MAX_ICM_BUFFER_SIZE 10
+/*
+ * SMC function ID to set the ARM boot state to up
+ */
+#define MLNX_HANDLE_OS_UP 0x82000014
+
/* SMC function IDs for SiP Service queries */
#define MLXBF_BOOTCTL_SIP_SVC_CALL_COUNT 0x8200ff00
#define MLXBF_BOOTCTL_SIP_SVC_UID 0x8200ff01
--
2.30.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read
2023-08-09 16:28 ` [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read Asmaa Mnebhi
@ 2023-08-09 16:40 ` Vadim Pasternak
0 siblings, 0 replies; 6+ messages in thread
From: Vadim Pasternak @ 2023-08-09 16:40 UTC (permalink / raw)
To: Asmaa Mnebhi, markgross@kernel.org, hdegoede@redhat.com,
linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Asmaa Mnebhi <asmaa@nvidia.com>
> Sent: Wednesday, 9 August 2023 19:29
> To: markgross@kernel.org; Vadim Pasternak <vadimp@nvidia.com>;
> hdegoede@redhat.com; linux-kernel@vger.kernel.org
> Cc: Asmaa Mnebhi <asmaa@nvidia.com>
> Subject: [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read
>
> Enable reading and writing the size of the memory region associated with the
> large ICM carveout.
> The max size of the large ICM carveout 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 <asmaa@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
> ---
> v1->v2:
> - added defines for icmc related integers
> - removed unnecessary parentheses.
>
> drivers/platform/mellanox/mlxbf-bootctl.c | 42 +++++++++++++++++++++++
> drivers/platform/mellanox/mlxbf-bootctl.h | 14 ++++++++
> 2 files changed, 56 insertions(+)
>
> diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c
> b/drivers/platform/mellanox/mlxbf-bootctl.c
> index fb9f7815c6cd..52d1272478a4 100644
> --- a/drivers/platform/mellanox/mlxbf-bootctl.c
> +++ b/drivers/platform/mellanox/mlxbf-bootctl.c
> @@ -79,6 +79,8 @@ static void __iomem *mlxbf_rsh_scratch_buf_data;
> static const char * const mlxbf_rsh_log_level[] = {
> "INFO", "WARN", "ERR", "ASSERT"};
>
> +static DEFINE_MUTEX(icm_ops_lock);
> +
> /* ARM SMC call which is atomic and no need for lock. */ static int
> mlxbf_bootctl_smc(unsigned int smc_op, int smc_arg) { @@ -391,6 +393,44
> @@ static ssize_t rsh_log_store(struct device *dev,
> return count;
> }
>
> +static ssize_t large_icm_show(struct device *dev,
> + struct device_attribute *attr, char *buf) {
> + struct arm_smccc_res res;
> +
> + mutex_lock(&icm_ops_lock);
> + arm_smccc_smc(MLNX_HANDLE_GET_ICM_INFO, 0, 0, 0, 0,
> + 0, 0, 0, &res);
> + mutex_unlock(&icm_ops_lock);
> + if (res.a0)
> + return -EPERM;
> +
> + return snprintf(buf, PAGE_SIZE, "0x%lx", res.a1); }
> +
> +static ssize_t large_icm_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count) {
> + struct arm_smccc_res res;
> + unsigned long icm_data;
> + int err;
> +
> + err = kstrtoul(buf, MLXBF_LARGE_ICMC_MAX_STRING_SIZE,
> &icm_data);
> + if (err)
> + return err;
> +
> + if ((icm_data != 0 && icm_data < MLXBF_LARGE_ICMC_SIZE_MIN) ||
> + icm_data > MLXBF_LARGE_ICMC_SIZE_MAX || icm_data %
> MLXBF_LARGE_ICMC_GRANULARITY)
> + 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 DEVICE_ATTR_RW(post_reset_wdog); static
> DEVICE_ATTR_RW(reset_action); static
> DEVICE_ATTR_RW(second_reset_action);
> @@ -398,6 +438,7 @@ static DEVICE_ATTR_RO(lifecycle_state); static
> DEVICE_ATTR_RO(secure_boot_fuse_state);
> static DEVICE_ATTR_WO(fw_reset);
> static DEVICE_ATTR_WO(rsh_log);
> +static DEVICE_ATTR_RW(large_icm);
>
> static struct attribute *mlxbf_bootctl_attrs[] = {
> &dev_attr_post_reset_wdog.attr,
> @@ -407,6 +448,7 @@ static struct attribute *mlxbf_bootctl_attrs[] = {
> &dev_attr_secure_boot_fuse_state.attr,
> &dev_attr_fw_reset.attr,
> &dev_attr_rsh_log.attr,
> + &dev_attr_large_icm.attr,
> NULL
> };
>
> diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h
> b/drivers/platform/mellanox/mlxbf-bootctl.h
> index b48243f60a59..fc5019c90fc5 100644
> --- a/drivers/platform/mellanox/mlxbf-bootctl.h
> +++ b/drivers/platform/mellanox/mlxbf-bootctl.h
> @@ -81,6 +81,15 @@
> */
> #define MLXBF_BOOTCTL_FW_RESET 0x8200000D
>
> +/*
> + * 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 MLXBF_BOOTCTL_SIP_SVC_CALL_COUNT 0x8200ff00
> #define MLXBF_BOOTCTL_SIP_SVC_UID 0x8200ff01
> @@ -106,4 +115,9 @@
> /* Additional value to disable the
> MLXBF_BOOTCTL_SET_SECOND_RESET_ACTION. */
> #define MLXBF_BOOTCTL_NONE 0x7fffffff /* Don't change next boot
> action */
>
> +#define MLXBF_LARGE_ICMC_MAX_STRING_SIZE 16
> +#define MLXBF_LARGE_ICMC_SIZE_MIN 0x80
> +#define MLXBF_LARGE_ICMC_SIZE_MAX 0x100000
> +#define MLXBF_LARGE_ICMC_GRANULARITY
> MLXBF_LARGE_ICMC_SIZE_MIN
> +
> #endif /* __MLXBF_BOOTCTL_H__ */
> --
> 2.30.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state.
2023-08-09 16:28 [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Asmaa Mnebhi
2023-08-09 16:28 ` [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read Asmaa Mnebhi
2023-08-09 16:28 ` [PATCH v2 2/2] mlxbf-bootctl: Support setting the ARM boot state to "OS up" Asmaa Mnebhi
@ 2023-08-09 20:16 ` Hans de Goede
2023-08-09 20:17 ` Asmaa Mnebhi
2 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2023-08-09 20:16 UTC (permalink / raw)
To: Asmaa Mnebhi, markgross, vadimp, linux-kernel
HI,
On 8/9/23 18:28, Asmaa Mnebhi wrote:
> Support 2 new features for the mlxbf-bootctl driver:
> 1) Enable reading and writing the size of the memory region
> dedicated to the large ICM carveout.
> 2) Enable setting the BlueField ARM boot state to "os up".
> The SMC call involved will handle updating the state in
> BlueField registers.
>
> Asmaa Mnebhi (2):
> mlxbf-bootctl: Support the large icmc write/read
> mlxbf-bootctl: Support setting the ARM boot state to "OS up"
>
> drivers/platform/mellanox/mlxbf-bootctl.c | 67 +++++++++++++++++++++++
> drivers/platform/mellanox/mlxbf-bootctl.h | 19 +++++++
> 2 files changed, 86 insertions(+)
Thank you for your patch-series, I've applied the series to my
review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state.
2023-08-09 20:16 ` [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Hans de Goede
@ 2023-08-09 20:17 ` Asmaa Mnebhi
0 siblings, 0 replies; 6+ messages in thread
From: Asmaa Mnebhi @ 2023-08-09 20:17 UTC (permalink / raw)
To: Hans de Goede, markgross@kernel.org, Vadim Pasternak,
linux-kernel@vger.kernel.org
> > drivers/platform/mellanox/mlxbf-bootctl.c | 67
> > +++++++++++++++++++++++ drivers/platform/mellanox/mlxbf-bootctl.h |
> > 19 +++++++
> > 2 files changed, 86 insertions(+)
>
> Thank you for your patch-series, I've applied the series to my review-hans
> branch:
> https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-
> x86.git/log/?h=review-hans
>
> Once I've run some tests on this branch the patches there will be added to the
> platform-drivers-x86/for-next branch and eventually will be included in the
> pdx86 pull-request to Linus for the next merge-window.
>
Thank you very much Hans!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-08-09 20:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 16:28 [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Asmaa Mnebhi
2023-08-09 16:28 ` [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read Asmaa Mnebhi
2023-08-09 16:40 ` Vadim Pasternak
2023-08-09 16:28 ` [PATCH v2 2/2] mlxbf-bootctl: Support setting the ARM boot state to "OS up" Asmaa Mnebhi
2023-08-09 20:16 ` [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Hans de Goede
2023-08-09 20:17 ` Asmaa Mnebhi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox