Messages in this thread | | | Date | Tue, 28 Jan 2020 17:35:24 +0000 | From | Sudeep Holla <> | Subject | Re: [PATCH V5] firmware: arm_scmi: Make scmi core independent of the transport type |
| |
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
| |