<html>
<body>
  <div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src</tt></b></td></tr>
<tr><td><tt><a href="#file1">asic.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+14</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-6</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">3a058c62e9e1 -> 50c63f63bf8f</td></tr>
</table>
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
Break large PVR dma transfers up into blocks to avoid potentially allocating
8MB+ on the stack. Patch from guinux, thanks!
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>asic.c</b></big> <small id="info" style="color: #888888;" >3a058c62e9e1 -> 50c63f63bf8f</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/asic.c
+++ lxdream/src/asic.c
@@ -337,17 +337,25 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
     sh4addr_t destaddr = MMIO_READ( ASIC, PVRDMADEST) &0x1FFFFFE0;
     uint32_t count = MMIO_READ( ASIC, PVRDMACNT );
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    unsigned char *data = alloca( count );
-    uint32_t rcount = DMAC_get_buffer( 2, data, count );
-    if( rcount != count )
-        WARN( "PVR received %08X bytes from DMA, expected %08X", rcount, count );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    unsigned char data[8192];
+    uint32_t rcount;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    pvr2_dma_write( destaddr, data, rcount );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    while( count ) {
+        uint32_t chunksize = (count < 8192) ? count : 8192;
+        rcount = DMAC_get_buffer( 2, data, chunksize );
+        pvr2_dma_write( destaddr, data, rcount );
+        destaddr += rcount;
+        count -= rcount;
+        if( rcount != chunksize ) {
+            WARN( "PVR received %08X bytes from DMA, expected %08X", rcount, chunksize );
+            break;
+        }
+    }
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
     MMIO_WRITE( ASIC, PVRDMACTL, 0 );
     MMIO_WRITE( ASIC, PVRDMACNT, 0 );
     if( destaddr & 0x01000000 ) { /* Write to texture RAM */
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        MMIO_WRITE( ASIC, PVRDMADEST, destaddr <span id="removedchars" style="background-color:#ff9999;font-weight:bolder;" >+ rcount </span>);
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        MMIO_WRITE( ASIC, PVRDMADEST, destaddr );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     }
     asic_event( EVENT_PVR_DMA );
 }
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>