You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/05/13 16:07:45 UTC
[incubator-nuttx] branch master updated: risc-v/mpfs: IHC: clarify semaphore usage
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0178792a01 risc-v/mpfs: IHC: clarify semaphore usage
0178792a01 is described below
commit 0178792a018c1654a8a6725ca2a3306861afb00d
Author: Eero Nurkkala <ee...@offcode.fi>
AuthorDate: Fri May 13 11:38:29 2022 +0300
risc-v/mpfs: IHC: clarify semaphore usage
g_mpfs_ack_sig and g_mpfs_rx_sig are better used with
SEM_INITIALIZER(0) (signalling) rather than with
SEM_INITIALIZER(1) (mutual exclusion).
Co-authored-by: Petro Karashchenko <pe...@gmail.com>
Signed-off-by: Eero Nurkkala <ee...@offcode.fi>
---
arch/risc-v/src/mpfs/mpfs_ihc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/risc-v/src/mpfs/mpfs_ihc.c b/arch/risc-v/src/mpfs/mpfs_ihc.c
index 4f3c571dd6..f428df6e5d 100755
--- a/arch/risc-v/src/mpfs/mpfs_ihc.c
+++ b/arch/risc-v/src/mpfs/mpfs_ihc.c
@@ -169,8 +169,8 @@ static struct mpfs_rptun_shmem_s g_shmem;
static struct rpmsg_device *g_mpfs_rpmsg_device;
static struct rpmsg_virtio_device *g_mpfs_virtio_device;
-static sem_t g_mpfs_ack_lock = SEM_INITIALIZER(1);
-static sem_t g_mpfs_rx_sig = SEM_INITIALIZER(1);
+static sem_t g_mpfs_ack_sig = SEM_INITIALIZER(0);
+static sem_t g_mpfs_rx_sig = SEM_INITIALIZER(0);
static struct list_node g_dev_list = LIST_INITIAL_VALUE(g_dev_list);
static uint32_t g_connected_hart_ints;
@@ -335,7 +335,7 @@ static uint32_t mpfs_ihc_context_to_remote_hart_id(ihc_channel_t channel)
*
* Description:
* This handles the received information and either lets the vq to proceed
- * via posting g_mpfs_ack_lock, or lets the mpfs_rptun_thread() run as it
+ * via posting g_mpfs_ack_sig, or lets the mpfs_rptun_thread() run as it
* waits for the g_mpfs_rx_sig. virtqueue_notification() cannot be called
* from the interrupt context, thus the thread that will perform it.
*
@@ -354,7 +354,7 @@ static void mpfs_ihc_rx_handler(uint32_t *message, bool is_ack)
{
/* Received the ack */
- nxsem_post(&g_mpfs_ack_lock);
+ nxsem_post(&g_mpfs_ack_sig);
}
else
{
@@ -683,7 +683,7 @@ static int mpfs_ihc_tx_message(ihc_channel_t channel, uint32_t *message)
/* Wait for the ACK to arrive to maintain the logic */
- nxsem_wait_uninterruptible(&g_mpfs_ack_lock);
+ nxsem_wait_uninterruptible(&g_mpfs_ack_sig);
}
return OK;