All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com,
	lukasz.luba@arm.com, james.quinlan@broadcom.com,
	Jonathan.Cameron@Huawei.com, etienne.carriere@linaro.org,
	thara.gopinath@linaro.org, vincent.guittot@linaro.org,
	souvik.chakravarty@arm.com
Subject: Re: [PATCH 02/11] firmware: arm_scmi: hide protocols' private data
Date: Thu, 15 Oct 2020 09:52:58 +0100	[thread overview]
Message-ID: <20201015085258.GB34395@e120937-lin> (raw)
In-Reply-To: <ae5b36f6-68de-d764-636d-ad12d3276302@gmail.com>

On Wed, Oct 14, 2020 at 12:19:43PM -0700, Florian Fainelli wrote:
> On 10/14/20 8:05 AM, Cristian Marussi wrote:
> > Protocols private data were meant to be used exclusively by protocol code
> > but they are currently exposed through the handle, so available also to
> > SCMI drivers: move them away from handle into instance specific data and
> > provide internal helpers to let protocols implementation set/get their own
> > private data from protocol code.
> > 
> > Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
> 
> [snip]
> 
> 
> > diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c
> > index 94bcad9a7d19..4e8dafc36d7e 100644
> > --- a/drivers/firmware/arm_scmi/clock.c
> > +++ b/drivers/firmware/arm_scmi/clock.c
> > @@ -240,7 +240,8 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id,
> >  	u32 flags = 0;
> >  	struct scmi_xfer *t;
> >  	struct scmi_clock_set_rate *cfg;
> > -	struct clock_info *ci = handle->clk_priv;
> > +	struct clock_info *ci =
> > +		scmi_get_proto_priv(handle, SCMI_PROTOCOL_CLOCK);
> 
> Having to repeat the protocol identifier is a bit error prone, does not
> scale really and it will not change throughout the lifecycle of the
> protocol handler. This is the least path of resistance though so it
> makes sense you went that route for now.
> 
> Instead of exposing scmi_handle towards the various operations what you
> could do is just pass down an encapsulating object which is comprised of
> a scmi_handle reference and the protocol's private structure already
> resolved?

That's really a good point.

Later on in the series when modularization is introduced you'll see that
I modified the protocol init callback to receive the core xfer_ops as a
parameter so that any protocol even if loaded as a module can use the
core xfer ops to built and generate SCMI msgs (without EXPORTing them),
but one thing which is not addressed by this series still, is the fact
that this way each protocol would have to specify for each of this ops
a protocol_id param, thing which, beside being cumbersome as you said,
lets the protocol potentially cheat, registering itself for protocol X
but then potentially building and sending SCMI msgs for any other
protocol: so your proposed solution could address also this case.

Thanks for the hint !

Cristian

> -- 
> Florian

WARNING: multiple messages have this Message-ID (diff)
From: Cristian Marussi <cristian.marussi@arm.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: vincent.guittot@linaro.org, sudeep.holla@arm.com,
	linux-kernel@vger.kernel.org, thara.gopinath@linaro.org,
	linux-arm-kernel@lists.infradead.org, james.quinlan@broadcom.com,
	Jonathan.Cameron@Huawei.com, souvik.chakravarty@arm.com,
	etienne.carriere@linaro.org, lukasz.luba@arm.com
Subject: Re: [PATCH 02/11] firmware: arm_scmi: hide protocols' private data
Date: Thu, 15 Oct 2020 09:52:58 +0100	[thread overview]
Message-ID: <20201015085258.GB34395@e120937-lin> (raw)
In-Reply-To: <ae5b36f6-68de-d764-636d-ad12d3276302@gmail.com>

On Wed, Oct 14, 2020 at 12:19:43PM -0700, Florian Fainelli wrote:
> On 10/14/20 8:05 AM, Cristian Marussi wrote:
> > Protocols private data were meant to be used exclusively by protocol code
> > but they are currently exposed through the handle, so available also to
> > SCMI drivers: move them away from handle into instance specific data and
> > provide internal helpers to let protocols implementation set/get their own
> > private data from protocol code.
> > 
> > Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
> 
> [snip]
> 
> 
> > diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c
> > index 94bcad9a7d19..4e8dafc36d7e 100644
> > --- a/drivers/firmware/arm_scmi/clock.c
> > +++ b/drivers/firmware/arm_scmi/clock.c
> > @@ -240,7 +240,8 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id,
> >  	u32 flags = 0;
> >  	struct scmi_xfer *t;
> >  	struct scmi_clock_set_rate *cfg;
> > -	struct clock_info *ci = handle->clk_priv;
> > +	struct clock_info *ci =
> > +		scmi_get_proto_priv(handle, SCMI_PROTOCOL_CLOCK);
> 
> Having to repeat the protocol identifier is a bit error prone, does not
> scale really and it will not change throughout the lifecycle of the
> protocol handler. This is the least path of resistance though so it
> makes sense you went that route for now.
> 
> Instead of exposing scmi_handle towards the various operations what you
> could do is just pass down an encapsulating object which is comprised of
> a scmi_handle reference and the protocol's private structure already
> resolved?

