Messages in this thread Patch in this message | | | Date | Wed, 17 Apr 2024 13:42:50 +0100 | From | Cristian Marussi <> | Subject | Re: [PATCH v2 1/2] firmware: arm_scmi: Add support for multiple vendors custom protocols |
| |
On Wed, Apr 17, 2024 at 01:32:08PM +0100, Sudeep Holla wrote: > On Mon, Apr 08, 2024 at 10:30:51AM +0100, Cristian Marussi wrote: > > Add a mechanism to be able to tag vendor protocol modules at compile-time > > with a vendor/sub_vendor string and an implementation version and then to > > choose to load, at run-time, only those vendor protocol modules matching > > as close as possible the vendor/subvendor identification advertised by > > the SCMI platform server. > > > > In this way, any in-tree existent vendor protocol module can be build and > > shipped by default in a single kernel image, even when using the same > > clashing protocol identification numbers, since the SCMI core will take > > care at run-time to load only the ones pertinent to the running system. > > > > Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> > > --- > > drivers/firmware/arm_scmi/driver.c | 165 ++++++++++++++++++++++---- > > drivers/firmware/arm_scmi/protocols.h | 15 +++ > > 2 files changed, 158 insertions(+), 22 deletions(-) > > > > diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c > > index d0091459a276..aa18202054a5 100644 > > --- a/drivers/firmware/arm_scmi/driver.c > > +++ b/drivers/firmware/arm_scmi/driver.c > > [...] > > > +static const struct scmi_protocol * > > +scmi_vendor_protocol_lookup(int protocol_id, char *vendor_id, > > + char *sub_vendor_id, u32 impl_ver) > > +{ > > + unsigned long key; > > + struct scmi_protocol *proto = NULL; > > + > > + /* Searching for closest match ...*/ > > + key = scmi_protocol_key_calculate(protocol_id, vendor_id, > > + sub_vendor_id, impl_ver); > > + if (key) > > + proto = xa_load(&scmi_protocols, key); > > + > > + if (proto) > > + return proto; > > + > > + /* Any match on vendor/sub_vendor ? */ > > + if (impl_ver) { > > + key = scmi_protocol_key_calculate(protocol_id, vendor_id, > > + sub_vendor_id, 0); > > + if (key) > > + proto = xa_load(&scmi_protocols, key); > > + > > + if (proto) > > + return proto; > > + } > > + > > + /* Any match on just the vendor ? */ > > + if (sub_vendor_id) { > > + key = scmi_protocol_key_calculate(protocol_id, vendor_id, > > + NULL, 0); > > + if (key) > > + proto = xa_load(&scmi_protocols, key); > > + } > > > > I see a pattern here, can be simplify/compress by something like below ? > > static const struct scmi_protocol * > __scmi_vendor_protocol_lookup(int protocol_id, char *vendor_id, > char *sub_vendor_id, u32 impl_ver) > { > unsigned long key; > struct scmi_protocol *proto = NULL; > > key = scmi_protocol_key_calculate(protocol_id, vendor_id, > sub_vendor_id, impl_ver); > if (key) > proto = xa_load(&scmi_protocols, key); > > return proto; > }
Sure...was not completely sure to proceed that way because only 2 lines were saved for a each block....bit indeed is more clear...I'll d in V3 > > [...] > > > diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h > > index 317d3fb32676..45ee8b35f56d 100644 > > --- a/drivers/firmware/arm_scmi/protocols.h > > +++ b/drivers/firmware/arm_scmi/protocols.h > > @@ -29,6 +29,8 @@ > > #define PROTOCOL_REV_MAJOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x)))) > > #define PROTOCOL_REV_MINOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x)))) > > > > +#define SCMI_PROTOCOL_VENDOR 0x80 > > + > > s/SCMI_PROTOCOL_VENDOR/SCMI_PROTOCOL_VENDOR_BASE/ > > as I expect 0x80 to be used by most vendors. >
I'll do.
Thanks for the review. Cristian
| |