Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv m-timer is schduled multiple times per interrupt. #12407

Closed
g2gps opened this issue May 27, 2024 · 3 comments · Fixed by #12433
Closed

riscv m-timer is schduled multiple times per interrupt. #12407

g2gps opened this issue May 27, 2024 · 3 comments · Fixed by #12433

Comments

@g2gps
Copy link
Contributor

g2gps commented May 27, 2024

While profiling some of the litex layers, I found that the riscv mtimer is scheduled through openSBI multiple times per alarm interrupt. This isn't ideal, as the openSBI ecall is relatively expensive on platforms which don't have the supervisor time (sstc) extension. I don't think there is any reason for this behavior to remain as it is. The only requirement from the riscv machine timer is that it is written once to clear the pending interrupt.

I've done proof on concept locally where the next update time is cached as part of the instance, and updated once at the end of the timer interrupt, which works, but it needs to be tested more thoroughly.

What is a good test configuration to verify that updated behavior is correct? I was thinking qemu-rv:knsh32 with ostest enabled, along with testing on our platform, as it's the only other suitable platform we have available.

Open to suggestions.

@acassis
Copy link
Contributor

acassis commented May 27, 2024

@g2gps I think testing on qemu-rv:knsh32 is a good valid initial test, but it is important to test in other boards supported by NuttX. @lupyuen what do you think?

@lupyuen
Copy link
Member

lupyuen commented May 27, 2024

@g2gps Yep it's good to test on knsh32 and knsh64. Most of the 64-bit RISC-V ports were derived from knsh64 with OpenSBI, without SSTC.

@g2gps
Copy link
Contributor Author

g2gps commented May 27, 2024

Ok, thanks for the suggestions. I'll put together a PR early next week, when I have a chance to test this out properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants