riscvarchive / riscv-platform-specs

RISC-V Profiles and Platform Specification
Creative Commons Attribution 4.0 International
112 stars 39 forks source link

How to handle non-coherent I/O masters #28

Open jrtc27 opened 3 years ago

jrtc27 commented 3 years ago

Currently the base spec says:

Memory accesses by I/O masters can be coherent or non-coherent with respect to all hart-related caches.

However, nothing is said about what software should do in that case. I believe the CMOs extension should be required in such a case, as otherwise software cannot work without adding SoC-specific cache management operations, which quickly becomes the kind of mess that platform specs are supposed to stop happening.

atishp04 commented 3 years ago

Yes. We need CMOs in the software to manage that. Do we need to mandate CMO (at least the base one expected to be ratified this year) in the platform spec ?

jrtc27 commented 3 years ago

If you allow non-coherent access but don't mandate that CMO be used in that case, you will end up with more platforms like the BeagleV and C906 adding in their own vendor-specific cache management extension, which is not a good place to be. Ideally Zicbom will be ratified later this year and can be mandated by the RVA22 platform spec. If it doesn't get ratified, you'll have to choose between mandating coherent access (and thus, for backwards compatibility, may have to mandate but deprecate it in RVA24) or allowing the current "Wild West" approach where vendors just do what they feel like and software has to support each platform individually.

paul-walmsley-sifive commented 3 years ago

Coherence must be mandated, otherwise the system is broken. The key question here seems to be whether a software-managed coherence implementation is used, or hardware-managed cache coherence. If the former, @jrtc27 is exactly right that the spec must mandate that implementors use the RISC-V standard CMO instructions to support SW coherency.

atishp04 commented 3 years ago

As @jrtc27 pointed out, Zicbom is on track to be ratified this year and expected to be included in RVA22. Thus, platform spec inherit that as it mandates RVA22. Same goes for SvPBMT extension as well.

andreiw commented 1 year ago

Is it worthwhile to be explicit about how pre-CMO platforms could be supported by the spec? I.e. emulation of the CMO ops in SBI still seems like a benefit, when compared to explicit manipulation of MMIO cache controllers from the kernel or use of proprietary ISA extensions. Is this an interesting area of investigation?