Re: [PATCH 08/15] firmware: arm_scmi: Add and initialise protocol version to scmi_device structure

From: Sudeep Holla
Date: Thu Dec 12 2019 - 07:15:39 EST


On Wed, Dec 11, 2019 at 06:06:50PM +0000, Cristian Marussi wrote:
> On 10/12/2019 14:53, Sudeep Holla wrote:
> > It's useful to keep track of scmi protocol version in the scmi device
> > structure along with the protocol id. These can be used to expose the
> > information to the userspace via bus dev_groups attributes as well.
> >
> > Signed-off-by: Sudeep Holla <sudeep.holla@xxxxxxx>
> > ---
> > drivers/firmware/arm_scmi/clock.c | 6 +++++-
> > drivers/firmware/arm_scmi/perf.c | 6 +++++-
> > drivers/firmware/arm_scmi/power.c | 6 +++++-
> > drivers/firmware/arm_scmi/reset.c | 6 +++++-
> > drivers/firmware/arm_scmi/sensors.c | 6 +++++-
> > include/linux/scmi_protocol.h | 1 +
> > 6 files changed, 26 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c
> > index b567ec03f711..b68736ae7f88 100644
> > --- a/drivers/firmware/arm_scmi/clock.c
> > +++ b/drivers/firmware/arm_scmi/clock.c
> > @@ -318,8 +318,11 @@ static int scmi_clock_protocol_init(struct scmi_device *dev)
> > struct clock_info *cinfo;
> > struct scmi_handle *handle = dev->handle;
> >
> > - if (handle->clk_ops && handle->clk_priv)
> > + if (handle->clk_ops && handle->clk_priv) {
> > + cinfo = handle->clk_priv;
> > + dev->version = cinfo->version;
> > return 0; /* initialised already for the first device */
> > + }
> >
>
> This is the device specific init stuff which I would remove from this proto
> initialization, which is the reason for this proto_init to be invoked for
> all devices defined for such proto.
>

Agreed, this is something I could come up with quickly, I have to think about
this more for sure.

> I'd say to move dev->version initialization into the specific
> scmi_drv->probe which is called after scmi_protocol_init inside
> bus:scmi_dev_probe, after having disabled the proto_init after the first
> invocation, once the protocol is initialized, BUT this would result anyway
> in duplication since you'll have to fill dev->version from the custom
> protocol info in each of the related scmi drivers, and that would also mean
> delegating to a possible user scmi driver .probe an initialization which is
> then needed by the sysfs attribute exposed by the SCMI framework code.
>
I am trying to avoid that as it's just version and we should be able to
manage this in the scmi_bus layer. I agree what we have in these patches
are not so pretty.

Anyways, thanks a lot for all the review.

--
Regards,
Sudeep