public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] early_malloc() vs. enable_caches()
Date: Sun, 29 Jul 2012 11:42:45 +0200	[thread overview]
Message-ID: <20120729114245.3cf41a0b@lilith> (raw)
In-Reply-To: <CAEB7QLBG_HYmgHDKYu=1J-WWQoCRSf_0QOjuq3nuv3bBxo_gbg@mail.gmail.com>

Hi Tomas,

On Sat, 28 Jul 2012 17:46:41 +0200, Tomas Hlavacek <tmshlvck@gmail.com> wrote:
> Hello!
> 
> I am working on early_malloc() for U-Boot Driver Model (this malloc is
> going to serve for internal DM structures during early init and it has it's
> minimalistic heap in global data).
> 
> My question is how to correctly switch from early allocator to full-scale
> malloc and when to enable caches.
> 
> The current state (on ARM) is:
> 1) gd = id;
> 3) enable_caches();
> 3) mem_malloc_init();
> 
> Proposed sequence for mallocator (in order no to loose any data from old
> and not-relocated part of GD):
> 
> 1) gd_old = gd;
> 2) gd = id;
> 3) mem_malloc_init();
> 4) relocation of DM structures
> 5) early_malloc_disab()
> 6) enable_caches();

I suspect the sequence here is atomic because there is only one thread of
execution and no interrupt able to run, but still: would you not rather
disable early malloc *before* relocating DM structures?

> Does it make sense? It actually boils down to one fundamental question:
> When I have not-rellocated data locked in cache-lines, do I loose them once
> enable_caches() is called?

Based on the (possibly wrong) assumption that in the case you describe, caches
are being enabled for the first time, then there is no such thing as "locked
cache lines" because the caches were disabled so far.

If you are enabling the caches for the first time there, then all lines are
(or should be, more exactly) empty and unlocked.

> Thanks,
> Tomas

Amicalement,
-- 
Albert.

  reply	other threads:[~2012-07-29  9:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-28 15:46 [U-Boot] early_malloc() vs. enable_caches() Tomas Hlavacek
2012-07-29  9:42 ` Albert ARIBAUD [this message]
2012-07-29 10:25   ` [U-Boot] [U-Boot-DM] " Marek Vasut
2012-07-29 10:53 ` Graeme Russ
2012-07-29 12:15   ` Marek Vasut
2012-07-29 13:19   ` Tomas Hlavacek
2012-07-29 22:34     ` Graeme Russ

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=20120729114245.3cf41a0b@lilith \
    --to=albert.u.boot@aribaud.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox