Cache coherency management subsystem
Subsystems (12)
v3 cover Cache coherency management subsystem
Support system level interfaces for cache maintenance as found on some ARM64 systems. This is needed for correct functionality during various forms of memory hotplug (e.g. CXL). Typical hardware has MMIO interface found via ACPI DSDT.
Includes parameter changes to cpu_cache_invalidate_memregion() but no functional changes for architectures that already support this call.
v3:
- Squash the layers by moving all the management code into lib/cache_maint.c that architectures can opt into via GENERIC_CPU_CACHE_MAINTENANCE (Dan). I added entries to Conor's drivers/cache MAINTAINERS entry to include this lib/ code but if preferred I can add a separate entry for it.
- Add a new patch 1 that drops the old IODESC_RES_ parameter as it never did anything other than document intent. With the addition of a flushing range, we would have to check the range and resource type matched. Simpler to just drop the parameter. (Dan)
- Minor fixes and renames as per reviews.
- Even if all else looks good, I fully expect some discussion of the naming as I'm not particularly happy with it.
- Open question on whether is acceptable for the answer to whether cpu_cache_invalidate_memregion() is supported to change as drivers register (potentially after initial boot). Could design a firmware table solution to this, but will take a while - not sure if it is necessary.
- Switch to a fwctl style allocation function that makes the container nature of the allocation explicit.
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. The 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 possible 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 is left to the individual drivers.
Two drivers are included. This HiSilicon Hydra Home Agent driver which controls hardware found on some of our relevant server SoCs and, mostly to show that the approach is general, a driver based on a firmware interface that was in a public PSCI specification alpha version (now dropped - don't merge that!)
QEMU emulation code at
http://gitlab.com/jic23/qemu cxl-2025-03-20
Remaining opens:
- Naming. All suggestions welcome!
- 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!
- I made up the ACPI spec - it's not documented, non official and honestly needs work. I would however like to get feedback on whether it is something we want to try and get through the ACPI Working group as a much improved code first proposal? The potential justification being to avoid the need for lots trivial drivers where maybe a bit of DSDT interpreted code does the job better. (Currently I'm not hearing much demand for this so will probably drop in a future version).
Thanks to all who engaged in the discussion so far.
Jonathan
Jonathan Cameron (5):
memregion: Drop unused IORES_DESC_* parameter from
cpu_cache_invalidate_memregion()
MAINTAINERS: Add Jonathan Cameron to drivers/cache
arm64: Select GENERIC_CPU_CACHE_MAINTENANCE and
ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
acpi: PoC of Cache control via ACPI0019 and _DSM
Hack: Pretend we have PSCI 1.2
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 | 2 + arch/x86/mm/pat/set_memory.c | 2 +- drivers/cache/Kconfig | 22 ++++ drivers/cache/Makefile | 3 + drivers/cache/acpi_cache_control.c | 153 +++++++++++++++++++++++ drivers/cache/hisi_soc_hha.c | 187 +++++++++++++++++++++++++++++ drivers/cxl/core/region.c | 5 +- drivers/firmware/psci/psci.c | 2 + drivers/nvdimm/region.c | 2 +- drivers/nvdimm/region_devs.c | 2 +- include/linux/cache_coherency.h | 57 +++++++++ include/linux/memregion.h | 10 +- lib/Kconfig | 3 + lib/Makefile | 2 + lib/cache_maint.c | 128 ++++++++++++++++++++ 16 files changed, 575 insertions(+), 8 deletions(-) create mode 100644 drivers/cache/acpi_cache_control.c 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
PATCH v3 1/8 memregion: Drop unused IORES_DESC_* parameter from cpu_cache_invalidate_memregion()
The res_desc parameter was originally introduced for documentation purposes and with the idea that with HDM-DB CXL invalidation could be triggered from the device. That has not come to pass and the continued existence of the option is confusing when we add a range in the following patch which might not be a strict subset of the res_desc. So avoid that confusion by dropping the parameter.
---
V3: New patch.
As Dan calls out in the linked mail, an alternative might be to lookup the ranges and enforce the descriptor but his expressed preference was for dropping the parameter.
--- arch/x86/mm/pat/set_memory.c | 2 +- drivers/cxl/core/region.c | 2 +- drivers/nvdimm/region.c | 2 +- drivers/nvdimm/region_devs.c | 2 +- include/linux/memregion.h | 7 +++---- 5 files changed, 7 insertions(+), 8 deletions(-)
arch/x86/mm/pat/set_memory.c +1 -1
@@ -368,7 +368,7 @@ bool cpu_cache_has_invalidate_memregion(void) }EXPORT_SYMBOL_NS_GPL (cpu_cache_has_invalidate_memregion,"DEVMEM" ); -int cpu_cache_invalidate_memregion (int res_desc) +int cpu_cache_invalidate_memregion (void ) {if (WARN_ON_ONCE (!cpu_cache_has_invalidate_memregion ()))return -ENXIO ;
drivers/cxl/core/region.c +1 -1
@@ -228,7 +228,7 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)return -ENXIO ; } -cpu_cache_invalidate_memregion (IORES_DESC_CXL ); +cpu_cache_invalidate_memregion ();return 0 ; }
drivers/nvdimm/region.c +1 -1
@@ -110,7 +110,7 @@ static void nd_region_remove(struct device *dev)* here is ok. */ if (cpu_cache_has_invalidate_memregion ()) -cpu_cache_invalidate_memregion (IORES_DESC_PERSISTENT_MEMORY ); +cpu_cache_invalidate_memregion (); }static int child_notify (struct device *dev,void *data)
drivers/nvdimm/region_devs.c +1 -1
@@ -90,7 +90,7 @@ static int nd_region_invalidate_memregion(struct nd_region *nd_region) } } -cpu_cache_invalidate_memregion (IORES_DESC_PERSISTENT_MEMORY ); +cpu_cache_invalidate_memregion (); out:for (i =0 ; i < nd_region->ndr_mappings; i++) {struct nd_mapping *nd_mapping = &nd_region->mapping[i];
include/linux/memregion.h +3 -4
@@ -26,8 +26,7 @@ static inline void memregion_free(int id)/** * cpu_cache_invalidate_memregion - drop any CPU cached data for -* memregions described by @res_desc -* @res_desc: one of the IORES_DESC_* types +* memregion * * Perform cache maintenance after a memory event / operation that * changes the contents of physical memory in a cache-incoherent manner.
@@ -46,7 +45,7 @@ static inline void memregion_free(int id)* the cache maintenance. */ #ifdef CONFIG_ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION -int cpu_cache_invalidate_memregion (int res_desc); +int cpu_cache_invalidate_memregion (void );bool cpu_cache_has_invalidate_memregion (void );#else static inline bool cpu_cache_has_invalidate_memregion (void )
@@ -54,7 +53,7 @@ static inline bool cpu_cache_has_invalidate_memregion(void)return false; } -static inline int cpu_cache_invalidate_memregion (int res_desc) +static inline int cpu_cache_invalidate_memregion (void ) {WARN_ON_ONCE ("CPU cache invalidation required" );return -ENXIO ;
Signature · 1 line
2.48.1
Re: [PATCH v3 1/8] memregion: Drop unused IORES_DESC_* parameter from cpu_cache_invalidate_memregion()
Quoted 11 lines · Jonathan Cameron
The
res_descparameter was originally introduced for documentation purposes and with the idea that with HDM-DB CXL invalidation could be triggered from the device. That has not come to pass and the continued existence of the option is confusing when we add a range in the following patch which might not be a strict subset of theres_desc. So avoid that confusion by dropping the parameter.Suggested-by Dan Williams <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
Quoted 5 lines
---
V3: New patch.
As Dan calls out in the linked mail, an alternative might be to lookup the ranges and enforce the descriptor but his expressed preference was for dropping the parameter.
PATCH v3 2/8 memregion: Support fine grained invalidate by cpu_cache_invalidate_memregion()
In reply to Jonathan CameronFrom: Yicong Yang <[email protected]>
Extend cpu_cache_invalidate_memregion() to support invalidate certain range of memory by introducing start and length parameters. Control of types of invalidation is left for when usecases turn up. For now everything is Clean and Invalidate.
---
v3: Rebase on top of previous patch that removed the IO_RESDESC_*
parameter.
--- arch/x86/mm/pat/set_memory.c | 2 +- drivers/cxl/core/region.c | 5 ++++- drivers/nvdimm/region.c | 2 +- drivers/nvdimm/region_devs.c | 2 +- include/linux/memregion.h | 7 +++++-- 5 files changed, 12 insertions(+), 6 deletions(-)
arch/x86/mm/pat/set_memory.c +1 -1
@@ -368,7 +368,7 @@ bool cpu_cache_has_invalidate_memregion(void) }EXPORT_SYMBOL_NS_GPL (cpu_cache_has_invalidate_memregion,"DEVMEM" ); -int cpu_cache_invalidate_memregion (void ) +int cpu_cache_invalidate_memregion (phys_addr_t start,size_t len) {if (WARN_ON_ONCE (!cpu_cache_has_invalidate_memregion ()))return -ENXIO ;
drivers/cxl/core/region.c +4 -1
@@ -228,7 +228,10 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)return -ENXIO ; } -cpu_cache_invalidate_memregion (); +if (!cxlr->params.res) +return -ENXIO ; +cpu_cache_invalidate_memregion (cxlr->params.res->start, +resource_size (cxlr->params.res));return 0 ; }
drivers/nvdimm/region.c +1 -1
@@ -110,7 +110,7 @@ static void nd_region_remove(struct device *dev)* here is ok. */ if (cpu_cache_has_invalidate_memregion ()) -cpu_cache_invalidate_memregion (); +cpu_cache_invalidate_memregion (0 ,-1 ); }static int child_notify (struct device *dev,void *data)
drivers/nvdimm/region_devs.c +1 -1
@@ -90,7 +90,7 @@ static int nd_region_invalidate_memregion(struct nd_region *nd_region) } } -cpu_cache_invalidate_memregion (); +cpu_cache_invalidate_memregion (0 ,-1 ); out:for (i =0 ; i < nd_region->ndr_mappings; i++) {struct nd_mapping *nd_mapping = &nd_region->mapping[i];
include/linux/memregion.h +5 -2
@@ -27,6 +27,9 @@ static inline void memregion_free(int id)/** * cpu_cache_invalidate_memregion - drop any CPU cached data for * memregion +* @start: start physical address of the target memory region. +* @len: length of the target memory region. -1 for all the regions of +* the target type. * * Perform cache maintenance after a memory event / operation that * changes the contents of physical memory in a cache-incoherent manner.
@@ -45,7 +48,7 @@ static inline void memregion_free(int id)* the cache maintenance. */ #ifdef CONFIG_ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION -int cpu_cache_invalidate_memregion (void ); +int cpu_cache_invalidate_memregion (phys_addr_t start,size_t len);bool cpu_cache_has_invalidate_memregion (void );#else static inline bool cpu_cache_has_invalidate_memregion (void )
@@ -53,7 +56,7 @@ static inline bool cpu_cache_has_invalidate_memregion(void)return false; } -static inline int cpu_cache_invalidate_memregion (void ) +static inline int cpu_cache_invalidate_memregion (phys_addr_t start,size_t len) {WARN_ON_ONCE ("CPU cache invalidation required" );return -ENXIO ;
Signature · 1 line
2.48.1
Re: [PATCH v3 2/8] memregion: Support fine grained invalidate by cpu_cache_invalidate_memregion()
Quoted 10 lines · Jonathan Cameron
From: Yicong Yang <[email protected]>
Extend
cpu_cache_invalidate_memregion()to support invalidate certain range of memory by introducing start and length parameters. Control of types of invalidation is left for when usecases turn up. For now everything is Clean and Invalidate.Signed-off-by Yicong Yang <[email protected]>Acked-by Davidlohr Bueso <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
I think it might be useful to have a cpu_cache_invalidate_all() helper to replace the open coded:
cpu_cache_invalidate_memregion(0, -1);
...just to document the places that do not know a range to flush. Not critical though so if you spin to add that, great, if not, ok.
PATCH v3 3/8 lib: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
In reply to Jonathan CameronFrom: Yicong Yang <[email protected]>
ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION provides the mechanism for invalidating certain memory regions in a cache-incoherent manner. Currently this is used by NVDIMM and CXL memory drivers in cases where it is necessary to flush all data from caches by physical address range.
In some architectures these operations are supported by system components that may become available only later in boot as they are either present on a discoverable bus, or via a firmware description of an MMIO interface (e.g. ACPI DSDT). Provide a framework to handle this case.
Architectures can opt in for this support viaCONFIG_GENERIC_CPU_CACHE_MAINTENANCE
Add a registration framework. Each driver provides an ops structure and the first op is Write Back and Invalidate by PA Range. The driver may over invalidate.
An optional completion check operation is also provided. If present that should be called to ensure that the action has finished.
When multiple agents are present in the system each should register with this framework and the core code will issue the invalidate to all of them before checking for completion on each. This is done to avoid need for filtering in the core code which can become complex when interleave, potentially across different cache coherency hardware is going on, so it is easier to tell everyone and let those who don't care do nothing.
---
v3: Squash all the layering from v2 so that the infrastucture is
always present.
Suggestions on naming welcome. Note that the hardware I have available supports a much richer set of maintenance operations than Write Back and Invalidate, so I'd like a name that covers all resonable maintenance operations.
Use an allocation wrapper macro, based on the fwctl one to ensure that the first element of the allocated driver structure is a struct cache_coherency_device.
Thanks to all who provided feedback.
--- include/linux/cache_coherency.h | 57 ++++++++++++++ lib/Kconfig | 3 + lib/Makefile | 2 + lib/cache_maint.c | 128 ++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+)
include/linux/cache_coherency.h new file +57 -0
@@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Cache coherency maintenace operation device drivers +* +* Copyright Huawei 2025 +*/ +#ifndef _LINUX_CACHE_COHERENCY_H_ +#define _LINUX_CACHE_COHERENCY_H_ + +#include <linux/list.h> +#include <linux/types.h> + +struct cc_inval_params { +phys_addr_t addr; +size_t size; +}; + +struct cache_coherency_device ; + +struct coherency_ops { +int (*wbinv)(struct cache_coherency_device *ccd,struct cc_inval_params *invp); +int (*done)(struct cache_coherency_device *ccd); +}; + +struct cache_coherency_device { +struct list_head node; +const struct coherency_ops *ops; +}; + +int cache_coherency_device_register (struct cache_coherency_device *ccd); +void cache_coherency_device_unregister (struct cache_coherency_device *ccd); + +struct cache_coherency_device * +_cache_coherency_device_alloc (const struct coherency_ops *ops,size_t size); +/** +* cache_coherency_device_alloc - Allocate a cache coherency device +* @ops: Cache maintenance operations +* @drv_struct: structure that contains the struct cache_coherency_device +* @member: Name of the struct cache_coherency_device member in @drv_struct. +* +* This allocates and initializes the cache_coherency_device embedded in the +* drv_struct. Upon success the pointer must be freed via +* cache_coherency_device_free(). +* +* Returns a 'drv_struct \*' on success, NULL on error. +*/ +#define cache_coherency_device_alloc (ops, drv_struct, member) \ + ({ \ + static_assert(__same_type(struct cache_coherency_device, \ + ((drv_struct *)NULL)->member)); \ + static_assert(offsetof(drv_struct, member) == 0); \ + (drv_struct *)_cache_coherency_device_alloc(ops, \ + sizeof(drv_struct)); \ + }) +void cache_coherency_device_free (struct cache_coherency_device *ccd); + +#endif
lib/Kconfig +3 -0
@@ -543,6 +543,9 @@ config MEMREGION config ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION bool +config GENERIC_CPU_CACHE_MAINTENANCE + bool + config ARCH_HAS_MEMREMAP_COMPAT_ALIGN bool
lib/Makefile +2 -0
@@ -130,6 +130,8 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o +obj-$(CONFIG_GENERIC_CPU_CACHE_MAINTENANCE) += cache_maint.o + lib-y += logic_pio.o lib-$(CONFIG_INDIRECT_IOMEM) += logic_iomem.o
lib/cache_maint.c new file +128 -0
128 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH v3 3/8] lib: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
include/linux/cache_coherency.h line 45
Quoted 13 lines · Jonathan Cameron
include/linux/cache_coherency.h new file +13
-0+struct cache_coherency_device * +_cache_coherency_device_alloc (const struct coherency_ops *ops,size_t size); +/** +* cache_coherency_device_alloc - Allocate a cache coherency device +* @ops: Cache maintenance operations +* @drv_struct: structure that contains the struct cache_coherency_device +* @member: Name of the struct cache_coherency_device member in @drv_struct. +* +* This allocates and initializes the cache_coherency_device embedded in the +* drv_struct. Upon success the pointer must be freed via +* cache_coherency_device_free(). +* +* Returns a 'drv_struct \*' on success, NULL on error.
Preferably:
* Returns: a &drv_struct * on success, %NULL on error.
Quoted 12 lines
+ */
include/linux/cache_coherency.h new file +11
-0+#define cache_coherency_device_alloc (ops, drv_struct, member) \ + ({ \ + static_assert(__same_type(struct cache_coherency_device, \ + ((drv_struct *)NULL)->member)); \ + static_assert(offsetof(drv_struct, member) == 0); \ + (drv_struct *)_cache_coherency_device_alloc(ops, \ + sizeof(drv_struct)); \ + }) +void cache_coherency_device_free (struct cache_coherency_device *ccd); + +#endif
Signature · 1 line
~Randy
Catalin Marinas
maintainerRe: [PATCH v3 3/8] lib: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
In reply to Jonathan Cameronlib/Kconfig config MEMREGION · line 547
Quoted 10 lines · Jonathan Cameron
lib/Kconfig +2
-0@@ -543,6 +543,9 @@ config MEMREGION config ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION bool +config GENERIC_CPU_CACHE_MAINTENANCE + bool
Nit: you could select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION here since the interface is now provided by the generic implementation.
Signature · 1 line
Catalin
Re: [PATCH v3 3/8] lib: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
In reply to Jonathan CameronQuoted 74 lines · Jonathan Cameron
From: Yicong Yang <[email protected]>
ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGIONprovides the mechanism for invalidating certain memory regions in a cache-incoherent manner. Currently this is used by NVDIMM and CXL memory drivers in cases where it is necessary to flush all data from caches by physical address range.In some architectures these operations are supported by system components that may become available only later in boot as they are either present on a discoverable bus, or via a firmware description of an MMIO interface (e.g. ACPI DSDT). Provide a framework to handle this case.
Architectures can opt in for this support via
CONFIG_GENERIC_CPU_CACHE_MAINTENANCEAdd a registration framework. Each driver provides an ops structure and the first op is Write Back and Invalidate by PA Range. The driver may over invalidate.
An optional completion check operation is also provided. If present that should be called to ensure that the action has finished.
When multiple agents are present in the system each should register with this framework and the core code will issue the invalidate to all of them before checking for completion on each. This is done to avoid need for filtering in the core code which can become complex when interleave, potentially across different cache coherency hardware is going on, so it is easier to tell everyone and let those who don't care do nothing.
Signed-off-by Yicong Yang <[email protected]>Co-developed-by Jonathan Cameron <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>---
v3: Squash all the layering from v2 so that the infrastucture is
always present.
Suggestions on naming welcome. Note that the hardware I have available supports a much richer set of maintenance operations than Write Back and Invalidate, so I'd like a name that covers all resonable maintenance operations.
Use an allocation wrapper macro, based on the fwctl one to ensure that the first element of the allocated driver structure is a structcache_coherency_device.
Thanks to all who provided feedback.--- include/linux/cache_coherency.h | 57 ++++++++++++++ lib/Kconfig | 3 + lib/Makefile | 2 + lib/cache_maint.c | 128 ++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+)include/linux/cache_coherency.h new file +18
-0@@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Cache coherency maintenace operation device drivers +* +* Copyright Huawei 2025 +*/ +#ifndef _LINUX_CACHE_COHERENCY_H_ +#define _LINUX_CACHE_COHERENCY_H_ + +#include <linux/list.h> +#include <linux/types.h> + +struct cc_inval_params { +phys_addr_t addr; +size_t size; +}; + +struct cache_coherency_device ;
include/linux/cache_coherency.h line 28
Quoted 10 lines
include/linux/cache_coherency.h new file +10
-0+ +struct coherency_ops { +int (*wbinv)(struct cache_coherency_device *ccd,struct cc_inval_params *invp); +int (*done)(struct cache_coherency_device *ccd); +}; + +struct cache_coherency_device { +struct list_head node; +const struct coherency_ops *ops; +};
Why is this called a device when there is no 'struct device'?
This is just 'cache_coherency_ops'.
Are you sure that this structure does not need something like "priority" or "level" indicator to know where the ops should be sorted in a list? Or is it the responsibility of the arch to make sure that the registration order of the ops structures follows the hierarchy order of the caches?
Quoted 82 lines
include/linux/cache_coherency.h new file +28
-0+int cache_coherency_device_register (struct cache_coherency_device *ccd); +void cache_coherency_device_unregister (struct cache_coherency_device *ccd); + +struct cache_coherency_device * +_cache_coherency_device_alloc (const struct coherency_ops *ops,size_t size); +/** +* cache_coherency_device_alloc - Allocate a cache coherency device +* @ops: Cache maintenance operations +* @drv_struct: structure that contains the struct cache_coherency_device +* @member: Name of the struct cache_coherency_device member in @drv_struct. +* +* This allocates and initializes the cache_coherency_device embedded in the +* drv_struct. Upon success the pointer must be freed via +* cache_coherency_device_free(). +* +* Returns a 'drv_struct \*' on success, NULL on error. +*/ +#define cache_coherency_device_alloc (ops, drv_struct, member) \ + ({ \ + static_assert(__same_type(struct cache_coherency_device, \ + ((drv_struct *)NULL)->member)); \ + static_assert(offsetof(drv_struct, member) == 0); \ + (drv_struct *)_cache_coherency_device_alloc(ops, \ + sizeof(drv_struct)); \ + }) +void cache_coherency_device_free (struct cache_coherency_device *ccd); + +#endif lib/Kconfig +3
-0@@ -543,6 +543,9 @@ config MEMREGION config ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION bool +config GENERIC_CPU_CACHE_MAINTENANCE + bool + config ARCH_HAS_MEMREMAP_COMPAT_ALIGN boollib/Makefile +2
-0@@ -130,6 +130,8 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o +obj-$(CONFIG_GENERIC_CPU_CACHE_MAINTENANCE) += cache_maint.o + lib-y += logic_pio.o lib-$(CONFIG_INDIRECT_IOMEM) += logic_iomem.olib/cache_maint.c new file +21
-0@@ -0,0 +1,128 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Generic support for Memory System Cache Maintenance operations. +* +* Coherency maintenance drivers register with this simple framework that will +* iterate over each registered instance to first kick off invalidation and +* then to wait until it is complete. +* +* If no implementations are registered yet cpu_cache_has_invalidate_memregion() +* will return false. If this runs concurrently with unregistration then a +* race exists but this is no worse than the case where the device responsible +* for a given memory region has not yet registered. +*/ +#include <linux/cache_coherency.h> +#include <linux/cleanup.h> +#include <linux/container_of.h> +#include <linux/export.h> +#include <linux/list.h> +#include <linux/memregion.h> +#include <linux/module.h> +#include <linux/rwsem.h>
lib/cache_maint.c line 31
Quoted 10 lines
lib/cache_maint.c new file +10
-0+#include <linux/slab.h> + +static LIST_HEAD (cache_device_list); +static DECLARE_RWSEM (cache_device_list_lock); + +void cache_coherency_device_free (struct cache_coherency_device *ccd) +{ +kfree (ccd); +} +EXPORT_SYMBOL_GPL (cache_coherency_device_free);
Why do you need a new GPL export wrapper for kfree?
Re: [PATCH v3 3/8] lib: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
Quoted 88 lines · On Mon, 8 Sep 2025 13:59:29 -0700 [email protected] wrote:
Quoted 74 lines · Jonathan Cameron
From: Yicong Yang <[email protected]>
ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGIONprovides the mechanism for invalidating certain memory regions in a cache-incoherent manner. Currently this is used by NVDIMM and CXL memory drivers in cases where it is necessary to flush all data from caches by physical address range.In some architectures these operations are supported by system components that may become available only later in boot as they are either present on a discoverable bus, or via a firmware description of an MMIO interface (e.g. ACPI DSDT). Provide a framework to handle this case.
Architectures can opt in for this support via
CONFIG_GENERIC_CPU_CACHE_MAINTENANCEAdd a registration framework. Each driver provides an ops structure and the first op is Write Back and Invalidate by PA Range. The driver may over invalidate.
An optional completion check operation is also provided. If present that should be called to ensure that the action has finished.
When multiple agents are present in the system each should register with this framework and the core code will issue the invalidate to all of them before checking for completion on each. This is done to avoid need for filtering in the core code which can become complex when interleave, potentially across different cache coherency hardware is going on, so it is easier to tell everyone and let those who don't care do nothing.
Signed-off-by Yicong Yang <[email protected]>Co-developed-by Jonathan Cameron <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>---
v3: Squash all the layering from v2 so that the infrastucture is
always present.
Suggestions on naming welcome. Note that the hardware I have available supports a much richer set of maintenance operations than Write Back and Invalidate, so I'd like a name that covers all resonable maintenance operations.
Use an allocation wrapper macro, based on the fwctl one to ensure that the first element of the allocated driver structure is a structcache_coherency_device.
Thanks to all who provided feedback.--- include/linux/cache_coherency.h | 57 ++++++++++++++ lib/Kconfig | 3 + lib/Makefile | 2 + lib/cache_maint.c | 128 ++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+)include/linux/cache_coherency.h new file +18
-0@@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Cache coherency maintenace operation device drivers +* +* Copyright Huawei 2025 +*/ +#ifndef _LINUX_CACHE_COHERENCY_H_ +#define _LINUX_CACHE_COHERENCY_H_ + +#include <linux/list.h> +#include <linux/types.h> + +struct cc_inval_params { +phys_addr_t addr; +size_t size; +}; + +struct cache_coherency_device ;include/linux/cache_coherency.h line 28
Quoted 10 lines
include/linux/cache_coherency.h new file +10
-0+ +struct coherency_ops { +int (*wbinv)(struct cache_coherency_device *ccd,struct cc_inval_params *invp); +int (*done)(struct cache_coherency_device *ccd); +}; + +struct cache_coherency_device { +struct list_head node; +const struct coherency_ops *ops; +};Why is this called a device when there is no 'struct device'?
Quoted 1 line
This is just '
cache_coherency_ops'.
That's fair. The device went away as Greg KH quite reasonably didn't like the idea of a struct device with no userspace ABI at all.
I'll change the various register / unregister to use terminology
cache_coherency_ops_instance_register() etc to make it clear it isn't just a register one global set of ops.
Quoted 5 lines
Are you sure that this structure does not need something like "priority" or "level" indicator to know where the ops should be sorted in a list? Or is it the responsibility of the arch to make sure that the registration order of the ops structures follows the hierarchy order of the caches?
For all known implementations where we actually need this (so hosts with CXL or similar) the implementation is in a device somewhere on the coherency fabric that is capable of causing appropriate invalidation messages to be issued to all caches to the point where it knows that it there are no copies in the wrong state anywhere. In a simple model an offload agent has grabbed exclusive ownership of the line and written the content to memory.
The multiple 'device' support is about different cachelines being the responsibility of different cache flushing 'devices' (interleave, multiple sockets etc), not a single line being flushed from different places.
The PSCI spec alpha (that never went further) did allow for a case where a complex timing dance was needed but IIRC even that didn't assume an ordering constraint across the various devices. It envisioned a stop world situation where all fetches were disabled until the line was definitely flushed by everyone. Thankfully we don't know of any implementation that needs that.
We might need to extend things in future, but for now no ordering needed.
Quoted 31 lines
Quoted 31 lines
lib/cache_maint.c new file +25
-0@@ -0,0 +1,128 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Generic support for Memory System Cache Maintenance operations. +* +* Coherency maintenance drivers register with this simple framework that will +* iterate over each registered instance to first kick off invalidation and +* then to wait until it is complete. +* +* If no implementations are registered yet cpu_cache_has_invalidate_memregion() +* will return false. If this runs concurrently with unregistration then a +* race exists but this is no worse than the case where the device responsible +* for a given memory region has not yet registered. +*/ +#include <linux/cache_coherency.h> +#include <linux/cleanup.h> +#include <linux/container_of.h> +#include <linux/export.h> +#include <linux/list.h> +#include <linux/memregion.h> +#include <linux/module.h> +#include <linux/rwsem.h> +#include <linux/slab.h> + +static LIST_HEAD (cache_device_list); +static DECLARE_RWSEM (cache_device_list_lock);
Quoted 8 lines
lib/cache_maint.c line 31
Quoted 6 lines
lib/cache_maint.c new file +6
-0+ +void cache_coherency_device_free (struct cache_coherency_device *ccd) +{ +kfree (ccd); +} +EXPORT_SYMBOL_GPL (cache_coherency_device_free);Why do you need a new GPL export wrapper for kfree?
As per your other comment this will become a kref_put() I think.
Quoted 1 line
PATCH v3 4/8 MAINTAINERS: Add Jonathan Cameron to drivers/cache
In reply to Jonathan CameronSeems unfair to inflict the cache-coherency drivers on Conor with out also stepping up as a second maintainer for drivers/cache.
---
v3: Add lib/cache_maint.c and include/cache_coherency.h
Conor, do you mind those two being in this entry? Seems silly to spin another MAINTAINERS entry for a few 10s of lines of simple code.
--- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
@@ -23967,10 +23967,13 @@ F: drivers/staging/ STANDALONE CACHE CONTROLLER DRIVERS M: Conor Dooley <[email protected]> +M: Jonathan Cameron <[email protected]> S: Maintained T: git https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/ F: Documentation/devicetree/bindings/cache/ F: drivers/cache +F: include/cache_coherency.h +F: lib/cache_maint.c STARFIRE/DURALAN NETWORK DRIVER M: Ion Badulescu <[email protected]>
Signature · 1 line
2.48.1
Re: [PATCH v3 4/8] MAINTAINERS: Add Jonathan Cameron to drivers/cache
Quoted 8 lines · Jonathan Cameron
Seems unfair to inflict the cache-coherency drivers on Conor with out also stepping up as a second maintainer for
drivers/cache.Signed-off-by Jonathan Cameron <[email protected]>---
v3: Addlib/cache_maint.candinclude/cache_coherency.h
Conor, do you mind those two being in this entry? Seems silly to spin anotherMAINTAINERSentry for a few 10s of lines of simple code.
Oh damn, I just found this randomly while wondering if this series was going ahead - you forgot to CC me here! I don't mind the extra bits, I think this makes sense, splitting it out would imply a different path for merging.
FWIW, I don't mind using some non-personal tree location for this, but that's something that can be done independently if it's needed.
Quoted 25 lines
--- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+)MAINTAINERS +3
-0@@ -23967,10 +23967,13 @@ F: drivers/staging/ STANDALONE CACHE CONTROLLER DRIVERS M: Conor Dooley <[email protected]> +M: Jonathan Cameron <[email protected]> S: Maintained T: git https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/ F: Documentation/devicetree/bindings/cache/ F: drivers/cache +F: include/cache_coherency.h +F: lib/cache_maint.c STARFIRE/DURALAN NETWORK DRIVER M: Ion Badulescu <[email protected]>Signature · 1 line
2.48.1
PATCH v3 5/8 arm64: Select GENERIC_CPU_CACHE_MAINTENANCE and ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
In reply to Jonathan CameronEnsure the hooks that the generic cache maintenance framework uses are available on ARM64 by selecting ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION.
The generic CPU cache maintenance framework provides a way to register drivers for devices implementing the underlying support for cpu_cache_has_invalidate_memregion().
--- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/Kconfig +2 -0
@@ -21,6 +21,7 @@ config ARM64 select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE select ARCH_HAS_CACHE_LINE_SIZE select ARCH_HAS_CC_PLATFORM + select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEBUG_VM_PGTABLE
@@ -146,6 +147,7 @@ config ARM64 select GENERIC_ARCH_TOPOLOGY select GENERIC_CLOCKEVENTS_BROADCAST select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_CACHE_MAINTENANCE select GENERIC_CPU_DEVICES select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP
Signature · 1 line
2.48.1
Re: [PATCH v3 5/8] arm64: Select GENERIC_CPU_CACHE_MAINTENANCE and ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
Quoted 17 lines · Jonathan Cameron
Ensure the hooks that the generic cache maintenance framework uses are available on ARM64 by selecting
ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION.The generic CPU cache maintenance framework provides a way to register drivers for devices implementing the underlying support for
cpu_cache_has_invalidate_memregion().Signed-off-by Jonathan Cameron <[email protected]>--- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/Kconfig +0
-0
arch/arm64/Kconfig config ARM64 · line 24
Quoted 4 lines
arch/arm64/Kconfig +1
-0@@ -21,6 +21,7 @@ config ARM64 select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE select ARCH_HAS_CACHE_LINE_SIZE select ARCH_HAS_CC_PLATFORM + select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
We could drop this if GENERIC_CPU_CACHE_MAINTENANCE selects it.
arch/arm64/Kconfig config ARM64 · line 150
Quoted 8 lines
arch/arm64/Kconfig +1
-0select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEBUG_VM_PGTABLE@@ -146,6 +147,7 @@ config ARM64 select GENERIC_ARCH_TOPOLOGY select GENERIC_CLOCKEVENTS_BROADCAST select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_CACHE_MAINTENANCE
Either way:
PATCH v3 6/8 cache: Support cache maintenance for HiSilicon SoC Hydra Home Agent
In reply to Jonathan CameronFrom: Yushan Wang <[email protected]>
Hydra Home Agent is a device used to maintain cache coherency. Add support of explicit cache maintenance operations for it.
Memory resource of HHA conflicts with that of HHA PMU. A workaround is implemented here by replacing devm_ioremap_resource() to devm_ioremap() to workaround the resource conflict check.
--- drivers/cache/Kconfig | 15 +++ drivers/cache/Makefile | 2 + drivers/cache/hisi_soc_hha.c | 187 +++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+)
drivers/cache/Kconfig +15 -0
@@ -1,6 +1,21 @@ # SPDX-License-Identifier: GPL-2.0 menu "Cache Drivers" +if GENERIC_CPU_CACHE_MAINTENANCE + +config HISI_SOC_HHA + tristate "HiSilicon Hydra Home Agent (HHA) device driver" + depends on (ARM64 && ACPI) || COMPILE_TEST + help + The Hydra Home Agent (HHA) is responsible for cache coherency + on the SoC. This drivers enables the cache maintenance functions of + the HHA. + + This driver can be built as a module. If so, the module will be + called hisi_soc_hha. + +endif + config AX45MP_L2_CACHE bool "Andes Technology AX45MP L2 Cache controller" depends on RISCV
drivers/cache/Makefile +2 -0
@@ -3,3 +3,5 @@ obj-$(CONFIG_AX45MP_L2_CACHE) += ax45mp_cache.o obj-$(CONFIG_SIFIVE_CCACHE) += sifive_ccache.o obj-$(CONFIG_STARFIVE_STARLINK_CACHE) += starfive_starlink_cache.o + +obj-$(CONFIG_HISI_SOC_HHA) += hisi_soc_hha.o
drivers/cache/hisi_soc_hha.c new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH v3 6/8] cache: Support cache maintenance for HiSilicon SoC Hydra Home Agent
Quoted 13 lines · Jonathan Cameron
From: Yushan Wang <[email protected]>
Hydra Home Agent is a device used to maintain cache coherency. Add support of explicit cache maintenance operations for it.
Memory resource of HHA conflicts with that of HHA PMU. A workaround is implemented here by replacing
devm_ioremap_resource()todevm_ioremap()to workaround the resource conflict check.Signed-off-by Yicong Yang <[email protected]>Co-developed-by Yicong Yang <[email protected]>Signed-off-by Yushan Wang <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
[..]
Quoted 33 lines
drivers/cache/hisi_soc_hha.c new file +33
-0+static int hisi_soc_hha_probe (struct platform_device *pdev) +{ +struct hisi_soc_hha *soc_hha; +struct resource *mem; +int ret; + + soc_hha = cache_coherency_device_alloc(&hha_ops, struct hisi_soc_hha, + ccd); +if (!soc_hha) +return -ENOMEM ; + +platform_set_drvdata (pdev, soc_hha); + +mutex_init (&soc_hha->lock); + + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!mem) +return -ENODEV ; + +/* +* HHA cache driver share the same register region with HHA uncore PMU +* driver in hardware's perspective, none of them should reserve the +* resource to itself only. Here exclusive access verification is +* avoided by calling devm_ioremap instead of devm_ioremap_resource to +* allow both drivers to exist at the same time. +*/ + soc_hha->base =ioremap (mem->start,resource_size (mem)); +if (IS_ERR_OR_NULL (soc_hha->base)) { + ret =dev_err_probe (&pdev->dev,PTR_ERR (soc_hha->base), +"failed to remap io memory" ); + goto err_free_ccd; + } +
drivers/cache/hisi_soc_hha.c line 153
Quoted 10 lines
drivers/cache/hisi_soc_hha.c new file +10
-0+ ret =cache_coherency_device_register (&soc_hha->ccd); +if (ret) + goto err_iounmap; + +return 0 ; + +err_iounmap: +iounmap (soc_hha->base); +err_free_ccd: +cache_coherency_device_free (&soc_hha->ccd);
I understand that this scheme works because ccd is the first member and that is forced at alloc the same way fwctl does it. However, fwctl hides confusing code like this behind put_device() in the free path. So I would say if you want to borrow the "_alloc(ops, drv_struct, member)" approach do also hide the "offsetof(drv_struct, member) == 0" in the object release path and not have eye-popping code like:
cache_coherency_device_free(&soc_hha->ccd)
...that throws away the allocation side cleverness into a cloud of reader confusion. Either make this an actual "device" or otherwise have a kref.
Re: [PATCH v3 6/8] cache: Support cache maintenance for HiSilicon SoC Hydra Home Agent
Quoted 66 lines · On Mon, 8 Sep 2025 15:04:42 -0700 [email protected] wrote:
Quoted 13 lines · Jonathan Cameron
From: Yushan Wang <[email protected]>
Hydra Home Agent is a device used to maintain cache coherency. Add support of explicit cache maintenance operations for it.
Memory resource of HHA conflicts with that of HHA PMU. A workaround is implemented here by replacing
devm_ioremap_resource()todevm_ioremap()to workaround the resource conflict check.Signed-off-by Yicong Yang <[email protected]>Co-developed-by Yicong Yang <[email protected]>Signed-off-by Yushan Wang <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>[..]
Quoted 33 lines
drivers/cache/hisi_soc_hha.c new file +33
-0+static int hisi_soc_hha_probe (struct platform_device *pdev) +{ +struct hisi_soc_hha *soc_hha; +struct resource *mem; +int ret; + + soc_hha = cache_coherency_device_alloc(&hha_ops, struct hisi_soc_hha, + ccd); +if (!soc_hha) +return -ENOMEM ; + +platform_set_drvdata (pdev, soc_hha); + +mutex_init (&soc_hha->lock); + + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!mem) +return -ENODEV ; + +/* +* HHA cache driver share the same register region with HHA uncore PMU +* driver in hardware's perspective, none of them should reserve the +* resource to itself only. Here exclusive access verification is +* avoided by calling devm_ioremap instead of devm_ioremap_resource to +* allow both drivers to exist at the same time. +*/ + soc_hha->base =ioremap (mem->start,resource_size (mem)); +if (IS_ERR_OR_NULL (soc_hha->base)) { + ret =dev_err_probe (&pdev->dev,PTR_ERR (soc_hha->base), +"failed to remap io memory" ); + goto err_free_ccd; + } +drivers/cache/hisi_soc_hha.c line 153
Quoted 10 lines
drivers/cache/hisi_soc_hha.c new file +10
-0+ ret =cache_coherency_device_register (&soc_hha->ccd); +if (ret) + goto err_iounmap; + +return 0 ; + +err_iounmap: +iounmap (soc_hha->base); +err_free_ccd: +cache_coherency_device_free (&soc_hha->ccd);I understand that this scheme works because ccd is the first member and that is forced at alloc the same way fwctl does it. However, fwctl hides confusing code like this behind
put_device()in the free path. So I would say if you want to borrow the "_alloc(ops, drv_struct, member)" approach do also hide the "offsetof(drv_struct, member)== 0" in the object release path and not have eye-popping code like:
Quoted 5 lines
cache_coherency_device_free(&soc_hha->ccd)...that throws away the allocation side cleverness into a cloud of reader confusion. Either make this an actual "device" or otherwise have a kref.
The device option is out because Greg KH was not keen on me using that infrastructure when we don't have any userspace ABI.
Kref seems fine but because we have to pass an explicit release to kref_put() we end up either with the odd looking
kfree_put(&soc_hha->cci, cache_coherency_ops_inst_free);
or wrapping it up with a helper along the lines of cache_coherency_ops_instance_put(&soc_hha->cci);
That seems reasonable but given there is no real reference counting going on (the reference count == 1 from alloc to this call) using an actual kref is perhaps overkill because this is really the same as having no kref and just implementing.
void cache_coherency_ops_instance_put(struct cache_coherency_ops_inst *cci)
{
kfree(cci);
}So other than a rename it is the same as current implementation. :(
So for now I'm thinking have the helper and use a kref even if it's rather silly just because it will then behave how people (hopefully) expect it to.
Jonathan
PATCH v3 7/8 acpi: PoC of Cache control via ACPI0019 and _DSM
In reply to Jonathan CameronDo not merge. This is the bare outline of what may become an ACPI code first specification proposal. For that reason it remains an RFC and is mainly here to show that the framework is flexible enough to be useful by providing a second driver.
From various discussions, it has become clear that there is some desire not to end up needing a cache flushing driver for every host that supports the flush by PA range functionality that is needed for CXL and similar disagregated memory pools where the host PA mapping to actual memory may change over time and where various races can occur with prefetchers making it hard to use CPU instructions to flush all stale data out.
There was once an ARM PSCI specification [1] that defined a firmware interface to solve this problem. However that meant dropping into a more privileged mode, or chatting to an external firmware. That was overkill for those systems that provide a simple MMIO register interface for these operations (which seems to be the common case). That specification never made it beyond alpha level.
For the typical class of machine that actually uses these disaggregated pools, ACPI can potentially provide the same benefits with a great deal more flexibility. A _DSM in DSDT via operation regions, may be used to do any of:
1) Make firmware calls
2) Operate a register based state machine.
3) Most other things you might dream of.
This was prototyped against an implementation of the ARM specification in
[1] wrapped up in _DSM magic. That was chosen to give a second (be it abandoned) example of how this cache control class can be used.
--- drivers/cache/Kconfig | 7 ++ drivers/cache/Makefile | 1 + drivers/cache/acpi_cache_control.c | 153 +++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+)
drivers/cache/Kconfig +7 -0
@@ -3,6 +3,13 @@ menu "Cache Drivers" if GENERIC_CPU_CACHE_MAINTENANCE +config ACPI_CACHE_CONTROL + tristate "ACPI cache maintenance" + depends on ARM64 && ACPI + help + ACPI0019 device ID in DSDT identifies an interface that may be used + to carry out certain forms of cache flush operation. + config HISI_SOC_HHA tristate "HiSilicon Hydra Home Agent (HHA) device driver" depends on (ARM64 && ACPI) || COMPILE_TEST
drivers/cache/Makefile +1 -0
@@ -4,4 +4,5 @@ obj-$(CONFIG_AX45MP_L2_CACHE) += ax45mp_cache.o obj-$(CONFIG_SIFIVE_CCACHE) += sifive_ccache.o obj-$(CONFIG_STARFIVE_STARLINK_CACHE) += starfive_starlink_cache.o +obj-$(CONFIG_ACPI_CACHE_CONTROL) += acpi_cache_control.o obj-$(CONFIG_HISI_SOC_HHA) += hisi_soc_hha.o
drivers/cache/acpi_cache_control.c new file +153 -0
153 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH v3 7/8] acpi: PoC of Cache control via ACPI0019 and _DSM
Hi,
drivers/cache/Kconfig menu "Cache Drivers" · line 9
Quoted 12 lines · Jonathan Cameron
drivers/cache/Kconfig +4
-0@@ -3,6 +3,13 @@ menu "Cache Drivers" if GENERIC_CPU_CACHE_MAINTENANCE +config ACPI_CACHE_CONTROL + tristate "ACPI cache maintenance" + depends on ARM64 && ACPI + help
If there is a v4, please use one tab to indent the 3 lines above.
drivers/cache/Kconfig menu "Cache Drivers" · line 10
Quoted 1 line
drivers/cache/Kconfig +1
-0+ ACPI0019 device ID in DSDT identifies an interface that may be used
and tab + 2 spaces to indent the 1 line above.
Quoted 1 line
drivers/cache/Kconfig +1
-0+ to carry out certain forms of cache flush operation.
Signature · 1 line
~Randy
PATCH v3 8/8 Hack: Pretend we have PSCI 1.2
In reply to Jonathan CameronNeed to update QEMU to PSCI 1.2. In meantime lie.
This is just here to aid testing, not for review!
--- drivers/firmware/psci/psci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firmware/psci/psci.c +2 -0
@@ -646,6 +646,8 @@ static void __init psci_init_smccc(void) } } +/* Hack until qemu version stuff updated */ +arm_smccc_version_init (ARM_SMCCC_VERSION_1_2 , psci_conduit);/* * Conveniently, the SMCCC and PSCI versions are encoded the * same way. No, this isn't accidental.
Signature · 1 line
2.48.1