Skip to contentSkip to conversation

Add SMCCC cache clean/invalidate provider

PATCH Superseded Srirangan Madhavan 4 participants 9 messages Oct 13 – Oct 21

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add SMCCC cache clean/invalidate provider

This series adds an arm64 backend for memregion cache invalidation users based on the Arm SMCCC cache clean+invalidate interface.

Per DEN0028, this interface targets systems where a Normal Cacheable memory region can be modified in ways that are not handled by usual PE coherency mechanisms, and where VA-based CMOs may be too slow or insufficient for large ranges and/or system-cache implementations.

Representative use cases include device-backed memory state transitions where stale CPU/system cache lines must be invalidated reliably (for example secure erase, reset/offline flows, and dynamic memory reconfiguration).

Patch 1 introduces the Arm SMCCC cache clean/invalidate function IDs and transient return codes needed by callers [1].

Patch 2 adds a cache maintenance provider that:
- registers the interface attributes function as an SMCCC device
- binds to the service through the SMCCC bus
- registers with the generic cache coherency framework used by cpu_cache_invalidate_memregion()
- handles transient BUSY/RATE_LIMITED responses with bounded retries

This patch set does not add a software fallback path; when firmware does not implement the SMCCC cache maintenance interface, the SMCCC device is not registered and existing behavior is preserved.

The series is based on the current SMCCC bus topic branch queued for v7.4 [3].

References:
[1] https://developer.arm.com/documentation/den0028/h
[2] https://lore.kernel.org/linux-cxl/[email protected]/
[3] https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/log/?h=for-next/smccc-bus

DEN0028 v1.7 has since been confirmed as stable.

Testing:
- With corresponding TF-A support enabled, exercised the cache operation path through CXL Reset [2] and verified that it invokes the SMCCC call and completes the cache flush successfully.
- ARM64 defconfig with CONFIG_CACHEMAINT_FOR_HOTPLUG=y and CONFIG_ARM_SMCCC_CACHE=y
- W=1 build of drivers/cache/arm_smccc_cache.o
- W=1 build of the ARM64 Image

Changes since v3:
- Rebased onto the current SMCCC bus topic branch queued for v7.4.
- Converted the provider to an SMCCC bus driver and registered the attributes function as an SMCCC device.
- Added an explicit DEN0028 v1.7 reference to the provider source and patch 2 commit message.
- Dropped the unused tools/include copy of the new definitions.
- Replaced the catch-all linux/kernel.h include with the specific headers used by the provider.
- Added Reviewed-by tags for patch 1 from Bence and Andre.
- Dropped the review tags from patch 2 because the SMCCC bus conversion changed its discovery and initialization paths after the rebase.

Srirangan Madhavan (2):
arm64: smccc: add cache clean/invalidate IDs and return codes
cache: add SMCCC-backed cache invalidate provider

 drivers/cache/Kconfig           |  11 +++
 drivers/cache/Makefile          |   2 +
 drivers/cache/arm_smccc_cache.c | 161 ++++++++++++++++++++++++++++++++
 drivers/firmware/smccc/smccc.c  |   5 +
 include/linux/arm-smccc.h       |  21 ++++-
 5 files changed, 198 insertions(+), 2 deletions(-)
 create mode 100644 drivers/cache/arm_smccc_cache.c

base-commit: c6e78a4080a3b310a9f61db778d6dee7bc646cb7

Signature · 1 line
2.43.0
#1 lore raw

PATCH v4 1/2 arm64: smccc: add cache clean/invalidate IDs and return codes

Define SMCCC Arch function IDs for CLEAN_INV_MEMREGION and its ATTRIBUTES call, and add RATE_LIMITED/BUSY return codes from DEN0028 for callers that need transient error handling.

---
 include/linux/arm-smccc.h | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
include/linux/arm-smccc.h +19 -2
index 4de81848fe2e..2e205320d88a 100644
@@ -116,6 +116,22 @@
 			   ARM_SMCCC_SMC_32,				\
 			   ARM_SMCCC_OWNER_CPU, 0x10)
 
