xserver/hw/kdrive/ati ati_dma.c, 1.3, 1.4 ati_dma.h, 1.2, 1.3 ati_dri.c, 1.7, 1.8

Eric Anholt xserver-commit at pdx.freedesktop.org
Sun Sep 12 12:52:53 PDT 2004


Committed by: anholt

Update of /cvs/xserver/xserver/hw/kdrive/ati
In directory gabe:/tmp/cvs-serv4605/hw/kdrive/ati

Modified Files:
	ati_dma.c ati_dma.h ati_dri.c 
Log Message:
Improve error handling, especially in the DRI case.  Do some FatalErrors
instead of ErrorFs for things that are really bad, and put limits on
some loops.  Now, sometimes instead of hanging the entire system, we
(mostly-) cleanly drop to console when the card has hung.


Index: ati_dma.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_dma.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ati_dma.c	10 Jun 2004 08:37:28 -0000	1.3
+++ ati_dma.c	12 Sep 2004 19:52:51 -0000	1.4
@@ -41,7 +41,6 @@
 extern CARD32 r200_cp_microcode[][2];
 extern CARD32 r300_cp_microcode[][2];
 
-#if DEBUG_FIFO
 static void
 ATIDebugFifo(ATIScreenInfo *atis)
 {
@@ -68,7 +67,6 @@
 		    MMIO_IN32(mmio, R128_REG_PC_NGUI_CTLSTAT));
 	}
 }
-#endif
 
 static void
 ATIUploadMicrocode(ATIScreenInfo *atis)
@@ -320,9 +318,15 @@
 		int ret;
 		int cmd = (atic->is_radeon ? DRM_RADEON_CP_IDLE :
 		    DRM_R128_CCE_IDLE);
-		do {
+		for (tries = 100; tries != 0; tries--) {
 			ret = drmCommandNone(atic->drmFd, cmd);
-		} while (ret == -EBUSY);
+			if (ret != -EBUSY)
+				break;
+		}
+		if (tries == 0) {
+			ATIDebugFifo(atis);
+			FatalError("Timed out idling CCE (card hung)\n");
+		}
 		if (ret != 0)
 			ErrorF("Failed to idle DMA, returned %d\n", ret);
 		return;

Index: ati_dma.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_dma.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ati_dma.h	11 Sep 2004 09:28:19 -0000	1.2
+++ ati_dma.h	12 Sep 2004 19:52:51 -0000	1.3
@@ -65,8 +65,8 @@
 } while (0)
 #define END_DMA() do {							\
 	if (__count != __total)						\
-		ErrorF("count != total (%d vs %d) at %s:%d\n", __count, \
-		    __total, __FILE__, __LINE__);			\
+		FatalError("count != total (%d vs %d) at %s:%d\n",	 \
+		     __count, __total, __FILE__, __LINE__);		\
 	atis->indirectBuffer->used += __count * 4;			\
 } while (0)
 

Index: ati_dri.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_dri.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ati_dri.c	17 May 2004 20:18:02 -0000	1.7
+++ ati_dri.c	12 Sep 2004 19:52:51 -0000	1.8
@@ -1048,7 +1048,7 @@
 	if (ret == 0)
 		atis->dma_started = TRUE;
 	else
-		ErrorF("%s: DMA start returned %d\n", __FUNCTION__, ret);
+		FatalError("%s: DMA start returned %d\n", __FUNCTION__, ret);
 }
 
 /* Attempts to idle the DMA engine and stops it.  Note that the ioctl is the
@@ -1105,7 +1105,7 @@
 	drmBufPtr buf = NULL;
 	int indx = 0;
 	int size = 0;
-	int ret;
+	int ret, tries;
 
 	dma.context = atis->serverContext;
 	dma.send_count = 0;
@@ -1113,7 +1113,7 @@
 	dma.send_sizes = NULL;
 	dma.flags = 0;
 	dma.request_count = 1;
-	if (atis->atic->is_radeon)
+	if (atic->is_radeon)
 		dma.request_size = RADEON_BUFFER_SIZE;
 	else
 		dma.request_size = R128_BUFFER_SIZE;
@@ -1121,9 +1121,15 @@
 	dma.request_sizes = &size;
 	dma.granted_count = 0;
 
-	do {
+	for (tries = 100; tries != 0; tries--) {
 		ret = drmDMA(atic->drmFd, &dma);
-	} while (ret != 0);
+		if (ret != -EBUSY)
+			break;
+	}
+	if (tries == 0)
+		FatalError("Timeout fetching DMA buffer (card hung)\n");
+	if (ret != 0)
+		FatalError("Error fetching DMA buffer: %d\n", ret);
 
 	buf = &atis->buffers->list[indx];
 	buf->used = 0;



More information about the xserver-commit mailing list