mbox series

[v2,0/2] Add StarFive's JH8100 StarLink Cache Controller

Message ID 20240423072639.143450-1-joshua.yeong@starfivetech.com
Headers show
Series Add StarFive's JH8100 StarLink Cache Controller | expand

Message

Joshua Yeong April 23, 2024, 7:26 a.m. UTC
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

Comments

Conor Dooley April 23, 2024, 3:54 p.m. UTC | #1
On Tue, Apr 23, 2024 at 03:26:38PM +0800, Joshua Yeong wrote:
> +
> +#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
> +
> +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?

> +                                      STARLINK_CACHE_FLUSH_CTL;

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

> +	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.