Cache coherency management subsystem
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v6 Latest7 patches 7 repliesIn review
- v56 patches 6 repliesSuperseded
- v46 patches 11 repliesSuperseded
Earlier versions · 3
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v3 | 8 patches | 11 replies | Superseded | |
| v2 | 8 patches | 27 replies | Superseded | |
| v1 RFC | 6 patches | 7 replies | Superseded |
Patches in v6 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | memregion: Drop unused IORES_DESC_* parameter from cpu_cache_invalidate_memregion()arch/ drivers/ drivers/ +2 more | +7 | 0 replies | |
| 2/7 | memregion: Support fine grained invalidate by cpu_cache_invalidate_memregion()arch/ drivers/ drivers/ +2 more | +18 | 0 replies | |
| 3/7 | lib: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGIONinclude/ lib/ lib/ +1 more | +205 | 7 replies | |
| 4/7 | arm64: Select GENERIC_CPU_CACHE_MAINTENANCEarch/ | +1 | 0 replies | |
| 5/7 | MAINTAINERS: Add Jonathan Cameron to drivers/cache and add lib/cache_maint.c + headerMAINTAINERS | +3 | 0 replies | |
| 6/7 | cache: Make top level Kconfig menu a boolean dependent on RISCVdrivers/ | +11 | 0 replies | |
| 7/7 | cache: Support cache maintenance for HiSilicon SoC Hydra Home Agentdrivers/ drivers/ drivers/ | +218 | 0 replies |
Reviews trailers per patch
5 of 7 patches have a Reviewed-by or Acked-by.
| Patch | Dan Williams | Davidlohr Bueso | Conor Dooley | Catalin Marinas | Jonathan Cameron |
|---|---|---|---|---|---|
| 1/7 | R-b | ||||
| 2/7 | R-b | A-b | |||
| 3/7 | A-b | A-b | |||
| 4/7 | A-b | ||||
| 5/7 | A-b | ||||
| 6/7 | |||||
| 7/7 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.
Cover letter [PATCH v6 0/7] Cache coherency management subsystem
v6: Split the Kconfig menu to differentiate the new type of driver this set
adds from existing riscv cache maintenance drivers for interaction with non coherent DMA master. This provides a good resolution to concerns around mixing different types of driver, whilst avoiding yet another drivers/* directory (Thanks to Arnd Bergmann)
Support system level interfaces for cache maintenance as found on some ARM64 systems. It is expected that systems using other CPU architectures (such as RiscV) that support CXL memory and allow for native OS flows will also use this. This is needed for correct functionality during various forms of memory hotplug (e.g. CXL). Typical hardware has MMIO interface found via ACPI DSDT. A system will often contain multiple hardware instances.
Includes parameter changes to cpu_cache_invalidate_memregion() but no functional changes for architectures that already support this call.
Merge plan. Through Conor's drivers/cache tree which routes through the SoC tree.
* Andrew Morton has expressed he is fine with the MM related changes going via another appropriate tree.
* CXL maintainers expressed that they don't consider it appropriate to go through theit tree.
* The tiny touching of Arm specific code has an ack from Catalin.
v5: Changes called out in individual patches.
Comment and patch description updates to make the following clearer.
- Difference from cache-coherence operations for non-coherent DMA. Longer term it may make sense to share infrastructure but for now we have two parallel systems as there would be near zero overlap in code or functionality.
- Why multiple agent handling is necessary and what that means for the HiSilicon HHAs in our systems + the driver inclued in this set.
v4: (Small changes called out in each patch)
- Drop the ACPI driver. It has done it's job as a second implementation to help with generality testing. I have heard zero interest in actually doing the specification work needed to make that official. Easy to bring back if needed in future. I have it locally still as a second test case.
- Add a cpu_cache_invalidate_all() helper for the 0,-1 case that is used to indicate everything should be flushed as no fine grained range info available.
- Simplify the necessary symbols to be selected by architectures by making CONFIG_GENERIC_CPU_CACHE_MAINTENANCE select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
- Avoid naming mentioning devices as there is no struct device.
- Use a kref so as to have something on which a _put() operation makes sense avoiding rather confusing freeing of an internal structure pointer that was seen in v3.
- Gather tags given.
- Various minor things like typos, header tweaks etc.
Thanks to all who reviewed v3.
On current ARM64 systems (and likely other architectures) the implementation of cache flushing need for actions such as CXL memory hotplug e.g. cpu_cache_invalidate_memregion(), is performed by system components outside of the CPU, controlled via either firmware or MMIO interfaces.
These control units run the necessary coherency protocol operations to cause the write backs and cache flushes to occur asynchronously. They allow filtering by PA range to reduce disruption to the system. Systems supporting this interface must be designed to ensure that, when complete, all cache lines in the range are in invalid state or clean state (prefetches may have raced with the invalidation). This must include memory-side caches and other non architectural caches beyond the Point of Coherence (ARM terminology) such that writes will reach memory even after OS programmable address decoders are modified (for CXL this is any HDM decoders that aren't locked). Software will guarantee that no writes to these memory ranges race with this operation. Whilst this is subtly different from write backs must reach the physical memory that difference probably doesn't matter to those reading this series.
The often distributed nature of the relevant coherency management units (e.g. due to interleaving) requires the appropriate commands to be issued to multiple (potentially heterogeneous) units. To enable this a registration framework is provided to which drivers may register a set of callbacks. Upon a request for a cache maintenance operation the framework iterates over all registered callback sets, calling first a command to write back and invalidate, and then optionally a command to wait for completion. Filtering on relevance if a give request is left to the individual drivers.
In this version only one driver is included. This is the HiSilicon Hydra Home Agent driver which controls hardware found on some of our relevant server SoCs. Also available (I can post if anyone is interested) is an ACPI driver based on a firmware interface that was in a public PSCI specification alpha version
QEMU emulation code at
http://gitlab.com/jic23/qemu cxl-2025-03-20
Notes:
- I don't particularly like defining 'generic' infrastructure with so few implementations. If anyone can point me at docs for another one or two, or confirm that they think this is fine that would be great! The converse to this is I don't want to wait longer for those to surface given the necessity to support this one platform that I do know about!
Jonathan Cameron (4):
memregion: Drop unused IORES_DESC_* parameter from
cpu_cache_invalidate_memregion()
arm64: Select GENERIC_CPU_CACHE_MAINTENANCE
MAINTAINERS: Add Jonathan Cameron to drivers/cache and add
lib/cache_maint.c + header
cache: Make top level Kconfig menu a boolean dependent on RISCV
Yicong Yang (2):
memregion: Support fine grained invalidate by
cpu_cache_invalidate_memregion()
lib: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
Yushan Wang (1):
cache: Support cache maintenance for HiSilicon SoC Hydra Home Agent
MAINTAINERS | 3 + arch/arm64/Kconfig | 1 + arch/x86/mm/pat/set_memory.c | 2 +- drivers/cache/Kconfig | 37 +++++- drivers/cache/Makefile | 2 + drivers/cache/hisi_soc_hha.c | 194 ++++++++++++++++++++++++++++++++ drivers/cxl/core/region.c | 5 +- drivers/nvdimm/region.c | 2 +- drivers/nvdimm/region_devs.c | 2 +- include/linux/cache_coherency.h | 61 ++++++++++ include/linux/memregion.h | 16 ++- lib/Kconfig | 4 + lib/Makefile | 2 + lib/cache_maint.c | 138 +++++++++++++++++++++++ 14 files changed, 457 insertions(+), 12 deletions(-) create mode 100644 drivers/cache/hisi_soc_hha.c create mode 100644 include/linux/cache_coherency.h create mode 100644 lib/cache_maint.c
Signature · 1 line
2.48.1