Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20210803131024.40280-15-cristian.marussi@arm.com
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

authored by

Cristian Marussi and committed by
Sudeep Holla
13fba878 60625667

+18 -8
+3 -1
drivers/firmware/arm_scmi/common.h
··· 172 172 * - SCMI_XFER_SENT_OK -> SCMI_XFER_DRESP_OK 173 173 * (Missing synchronous response is assumed OK and ignored) 174 174 * @lock: A spinlock to protect state and busy fields. 175 + * @priv: A pointer for transport private usage. 175 176 */ 176 177 struct scmi_xfer { 177 178 int transfer_id; ··· 193 192 int state; 194 193 /* A lock to protect state and busy fields */ 195 194 spinlock_t lock; 195 + void *priv; 196 196 }; 197 197 198 198 /* ··· 419 417 extern const struct scmi_desc scmi_smc_desc; 420 418 #endif 421 419 422 - void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr); 420 + void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv); 423 421 void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id); 424 422 425 423 /* shmem related declarations */
+12 -5
drivers/firmware/arm_scmi/driver.c
··· 609 609 info->desc->ops->clear_channel(cinfo); 610 610 } 611 611 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) 613 614 { 614 615 struct scmi_xfer *xfer; 615 616 struct device *dev = cinfo->dev; ··· 628 627 } 629 628 630 629 unpack_scmi_header(msg_hdr, &xfer->hdr); 630 + if (priv) 631 + xfer->priv = priv; 631 632 info->desc->ops->fetch_notification(cinfo, info->desc->max_msg_size, 632 633 xfer); 633 634 scmi_notify(cinfo->handle, xfer->hdr.protocol_id, ··· 644 641 scmi_clear_channel(info, cinfo); 645 642 } 646 643 647 - static void scmi_handle_response(struct scmi_chan_info *cinfo, u32 msg_hdr) 644 + static void scmi_handle_response(struct scmi_chan_info *cinfo, 645 + u32 msg_hdr, void *priv) 648 646 { 649 647 struct scmi_xfer *xfer; 650 648 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); ··· 660 656 if (xfer->hdr.type == MSG_TYPE_DELAYED_RESP) 661 657 xfer->rx.len = info->desc->max_msg_size; 662 658 659 + if (priv) 660 + xfer->priv = priv; 663 661 info->desc->ops->fetch_response(cinfo, xfer); 664 662 665 663 trace_scmi_rx_done(xfer->transfer_id, xfer->hdr.id, ··· 683 677 * 684 678 * @cinfo: SCMI channel info 685 679 * @msg_hdr: Message header 680 + * @priv: Transport specific private data. 686 681 * 687 682 * Processes one received message to appropriate transfer information and 688 683 * signals completion of the transfer. ··· 691 684 * NOTE: This function will be invoked in IRQ context, hence should be 692 685 * as optimal as possible. 693 686 */ 694 - void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr) 687 + void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv) 695 688 { 696 689 u8 msg_type = MSG_XTRACT_TYPE(msg_hdr); 697 690 698 691 switch (msg_type) { 699 692 case MSG_TYPE_NOTIFICATION: 700 - scmi_handle_notification(cinfo, msg_hdr); 693 + scmi_handle_notification(cinfo, msg_hdr, priv); 701 694 break; 702 695 case MSG_TYPE_COMMAND: 703 696 case MSG_TYPE_DELAYED_RESP: 704 - scmi_handle_response(cinfo, msg_hdr); 697 + scmi_handle_response(cinfo, msg_hdr, priv); 705 698 break; 706 699 default: 707 700 WARN_ONCE(1, "received unknown msg_type:%d\n", msg_type);
+1 -1
drivers/firmware/arm_scmi/mailbox.c
··· 43 43 { 44 44 struct scmi_mailbox *smbox = client_to_scmi_mailbox(cl); 45 45 46 - scmi_rx_callback(smbox->cinfo, shmem_read_header(smbox->shmem)); 46 + scmi_rx_callback(smbox->cinfo, shmem_read_header(smbox->shmem), NULL); 47 47 } 48 48 49 49 static bool mailbox_chan_available(struct device *dev, int idx)
+2 -1
drivers/firmware/arm_scmi/smc.c
··· 154 154 if (scmi_info->irq) 155 155 wait_for_completion(&scmi_info->tx_complete); 156 156 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); 158 159 159 160 mutex_unlock(&scmi_info->shmem_lock); 160 161