All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anshul Dalal <anshuld@ti.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: <u-boot@lists.denx.de>, <d-gole@ti.com>, <b-padhi@ti.com>,
	<vigneshr@ti.com>, <trini@konsulko.com>, <nm@ti.com>,
	<robertcnelson@gmail.com>, <w.egorov@phytec.de>,
	<francesco.dolcini@toradex.com>, <ggiordano@phytec.com>,
	<m-chawdhry@ti.com>, <a-nandan@ti.com>, <afd@ti.com>, <bb@ti.com>,
	<u-kumar1@ti.com>, <devarsht@ti.com>
Subject: Re: [PATCH -next v6 05/10] arm: armv8: mmu: add mem_map_fix_dram_banks
Date: Fri, 12 Sep 2025 13:11:36 +0530	[thread overview]
Message-ID: <DCQNHVLA3G7W.13QL3Z9ZMVJDQ@ti.com> (raw)
In-Reply-To: <CAC_iWjLKGe8CUhA42M_2BEd7gDKT0pW+FWFwmCcoiVcU6YUPmw@mail.gmail.com>

On Fri Sep 12, 2025 at 12:56 PM IST, Ilias Apalodimas wrote:
> On Fri, 12 Sept 2025 at 09:38, Anshul Dalal <anshuld@ti.com> wrote:
>>
>> Hi Ilias,
>>
>> On Fri Sep 12, 2025 at 12:03 PM IST, Ilias Apalodimas wrote:
>> > Hi Anshul,
>> >
>> > On Fri, 5 Sept 2025 at 11:19, Anshul Dalal <anshuld@ti.com> wrote:
>> >>
>> >> For armv8, U-Boot uses a static map defined as 'mem_map' for configuring
>> >> the MMU as part of mmu_setup.
>> >>
>> >> But since the exact configuration of memory banks might not be known at
>> >> build time, many platforms such as imx9, versal2 etc. utilize
>> >> gd->bd->bi_dram to configure the static map at runtime.
>> >>
>> >> Therefore this patch adds a new API mem_map_fix_dram_banks that modifies
>> >> the static map in a similar way. Allowing for anyone to map all dram
>> >> banks by just passing the index to last entry in their mem_map and it's
>> >> length.
>> >>
>> >> Signed-off-by: Anshul Dalal <anshuld@ti.com>
>> >> ---
>> >>  arch/arm/cpu/armv8/cache_v8.c    | 27 +++++++++++++++++++++++++++
>> >>  arch/arm/include/asm/armv8/mmu.h | 10 ++++++++++
>> >>  2 files changed, 37 insertions(+)
>> >>
>> >> diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
>> >> index 6e662395a83..edb895da1f2 100644
>> >> --- a/arch/arm/cpu/armv8/cache_v8.c
>> >> +++ b/arch/arm/cpu/armv8/cache_v8.c
>> >> @@ -58,6 +58,33 @@ static int get_effective_el(void)
>> >>         return el;
>> >>  }
>> >>
>> >> +int mem_map_fix_dram_banks(unsigned int index, unsigned int len, u64 attrs)
>> >> +{
>> >> +       unsigned int i;
>> >> +       int ret = fdtdec_setup_memory_banksize();
>> >> +
>> >> +       if (ret) {
>> >> +               printf("%s: Failed to setup dram banks\n", __func__);
>> >> +               return ret;
>> >> +       }
>> >> +
>> >> +       if (index + CONFIG_NR_DRAM_BANKS >= len) {
>> >> +               printf("%s: Not sufficient space in memory map\n", __func__);
>> >> +               return -ENOMEM;
>> >> +       }
>> >
>> > The length of the mem_map array is configured at compile time.
>> > So this is going to fail for all existing boards unless someone
>> > explicitly changes the size of their struct mm_region.
>> > I think if we go down that path, we need to change the error message
>> > as well and point them to the right direction
>> >
>> >> +
>> >> +       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
>> >> +               mem_map[index].virt = gd->bd->bi_dram[i].start;
>> >> +               mem_map[index].phys = gd->bd->bi_dram[i].start;
>> >> +               mem_map[index].size = gd->bd->bi_dram[i].size;
>> >> +               mem_map[index].attrs = attrs;
>> >> +               index++;
>> >> +       }
>> >> +
>> >> +       mem_map[index] = (const struct mm_region){ 0 };
>> >
>> > Why do you need the const?
>> > Can we do
>> > memset(&mem_map[index], 0, sizeof(mem_map[index]));
>> > instead?
>> >
>>
>> Yeah, we could do that instead. But it essentially achieves the same
>> thing, right?
>
> Yes, i just find it a bit easier to read
>