That's really a good point.

Later on in the series when modularization is introduced you'll see that
I modified the protocol init callback to receive the core xfer_ops as a
parameter so that any protocol even if loaded as a module can use the
core xfer ops to built and generate SCMI msgs (without EXPORTing them),
but one thing which is not addressed by this series still, is the fact
that this way each protocol would have to specify for each of this ops
a protocol_id param, thing which, beside being cumbersome as you said,
lets the protocol potentially cheat, registering itself for protocol X
but then potentially building and sending SCMI msgs for any other
protocol: so your proposed solution could address also this case.

Thanks for the hint !

Cristian

> -- 
> Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-10-15  8:53 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 15:05 [PATCH 00/11] SCMI vendor protocols and modularization Cristian Marussi
2020-10-14 15:05 ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 01/11] firmware: arm_scmi: review protocol registration interface Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-14 19:03   ` Florian Fainelli
2020-10-14 19:03     ` Florian Fainelli
2020-10-14 20:20     ` Sudeep Holla
2020-10-14 20:20       ` Sudeep Holla
2020-10-15  8:42     ` Cristian Marussi
2020-10-15  8:42       ` Cristian Marussi
2020-10-15  9:41   ` Vincent Guittot
2020-10-15  9:41     ` Vincent Guittot
2020-10-15  9:58     ` Cristian Marussi
2020-10-15  9:58       ` Cristian Marussi
2020-10-21  2:46   ` Thara Gopinath
2020-10-21  2:46     ` Thara Gopinath
2020-10-21 10:08     ` Cristian Marussi
2020-10-21 10:08       ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 02/11] firmware: arm_scmi: hide protocols' private data Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-14 19:19   ` Florian Fainelli
2020-10-14 19:19     ` Florian Fainelli
2020-10-15  8:52     ` Cristian Marussi [this message]
2020-10-15  8:52       ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 03/11] firmware: arm_scmi: introduce common protocol interface Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-21  2:47   ` Thara Gopinath
2020-10-21  2:47     ` Thara Gopinath
2020-10-21 10:27     ` Cristian Marussi
2020-10-21 10:27       ` Cristian Marussi
2020-10-26 13:07       ` Thara Gopinath
2020-10-26 13:07         ` Thara Gopinath
2020-10-28 21:04         ` Cristian Marussi
2020-10-28 21:04           ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 04/11] firmware: arm_scmi: refactor events registration Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 05/11] firmware: arm_scmi: make notify_priv really private Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 06/11] firmware: arm_scmi: add support for protocol modularization Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-21  2:47   ` Thara Gopinath
2020-10-21  2:47     ` Thara Gopinath
2020-10-21 10:30     ` Cristian Marussi
2020-10-21 10:30       ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 07/11] [DEBUG] firmware: arm_scmi: add example custom protocol Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 08/11] [DEBUG] arm64: dts: juno: add example custom protocol support Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 09/11] [DEBUG] firmware: arm_scmi: add example SCMI driver for custom protocol Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-14 15:55   ` Randy Dunlap
2020-10-14 15:55     ` Randy Dunlap
2020-10-14 16:44     ` Cristian Marussi
2020-10-14 16:44       ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 10/11] [DEBUG] firmware: arm_scmi: add custom_dummy SCMI devname Cristian Marussi
2020-10-14 15:05   ` Cristian Marussi
2020-10-21  2:49   ` Thara Gopinath
2020-10-21  2:49     ` Thara Gopinath
2020-10-21 11:35     ` Cristian Marussi
2020-10-21 11:35       ` Cristian Marussi
2020-10-26 12:37       ` Thara Gopinath
2020-10-26 12:37         ` Thara Gopinath
2020-10-28 21:28         ` Cristian Marussi
2020-10-28 21:28           ` Cristian Marussi
2020-10-14 15:05 ` [PATCH 11/11] [DEBUG][HACK] firmware: arm_scmi: force implemented protocol 0x99 Cristian Marussi
2020-10-14 15:05   ` 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=20201015085258.GB34395@e120937-lin \
    --to=cristian.marussi@arm.com \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=etienne.carriere@linaro.org \
    --cc=f.fainelli@gmail.com \
    --cc=james.quinlan@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=souvik.chakravarty@arm.com \
    --cc=sudeep.holla@arm.com \
    --cc=thara.gopinath@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.