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 <eero.nurkkala@offcode.fi>
This commit is contained in:
Eero Nurkkala
2022-08-17 10:48:00 +03:00
committed by Xiang Xiao
parent daa4cf7ad2
commit a1ff841ca4
+16 -2
View File
@@ -177,8 +177,12 @@ static struct mpfs_rptun_shmem_s g_shmem;
static struct rpmsg_device *g_mpfs_rpmsg_device; static struct rpmsg_device *g_mpfs_rpmsg_device;
static struct rpmsg_virtio_device *g_mpfs_virtio_device; static struct rpmsg_virtio_device *g_mpfs_virtio_device;
static sem_t g_mpfs_ack_sig = SEM_INITIALIZER(0); #ifndef CONFIG_MPFS_OPENSBI
static sem_t g_mpfs_rx_sig = SEM_INITIALIZER(0); 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 struct list_node g_dev_list = LIST_INITIAL_VALUE(g_dev_list);
static uint32_t g_connected_hart_ints; 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 */ /* Received the ack */
#ifndef CONFIG_MPFS_OPENSBI
nxsem_post(&g_mpfs_ack_sig); nxsem_post(&g_mpfs_ack_sig);
#endif
} }
else else
{ {
@@ -437,7 +443,9 @@ static void mpfs_ihc_rx_handler(uint32_t *message, bool is_ack)
DEBUGASSERT(g_vq_idx < VRINGS); DEBUGASSERT(g_vq_idx < VRINGS);
#ifndef CONFIG_MPFS_OPENSBI
nxsem_post(&g_mpfs_rx_sig); 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) if ((RMP_MESSAGE_PRESENT | ACK_INT) & ctrl_reg)
{ {
#ifndef CONFIG_MPFS_OPENSBI
nxsig_usleep(100); nxsig_usleep(100);
#endif
/* Give it a one more try */ /* 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 */ /* Only applicable for the CONTEXTB_HART */
#ifndef CONFIG_MPFS_OPENSBI
nxsem_wait_uninterruptible(&g_mpfs_ack_sig); 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]; info = &g_mpfs_virtqueue_table[g_vq_idx];
virtqueue_notification((struct virtqueue *)info->data); virtqueue_notification((struct virtqueue *)info->data);
#ifndef CONFIG_MPFS_OPENSBI
nxsem_wait(&g_mpfs_rx_sig); nxsem_wait(&g_mpfs_rx_sig);
#endif
} }
return 0; return 0;