Hi, On Thu, Oct 29, 2026 at 02:30:55PM +0530, Shivendra Pratap wrote: > ARM PSCI vendor-specific resets, require a 32-bit reset_type and a 64-bit > cookie as arguments. This cannot be implemented via the reboot-mode > framework, which supports a single 32-bit argument as magic value. > > Extend the reboot-mode framework to support up to three 32-bit arguments > as magic, per reboot-mode. > > Signed-off-by: Shivendra Pratap > --- Acked-by: Sebastian Reichel -- Sebastian > drivers/power/reset/reboot-mode.c | 46 +++++++++++++++++++++++++++------------ > include/linux/reboot-mode.h | 3 +++ > 2 files changed, 35 insertions(+), 14 deletions(-) > > diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c > index 3611bed341e1..328fa37598df 100644 > --- a/drivers/power/reset/reboot-mode.c > +++ b/drivers/power/reset/reboot-mode.c > @@ -20,7 +20,8 @@ > > struct mode_info { > const char *mode; > - u32 magic; > + u32 magic[3]; > + u32 count; > struct list_head list; > }; > > @@ -72,8 +73,7 @@ static const struct class reboot_mode_class = { > .dev_groups = reboot_mode_groups, > }; > > -static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot, > - const char *cmd) > +static struct mode_info *get_reboot_mode_info(struct reboot_mode_driver *reboot, const char *cmd) > { > const char *normal = "normal"; > struct mode_info *info; > @@ -84,11 +84,11 @@ static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot, > > list_for_each_entry(info, &reboot->head, list) > if (!strcmp(info->mode, cmd)) > - return info->magic; > + return info; > > /* try to match again, replacing characters impossible in DT */ > if (strscpy(cmd_, cmd, sizeof(cmd_)) == -E2BIG) > - return 0; > + return NULL; > > strreplace(cmd_, ' ', '-'); > strreplace(cmd_, ',', '-'); > @@ -96,21 +96,25 @@ static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot, > > list_for_each_entry(info, &reboot->head, list) > if (!strcmp(info->mode, cmd_)) > - return info->magic; > + return info; > > - return 0; > + return NULL; > } > > static int reboot_mode_notify(struct notifier_block *this, > unsigned long mode, void *cmd) > { > struct reboot_mode_driver *reboot; > - unsigned int magic; > + struct mode_info *info; > > reboot = container_of(this, struct reboot_mode_driver, reboot_notifier); > - magic = get_reboot_mode_magic(reboot, cmd); > - if (magic) > - reboot->write(reboot, magic); > + info = get_reboot_mode_info(reboot, cmd); > + if (info && info->count) { > + if (reboot->write_array) > + reboot->write_array(reboot, info->magic, info->count); > + else if (reboot->write && info->magic[0]) > + reboot->write(reboot, info->magic[0]); > + } > > return NOTIFY_DONE; > } > @@ -173,16 +177,22 @@ int reboot_mode_register(struct reboot_mode_driver *reboot) > struct property *prop; > struct device_node *np = reboot->dev->of_node; > size_t len = strlen(PREFIX); > - u32 magic; > + u32 magic[3]; > + int count; > int ret; > > INIT_LIST_HEAD(&reboot->head); > > for_each_property_of_node(np, prop) { > + memset(magic, 0, sizeof(magic)); > + > if (strncmp(prop->name, PREFIX, len)) > continue; > > - if (device_property_read_u32(reboot->dev, prop->name, &magic)) { > + count = device_property_count_u32(reboot->dev, prop->name); > + > + if (count <= 0 || count > ARRAY_SIZE(magic) || > + device_property_read_u32_array(reboot->dev, prop->name, magic, count)) { > dev_dbg(reboot->dev, "reboot mode %s without magic number\n", > prop->name); > continue; > @@ -194,7 +204,15 @@ int reboot_mode_register(struct reboot_mode_driver *reboot) > goto error; > } > > - info->magic = magic; > + if (!memchr_inv(magic, 0, count * sizeof(u32))) { > + dev_dbg(reboot->dev, "reboot mode %s with zero magic values\n", > + prop->name); > + info->count = 0; > + } else { > + memcpy(info->magic, magic, count * sizeof(u32)); > + info->count = count; > + } > + > info->mode = kstrdup_const(prop->name + len, GFP_KERNEL); > if (!info->mode) { > ret = -ENOMEM; > diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h > index 4a2abb38d1d6..29ae39935d69 100644 > --- a/include/linux/reboot-mode.h > +++ b/include/linux/reboot-mode.h > @@ -2,10 +2,13 @@ > #ifndef __REBOOT_MODE_H__ > #define __REBOOT_MODE_H__ > > +#include > + > struct reboot_mode_driver { > struct device *dev; > struct list_head head; > int (*write)(struct reboot_mode_driver *reboot, unsigned int magic); > + int (*write_array)(struct reboot_mode_driver *reboot, const u32 *magic, int count); > struct notifier_block reboot_notifier; > }; > > > -- > 2.34.1 > >