[PATCH v3 0/2] SCMI multiple vendor protocol support

From: Cristian Marussi
Date: Thu Apr 18 2024 - 05:51:58 EST


Hi all,

this is meant to address the possibility of having multiple vendors
implementing distinct SCMI vendor protocols with possibly the same
overlapping protocol number without the need of crafting the Kconfig
at compile time to include only wanted protos

Basic idea is simple:

- vendor protos HAS to be 'tagged' at build time with a vendor_id
- vendor protos COULD also optionally be tagged at build time with
sub_vendor_id and implementation version

- at init all the build vendor protos are registered with the SCMI core
using a key derived from the above tags

- at SCMI probe time the platform is identified via Base protocol as
usual and all the required vendor protos (i.e. IDs defined in the DT
as usual) are loaded (if required) after a lookup process based on the
following rules:

+ protocol DB is searched using the platform/Base runtime provided tags

<vendor> / <sub_vendor> / <impl_ver>

using the following search logic (keys), first match:

1. proto_id / <vendor_id> / <sub_vendor_id> / <impl_ver>

2. proto_id / <vendor_id> / <sub_vendor_id> / 0

3. proto_id / <vendor_id> / NULL / 0

IOW, closest match, depending on how much fine grained is your
protocol tuned (tagged) for the platform.

I am still doubtful about the usage of <impl_ver>, and tempted to drop it
since we have anyway protocol version and NEGOTIATE_PROTOCOL_VERSION
to deal with slight difference in fw revision...

In V2 a dedicated vendors dir/Makefile/Kconfig is added: not sure if we
want to provide also a way of grouping SCMI vendor protocol headers under
include/linux...open to any suggestion/opinion.

Based on sudeep/for-next/scmi/updates on top of

commit bb48844a08a0 ("clk: scmi: Add support for get/set duty_cycle operations")

Any feedback welcome

Thanks,
Cristian

---
v2 -> v3
- renaming base vendor proto define to SCMI_PROTOCOL_VENDOR_BASE
- adding a dedicated helper __scmi_vendor_protocol_lookup to cleanup protocol
lookup
v1 -> v2
- added a dedicated vendors/ directory and Kconfig under arm_scmi/

Cristian Marussi (2):
firmware: arm_scmi: Add support for multiple vendors custom protocols
firmware: arm_scmi: Add dedicated vendor protocols submenu

drivers/firmware/arm_scmi/Kconfig | 2 +
drivers/firmware/arm_scmi/Makefile | 1 +
drivers/firmware/arm_scmi/driver.c | 169 ++++++++++++++++++---
drivers/firmware/arm_scmi/protocols.h | 15 ++
drivers/firmware/arm_scmi/vendors/Kconfig | 4 +
drivers/firmware/arm_scmi/vendors/Makefile | 2 +
6 files changed, 171 insertions(+), 22 deletions(-)
create mode 100644 drivers/firmware/arm_scmi/vendors/Kconfig
create mode 100644 drivers/firmware/arm_scmi/vendors/Makefile

--
2.44.0