+/*
+ * DEN0028 v1.7 defines these cache maintenance functions as SMC64
+ * because they carry 64-bit memory range arguments.
+ */
+#define ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION				\
+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
+			   ARM_SMCCC_SMC_64,				\
+			   ARM_SMCCC_OWNER_ARCH,			\
+			   0x5)
+
+#define ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION_ATTRIBUTES			\
+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
+			   ARM_SMCCC_SMC_64,				\
+			   ARM_SMCCC_OWNER_ARCH,			\
+			   0x6)
+
 #define ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID				\
 	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
 			   ARM_SMCCC_SMC_32,				\
@@ -305,13 +321,14 @@
 			   0x53)
 
 /*
- * Return codes defined in ARM DEN 0070A
- * ARM DEN 0070A is now merged/consolidated into ARM DEN 0028 C
+ * Return codes defined by Arm SMCCC (DEN0028 v1.7).
  */
 #define SMCCC_RET_SUCCESS			0
 #define SMCCC_RET_NOT_SUPPORTED			-1
 #define SMCCC_RET_NOT_REQUIRED			-2
 #define SMCCC_RET_INVALID_PARAMETER		-3
+#define SMCCC_RET_RATE_LIMITED			-4
+#define SMCCC_RET_BUSY				-5
 
 #ifndef __ASSEMBLY__
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v4 2/2 cache: add SMCCC-backed cache invalidate provider

In reply to Srirangan Madhavan

Add a cache maintenance provider for the cache clean+invalidate interface defined by Arm DEN0028 v1.7.

Register the interface attributes function as an SMCCC device and bind the provider through the SMCCC bus. The provider reads the firmware attributes during probe and serializes cache maintenance calls. It handles transient BUSY and RATE_LIMITED responses with bounded retries. It also registers with the generic cache coherency framework used by memregion callers.

---
 drivers/cache/Kconfig           |  11 +++
 drivers/cache/Makefile          |   2 +
 drivers/cache/arm_smccc_cache.c | 161 ++++++++++++++++++++++++++++++++
 drivers/firmware/smccc/smccc.c  |   5 +
 4 files changed, 179 insertions(+)
 create mode 100644 drivers/cache/arm_smccc_cache.c
drivers/cache/Kconfig +11 -0
index 1518449d47b5..57fd1823dec5 100644
@@ -42,6 +42,17 @@ menuconfig CACHEMAINT_FOR_HOTPLUG
 
 if CACHEMAINT_FOR_HOTPLUG
 
+config ARM_SMCCC_CACHE
+	bool "Arm SMCCC cache maintenance provider"
+	depends on ARM64 && HAVE_ARM_SMCCC_DISCOVERY
+	help
+	  Enable support for the Arm SMCCC cache clean+invalidate
+	  interface as a provider for memory hotplug-like cache
+	  maintenance operations.
+	  The provider registers only when firmware advertises the
+	  SMCCC calls and attributes, so systems without firmware support
+	  continue without this registered provider.
+
 config HISI_SOC_HHA
 	tristate "HiSilicon Hydra Home Agent (HHA) device driver"
 	depends on (ARM64 && ACPI) || COMPILE_TEST
drivers/cache/Makefile +2 -0
index b3362b15d6c1..55736a032d6f 100644
@@ -4,4 +4,6 @@ obj-$(CONFIG_AX45MP_L2_CACHE)		+= ax45mp_cache.o
 obj-$(CONFIG_SIFIVE_CCACHE)		+= sifive_ccache.o
 obj-$(CONFIG_STARFIVE_STARLINK_CACHE)	+= starfive_starlink_cache.o
 
+# Providers below depend on CACHEMAINT_FOR_HOTPLUG.
+obj-$(CONFIG_ARM_SMCCC_CACHE)		+= arm_smccc_cache.o
 obj-$(CONFIG_HISI_SOC_HHA)		+= hisi_soc_hha.o
