aboutsummaryrefslogtreecommitdiff
path: root/interface
diff options
context:
space:
mode:
authorDavid Hu <david.hu@arm.com>2020-05-13 16:37:34 +0800
committerDavid Hu <david.hu@arm.com>2021-01-22 02:21:55 +0000
commit9483037418668673139e324b6c067129337867ff (patch)
tree65e7e4ccc3355852f6b3257590318ada8a8e36ee /interface
parent6730af25d5cc01fd573596ab469b1e025b30a49e (diff)
downloadtrusted-firmware-m-9483037418668673139e324b6c067129337867ff.tar.gz
Dualcpu: Refine NS mailbox wake-up mechanism
Move the loop of going through replied mailbox messages in NS mailbox queue into the NS mailbox wake-up function, to simplify the implementation in platform mailbox IRQ handler. Change-Id: I6dfed2e4ac2cdbb05aedb2a570e9592b2e2b6670 Signed-off-by: David Hu <david.hu@arm.com>
Diffstat (limited to 'interface')
-rw-r--r--interface/include/tfm_ns_mailbox.h13
-rw-r--r--interface/src/tfm_ns_mailbox.c37
2 files changed, 27 insertions, 23 deletions
diff --git a/interface/include/tfm_ns_mailbox.h b/interface/include/tfm_ns_mailbox.h
index 114000f8a5..6b64443fa0 100644
--- a/interface/include/tfm_ns_mailbox.h
+++ b/interface/include/tfm_ns_mailbox.h
@@ -65,18 +65,13 @@ int32_t tfm_ns_mailbox_client_call(uint32_t call_type,
int32_t *reply);
/**
- * \brief Wake up the owner task of the first replied mailbox message in the
- * NSPE mailbox queue.
+ * \brief Go through mailbox messages already replied by SPE mailbox and
+ * wake up the owner tasks of replied mailbox messages.
* This function is intended to be called inside platform specific
* notification IRQ handler.
*
- * \note The replied status of the fetched mailbox message will be cleaned after
- * the message is fetched. When this function is called again, it wakes
- * the owner task of next replied mailbox message from the NSPE mailbox
- * queue.
- *
- * \return MAILBOX_SUCCESS The task of the first replied mailbox message
- * is found and wake-up signal is sent.
+ * \return MAILBOX_SUCCESS The tasks of replied mailbox messages
+ * were found and wake-up signals were sent.
* \return MAILBOX_NO_PEND_EVENT No replied mailbox message is found.
* \return Other return code Failed with an error code
*/
diff --git a/interface/src/tfm_ns_mailbox.c b/interface/src/tfm_ns_mailbox.c
index f8f4298b9c..97c2bfa4cc 100644
--- a/interface/src/tfm_ns_mailbox.c
+++ b/interface/src/tfm_ns_mailbox.c
@@ -43,6 +43,11 @@ static inline void clear_queue_slot_replied(uint8_t idx)
}
}
+static inline void clear_queue_slot_all_replied(mailbox_queue_status_t status)
+{
+ mailbox_queue_ptr->replied_slots &= ~status;
+}
+
static inline bool is_queue_slot_replied(uint8_t idx)
{
if (idx < NUM_MAILBOX_QUEUE_SLOT) {
@@ -296,6 +301,7 @@ int32_t tfm_ns_mailbox_wake_reply_owner_isr(void)
tfm_ns_mailbox_hal_enter_critical_isr();
replied_status = mailbox_queue_ptr->replied_slots;
+ clear_queue_slot_all_replied(replied_status);
tfm_ns_mailbox_hal_exit_critical_isr();
if (!replied_status) {
@@ -303,23 +309,26 @@ int32_t tfm_ns_mailbox_wake_reply_owner_isr(void)
}
for (idx = 0; idx < NUM_MAILBOX_QUEUE_SLOT; idx++) {
- /* Find the first replied message in queue */
- if (replied_status & (0x1UL << idx)) {
- tfm_ns_mailbox_hal_enter_critical_isr();
- clear_queue_slot_replied(idx);
- set_queue_slot_woken(idx);
- tfm_ns_mailbox_hal_exit_critical_isr();
+ /*
+ * The reply has already received from SPE mailbox but
+ * the wake-up signal is not sent yet.
+ */
+ if (!(replied_status & (0x1UL << idx))) {
+ continue;
+ }
- break;
- }
- }
+ /* Set woken-up flag */
+ tfm_ns_mailbox_hal_enter_critical_isr();
+ set_queue_slot_woken(idx);
+ tfm_ns_mailbox_hal_exit_critical_isr();
- /* In theory, it won't occur. Just in case */
- if (idx >= NUM_MAILBOX_QUEUE_SLOT) {
- return MAILBOX_NO_PEND_EVENT;
- }
+ tfm_ns_mailbox_os_wake_task_isr(mailbox_queue_ptr->queue[idx].owner);
- tfm_ns_mailbox_os_wake_task_isr(mailbox_queue_ptr->queue[idx].owner);
+ replied_status &= ~(0x1UL << idx);
+ if (!replied_status) {
+ break;
+ }
+ }
return MAILBOX_SUCCESS;
}