Skip to content

Commit 4ebd8f6

Browse files
committed
firmware: arm_scmi: Add receive buffer support for notifications
With all the plumbing in place, let's just add the separate dedicated receive buffers to handle notifications that can arrive asynchronously from the platform firmware to OS. Also add one check to see if the platform supports any receive channels before allocating the receive buffers: since those buffers are optionally supported though, the whole xfer initialization is also postponed to be able to check for their existence in advance. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jonathan Cameron <[email protected]> [Changed parameters in __scmi_xfer_info_init()] Signed-off-by: Cristian Marussi <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 23818b3 commit 4ebd8f6

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/firmware/arm_scmi/driver.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct scmi_xfers_info {
7676
* implementation version and (sub-)vendor identification.
7777
* @handle: Instance of SCMI handle to send to clients
7878
* @tx_minfo: Universal Transmit Message management info
79+
* @rx_minfo: Universal Receive Message management info
7980
* @tx_idr: IDR object to map protocol id to Tx channel info pointer
8081
* @rx_idr: IDR object to map protocol id to Rx channel info pointer
8182
* @protocols_imp: List of protocols implemented, currently maximum of
@@ -89,6 +90,7 @@ struct scmi_info {
8990
struct scmi_revision_info version;
9091
struct scmi_handle handle;
9192
struct scmi_xfers_info tx_minfo;
93+
struct scmi_xfers_info rx_minfo;
9294
struct idr tx_idr;
9395
struct idr rx_idr;
9496
u8 *protocols_imp;
@@ -525,13 +527,13 @@ int scmi_handle_put(const struct scmi_handle *handle)
525527
return 0;
526528
}
527529

528-
static int scmi_xfer_info_init(struct scmi_info *sinfo)
530+
static int __scmi_xfer_info_init(struct scmi_info *sinfo,
531+
struct scmi_xfers_info *info)
529532
{
530533
int i;
531534
struct scmi_xfer *xfer;
532535
struct device *dev = sinfo->dev;
533536
const struct scmi_desc *desc = sinfo->desc;
534-
struct scmi_xfers_info *info = &sinfo->tx_minfo;
535537

536538
/* Pre-allocated messages, no more than what hdr.seq can support */
537539
if (WARN_ON(desc->max_msg >= MSG_TOKEN_MAX)) {
@@ -566,6 +568,16 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo)
566568
return 0;
567569
}
568570

571+
static int scmi_xfer_info_init(struct scmi_info *sinfo)
572+
{
573+
int ret = __scmi_xfer_info_init(sinfo, &sinfo->tx_minfo);
574+
575+
if (!ret && idr_find(&sinfo->rx_idr, SCMI_PROTOCOL_BASE))
576+
ret = __scmi_xfer_info_init(sinfo, &sinfo->rx_minfo);
577+
578+
return ret;
579+
}
580+
569581
static int scmi_chan_setup(struct scmi_info *info, struct device *dev,
570582
int prot_id, bool tx)
571583
{
@@ -699,10 +711,6 @@ static int scmi_probe(struct platform_device *pdev)
699711
info->desc = desc;
700712
INIT_LIST_HEAD(&info->node);
701713

702-
ret = scmi_xfer_info_init(info);
703-
if (ret)
704-
return ret;
705-
706714
platform_set_drvdata(pdev, info);
707715
idr_init(&info->tx_idr);
708716
idr_init(&info->rx_idr);
@@ -715,6 +723,10 @@ static int scmi_probe(struct platform_device *pdev)
715723
if (ret)
716724
return ret;
717725

726+
ret = scmi_xfer_info_init(info);
727+
if (ret)
728+
return ret;
729+
718730
ret = scmi_base_protocol_init(handle);
719731
if (ret) {
720732
dev_err(dev, "unable to communicate with SCMI(%d)\n", ret);

0 commit comments

Comments
 (0)