LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	cristian.marussi@arm.com, peng.fan@nxp.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH V2] firmware: arm_scmi: Make scmi core independent of transport type
Date: Fri, 10 Jan 2020 12:15:56 +0100	[thread overview]
Message-ID: <CAK8P3a1MLyP4ooyEDiBF1fE0BJGocgDmO1f5Qrvn_W5eqahz8g@mail.gmail.com> (raw)
In-Reply-To: <3f5567ec928e20963d729350e6d674c4acb0c7a0.1578648530.git.viresh.kumar@linaro.org>

On Fri, Jan 10, 2020 at 10:43 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> The SCMI specification is fairly independent of the transport protocol,
> which can be a simple mailbox (already implemented) or anything else.
> The current Linux implementation however is very much dependent of the
> mailbox transport layer.
>
> This patch makes the SCMI core code (driver.c) independent of the
> mailbox transport layer and moves all mailbox related code to a new
> file: mailbox.c.
>
> We can now implement more transport protocols to transport SCMI
> messages, some of the transport protocols getting discussed currently
> are SMC/HVC, SPCI (built on top of SMC/HVC), OPTEE based mailbox
> (similar to SPCI), and vitio based transport as alternative to mailbox.
>
> The transport protocols just need to provide struct scmi_desc, which
> also implements the struct scmi_transport_ops.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> V2:
> - Dropped __iomem from payload data.

Simply dropping the __iomem isn't much better, now you get other
type mismatches.

> - Moved transport ops to scmi_desc, and that has a per transport
>   instance now which is differentiated using the compatible string.
> - Converted IS_ERR_OR_NULL to IS_ERR.

These look good to me.

> + * @payload: Transmit/Receive payload area
> + * @dev: Reference to device in the SCMI hierarchy corresponding to this
> + *      channel
> + * @handle: Pointer to SCMI entity handle
> + * @transport_info: Transport layer related information
> + */
> +struct scmi_chan_info {
> +       void *payload;
> +       struct device *dev;
> +       struct scmi_handle *handle;
> +       void *transport_info;
> +};

Maybe you can wrap the scmi_chan_info inside of another
structure that contains  the payload pointer, and use container_of
to convert between them?

It's not obvious which parts of the structure should be shared and
which are transport specific.

> -static void scmi_rx_callback(struct mbox_client *cl, void *m)
> +void scmi_rx_callback(struct scmi_chan_info *cinfo, struct scmi_xfer *t)
>  {
>         u8 msg_type;
>         u32 msg_hdr;
>         u16 xfer_id;
>         struct scmi_xfer *xfer;
> -       struct scmi_chan_info *cinfo = client_to_scmi_chan_info(cl);
>         struct device *dev = cinfo->dev;
>         struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
>         struct scmi_xfers_info *minfo = &info->tx_minfo;
> -       struct scmi_shared_mem __iomem *mem = cinfo->payload;
> +       struct scmi_shared_mem *mem = cinfo->payload;
>
>         msg_hdr = ioread32(&mem->msg_header);

This is where it goes wrong: you cannot pass a kernel pointer
without __iomem into ioread32(). Building the driver with sparse
(using "make C=1") should show you this and possibly other
related conversion bugs.

       Arnd

  reply	other threads:[~2020-01-10 11:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  9:43 Viresh Kumar
2020-01-10 11:15 ` Arnd Bergmann [this message]
2020-01-13  6:41   ` Viresh Kumar
2020-01-13 11:36     ` Arnd Bergmann
2020-01-14  9:26       ` Viresh Kumar
2020-01-14  9:56         ` Arnd Bergmann
2020-01-14 11:11           ` Viresh Kumar
2020-01-14 11:17             ` Arnd Bergmann
2020-01-14 17:41               ` Sudeep Holla
2020-01-15  8:20               ` Peng Fan
2020-01-15 19:37             ` peter.hilber
2020-01-14 11:03         ` Sudeep Holla
2020-01-15  8:53 ` Peng Fan
2020-01-15 14:33   ` Sudeep Holla
2020-01-17  2:26     ` Peng Fan
2020-01-16 15:21 ` kbuild test robot

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=CAK8P3a1MLyP4ooyEDiBF1fE0BJGocgDmO1f5Qrvn_W5eqahz8g@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=cristian.marussi@arm.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=sudeep.holla@arm.com \
    --cc=viresh.kumar@linaro.org \
    --subject='Re: [PATCH V2] firmware: arm_scmi: Make scmi core independent of transport type' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).