All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pragnesh Patel <pragnesh.patel@sifive.com>
To: u-boot@lists.denx.de
Subject: [PATCH v5 12/14] riscv: sifive: fu540: enable all cache ways from u-boot proper
Date: Tue, 17 Mar 2020 09:52:15 +0000	[thread overview]
Message-ID: <MWHPR13MB0944438B1725A299976A4CBAE5F60@MWHPR13MB0944.namprd13.prod.outlook.com> (raw)
In-Reply-To: <CAEUhbmUz=Mm+o5cC+cQ4kghrSYEoPe44PyxDXw_vLAyfDfosjw@mail.gmail.com>


Hi,

>-----Original Message-----
>From: Bin Meng <bmeng.cn@gmail.com>
>Sent: 13 March 2020 19:19
>To: Anup Patel <anup@brainfault.org>
>Cc: Pragnesh Patel <pragnesh.patel@sifive.com>; U-Boot Mailing List <u-
>boot at lists.denx.de>; Atish Patra <atish.patra@wdc.com>; Palmer Dabbelt
><palmerdabbelt@google.com>; Paul Walmsley <paul.walmsley@sifive.com>;
>Jagan Teki <jagan@amarulasolutions.com>; Troy Benjegerdes
><troy.benjegerdes@sifive.com>; Anup Patel <anup.patel@wdc.com>; Sagar
>Kadam <sagar.kadam@sifive.com>; Rick Chen <rick@andestech.com>; Palmer
>Dabbelt <palmer@dabbelt.com>
>Subject: Re: [PATCH v5 12/14] riscv: sifive: fu540: enable all cache ways from
>u-boot proper
>
>Hi Anup,
>
>On Fri, Mar 13, 2020 at 6:49 PM Anup Patel <anup@brainfault.org> wrote:
>>
>> On Fri, Mar 13, 2020 at 3:52 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>> >
>> > Hi Anup,
>> >
>> > On Fri, Mar 13, 2020 at 6:02 PM Anup Patel <anup@brainfault.org> wrote:
>> > >
>> > > On Fri, Mar 13, 2020 at 2:31 PM Bin Meng <bmeng.cn@gmail.com>
>wrote:
>> > > >
>> > > > On Wed, Mar 11, 2020 at 3:04 PM Pragnesh Patel
>> > > > <pragnesh.patel@sifive.com> wrote:
>> > > > >
>> > > > > Enable all cache ways from u-boot proper.
>> > > >
>> > > > U-Boot
>> > > >
>> > > > >
>> > > > > Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
>> > > > > ---
>> > > > >  board/sifive/fu540/Makefile |  1 +
>> > > > > board/sifive/fu540/cache.c  | 20 ++++++++++++++++++++
>> > > > > board/sifive/fu540/cache.h  | 13 +++++++++++++
>> > > > > board/sifive/fu540/fu540.c  |  6 ++++--
>> > > > >  4 files changed, 38 insertions(+), 2 deletions(-)  create
>> > > > > mode 100644 board/sifive/fu540/cache.c  create mode 100644
>> > > > > board/sifive/fu540/cache.h
>> > > > >
>> > > > > diff --git a/board/sifive/fu540/Makefile
>> > > > > b/board/sifive/fu540/Makefile index b05e2f5807..3b867bbd89
>> > > > > 100644
>> > > > > --- a/board/sifive/fu540/Makefile
>> > > > > +++ b/board/sifive/fu540/Makefile
>> > > > > @@ -3,6 +3,7 @@
>> > > > >  # Copyright (c) 2019 Western Digital Corporation or its affiliates.
>> > > > >
>> > > > >  obj-y  += fu540.o
>> > > > > +obj-y  += cache.o
>> > > > >
>> > > > >  ifdef CONFIG_SPL_BUILD
>> > > > >  obj-y += spl.o
>> > > > > diff --git a/board/sifive/fu540/cache.c
>> > > > > b/board/sifive/fu540/cache.c new file mode 100644 index
>> > > > > 0000000000..a0bcd2ba48
>> > > > > --- /dev/null
>> > > > > +++ b/board/sifive/fu540/cache.c
>> > > >
>> > > > This should be put into arch/riscv/cpu/fu540/cache.c
>> > > >
>> > > > > @@ -0,0 +1,20 @@
>> > > > > +// SPDX-License-Identifier: GPL-2.0+
>> > > > > +/*
>> > > > > + * Copyright (c) 2019 SiFive, Inc  */ #include <asm/io.h>
>> > > > > +
>> > > > > +/* Register offsets */
>> > > > > +#define CACHE_ENABLE           0x008
>> > > > > +
>> > > > > +/* Enable ways; allow cache to use these ways */ void
>> > > > > +cache_enable_ways(u64 base_addr, u8 value) {
>> > > > > +       volatile u32 *enable = (volatile u32 *)(base_addr +
>> > > > > +                                         CACHE_ENABLE);
>> > > > > +       /* memory barrier */
>> > > > > +       mb();
>> > > > > +       (*enable) = value;
>> > > > > +       /* memory barrier */
>> > > > > +       mb();
>> > > > > +}
>> > > > > diff --git a/board/sifive/fu540/cache.h
>> > > > > b/board/sifive/fu540/cache.h new file mode 100644 index
>> > > > > 0000000000..425124a23b
>> > > > > --- /dev/null
>> > > > > +++ b/board/sifive/fu540/cache.h
>> > > >
>> > > > arch/riscv/include/asm/arch-fu540/cache.h
>> > >
>> > > Let's not entire FU540 directory under arch/riscv/cpu directory
>> > > just to have cache functions. The arch/riscv/cpu/generic is
>> > > perfectly suitable for FU540.
>> >
>> > I doubt arch/riscv/cpu/generic can be generic if we consider U-Boot
>> > SPL phase. It can be generic for S-mode U-Boot though.
>>
>> Its really very easy to do. We are already doing this in Xvisor.
>>
>> As an example, of DT based operations in a generic board support refer:
>> https://github.com/avpatel/xvisor-next/blob/master/arch/arm/board/gene
>> ric/brd_main.c
>> https://github.com/avpatel/xvisor-next/blob/master/arch/arm/board/gene
>> ric/foundation-v8.c
>
>Yes, this can be easy to do if we have everything written based on DT.
>But we cannot always assume DT is available in SPL. Some SoCs will not allow
>SPL with DT support to run due to constraint resources.
>
>Even for DT, due to SPL initialization codes can be very low-level and specific
>to an SoC, not everything can be properly modeled by DT. Take a look at the
>u-boot/arch/arm directory. Things are not that easy.
>
>>
>> Using the above approach, we are able to boot same Xvisor ARM/ARM64
>> binary on multiple boards.
>>
>
>Yes, I know. The same as what is done in the Linux kernel. Take x86 for
>example, the same kernel image can boot on almost every x86
>desktop/laptop/server we have today. But we have to understand that this is
>built on top of BIOS which does all low-level processor / chipset initialization
>and hide that very well for OS.
>

