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/25 18:12:32 UTC

[incubator-nuttx] branch master updated: risc-v/mpfs: ihc: fix performance issue

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 71ace555f2 risc-v/mpfs: ihc: fix performance issue
71ace555f2 is described below

commit 71ace555f25d3fbb2912f4615f98e36b2d134bb6
Author: Eero Nurkkala <ee...@offcode.fi>
AuthorDate: Thu Aug 25 15:30:09 2022 +0300

    risc-v/mpfs: ihc: fix performance issue
    
    nxsig_usleep() will wait for the next timer tick which is way
    too much here. It's not sleeping 100 us, but rather, near 1/60 s.
    
    This causes severe performance problems. Fix this by polling the
    register for a while if the remote end is busy.
    
    Signed-off-by: Eero Nurkkala <ee...@offcode.fi>
---
 arch/risc-v/src/mpfs/mpfs_ihc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/risc-v/src/mpfs/mpfs_ihc.c b/arch/risc-v/src/mpfs/mpfs_ihc.c
index 7e7cf491e7..7e279a2abc 100644
--- a/arch/risc-v/src/mpfs/mpfs_ihc.c
+++ b/arch/risc-v/src/mpfs/mpfs_ihc.c
@@ -785,22 +785,18 @@ static int mpfs_ihc_tx_message(ihc_channel_t channel, uint32_t *message)
   uint32_t mhartid      = mpfs_ihc_context_to_local_hart_id(channel);
   uint32_t rhartid      = mpfs_ihc_context_to_remote_hart_id(channel);
   uint32_t message_size = getreg32(MPFS_IHC_MSG_SIZE(mhartid, rhartid));
-  uint32_t ctrl_reg     = getreg32(MPFS_IHC_CTRL(mhartid, rhartid));
+  uint32_t ctrl_reg;
+  uint32_t retries      = 10000;
 
   DEBUGASSERT(message_size <= IHC_MAX_MESSAGE_SIZE);
 
   /* Check if the system is busy.  All we can try is wait. */
 
-  if ((RMP_MESSAGE_PRESENT | ACK_INT) & ctrl_reg)
+  do
     {
-#ifndef CONFIG_MPFS_OPENSBI
-      nxsig_usleep(100);
-#endif
-
-      /* Give it a one more try */
-
       ctrl_reg = getreg32(MPFS_IHC_CTRL(mhartid, rhartid));
     }
+  while ((ctrl_reg & (RMP_MESSAGE_PRESENT | ACK_INT)) && --retries);
 
   /* Return if RMP bit 1 indicating busy */