mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state.
cover mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state.
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 | 14 +++++ 2 files changed, 81 insertions(+)
Signature · 1 line
2.30.1
PATCH 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.
--- drivers/platform/mellanox/mlxbf-bootctl.c | 42 +++++++++++++++++++++++ drivers/platform/mellanox/mlxbf-bootctl.h | 9 +++++ 2 files changed, 51 insertions(+)
drivers/platform/mellanox/mlxbf-bootctl.c +42 -0
@@ -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,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 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 };
drivers/platform/mellanox/mlxbf-bootctl.h +9 -0
@@ -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
Signature · 1 line
2.30.1
Vadim Pasternak
maintainerRE: [PATCH v1 1/2] mlxbf-bootctl: Support the large icmc write/read
Quoted 51 lines
-----Original Message-----
From: Asmaa Mnebhi <[email protected]>
Sent: Wednesday, 9 August 2023 17:15
To: [email protected]; Vadim Pasternak <[email protected]>; [email protected]; [email protected]
Cc: Asmaa Mnebhi <[email protected]>
Subject: [PATCH v1 1/2] mlxbf-bootctl: Support the large icmc write/readEnable 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 <[email protected]>--- drivers/platform/mellanox/mlxbf-bootctl.c | 42 +++++++++++++++++++++++ drivers/platform/mellanox/mlxbf-bootctl.h | 9 +++++ 2 files changed, 51 insertions(+)drivers/platform/mellanox/mlxbf-bootctl.c +2
-0@@ -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 @@ staticssize_trsh_log_store(struct device *dev,drivers/platform/mellanox/mlxbf-bootctl.c +13
-0return 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); } +
drivers/platform/mellanox/mlxbf-bootctl.c static ssize_t rsh_log_store(struct device *dev, · line 421
Quoted 10 lines
drivers/platform/mellanox/mlxbf-bootctl.c +10
-0+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,16 , &icm_data); +if (err) +return err;
I suggest using define instead of 16.
drivers/platform/mellanox/mlxbf-bootctl.c static ssize_t rsh_log_store(struct device *dev, · line 425
Quoted 4 lines
drivers/platform/mellanox/mlxbf-bootctl.c +4
-0+ +if (((icm_data !=0 ) && (icm_data <0x80 )) || + (icm_data >0x100000 ) || (icm_data %128 )) +return -EPERM ;
You can remove reduce '()' and I suggest for to use for consistency 128:
Instead of 128 and 0x80
If ((icm_data > 0 && icm_data < 128)
Probably consider to use defines also for the above magic.
Quoted 51 lines
drivers/platform/mellanox/mlxbf-bootctl.c +3
-0+ +mutex_lock (&icm_ops_lock); + arm_smccc_smc(MLNX_HANDLE_SET_ICM_INFO, icm_data, 0, 0, 0,0, 0, 0, &res);
drivers/platform/mellanox/mlxbf-bootctl.c +5
-0+mutex_unlock (&icm_ops_lock); + +return res.a0 ? -EPERM : count; +} + static DEVICE_ATTR_RW(post_reset_wdog); static
DEVICE_ATTR_RW(reset_action); staticDEVICE_ATTR_RW(second_reset_action);drivers/platform/mellanox/mlxbf-bootctl.c +2
-0@@ -398,6 +438,7 @@ static DEVICE_ATTR_RO(lifecycle_state); staticDEVICE_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 };drivers/platform/mellanox/mlxbf-bootctl.h +9
-1@@ -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 --2.30.1
RE: [PATCH v1 1/2] mlxbf-bootctl: Support the large icmc write/read
Quoted 5 lines
drivers/platform/mellanox/mlxbf-bootctl.c static ssize_t rsh_log_store(struct device *dev, · line 421
Quoted 3 lines
drivers/platform/mellanox/mlxbf-bootctl.c +3
-0+ err =kstrtoul (buf,16 , &icm_data); +if (err) +return err;I suggest using define instead of 16.
Done.
Quoted 10 lines
drivers/platform/mellanox/mlxbf-bootctl.c static ssize_t rsh_log_store(struct device *dev, · line 425
Quoted 4 lines
drivers/platform/mellanox/mlxbf-bootctl.c +4
-0+ +if (((icm_data !=0 ) && (icm_data <0x80 )) || + (icm_data >0x100000 ) || (icm_data %128 )) +return -EPERM ;You can remove reduce '()' and I suggest for to use for consistency 128:
Instead of 128 and0x80If ((icm_data > 0 && icm_data < 128)Probably consider to use defines also for the above magic.
Done.
PATCH 2/2 mlxbf-bootctl: Support setting the ARM boot state to "OS up"
In reply to Asmaa MnebhiThe BlueField has internal registers to store the ARM boot states. Support setting the BlueField ARM boot state to "OS up".
--- drivers/platform/mellanox/mlxbf-bootctl.c | 25 +++++++++++++++++++++++ drivers/platform/mellanox/mlxbf-bootctl.h | 5 +++++ 2 files changed, 30 insertions(+)
drivers/platform/mellanox/mlxbf-bootctl.c +25 -0
@@ -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 };
drivers/platform/mellanox/mlxbf-bootctl.h +5 -0
@@ -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
Signature · 1 line
2.30.1
RE: [PATCH v1 2/2] mlxbf-bootctl: Support setting the ARM boot state to "OS up"
Quoted 11 lines
-----Original Message-----
From: Asmaa Mnebhi <[email protected]>
Sent: Wednesday, 9 August 2023 17:15
To: [email protected]; Vadim Pasternak <[email protected]>; [email protected]; [email protected]
Cc: Asmaa Mnebhi <[email protected]>
Subject: [PATCH v1 2/2] mlxbf-bootctl: Support setting the ARM boot state to "OS up"
Quoted 4 lines
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 <[email protected]>
Quoted 81 lines
--- drivers/platform/mellanox/mlxbf-bootctl.c | 25 +++++++++++++++++++++++ drivers/platform/mellanox/mlxbf-bootctl.h | 5 +++++ 2 files changed, 30 insertions(+)drivers/platform/mellanox/mlxbf-bootctl.c +1
-0@@ -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 @@ staticssize_tlarge_icm_store(struct device *dev,drivers/platform/mellanox/mlxbf-bootctl.c +22
-0return 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); staticDEVICE_ATTR_RW(second_reset_action);drivers/platform/mellanox/mlxbf-bootctl.c +2
-0@@ -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 };drivers/platform/mellanox/mlxbf-bootctl.h +4
-1@@ -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