please find attached a complete patch that allows pci Radeon cards to
work with DRI. It was created against the DRI CVS xc branch/trunk.

Thanks to MrCooper and M.Harris for their help.

Note: also contains the pcigart patch many often refer too.
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c,v
retrieving revision 1.43
diff -u -r1.43 radeon_dri.c
--- programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c        25 Jan 2003 22:25:43 
-0000      1.43
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c        3 Feb 2003 14:22:24 
+-0000
@@ -56,12 +56,6 @@
 #include "sarea.h"
 #include "radeon_sarea.h"
 
-#if defined(__alpha__) || defined(__powerpc__)
-# define PCIGART_ENABLED
-#else
-# undef PCIGART_ENABLED
-#endif
-
 /* HACK - for now, put this here... */
 /* Alpha - this may need to be a variable to handle UP1x00 vs TITAN */
 #if defined(__alpha__)
@@ -883,7 +877,6 @@
     return TRUE;
 }
 
-#if defined(PCIGART_ENABLED)
 /* Initialize the PCIGART state.  Request memory for use in PCI space,
  * and initialize the Radeon registers to point to that memory.
  */
@@ -987,7 +980,6 @@
 
     return TRUE;
 }
-#endif
 
 /* Add a map for the MMIO registers that will be accessed by any
  * DRI-based clients.
@@ -1092,15 +1084,11 @@
 {
                                /* Initialize vertex buffers */
     if (info->IsPCI) {
-#if !defined(PCIGART_ENABLED)
-       return TRUE;
-#else
        info->bufNumBufs = drmAddBufs(info->drmFD,
                                      info->bufMapSize / RADEON_BUFFER_SIZE,
                                      RADEON_BUFFER_SIZE,
                                      DRM_SG_BUFFER,
                                      info->bufStart);
-#endif
     } else {
        info->bufNumBufs = drmAddBufs(info->drmFD,
                                      info->bufMapSize / RADEON_BUFFER_SIZE,
@@ -1415,30 +1403,21 @@
        drmFreeVersion(version);
     }
 
-#if !defined(PCIGART_ENABLED)
-                               /* Initialize AGP */
-    if (!info->IsPCI && !RADEONDRIAgpInit(info, pScreen)) {
-       RADEONDRICloseScreen(pScreen);
-       return FALSE;
-    }
-
-                               /* Initialize PCI */
-    if (info->IsPCI) {
-       xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] PCI cards not yet "
-                  "supported.  Disabling DRI.\n");
-       RADEONDRICloseScreen(pScreen);
-       return FALSE;
-    }
-#else
                                /* Initialize AGP */
     if (!info->IsPCI && !RADEONDRIAgpInit(info, pScreen)) {
+#if defined(__alpha__) || defined(__powerpc__)
        info->IsPCI = TRUE;
        xf86DrvMsg(pScreen->myNum, X_WARNING,
                   "[agp] AGP failed to initialize "
                   "-- falling back to PCI mode.\n");
        xf86DrvMsg(pScreen->myNum, X_WARNING,
-                  "[agp] Make sure you have the agpgart kernel module "
-                  "loaded.\n");
+                  "[agp] If this is an AGP card, you may want to make sure "
+                  "the agpgart\nkernel module is loaded before the radeon "
+                  "kernel module.\n");
+#else
+       RADEONDRICloseScreen(pScreen);
+       return FALSE;
+#endif
     }
 
                                /* Initialize PCI */
@@ -1446,7 +1425,6 @@
        RADEONDRICloseScreen(pScreen);
        return FALSE;
     }
-#endif
 
                                /* DRIScreenInit doesn't add all the
                                 * common mappings.  Add additional
Index: programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c,v
retrieving revision 1.17
diff -u -r1.17 radeon_cp.c
--- programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c        16 Jan 
2003 06:20:44 -0000      1.17
+++ programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c        3 Feb 
+2003 14:22:29 -0000
@@ -36,11 +36,6 @@
 
 #define RADEON_FIFO_DEBUG      0
 
-#if defined(__alpha__) || defined(__powerpc__)
-# define PCIGART_ENABLED
-#else
-# undef PCIGART_ENABLED
-#endif
 
 
 /* CP microcode (from ATI) */
@@ -989,17 +984,6 @@
        memset( dev_priv, 0, sizeof(drm_radeon_private_t) );
 
        dev_priv->is_pci = init->is_pci;
-
-#if !defined(PCIGART_ENABLED)
-       /* PCI support is not 100% working, so we disable it here.
-        */
-       if ( dev_priv->is_pci ) {
-               DRM_ERROR( "PCI GART not yet supported for Radeon!\n" );
-               dev->dev_private = (void *)dev_priv;
-               radeon_do_cleanup_cp(dev);
-               return DRM_ERR(EINVAL);
-       }
-#endif
 
        if ( dev_priv->is_pci && !dev->sg ) {
                DRM_ERROR( "PCI GART memory not allocated!\n" );
Index: programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h,v
retrieving revision 1.12
diff -u -r1.12 radeon_drv.h
--- programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h       2 Jan 
2003 18:38:07 -0000       1.12
+++ programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h       3 Feb 
+2003 14:22:29 -0000
@@ -864,8 +864,11 @@
                dev_priv->ring.tail = write;                            \
 } while (0)
 
-#define COMMIT_RING() do {                                         \
-       RADEON_WRITE( RADEON_CP_RB_WPTR, dev_priv->ring.tail );             \
+#define COMMIT_RING() do {                                             \
+       /* read from PCI bus to ensure correct posting */               \
+       RADEON_READ( RADEON_CP_RB_WPTR );                               \
+       RADEON_WRITE( RADEON_CP_RB_WPTR, dev_priv->ring.tail );         \
+       RADEON_READ( RADEON_CP_RB_WPTR );                               \
 } while (0)
 
 #define OUT_RING( x ) do {                                             \

Reply via email to