From ef28d915fe827b23b4bc03eb098b3b91decd04d8 Mon Sep 17 00:00:00 2001 From: Eero Nurkkala Date: Tue, 28 Jun 2022 15:55:34 +0300 Subject: [PATCH] risc-v/mpfs: ihc: don't start rptun automatically Starting the rptun with the autostart flag set will cause significant delays at the boot, as it will wait for the master to be up. U-boot/linux combination may take more than 10 seconds to boot to the point where the rpmsg bus is initialized. For now, the user needs to initialize the rptun separately, for example, by issuing the following command: rptun start /dev/rptun/mpfs-ihc This command will also block if started before the rpmsg bus master is up. Signed-off-by: Eero Nurkkala --- arch/risc-v/src/mpfs/mpfs_ihc.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/risc-v/src/mpfs/mpfs_ihc.c b/arch/risc-v/src/mpfs/mpfs_ihc.c index 09101d33d6..5611998f46 100755 --- a/arch/risc-v/src/mpfs/mpfs_ihc.c +++ b/arch/risc-v/src/mpfs/mpfs_ihc.c @@ -74,7 +74,7 @@ /* rptun initialization names */ -#define MPFS_RPTUN_CPU_NAME "mpfs-hart4" +#define MPFS_RPTUN_CPU_NAME "mpfs-ihc" #define MPFS_RPTUN_SHMEM_NAME "mpfs-shmem" /* Vring configuration parameters */ @@ -185,6 +185,7 @@ static uint32_t g_connected_hart_ints; static uint32_t g_connected_harts; static int g_vq_idx; static int g_plic_irq; +static bool g_rptun_initialized; const uint32_t ihcia_remote_harts[MPFS_NUM_HARTS] = { @@ -590,6 +591,15 @@ static void mpfs_ihc_message_present_isr(void) if (origin_hart != UNDEFINED_HART_ID) { + /* If autostart is false, we delay the ack until rptun is up. Note + * that the master will keep sending the irq if no ack is received. + */ + + if (!g_rptun_initialized) + { + return; + } + /* This is used to declare the master is up and running */ g_shmem.master_up = true; @@ -952,6 +962,12 @@ mpfs_rptun_get_resource(struct rptun_dev_s *dev) rsc->config.txbuf_size = VRING_SIZE; } + /* It might be tempting to set this at mpfs_rptun_start(), but it's only + * called if we're the bus master. + */ + + g_rptun_initialized = true; + return &priv->shmem->rsc; } @@ -960,19 +976,20 @@ mpfs_rptun_get_resource(struct rptun_dev_s *dev) * * Description: * Checks whether the rptun needs to autostart without explicit user - * start command. + * start command. Currently autostart is false, which means that the user + * must start the service explicitly, eg. rptun start /dev/rptun/mpfs-ihc * * Input Parameters: * dev - Rptun device. * * Returned Value: - * Always true + * Always false * ****************************************************************************/ static bool mpfs_rptun_is_autostart(struct rptun_dev_s *dev) { - return true; + return false; } /****************************************************************************