Possible fix for trispd bug

main
Jeff Hartmann 2000-08-18 19:03:19 +00:00
parent 364d44a24c
commit e30361416b
2 changed files with 45 additions and 36 deletions

View File

@ -39,8 +39,8 @@
typedef struct { typedef struct {
u32 buffer_status; u32 buffer_status;
unsigned int num_dwords; int num_dwords;
unsigned int max_dwords; int max_dwords;
u32 *current_dma_ptr; u32 *current_dma_ptr;
u32 *head; u32 *head;
u32 phys_head; u32 phys_head;
@ -209,19 +209,27 @@ typedef struct {
#define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \ #define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \
int outcount, num_dwords int outcount, num_dwords
#define PRIM_OVERFLOW(dev, dev_priv, length) do { \ #define PRIM_OVERFLOW(dev, dev_priv, length) do { \
drm_mga_prim_buf_t *tmp_buf = \ drm_mga_prim_buf_t *tmp_buf = \
dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \ if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \
&tmp_buf->buffer_status)) { \ &tmp_buf->buffer_status)) { \
mga_advance_primary(dev); \ mga_advance_primary(dev); \
mga_dma_schedule(dev, 1); \ mga_dma_schedule(dev, 1); \
} else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length ||\ tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length || \
set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \ tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \
mga_advance_primary(dev); \ set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \
mga_dma_schedule(dev, 1); \ mga_advance_primary(dev); \
} \ mga_dma_schedule(dev, 1); \
tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
} \
if(MGA_VERBOSE) \
DRM_DEBUG("PRIMGETPTR in %s\n", __FUNCTION__); \
dma_ptr = tmp_buf->current_dma_ptr; \
num_dwords = tmp_buf->num_dwords; \
phys_head = tmp_buf->phys_head; \
outcount = 0; \
} while(0) } while(0)
#define PRIMGETPTR(dev_priv) do { \ #define PRIMGETPTR(dev_priv) do { \

View File

