pussuw commented on a change in pull request #5782:
URL: https://github.com/apache/incubator-nuttx/pull/5782#discussion_r837265005



##########
File path: arch/risc-v/src/common/supervisor/riscv_sbi.c
##########
@@ -41,7 +47,11 @@
 
 void riscv_sbi_ack_timer(void)
 {
+#ifdef CONFIG_NUTTSBI
+  riscv_mcall_ack_timer();

Review comment:
       As you already mentioned, this acking of the timer is not used in the 
RISC-V SBI spec. but my analysis of the spec is that the timer is unusable as 
is anyway. The format of sbi_set_timer(absolute_time) is not safe to use, as 
S-mode does not know the timer's value, so it cannot calculate absolute_time > 
mtimecmp anyway. Setting the timer will very likely result in either two things:
   
   - Immediate interrupt, because absolute_time > mtimecmp. As I said, the IRQ 
is a level detect, so whenever mtime > mtimecmp, an interrupt will fire. Other 
compare match implementations use level detect, so when time == cmpvalue, an 
interrupt is triggered exactly once.
   - Interrupt will fire much later than expected, or perhaps even never, as 
mtimecmp > mtime. The counter is 64-bit so mtimecmp can become so outrageously 
large compared to mtime, tha the interrupt will never fire (the sun will 
explode before).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to