You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/08/17 10:33:38 UTC
[incubator-nuttx] branch master updated: risc-v/mpfs: ihc: don't use semaphores with OpenSBI vendor calls
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang 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 a1ff841ca4 risc-v/mpfs: ihc: don't use semaphores with OpenSBI vendor calls
a1ff841ca4 is described below
commit a1ff841ca44734c75015119eab1b0f63d47e81b9
Author: Eero Nurkkala <ee...@offcode.fi>
AuthorDate: Wed Aug 17 10:48:00 2022 +0300
risc-v/mpfs: ihc: don't use semaphores with OpenSBI vendor calls
OpenSBI vendor extension calls must not cause scheduling, as they're
part of M-mode trap handling. Thus, comment out nxsig_usleep() as
well, which is occasionally taken and crashes the system in that
case. Fix this by commenting out lines that have the potential to
cause scheduling.
Signed-off-by: Eero Nurkkala <ee...@offcode.fi>
---
arch/risc-v/src/mpfs/mpfs_ihc.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/risc-v/src/mpfs/mpfs_ihc.c b/arch/risc-v/src/mpfs/mpfs_ihc.c
index ac6bc15f00..a3390afc74 100644
--- a/arch/risc-v/src/mpfs/mpfs_ihc.c
+++ b/arch/risc-v/src/mpfs/mpfs_ihc.c
@@ -177,8 +177,12 @@ 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_sig = SEM_INITIALIZER(0);
-static sem_t g_mpfs_rx_sig = SEM_INITIALIZER(0);
+#ifndef CONFIG_MPFS_OPENSBI
+static sem_t g_mpfs_ack_sig = NXSEM_INITIALIZER(0,
+ PRIOINHERIT_FLAGS_DISABLE);
+static sem_t g_mpfs_rx_sig = NXSEM_INITIALIZER(0,
+ PRIOINHERIT_FLAGS_DISABLE);
+#endif
static struct list_node g_dev_list = LIST_INITIAL_VALUE(g_dev_list);
static uint32_t g_connected_hart_ints;
@@ -429,7 +433,9 @@ static void mpfs_ihc_rx_handler(uint32_t *message, bool is_ack)
{
/* Received the ack */
+#ifndef CONFIG_MPFS_OPENSBI
nxsem_post(&g_mpfs_ack_sig);
+#endif
}
else
{
@@ -437,7 +443,9 @@ static void mpfs_ihc_rx_handler(uint32_t *message, bool is_ack)
DEBUGASSERT(g_vq_idx < VRINGS);
+#ifndef CONFIG_MPFS_OPENSBI
nxsem_post(&g_mpfs_rx_sig);
+#endif
}
}
@@ -785,7 +793,9 @@ static int mpfs_ihc_tx_message(ihc_channel_t channel, uint32_t *message)
if ((RMP_MESSAGE_PRESENT | ACK_INT) & ctrl_reg)
{
+#ifndef CONFIG_MPFS_OPENSBI
nxsig_usleep(100);
+#endif
/* Give it a one more try */
@@ -821,7 +831,9 @@ static int mpfs_ihc_tx_message(ihc_channel_t channel, uint32_t *message)
{
/* Only applicable for the CONTEXTB_HART */
+#ifndef CONFIG_MPFS_OPENSBI
nxsem_wait_uninterruptible(&g_mpfs_ack_sig);
+#endif
}
}
@@ -1277,7 +1289,9 @@ static int mpfs_rptun_thread(int argc, char *argv[])
info = &g_mpfs_virtqueue_table[g_vq_idx];
virtqueue_notification((struct virtqueue *)info->data);
+#ifndef CONFIG_MPFS_OPENSBI
nxsem_wait(&g_mpfs_rx_sig);
+#endif
}
return 0;