drivers/cache/arm_smccc_cache.c new file +161 -0

161 lines not on this page · raw message

drivers/firmware/smccc/smccc.c +5 -0
index 5dc768ac4143..5a5d50d17410 100644
@@ -100,6 +100,11 @@ static const struct smccc_device_info smccc_devices[] __initconst = {
 		.requires_smc   = true,
 		.device_name    = "arm-rsi",
 	},
+	{
+		.func_id        = ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION_ATTRIBUTES,
+		.requires_smc   = false,
+		.device_name    = "arm-smccc-cache",
+	},
 };
 
 static bool __init smccc_probe_smccc_device(const struct smccc_device_info *smccc_dev)
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH v4 2/2] cache: add SMCCC-backed cache invalidate provider

Hi,

thanks for adapting this to the SMCCC bus, that part looks good. Some minor things:

Quoted 110 lines · Srirangan Madhavan

Add a cache maintenance provider for the cache clean+invalidate interface defined by Arm DEN0028 v1.7.

Register the interface attributes function as an SMCCC device and bind the provider through the SMCCC bus. The provider reads the firmware attributes during probe and serializes cache maintenance calls. It handles transient BUSY and RATE_LIMITED responses with bounded retries. It also registers with the generic cache coherency framework used by memregion callers.

---
  drivers/cache/Kconfig           |  11 +++
  drivers/cache/Makefile          |   2 +
  drivers/cache/arm_smccc_cache.c | 161 ++++++++++++++++++++++++++++++++
  drivers/firmware/smccc/smccc.c  |   5 +
  4 files changed, 179 insertions(+)

create mode 100644 drivers/cache/arm_smccc_cache.c

drivers/cache/Kconfig +11 -0
index 1518449d47b5..57fd1823dec5 100644
@@ -42,6 +42,17 @@ menuconfig CACHEMAINT_FOR_HOTPLUG
 
  if CACHEMAINT_FOR_HOTPLUG
 
+config ARM_SMCCC_CACHE
+	bool "Arm SMCCC cache maintenance provider"
+	depends on ARM64 && HAVE_ARM_SMCCC_DISCOVERY
+	help
+	  Enable support for the Arm SMCCC cache clean+invalidate
+	  interface as a provider for memory hotplug-like cache
+	  maintenance operations.
+	  The provider registers only when firmware advertises the
+	  SMCCC calls and attributes, so systems without firmware support
+	  continue without this registered provider.
+
  config HISI_SOC_HHA
  	tristate "HiSilicon Hydra Home Agent (HHA) device driver"
  	depends on (ARM64 && ACPI) || COMPILE_TEST
drivers/cache/Makefile +2 -0
index b3362b15d6c1..55736a032d6f 100644
@@ -4,4 +4,6 @@ obj-$(CONFIG_AX45MP_L2_CACHE)		+= ax45mp_cache.o
  obj-$(CONFIG_SIFIVE_CCACHE)		+= sifive_ccache.o
  obj-$(CONFIG_STARFIVE_STARLINK_CACHE)	+= starfive_starlink_cache.o
 
+# Providers below depend on CACHEMAINT_FOR_HOTPLUG.
+obj-$(CONFIG_ARM_SMCCC_CACHE)		+= arm_smccc_cache.o
  obj-$(CONFIG_HISI_SOC_HHA)		+= hisi_soc_hha.o
