Skip to contentSkip to conversation

Add StarFive's JH8100 StarLink Cache Controller

PATCH Superseded Joshua Yeong 3 participants 6 messages Apr 23, 2024

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add StarFive's JH8100 StarLink Cache Controller

StarFive's JH8100 StarLink Cache Controller flush/invalidates cache using non- conventional RISC-V Zicbom extension instructions. This driver provides the cache handling on StarFive RISC-V SoC.

Joshua Yeong (2):
cache: Add StarFive StarLink cache management for StarFive JH8100
dt-bindings: cache: Add docs for StarFive Starlink cache controller

 .../cache/starfive,jh8100-starlink-cache.yaml |  62 ++++++++
 drivers/cache/Kconfig                         |   9 ++
 drivers/cache/Makefile                        |   1 +
 drivers/cache/starfive_starlink_cache.c       | 132 ++++++++++++++++++
 4 files changed, 204 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml
 create mode 100644 drivers/cache/starfive_starlink_cache.c
Signature · 11 lines
Changes in v2:
- Change patch title from 'Add StarFive's StarLink-500 Cache Controller'
- Remove StarFive alternative from errata framework
- Fixes warning from https://lore.kernel.org/oe-kbuild-all/[email protected]/
- Flush completion through atomic timeout function
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw

PATCH v2 1/2 cache: Add StarFive StarLink cache management for StarFive JH8100

Add StarFive Starlink cache management driver for
JH8100 SoC. This driver enables RISC-V
non-standard cache operation on JH8100 that does
not support Zicbom extension instructions.

---
 drivers/cache/Kconfig                   |   9 ++
 drivers/cache/Makefile                  |   1 +
 drivers/cache/starfive_starlink_cache.c | 132 ++++++++++++++++++++++++
 3 files changed, 142 insertions(+)
 create mode 100644 drivers/cache/starfive_starlink_cache.c
drivers/cache/Kconfig +9 -0
index 9345ce4976d7..9181cd391f53 100644
@@ -14,4 +14,13 @@ config SIFIVE_CCACHE
 	help
 	  Support for the composable cache controller on SiFive platforms.
 
+config STARFIVE_STARLINK_CACHE
+	bool "StarFive StarLink Cache controller"
+	depends on RISCV
+	depends on ARCH_STARFIVE
+	select RISCV_DMA_NONCOHERENT
+	select RISCV_NONSTANDARD_CACHE_OPS
+	help
+	  Support for the StarLink cache controller on StarFive platforms.
+
 endmenu
drivers/cache/Makefile +1 -0
index 7657cff3bd6c..8ff8b47ac3f7 100644
@@ -2,3 +2,4 @@
 
 obj-$(CONFIG_AX45MP_L2_CACHE)	+= ax45mp_cache.o
 obj-$(CONFIG_SIFIVE_CCACHE)	+= sifive_ccache.o
+obj-$(CONFIG_STARFIVE_STARLINK_CACHE) += starfive_starlink_cache.o
drivers/cache/starfive_starlink_cache.c new file +132 -0

132 lines not on this page · raw message

Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer
#2 lore raw

Re: [PATCH v2 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100

Quoted 16 lines · Joshua Yeong
drivers/cache/starfive_starlink_cache.c new file +16 -0
+
+#include <asm/dma-noncoherent.h>
+
+#define STARLINK_CACHE_FLUSH_START_ADDR			0x0
+#define STARLINK_CACHE_FLUSH_END_ADDR			0x8
+#define STARLINK_CACHE_FLUSH_CTL			0x10
+#define STARLINK_CACHE_CACHE_ALIGN			0x40
+
+#define STARLINK_CACHE_ADDRESS_RANGE_MASK		GENMASK(39, 0)
+#define STARLINK_CACHE_FLUSH_CTL_MODE_MASK		GENMASK(2, 1)
+#define STARLINK_CACHE_FLUSH_CTL_ENABLE_MASK		BIT(0)
+
+#define STARLINK_CACHE_FLUSH_CTL_CLEAN_INVALIDATE	0
+#define STARLINK_CACHE_FLUSH_CTL_MAKE_INVALIDATE	1
+#define STARLINK_CACHE_FLUSH_CTL_CLEAN_SHARED		2
+#define STARLINK_CACHE_FLUSH_TIMEOUT_US			5000000

drivers/cache/starfive_starlink_cache.c line 39

Quoted 10 lines
drivers/cache/starfive_starlink_cache.c new file +10 -0
+
+struct starlink_cache_priv {
+	void __iomem *base_addr;
+};
+
+static struct starlink_cache_priv starlink_cache_priv;
+
+static void starlink_cache_flush_complete(void)
+{
+	volatile void __iomem *_ctl = starlink_cache_priv.base_addr +

Why does this variable have an _ prefix?

Quoted 1 line

+ STARLINK_CACHE_FLUSH_CTL;

This link only has spaces, it should be tabs + < 8 spaces.

drivers/cache/starfive_starlink_cache.c line 47

Quoted 7 lines
drivers/cache/starfive_starlink_cache.c new file +7 -0
+	u64 v;
+
+	if (readq_poll_timeout_atomic((_ctl), v,
+	    !(v & STARLINK_CACHE_FLUSH_CTL_ENABLE_MASK), 1,
+	    STARLINK_CACHE_FLUSH_TIMEOUT_US))
+		WARN(1, "StarFive Starlink cache flush operation timeout\n");
+}

I'd fine this easier to read as:

static void starlink_cache_flush_complete(void)

{
	volatile void __iomem *_ctl = starlink_cache_priv.base_addr +
				      STARLINK_CACHE_FLUSH_CTL;
	u64 v;
	int ret;

	ret = readq_poll_timeout_atomic(_ctl, v, !(v & STARLINK_CACHE_FLUSH_CTL_ENABLE_MASK),
					STARLINK_CACHE_FLUSH_POLL_DELAY_US,
					STARLINK_CACHE_FLUSH_TIMEOUT_US);
	if (ret)
		WARN(1, "StarFive Starlink cache flush operation timeout\n");
}

Cheers,
Conor.

#3 lore raw

PATCH v2 2/2 dt-bindings: cache: Add docs for StarFive Starlink cache controller

In reply to Joshua Yeong

Add DT binding documentation used by StarFive's
JH8100 SoC Starlink cache controller.

---
 .../cache/starfive,jh8100-starlink-cache.yaml | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml
Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml new file +62 -0
new file mode 100644
index 000000000000..a8f39baca6cf
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/cache/starfive,starlink-500-cache.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive StarLink-500 Cache Controller
+
+maintainers:
+  - Joshua Yeong <[email protected]>
+
+description:
+  StarFive's JH8100 StarLink Cache Controller manages the L3 cache shared
+  between clusters of CPU cores. The cache driver enables RISC-V non-standard
+  cache management as an alternative to instructions in the RISC-V Zicbom
+  extension.
+
+allOf:
+  - $ref: /schemas/cache-controller.yaml#
+
+# We need a select here so we don't match all nodes with 'cache'
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - starfive,jh8100-starlink-cache
+
+  required:
+    - compatible
+
+properties:
+  compatible:
+    items:
+      - const: starfive,jh8100-starlink-cache
+      - const: cache
+
+  reg:
+    maxItems: 1
+
+unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - cache-block-size
+  - cache-level
+  - cache-sets
+  - cache-size
+  - cache-unified
+
+examples:
+  - |
+      cache-controller@15000000 {
+        compatible = "starfive,jh8100-starlink-cache", "cache";
+        reg = <0x15000000 0x278>;
+        cache-block-size = <64>;
+        cache-level = <3>;
+        cache-sets = <8192>;
+        cache-size = <0x400000>;
+        cache-unified;
+      };
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer
#4 lore raw

Re: [PATCH v2 2/2] dt-bindings: cache: Add docs for StarFive Starlink cache controller

Quoted 9 lines · Joshua Yeong

Add DT binding documentation used by StarFive's
JH8100 SoC Starlink cache controller.

---
 .../cache/starfive,jh8100-starlink-cache.yaml | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml: $id: Cannot determine base path from $id, relative path/filename doesn't match actual path or filename
$id: http://devicetree.org/schemas/cache/starfive,starlink-500-cache.yaml
file: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.