public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: peng.fan@nxp.com, arnd@arndb.de, jassisinghbrar@gmail.com,
	linux-kernel@vger.kernel.org, peter.hilber@opensynergy.com,
	linux-arm-kernel@lists.infradead.org,
	Sudeep Holla <sudeep.holla@arm.com>,
	cristian.marussi@arm.com
Subject: Re: [PATCH V5] firmware: arm_scmi: Make scmi core independent of the transport type
Date: Tue, 28 Jan 2020 17:35:24 +0000	[thread overview]
Message-ID: <20200128173524.GB36496@bogus> (raw)
In-Reply-To: <f170b33989b426ac095952634fcd1bf45b86a7a3.1580208329.git.viresh.kumar@linaro.org>

On Tue, Jan 28, 2020 at 04:24:19PM +0530, Viresh Kumar 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 on 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.
>
> The transport protocols just need to provide struct scmi_transport_ops,
> with its version of the callbacks to enable exchange of SCMI messages.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> @Sudeep: Please help getting this tested as well :)
>

I did a quick test and it just works fine ;)

> diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
> index df35358ff324..805482c41ab4 100644
> --- a/drivers/firmware/arm_scmi/common.h
> +++ b/drivers/firmware/arm_scmi/common.h
> @@ -13,6 +13,7 @@
>  #include <linux/errno.h>
>  #include <linux/kernel.h>
>  #include <linux/scmi_protocol.h>
> +#include <linux/stddef.h>

May be not needed anymore ? IIUC you had added it for offset and friends.

>  #include <linux/types.h>
>
>  #include <asm/unaligned.h>
> @@ -33,8 +34,8 @@ enum scmi_common_cmd {
>  /**
>   * struct scmi_msg_resp_prot_version - Response for a message
>   *
> - * @major_version: Major version of the ABI that firmware supports
>   * @minor_version: Minor version of the ABI that firmware supports
> + * @major_version: Major version of the ABI that firmware supports
>   *
>   * In general, ABI version changes follow the rule that minor version increments
>   * are backward compatible. Major revision changes in ABI may not be
> @@ -47,6 +48,19 @@ struct scmi_msg_resp_prot_version {
>  	__le16 major_version;
>  };
>
> +#define MSG_ID_MASK		GENMASK(7, 0)
> +#define MSG_XTRACT_ID(hdr)	FIELD_GET(MSG_ID_MASK, (hdr))
> +#define MSG_TYPE_MASK		GENMASK(9, 8)
> +#define MSG_XTRACT_TYPE(hdr)	FIELD_GET(MSG_TYPE_MASK, (hdr))
> +#define MSG_TYPE_COMMAND	0
> +#define MSG_TYPE_DELAYED_RESP	2
> +#define MSG_TYPE_NOTIFICATION	3
> +#define MSG_PROTOCOL_ID_MASK	GENMASK(17, 10)
> +#define MSG_XTRACT_PROT_ID(hdr)	FIELD_GET(MSG_PROTOCOL_ID_MASK, (hdr))
> +#define MSG_TOKEN_ID_MASK	GENMASK(27, 18)
> +#define MSG_XTRACT_TOKEN(hdr)	FIELD_GET(MSG_TOKEN_ID_MASK, (hdr))
> +#define MSG_TOKEN_MAX		(MSG_XTRACT_TOKEN(MSG_TOKEN_ID_MASK) + 1)
> +
>  /**
>   * struct scmi_msg_hdr - Message(Tx/Rx) header
>   *
> @@ -67,6 +81,33 @@ struct scmi_msg_hdr {
>  	bool poll_completion;
>  };
>
> +/**
> + * pack_scmi_header() - packs and returns 32-bit header
> + *
> + * @hdr: pointer to header containing all the information on message id,
> + *	protocol id and sequence id.
> + *
> + * Return: 32-bit packed message header to be sent to the platform.
> + */
> +static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr)
> +{
> +	return FIELD_PREP(MSG_ID_MASK, hdr->id) |
> +		FIELD_PREP(MSG_TOKEN_ID_MASK, hdr->seq) |
> +		FIELD_PREP(MSG_PROTOCOL_ID_MASK, hdr->protocol_id);
> +}
> +
> +/**
> + * unpack_scmi_header() - unpacks and records message and protocol id
> + *
> + * @msg_hdr: 32-bit packed message header sent from the platform
> + * @hdr: pointer to header to fetch message and protocol id.
> + */
> +static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr)
> +{
> +	hdr->id = MSG_XTRACT_ID(msg_hdr);
> +	hdr->protocol_id = MSG_XTRACT_PROT_ID(msg_hdr);
> +}
> +

I prefer this moving of the above code to header as separate patch,
just to keep it easy for bisection in case we break anything with new
transport layer. There's nothing I see, but to be safer. You can also
claim no functionality change with that patch then ;)

>  /**
>   * struct scmi_info - Structure representing a SCMI instance
>   *
>   * @dev: Device pointer
>   * @desc: SoC description for this instance
> - * @handle: Instance of SCMI handle to send to clients
>   * @version: SCMI revision information containing protocol version,
>   *	implementation version and (sub-)vendor identification.
> + * @handle: Instance of SCMI handle to send to clients

I saw this and couple other doc changes that are not related to this patch
but are fixed to existing code ? Can be separate patch again if I am not
wrong.

Otherwise looks good. Since we are not adding module support, I am fine
even if we have to make changes to transport ops bit later if required
and realised when adding new transport. Let us see if Peter has any major
objections.

--
Regards,
Sudeep

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

  reply	other threads:[~2020-01-28 17:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28 10:54 [PATCH V5] firmware: arm_scmi: Make scmi core independent of the transport type Viresh Kumar
2020-01-28 17:35 ` Sudeep Holla [this message]
2020-01-30 11:58   ` Peter Hilber
2020-01-31  4:33     ` Viresh Kumar

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=20200128173524.GB36496@bogus \
    --to=sudeep.holla@arm.com \
    --cc=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=peter.hilber@opensynergy.com \
    --cc=viresh.kumar@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