DMA Priority Against the CPU and Between Channels: Difference between revisions
| Revision as of 04:48, 23 October 2026 RemmyLee (Main page: drop the Hardware Tests lede) | Revision as of 05:11, 23 October 2026 RemmyLee (Hardware tests: 72 more test pages, listed on the main page by area; RUN.toml no longer published) | ||
| Line 1: | Line 1: | ||
| + | --- | ||
| + | title: DMA Priority Against the CPU and Between Channels | ||
| + | type: test | ||
| + | summary: Measures whether the DPCR priority fields change how the CPU and two DMA channels share the bus. | ||
| + | category: Hardware tests | ||
| + | info: Machine = SCPH-5501 | ||
| + | info: Program = dma-priority (pcsx-redux nugget) | ||
| + | --- | ||
| + | |||
| + | ## Overview | ||
| + | |||
| + | The program tests the priority fields of DPCR on the [DMA controller](/hardware/dma/). Part 1 starts a transfer, then reads root counter 2 and runs a work loop: uncached RAM loads, scratchpad loads or a cached ALU loop. The transfer is DMA6 (an OT clear of 4096 words, as a burst or chopped) or DMA2 (a VRAM read of 1024 words in sync mode 1). All times are in system clock cycles. "stall" is the time to the first counter read, "loop" the time of the work loop and "done" the time to the end of the transfer. DPCR bits 28 to 30 (the CPU) and the channel's priority field are varied.[^src] | ||
| + | |||
| + | Part 2 programs DMA2 and DMA6 with their master enables clear and starts both with one DPCR write. DMA2 reads a filled VRAM rectangle into a RAM buffer in ascending order, and DMA6 writes the OT clear pattern into the same buffer in descending order. The last writer of each word shows the order. Part 3 starts DMA6 and reads the counter after 0 to 12 NOPs. It takes eight samples of each, and the first sample runs from a cold instruction cache. Rows of parts 1 and 2 run twice and are marked UNSTABLE when the two runs differ.[^src] | ||
| + | |||
| + | ## Results | ||
| + | |||
| + | ### CPU Against a Transfer | ||
| + | |||
| + | The CPU priority field changed nothing. Each row gave the same stall, loop and done times for CPU priority 0 against channel priority 7, 7 against 0, and 3 against 3.[^out] | ||
| + | |||
| + | Table: Part 1 with CPU priority 0 and channel priority 7 | ||
| + | |||
| + | | Transfer | Work loop | Stall | Loop (alone) | Done | | ||
| + | | --- | --- | --- | --- | --- | | ||
| + | | DMA6 burst | uncached RAM loads | 17 | 1819 (1821) | 6242 | | ||
| + | | DMA6 burst | cached ALU loop | 17 | 1803 (1803) | 6223 | | ||
| + | | DMA6 burst | scratchpad loads | 17 | 260 (260) | 4682 | | ||
| + | | DMA6 chopped | uncached RAM loads | 17 | 1820 (1819) | 6243 | | ||
| + | | DMA2 sync mode 1 | uncached RAM loads | 17 | 3120 (1821) | 3254 | | ||
| + | |||
| + | ### Start of a Burst | ||
| + | |||
| + | A counter read 0 to 3 NOPs after the CHCR store that starts DMA6 returned after 6 to 8 cycles, and the RAM loads that followed then waited about 6170 cycles. From 4 NOPs on, the counter read itself waited about 4360 cycles. In each row the first sample differed from the other seven.[^out] | ||
| + | |||
| + | ### DMA2 Against DMA6 | ||
| + | |||
| + | Table: Last writer of the 1024 shared words | ||
| + | |||
| + | | DMA2 priority | DMA6 priority | Words last written by DMA6 | Words last written by DMA2 | | ||
| + | | --- | --- | --- | --- | | ||
| + | | 3 | 7 | 112 (words 0 to 111) | 912 | | ||
| + | | 0 | 7 | 112 (words 0 to 111) | 912 | | ||
| + | | 7 | 0 | 0 | 1024 | | ||
| + | | 3 | 3 | 0 | 1024 | | ||
| + | | 0 | 0 | 0 | 1024 | | ||
| + | |||
| + | With DMA2 at the higher priority, DMA2 started first, DMA6 cut in and ran to the end, and DMA2 then finished. The OT clear pattern was left in the low 112 words. With DMA6 at the higher priority or at equal priority, DMA6 finished before DMA2 wrote its words. With both master enables clear nothing moved.[^out][^notes] | ||
| + | |||
| + | ## Runs | ||
| + | |||
| + | ### 22 October 2026 link | ||
| + | |||
| + | Raw output: [DMAPRIORITY.txt](/tests/raw/20261022T2244Z-5501a-link/dmapriority/DMAPRIORITY.txt) · [bench.txt](/tests/raw/20261022T2244Z-5501a-link/dmapriority/bench.txt) | ||
| + | |||
| + | DMAPRIORITY.txt: | ||
| + | |||
| + | ``` | ||
| + | DMAPRIO-START dpcr=33333333 | ||
| + | CPU burst6 cpuHi cpu=0 dma=7 dpcr=0f654321 alone=1821 stall=17 loop=1819 done=6242 UNSTABLE | ||
| + | CPU burst6 dmaHi cpu=7 dma=0 dpcr=78654321 alone=1820 stall=17 loop=1819 done=6243 UNSTABLE | ||
| + | CPU burst6 tie3 cpu=3 dma=3 dpcr=3b654321 alone=1820 stall=17 loop=1819 done=6243 UNSTABLE | ||
| + | CPU burst6-alu cpuHi cpu=0 dma=7 dpcr=0f654321 alone=1803 stall=17 loop=1803 done=6223 | ||
| + | CPU burst6-alu dmaHi cpu=7 dma=0 dpcr=78654321 alone=1803 stall=17 loop=1803 done=6223 | ||
| + | CPU burst6-alu tie3 cpu=3 dma=3 dpcr=3b654321 alone=1803 stall=17 loop=1803 done=6223 | ||
| + | CPU burst6-spad cpuHi cpu=0 dma=7 dpcr=0f654321 alone=260 stall=17 loop=260 done=4682 | ||
| + | CPU burst6-spad dmaHi cpu=7 dma=0 dpcr=78654321 alone=260 stall=17 loop=260 done=4682 | ||
| + | CPU burst6-spad tie3 cpu=3 dma=3 dpcr=3b654321 alone=260 stall=17 loop=260 done=4682 | ||
| + | CPU chop6 cpuHi cpu=0 dma=7 dpcr=0f654321 alone=1819 stall=17 loop=1820 done=6243 UNSTABLE | ||
| + | CPU chop6 dmaHi cpu=7 dma=0 dpcr=78654321 alone=1821 stall=17 loop=1819 done=6243 | ||
| + | CPU chop6 tie3 cpu=3 dma=3 dpcr=3b654321 alone=1821 stall=17 loop=1820 done=6240 | ||
| + | CPU sync1-2 cpuHi cpu=0 dma=7 dpcr=07654f21 alone=1821 stall=17 loop=3120 done=3254 UNSTABLE | ||
| + | CPU sync1-2 dmaHi cpu=7 dma=0 dpcr=77654821 alone=1820 stall=17 loop=3116 done=3250 UNSTABLE | ||
| + | CPU sync1-2 tie3 cpu=3 dma=3 dpcr=37654b21 alone=1821 stall=17 loop=3123 done=3257 UNSTABLE | ||
| + | RACE nops=0 cpu=0 dma6=7 6/6713/6805 6/6180/6235 6/6170/6225 6/6175/6230 6/6174/6229 6/6170/6225 6/6172/6227 6/6170/6228 | ||
| + | RACE nops=1 cpu=0 dma6=7 13/6704/6845 6/6288/6410 6/6304/6421 6/6295/6416 6/6303/6420 6/6304/6421 6/6295/6418 6/6304/6421 | ||
| + | RACE nops=2 cpu=0 dma6=7 4359/2339/6780 7/6175/6231 7/6174/6230 7/6173/6229 7/6169/6225 7/6174/6230 7/6173/6229 7/6169/6225 | ||
| + | RACE nops=3 cpu=0 dma6=7 4359/2364/6799 8/6175/6232 8/6165/6222 8/6179/6236 8/6175/6232 8/6170/6227 8/6172/6229 8/6168/6225 | ||
| + | RACE nops=4 cpu=0 dma6=7 4371/2353/6835 4360/1872/6323 4356/1866/6313 4360/1869/6320 4360/1869/6320 4360/1869/6320 4360/1869/6320 4360/1869/6320 | ||
| + | RACE nops=6 cpu=0 dma6=7 4372/2356/6833 4360/1902/6332 4356/1899/6329 4360/1908/6338 4360/1901/6331 4360/1896/6326 4355/1902/6337 4360/1901/6331 | ||
| + | RACE nops=8 cpu=0 dma6=7 4368/2349/6793 4360/1820/6229 4360/1823/6232 4360/1820/6229 4360/1820/6229 4360/1823/6232 4360/1820/6229 4355/1820/6224 | ||
| + | RACE nops=12 cpu=0 dma6=7 4388/2345/6824 4355/1820/6224 4345/1823/6217 4360/1823/6232 4360/1821/6230 4356/1824/6229 4360/1823/6232 4355/1823/6227 | ||
| + | RACE nops=0 cpu=7 dma6=0 6/6712/6794 6/6170/6225 6/6175/6230 6/6174/6229 6/6170/6225 6/6175/6230 6/6174/6229 6/6170/6225 | ||
| + | RACE nops=1 cpu=7 dma6=0 13/6699/6836 6/6294/6416 6/6302/6419 6/6309/6426 6/6301/6422 6/6305/6422 6/6302/6419 6/6299/6416 | ||
| + | RACE nops=2 cpu=7 dma6=0 4364/2340/6786 7/6166/6222 7/6169/6225 7/6174/6230 7/6173/6229 7/6169/6225 7/6171/6227 7/6169/6228 | ||
| + | RACE nops=3 cpu=7 dma6=0 4364/2348/6788 8/6179/6236 8/6168/6225 8/6170/6227 8/6175/6232 8/6172/6229 8/6172/6229 8/6175/6232 | ||
| + | RACE nops=4 cpu=7 dma6=0 4371/2345/6827 4360/1870/6321 4360/1869/6320 4360/1869/6320 4360/1869/6320 4360/1869/6320 4360/1869/6320 4360/1869/6320 | ||
| + | RACE nops=6 cpu=7 dma6=0 4372/2339/6816 4360/1901/6331 4360/1896/6326 4360/1912/6342 4345/1900/6315 4355/1901/6326 4360/1903/6333 4360/1904/6334 | ||
| + | RACE nops=8 cpu=7 dma6=0 4368/2346/6790 4360/1819/6228 4360/1827/6236 4360/1823/6232 4355/1823/6227 4356/1824/6229 4360/1823/6232 4360/1823/6232 | ||
| + | RACE nops=12 cpu=7 dma6=0 4388/2344/6822 4355/1820/6224 4360/1820/6229 4360/1823/6232 4360/1820/6229 4355/1820/6224 4360/1823/6232 4360/1820/6229 | ||
| + | DMA alone2 dma2=3 dma6=7 held2=1 held6=-1 touchedWhileHeld=0 done2=1 done6=-1 otc=0 gpu=1024 poison=0 other=0 changes=0 firstGpu=0 firstOtc=-1 | ||
| + | DMA alone6 dma2=3 dma6=7 held2=-1 held6=1 touchedWhileHeld=0 done2=-1 done6=1 otc=1024 gpu=0 poison=0 other=0 changes=0 firstGpu=-1 firstOtc=0 | ||
| + | DMA default dma2=3 dma6=7 held2=1 held6=1 touchedWhileHeld=0 done2=1 done6=1 otc=112 gpu=912 poison=0 other=0 changes=1 firstGpu=112 firstOtc=0 UNSTABLE | ||
| + | DMA dma2hi dma2=0 dma6=7 held2=1 held6=1 touchedWhileHeld=0 done2=1 done6=1 otc=112 gpu=912 poison=0 other=0 changes=1 firstGpu=112 firstOtc=0 | ||
| + | DMA dma6hi dma2=7 dma6=0 held2=1 held6=1 touchedWhileHeld=0 done2=1 done6=1 otc=0 gpu=1024 poison=0 other=0 changes=0 firstGpu=0 firstOtc=-1 | ||
| + | DMA tie3 dma2=3 dma6=3 held2=1 held6=1 touchedWhileHeld=0 done2=1 done6=1 otc=0 gpu=1024 poison=0 other=0 changes=0 firstGpu=0 firstOtc=-1 | ||
| + | DMA tie0 dma2=0 dma6=0 held2=1 held6=1 touchedWhileHeld=0 done2=1 done6=1 otc=0 gpu=1024 poison=0 other=0 changes=0 firstGpu=0 firstOtc=-1 | ||
| + | DMA alone2 dma2=3 dma6=7 held2=1 held6=-1 touchedWhileHeld=0 done2=1 done6=-1 otc=0 gpu=1024 poison=0 other=0 changes=0 firstGpu=0 firstOtc=-1 | ||
| + | DMAPRIO-DONE | ||
| + | ResetGraph:jtb=801e78b8,env=801e7900 | ||
| + | ``` | ||
| + | |||
| + | bench.txt: | ||
| + | |||
| + | ``` | ||
| + | 4791 bytes of TTY text in psx.log | ||
| + | ``` | ||
| + | |||
| + | ## References | ||
| + | |||
| + | [^src]: pcsx-redux nugget, tests/dma-priority/dma-priority.c, header comment. MIT License. https://github.com/pcsx-redux/nugget | ||
| + | [^out]: Hardware test run 20261022T2244Z-5501a-link: [dmapriority/DMAPRIORITY.txt](/tests/raw/20261022T2244Z-5501a-link/dmapriority/DMAPRIORITY.txt). | ||
| + | [^notes]: pcsx-redux nugget, tests/dma-priority/RESULTS.md, "DMA2 against DMA6". https://github.com/pcsx-redux/nugget | ||
| + | |||