Skip to content

Commit 13fba87

Browse files
cris-masudeep-holla
authored andcommitted
firmware: arm_scmi: Add priv parameter to scmi_rx_callback
Add a new opaque void *priv parameter to scmi_rx_callback which can be optionally provided by the transport layer when invoking scmi_rx_callback and that will be passed back to the transport layer in xfer->priv. This can be used by transports that needs to keep track of their specific data structures together with the valid xfers. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Cristian Marussi <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 6062566 commit 13fba87

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

drivers/firmware/arm_scmi/common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ struct scmi_msg {
172172
* - SCMI_XFER_SENT_OK -> SCMI_XFER_DRESP_OK
173173
* (Missing synchronous response is assumed OK and ignored)
174174
* @lock: A spinlock to protect state and busy fields.
175+
* @priv: A pointer for transport private usage.
175176
*/
176177
struct scmi_xfer {
177178
int transfer_id;
@@ -192,6 +193,7 @@ struct scmi_xfer {
192193
int state;
193194
/* A lock to protect state and busy fields */
194195
spinlock_t lock;
196+
void *priv;
195197
};
196198

197199
/*
@@ -417,7 +419,7 @@ extern const struct scmi_desc scmi_mailbox_desc;
417419
extern const struct scmi_desc scmi_smc_desc;
418420
#endif
419421

420-
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr);
422+
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv);
421423
void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
422424

423425
/* shmem related declarations */

drivers/firmware/arm_scmi/driver.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@ static inline void scmi_clear_channel(struct scmi_info *info,
609609
info->desc->ops->clear_channel(cinfo);
610610
}
611611

612-
static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr)
612+
static void scmi_handle_notification(struct scmi_chan_info *cinfo,
613+
u32 msg_hdr, void *priv)
613614
{
614615
struct scmi_xfer *xfer;
615616
struct device *dev = cinfo->dev;
@@ -627,6 +628,8 @@ static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr)
627628
}
628629

629630
unpack_scmi_header(msg_hdr, &xfer->hdr);
631+
if (priv)
632+
xfer->priv = priv;
630633
info->desc->ops->fetch_notification(cinfo, info->desc->max_msg_size,
631634
xfer);
632635
scmi_notify(cinfo->handle, xfer->hdr.protocol_id,
@@ -641,7 +644,8 @@ static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr)
641644
scmi_clear_channel(info, cinfo);
642645
}
643646

644-
static void scmi_handle_response(struct scmi_chan_info *cinfo, u32 msg_hdr)
647+
static void scmi_handle_response(struct scmi_chan_info *cinfo,
648+
u32 msg_hdr, void *priv)
645649
{
646650
struct scmi_xfer *xfer;
647651
struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
@@ -656,6 +660,8 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo, u32 msg_hdr)
656660
if (xfer->hdr.type == MSG_TYPE_DELAYED_RESP)
657661
xfer->rx.len = info->desc->max_msg_size;
658662

663+
if (priv)
664+
xfer->priv = priv;
659665
info->desc->ops->fetch_response(cinfo, xfer);
660666

661667
trace_scmi_rx_done(xfer->transfer_id, xfer->hdr.id,
@@ -677,24 +683,25 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo, u32 msg_hdr)
677683
*
678684
* @cinfo: SCMI channel info
679685
* @msg_hdr: Message header
686+
* @priv: Transport specific private data.
680687
*
681688
* Processes one received message to appropriate transfer information and
682689
* signals completion of the transfer.
683690
*
684691
* NOTE: This function will be invoked in IRQ context, hence should be
685692
* as optimal as possible.
686693
*/
687-
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr)
694+
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv)
688695
{
689696
u8 msg_type = MSG_XTRACT_TYPE(msg_hdr);
690697

691698
switch (msg_type) {
692699
case MSG_TYPE_NOTIFICATION:
693-
scmi_handle_notification(cinfo, msg_hdr);
700+
scmi_handle_notification(cinfo, msg_hdr, priv);
694701
break;
695702
case MSG_TYPE_COMMAND:
696703
case MSG_TYPE_DELAYED_RESP:
697-
scmi_handle_response(cinfo, msg_hdr);
704+
scmi_handle_response(cinfo, msg_hdr, priv);
698705
break;
699706
default:
700707
WARN_ONCE(1, "received unknown msg_type:%d\n", msg_type);

drivers/firmware/arm_scmi/mailbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void rx_callback(struct mbox_client *cl, void *m)
4343
{
4444
struct scmi_mailbox *smbox = client_to_scmi_mailbox(cl);
4545

46-
scmi_rx_callback(smbox->cinfo, shmem_read_header(smbox->shmem));
46+
scmi_rx_callback(smbox->cinfo, shmem_read_header(smbox->shmem), NULL);
4747
}
4848

4949
static bool mailbox_chan_available(struct device *dev, int idx)

drivers/firmware/arm_scmi/smc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
154154
if (scmi_info->irq)
155155
wait_for_completion(&scmi_info->tx_complete);
156156

157-
scmi_rx_callback(scmi_info->cinfo, shmem_read_header(scmi_info->shmem));
157+
scmi_rx_callback(scmi_info->cinfo,
158+
shmem_read_header(scmi_info->shmem), NULL);
158159

159160
mutex_unlock(&scmi_info->shmem_lock);
160161

0 commit comments

Comments
 (0)