That's fair, will update in a v2 along with a better error message for
mem_map array size.

Thanks for the review,
Anshul

  reply	other threads:[~2025-09-12  7:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05  8:18 [PATCH -next v6 0/9] Add support for dynamic MMU configuration Anshul Dalal
2025-09-05  8:18 ` [PATCH -next v6 01/10] mach-k3: use minimal memory map for all K3 Anshul Dalal
2025-09-10  9:42   ` Dhruva Gole
2025-09-05  8:18 ` [PATCH -next v6 02/10] mach-k3: use custom enable_cache Anshul Dalal
2025-09-10  9:44   ` Dhruva Gole
2025-09-05  8:18 ` [PATCH -next v6 03/10] arm: armv8: mmu: export mmu_setup Anshul Dalal
2025-09-10  9:47   ` Dhruva Gole
2025-09-12  5:59   ` Ilias Apalodimas
2025-09-12  6:02     ` Ilias Apalodimas
2025-09-05  8:18 ` [PATCH -next v6 04/10] arm: armv8: invalidate dcache entries on dcache_enable Anshul Dalal
2025-09-10  9:50   ` Dhruva Gole
2025-09-12  6:03   ` Ilias Apalodimas
2025-09-05  8:18 ` [PATCH -next v6 05/10] arm: armv8: mmu: add mem_map_fix_dram_banks Anshul Dalal
2025-09-12  6:33   ` Ilias Apalodimas
2025-09-12  6:38     ` Anshul Dalal
2025-09-12  7:26       ` Ilias Apalodimas
2025-09-12  7:41         ` Anshul Dalal [this message]
2025-09-05  8:18 ` [PATCH -next v6 06/10] mach-k3: map all banks using mem_map_fix_dram_banks Anshul Dalal
2025-09-05  8:18 ` [PATCH -next v6 07/10] arm: armv8: mmu: add mmu_unmap_reserved_mem Anshul Dalal
2025-09-12  6:35   ` Ilias Apalodimas
2025-09-05  8:18 ` [PATCH -next v6 08/10] spl: split spl_board_fixups to arch/board specific Anshul Dalal
2025-09-05  8:19 ` [PATCH -next v6 09/10] mach-k3: add reserved memory fixups for next boot stage Anshul Dalal
2025-09-05  8:19 ` [PATCH -next v6 10/10] mach-k3: add carveouts for TFA and optee Anshul Dalal
2025-09-10 11:14   ` Bryan Brattlof
2025-09-10 12:05     ` Anshul Dalal
2025-09-08 14:20 ` [PATCH -next v6 0/9] Add support for dynamic MMU configuration Wadim Egorov

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=DCQNHVLA3G7W.13QL3Z9ZMVJDQ@ti.com \
    --to=anshuld@ti.com \
    --cc=a-nandan@ti.com \
    --cc=afd@ti.com \
    --cc=b-padhi@ti.com \
    --cc=bb@ti.com \
    --cc=d-gole@ti.com \
    --cc=devarsht@ti.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=ggiordano@phytec.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=m-chawdhry@ti.com \
    --cc=nm@ti.com \
    --cc=robertcnelson@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=u-kumar1@ti.com \
    --cc=vigneshr@ti.com \
    --cc=w.egorov@phytec.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.