From: Conor Dooley <conor@kernel.org>
To: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Emil Renner Berthing <kernel@esmil.dk>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Subject: Re: [PATCH v2 2/2] soc: sifive: ccache: Add StarFive JH7100 support
Date: Fri, 3 Nov 2023 15:53:57 +0000 [thread overview]
Message-ID: <20231103-wielder-poem-19ffccf03031@spud> (raw)
In-Reply-To: <20231031141444.53426-3-emil.renner.berthing@canonical.com>
[-- Attachment #1: Type: text/plain, Size: 3694 bytes --]
On Tue, Oct 31, 2023 at 03:14:44PM +0100, Emil Renner Berthing wrote:
> From: Emil Renner Berthing <kernel@esmil.dk>
>
> This adds support for the StarFive JH7100 SoC which also features this
> SiFive cache controller.
>
> The JH7100 has non-coherent DMAs but predate the standard RISC-V Zicbom
> exension, so instead we need to use this cache controller for
> non-standard cache management operations.
>
> Unfortunately the interrupt for uncorrected data is broken on the JH7100
> and fires continuously, so add a quirk to not register a handler for it.
>
> Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
> ---
> drivers/soc/sifive/sifive_ccache.c | 62 +++++++++++++++++++++++++++++-
> 1 file changed, 60 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c
> index 3684f5b40a80..0da3d1bd0866 100644
> --- a/drivers/soc/sifive/sifive_ccache.c
> +++ b/drivers/soc/sifive/sifive_ccache.c
> @@ -8,13 +8,16 @@
>
> #define pr_fmt(fmt) "CCACHE: " fmt
>
> +#include <linux/align.h>
> #include <linux/debugfs.h>
> #include <linux/interrupt.h>
> #include <linux/of_irq.h>
> #include <linux/of_address.h>
> #include <linux/device.h>
> #include <linux/bitfield.h>
> +#include <asm/cacheflush.h>
> #include <asm/cacheinfo.h>
> +#include <asm/dma-noncoherent.h>
> #include <soc/sifive/sifive_ccache.h>
>
> #define SIFIVE_CCACHE_DIRECCFIX_LOW 0x100
> @@ -39,10 +42,14 @@
> #define SIFIVE_CCACHE_CONFIG_SETS_MASK GENMASK_ULL(23, 16)
> #define SIFIVE_CCACHE_CONFIG_BLKS_MASK GENMASK_ULL(31, 24)
>
> +#define SIFIVE_CCACHE_FLUSH64 0x200
> +#define SIFIVE_CCACHE_FLUSH32 0x240
> +
> #define SIFIVE_CCACHE_WAYENABLE 0x08
> #define SIFIVE_CCACHE_ECCINJECTERR 0x40
>
> #define SIFIVE_CCACHE_MAX_ECCINTR 4
> +#define SIFIVE_CCACHE_LINE_SIZE 64
>
> static void __iomem *ccache_base;
> static int g_irq[SIFIVE_CCACHE_MAX_ECCINTR];
> @@ -56,6 +63,11 @@ enum {
> DIR_UNCORR,
> };
>
> +enum {
> + QUIRK_NONSTANDARD_CACHE_OPS = BIT(0),
> + QUIRK_BROKEN_DATA_UNCORR = BIT(1),
> +};
> +
> #ifdef CONFIG_DEBUG_FS
> static struct dentry *sifive_test;
>
> @@ -106,6 +118,8 @@ static void ccache_config_read(void)
> static const struct of_device_id sifive_ccache_ids[] = {
> { .compatible = "sifive,fu540-c000-ccache" },
> { .compatible = "sifive,fu740-c000-ccache" },
> + { .compatible = "starfive,jh7100-ccache",
> + .data = (void *)(QUIRK_NONSTANDARD_CACHE_OPS | QUIRK_BROKEN_DATA_UNCORR) },
> { .compatible = "sifive,ccache0" },
> { /* end of table */ }
> };
> @@ -124,6 +138,34 @@ int unregister_sifive_ccache_error_notifier(struct notifier_block *nb)
> }
> EXPORT_SYMBOL_GPL(unregister_sifive_ccache_error_notifier);
>
> +#ifdef CONFIG_RISCV_NONSTANDARD_CACHE_OPS
> +static void ccache_flush_range(phys_addr_t start, size_t len)
> +{
> + phys_addr_t end = start + len;
> + phys_addr_t line;
> +
> + if (!len)
> + return;
> +
> + mb();
Apparently memory barriers are supposed to be commented as to why they
are required.
I'm not sure if I care about that particular checkpatch complaint here.
> + for (line = ALIGN_DOWN(start, SIFIVE_CCACHE_LINE_SIZE); line < end;
> + line += SIFIVE_CCACHE_LINE_SIZE) {
> +#ifdef CONFIG_32BIT
> + writel(line >> 4, ccache_base + SIFIVE_CCACHE_FLUSH32);
> +#else
> + writeq(line, ccache_base + SIFIVE_CCACHE_FLUSH64);
> +#endif
> + mb();
> + }
> +}
> +
> +static const struct riscv_nonstd_cache_ops ccache_mgmt_ops __initdata = {
And apparently this should be __initconst rather than __initdata. I can
squash that in.
Cheers,
Conor.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-11-03 15:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 14:14 [PATCH v2 0/2] soc: sifive: ccache: Add StarFive JH7100 support Emil Renner Berthing
2023-10-31 14:14 ` [PATCH v2 1/2] dt-bindings: cache: sifive,ccache0: Add StarFive JH7100 compatible Emil Renner Berthing
2023-10-31 14:14 ` [PATCH v2 2/2] soc: sifive: ccache: Add StarFive JH7100 support Emil Renner Berthing
2023-11-03 15:53 ` Conor Dooley [this message]
2023-11-01 11:52 ` [PATCH v2 0/2] " Conor Dooley
2023-11-22 11:59 ` Conor Dooley
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=20231103-wielder-poem-19ffccf03031@spud \
--to=conor@kernel.org \
--cc=cristian.ciocaltea@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=emil.renner.berthing@canonical.com \
--cc=kernel@esmil.dk \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh+dt@kernel.org \
/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