linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"Nicolas Pitre" <nico@fluxnic.net>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Lukasz Stelmach" <l.stelmach@samsung.com>,
	"Russell King" <linux@armlinux.org.uk>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	"Chris Brandt" <chris.brandt@renesas.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Eric Miao" <eric.miao@nvidia.com>,
	"Dmitry Osipenko" <digetx@gmail.com>,
	"Linux ARM" <linux-arm-kernel@lists.infradead.org>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>
Subject: Re: [PATCH/RFC v7] ARM: boot: Obtain start of physical memory from DTB
Date: Tue, 7 Jul 2020 09:58:35 +0200	[thread overview]
Message-ID: <CAMuHMdU4htNtgTTXjS5Q7-oxLaCtFVXypG14j0D9un09RM1Dxg@mail.gmail.com> (raw)
In-Reply-To: <CAMj1kXHe96g+4uuUsWTHbKom=EvssnbzZyX9i5La463QKjhLsw@mail.gmail.com>

Hi Ard,

On Tue, Jul 7, 2020 at 9:45 AM Ard Biesheuvel <ardb@kernel.org> wrote:
> On Tue, 7 Jul 2020 at 10:39, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Tue, Jul 7, 2020 at 8:50 AM Ard Biesheuvel <ardb@kernel.org> wrote:
> > > On Mon, 6 Jul 2020 at 18:02, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> > > > Currently, the start address of physical memory is obtained by masking
> > > > the program counter with a fixed mask of 0xf8000000.  This mask value
> > > > was chosen as a balance between the requirements of different platforms.
> > > > However, this does require that the start address of physical memory is
> > > > a multiple of 128 MiB, precluding booting Linux on platforms where this
> > > > requirement is not fulfilled.
> > > >
> > > > Fix this limitation by obtaining the start address from the DTB instead,
> > > > if available (either explicitly passed, or appended to the kernel).
> > > > Fall back to the traditional method when needed.
> > > >
> > > > This allows to boot Linux on r7s9210/rza2mevb using the 64 MiB of SDRAM
> > > > on the RZA2MEVB sub board, which is located at 0x0C000000 (CS3 space),
> > > > i.e. not at a multiple of 128 MiB.
> > > >
> > > > Suggested-by: Nicolas Pitre <nico@fluxnic.net>
> > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > > Reviewed-by: Nicolas Pitre <nico@fluxnic.net>
> > > > Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
> > > > Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > > > Tested-by: Dmitry Osipenko <digetx@gmail.com>
> > > > Cc: Lukasz Stelmach <l.stelmach@samsung.com>
> > > > ---
> > > > Marked as RFC, because:
> > > >   1. This is known to break crashkernel support, as the memory used by
> > > >      the crashkernel is not marked reserved in DT (yet),
> > > >   2. Russell won't apply this for v5.9 anyway,
> > > >
> > >
> > > Would it help if we make this behavior dependent on a simple heuristic, e.g.,
> > >
> > > if (round_up(load_address, 128M) >= dram_end)
> > >   use dram_start from DT
> > > else
> > >   use round_up(load_address, 128M)
> > >
> > > That way, the fix is guaranteed to only take effect for systems that
> > > cannot even boot otherwise, which fixes the crashkernel case, as well
> > > as other potential regressions due to the load address of the core
> > > kernel changing for existing boards.
> >
> > Thanks for your suggestion!
> >   1. Shouldn't the calculation use round_down() instead of round_up()?
> >   2. Likewise, "round_down(load_address, 128M) < dram_start from DT"?
> >
>
> No.
>
> What the code does today is round *up* to a multiple of 128 MB, and
> only when that leads to a problem, we should use the DT provided
> memory regions.

                mov     r4, pc
                and     r4, r4, #0xf8000000

Surely this is rounding down, isn't it?

                add     r4, r4, #TEXT_OFFSET

Followed by adding a small number (typically 0x00008000).

On RZA2MEVB with 64 MiB of RAM, the result lies below dram_start.
BTW, how to obtain dram_end? From DT again? Do we trust it, as we
apparently cannot trust dram_start in some configurations.

Do I need more coffee?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-07-07  8:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 15:02 [PATCH/RFC v7] ARM: boot: Obtain start of physical memory from DTB Geert Uytterhoeven
2020-07-07  6:50 ` Ard Biesheuvel
2020-07-07  7:39   ` Geert Uytterhoeven
2020-07-07  7:45     ` Ard Biesheuvel
2020-07-07  7:58       ` Geert Uytterhoeven [this message]
2020-07-07  8:35         ` Ard Biesheuvel
2020-07-07  8:40           ` Ard Biesheuvel
2020-07-07  9:09             ` Ard Biesheuvel
2020-07-20  9:45 ` Linus Walleij
2020-07-20  9:53   ` Arnd Bergmann
2020-07-21 12:58     ` Linus Walleij
2020-07-23  1:19       ` Stephen Boyd
2020-08-03 10:18         ` Geert Uytterhoeven
2020-08-03 19:46           ` Stephen Boyd
2020-08-14 14:03         ` Linus Walleij
2020-08-14 14:06           ` Ard Biesheuvel
2020-08-15  9:18             ` Russell King - ARM Linux admin
2020-08-15  8:28           ` Stephen Boyd
2020-08-15  9:16           ` Russell King - ARM Linux admin
2020-08-15 10:28             ` Linus Walleij

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=CAMuHMdU4htNtgTTXjS5Q7-oxLaCtFVXypG14j0D9un09RM1Dxg@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=chris.brandt@renesas.com \
    --cc=digetx@gmail.com \
    --cc=eric.miao@nvidia.com \
    --cc=l.stelmach@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=masahiroy@kernel.org \
    --cc=nico@fluxnic.net \
    --cc=u.kleine-koenig@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).