[PATCH] - trident cyberblade FIFO status check

Laurence Darby ldarby at sdf-eu.org
Sun May 15 03:54:06 PDT 2005


Hi,

I was getting the audio problems described here:
www.alsa-project.org/misc/vgakills.txt

It's caused by writing to a FIFO without checking if it's full or not, and 
if it is full, the PCI bus locks up for long enough to damage the audio 
stream to the sound card.  I've fixed it for the trident cyberblade chip.

I basically made guesses where the checks should go, as if they go before 
every single BLADE_OUT(), then X wont start. It works for me, but consider 
it a draft.  I called the new function BladeSync_unsafe(), because it's 
based on BladeSync() but doesn't check for timeouts or other stuff.

btw, There were recent posts about the CyberBladeXP4 not being 
accelerated, is it possible the problems are related?

Laurence



--- old/xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c	2004-07-30 21:30:55.000000000 +0100
+++ xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c	2005-05-14 23:47:27.000000000 +0100
@@ -41,6 +41,10 @@
 #include "xaalocal.h"
 
 static void BladeSync(ScrnInfoPtr pScrn);
+static void BladeSync_unsafe(ScrnInfoPtr pScrn);
+
+static int busy;
+
 #if 0
 static void BladeSetupForSolidLine(ScrnInfoPtr pScrn, int color,
 				int rop, unsigned int planemask);
@@ -270,6 +274,16 @@
     }
 }
 
+
+static void
+BladeSync_unsafe(ScrnInfoPtr pScrn)
+{
+       TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+       BLADEBUSY(busy);
+       while (busy != 0) { BLADEBUSY(busy); };
+}
+
+
 static void
 BladeSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, 
 				int xdir, int ydir, int rop,
@@ -292,6 +306,7 @@
 	pTrident->BltScanDirection |= 1<<5;
     }
 #endif
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2148, XAAGetCopyROP(rop));
 }
 
@@ -304,6 +319,7 @@
 
     if (pTrident->Clipping) clip = 1;
 
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2144, 0xE0000000 | 1<<19 | 1<<4 | 1<<2 | pTrident->BltScanDirection | clip);
 
     if (pTrident->BltScanDirection) {
@@ -470,6 +486,7 @@
     TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
 
     REPLICATE(color);
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2160, color);
     BLADE_OUT(0x2148, XAAGetCopyROP(rop));
     pTrident->BltScanDirection = 0;
@@ -487,6 +504,7 @@
 {
     TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
 
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2144, 0x20000000 | pTrident->BltScanDirection | 1<<19 | 1<<4 | 2<<2 | (pTrident->Clipping ? 1:0));
     BLADE_OUT(0x2108, y<<16 | x);
     BLADE_OUT(0x210C, ((y+h-1)&0xfff)<<16 | ((x+w-1)&0xfff));
@@ -538,6 +556,7 @@
     TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
 
     pTrident->BltScanDirection = 0;
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2148, XAAGetCopyROP(rop));
     if (bg == -1) {
 	pTrident->BltScanDirection |= 2<<19;
@@ -567,6 +586,7 @@
     TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
 
     if (skipleft) BladeSetClippingRectangle(pScrn,x+skipleft,y,(x+w-1),(y+h-1));
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2144, 0xE0000000 | pTrident->BltScanDirection | 1<<4 | (skipleft ? 1 : 0));
     BLADE_OUT(0x2108, (y&0xfff)<<16 | (x&0xfff));
     BLADE_OUT(0x210C, ((y+h-1)&0xfff)<<16 | ((x+w-1)&0xfff));
@@ -580,13 +600,14 @@
 {
     TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
 
-    BladeSync(pScrn);
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2148, XAAGetPatternROP(rop));
 
     if (bg == -1) {
     REPLICATE(fg);
     BLADE_OUT(0x216C, 0x80000000 | 1<<30);
     BLADE_OUT(0x216C, 0x80000000 | 1<<28 | 1<<30);
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2170, patternx);
     BLADE_OUT(0x2170, patterny);
     BLADE_OUT(0x2174, fg);
@@ -598,6 +619,7 @@
     REPLICATE(bg);
     BLADE_OUT(0x216C, 0x80000000);
     BLADE_OUT(0x216C, 0x80000000 | 1<<28);
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2170, patternx);
     BLADE_OUT(0x2170, patterny);
     BLADE_OUT(0x2174, fg);
@@ -623,6 +645,7 @@
     int clip = 0;
 
     if (pTrident->Clipping) clip = 1;
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2144, 0x20000000 | pTrident->BltScanDirection | 7<<12 | 1<<4 | 1<<19 | 2<<2 | clip);
     BLADE_OUT(0x2108, y<<16 | x);
     BLADE_OUT(0x210C, ((y+h-1)&0xfff)<<16 | ((x+w-1)&0xfff));
@@ -677,6 +700,7 @@
 ){
     TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
 
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2148, XAAGetCopyROP(rop));
     pTrident->BltScanDirection = 0;
 #if 0
@@ -696,6 +720,7 @@
     TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
 
     if (skipleft) BladeSetClippingRectangle(pScrn,x+skipleft,y,(x+w-1),(y+h-1));
+    BladeSync_unsafe(pScrn);
     BLADE_OUT(0x2144, 0xE0000000 | 1<<19 | 1<<4 | pTrident->BltScanDirection | (skipleft ? 1 : 0));
     BLADE_OUT(0x2108, y<<16 | (x&0xfff));
     BLADE_OUT(0x210C, ((y+h-1)&0xfff)<<16 | ((x+w-1)&0xfff));



More information about the xorg mailing list