From: Sean Anderson <seanga2@gmail.com>
To: Zong Li <zong.li@sifive.com>,
rick@andestech.com, ycliang@andestech.com, bmeng.cn@gmail.com,
green.wan@sifive.com, paul.walmsley@sifive.com, sjg@chromium.org,
u-boot@lists.denx.de
Subject: Re: [PATCH v2 3/6] riscv: lib: introduce cache_init interface
Date: Tue, 10 Aug 2021 00:47:28 -0400 [thread overview]
Message-ID: <a42cb3ca-5430-2ed9-0789-0b4c08a34439@gmail.com> (raw)
In-Reply-To: <20210803044444.14032-4-zong.li@sifive.com>
On 8/3/21 12:44 AM, Zong Li wrote:
> Add an interface for cache initialization. Each platform can overwrite
> this weak function by their own implementation, such as sifive_cache in
> this patch.
Can we call this enable_caches instead of cache_init? This function is
called by initr_caches in board_r.c for ARM. There's even an
eight-year-old TODO on the subject.
>
> Signed-off-by: Zong Li <zong.li@sifive.com>
> ---
> arch/riscv/Kconfig | 5 +++++
> arch/riscv/include/asm/cache.h | 1 +
> arch/riscv/lib/Makefile | 1 +
> arch/riscv/lib/cache.c | 5 +++++
> arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++
> 5 files changed, 39 insertions(+)
> create mode 100644 arch/riscv/lib/sifive_cache.c
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 4b0c3dffa6..ec651fe0a4 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -179,6 +179,11 @@ config SPL_SIFIVE_CLINT
> The SiFive CLINT block holds memory-mapped control and status registers
> associated with software and timer interrupts.
>
> +config SIFIVE_CACHE
> + bool
> + help
> + This enables the operations to configure SiFive cache
> +
> config ANDES_PLIC
> bool
> depends on RISCV_MMODE || SPL_RISCV_MMODE
> diff --git a/arch/riscv/include/asm/cache.h b/arch/riscv/include/asm/cache.h
> index ec8fe201d3..6ebb2b4329 100644
> --- a/arch/riscv/include/asm/cache.h
> +++ b/arch/riscv/include/asm/cache.h
> @@ -9,6 +9,7 @@
>
> /* cache */
> void cache_flush(void);
> +int cache_init(void);
>
> /*
> * The current upper bound for RISCV L1 data cache line sizes is 32 bytes.
> diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
> index c4cc41434b..06020fcc2a 100644
> --- a/arch/riscv/lib/Makefile
> +++ b/arch/riscv/lib/Makefile
> @@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
> obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
> obj-$(CONFIG_CMD_GO) += boot.o
> obj-y += cache.o
> +obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o
> ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y)
> obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o
> obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
> diff --git a/arch/riscv/lib/cache.c b/arch/riscv/lib/cache.c
> index b1d42bcc2b..2cd66504c6 100644
> --- a/arch/riscv/lib/cache.c
> +++ b/arch/riscv/lib/cache.c
> @@ -70,3 +70,8 @@ __weak int dcache_status(void)
> {
> return 0;
> }
> +
> +__weak int cache_init(void)
> +{
> + return 0;
> +}
> diff --git a/arch/riscv/lib/sifive_cache.c b/arch/riscv/lib/sifive_cache.c
> new file mode 100644
> index 0000000000..94e84e024e
> --- /dev/null
> +++ b/arch/riscv/lib/sifive_cache.c
> @@ -0,0 +1,27 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2021 SiFive, Inc
> + */
> +
> +#include <common.h>
> +#include <cache.h>
> +#include <dm.h>
> +
> +int cache_init(void)
> +{
> + struct udevice *dev;
> + int ret;
> +
> + /* Enable ways of ccache */
> + ret = uclass_get_device_by_driver(UCLASS_CACHE,
> + DM_DRIVER_GET(sifive_ccache),
> + &dev);
> + if (ret)
> + return log_msg_ret("Cannot enable cache ways", ret);
> +
> + ret = cache_enable(dev);
> + if (ret)
> + return log_msg_ret("ccache enable failed", ret);
> +
> + return 0;
> +}
>
Otherwise LGTM
next prev parent reply other threads:[~2021-08-10 4:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 4:44 [PATCH v2 0/6] Support SiFive Composable cache driver Zong Li
2021-08-03 4:44 ` [PATCH v2 1/6] cache: add sifive composable " Zong Li
2021-08-10 4:39 ` Sean Anderson
2021-08-03 4:44 ` [PATCH v2 2/6] board: sifive: use ccache driver instead of helper function Zong Li
2021-08-10 4:51 ` Sean Anderson
2021-08-10 6:40 ` Zong Li
2021-08-03 4:44 ` [PATCH v2 3/6] riscv: lib: introduce cache_init interface Zong Li
2021-08-10 4:47 ` Sean Anderson [this message]
2021-08-10 6:57 ` Zong Li
2021-08-12 20:20 ` Sean Anderson
2021-08-13 4:00 ` Zong Li
2021-08-03 4:44 ` [PATCH v2 4/6] riscv: sifive: use common cache_init instead of duplicated implementation Zong Li
2021-08-03 4:44 ` [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder Zong Li
2021-08-10 4:55 ` Sean Anderson
2021-08-10 7:04 ` Zong Li
2021-08-12 20:22 ` Sean Anderson
2021-08-13 3:49 ` Zong Li
2021-08-03 4:44 ` [PATCH v2 6/6] riscv: lib: modify the indent Zong Li
2021-08-10 4:55 ` Sean Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a42cb3ca-5430-2ed9-0789-0b4c08a34439@gmail.com \
--to=seanga2@gmail.com \
--cc=bmeng.cn@gmail.com \
--cc=green.wan@sifive.com \
--cc=paul.walmsley@sifive.com \
--cc=rick@andestech.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=ycliang@andestech.com \
--cc=zong.li@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox