summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Daenzer <michel@daenzer.net>2001-03-01 23:22:29 +0000
committerMichel Daenzer <michel@daenzer.net>2001-03-01 23:22:29 +0000
commit797dbc850caa573ecd7c609e725906c585cbf14c (patch)
tree38b5a3479d9702207335b26494bb308061fc7cce
parent033735ef46ee61c30745fe195001e17ab61616ed (diff)
first attempt to fix PCI GART and PPC (client side still broken for PPC)ati-pcigart-0-0-1-branch
-rw-r--r--libdrm/xf86drm.c22
-rw-r--r--linux-core/drmP.h4
-rw-r--r--linux-core/drm_bufs.c2
-rw-r--r--linux-core/drm_memory.h1
-rw-r--r--linux-core/r128_drv.c2
-rw-r--r--linux/Makefile.linux22
-rw-r--r--linux/drmP.h4
-rw-r--r--linux/drm_bufs.h2
-rw-r--r--linux/drm_memory.h1
-rw-r--r--linux/r128.h3
-rw-r--r--linux/r128_cce.c15
-rw-r--r--linux/r128_drv.c2
-rw-r--r--linux/r128_drv.h15
-rw-r--r--linux/r128_state.c30
14 files changed, 83 insertions, 42 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index 73a083e3..093b4606 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -997,6 +997,28 @@ unsigned int drmAgpDeviceId(int fd)
return i.id_device;
}
+int drmScatterGatherAlloc(int fd, unsigned long size,
+ unsigned long *handle)
+{
+ drm_agp_buffer_t b;
+ *handle = 0;
+ b.size = size;
+ b.handle = 0;
+ if (ioctl(fd, DRM_IOCTL_SG_ALLOC, &b)) return -errno;
+ *handle = b.handle;
+ return 0;
+}
+
+int drmScatterGatherFree(int fd, unsigned long handle)
+{
+ drm_agp_buffer_t b;
+
+ b.size = 0;
+ b.handle = handle;
+ if (ioctl(fd, DRM_IOCTL_SG_FREE, &b)) return -errno;
+ return 0;
+}
+
int drmError(int err, const char *label)
{
switch (err) {
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 37fc1661..2d3322be 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -144,6 +144,7 @@
#define DRM_MEM_BOUNDAGP 17
#define DRM_MEM_CTXBITMAP 18
#define DRM_MEM_STUB 19
+#define DRM_MEM_SGLISTS 20
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
@@ -540,7 +541,8 @@ typedef struct drm_device_dma {
unsigned long *pagelist;
unsigned long byte_count;
enum {
- _DRM_DMA_USE_AGP = 0x01
+ _DRM_DMA_USE_AGP = 0x01,
+ _DRM_DMA_USE_SG = 0x02
} flags;
/* DMA support */
diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c
index c1a4862b..aa1630ac 100644
--- a/linux-core/drm_bufs.c
+++ b/linux-core/drm_bufs.c
@@ -136,7 +136,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
#endif
case _DRM_SCATTER_GATHER:
if (!dev->sg) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
return -EINVAL;
}
map->offset = map->offset + dev->sg->handle;
diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h
index caf05394..b34be204 100644
--- a/linux-core/drm_memory.h
+++ b/linux-core/drm_memory.h
@@ -63,6 +63,7 @@ static drm_mem_stats_t DRM(mem_stats)[] = {
[DRM_MEM_MAPPINGS] = { "mappings" },
[DRM_MEM_BUFLISTS] = { "buflists" },
[DRM_MEM_AGPLISTS] = { "agplist" },
+ [DRM_MEM_SGLISTS] = { "sglist" },
[DRM_MEM_TOTALAGP] = { "totalagp" },
[DRM_MEM_BOUNDAGP] = { "boundagp" },
[DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
diff --git a/linux-core/r128_drv.c b/linux-core/r128_drv.c
index e42868ed..d83269d9 100644
--- a/linux-core/r128_drv.c
+++ b/linux-core/r128_drv.c
@@ -33,6 +33,7 @@
#include "r128.h"
#include "drmP.h"
#include "r128_drv.h"
+#include "ati_pcigart.h"
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
@@ -86,5 +87,6 @@
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
+#include "drm_scatter.h"
#include "drm_vm.h"
#include "drm_stub.h"
diff --git a/linux/Makefile.linux b/linux/Makefile.linux
index d022557d..0a96320a 100644
--- a/linux/Makefile.linux
+++ b/linux/Makefile.linux
@@ -47,7 +47,7 @@
# **** End of SMP/MODVERSIONS detection
-MODS = gamma.o tdfx.o
+MODS = gamma.o tdfx.o r128.o
LIBS =
DRMTEMPLATES = drm_auth.h drm_bufs.h drm_context.h drm_dma.h drm_drawable.h \
@@ -58,6 +58,9 @@ DRMHEADERS = drm.h drmP.h compat-pre24.h
GAMMAOBJS = gamma_drv.o gamma_dma.o
GAMMAHEADERS = gamma_drv.h $(DRMHEADERS) $(DRMTEMPLATES)
+R128OBJS = r128_drv.o r128_cce.o r128_state.o
+R128HEADERS = r128.h r128_drv.h r128_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
+
TDFXOBJS = tdfx_drv.o
TDFXHEADERS = tdfx.h $(DRMHEADERS)
@@ -132,7 +135,7 @@ ifeq ($(AGP),1)
MODCFLAGS += -DCONFIG_AGP -DCONFIG_AGP_MODULE
DRMTEMPLATES += drm_agpsupport.h
DRMHEADERS += agpsupport-pre24.h
-MODS += mga.o r128.o radeon.o
+MODS += mga.o radeon.o
ifeq ($(MACHINE),i386)
MODS += i810.o
endif
@@ -147,9 +150,6 @@ MGAHEADERS = mga.h mga_drv.h mga_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
I810OBJS = i810_drv.o i810_dma.o
I810HEADERS = i810.h i810_drv.h i810_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
-R128OBJS = r128_drv.o r128_cce.o r128_state.o
-R128HEADERS = r128.h r128_drv.h r128_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
-
RADEONOBJS = radeon_drv.o radeon_cp.o radeon_state.o
RADEONHEADERS = radeon.h radeon_drv.h radeon_drm.h $(DRMHEADERS) \
$(DRMTEMPLATES)
@@ -210,6 +210,11 @@ gamma_drv.o: gamma_drv.c
gamma.o: $(GAMMAOBJS)
$(LD) -r $^ -o $@
+r128_drv.o: r128_drv.c
+ $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
+r128.o: $(R128OBJS) $(LIBS)
+ $(LD) -r $^ -o $@
+
tdfx_drv.o: tdfx_drv.c
$(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
tdfx.o: $(TDFXOBJS) $(LIBS)
@@ -229,11 +234,6 @@ i810_drv.o: i810_drv.c
i810.o: $(I810OBJS) $(LIBS)
$(LD) -r $^ -o $@
-r128_drv.o: r128_drv.c
- $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
-r128.o: $(R128OBJS) $(LIBS)
- $(LD) -r $^ -o $@
-
radeon_drv.o: radeon_drv.c
$(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@
radeon.o: $(RADEONOBJS) $(LIBS)
@@ -254,11 +254,11 @@ ChangeLog:
$(CC) $(MODCFLAGS) -I$(TREE) -c $< -o $@
$(GAMMAOBJS): $(GAMMAHEADERS)
+$(R128OBJS): $(R128HEADERS)
$(TDFXOBJS): $(TDFXHEADERS)
ifeq ($(AGP),1)
$(MGAOBJS): $(MGAHEADERS)
$(I810OBJS): $(I810HEADERS)
-$(R128OBJS): $(R128HEADERS)
$(RADEONOBJS): $(RADEONHEADERS)
endif
diff --git a/linux/drmP.h b/linux/drmP.h
index 37fc1661..2d3322be 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -144,6 +144,7 @@
#define DRM_MEM_BOUNDAGP 17
#define DRM_MEM_CTXBITMAP 18
#define DRM_MEM_STUB 19
+#define DRM_MEM_SGLISTS 20
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
@@ -540,7 +541,8 @@ typedef struct drm_device_dma {
unsigned long *pagelist;
unsigned long byte_count;
enum {
- _DRM_DMA_USE_AGP = 0x01
+ _DRM_DMA_USE_AGP = 0x01,
+ _DRM_DMA_USE_SG = 0x02
} flags;
/* DMA support */
diff --git a/linux/drm_bufs.h b/linux/drm_bufs.h
index c1a4862b..aa1630ac 100644
--- a/linux/drm_bufs.h
+++ b/linux/drm_bufs.h
@@ -136,7 +136,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
#endif
case _DRM_SCATTER_GATHER:
if (!dev->sg) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
return -EINVAL;
}
map->offset = map->offset + dev->sg->handle;
diff --git a/linux/drm_memory.h b/linux/drm_memory.h
index caf05394..b34be204 100644
--- a/linux/drm_memory.h
+++ b/linux/drm_memory.h
@@ -63,6 +63,7 @@ static drm_mem_stats_t DRM(mem_stats)[] = {
[DRM_MEM_MAPPINGS] = { "mappings" },
[DRM_MEM_BUFLISTS] = { "buflists" },
[DRM_MEM_AGPLISTS] = { "agplist" },
+ [DRM_MEM_SGLISTS] = { "sglist" },
[DRM_MEM_TOTALAGP] = { "totalagp" },
[DRM_MEM_BOUNDAGP] = { "boundagp" },
[DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
diff --git a/linux/r128.h b/linux/r128.h
index d94b9256..926b4bfd 100644
--- a/linux/r128.h
+++ b/linux/r128.h
@@ -37,10 +37,11 @@
/* General customization:
*/
#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 1
+#define __MUST_HAVE_AGP 0
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
#define __HAVE_SG 1
+#define __HAVE_PCI_DMA 1
/* Driver customization:
*/
diff --git a/linux/r128_cce.c b/linux/r128_cce.c
index f01aecff..fab62a0b 100644
--- a/linux/r128_cce.c
+++ b/linux/r128_cce.c
@@ -206,9 +206,10 @@ static void r128_do_cce_flush( drm_r128_private_t *dev_priv )
int r128_do_cce_idle( drm_r128_private_t *dev_priv )
{
int i;
-
+ drm_r128_ring_buffer_t *ring = &dev_priv->ring;
+
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
- if ( *dev_priv->ring.head == dev_priv->ring.tail ) {
+ if ( GET_RING_HEAD(ring) == dev_priv->ring.tail ) {
int pm4stat = R128_READ( R128_PM4_STAT );
if ( ( (pm4stat & R128_PM4_FIFOCNT_MASK) >=
dev_priv->cce_fifo_size ) &&
@@ -249,7 +250,7 @@ static void r128_do_cce_reset( drm_r128_private_t *dev_priv )
{
R128_WRITE( R128_PM4_BUFFER_DL_WPTR, 0 );
R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 );
- *dev_priv->ring.head = 0;
+ SET_RING_HEAD( &dev_priv->ring, 0 );
dev_priv->ring.tail = 0;
}
@@ -328,7 +329,7 @@ static void r128_cce_init_ring_buffer( drm_device_t *dev )
R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 );
/* DL_RPTR_ADDR is a physical address in AGP space. */
- *dev_priv->ring.head = 0;
+ SET_RING_HEAD( &dev_priv->ring, 0 );
if ( !dev_priv->is_pci ) {
R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR,
@@ -380,7 +381,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
if ( dev_priv->is_pci && !dev->sg ) {
DRM_ERROR( "PCI GART memory not allocated!\n" );
- drm_free( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER );
+ DRM(free)( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER );
dev->dev_private = NULL;
return -EINVAL;
}
@@ -887,7 +888,7 @@ int r128_wait_ring( drm_r128_private_t *dev_priv, int n )
int i;
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
- ring->space = *ring->head - ring->tail;
+ ring->space = GET_RING_HEAD( ring ) - ring->tail;
if ( ring->space <= 0 )
ring->space += ring->size;
@@ -906,7 +907,7 @@ void r128_update_ring_snapshot( drm_r128_private_t *dev_priv )
{
drm_r128_ring_buffer_t *ring = &dev_priv->ring;
- ring->space = *ring->head - ring->tail;
+ ring->space = GET_RING_HEAD( ring ) - ring->tail;
#if R128_PERFORMANCE_BOXES
if ( ring->space == 0 )
atomic_inc( &dev_priv->idle_count );
diff --git a/linux/r128_drv.c b/linux/r128_drv.c
index e42868ed..d83269d9 100644
--- a/linux/r128_drv.c
+++ b/linux/r128_drv.c
@@ -33,6 +33,7 @@
#include "r128.h"
#include "drmP.h"
#include "r128_drv.h"
+#include "ati_pcigart.h"
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
@@ -86,5 +87,6 @@
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
+#include "drm_scatter.h"
#include "drm_vm.h"
#include "drm_stub.h"
diff --git a/linux/r128_drv.h b/linux/r128_drv.h
index 9f53746f..518fd34b 100644
--- a/linux/r128_drv.h
+++ b/linux/r128_drv.h
@@ -67,6 +67,8 @@ typedef struct drm_r128_private {
int usec_timeout;
int is_pci;
+ unsigned long phys_pci_gart;
+ unsigned long cce_buffers_offset;
atomic_t idle_count;
@@ -241,6 +243,7 @@ extern int r128_cce_indirect( struct inode *inode, struct file *filp,
# define R128_PC_FLUSH_ALL 0x00ff
# define R128_PC_BUSY (1 << 31)
+#define R128_PCI_GART_PAGE 0x017c
#define R128_PRIM_TEX_CNTL_C 0x1cb0
#define R128_SCALE_3D_CNTL 0x1a00
@@ -370,8 +373,8 @@ extern int r128_cce_indirect( struct inode *inode, struct file *filp,
#define R128_ADDR(reg) (R128_BASE( reg ) + reg)
#define R128_DEREF(reg) *(volatile u32 *)R128_ADDR( reg )
-#define R128_READ(reg) R128_DEREF( reg )
-#define R128_WRITE(reg,val) do { R128_DEREF( reg ) = val; } while (0)
+#define R128_READ(reg) le32_to_cpu( R128_DEREF( reg ) )
+#define R128_WRITE(reg,val) do { R128_DEREF( reg ) = cpu_to_le32( val ); } while (0)
#define R128_DEREF8(reg) *(volatile u8 *)R128_ADDR( reg )
#define R128_READ8(reg) R128_DEREF8( reg )
@@ -400,6 +403,10 @@ extern int R128_READ_PLL(drm_device_t *dev, int addr);
* Misc helper macros
*/
+#define GET_RING_HEAD(ring) le32_to_cpu( *(ring)->head )
+#define SET_RING_HEAD(ring,x) *(ring)->head = cpu_to_le32( x )
+
+
#define LOCK_TEST_WITH_RETURN( dev ) \
do { \
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
@@ -415,7 +422,7 @@ do { \
drm_r128_ring_buffer_t *ring = &dev_priv->ring; int i; \
if ( ring->space < ring->high_mark ) { \
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { \
- ring->space = *ring->head - ring->tail; \
+ ring->space = GET_RING_HEAD(ring) - ring->tail; \
if ( ring->space <= 0 ) \
ring->space += ring->size; \
if ( ring->space >= ring->high_mark ) \
@@ -498,7 +505,7 @@ do { \
DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \
(unsigned int)(x), write ); \
} \
- ring[write++] = (x); \
+ ring[write++] = cpu_to_le32( x ); \
write &= tail_mask; \
} while (0)
diff --git a/linux/r128_state.c b/linux/r128_state.c
index c926b2e1..a7ecb861 100644
--- a/linux/r128_state.c
+++ b/linux/r128_state.c
@@ -670,7 +670,7 @@ static void r128_cce_dispatch_indirect( drm_device_t *dev,
u32 *data = (u32 *)
((char *)dev_priv->buffers->handle
+ buf->offset + start);
- data[dwords++] = R128_CCE_PACKET2;
+ data[dwords++] = cpu_to_le32( R128_CCE_PACKET2 );
}
buf_priv->dispatched = 1;
@@ -739,16 +739,16 @@ static void r128_cce_dispatch_indices( drm_device_t *dev,
data = (u32 *)((char *)dev_priv->buffers->handle
+ buf->offset + start);
- data[0] = CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM, dwords-2 );
+ data[0] = cpu_to_le32( CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM, dwords-2 ) );
- data[1] = offset;
- data[2] = R128_MAX_VB_VERTS;
- data[3] = format;
- data[4] = (prim | R128_CCE_VC_CNTL_PRIM_WALK_IND |
- (count << 16));
+ data[1] = cpu_to_le32( offset );
+ data[2] = cpu_to_le32( R128_MAX_VB_VERTS );
+ data[3] = cpu_to_le32( format );
+ data[4] = cpu_to_le32( (prim | R128_CCE_VC_CNTL_PRIM_WALK_IND |
+ (count << 16)) );
if ( count & 0x1 ) {
- data[dwords-1] &= 0x0000ffff;
+ data[dwords-1] &= cpu_to_le32( 0x0000ffff );
}
do {
@@ -856,8 +856,8 @@ static int r128_cce_dispatch_blit( drm_device_t *dev,
data = (u32 *)((char *)dev_priv->buffers->handle + buf->offset);
- data[0] = CCE_PACKET3( R128_CNTL_HOSTDATA_BLT, dwords + 6 );
- data[1] = (R128_GMC_DST_PITCH_OFFSET_CNTL |
+ data[0] = cpu_to_le32( CCE_PACKET3( R128_CNTL_HOSTDATA_BLT, dwords + 6 ) );
+ data[1] = cpu_to_le32( (R128_GMC_DST_PITCH_OFFSET_CNTL |
R128_GMC_BRUSH_NONE |
(blit->format << 8) |
R128_GMC_SRC_DATATYPE_COLOR |
@@ -865,14 +865,14 @@ static int r128_cce_dispatch_blit( drm_device_t *dev,
R128_DP_SRC_SOURCE_HOST_DATA |
R128_GMC_CLR_CMP_CNTL_DIS |
R128_GMC_AUX_CLIP_DIS |
- R128_GMC_WR_MSK_DIS);
+ R128_GMC_WR_MSK_DIS) );
- data[2] = (blit->pitch << 21) | (blit->offset >> 5);
+ data[2] = cpu_to_le32( (blit->pitch << 21) | (blit->offset >> 5) );
data[3] = 0xffffffff;
data[4] = 0xffffffff;
- data[5] = (blit->y << 16) | blit->x;
- data[6] = (blit->height << 16) | blit->width;
- data[7] = dwords;
+ data[5] = cpu_to_le32( (blit->y << 16) | blit->x );
+ data[6] = cpu_to_le32( (blit->height << 16) | blit->width );
+ data[7] = cpu_to_le32( dwords );
buf->used = (dwords + 8) * sizeof(u32);