Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Aligning the buffer for DMA

Re: Aligning the buffer for DMA

From: Michael Sevakis <jethead71_at_sbcglobal.net>
Date: Mon, 2 Mar 2009 17:12:02 -0500

> Hello,
>
> While working on the PP502x ATA DMA patch (
> http://www.rockbox.org/tracker/task/9708 ) I noticed that data in the
> buffer is not always properly aligned for DMA. The buffering.c code
> word-aligns the first frame, but the DMA code needs alignment of sector
> boundaries. For example, if the size of the ID3v2 tag in an MP3 file
> isn't divisible by 4, the whole file must be read via PIO.

I'm sort of surprised it isn't word aligned already. It could be a plus all
around anyway.

>
> Another issue is cache line alignment of the start and end of reads. If
> they're not aligned, the start and end must be read via PIO to prevent
> cache line interference. This would double the number of ATA commands
> needed.

As you know, we need the alignment to ensure the integrity of other data.
The gigabeat F has been getting away with not doing this (uses PIO and its
DMA controller, not DMA disk modes but same problem) but it really should be
corrected there as well. I can't say it hasn't caused problems either.

>
> It's easy to change buffer alignment. FS#9708 already has a separate
> patch which word-aligns the buffer for DMA. But is it okay to do this?
> Will it cause errors or slowdowns due to unaligned reads? I
> understand that even if it is a good idea it probably belongs in
> separate platform-independent patch.

If any platform starts using a new implementation from its inception, any
considerations for that platform should be implemented from the start. Also,
I haven't found it to be a big deal to shuffle things around if later things
need to be split or merged. It's still early and it would be in essence only
two targets at this point.

Mike
Received on 2009-03-02


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa