diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-09-03 20:45:47 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-09-03 23:15:49 -0400 |
commit | 7b7f57e01c87efc74ed0c632b14c1fc7897c5a6e (patch) | |
tree | 95dc025194f56e8f3741f910dd49162dbee520ac /src/pru | |
parent | 8d0ef49e8f2151a4003eb4391a0a769f5dd470aa (diff) | |
download | kutter-7b7f57e01c87efc74ed0c632b14c1fc7897c5a6e.tar.gz kutter-7b7f57e01c87efc74ed0c632b14c1fc7897c5a6e.tar.xz kutter-7b7f57e01c87efc74ed0c632b14c1fc7897c5a6e.zip |
pru: Only sleep the pru0 if the incoming queue is fully empty
It's possible for multiple blocks to be pending on the incoming
"rpmsg" stream. Don't sleep unless the input is confirmed to be
empty.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/pru')
-rw-r--r-- | src/pru/pru0.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pru/pru0.c b/src/pru/pru0.c index a2c3ec59..8007823a 100644 --- a/src/pru/pru0.c +++ b/src/pru/pru0.c @@ -101,7 +101,7 @@ do_dispatch(char *buf, uint32_t msglen) } // See if there are commands from the host ready to be processed -static void +static int check_can_read(void) { // Read data @@ -109,12 +109,12 @@ check_can_read(void) char *p = SHARED_MEM->read_data; int16_t ret = pru_rpmsg_receive(&transport, &transport_dst, &dst, p, &len); if (ret) - return; + return ret == PRU_RPMSG_NO_BUF_AVAILABLE; // Check for force shutdown request if (len == 15 && p[14] == '\n' && memcmp(p, "FORCE_SHUTDOWN\n", 15) == 0) { send_pru1_shutdown(); - return; + return 0; } // Parse data into message blocks @@ -128,6 +128,7 @@ check_can_read(void) p += pop_count; len -= pop_count; } + return 0; } // Main processing loop @@ -135,10 +136,11 @@ static void process_io(void) { for (;;) { - asm("slp 1"); CT_INTC.SECR0 = (1 << KICK_PRU0_FROM_ARM_EVENT) | (1 << KICK_PRU0_EVENT); check_can_send(); - check_can_read(); + int can_sleep = check_can_read(); + if (can_sleep) + asm("slp 1"); } } |