[PATCH v2 2/8] generic: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
Jonathan Cameron
Jonathan.Cameron at huawei.com
Wed Jun 25 09:46:37 PDT 2025
On Tue, 24 Jun 2025 16:47:58 +0100
Jonathan Cameron <Jonathan.Cameron at huawei.com> wrote:
> From: Yicong Yang <yangyicong at hisilicon.com>
>
> ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION provides the mechanism for
> invalidate certain memory regions in a cache-incoherent manner.
> Currently is used by NVIDMM adn CXL memory. This is mainly done
> by the system component and is implementation define per spec.
> Provides a method for the platforms register their own invalidate
> method and implement ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION.
>
> Architectures can opt in for this support via
> CONFIG_GENERIC_CPU_CACHE_INVALIDATE_MEMREGION.
>
> Signed-off-by: Yicong Yang <yangyicong at hisilicon.com>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron at huawei.com>
> diff --git a/drivers/base/cache.c b/drivers/base/cache.c
> new file mode 100644
> index 000000000000..8d351657bbef
> --- /dev/null
> +++ b/drivers/base/cache.c
> @@ -0,0 +1,46 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Generic support for CPU Cache Invalidate Memregion
> + */
> +
> +#include <linux/spinlock.h>
I got carried away dropping some unused headers. This needs
linux/memregion.h
> +#include <linux/export.h>
> +#include <asm/cacheflush.h>
> +
So that the following have 'previous' prototypes.
> +int cpu_cache_invalidate_memregion(int res_desc, phys_addr_t start, size_t len)
> +{
> + guard(spinlock_irqsave)(&scfm_lock);
> + if (!scfm_data)
> + return -EOPNOTSUPP;
> +
> + return scfm_data->invalidate_memregion(res_desc, start, len);
> +}
> +EXPORT_SYMBOL_NS_GPL(cpu_cache_invalidate_memregion, "DEVMEM");
> +
> +bool cpu_cache_has_invalidate_memregion(void)
> +{
> + guard(spinlock_irqsave)(&scfm_lock);
> + return !!scfm_data;
> +}
> +EXPORT_SYMBOL_NS_GPL(cpu_cache_has_invalidate_memregion, "DEVMEM");
More information about the linux-arm-kernel
mailing list