U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Randolph Sapp <rs@ti.com>
To: Simon Glass <sjg@chromium.org>, <rs@ti.com>
Cc: <robertcnelson@gmail.com>, <ayush@beagleboard.org>,
	<Erik.Welsh@octavosystems.com>, <anshuld@ti.com>, <bb@ti.com>,
	<trini@konsulko.com>, <afd@ti.com>, <xypron.glpk@gmx.de>,
	<ilias.apalodimas@linaro.org>, <u-boot@lists.denx.de>
Subject: Re: [PATCHv6 1/3] sandbox: add board_get_usable_ram_top
Date: Mon, 11 May 2026 13:44:54 -0500	[thread overview]
Message-ID: <DIG2J12J21HH.K196O8LVE6B5@ti.com> (raw)
In-Reply-To: <CAFLszTgDu56LqCfzXgZ2P=V6szOYytMSvj0LRn4u4S8YWOcEuw@mail.gmail.com>

On Mon May 11, 2026 at 1:26 PM CDT, Simon Glass wrote:
> Hi Randolph,
>
> On 2026-05-08T22:29:09, Randolph Sapp <rs@ti.com> wrote:
>> sandbox: add board_get_usable_ram_top
>>
>> Add a board_get_usable_ram_top definition, since currently ram_top is
>> equal to ram_size. Attempting to actually map ram_size with map_sysmem
>> results in a fault.
>>
>> Signed-off-by: Randolph Sapp <rs@ti.com>
>>
>> board/sandbox/sandbox.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>
>> diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
>> @@ -105,6 +105,11 @@ int dram_init(void)
>> +phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
>> +{
>> +     return gd->ram_size - 1;
>> +}
>> +
>
> Please describe which caller actually faults on map_sysmem(), since
> that is the real motivation.
>
> But this contradicts the documented API. From include/init.h:
>
>    The returned address is exclusive (i.e. 1 byte above the
>    last usable address).
>
> See the weak function in common/board_f.c

Ugh. Why is *usable* ram top exclusive? That's returning an explicitly
*unusable* address. Fun. Suppose it's my fault for not reading that first.

> If the real problem is callers doing map_sysmem(ram_top, ...) and
> faulting, you could fix it in those callers (use ram_top - 1 when you
> need the last valid byte). But I could take a look if you point to the
> code.
>
> Also, this uses gd->ram_size as if it were an address; it should
> really be gd->ram_base + gd->ram_size. It happens to work because
> sandbox's ram_base is 0, but it reads as a type confusion.
>
> Regards,
> Simon

Fair enough, but it seems that this board definition will not be required given
the above feedback.

  reply	other threads:[~2026-05-11 18:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 22:29 [PATCHv6 0/3] various memory related fixups rs
2026-05-08 22:29 ` [PATCHv6 1/3] sandbox: add board_get_usable_ram_top rs
2026-05-11 18:26   ` Simon Glass
2026-05-11 18:44     ` Randolph Sapp [this message]
2026-05-11 19:22       ` Simon Glass
2026-05-08 22:29 ` [PATCHv6 2/3] boot_fdt_add_mem_rsv_regions: free old dtb reservations rs
2026-05-11 18:27   ` Simon Glass
2026-05-11 23:17     ` Randolph Sapp
2026-05-08 22:29 ` [PATCHv6 3/3] memory: reserve from start_addr_sp to initial_relocaddr rs
2026-05-11 18:28   ` Simon Glass
2026-05-11 19:41     ` Randolph Sapp
2026-05-13 16:39       ` Simon Glass
2026-05-11 18:28 ` [PATCHv6,0/3] various memory related fixups Simon Glass

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=DIG2J12J21HH.K196O8LVE6B5@ti.com \
    --to=rs@ti.com \
    --cc=Erik.Welsh@octavosystems.com \
    --cc=afd@ti.com \
    --cc=anshuld@ti.com \
    --cc=ayush@beagleboard.org \
    --cc=bb@ti.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=robertcnelson@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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