From fdd699c7b764e5ec40e252651ea649222045f58f Mon Sep 17 00:00:00 2001 From: Rudolf Cornelissen Date: Tue, 1 Feb 2005 15:05:57 +0000 Subject: [PATCH] fixed DMA acc blit function crashing once you place data near the end of the cardRAM on NV40 and higher (for overlay bitmaps). These cards needs a certain unused space in front of their DMA command buffer to prevent the blit's DMA data source instance from malfunctioning (moved windows then contain rubbish instead of valid data). I would say this is a hardware fault or limitation (costs us 400kB+ of RAM). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11182 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/accelerants/nvidia/Overlay.c | 44 ++++++++++++++++--- .../accelerants/nvidia/ProposeDisplayMode.c | 26 +++++++++-- .../accelerants/nvidia/SetDisplayMode.c | 23 ++++++++-- .../accelerants/nvidia/engine/nv_general.c | 2 +- 4 files changed, 83 insertions(+), 12 deletions(-) diff --git a/src/add-ons/accelerants/nvidia/Overlay.c b/src/add-ons/accelerants/nvidia/Overlay.c index fa537da948..094ef3738b 100644 --- a/src/add-ons/accelerants/nvidia/Overlay.c +++ b/src/add-ons/accelerants/nvidia/Overlay.c @@ -1,4 +1,4 @@ -/* Written by Rudolf Cornelissen 05/2002-1/2005 */ +/* Written by Rudolf Cornelissen 05/2002-2/2005 */ /* Note on 'missing features' in BeOS 5.0.3 and DANO: * BeOS needs to define more colorspaces! It would be nice if BeOS would support the FourCC 'definitions' @@ -207,8 +207,25 @@ const overlay_buffer *ALLOCATE_OVERLAY_BUFFER(color_space cs, uint16 width, uint adress = (((uint32)((uint8*)si->framebuffer)) + si->ps.memory_size); /* don't touch the DMA acceleration engine command buffer if it exists */ /* note: - * the buffer is 32kB in size. Keep a distance of another 32kB for safety. */ - if (si->settings.dma_acc) adress -= (64 * 1024); + * the buffer is 32kB in size. Keep some extra distance for safety (faulty apps). */ + if (si->settings.dma_acc) + { + if (si->ps.card_arch < NV40A) + { + /* keeping 32kB distance from the DMA buffer */ + adress -= (64 * 1024); + } + else + { + /* 416kB distance is just OK: keeping another 64kB distance for safety; + * confirmed for NV43. */ + /* note: + * if you get too close to the DMA command buffer on NV40 and NV43 at + * least (both confirmed), the source DMA instance will mess-up for + * at least engine cmd NV_IMAGE_BLIT and NV12_IMAGE_BLIT. */ + adress -= (512 * 1024); + } + } for (cnt = 0; cnt <= offset; cnt++) { @@ -296,8 +313,25 @@ const overlay_buffer *ALLOCATE_OVERLAY_BUFFER(color_space cs, uint16 width, uint adress = (((uint32)((uint8*)si->framebuffer_pci)) + si->ps.memory_size); /* don't touch the DMA acceleration engine command buffer if it exists */ /* note: - * the buffer is 32kB in size. Keep a distance of another 32kB for safety. */ - if (si->settings.dma_acc) adress -= (64 * 1024); + * the buffer is 32kB in size. Keep some extra distance for safety (faulty apps). */ + if (si->settings.dma_acc) + { + if (si->ps.card_arch < NV40A) + { + /* keeping 32kB distance from the DMA buffer */ + adress -= (64 * 1024); + } + else + { + /* 416kB distance is just OK: keeping another 64kB distance for safety; + * confirmed for NV43. */ + /* note: + * if you get too close to the DMA command buffer on NV40 and NV43 at + * least (both confirmed), the source DMA instance will mess-up for + * at least engine cmd NV_IMAGE_BLIT and NV12_IMAGE_BLIT. */ + adress -= (512 * 1024); + } + } for (cnt = 0; cnt <= offset; cnt++) { diff --git a/src/add-ons/accelerants/nvidia/ProposeDisplayMode.c b/src/add-ons/accelerants/nvidia/ProposeDisplayMode.c index b24c1ae434..7129155364 100644 --- a/src/add-ons/accelerants/nvidia/ProposeDisplayMode.c +++ b/src/add-ons/accelerants/nvidia/ProposeDisplayMode.c @@ -4,7 +4,7 @@ Other authors for NV driver: Mark Watson, - Rudolf Cornelissen 9/2002-1/2005 + Rudolf Cornelissen 9/2002-2/2005 */ #define MODULE_BIT 0x00400000 @@ -384,8 +384,28 @@ status_t PROPOSE_DISPLAY_MODE(display_mode *target, const display_mode *low, con mem_reservation = 0; /* checkout space needed for hardcursor (if any) */ if (si->settings.hardcursor) mem_reservation = 2048; - /* checkout space needed for DMA (if active) */ - if (si->settings.dma_acc) mem_reservation += 65536; + /* reserve space for DMA acceleration engine command buffer (if active) */ + /* note: + * the buffer is 32kB in size. Keep some extra distance for safety (faulty apps). */ + if (si->settings.dma_acc) + { + if (si->ps.card_arch < NV40A) + { + /* keeping 32kB distance from the DMA buffer */ + mem_reservation += (64 * 1024); + } + else + { + /* 416kB distance is just OK: keeping another 64kB distance for safety; + * confirmed for NV43. */ + /* note: + * if you get too close to the DMA command buffer on NV40 and NV43 at + * least (both confirmed), the source DMA instance will mess-up for + * at least engine cmd NV_IMAGE_BLIT and NV12_IMAGE_BLIT. */ + mem_reservation += (512 * 1024); + } + } + /* memory requirement for frame buffer */ if ((row_bytes * target->virtual_height) > (si->ps.memory_size - mem_reservation)) diff --git a/src/add-ons/accelerants/nvidia/SetDisplayMode.c b/src/add-ons/accelerants/nvidia/SetDisplayMode.c index 56a40d9caf..3cfec81975 100644 --- a/src/add-ons/accelerants/nvidia/SetDisplayMode.c +++ b/src/add-ons/accelerants/nvidia/SetDisplayMode.c @@ -6,7 +6,7 @@ Other authors: Mark Watson, Apsed, - Rudolf Cornelissen 11/2002-1/2005 + Rudolf Cornelissen 11/2002-2/2005 */ #define MODULE_BIT 0x00200000 @@ -332,8 +332,25 @@ status_t SET_DISPLAY_MODE(display_mode *mode_to_set) si->mem_high = si->ps.memory_size - 1; /* don't touch the DMA acceleration engine command buffer if it exists */ /* note: - * the buffer is 32kB in size. Keep a distance of another 32kB for safety. */ - if (si->settings.dma_acc) si->mem_high -= (64 * 1024); + * the buffer is 32kB in size. Keep some extra distance for safety (faulty apps). */ + if (si->settings.dma_acc) + { + if (si->ps.card_arch < NV40A) + { + /* keeping 32kB distance from the DMA buffer */ + si->mem_high -= (64 * 1024); + } + else + { + /* 416kB distance is just OK: keeping another 64kB distance for safety; + * confirmed for NV43. */ + /* note: + * if you get too close to the DMA command buffer on NV40 and NV43 at + * least (both confirmed), the source DMA instance will mess-up for + * at least engine cmd NV_IMAGE_BLIT and NV12_IMAGE_BLIT. */ + si->mem_high -= (512 * 1024); + } + } si->mem_high -= (MAXBUFFERS * 1024 * 1024 * 2); /* see overlay.c file */ LOG(1,("SETMODE: booted since %f mS\n", system_time()/1000.0)); diff --git a/src/add-ons/accelerants/nvidia/engine/nv_general.c b/src/add-ons/accelerants/nvidia/engine/nv_general.c index 65316da172..b0d6e5f5cc 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_general.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_general.c @@ -90,7 +90,7 @@ status_t nv_general_powerup() { status_t status; - LOG(1,("POWERUP: Haiku nVidia Accelerant 0.33 running.\n")); + LOG(1,("POWERUP: Haiku nVidia Accelerant 0.34 running.\n")); /* preset no laptop */ si->ps.laptop = false;