Search
lxdream.org :: lxdream :: r1269:50c63f63bf8f
lxdream 0.9.1
released Jun 29
Download Now
changeset1269:50c63f63bf8f
parent1268:3a058c62e9e1
child1270:65fd19c07e2e
authornkeynes
dateMon Mar 12 18:06:24 2012 +1000 (7 years ago)
Break large PVR dma transfers up into blocks to avoid potentially allocating
8MB+ on the stack. Patch from guinux, thanks!
src/asic.c
1.1 --- a/src/asic.c Tue Mar 06 17:43:54 2012 +1000
1.2 +++ b/src/asic.c Mon Mar 12 18:06:24 2012 +1000
1.3 @@ -337,17 +337,25 @@
1.4 {
1.5 sh4addr_t destaddr = MMIO_READ( ASIC, PVRDMADEST) &0x1FFFFFE0;
1.6 uint32_t count = MMIO_READ( ASIC, PVRDMACNT );
1.7 - unsigned char *data = alloca( count );
1.8 - uint32_t rcount = DMAC_get_buffer( 2, data, count );
1.9 - if( rcount != count )
1.10 - WARN( "PVR received %08X bytes from DMA, expected %08X", rcount, count );
1.11 + unsigned char data[8192];
1.12 + uint32_t rcount;
1.13
1.14 - pvr2_dma_write( destaddr, data, rcount );
1.15 + while( count ) {
1.16 + uint32_t chunksize = (count < 8192) ? count : 8192;
1.17 + rcount = DMAC_get_buffer( 2, data, chunksize );
1.18 + pvr2_dma_write( destaddr, data, rcount );
1.19 + destaddr += rcount;
1.20 + count -= rcount;
1.21 + if( rcount != chunksize ) {
1.22 + WARN( "PVR received %08X bytes from DMA, expected %08X", rcount, chunksize );
1.23 + break;
1.24 + }
1.25 + }
1.26
1.27 MMIO_WRITE( ASIC, PVRDMACTL, 0 );
1.28 MMIO_WRITE( ASIC, PVRDMACNT, 0 );
1.29 if( destaddr & 0x01000000 ) { /* Write to texture RAM */
1.30 - MMIO_WRITE( ASIC, PVRDMADEST, destaddr + rcount );
1.31 + MMIO_WRITE( ASIC, PVRDMADEST, destaddr );
1.32 }
1.33 asic_event( EVENT_PVR_DMA );
1.34 }
.