From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Sun, 29 Jul 2012 12:25:30 +0200 Subject: [U-Boot] [U-Boot-DM] early_malloc() vs. enable_caches() In-Reply-To: <20120729114245.3cf41a0b@lilith> References: <20120729114245.3cf41a0b@lilith> Message-ID: <201207291225.30559.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Albert ARIBAUD, > Hi Tomas, > > On Sat, 28 Jul 2012 17:46:41 +0200, Tomas Hlavacek 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? I think this was somehow solved in here ... Tomas can elaborate further I believe. > > 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. Not so fast, on PXA there was time when we used caches as RAM in the early stage. We locked some cachelines and placed stack there (and therefore global data etc). > 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, Best regards, Marek Vasut