gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Enabling data caching on gba slot does sweet nothing

#135294 - simonjhall - Sat Jul 21, 2007 11:41 pm

Hi guys,

I've been trying to improve performance by enabling data caching for slot-2 RAM...but I've been having no luck.

After looking through ds/ds_arm9_crt0.s I can see that the gba slot is set up as protection region three with this:
Code:
   @-------------------------------------------------------------------------
   @ Region 3 - DS Accessory (GBA Cart)
   @-------------------------------------------------------------------------
   ldr   r0,=( PAGE_128M | 0x08000000 | 1)   
   mcr   p15, 0, r0, c6, c3, 0

After looking again at that file, gbatek and the ARM reference manual I ought to be able to turn on data caching for that region with just
Code:
ldr   r0,=0b00001110
mcr   p15, 0, r0, c3, c0, 0
but this does nothing for performance. In fact I think it may actually make it very slightly worse...

In sure I'm limited by the performance of that memory, as the game has taken a turn for the worse since moving wholly to slot-2 memory. Plus, if I just decrease the memory wait states performance increases by 25%.

Any hints as to what I'm doing wrong?

[Clarified subject. FA means "fantastic attack", or an attempt to make all steps with perfect timing, in the In The Groove community. -- MOD]
_________________
Big thanks to everyone who donated for Quake2

#135298 - Lick - Sat Jul 21, 2007 11:58 pm

I wouldn't recommend decreasing the wait states. EZ's fail when you do that and access RAM -> FAT -> RAM -> etc.

I really hate myself for deleting the code I had. It was working, and the performance equaled cached main ram!
_________________
http://licklick.wordpress.com

#135350 - simonjhall - Sun Jul 22, 2007 5:44 pm

Yeah, what was the failing EZ thing you were talking about before? Decreasing the wait states on my EZ 3-in-1 seems to work fine (although my SC won't handle any changes at all).
Also since the 3-in-1 has no FAT support for the slot-2 part of the solution, I should never have to lock/unlock except when I start the game.
But obviously just cos it works on my card, doesn't mean it'll function on anyone else's! I'm wondering about exposing the controls to adjust the wait states (as it really does boost performance) but I don't want angry mails from people telling me their card is fuxored.

So, does anyone actually know about enabling caching? I think it'll make the world of difference to performance!
_________________
Big thanks to everyone who donated for Quake2

#135353 - Lick - Sun Jul 22, 2007 6:09 pm

I have an EZ Lite 4 Deluxe and lowered waitstates crash it.
Maybe you could talk to WinterMute..?
_________________
http://licklick.wordpress.com

#135360 - wintermute - Sun Jul 22, 2007 7:07 pm

simonjhall wrote:


After looking through ds/ds_arm9_crt0.s I can see that the gba slot is set up as protection region three with this:
Code:
   @-------------------------------------------------------------------------
   @ Region 3 - DS Accessory (GBA Cart)
   @-------------------------------------------------------------------------
   ldr   r0,=( PAGE_128M | 0x08000000 | 1)   
   mcr   p15, 0, r0, c6, c3, 0

After looking again at that file, gbatek and the ARM reference manual I ought to be able to turn on data caching for that region with just
Code:
ldr   r0,=0b00001110
mcr   p15, 0, r0, c3, c0, 0
but this does nothing for performance. In fact I think it may actually make it very slightly worse...



That's the write buffer, not the cache. Not entirely sure how you missed the cache setting if you were reading the arm9 crt0 source :P

Code:

   @-------------------------------------------------------------------------
   @ DCache & ICache enable
   @-------------------------------------------------------------------------
   ldr   r0,=0b01000010
   mcr   p15, 0, r0, c2, c0, 0
   mcr   p15, 0, r0, c2, c0, 1


the last opcode sets the cache type - 0 for data, 1 for instruction. Set bit 3 to enable caching for region 3.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#135362 - simonjhall - Sun Jul 22, 2007 7:41 pm

Oops forgot to mention that I'd tried that too! For some reason I posted the write buffer stuff instead...
Code:
__asm__ __volatile__ (
      "ldr   r0,=0b01001010\n"
      "mcr   p15, 0, r0, c2, c0, 0\n");
...was the magic code I used.
Also, does using the write buffer improve improve performance? Again, doesn't seem to do a lot for me.

Maybe my data's too random to cache well...
_________________
Big thanks to everyone who donated for Quake2