@ -34,6 +34,22 @@
#include "mga_drv.h" #include "mga_drv.h"
#include "drm.h" #include "drm.h"
/* If you change the functions to set state, PLEASE
* change these values
*/
#define MGAEMITCLIP_SIZE 10
#define MGAEMITCTX_SIZE 15
#define MGAG200EMITTEX_SIZE 20
#define MGAG400EMITTEX0_SIZE 30
#define MGAG400EMITTEX1_SIZE 25
#define MGAG400EMITPIPE_SIZE 50
#define MGAG200EMITPIPE_SIZE 15
#define MAX_STATE_SIZE ((MGAEMITCLIP_SIZE * MGA_NR_SAREA_CLIPRECTS) + \
MGAEMITCTX_SIZE + MGAG400EMITTEX0_SIZE + \
MGAG400EMITTEX1_SIZE + MGAG400EMITPIPE_SIZE)
static void mgaEmitClipRect(drm_mga_private_t * dev_priv, static void mgaEmitClipRect(drm_mga_private_t * dev_priv,
drm_clip_rect_t * box) drm_clip_rect_t * box)
{ {
@ -224,7 +240,6 @@ static void mgaG400EmitTex1(drm_mga_private_t * dev_priv)
PRIMADVANCE(dev_priv); PRIMADVANCE(dev_priv);
} }
#define EMIT_PIPE 50
static void mgaG400EmitPipe(drm_mga_private_t * dev_priv) static void mgaG400EmitPipe(drm_mga_private_t * dev_priv)
{ {
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
@ -492,7 +507,6 @@ static void mga_dma_dispatch_tex_blit(drm_device_t * dev,
y2 = length / 64; y2 = length / 64;
PRIM_OVERFLOW(dev, dev_priv, 30); PRIM_OVERFLOW(dev, dev_priv, 30);
PRIMGETPTR(dev_priv);
PRIMOUTREG(MGAREG_DSTORG, destOrg); PRIMOUTREG(MGAREG_DSTORG, destOrg);
PRIMOUTREG(MGAREG_MACCESS, 0x00000000); PRIMOUTREG(MGAREG_MACCESS, 0x00000000);
@ -526,7 +540,6 @@ static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf)
int length = buf->used; int length = buf->used;
int use_agp = PDEA_pagpxfer_enable; int use_agp = PDEA_pagpxfer_enable;
int i = 0; int i = 0;
int primary_needed;
PRIMLOCALS; PRIMLOCALS;
DRM_DEBUG("%s\n", __FUNCTION__); DRM_DEBUG("%s\n", __FUNCTION__);
@ -542,9 +555,8 @@ static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf)
* these numbers (Overestimating this doesn't hurt). * these numbers (Overestimating this doesn't hurt).
*/ */
buf_priv->dispatched = 1; buf_priv->dispatched = 1;
primary_needed = (50 + 15 + 15 + 30 + 25 + PRIM_OVERFLOW(dev, dev_priv,
10 + 15 * MGA_NR_SAREA_CLIPRECTS); (MAX_STATE_SIZE + (5 * MGA_NR_SAREA_CLIPRECTS)));
PRIM_OVERFLOW(dev, dev_priv, primary_needed);
mgaEmitState(dev_priv); mgaEmitState(dev_priv);
do { do {
if (i < sarea_priv->nbox) { if (i < sarea_priv->nbox) {
@ -592,7 +604,6 @@ static void mga_dma_dispatch_indices(drm_device_t * dev,
unsigned int address = (unsigned int) buf->bus_address; unsigned int address = (unsigned int) buf->bus_address;
int use_agp = PDEA_pagpxfer_enable; int use_agp = PDEA_pagpxfer_enable;
int i = 0; int i = 0;
int primary_needed;
PRIMLOCALS; PRIMLOCALS;
DRM_DEBUG("%s\n", __FUNCTION__); DRM_DEBUG("%s\n", __FUNCTION__);
@ -606,9 +617,8 @@ static void mga_dma_dispatch_indices(drm_device_t * dev,
* these numbers (Overestimating this doesn't hurt). * these numbers (Overestimating this doesn't hurt).
*/ */
buf_priv->dispatched = 1; buf_priv->dispatched = 1;
primary_needed = (50 + 15 + 15 + 30 + 25 + PRIM_OVERFLOW(dev, dev_priv,
10 + 15 * MGA_NR_SAREA_CLIPRECTS); (MAX_STATE_SIZE + (5 * MGA_NR_SAREA_CLIPRECTS)));
PRIM_OVERFLOW(dev, dev_priv, primary_needed);
mgaEmitState(dev_priv); mgaEmitState(dev_priv);
do { do {
@ -657,7 +667,6 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
drm_clip_rect_t *pbox = sarea_priv->boxes; drm_clip_rect_t *pbox = sarea_priv->boxes;
unsigned int cmd; unsigned int cmd;
int i; int i;
int primary_needed;
PRIMLOCALS; PRIMLOCALS;
DRM_DEBUG("%s\n", __FUNCTION__); DRM_DEBUG("%s\n", __FUNCTION__);
@ -666,11 +675,7 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
else else
cmd = MGA_CLEAR_CMD | DC_atype_rstr; cmd = MGA_CLEAR_CMD | DC_atype_rstr;
primary_needed = nbox * 70; PRIM_OVERFLOW(dev, dev_priv, 35 * MGA_NR_SAREA_CLIPRECTS);
if (primary_needed == 0)
primary_needed = 70;
PRIM_OVERFLOW(dev, dev_priv, primary_needed);
PRIMGETPTR(dev_priv);
for (i = 0; i < nbox; i++) { for (i = 0; i < nbox; i++) {
unsigned int height = pbox[i].y2 - pbox[i].y1; unsigned int height = pbox[i].y2 - pbox[i].y1;
@ -741,14 +746,10 @@ static void mga_dma_dispatch_swap(drm_device_t * dev)
int nbox = sarea_priv->nbox; int nbox = sarea_priv->nbox;
drm_clip_rect_t *pbox = sarea_priv->boxes; drm_clip_rect_t *pbox = sarea_priv->boxes;
int i; int i;
int primary_needed;
PRIMLOCALS; PRIMLOCALS;
DRM_DEBUG("%s\n", __FUNCTION__); DRM_DEBUG("%s\n", __FUNCTION__);
primary_needed = nbox * 5; PRIM_OVERFLOW(dev, dev_priv, (MGA_NR_SAREA_CLIPRECTS * 5) + 20);
primary_needed += 65;
PRIM_OVERFLOW(dev, dev_priv, primary_needed);
PRIMGETPTR(dev_priv);
PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0);