From d5141f37c42e0b833863f157ac4cee203b2ba3d2 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Fri, 27 Mar 2020 14:34:28 +0000 Subject: firmware: arm_scmi: Add notifications support in transport layer Add common transport-layer methods to: - fetch a notification instead of a response - clear a pending notification Add also all the needed support in mailbox/shmem transports. Link: https://lore.kernel.org/r/20200327143438.5382-4-cristian.marussi@arm.com Reviewed-by: Jonathan Cameron Reviewed-by: Viresh Kumar Signed-off-by: Cristian Marussi Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/shmem.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/firmware/arm_scmi/shmem.c') diff --git a/drivers/firmware/arm_scmi/shmem.c b/drivers/firmware/arm_scmi/shmem.c index e1e816e0018c..a5a5d0f6bf86 100644 --- a/drivers/firmware/arm_scmi/shmem.c +++ b/drivers/firmware/arm_scmi/shmem.c @@ -67,6 +67,21 @@ void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem, memcpy_fromio(xfer->rx.buf, shmem->msg_payload + 4, xfer->rx.len); } +void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem, + size_t max_len, struct scmi_xfer *xfer) +{ + /* Skip only the length of header in shmem area i.e 4 bytes */ + xfer->rx.len = min_t(size_t, max_len, ioread32(&shmem->length) - 4); + + /* Take a copy to the rx buffer.. */ + memcpy_fromio(xfer->rx.buf, shmem->msg_payload, xfer->rx.len); +} + +void shmem_clear_notification(struct scmi_shared_mem __iomem *shmem) +{ + iowrite32(SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE, &shmem->channel_status); +} + bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem, struct scmi_xfer *xfer) { -- cgit v1.2.3 From 87dff4e63cf2910f2e4a32d1cb3e4a1a25406eb7 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Mon, 20 Apr 2020 16:23:12 +0100 Subject: firmware: arm_scmi: Rename .clear_notification() transport_ops SCMI transport operation .clear_notification() is indeed a generic method to clear the channel in a transport dependent way, as such it could be a useful helper also in other contexts. Rename such method as .clear_channel(), renaming accordingly also its already existent call-sites. No functional change. Link: https://lore.kernel.org/r/20200420152315.21008-2-cristian.marussi@arm.com Signed-off-by: Cristian Marussi Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/common.h | 6 +++--- drivers/firmware/arm_scmi/driver.c | 4 ++-- drivers/firmware/arm_scmi/mailbox.c | 6 +++--- drivers/firmware/arm_scmi/shmem.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/firmware/arm_scmi/shmem.c') diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 07eb33c1576b..31fe5a22a011 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -179,7 +179,7 @@ struct scmi_chan_info { * @mark_txdone: Callback to mark tx as done * @fetch_response: Callback to fetch response * @fetch_notification: Callback to fetch notification - * @clear_notification: Callback to clear a pending notification + * @clear_channel: Callback to clear a channel * @poll_done: Callback to poll transfer status */ struct scmi_transport_ops { @@ -194,7 +194,7 @@ struct scmi_transport_ops { struct scmi_xfer *xfer); void (*fetch_notification)(struct scmi_chan_info *cinfo, size_t max_len, struct scmi_xfer *xfer); - void (*clear_notification)(struct scmi_chan_info *cinfo); + void (*clear_channel)(struct scmi_chan_info *cinfo); bool (*poll_done)(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer); }; @@ -232,6 +232,6 @@ void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem, struct scmi_xfer *xfer); void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem, size_t max_len, struct scmi_xfer *xfer); -void shmem_clear_notification(struct scmi_shared_mem __iomem *shmem); +void shmem_clear_channel(struct scmi_shared_mem __iomem *shmem); bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem, struct scmi_xfer *xfer); diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 332edf1b09fc..90c7a0bb62ef 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -213,7 +213,7 @@ static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr) if (IS_ERR(xfer)) { dev_err(dev, "failed to get free message slot (%ld)\n", PTR_ERR(xfer)); - info->desc->ops->clear_notification(cinfo); + info->desc->ops->clear_channel(cinfo); return; } @@ -228,7 +228,7 @@ static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr) __scmi_xfer_put(minfo, xfer); - info->desc->ops->clear_notification(cinfo); + info->desc->ops->clear_channel(cinfo); } static void scmi_handle_response(struct scmi_chan_info *cinfo, diff --git a/drivers/firmware/arm_scmi/mailbox.c b/drivers/firmware/arm_scmi/mailbox.c index 19ee058f9f44..6998dc86b5ce 100644 --- a/drivers/firmware/arm_scmi/mailbox.c +++ b/drivers/firmware/arm_scmi/mailbox.c @@ -166,11 +166,11 @@ static void mailbox_fetch_notification(struct scmi_chan_info *cinfo, shmem_fetch_notification(smbox->shmem, max_len, xfer); } -static void mailbox_clear_notification(struct scmi_chan_info *cinfo) +static void mailbox_clear_channel(struct scmi_chan_info *cinfo) { struct scmi_mailbox *smbox = cinfo->transport_info; - shmem_clear_notification(smbox->shmem); + shmem_clear_channel(smbox->shmem); } static bool @@ -189,7 +189,7 @@ static struct scmi_transport_ops scmi_mailbox_ops = { .mark_txdone = mailbox_mark_txdone, .fetch_response = mailbox_fetch_response, .fetch_notification = mailbox_fetch_notification, - .clear_notification = mailbox_clear_notification, + .clear_channel = mailbox_clear_channel, .poll_done = mailbox_poll_done, }; diff --git a/drivers/firmware/arm_scmi/shmem.c b/drivers/firmware/arm_scmi/shmem.c index a5a5d0f6bf86..0e3eaea5d852 100644 --- a/drivers/firmware/arm_scmi/shmem.c +++ b/drivers/firmware/arm_scmi/shmem.c @@ -77,7 +77,7 @@ void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem, memcpy_fromio(xfer->rx.buf, shmem->msg_payload, xfer->rx.len); } -void shmem_clear_notification(struct scmi_shared_mem __iomem *shmem) +void shmem_clear_channel(struct scmi_shared_mem __iomem *shmem) { iowrite32(SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE, &shmem->channel_status); } -- cgit v1.2.3