From: Sudeep Holla <sudeep.holla@arm.com>
To: Cristian Marussi <cristian.marussi@arm.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Sudeep Holla <sudeep.holla@arm.com>,
james.quinlan@broadcom.com, f.fainelli@gmail.com,
vincent.guittot@linaro.org, peng.fan@oss.nxp.com,
michal.simek@amd.com, quic_sibis@quicinc.com,
konrad.dybcio@linaro.org, souvik.chakravarty@arm.com
Subject: Re: [PATCH v2 1/2] firmware: arm_scmi: Add support for multiple vendors custom protocols
Date: Wed, 17 Apr 2024 14:20:57 +0100 [thread overview]
Message-ID: <20240417132057.2s5s2mzgub2nnyd3@bogus> (raw)
In-Reply-To: <Zh_Dyi_rJGpW4qZr@pluto>
On Wed, Apr 17, 2024 at 01:42:50PM +0100, Cristian Marussi wrote:
> 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
Agreed, that's why I was asking rather than requesting you to change 😉.
Even I was not sure by the time I completed writing the above one 😁.
It may make it bit easier to read.
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-04-17 13:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 9:30 [PATCH v2 0/2] SCMI multiple vendor protocol support Cristian Marussi
2024-04-08 9:30 ` [PATCH v2 1/2] firmware: arm_scmi: Add support for multiple vendors custom protocols Cristian Marussi
2024-04-17 12:32 ` Sudeep Holla
2024-04-17 12:42 ` Cristian Marussi
2024-04-17 13:20 ` Sudeep Holla [this message]
2024-04-08 9:30 ` [PATCH v2 2/2] firmware: arm_scmi: Add dedicated vendor protocols submenu Cristian Marussi
2024-04-17 12:09 ` Sudeep Holla
2024-04-17 12:54 ` Cristian Marussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240417132057.2s5s2mzgub2nnyd3@bogus \
--to=sudeep.holla@arm.com \
--cc=cristian.marussi@arm.com \
--cc=f.fainelli@gmail.com \
--cc=james.quinlan@broadcom.com \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=peng.fan@oss.nxp.com \
--cc=quic_sibis@quicinc.com \
--cc=souvik.chakravarty@arm.com \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox