* [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller
@ 2024-04-24 7:58 Joshua Yeong
2024-04-24 7:58 ` [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 Joshua Yeong
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Joshua Yeong @ 2024-04-24 7:58 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou,
joshua.yeong, leyfoon.tan, jeeheng.sia
Cc: devicetree, linux-kernel, linux-riscv
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.
Changes in v3:
- Fix code syntax
- Link to v2: https://lore.kernel.org/all/20240423072639.143450-1-joshua.yeong@starfivetech.com/
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/202403151625.boKDjHGr-lkp@intel.com/
- Flush completion through atomic timeout function
- Link to v1: https://lore.kernel.org/lkml/20240314061205.26143-1-joshua.yeong@starfivetech.com/
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 | 66 +++++++++
drivers/cache/Kconfig | 9 ++
drivers/cache/Makefile | 5 +-
drivers/cache/starfive_starlink_cache.c | 135 ++++++++++++++++++
4 files changed, 213 insertions(+), 2 deletions(-)
create mode 100644 Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml
create mode 100644 drivers/cache/starfive_starlink_cache.c
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 7:58 [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller Joshua Yeong @ 2024-04-24 7:58 ` Joshua Yeong 2024-04-24 10:25 ` Emil Renner Berthing 2024-04-24 7:58 ` [PATCH v3 2/2] dt-bindings: cache: Add docs for StarFive Starlink cache controller Joshua Yeong 2024-04-24 9:59 ` [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller Emil Renner Berthing 2 siblings, 1 reply; 14+ messages in thread From: Joshua Yeong @ 2024-04-24 7:58 UTC (permalink / raw) To: robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, joshua.yeong, leyfoon.tan, jeeheng.sia Cc: devicetree, linux-kernel, linux-riscv 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. Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> --- drivers/cache/Kconfig | 9 ++ drivers/cache/Makefile | 5 +- drivers/cache/starfive_starlink_cache.c | 135 ++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 drivers/cache/starfive_starlink_cache.c diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig index 9345ce4976d7..9181cd391f53 100644 --- a/drivers/cache/Kconfig +++ b/drivers/cache/Kconfig @@ -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 diff --git a/drivers/cache/Makefile b/drivers/cache/Makefile index 7657cff3bd6c..55c5e851034d 100644 --- a/drivers/cache/Makefile +++ b/drivers/cache/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_AX45MP_L2_CACHE) += ax45mp_cache.o -obj-$(CONFIG_SIFIVE_CCACHE) += sifive_ccache.o +obj-$(CONFIG_AX45MP_L2_CACHE) += ax45mp_cache.o +obj-$(CONFIG_SIFIVE_CCACHE) += sifive_ccache.o +obj-$(CONFIG_STARFIVE_STARLINK_CACHE) += starfive_starlink_cache.o diff --git a/drivers/cache/starfive_starlink_cache.c b/drivers/cache/starfive_starlink_cache.c new file mode 100644 index 000000000000..2f1fa6a923ee --- /dev/null +++ b/drivers/cache/starfive_starlink_cache.c @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Cache Management Operations for StarFive's Starlink cache controller + * + * Copyright (C) 2024 Shanghai StarFive Technology Co., Ltd. + * + * Author: Joshua Yeong <joshua.yeong@starfivetech.com> + */ + +#include <linux/bitfield.h> +#include <linux/cacheflush.h> +#include <linux/iopoll.h> +#include <linux/of_address.h> + +#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_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_POLL_DELAY_US 1 +#define STARLINK_CACHE_FLUSH_TIMEOUT_US 5000000 + +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 + + 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"); +} + +static void starlink_cache_dma_cache_wback(phys_addr_t paddr, unsigned long size) +{ + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_START_ADDR); + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr + size), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_END_ADDR); + + mb(); + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, + STARLINK_CACHE_FLUSH_CTL_CLEAN_SHARED), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); + + starlink_cache_flush_complete(); +} + +static void starlink_cache_dma_cache_invalidate(phys_addr_t paddr, unsigned long size) +{ + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_START_ADDR); + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr + size), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_END_ADDR); + + mb(); + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, + STARLINK_CACHE_FLUSH_CTL_MAKE_INVALIDATE), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); + + starlink_cache_flush_complete(); +} + +static void starlink_cache_dma_cache_wback_inv(phys_addr_t paddr, unsigned long size) +{ + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_START_ADDR); + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr + size), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_END_ADDR); + + mb(); + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, + STARLINK_CACHE_FLUSH_CTL_CLEAN_INVALIDATE), + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); + + starlink_cache_flush_complete(); +} + +static const struct riscv_nonstd_cache_ops starlink_cache_ops = { + .wback = &starlink_cache_dma_cache_wback, + .inv = &starlink_cache_dma_cache_invalidate, + .wback_inv = &starlink_cache_dma_cache_wback_inv, +}; + +static const struct of_device_id starlink_cache_ids[] = { + { .compatible = "starfive,jh8100-starlink-cache" }, + { /* sentinel */ } +}; + +static int __init starlink_cache_init(void) +{ + struct device_node *np; + u32 block_size = 0; + int ret; + + np = of_find_matching_node(NULL, starlink_cache_ids); + if (!of_device_is_available(np)) + return -ENODEV; + + ret = of_property_read_u32(np, "cache-block-size", &block_size); + if (ret) + return ret; + + if (block_size % STARLINK_CACHE_ALIGN) + return -EINVAL; + + starlink_cache_priv.base_addr = of_iomap(np, 0); + if (!starlink_cache_priv.base_addr) + return -ENOMEM; + + riscv_cbom_block_size = block_size; + riscv_noncoherent_supported(); + riscv_noncoherent_register_cache_ops(&starlink_cache_ops); + + return 0; +} +early_initcall(starlink_cache_init); -- 2.25.1 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 7:58 ` [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 Joshua Yeong @ 2024-04-24 10:25 ` Emil Renner Berthing 2024-04-24 14:07 ` Joshua Yeong 0 siblings, 1 reply; 14+ messages in thread From: Emil Renner Berthing @ 2024-04-24 10:25 UTC (permalink / raw) To: Joshua Yeong, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, leyfoon.tan, jeeheng.sia Cc: devicetree, linux-kernel, linux-riscv Joshua Yeong wrote: > 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. > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > --- > drivers/cache/Kconfig | 9 ++ > drivers/cache/Makefile | 5 +- > drivers/cache/starfive_starlink_cache.c | 135 ++++++++++++++++++++++++ > 3 files changed, 147 insertions(+), 2 deletions(-) > create mode 100644 drivers/cache/starfive_starlink_cache.c > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig > index 9345ce4976d7..9181cd391f53 100644 > --- a/drivers/cache/Kconfig > +++ b/drivers/cache/Kconfig > @@ -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. This is a bit misleading. The JH71x0s don't have this. It's only on the JH8100 so far, and hopefully later SoCs will just implement RISC-V standards for this. So maybe something like "Support for the StarLink cache controller on the StarFive JH8100 SoC." > + > endmenu > diff --git a/drivers/cache/Makefile b/drivers/cache/Makefile > index 7657cff3bd6c..55c5e851034d 100644 > --- a/drivers/cache/Makefile > +++ b/drivers/cache/Makefile > @@ -1,4 +1,5 @@ > # SPDX-License-Identifier: GPL-2.0 > > -obj-$(CONFIG_AX45MP_L2_CACHE) += ax45mp_cache.o > -obj-$(CONFIG_SIFIVE_CCACHE) += sifive_ccache.o > +obj-$(CONFIG_AX45MP_L2_CACHE) += ax45mp_cache.o > +obj-$(CONFIG_SIFIVE_CCACHE) += sifive_ccache.o > +obj-$(CONFIG_STARFIVE_STARLINK_CACHE) += starfive_starlink_cache.o > diff --git a/drivers/cache/starfive_starlink_cache.c b/drivers/cache/starfive_starlink_cache.c > new file mode 100644 > index 000000000000..2f1fa6a923ee > --- /dev/null > +++ b/drivers/cache/starfive_starlink_cache.c > @@ -0,0 +1,135 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Cache Management Operations for StarFive's Starlink cache controller > + * > + * Copyright (C) 2024 Shanghai StarFive Technology Co., Ltd. > + * > + * Author: Joshua Yeong <joshua.yeong@starfivetech.com> > + */ > + > +#include <linux/bitfield.h> > +#include <linux/cacheflush.h> > +#include <linux/iopoll.h> > +#include <linux/of_address.h> > + > +#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_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_POLL_DELAY_US 1 > +#define STARLINK_CACHE_FLUSH_TIMEOUT_US 5000000 > + > +struct starlink_cache_priv { > + void __iomem *base_addr; > +}; > + > +static struct starlink_cache_priv starlink_cache_priv; This could just be static void __iomem *starlink_cache_base; > + > +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"); > +} > + > +static void starlink_cache_dma_cache_wback(phys_addr_t paddr, unsigned long size) > +{ > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_START_ADDR); > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr + size), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_END_ADDR); > + > + mb(); > + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, > + STARLINK_CACHE_FLUSH_CTL_CLEAN_SHARED), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); > + > + starlink_cache_flush_complete(); > +} > + > +static void starlink_cache_dma_cache_invalidate(phys_addr_t paddr, unsigned long size) > +{ > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_START_ADDR); > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr + size), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_END_ADDR); > + > + mb(); > + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, > + STARLINK_CACHE_FLUSH_CTL_MAKE_INVALIDATE), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); > + > + starlink_cache_flush_complete(); > +} > + > +static void starlink_cache_dma_cache_wback_inv(phys_addr_t paddr, unsigned long size) > +{ > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_START_ADDR); > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, paddr + size), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_END_ADDR); > + > + mb(); > + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, > + STARLINK_CACHE_FLUSH_CTL_CLEAN_INVALIDATE), > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); > + > + starlink_cache_flush_complete(); > +} > + > +static const struct riscv_nonstd_cache_ops starlink_cache_ops = { > + .wback = &starlink_cache_dma_cache_wback, > + .inv = &starlink_cache_dma_cache_invalidate, > + .wback_inv = &starlink_cache_dma_cache_wback_inv, > +}; > + > +static const struct of_device_id starlink_cache_ids[] = { > + { .compatible = "starfive,jh8100-starlink-cache" }, > + { /* sentinel */ } > +}; > + > +static int __init starlink_cache_init(void) > +{ > + struct device_node *np; > + u32 block_size = 0; You return early if of_property_read_u32() fails, so this doesn't need to be initialized. > + int ret; > + > + np = of_find_matching_node(NULL, starlink_cache_ids); > + if (!of_device_is_available(np)) > + return -ENODEV; > + > + ret = of_property_read_u32(np, "cache-block-size", &block_size); > + if (ret) > + return ret; > + > + if (block_size % STARLINK_CACHE_ALIGN) > + return -EINVAL; > + > + starlink_cache_priv.base_addr = of_iomap(np, 0); > + if (!starlink_cache_priv.base_addr) > + return -ENOMEM; > + > + riscv_cbom_block_size = block_size; > + riscv_noncoherent_supported(); > + riscv_noncoherent_register_cache_ops(&starlink_cache_ops); > + > + return 0; > +} > +early_initcall(starlink_cache_init); The sifive driver gets away with arch_initcall() here. Any particular reason you need this earlier? > -- > 2.25.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 10:25 ` Emil Renner Berthing @ 2024-04-24 14:07 ` Joshua Yeong 2024-04-24 14:16 ` Emil Renner Berthing 0 siblings, 1 reply; 14+ messages in thread From: Joshua Yeong @ 2024-04-24 14:07 UTC (permalink / raw) To: Emil Renner Berthing, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, Leyfoon Tan, JeeHeng Sia Cc: devicetree, linux-kernel, linux-riscv Emil Renner Berthing wrote: > Joshua Yeong wrote: > > 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. > > > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > > --- > > drivers/cache/Kconfig | 9 ++ > > drivers/cache/Makefile | 5 +- > > drivers/cache/starfive_starlink_cache.c | 135 > > ++++++++++++++++++++++++ > > 3 files changed, 147 insertions(+), 2 deletions(-) create mode > > 100644 drivers/cache/starfive_starlink_cache.c > > > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig index > > 9345ce4976d7..9181cd391f53 100644 > > --- a/drivers/cache/Kconfig > > +++ b/drivers/cache/Kconfig > > @@ -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. > > This is a bit misleading. The JH71x0s don't have this. It's only on the JH8100 so > far, and hopefully later SoCs will just implement RISC-V standards for this. > So maybe something like > > "Support for the StarLink cache controller on the StarFive JH8100 SoC." > Hi Emil, The StarLink-500 cache controller is not designed exclusively for JH8100 SoC. While it is true that it currently exists on the StarFive platform, CPU/SoC that does not come with Zicbom extensions supported would need to rely on this cache drive to do cache management operations. I think we don’t need to mentioned 'JH8100 SoC' here. > > + > > endmenu > > diff --git a/drivers/cache/Makefile b/drivers/cache/Makefile index > > 7657cff3bd6c..55c5e851034d 100644 > > --- a/drivers/cache/Makefile > > +++ b/drivers/cache/Makefile > > @@ -1,4 +1,5 @@ > > # SPDX-License-Identifier: GPL-2.0 > > > > -obj-$(CONFIG_AX45MP_L2_CACHE) += ax45mp_cache.o > > -obj-$(CONFIG_SIFIVE_CCACHE) += sifive_ccache.o > > +obj-$(CONFIG_AX45MP_L2_CACHE) += ax45mp_cache.o > > +obj-$(CONFIG_SIFIVE_CCACHE) += sifive_ccache.o > > +obj-$(CONFIG_STARFIVE_STARLINK_CACHE) += starfive_starlink_cache.o > > diff --git a/drivers/cache/starfive_starlink_cache.c > > b/drivers/cache/starfive_starlink_cache.c > > new file mode 100644 > > index 000000000000..2f1fa6a923ee > > --- /dev/null > > +++ b/drivers/cache/starfive_starlink_cache.c > > @@ -0,0 +1,135 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Cache Management Operations for StarFive's Starlink cache > > +controller > > + * > > + * Copyright (C) 2024 Shanghai StarFive Technology Co., Ltd. > > + * > > + * Author: Joshua Yeong <joshua.yeong@starfivetech.com> */ > > + > > +#include <linux/bitfield.h> > > +#include <linux/cacheflush.h> > > +#include <linux/iopoll.h> > > +#include <linux/of_address.h> > > + > > +#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_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_POLL_DELAY_US 1 > > +#define STARLINK_CACHE_FLUSH_TIMEOUT_US > 5000000 > > + > > +struct starlink_cache_priv { > > + void __iomem *base_addr; > > +}; > > + > > +static struct starlink_cache_priv starlink_cache_priv; > > This could just be > > static void __iomem *starlink_cache_base; > > > + > > +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"); } > > + > > +static void starlink_cache_dma_cache_wback(phys_addr_t paddr, > > +unsigned long size) { > > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, > paddr), > > + starlink_cache_priv.base_addr + > STARLINK_CACHE_FLUSH_START_ADDR); > > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, > paddr + size), > > + starlink_cache_priv.base_addr + > > +STARLINK_CACHE_FLUSH_END_ADDR); > > + > > + mb(); > > + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, > > + STARLINK_CACHE_FLUSH_CTL_CLEAN_SHARED), > > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); > > + > > + starlink_cache_flush_complete(); > > +} > > + > > +static void starlink_cache_dma_cache_invalidate(phys_addr_t paddr, > > +unsigned long size) { > > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, > paddr), > > + starlink_cache_priv.base_addr + > STARLINK_CACHE_FLUSH_START_ADDR); > > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, > paddr + size), > > + starlink_cache_priv.base_addr + > > +STARLINK_CACHE_FLUSH_END_ADDR); > > + > > + mb(); > > + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, > > + STARLINK_CACHE_FLUSH_CTL_MAKE_INVALIDATE), > > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); > > + > > + starlink_cache_flush_complete(); > > +} > > + > > +static void starlink_cache_dma_cache_wback_inv(phys_addr_t paddr, > > +unsigned long size) { > > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, > paddr), > > + starlink_cache_priv.base_addr + > STARLINK_CACHE_FLUSH_START_ADDR); > > + writeq(FIELD_PREP(STARLINK_CACHE_ADDRESS_RANGE_MASK, > paddr + size), > > + starlink_cache_priv.base_addr + > > +STARLINK_CACHE_FLUSH_END_ADDR); > > + > > + mb(); > > + writeq(FIELD_PREP(STARLINK_CACHE_FLUSH_CTL_MODE_MASK, > > + STARLINK_CACHE_FLUSH_CTL_CLEAN_INVALIDATE), > > + starlink_cache_priv.base_addr + STARLINK_CACHE_FLUSH_CTL); > > + > > + starlink_cache_flush_complete(); > > +} > > + > > +static const struct riscv_nonstd_cache_ops starlink_cache_ops = { > > + .wback = &starlink_cache_dma_cache_wback, > > + .inv = &starlink_cache_dma_cache_invalidate, > > + .wback_inv = &starlink_cache_dma_cache_wback_inv, > > +}; > > + > > +static const struct of_device_id starlink_cache_ids[] = { > > + { .compatible = "starfive,jh8100-starlink-cache" }, > > + { /* sentinel */ } > > +}; > > + > > +static int __init starlink_cache_init(void) { > > + struct device_node *np; > > + u32 block_size = 0; > > You return early if of_property_read_u32() fails, so this doesn't need to be > initialized. > > > + int ret; > > + > > + np = of_find_matching_node(NULL, starlink_cache_ids); > > + if (!of_device_is_available(np)) > > + return -ENODEV; > > + > > + ret = of_property_read_u32(np, "cache-block-size", &block_size); > > + if (ret) > > + return ret; > > + > > + if (block_size % STARLINK_CACHE_ALIGN) > > + return -EINVAL; > > + > > + starlink_cache_priv.base_addr = of_iomap(np, 0); > > + if (!starlink_cache_priv.base_addr) > > + return -ENOMEM; > > + > > + riscv_cbom_block_size = block_size; > > + riscv_noncoherent_supported(); > > + riscv_noncoherent_register_cache_ops(&starlink_cache_ops); > > + > > + return 0; > > +} > > +early_initcall(starlink_cache_init); > > The sifive driver gets away with arch_initcall() here. Any particular reason you > need this earlier? I will change it to arch_initcall(). Appreciate for the comments. Thank you. Regards, Joshua > > > -- > > 2.25.1 > > > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 14:07 ` Joshua Yeong @ 2024-04-24 14:16 ` Emil Renner Berthing 2024-04-24 14:36 ` Joshua Yeong 0 siblings, 1 reply; 14+ messages in thread From: Emil Renner Berthing @ 2024-04-24 14:16 UTC (permalink / raw) To: Joshua Yeong, Emil Renner Berthing, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, Leyfoon Tan, JeeHeng Sia Cc: devicetree, linux-kernel, linux-riscv Joshua Yeong wrote: > Emil Renner Berthing wrote: > > Joshua Yeong wrote: > > > 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. > > > > > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > > > --- > > > drivers/cache/Kconfig | 9 ++ > > > drivers/cache/Makefile | 5 +- > > > drivers/cache/starfive_starlink_cache.c | 135 > > > ++++++++++++++++++++++++ > > > 3 files changed, 147 insertions(+), 2 deletions(-) create mode > > > 100644 drivers/cache/starfive_starlink_cache.c > > > > > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig index > > > 9345ce4976d7..9181cd391f53 100644 > > > --- a/drivers/cache/Kconfig > > > +++ b/drivers/cache/Kconfig > > > @@ -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. > > > > This is a bit misleading. The JH71x0s don't have this. It's only on the JH8100 so > > far, and hopefully later SoCs will just implement RISC-V standards for this. > > So maybe something like > > > > "Support for the StarLink cache controller on the StarFive JH8100 SoC." > > > > Hi Emil, > > The StarLink-500 cache controller is not designed exclusively for JH8100 SoC. > While it is true that it currently exists on the StarFive platform, CPU/SoC > that does not come with Zicbom extensions supported would need to rely > on this cache drive to do cache management operations. I think we don’t need > to mentioned 'JH8100 SoC' here. Wait, in the previous mail you said that future designs will implement Zicbom and not need this work-around, but here you're talking about other SoCs that do need it. So which is it? ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 14:16 ` Emil Renner Berthing @ 2024-04-24 14:36 ` Joshua Yeong 2024-04-24 14:44 ` Emil Renner Berthing 0 siblings, 1 reply; 14+ messages in thread From: Joshua Yeong @ 2024-04-24 14:36 UTC (permalink / raw) To: Emil Renner Berthing, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, Leyfoon Tan, JeeHeng Sia, Joshua Yeong Cc: devicetree, linux-kernel, linux-riscv Emil Renner Berthing wrote: > Joshua Yeong wrote: > > Emil Renner Berthing wrote: > > > Joshua Yeong wrote: > > > > 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. > > > > > > > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > > > > --- > > > > drivers/cache/Kconfig | 9 ++ > > > > drivers/cache/Makefile | 5 +- > > > > drivers/cache/starfive_starlink_cache.c | 135 > > > > ++++++++++++++++++++++++ > > > > 3 files changed, 147 insertions(+), 2 deletions(-) create mode > > > > 100644 drivers/cache/starfive_starlink_cache.c > > > > > > > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig index > > > > 9345ce4976d7..9181cd391f53 100644 > > > > --- a/drivers/cache/Kconfig > > > > +++ b/drivers/cache/Kconfig > > > > @@ -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. > > > > > > This is a bit misleading. The JH71x0s don't have this. It's only on > > > the JH8100 so far, and hopefully later SoCs will just implement RISC-V > standards for this. > > > So maybe something like > > > > > > "Support for the StarLink cache controller on the StarFive JH8100 SoC." > > > > > > > Hi Emil, > > > > The StarLink-500 cache controller is not designed exclusively for JH8100 SoC. > > While it is true that it currently exists on the StarFive platform, > > CPU/SoC that does not come with Zicbom extensions supported would need > > to rely on this cache drive to do cache management operations. I think > > we don’t need to mentioned 'JH8100 SoC' here. > > Wait, in the previous mail you said that future designs will implement Zicbom > and not need this work-around, but here you're talking about other SoCs that > do need it. So which is it? If you visit the company website and look for StarLink-500, you will find that it is a standalone IP that the company is selling as an interconnect. Anyone who integrates StarLink without Zicbom extensions may utilize the cache management operation from this IP. ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 14:36 ` Joshua Yeong @ 2024-04-24 14:44 ` Emil Renner Berthing 2024-04-24 14:52 ` Joshua Yeong 0 siblings, 1 reply; 14+ messages in thread From: Emil Renner Berthing @ 2024-04-24 14:44 UTC (permalink / raw) To: Joshua Yeong, Emil Renner Berthing, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, Leyfoon Tan, JeeHeng Sia Cc: devicetree, linux-kernel, linux-riscv Joshua Yeong wrote: > > > Emil Renner Berthing wrote: > > Joshua Yeong wrote: > > > Emil Renner Berthing wrote: > > > > Joshua Yeong wrote: > > > > > 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. > > > > > > > > > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > > > > > --- > > > > > drivers/cache/Kconfig | 9 ++ > > > > > drivers/cache/Makefile | 5 +- > > > > > drivers/cache/starfive_starlink_cache.c | 135 > > > > > ++++++++++++++++++++++++ > > > > > 3 files changed, 147 insertions(+), 2 deletions(-) create mode > > > > > 100644 drivers/cache/starfive_starlink_cache.c > > > > > > > > > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig index > > > > > 9345ce4976d7..9181cd391f53 100644 > > > > > --- a/drivers/cache/Kconfig > > > > > +++ b/drivers/cache/Kconfig > > > > > @@ -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. > > > > > > > > This is a bit misleading. The JH71x0s don't have this. It's only on > > > > the JH8100 so far, and hopefully later SoCs will just implement RISC-V > > standards for this. > > > > So maybe something like > > > > > > > > "Support for the StarLink cache controller on the StarFive JH8100 SoC." > > > > > > > > > > Hi Emil, > > > > > > The StarLink-500 cache controller is not designed exclusively for JH8100 SoC. > > > While it is true that it currently exists on the StarFive platform, > > > CPU/SoC that does not come with Zicbom extensions supported would need > > > to rely on this cache drive to do cache management operations. I think > > > we don’t need to mentioned 'JH8100 SoC' here. > > > > Wait, in the previous mail you said that future designs will implement Zicbom > > and not need this work-around, but here you're talking about other SoCs that > > do need it. So which is it? > > If you visit the company website and look for StarLink-500, you will find that > it is a standalone IP that the company is selling as an interconnect. Anyone > who integrates StarLink without Zicbom extensions may utilize the cache > management operation from this IP. So then the "on StarFive platforms" part is wrong? Or will this always go together with the Dubhe cores? > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 14:44 ` Emil Renner Berthing @ 2024-04-24 14:52 ` Joshua Yeong 2024-04-24 14:57 ` Emil Renner Berthing 0 siblings, 1 reply; 14+ messages in thread From: Joshua Yeong @ 2024-04-24 14:52 UTC (permalink / raw) To: Emil Renner Berthing, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, Leyfoon Tan, JeeHeng Sia Cc: devicetree, linux-kernel, linux-riscv Emil Renner Berthing wrote: > Joshua Yeong wrote: > > > > > > Emil Renner Berthing wrote: > > > Joshua Yeong wrote: > > > > Emil Renner Berthing wrote: > > > > > Joshua Yeong wrote: > > > > > > 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. > > > > > > > > > > > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > > > > > > --- > > > > > > drivers/cache/Kconfig | 9 ++ > > > > > > drivers/cache/Makefile | 5 +- > > > > > > drivers/cache/starfive_starlink_cache.c | 135 > > > > > > ++++++++++++++++++++++++ > > > > > > 3 files changed, 147 insertions(+), 2 deletions(-) create > > > > > > mode > > > > > > 100644 drivers/cache/starfive_starlink_cache.c > > > > > > > > > > > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig > > > > > > index > > > > > > 9345ce4976d7..9181cd391f53 100644 > > > > > > --- a/drivers/cache/Kconfig > > > > > > +++ b/drivers/cache/Kconfig > > > > > > @@ -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. > > > > > > > > > > This is a bit misleading. The JH71x0s don't have this. It's only > > > > > on the JH8100 so far, and hopefully later SoCs will just > > > > > implement RISC-V > > > standards for this. > > > > > So maybe something like > > > > > > > > > > "Support for the StarLink cache controller on the StarFive JH8100 SoC." > > > > > > > > > > > > > Hi Emil, > > > > > > > > The StarLink-500 cache controller is not designed exclusively for JH8100 > SoC. > > > > While it is true that it currently exists on the StarFive > > > > platform, CPU/SoC that does not come with Zicbom extensions > > > > supported would need to rely on this cache drive to do cache > > > > management operations. I think we don’t need to mentioned 'JH8100 > SoC' here. > > > > > > Wait, in the previous mail you said that future designs will > > > implement Zicbom and not need this work-around, but here you're > > > talking about other SoCs that do need it. So which is it? > > > > If you visit the company website and look for StarLink-500, you will > > find that it is a standalone IP that the company is selling as an > > interconnect. Anyone who integrates StarLink without Zicbom extensions > > may utilize the cache management operation from this IP. > > So then the "on StarFive platforms" part is wrong? Or will this always go > together with the Dubhe cores? It would be 'on StarFive platform' without 'JH8100 SoC' that you suggested. StarFive's newer cores that will have Zicbom extensions supported. Those CPU core will not need to have this cache controller enabled. > > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 14:52 ` Joshua Yeong @ 2024-04-24 14:57 ` Emil Renner Berthing 2024-04-24 15:26 ` Joshua Yeong 0 siblings, 1 reply; 14+ messages in thread From: Emil Renner Berthing @ 2024-04-24 14:57 UTC (permalink / raw) To: Joshua Yeong, Emil Renner Berthing, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, Leyfoon Tan, JeeHeng Sia Cc: devicetree, linux-kernel, linux-riscv Joshua Yeong wrote: > Emil Renner Berthing wrote: > > Joshua Yeong wrote: > > > > > > > > > Emil Renner Berthing wrote: > > > > Joshua Yeong wrote: > > > > > Emil Renner Berthing wrote: > > > > > > Joshua Yeong wrote: > > > > > > > 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. > > > > > > > > > > > > > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > > > > > > > --- > > > > > > > drivers/cache/Kconfig | 9 ++ > > > > > > > drivers/cache/Makefile | 5 +- > > > > > > > drivers/cache/starfive_starlink_cache.c | 135 > > > > > > > ++++++++++++++++++++++++ > > > > > > > 3 files changed, 147 insertions(+), 2 deletions(-) create > > > > > > > mode > > > > > > > 100644 drivers/cache/starfive_starlink_cache.c > > > > > > > > > > > > > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig > > > > > > > index > > > > > > > 9345ce4976d7..9181cd391f53 100644 > > > > > > > --- a/drivers/cache/Kconfig > > > > > > > +++ b/drivers/cache/Kconfig > > > > > > > @@ -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. > > > > > > > > > > > > This is a bit misleading. The JH71x0s don't have this. It's only > > > > > > on the JH8100 so far, and hopefully later SoCs will just > > > > > > implement RISC-V > > > > standards for this. > > > > > > So maybe something like > > > > > > > > > > > > "Support for the StarLink cache controller on the StarFive JH8100 SoC." > > > > > > > > > > > > > > > > Hi Emil, > > > > > > > > > > The StarLink-500 cache controller is not designed exclusively for JH8100 > > SoC. > > > > > While it is true that it currently exists on the StarFive > > > > > platform, CPU/SoC that does not come with Zicbom extensions > > > > > supported would need to rely on this cache drive to do cache > > > > > management operations. I think we don’t need to mentioned 'JH8100 > > SoC' here. > > > > > > > > Wait, in the previous mail you said that future designs will > > > > implement Zicbom and not need this work-around, but here you're > > > > talking about other SoCs that do need it. So which is it? > > > > > > If you visit the company website and look for StarLink-500, you will > > > find that it is a standalone IP that the company is selling as an > > > interconnect. Anyone who integrates StarLink without Zicbom extensions > > > may utilize the cache management operation from this IP. > > > > So then the "on StarFive platforms" part is wrong? Or will this always go > > together with the Dubhe cores? > > It would be 'on StarFive platform' without 'JH8100 SoC' that you suggested. > StarFive's newer cores that will have Zicbom extensions supported. Those > CPU core will not need to have this cache controller enabled. No, what I meant was that if you're selling the "StarLink-500" IP to other SoC manufacturors then it will not be restricted to StarFive platforms. So then "Support for the StarLink cache controller _on StarFive platforms_" is no longer true, right? /Emil ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 2024-04-24 14:57 ` Emil Renner Berthing @ 2024-04-24 15:26 ` Joshua Yeong 0 siblings, 0 replies; 14+ messages in thread From: Joshua Yeong @ 2024-04-24 15:26 UTC (permalink / raw) To: Emil Renner Berthing, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, Leyfoon Tan, JeeHeng Sia Cc: devicetree, linux-kernel, linux-riscv Emil Renner Berthing wrote: > Joshua Yeong wrote: > > Emil Renner Berthing wrote: > > > Joshua Yeong wrote: > > > > > > > > > > > > Emil Renner Berthing wrote: > > > > > Joshua Yeong wrote: > > > > > > Emil Renner Berthing wrote: > > > > > > > Joshua Yeong wrote: > > > > > > > > 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. > > > > > > > > > > > > > > > > Signed-off-by: Joshua Yeong > > > > > > > > <joshua.yeong@starfivetech.com> > > > > > > > > --- > > > > > > > > drivers/cache/Kconfig | 9 ++ > > > > > > > > drivers/cache/Makefile | 5 +- > > > > > > > > drivers/cache/starfive_starlink_cache.c | 135 > > > > > > > > ++++++++++++++++++++++++ > > > > > > > > 3 files changed, 147 insertions(+), 2 deletions(-) > > > > > > > > create mode > > > > > > > > 100644 drivers/cache/starfive_starlink_cache.c > > > > > > > > > > > > > > > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig > > > > > > > > index > > > > > > > > 9345ce4976d7..9181cd391f53 100644 > > > > > > > > --- a/drivers/cache/Kconfig > > > > > > > > +++ b/drivers/cache/Kconfig > > > > > > > > @@ -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. > > > > > > > > > > > > > > This is a bit misleading. The JH71x0s don't have this. It's > > > > > > > only on the JH8100 so far, and hopefully later SoCs will > > > > > > > just implement RISC-V > > > > > standards for this. > > > > > > > So maybe something like > > > > > > > > > > > > > > "Support for the StarLink cache controller on the StarFive JH8100 > SoC." > > > > > > > > > > > > > > > > > > > Hi Emil, > > > > > > > > > > > > The StarLink-500 cache controller is not designed exclusively > > > > > > for JH8100 > > > SoC. > > > > > > While it is true that it currently exists on the StarFive > > > > > > platform, CPU/SoC that does not come with Zicbom extensions > > > > > > supported would need to rely on this cache drive to do cache > > > > > > management operations. I think we don’t need to mentioned > > > > > > 'JH8100 > > > SoC' here. > > > > > > > > > > Wait, in the previous mail you said that future designs will > > > > > implement Zicbom and not need this work-around, but here you're > > > > > talking about other SoCs that do need it. So which is it? > > > > > > > > If you visit the company website and look for StarLink-500, you > > > > will find that it is a standalone IP that the company is selling > > > > as an interconnect. Anyone who integrates StarLink without Zicbom > > > > extensions may utilize the cache management operation from this IP. > > > > > > So then the "on StarFive platforms" part is wrong? Or will this > > > always go together with the Dubhe cores? > > > > It would be 'on StarFive platform' without 'JH8100 SoC' that you suggested. > > StarFive's newer cores that will have Zicbom extensions supported. > > Those CPU core will not need to have this cache controller enabled. > > No, what I meant was that if you're selling the "StarLink-500" IP to other SoC > manufacturors then it will not be restricted to StarFive platforms. So then > "Support for the StarLink cache controller _on StarFive platforms_" is no longer > true, right? Yes, you are right on this. AFAIK JH8100 integrates StarLink-500 and which is why we need this cache controller driver, I do not know who/what else products that might use this IP. > > /Emil ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 2/2] dt-bindings: cache: Add docs for StarFive Starlink cache controller 2024-04-24 7:58 [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller Joshua Yeong 2024-04-24 7:58 ` [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 Joshua Yeong @ 2024-04-24 7:58 ` Joshua Yeong 2024-04-24 22:04 ` Rob Herring 2024-04-24 9:59 ` [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller Emil Renner Berthing 2 siblings, 1 reply; 14+ messages in thread From: Joshua Yeong @ 2024-04-24 7:58 UTC (permalink / raw) To: robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, joshua.yeong, leyfoon.tan, jeeheng.sia Cc: devicetree, linux-kernel, linux-riscv Add DT binding documentation used by StarFive's JH8100 SoC Starlink cache controller. Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> --- .../cache/starfive,jh8100-starlink-cache.yaml | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml diff --git a/Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml b/Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml new file mode 100644 index 000000000000..6d61098e388b --- /dev/null +++ b/Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/cache/starfive,jh8100-starlink-cache.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive StarLink Cache Controller + +maintainers: + - Joshua Yeong <joshua.yeong@starfivetech.com> + +description: + StarFive's 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: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + cache-controller@15000000 { + compatible = "starfive,jh8100-starlink-cache", "cache"; + reg = <0x0 0x15000000 0x0 0x278>; + cache-block-size = <64>; + cache-level = <3>; + cache-sets = <8192>; + cache-size = <0x400000>; + cache-unified; + }; + }; -- 2.25.1 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/2] dt-bindings: cache: Add docs for StarFive Starlink cache controller 2024-04-24 7:58 ` [PATCH v3 2/2] dt-bindings: cache: Add docs for StarFive Starlink cache controller Joshua Yeong @ 2024-04-24 22:04 ` Rob Herring 0 siblings, 0 replies; 14+ messages in thread From: Rob Herring @ 2024-04-24 22:04 UTC (permalink / raw) To: Joshua Yeong Cc: linux-kernel, aou, conor+dt, krzk+dt, jeeheng.sia, linux-riscv, leyfoon.tan, paul.walmsley, palmer, devicetree, conor On Wed, 24 Apr 2024 15:58:56 +0800, Joshua Yeong wrote: > Add DT binding documentation used by StarFive's > JH8100 SoC Starlink cache controller. > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > --- > .../cache/starfive,jh8100-starlink-cache.yaml | 66 +++++++++++++++++++ > 1 file changed, 66 insertions(+) > create mode 100644 Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml > Reviewed-by: Rob Herring (Arm) <robh@kernel.org> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller 2024-04-24 7:58 [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller Joshua Yeong 2024-04-24 7:58 ` [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 Joshua Yeong 2024-04-24 7:58 ` [PATCH v3 2/2] dt-bindings: cache: Add docs for StarFive Starlink cache controller Joshua Yeong @ 2024-04-24 9:59 ` Emil Renner Berthing 2024-04-24 13:45 ` Joshua Yeong 2 siblings, 1 reply; 14+ messages in thread From: Emil Renner Berthing @ 2024-04-24 9:59 UTC (permalink / raw) To: Joshua Yeong, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, leyfoon.tan, jeeheng.sia Cc: devicetree, linux-kernel, linux-riscv Joshua Yeong wrote: > 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. Hi Joshua, As far as I know you didn't tape out the JH8100 yet, and you seem to have replaced the SiFive cache controller with your own implementation. Can you exlain a bit more about why you didn't implement the perfectly good Zicbom standard instead of adding yet another non-standard work-around like this? /Emil > > Changes in v3: > - Fix code syntax > - Link to v2: https://lore.kernel.org/all/20240423072639.143450-1-joshua.yeong@starfivetech.com/ > > 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/202403151625.boKDjHGr-lkp@intel.com/ > - Flush completion through atomic timeout function > - Link to v1: https://lore.kernel.org/lkml/20240314061205.26143-1-joshua.yeong@starfivetech.com/ > > 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 | 66 +++++++++ > drivers/cache/Kconfig | 9 ++ > drivers/cache/Makefile | 5 +- > drivers/cache/starfive_starlink_cache.c | 135 ++++++++++++++++++ > 4 files changed, 213 insertions(+), 2 deletions(-) > create mode 100644 Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache.yaml > create mode 100644 drivers/cache/starfive_starlink_cache.c > > -- > 2.25.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller 2024-04-24 9:59 ` [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller Emil Renner Berthing @ 2024-04-24 13:45 ` Joshua Yeong 0 siblings, 0 replies; 14+ messages in thread From: Joshua Yeong @ 2024-04-24 13:45 UTC (permalink / raw) To: Emil Renner Berthing, robh, krzk+dt, conor+dt, conor, paul.walmsley, palmer, aou, Leyfoon Tan, JeeHeng Sia, Joshua Yeong Cc: devicetree, linux-kernel, linux-riscv Emil Renner Berthing : > Joshua Yeong wrote: > > 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. > > Hi Joshua, > > As far as I know you didn't tape out the JH8100 yet, and you seem to have > replaced the SiFive cache controller with your own implementation. Can you > exlain a bit more about why you didn't implement the perfectly good Zicbom > standard instead of adding yet another non-standard work-around like this? > > /Emil Hi Emil, I agree that the Zicbom standard is an important extension and future- designed SoC should have this. In the V1 patch, I mentioned that the CPU core used in JH8100 is matured, but unfortunately, it did not support the Zicbom extension. JH8100 integrates 'Starlink-500' IP (more information homepage), an in-house designed interconnect between peripherals and CPU to handle cache management operations. Regards, Joshua > > > Changes in v3: > > - Fix code syntax > > - Link to v2: > > https://lore.kernel.org/all/20240423072639.143450-1- > joshua.yeong@starf > > ivetech.com/ > > > > 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/202403151625.boKDjHGr-lkp@intel. > > com/ > > - Flush completion through atomic timeout function > > - Link to v1: > > https://lore.kernel.org/lkml/20240314061205.26143-1- > joshua.yeong@starf > > ivetech.com/ > > > > 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 | 66 +++++++++ > > drivers/cache/Kconfig | 9 ++ > > drivers/cache/Makefile | 5 +- > > drivers/cache/starfive_starlink_cache.c | 135 ++++++++++++++++++ > > 4 files changed, 213 insertions(+), 2 deletions(-) create mode > > 100644 > > Documentation/devicetree/bindings/cache/starfive,jh8100-starlink-cache > > .yaml create mode 100644 drivers/cache/starfive_starlink_cache.c > > > > -- > > 2.25.1 > > > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-04-24 22:04 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-04-24 7:58 [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller Joshua Yeong 2024-04-24 7:58 ` [PATCH v3 1/2] cache: Add StarFive StarLink cache management for StarFive JH8100 Joshua Yeong 2024-04-24 10:25 ` Emil Renner Berthing 2024-04-24 14:07 ` Joshua Yeong 2024-04-24 14:16 ` Emil Renner Berthing 2024-04-24 14:36 ` Joshua Yeong 2024-04-24 14:44 ` Emil Renner Berthing 2024-04-24 14:52 ` Joshua Yeong 2024-04-24 14:57 ` Emil Renner Berthing 2024-04-24 15:26 ` Joshua Yeong 2024-04-24 7:58 ` [PATCH v3 2/2] dt-bindings: cache: Add docs for StarFive Starlink cache controller Joshua Yeong 2024-04-24 22:04 ` Rob Herring 2024-04-24 9:59 ` [PATCH v3 0/2] Add StarFive's JH8100 StarLink Cache Controller Emil Renner Berthing 2024-04-24 13:45 ` Joshua Yeong
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®