[RFC PATCH 1/7] firmware: arm_scmi: Define a common SCMI_MAX_PROTOCOLS value

Cristian Marussi cristian.marussi at arm.com
Wed Jun 25 06:59:46 PDT 2025


On Tue, Jun 24, 2025 at 11:13:51AM +0800, Peng Fan wrote:
> On Fri, Jun 20, 2025 at 08:28:07PM +0100, Cristian Marussi wrote:
> >Add a common definition of SCMI_MAX_PROTOCOLS and use it all over the
> >SCMI stack.
> >

Hi Peng,

thanks for having a look.

> >Signed-off-by: Cristian Marussi <cristian.marussi at arm.com>
> >---
> > drivers/firmware/arm_scmi/notify.c | 4 +---
> > include/linux/scmi_protocol.h      | 3 +++
> > 2 files changed, 4 insertions(+), 3 deletions(-)
> >
> >diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
> >index e160ecb22948..27a53a6729dd 100644
> >--- a/drivers/firmware/arm_scmi/notify.c
> >+++ b/drivers/firmware/arm_scmi/notify.c
> >@@ -94,8 +94,6 @@
> > #include "common.h"
> > #include "notify.h"
> > 
> >-#define SCMI_MAX_PROTO		256
> >-
> > #define PROTO_ID_MASK		GENMASK(31, 24)
> > #define EVT_ID_MASK		GENMASK(23, 16)
> > #define SRC_ID_MASK		GENMASK(15, 0)
> >@@ -1652,7 +1650,7 @@ int scmi_notification_init(struct scmi_handle *handle)
> > 	ni->gid = gid;
> > 	ni->handle = handle;
> > 
> >-	ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTO,
> >+	ni->registered_protocols = devm_kcalloc(handle->dev, SCMI_MAX_PROTOCOLS,
> > 						sizeof(char *), GFP_KERNEL);
> > 	if (!ni->registered_protocols)
> > 		goto err;
> >diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
> >index 688466a0e816..6f8d36e1f8fc 100644
> >--- a/include/linux/scmi_protocol.h
> >+++ b/include/linux/scmi_protocol.h
> >@@ -926,8 +926,11 @@ enum scmi_std_protocol {
> > 	SCMI_PROTOCOL_VOLTAGE = 0x17,
> > 	SCMI_PROTOCOL_POWERCAP = 0x18,
> > 	SCMI_PROTOCOL_PINCTRL = 0x19,
> >+	SCMI_PROTOCOL_LAST = 0xff,
> 
> The enum says this is std protocol, but 0x80~0xff is for vendor extension.
> It might confuse others to keep "SCMI_PROTOCOL_LAST" here.
> 

Yes indeed. This patch was lingering around since ages in my trees and
it is probably to review in itself.

> > };
> > 
> >+#define SCMI_MAX_PROTOCOLS	(SCMI_PROTOCOL_LAST + 1)
> 
> How about "#define SCMI_MAX_PROTOCOLS 256" as the line you removed in notify.c.
> 

Yes, probably the easiest thing to do.

Thanks,
Cristian



More information about the linux-arm-kernel mailing list