Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp658290ybl; Tue, 28 Jan 2020 09:36:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzmKR4Ns/3FfI94xW2a22FrmcCylvpTNtoIp79laFIJEP2a8ihcsb64EcqEKbDkH+4wYjkn X-Received: by 2002:aca:f411:: with SMTP id s17mr3717179oih.177.1580232996065; Tue, 28 Jan 2020 09:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580232996; cv=none; d=google.com; s=arc-20160816; b=gZQK9mSDbNDN66r0qTzzciszG80IpwB2CvJqkrYTZKYkeZ2VHv2hOrJKLTCltWOCXM t0tovNBU0zwNEUokJkuynOGpbeODO+ICTXeQf0YEPrarmREr3h8ra7csYjAukjDtmeUS u72yiLJJQyWyDZ3XaVxLnb5Wo+eyjfzkHX7fvY4uiAyJZMANVBVqR+gv/fYlTzXrQRdu vIuzrOmn1UnaqtiiIiib7OpRpYe9PTseHNiG1H+yhIznbmLBd/JWh/p1tng4PBG4NB/H zWZRVkyZ8AQNUrQwtArf2hgmuq3AbXrI9sjNpFwwPodS8j+N0bT+90TLl08yTCsCUH1H R/qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=h5CxeBaGZAekHpXStFtwT0/sce99ci9h2orqVPnvHAU=; b=vdiKJOGte2Nf1n0y8433iqPeTuJwbYZDx/6AZQOT412BxLLv5Jmz140UcGuJd4lj/u 3RirKfi2GHQtBYaKzXHxRM+X+uU1ck+0+Q1CZY1EKbQjYG+BoatZRHKNt7DrNcaAaqR2 3DlcxtteLFNB/iKebYP2BcAGnhxgMp0FJi0fUutsWu9uFCqa6T1fSV4u83Y54LgRWCs9 +0TE6zW+8bOj0QRGxuaIIlvj+HrZhhM90VDgKQn+rTvw4ftHTg9/1878Rmdygv2an8s0 Igsman7nKyx1JMUMDJDeA9FdihAR1JGrj8YYzAVClx/WK10qY+KSA1Nonu0MiB/9lPWN 5rFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y26si9281959otk.315.2020.01.28.09.36.24; Tue, 28 Jan 2020 09:36:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbgA1Rf3 (ORCPT + 99 others); Tue, 28 Jan 2020 12:35:29 -0500 Received: from foss.arm.com ([217.140.110.172]:32830 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgA1Rf2 (ORCPT ); Tue, 28 Jan 2020 12:35:28 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E7DB7328; Tue, 28 Jan 2020 09:35:27 -0800 (PST) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 97E773F52E; Tue, 28 Jan 2020 09:35:26 -0800 (PST) Date: Tue, 28 Jan 2020 17:35:24 +0000 From: Sudeep Holla To: Viresh Kumar Cc: arnd@arndb.de, jassisinghbrar@gmail.com, cristian.marussi@arm.com, peng.fan@nxp.com, peter.hilber@opensynergy.com, Vincent Guittot , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sudeep Holla Subject: Re: [PATCH V5] firmware: arm_scmi: Make scmi core independent of the transport type Message-ID: <20200128173524.GB36496@bogus> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > --- > @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 > #include > #include > +#include May be not needed anymore ? IIUC you had added it for offset and friends. > #include > > #include > @@ -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