All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Patel <Anup.Patel@wdc.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 03/11] riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
Date: Tue, 22 Jan 2019 12:48:29 +0000	[thread overview]
Message-ID: <BYAPR04MB5303C488D0F23722244532128D980@BYAPR04MB5303.namprd04.prod.outlook.com> (raw)
In-Reply-To: <CAEUhbmWkgCoeYOMOt+ct9pWw7SRBSWf1sjO-hd8-NN2aS4vxgg@mail.gmail.com>



> -----Original Message-----
> From: Bin Meng [mailto:bmeng.cn at gmail.com]
> Sent: Tuesday, January 22, 2019 7:37 AM
> To: Anup Patel <Anup.Patel@wdc.com>
> Cc: Rick Chen <rick@andestech.com>; Joe Hershberger
> <joe.hershberger@ni.com>; Lukas Auer <lukas.auer@aisec.fraunhofer.de>;
> Masahiro Yamada <yamada.masahiro@socionext.com>; Simon Glass
> <sjg@chromium.org>; Alexander Graf <agraf@suse.de>; Palmer Dabbelt
> <palmer@sifive.com>; Paul Walmsley <paul.walmsley@sifive.com>; Atish
> Patra <Atish.Patra@wdc.com>; Christoph Hellwig <hch@infradead.org>; U-
> Boot Mailing List <u-boot@lists.denx.de>
> Subject: Re: [PATCH v2 03/11] riscv: generic: Ensure that U-Boot runs within
> 4GB for 64bit systems
> 
> On Fri, Jan 18, 2019 at 7:19 PM Anup Patel <Anup.Patel@wdc.com> wrote:
> >
> > On 64bit systems, the DRAM top can be easily beyond 4GB and U-Boot
> DMA
> > mapping APIs will generate DMA addresses beyond 4GB. This breaks DMA
> > programming in 32bit DMA capable devices (such as Cadence MACB
> > ethernet). For example, If DRAM is more then 2GB on QEMU sifive_u
> > machine then Cadence MACB ethernet stops working for U-Boot because
> it
> > is a 32bit DMA capable device.
> >
> > To handle 32bit DMA capable devices on 64bit systems, we provide
> > custom implementation of board_get_usable_ram_top() which ensures
> that
> > usable ram top is not more then 4GB. This in-turn ensures that U-Boot
> > always runs within 4GB hence DMA addresses generated by DMA mapping
> > APIs will be within 4GB too.
> >
> > Signed-off-by: Atish Patra <atish.patra@wdc.com>
> > Signed-off-by: Anup Patel <anup.patel@wdc.com>
> > Reviewed-by: Alexander Graf <agraf@suse.de>
> > ---
> >  arch/riscv/cpu/generic/dram.c | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> >
> 
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> 
> But see one comment below:
> 
> > diff --git a/arch/riscv/cpu/generic/dram.c
> > b/arch/riscv/cpu/generic/dram.c index 84d87d2a7f..5725d3c7ae 100644
> > --- a/arch/riscv/cpu/generic/dram.c
> > +++ b/arch/riscv/cpu/generic/dram.c
> > @@ -5,6 +5,9 @@
> >
> >  #include <common.h>
> >  #include <fdtdec.h>
> > +#include <linux/sizes.h>
> > +
> > +DECLARE_GLOBAL_DATA_PTR;
> >
> >  int dram_init(void)
> >  {
> > @@ -15,3 +18,20 @@ int dram_init_banksize(void)  {
> >         return fdtdec_setup_memory_banksize();  }
> > +
> > +ulong board_get_usable_ram_top(ulong total_size) { #ifdef
> > +CONFIG_64BIT
> > +       /*
> > +        * Ensure that we run from first 4GB so that all
> > +        * addresses used by U-Boot are 32bit addresses.
> > +        *
> > +        * This in-turn ensures that 32bit DMA capabale
> > +        * devices work fine because DMA mapping APIs will
> > +        * provide 32bit DMA addresses only.
> > +        */
> > +       if (gd->ram_top > SZ_4G)
> > +               return SZ_4G;
> > +#endif
> > +       return gd->ram_top;
> > +}
> 
> I was wondering whether we should change this for 32-bit too, given it's a
> valid configuration to have more than 4GB memory in a 32-bit system.

We had considered this but "gd->ram_top" is "unsigned long" so on
32bit system it will be 32bit only. In other words, value of "gd->ram_top"
on 32bit system can never exceed 4GB.

Regards,
Anup

  reply	other threads:[~2019-01-22 12:48 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18 11:18 [U-Boot] [PATCH v2 00/11] SiFive FU540 Support Anup Patel
2019-01-18 11:18 ` [U-Boot] [PATCH v2 01/11] riscv: Rename cpu/qemu to cpu/generic Anup Patel
2019-01-20 19:57   ` Auer, Lukas
2019-01-22  2:06   ` Bin Meng
2019-01-18 11:18 ` [U-Boot] [PATCH v2 02/11] riscv: Add asm/dma-mapping.h for DMA mappings Anup Patel
2019-01-20 19:57   ` Auer, Lukas
2019-01-18 11:18 ` [U-Boot] [PATCH v2 03/11] riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems Anup Patel
2019-01-20 20:04   ` Auer, Lukas
2019-01-21  5:49     ` Anup Patel
2019-01-22  2:06   ` Bin Meng
2019-01-22 12:48     ` Anup Patel [this message]
2019-01-18 11:19 ` [U-Boot] [PATCH v2 04/11] net: macb: Fix clk API usage for RISC-V systems Anup Patel
2019-01-18 11:19 ` [U-Boot] [PATCH v2 05/11] net: macb: Fix GEM hardware detection Anup Patel
2019-01-18 11:51   ` Alexander Graf
2019-01-18 13:03     ` Anup Patel
2019-01-18 13:11       ` Alexander Graf
2019-01-18 13:25         ` Anup Patel
2019-01-20 20:05   ` Auer, Lukas
2019-01-18 11:19 ` [U-Boot] [PATCH v2 06/11] clk: Add SiFive FU540 PRCI clock driver Anup Patel
2019-01-20 20:12   ` Auer, Lukas
2019-01-21  5:55     ` Anup Patel
2019-01-21 12:09       ` Auer, Lukas
2019-01-18 11:19 ` [U-Boot] [PATCH v2 07/11] clk: Add fixed-factor " Anup Patel
2019-01-31 10:04   ` Simon Glass
2019-02-05 12:53     ` Anup Patel
2019-01-18 11:19 ` [U-Boot] [PATCH v2 08/11] drivers: serial_sifive: Fix baud rate calculation Anup Patel
2019-01-18 11:52   ` Alexander Graf
2019-01-18 13:04     ` Anup Patel
2019-01-20 20:13   ` Auer, Lukas
2019-01-18 11:19 ` [U-Boot] [PATCH v2 09/11] drivers: serial_sifive: Skip baudrate config if no input clock Anup Patel
2019-01-20 20:22   ` Auer, Lukas
2019-01-21  1:07     ` Atish Patra
2019-01-21 12:39       ` Auer, Lukas
2019-02-10 18:02         ` Auer, Lukas
2019-01-18 11:19 ` [U-Boot] [PATCH v2 10/11] cpu: Bind timer driver for boot hart Anup Patel
2019-01-18 11:52   ` Alexander Graf
2019-01-18 13:04     ` Anup Patel
2019-01-20 20:22   ` Auer, Lukas
2019-01-22  2:06   ` Bin Meng
2019-01-18 11:19 ` [U-Boot] [PATCH v2 11/11] riscv: Add SiFive FU540 board support Anup Patel
2019-01-20 20:26   ` Auer, Lukas
2019-01-21  1:22     ` Atish Patra
2019-01-21 12:57       ` Auer, Lukas
2019-01-21  9:48   ` Andreas Schwab
2019-01-21 16:17     ` Anup Patel
2019-01-21 16:36       ` Andreas Schwab
2019-01-21 16:53         ` Anup Patel
2019-01-21 17:10           ` Andreas Schwab
2019-01-21 17:32             ` Anup Patel
2019-01-22  9:30               ` Andreas Schwab
2019-01-23 19:01                 ` Atish Patra
2019-01-24  9:53                   ` Andreas Schwab
2019-01-24 10:43                     ` Anup Patel
2019-01-24 10:46                       ` Alexander Graf
2019-01-24 11:05                         ` Anup Patel
2019-01-24 11:18                           ` Alexander Graf
2019-01-24 12:52                             ` Anup Patel
2019-01-24 13:38                             ` Andreas Schwab
2019-01-24 13:53                               ` Alexander Graf
2019-01-24 13:57                                 ` Andreas Schwab
2019-02-03  7:41                                   ` Anup Patel
2019-02-04 11:17                                     ` Andreas Schwab
2019-02-04 13:03                                       ` Atish Patra
2019-02-04 13:10                                         ` Andreas Schwab
2019-02-05 12:14                                           ` Anup Patel
2019-02-05 12:51                                             ` Andreas Schwab
2019-02-05 12:58                                               ` Anup Patel
2019-02-05 13:40                                                 ` Andreas Schwab
2019-02-05 14:28                                                   ` Anup Patel
2019-02-05 14:39                                                     ` Andreas Schwab
2019-02-05 14:43                                                       ` Anup Patel
2019-02-05 15:00                                                         ` Andreas Schwab
2019-02-05 15:04                                                           ` Anup Patel
2019-01-22  2:06   ` Bin Meng
2019-01-20 20:33 ` [U-Boot] [PATCH v2 00/11] SiFive FU540 Support Auer, Lukas
2019-01-21  1:37   ` Atish Patra
2019-01-21  4:04     ` Anup Patel
2019-01-21  6:14       ` Bin Meng
2019-01-21  6:41         ` Anup Patel
2019-01-21  7:02           ` Bin Meng
2019-01-22 11:51       ` Auer, Lukas
2019-01-22 12:31         ` Anup Patel
2019-01-22 22:35           ` Auer, Lukas
2019-02-02 17:06         ` Paul Walmsley
2019-02-10 17:54           ` Auer, Lukas

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=BYAPR04MB5303C488D0F23722244532128D980@BYAPR04MB5303.namprd04.prod.outlook.com \
    --to=anup.patel@wdc.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.