FS#9708 - PP5020 ATA (IDE) DMA
Opened by Boris Gjenero (dreamlayers) - Thursday, 25 December 2008, 01:09 GMT
Last edited by Torne Wuff (torne) - Tuesday, 23 March 2010, 20:50 GMT
I got Ultra DMA working on my 5th generation 30 gig iPod. Mode 2 (33.3 MB/s) seems stable, and it doesn't need CPU frequency boost. Mode 4 (66.7 MB/s) is the highest supported, but modes above 2 require CPU boosting.
The main benefit I can see from DMA is somewhat faster buffer filling. For example, with one large unfragmented FLAC file and the FS#9621 FAT read-ahead patch, the initial load is about twice as fast with DMA. Test_disk says 1 meg reads are 14102 KB/s and writes aren't sped up. I suspect the reported read speed is from the drive's cache, not the media. (BTW. Why are PIO reads slower than PIO writes in test_disk?)
The main cost of DMA is having to flush and invalidate the cache. I note that pp5020.h defines a CACHE_FLUSH_MASK, which makes me think it may be possible to only affect part of the cache. However, I don't know how to use that yet.
While implementing this I significantly altered firmware/drivers/ata.c. I merged the read and write functions into a transfer function which can do both reads and writes with both PIO and DMA. This removes some code duplication and IMHO enhances writes by using "write multiple" and doing retries if needed. I plan to make other changes to ata.c and add interrupt support. However, I feel the right thing to do is to redo the patch with minimum modifications to ata.c. The ata.c changes can become another, separate patch.
Due to interest shown on the developer mailing list, I am submitting this preliminary patch so I can get it out ASAP. I know it needs to be cleaned up, and it won't compile correctly for other targets, and things like detection of DMA modes need to be added. I'm sorry if this bothers you. I will release a cleaned up patch.
Note that messing with disk-related code can lead to filesystem corruption, losing all of your files, and having to restore your iPod. If you're concerned about this, you may want to at first disable writes at "//if (write)" in ata.c. I didn't have any problems, the test_disk write verify test passed, single sector transfers (like the FAT) are still done via PIO, and Ultra DMA CRC-checks DMA bursts.
Tuesday, 23 March 2010, 20:50 GMT
Reason for closing: Fixed
Additional comments about closing: submitted in r24405