Message ID | 20230602212715.7626-2-asmaa@nvidia.com |
---|---|
State | New |
Headers | show |
Acked-by: Bartlomiej Zolnierkiewicz <bartlomiej.zolnierkiewicz@canonical.com> On Fri, Jun 2, 2023 at 11:28 PM Asmaa Mnebhi <asmaa@nvidia.com> wrote: > > BugLink: https://bugs.launchpad.net/bugs/2013383 > > Add a new SMC call which allows setting the ARM boot progress state to "OS is up". > > Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com> > --- > drivers/platform/mellanox/mlx-bootctl.c | 23 +++++++++++++++++++++++ > drivers/platform/mellanox/mlx-bootctl.h | 5 +++++ > 2 files changed, 28 insertions(+) > > diff --git a/drivers/platform/mellanox/mlx-bootctl.c b/drivers/platform/mellanox/mlx-bootctl.c > index 88f3269da960..afec67851a1e 100644 > --- a/drivers/platform/mellanox/mlx-bootctl.c > +++ b/drivers/platform/mellanox/mlx-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(os_up_lock); > > #define MLNX_MFG_OOB_MAC_LEN ETH_ALEN > #define MLNX_MFG_OPN_VAL_LEN 24 > @@ -709,6 +710,26 @@ static ssize_t mfg_lock_store(struct device_driver *drv, const char *buf, > return count; > } > > +static ssize_t os_up_store(struct device_driver *drv, const char *buf, > + size_t count) > +{ > + unsigned long val; > + int err; > + > + err = kstrtoul(buf, 10, &val); > + if (err) > + return err; > + > + if (val != 1) > + return -EINVAL; > + > + mutex_lock(&os_up_lock); > + smc_call0(MLNX_HANDLE_OS_UP); > + mutex_unlock(&os_up_lock); > + > + return count; > +} > + > /* Log header format. */ > #define RSH_LOG_TYPE_SHIFT 56 > #define RSH_LOG_LEN_SHIFT 48 > @@ -1170,6 +1191,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_WO(os_up); > > static struct attribute *mbc_dev_attrs[] = { > &driver_attr_post_reset_wdog.attr, > @@ -1187,6 +1209,7 @@ static struct attribute *mbc_dev_attrs[] = { > &driver_attr_rev.attr, > &driver_attr_mfg_lock.attr, > &driver_attr_rsh_log.attr, > + &driver_attr_os_up.attr, > NULL > }; > > diff --git a/drivers/platform/mellanox/mlx-bootctl.h b/drivers/platform/mellanox/mlx-bootctl.h > index a937ecf16551..bcb13ab8c2fd 100644 > --- a/drivers/platform/mellanox/mlx-bootctl.h > +++ b/drivers/platform/mellanox/mlx-bootctl.h > @@ -111,6 +111,11 @@ > #define MLNX_HANDLE_GET_MFG_INFO 0x8200000F > #define MLNX_HANDLE_LOCK_MFG_INFO 0x82000011 > > +/* > + * 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 MLNX_SIP_SVC_CALL_COUNT 0x8200ff00 > #define MLNX_SIP_SVC_UID 0x8200ff01
diff --git a/drivers/platform/mellanox/mlx-bootctl.c b/drivers/platform/mellanox/mlx-bootctl.c index 88f3269da960..afec67851a1e 100644 --- a/drivers/platform/mellanox/mlx-bootctl.c +++ b/drivers/platform/mellanox/mlx-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(os_up_lock); #define MLNX_MFG_OOB_MAC_LEN ETH_ALEN #define MLNX_MFG_OPN_VAL_LEN 24 @@ -709,6 +710,26 @@ static ssize_t mfg_lock_store(struct device_driver *drv, const char *buf, return count; } +static ssize_t os_up_store(struct device_driver *drv, const char *buf, + size_t count) +{ + unsigned long val; + int err; + + err = kstrtoul(buf, 10, &val); + if (err) + return err; + + if (val != 1) + return -EINVAL; + + mutex_lock(&os_up_lock); + smc_call0(MLNX_HANDLE_OS_UP); + mutex_unlock(&os_up_lock); + + return count; +} + /* Log header format. */ #define RSH_LOG_TYPE_SHIFT 56 #define RSH_LOG_LEN_SHIFT 48 @@ -1170,6 +1191,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_WO(os_up); static struct attribute *mbc_dev_attrs[] = { &driver_attr_post_reset_wdog.attr, @@ -1187,6 +1209,7 @@ static struct attribute *mbc_dev_attrs[] = { &driver_attr_rev.attr, &driver_attr_mfg_lock.attr, &driver_attr_rsh_log.attr, + &driver_attr_os_up.attr, NULL }; diff --git a/drivers/platform/mellanox/mlx-bootctl.h b/drivers/platform/mellanox/mlx-bootctl.h index a937ecf16551..bcb13ab8c2fd 100644 --- a/drivers/platform/mellanox/mlx-bootctl.h +++ b/drivers/platform/mellanox/mlx-bootctl.h @@ -111,6 +111,11 @@ #define MLNX_HANDLE_GET_MFG_INFO 0x8200000F #define MLNX_HANDLE_LOCK_MFG_INFO 0x82000011 +/* + * 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 MLNX_SIP_SVC_CALL_COUNT 0x8200ff00 #define MLNX_SIP_SVC_UID 0x8200ff01
BugLink: https://bugs.launchpad.net/bugs/2013383 Add a new SMC call which allows setting the ARM boot progress state to "OS is up". Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com> --- drivers/platform/mellanox/mlx-bootctl.c | 23 +++++++++++++++++++++++ drivers/platform/mellanox/mlx-bootctl.h | 5 +++++ 2 files changed, 28 insertions(+)