drivers/cache/arm_smccc_cache.c new file +53 -0
new file mode 100644
index 000000000000..aca71113eb1c
@@ -0,0 +1,161 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2026 NVIDIA Corporation
+ *
+ * Arm SMCCC cache maintenance provider using the cache clean+invalidate
+ * interface defined by Arm DEN0028 v1.7.
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/arm-smccc-bus.h>
+#include <linux/cache_coherency.h>
+#include <linux/cleanup.h>
+#include <linux/container_of.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/math.h>
+#include <linux/minmax.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/nmi.h>
+#include <linux/time64.h>
+#include <linux/types.h>
+#include <linux/wordpart.h>
+
+#define SMCCC_CACHE_MAX_RETRIES		5
+#define SMCCC_CACHE_DEFAULT_DELAY_US	1000UL
+#define SMCCC_CACHE_MAX_DELAY_US	20000UL
+
+struct smccc_cache {
+	/* Must be first member */
+	struct cache_coherency_ops_inst cci;
+	struct mutex lock; /* Serializes SMCCC cache maintenance calls. */
+	u64 rate_limit;
+	u32 latency_us;
+};
+
+static int smccc_cache_status_to_errno(s32 status)
+{
+	switch (status) {
+	case SMCCC_RET_SUCCESS:
+		return 0;
+	case SMCCC_RET_NOT_SUPPORTED:
+		return -EOPNOTSUPP;
+	case SMCCC_RET_INVALID_PARAMETER:
+		return -EINVAL;
+	case SMCCC_RET_RATE_LIMITED:
+		return -EAGAIN;
+	case SMCCC_RET_BUSY:
+		return -EBUSY;
+	default:
+		return -EIO;
+	}
+}

drivers/cache/arm_smccc_cache.c line 63

