From f0c25a082fc8b891d4d21518028118561caa4735 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 12 Apr 2022 17:17:45 +0100 Subject: [PATCH] feat(spmc): add FFA_RX_RELEASE handler Enable a partition to release its RX buffer and the SPMC to update the appropriate state tracking. Signed-off-by: Marc Bonnici Change-Id: I5fb6d92244b5ed5f032269b29b102aa874bf3ae3 --- services/std_svc/spm/el3_spmc/spmc_main.c | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/services/std_svc/spm/el3_spmc/spmc_main.c b/services/std_svc/spm/el3_spmc/spmc_main.c index 703d44517..5dbc48d67 100644 --- a/services/std_svc/spm/el3_spmc/spmc_main.c +++ b/services/std_svc/spm/el3_spmc/spmc_main.c @@ -1011,6 +1011,7 @@ static uint64_t ffa_features_handler(uint32_t smc_fid, case FFA_ID_GET: case FFA_FEATURES: case FFA_VERSION: + case FFA_RX_RELEASE: case FFA_MSG_SEND_DIRECT_REQ_SMC32: case FFA_MSG_SEND_DIRECT_REQ_SMC64: case FFA_PARTITION_INFO_GET: @@ -1145,6 +1146,31 @@ static uint64_t ffa_run_handler(uint32_t smc_fid, handle, cookie, flags, target_id); } +static uint64_t rx_release_handler(uint32_t smc_fid, + bool secure_origin, + uint64_t x1, + uint64_t x2, + uint64_t x3, + uint64_t x4, + void *cookie, + void *handle, + uint64_t flags) +{ + struct mailbox *mbox = spmc_get_mbox_desc(secure_origin); + + spin_lock(&mbox->lock); + + if (mbox->state != MAILBOX_STATE_FULL) { + spin_unlock(&mbox->lock); + return spmc_ffa_error_return(handle, FFA_ERROR_DENIED); + } + + mbox->state = MAILBOX_STATE_EMPTY; + spin_unlock(&mbox->lock); + + SMC_RET1(handle, FFA_SUCCESS_SMC32); +} + /******************************************************************************* * This function will parse the Secure Partition Manifest. From manifest, it * will fetch details for preparing Secure partition image context and secure @@ -1573,6 +1599,10 @@ uint64_t spmc_smc_handler(uint32_t smc_fid, x2, x3, x4, cookie, handle, flags); + case FFA_RX_RELEASE: + return rx_release_handler(smc_fid, secure_origin, x1, x2, x3, + x4, cookie, handle, flags); + case FFA_MSG_WAIT: return msg_wait_handler(smc_fid, secure_origin, x1, x2, x3, x4, cookie, handle, flags);