IMHO just for cache, it's better not to add arch/riscv/cpu/fu540.
If something that we can not handle with arch/riscv/cpu/generic then we will
definitely add arch/riscv/cpu/fu540 dir.

Thanks Bin and Anup for the review.

>> >
>> > >
>> > > If we re-use arch/riscv/cpu/generic as-much as possible then
>> > > arch/riscv will be easy to maintain in future.
>> > >
>> > > We can add arch/riscv/cpu/generic/cache.c which will do things
>> > > FU540 specific based on "#ifdef" or "DT compatible string".
>> > >
>
>Regards,
>Bin

  reply	other threads:[~2020-03-17  9:52 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11  7:03 [PATCH v5 00/14] RISC-V SiFive FU540 support SPL Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 01/14] misc: add driver for the SiFive otp controller Pragnesh Patel
2020-03-11 10:25   ` Bin Meng
2020-03-17 17:30     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 02/14] riscv: sifive: fu540: Use OTP DM driver for serial environment variable Pragnesh Patel
2020-03-11 13:32   ` Bin Meng
2020-03-11 14:52     ` Bin Meng
2020-03-17 15:45       ` Pragnesh Patel
2020-03-11 15:00   ` Bin Meng
2020-03-17 17:36     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 03/14] riscv: Add _image_binary_end for SPL Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 04/14] lib: Makefile: build crc7.c when CONFIG_MMC_SPI Pragnesh Patel
2020-03-11 13:52   ` Bin Meng
2020-03-17 16:47     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 05/14] riscv: sifive: dts: fu540: Add board -u-boot.dtsi files Pragnesh Patel
2020-03-11 14:51   ` Bin Meng
2020-03-17 16:44     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 06/14] sifive: fu540: add ddr driver Pragnesh Patel
2020-03-13  7:48   ` Bin Meng
2020-03-17 13:00     ` Pragnesh Patel
2020-03-13 11:56   ` Giulio Benetti
2020-03-17 13:05     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 07/14] sifive: dts: fu540: Add DDR controller and phy register settings Pragnesh Patel
2020-03-13  7:51   ` Bin Meng
2020-03-17 15:35     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 08/14] clk: sifive: fu540-prci: Add clock enable and disable ops Pragnesh Patel
2020-03-13  7:57   ` Bin Meng
2020-03-13  8:15     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 09/14] clk: sifive: fu540-prci: Add clock initialization for SPL Pragnesh Patel
2020-03-13  8:11   ` Bin Meng
2020-03-17 17:47     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 10/14] riscv: sifive: fu540: add SPL configuration Pragnesh Patel
2020-03-13  8:28   ` Bin Meng
2020-03-17  7:41     ` Pragnesh Patel
2020-03-13 13:59   ` Bin Meng
2020-03-17  8:04     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 11/14] configs: fu540: Add config options for U-boot SPL Pragnesh Patel
2020-03-13  8:48   ` Bin Meng
2020-03-17 14:45     ` Pragnesh Patel
2020-03-11  7:03 ` [PATCH v5 12/14] riscv: sifive: fu540: enable all cache ways from u-boot proper Pragnesh Patel
2020-03-13  9:01   ` Bin Meng
2020-03-13 10:02     ` Anup Patel
2020-03-13 10:22       ` Bin Meng
2020-03-13 10:49         ` Anup Patel
2020-03-13 13:49           ` Bin Meng
2020-03-17  9:52             ` Pragnesh Patel [this message]
     [not found]               ` <752D002CFF5D0F4FA35C0100F1D73F3FA46E7F97@ATCPCS16.andestech.com>
2020-03-18  2:27                 ` Rick Chen
2020-03-13 10:54         ` Anup Patel
2020-03-11  7:03 ` [PATCH v5 13/14] sifive: fix palmer's email address Pragnesh Patel
2020-03-13  9:01   ` Bin Meng
2020-03-11  7:03 ` [PATCH v5 14/14] doc: update FU540 RISC-V documentation Pragnesh Patel
2020-03-13  9:22   ` Bin Meng
2020-03-17 14:31     ` Pragnesh Patel

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=MWHPR13MB0944438B1725A299976A4CBAE5F60@MWHPR13MB0944.namprd13.prod.outlook.com \
    --to=pragnesh.patel@sifive.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.