Quoted 10 lines
drivers/cache/arm_smccc_cache.c new file +10 -0
+
+static unsigned long smccc_cache_delay_us(const struct smccc_cache *cache)
+{
+	unsigned long delay_us = 0;
+
+	if (cache->rate_limit)
+		delay_us = DIV_ROUND_UP_ULL(USEC_PER_SEC, cache->rate_limit);
+
+	if (cache->latency_us)
+		delay_us = max(delay_us, (unsigned long)cache->latency_us);

If I understand the spec correctly, then the provided latency value reports the time it takes to execute the call. So this might be used to decide if we can tolerate the blackout time, but I don't think we make this decision in the kernel, or have the interface to do so. So I don't think we need to parse this value, or use it for calculating the back-off time, and you can just remove this part.

Quoted 49 lines
drivers/cache/arm_smccc_cache.c new file +49 -0
+
+	/*
+	 * Firmware may advertise neither a rate limit nor a latency hint; use
+	 * a small bounded backoff instead of retrying in a tight loop.
+	 */
+	if (!delay_us)
+		delay_us = SMCCC_CACHE_DEFAULT_DELAY_US;
+
+	return min(delay_us, SMCCC_CACHE_MAX_DELAY_US);
+}
+
+static int smccc_cache_wbinv(struct cache_coherency_ops_inst *cci,
+			     struct cc_inval_params *invp)
+{
+	struct smccc_cache *cache = container_of(cci, struct smccc_cache, cci);
+	unsigned long delay_us = smccc_cache_delay_us(cache);
+	struct arm_smccc_res res = {};
+	int ret;
+
+	if (!invp->size)
+		return -EINVAL;
+
+	/*
+	 * Serialize the full retry sequence. With the default bounds, a caller
+	 * may hold the mutex across up to five 20ms backoff sleeps.
+	 */
+	guard(mutex)(&cache->lock);
+
+	for (unsigned int i = 0; i < SMCCC_CACHE_MAX_RETRIES; i++) {
+		/* Long firmware operations can trigger watchdog checks. */
+		touch_nmi_watchdog();
+
+		arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION,
+				     invp->addr, invp->size, 0UL, &res);
+
+		ret = smccc_cache_status_to_errno((s32)res.a0);
+		if (!ret)
+			return 0;
+
+		if (ret != -EBUSY && ret != -EAGAIN)
+			return ret;
+
+		fsleep(delay_us);
+	}
+
+	return ret;
+}
+
+static const struct cache_coherency_ops smccc_cache_ops = {

drivers/cache/arm_smccc_cache.c line 122

Quoted 10 lines
drivers/cache/arm_smccc_cache.c new file +10 -0
+	.wbinv = smccc_cache_wbinv,
+};
+
+static int smccc_cache_probe(struct arm_smccc_device *sdev)
+{
+	struct arm_smccc_res res = {};
+	struct smccc_cache *cache;
+	int ret;
+
+	arm_smccc_1_1_invoke(sdev->func_id, &res);

I think you should provide the explicit function ID name here, and not rely on which function exactly is used to probe for the interface's existence.

drivers/cache/arm_smccc_cache.c line 133

Quoted 11 lines
drivers/cache/arm_smccc_cache.c new file +11 -0
+	if ((s32)res.a0)
+		return -ENODEV;
+
+	cache = cache_coherency_ops_instance_alloc(&smccc_cache_ops,
+						   struct smccc_cache, cci);
+	if (!cache)
+		return -ENOMEM;
+
+	mutex_init(&cache->lock);
+	cache->latency_us = lower_32_bits(res.a2);
+	cache->rate_limit = res.a3;

According to the spec you would need lower_32_bits() for a3 as well - if we are going to use this value. But I don't think we need to, see above.

Cheers,
Andre

Quoted 44 lines
drivers/cache/arm_smccc_cache.c new file +28 -0
+
+	ret = cache_coherency_ops_instance_register(&cache->cci);
+	if (ret) {
+		mutex_destroy(&cache->lock);
+		cache_coherency_ops_instance_put(&cache->cci);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct arm_smccc_device_id smccc_cache_id_table[] = {
+	{ .func_id = ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION_ATTRIBUTES },
+	{}
+};
+MODULE_DEVICE_TABLE(arm_smccc, smccc_cache_id_table);
+
+static struct arm_smccc_driver smccc_cache_driver = {
+	.name = KBUILD_MODNAME,
+	.probe = smccc_cache_probe,
+	.id_table = smccc_cache_id_table,
+};
+module_arm_smccc_driver(smccc_cache_driver);
+
+MODULE_IMPORT_NS("CACHE_COHERENCY");
+MODULE_AUTHOR("Srirangan Madhavan");
+MODULE_DESCRIPTION("Arm SMCCC cache maintenance provider");
+MODULE_LICENSE("GPL");
drivers/firmware/smccc/smccc.c +5 -0
index 5dc768ac4143..5a5d50d17410 100644
@@ -100,6 +100,11 @@ static const struct smccc_device_info smccc_devices[] __initconst = {
  		.requires_smc   = true,
  		.device_name    = "arm-rsi",
  	},
+	{
+		.func_id        = ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION_ATTRIBUTES,
+		.requires_smc   = false,
+		.device_name    = "arm-smccc-cache",
+	},
  };
 
  static bool __init smccc_probe_smccc_device(const struct smccc_device_info *smccc_dev)
#4 lore raw

Re: [PATCH v4 2/2] cache: add SMCCC-backed cache invalidate provider

Hi,

Quoted 9 lines · Andre Przywara

drivers/cache/arm_smccc_cache.c line 122

Quoted 7 lines
drivers/cache/arm_smccc_cache.c new file +7 -0
+static int smccc_cache_probe(struct arm_smccc_device *sdev)
+{
+    struct arm_smccc_res res = {};
+    struct smccc_cache *cache;
+    int ret;
+
+    arm_smccc_1_1_invoke(sdev->func_id, &res);

I think you should provide the explicit function ID name here, and not rely on which function exactly is used to probe for the interface's existence.

I thought that was the point of the matcher, that you could in theory assign the same probe handler to any function ID? For example if there's some FW that implements this (or a compatible) function, but at a different ID, you would only update the match table? At least that's how most subsystems (I2C, PCI, USB) do it.

Quoted 5 lines
Quoted 5 lines

+    if ((s32)res.a0)
+        return -ENODEV;
+
+    cache = cache_coherency_ops_instance_alloc(&smccc_cache_ops, +                           struct smccc_cache, cci);

Quoted 8 lines
Quoted 6 lines

+    if (!cache)
+        return -ENOMEM;
+
+    mutex_init(&cache->lock);
+    cache->latency_us = lower_32_bits(res.a2);
+    cache->rate_limit = res.a3;

According to the spec you would need lower_32_bits() for a3 as well - if we are going to use this value. But I don't think we need to, see above.

Where does it say that? My copy of DEN 0028 1.7 H, released 2026/Jul/24, only says the following:

X3 (uint64_t attr_2)
Rate Limit: The maximum number of SMCCCC_ARCH_CLEAN_INV_MEMREGION
calls allowed per second. If set to 0, it indicates that this field is not reported by the implementation.

See my second-to-last comment on v2 of this patch:

https://lore.kernel.org/lkml/[email protected]/

Maybe I have an outdated copy already? ;_;

Bence

#5 lore raw

Re: [PATCH v4 2/2] cache: add SMCCC-backed cache invalidate provider

Hi,

Quoted 13 lines · Bence Csókás

Hi,

Quoted 9 lines · Andre Przywara

drivers/cache/arm_smccc_cache.c line 122

Quoted 7 lines
drivers/cache/arm_smccc_cache.c new file +7 -0
+static int smccc_cache_probe(struct arm_smccc_device *sdev)
+{
+    struct arm_smccc_res res = {};
+    struct smccc_cache *cache;
+    int ret;
+
+    arm_smccc_1_1_invoke(sdev->func_id, &res);

I think you should provide the explicit function ID name here, and not rely on which function exactly is used to probe for the interface's existence.

Quoted 1 line

I thought that was the point of the matcher, that you could in theory

But that probe() function here is not a "matcher" or a check function, that is done in the SMCCC bus generic code, using a function ID that has no side effects and does not return -1.

The reason for this SMC call here is to learn the attributes, they are used below to fill the latency and rate_limit fields in the struct. So we should then make this explicit, I think, by using the ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION_ATTRIBUTES name.

Quoted 1 line

assign the same probe handler to any function ID? For example if there's some FW that implements this (or a compatible) function, but at a different ID, you would only update the match table? At least that's how most subsystems (I2C, PCI, USB) do it.

Not sure I understand this, this is a driver specifically for the CLEANINV_MEM_REGION SMCCC interface, I don't see how you would reuse that, or plug any other interfaces to it.

Quoted 19 lines
Quoted 5 lines
Quoted 5 lines

+    if ((s32)res.a0)
+        return -ENODEV;
+
+    cache = cache_coherency_ops_instance_alloc(&smccc_cache_ops, +                           struct smccc_cache, cci);

Quoted 8 lines
Quoted 6 lines

+    if (!cache)
+        return -ENOMEM;
+
+    mutex_init(&cache->lock);
+    cache->latency_us = lower_32_bits(res.a2);
+    cache->rate_limit = res.a3;

According to the spec you would need lower_32_bits() for a3 as well - if we are going to use this value. But I don't think we need to, see above.

Where does it say that? My copy of DEN 0028 1.7 H, released 2026/Jul/24, only says the following:

  X3 (uint64_t attr_2)
    Rate Limit: The maximum number of SMCCCC_ARCH_CLEAN_INV_MEMREGION
calls allowed per second. If set to 0, it indicates that this field is not reported by the implementation.

Quoted 5 lines

See my second-to-last comment on v2 of this patch:

https://lore.kernel.org/lkml/[email protected]/

Maybe I have an outdated copy already? ;_;

No, I had! Mine said v1.7H, but is was an early version, which had the upper 32 bits of rate_limit as reserved. Indeed in the later public version it's a 64-bit field, so ignore my comment. Sorry for the noise!

Cheers,
Andre

Reviewed-by on v4 2/2
#7 lore raw

Re: [PATCH v4 2/2] cache: add SMCCC-backed cache invalidate provider

In reply to Srirangan Madhavan
Quoted 10 lines · On Tue, 13 Oct 2026 07:02:05 +0000 Srirangan Madhavan <[email protected]>…

Add a cache maintenance provider for the cache clean+invalidate interface defined by Arm DEN0028 v1.7.

Register the interface attributes function as an SMCCC device and bind the provider through the SMCCC bus. The provider reads the firmware attributes during probe and serializes cache maintenance calls. It handles transient BUSY and RATE_LIMITED responses with bounded retries. It also registers with the generic cache coherency framework used by memregion callers.

I'm fine with the changes to put it on the bus and Andre's suggestion to drop the latency value handling. So with that done

I'd probably not have bothered with the mutex_destroy() given limited utility vs code added (I mind that less if devm is appropriate, but doing that here would be messy). If we ever see a use of that after the destroy then something exceedingly weird is going on!

Anyhow, doesn't really matter either way.

Jonathan

#6 lore raw

Re: [PATCH v4 2/2] cache: add SMCCC-backed cache invalidate provider

In reply to Andre Przywara
Quoted 22 lines · Andre Przywara
Quoted 12 lines
Quoted 11 lines

drivers/cache/arm_smccc_cache.c line 122

Quoted 7 lines
drivers/cache/arm_smccc_cache.c new file +7 -0
+static int smccc_cache_probe(struct arm_smccc_device *sdev)
+{
+    struct arm_smccc_res res = {};
+    struct smccc_cache *cache;
+    int ret;
+
+    arm_smccc_1_1_invoke(sdev->func_id, &res);

I think you should provide the explicit function ID name here, and not rely on which function exactly is used to probe for the interface's existence.

Quoted 1 line

I thought that was the point of the matcher, that you could in theory

But that probe() function here is not a "matcher" or a check function, that is done in the SMCCC bus generic code, using a function ID that has no side effects and does not return -1.

The reason for this SMC call here is to learn the attributes, they are used below to fill the latency and rate_limit fields in the struct. So we should then make this explicit, I think, by using the ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION_ATTRIBUTES name.

Quoted 8 lines
Quoted 4 lines

assign the same probe handler to any function ID? For example if there's some FW that implements this (or a compatible) function, but at a different ID, you would only update the match table? At least that's how most subsystems (I2C, PCI, USB) do it.

Not sure I understand this, this is a driver specifically for the CLEANINV_MEM_REGION SMCCC interface, I don't see how you would reuse that, or plug any other interfaces to it.

Thanks. The SMCCC bus has already performed the device matching before probe(), and this invocation is specifically used to retrieve the cache maintenance attributes. I changed this in v5 to use the explicit function ID.

Signature · 2 lines
Regards,
Srirangan
#8 lore raw

Re: [PATCH v4 2/2] cache: add SMCCC-backed cache invalidate provider

In reply to Jonathan Cameron
Quoted 22 lines · Jonathan Cameron

External email: Use caution opening links or attachments

Quoted 10 lines · On Tue, 13 Oct 2026 07:02:05 +0000 Srirangan Madhavan <[email protected]>…

Add a cache maintenance provider for the cache clean+invalidate interface defined by Arm DEN0028 v1.7.

Register the interface attributes function as an SMCCC device and bind the provider through the SMCCC bus. The provider reads the firmware attributes during probe and serializes cache maintenance calls. It handles transient BUSY and RATE_LIMITED responses with bounded retries. It also registers with the generic cache coherency framework used by memregion callers.

I'm fine with the changes to put it on the bus and Andre's suggestion to drop the latency value handling. So with that done

Quoted 8 lines

I'd probably not have bothered with the mutex_destroy() given limited utility vs code added (I mind that less if devm is appropriate, but doing that here would be messy). If we ever see a use of that after the destroy then something exceedingly weird is going on!

Anyhow, doesn't really matter either way.

Jonathan

Thanks, Jonathan.
The latency handling has been removed in v5 and I have added your Reviewed-by tag. I left mutex_destroy() in place as it is a harmless cleanup.

Signature · 2 lines
Regards,
Srirangan