diff options
-rw-r--r-- | libdrm/xf86drmHash.c | 32 | ||||
-rw-r--r-- | linux-core/r128_drv.c | 4 | ||||
-rw-r--r-- | linux-core/radeon_drv.c | 4 | ||||
-rw-r--r-- | linux/mga_dma.c | 40 | ||||
-rw-r--r-- | linux/mga_drm.h | 2 | ||||
-rw-r--r-- | linux/mga_drv.h | 10 | ||||
-rw-r--r-- | linux/mga_state.c | 21 | ||||
-rw-r--r-- | linux/r128_cce.c | 19 | ||||
-rw-r--r-- | linux/r128_drv.c | 4 | ||||
-rw-r--r-- | linux/r128_drv.h | 15 | ||||
-rw-r--r-- | linux/r128_state.c | 24 | ||||
-rw-r--r-- | linux/radeon_cp.c | 19 | ||||
-rw-r--r-- | linux/radeon_drv.c | 4 | ||||
-rw-r--r-- | linux/radeon_drv.h | 15 | ||||
-rw-r--r-- | linux/radeon_state.c | 28 |
15 files changed, 93 insertions, 148 deletions
diff --git a/libdrm/xf86drmHash.c b/libdrm/xf86drmHash.c index 24b698cce..70240b950 100644 --- a/libdrm/xf86drmHash.c +++ b/libdrm/xf86drmHash.c @@ -10,11 +10,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -22,7 +22,7 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: Rickard E. (Rik) Faith <faith@valinux.com> * * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.3 2000/06/17 00:03:34 martin Exp $ @@ -187,7 +187,7 @@ int N(HashDestroy)(void *t) int i; if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - + for (i = 0; i < HASH_SIZE; i++) { for (bucket = table->buckets[i]; bucket;) { next = bucket->next; @@ -235,8 +235,8 @@ int N(HashLookup)(void *t, unsigned long key, void **value) HashTablePtr table = (HashTablePtr)t; HashBucketPtr bucket; - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - + if (!table || table->magic != HASH_MAGIC) return -1; /* Bad magic */ + bucket = HashFind(table, key, NULL); if (!bucket) return 1; /* Not found */ *value = bucket->value; @@ -250,7 +250,7 @@ int N(HashInsert)(void *t, unsigned long key, void *value) unsigned long hash; if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - + if (HashFind(table, key, &hash)) return 1; /* Already in table */ bucket = HASH_ALLOC(sizeof(*bucket)); @@ -272,7 +272,7 @@ int N(HashDelete)(void *t, unsigned long key) HashBucketPtr bucket; if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - + bucket = HashFind(table, key, &hash); if (!bucket) return 1; /* Not found */ @@ -285,7 +285,7 @@ int N(HashDelete)(void *t, unsigned long key) int N(HashNext)(void *t, unsigned long *key, void **value) { HashTablePtr table = (HashTablePtr)t; - + for (; table->p0 < HASH_SIZE; ++table->p0, table->p1 = table->buckets[table->p0]) { if (table->p1) { @@ -301,7 +301,7 @@ int N(HashNext)(void *t, unsigned long *key, void **value) int N(HashFirst)(void *t, unsigned long *key, void **value) { HashTablePtr table = (HashTablePtr)t; - + if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ table->p0 = 0; @@ -337,7 +337,7 @@ static void compute_dist(HashTablePtr table) { int i; HashBucketPtr bucket; - + printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n", table->entries, table->hits, table->partials, table->misses); clear_dist(); @@ -356,7 +356,7 @@ static void check_table(HashTablePtr table, { unsigned long retval = 0; int retcode = N(HashLookup)(table, key, &retval); - + switch (retcode) { case -1: printf("Bad magic = 0x%08lx:" @@ -391,7 +391,7 @@ int main(void) for (i = 256; i >= 0; i--) check_table(table, i, i); compute_dist(table); N(HashDestroy)(table); - + printf("\n***** 1024 consecutive integers ****\n"); table = N(HashCreate)(); for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i); @@ -399,7 +399,7 @@ int main(void) for (i = 1024; i >= 0; i--) check_table(table, i, i); compute_dist(table); N(HashDestroy)(table); - + printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); table = N(HashCreate)(); for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i); @@ -407,7 +407,7 @@ int main(void) for (i = 1024; i >= 0; i--) check_table(table, i*4096, i); compute_dist(table); N(HashDestroy)(table); - + printf("\n***** 1024 random integers ****\n"); table = N(HashCreate)(); srandom(0xbeefbeef); @@ -429,7 +429,7 @@ int main(void) for (i = 0; i < 5000; i++) check_table(table, random(), i); compute_dist(table); N(HashDestroy)(table); - + return 0; } #endif diff --git a/linux-core/r128_drv.c b/linux-core/r128_drv.c index e42868ed6..daae0f875 100644 --- a/linux-core/r128_drv.c +++ b/linux-core/r128_drv.c @@ -38,11 +38,11 @@ #define DRIVER_NAME "r128" #define DRIVER_DESC "ATI Rage 128" -#define DRIVER_DATE "20010216" +#define DRIVER_DATE "20010308" #define DRIVER_MAJOR 2 #define DRIVER_MINOR 1 -#define DRIVER_PATCHLEVEL 4 +#define DRIVER_PATCHLEVEL 5 #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { r128_cce_buffers, 1, 0 }, \ diff --git a/linux-core/radeon_drv.c b/linux-core/radeon_drv.c index 1aa889aee..dba2037f9 100644 --- a/linux-core/radeon_drv.c +++ b/linux-core/radeon_drv.c @@ -36,11 +36,11 @@ #define DRIVER_NAME "radeon" #define DRIVER_DESC "ATI Radeon" -#define DRIVER_DATE "20010305" +#define DRIVER_DATE "20010308" #define DRIVER_MAJOR 1 #define DRIVER_MINOR 0 -#define DRIVER_PATCHLEVEL 0 +#define DRIVER_PATCHLEVEL 1 #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { radeon_cp_buffers, 1, 0 }, \ diff --git a/linux/mga_dma.c b/linux/mga_dma.c index 21e14f376..ec80fb417 100644 --- a/linux/mga_dma.c +++ b/linux/mga_dma.c @@ -178,7 +178,7 @@ void mga_do_dma_flush( drm_mga_private_t *dev_priv ) primary->last_flush = primary->tail; - head = *primary->head; + head = MGA_READ( MGA_PRIMADDRESS ); if ( head <= tail ) { primary->space = primary->size - primary->tail; @@ -218,7 +218,7 @@ void mga_do_dma_wrap_start( drm_mga_private_t *dev_priv ) primary->last_flush = 0; primary->last_wrap++; - head = *primary->head; + head = MGA_READ( MGA_PRIMADDRESS ); if ( head == dev_priv->primary->offset ) { primary->space = primary->size; @@ -240,7 +240,6 @@ void mga_do_dma_wrap_start( drm_mga_private_t *dev_priv ) void mga_do_dma_wrap_end( drm_mga_private_t *dev_priv ) { - drm_mga_primary_buffer_t *primary = &dev_priv->prim; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; u32 head = dev_priv->primary->offset; DRM_DEBUG( "%s:\n", __FUNCTION__ ); @@ -248,8 +247,6 @@ void mga_do_dma_wrap_end( drm_mga_private_t *dev_priv ) sarea_priv->last_wrap++; DRM_DEBUG( " wrap = %d\n", sarea_priv->last_wrap ); - *primary->head = head; - mga_flush_write_combine(); MGA_WRITE( MGA_PRIMADDRESS, head | MGA_DMA_GENERAL ); @@ -272,7 +269,7 @@ static void mga_freelist_print( drm_device_t *dev ) DRM_INFO( "\n" ); DRM_INFO( "current dispatch: last=0x%x done=0x%x\n", dev_priv->sarea_priv->last_dispatch, - (unsigned int)(*dev_priv->prim.head - + (unsigned int)(MGA_READ( MGA_PRIMADDRESS ) - dev_priv->primary->offset) ); DRM_INFO( "current freelist:\n" ); @@ -375,7 +372,7 @@ static drm_buf_t *mga_freelist_get( drm_device_t *dev ) u32 head, wrap; DRM_DEBUG( "%s:\n", __FUNCTION__ ); - head = *dev_priv->prim.head; + head = MGA_READ( MGA_PRIMADDRESS ); wrap = dev_priv->sarea_priv->last_wrap; DRM_DEBUG( " tail=0x%06lx %d\n", @@ -403,7 +400,7 @@ int mga_freelist_put( drm_device_t *dev, drm_buf_t *buf ) { drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_buf_priv_t *buf_priv = buf->dev_private; - drm_mga_freelist_t *head, *next, *prev; + drm_mga_freelist_t *head, *entry, *prev; DRM_DEBUG( "%s: age=0x%06lx wrap=%d\n", __FUNCTION__, @@ -411,22 +408,23 @@ int mga_freelist_put( drm_device_t *dev, drm_buf_t *buf ) dev_priv->primary->offset, buf_priv->list_entry->age.wrap ); - /* Put buffer on the head + 1, as the head is a sentinal. - */ - - next = buf_priv->list_entry; + entry = buf_priv->list_entry; head = dev_priv->head; - prev = head->next; if ( buf_priv->list_entry->age.head == MGA_BUFFER_USED ) { - SET_AGE( &next->age, MGA_BUFFER_FREE, 0 ); + SET_AGE( &entry->age, MGA_BUFFER_FREE, 0 ); + prev = dev_priv->tail; + prev->next = entry; + entry->prev = prev; + entry->next = NULL; + } else { + prev = head->next; + head->next = entry; + prev->prev = entry; + entry->prev = head; + entry->next = prev; } - head->next = next; - prev->prev = next; - next->prev = head; - next->next = prev; - return 0; } @@ -529,7 +527,6 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init ) + dev_priv->primary->size); dev_priv->prim.size = dev_priv->primary->size; - dev_priv->prim.head = &dev_priv->prim.status[0]; dev_priv->prim.tail = 0; dev_priv->prim.space = dev_priv->prim.size; @@ -625,10 +622,11 @@ int mga_dma_flush( struct inode *inode, struct file *filp, WRAP_TEST_WITH_RETURN( dev_priv ); +#if 0 if ( lock.flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL) ) { mga_do_dma_flush( dev_priv ); } - +#endif if ( lock.flags & _DRM_LOCK_QUIESCENT ) { return mga_do_wait_for_idle( dev_priv ); } else { diff --git a/linux/mga_drm.h b/linux/mga_drm.h index c2fe4a188..5cf863185 100644 --- a/linux/mga_drm.h +++ b/linux/mga_drm.h @@ -97,7 +97,7 @@ /* 32 buffers of 64k each, total 2 meg. */ #define MGA_BUFFER_SIZE (1 << 16) -#define MGA_NUM_BUFFERS 32 +#define MGA_NUM_BUFFERS 128 /* Keep these small for testing. */ diff --git a/linux/mga_drv.h b/linux/mga_drv.h index f56186e1e..bd33d9d1e 100644 --- a/linux/mga_drv.h +++ b/linux/mga_drv.h @@ -36,7 +36,6 @@ typedef struct drm_mga_primary_buffer { u8 *end; int size; - volatile u32 *head; u32 tail; int space; @@ -246,6 +245,13 @@ do { \ #define FLUSH_DMA() \ do { \ + if ( 0 ) { \ + DRM_INFO( __FUNCTION__ ":\n" ); \ + DRM_INFO( " tail=0x%06x head=0x%06lx\n", \ + dev_priv->prim.tail, \ + MGA_READ( MGA_PRIMADDRESS ) - \ + dev_priv->primary->offset ); \ + } \ if ( dev_priv->prim.space < dev_priv->prim.high_mark ) { \ mga_do_dma_wrap_start( dev_priv ); \ } else { \ @@ -278,7 +284,7 @@ do { \ } while (0) -/* Buffer ageing via primary DMA stream head pointer. +/* Buffer aging via primary DMA stream head pointer. */ #define SET_AGE( age, h, w ) \ diff --git a/linux/mga_state.c b/linux/mga_state.c index dc2c8c301..1e1c2827a 100644 --- a/linux/mga_state.c +++ b/linux/mga_state.c @@ -591,20 +591,9 @@ static void mga_dma_dispatch_swap( drm_device_t *dev ) int i; DMA_LOCALS; DRM_DEBUG( __FUNCTION__ ":\n" ); - DRM_DEBUG( " head = 0x%06x\n", *dev_priv->prim.head ); + DRM_DEBUG( " head = 0x%06x\n", MGA_READ( MGA_PRIMADDRESS ) ); - sarea_priv->last_frame.head = dev_priv->prim.tail; - sarea_priv->last_frame.wrap = dev_priv->prim.last_wrap; - - DRM_DEBUG( " tail = 0x%06x\n", dev_priv->prim.tail ); - DRM_DEBUG( " wrap = 0x%06x\n", dev_priv->prim.last_wrap ); - - BEGIN_DMA( 4 + nbox ); - - DMA_BLOCK( MGA_DMAPAD, 0x00000000, - MGA_DMAPAD, 0x00000000, - MGA_DWGSYNC, 0x00007100, - MGA_DWGSYNC, 0x00007000 ); + BEGIN_DMA( 3 + nbox ); DMA_BLOCK( MGA_DSTORG, dev_priv->front_offset, MGA_MACCESS, dev_priv->maccess, @@ -635,6 +624,12 @@ static void mga_dma_dispatch_swap( drm_device_t *dev ) ADVANCE_DMA(); + DRM_DEBUG( " tail = 0x%06x\n", dev_priv->prim.tail ); + DRM_DEBUG( " wrap = 0x%06x\n", dev_priv->prim.last_wrap ); + + sarea_priv->last_frame.head = dev_priv->prim.tail; + sarea_priv->last_frame.wrap = dev_priv->prim.last_wrap; + FLUSH_DMA(); DRM_DEBUG( "%s... done.\n", __FUNCTION__ ); diff --git a/linux/r128_cce.c b/linux/r128_cce.c index f4b4f0c4a..c0e20c213 100644 --- a/linux/r128_cce.c +++ b/linux/r128_cce.c @@ -839,13 +839,9 @@ 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; - if ( ring->space <= 0 ) - ring->space += ring->size; - + r128_update_ring_snapshot( ring ); if ( ring->space >= n ) return 0; - udelay( 1 ); } @@ -854,19 +850,6 @@ int r128_wait_ring( drm_r128_private_t *dev_priv, int n ) return -EBUSY; } -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; -#if R128_PERFORMANCE_BOXES - if ( ring->space == 0 ) - atomic_inc( &dev_priv->idle_count ); -#endif - if ( ring->space <= 0 ) - ring->space += ring->size; -} - static int r128_cce_get_buffers( drm_device_t *dev, drm_dma_t *d ) { int i; diff --git a/linux/r128_drv.c b/linux/r128_drv.c index e42868ed6..daae0f875 100644 --- a/linux/r128_drv.c +++ b/linux/r128_drv.c @@ -38,11 +38,11 @@ #define DRIVER_NAME "r128" #define DRIVER_DESC "ATI Rage 128" -#define DRIVER_DATE "20010216" +#define DRIVER_DATE "20010308" #define DRIVER_MAJOR 2 #define DRIVER_MINOR 1 -#define DRIVER_PATCHLEVEL 4 +#define DRIVER_PATCHLEVEL 5 #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { r128_cce_buffers, 1, 0 }, \ diff --git a/linux/r128_drv.h b/linux/r128_drv.h index 9f53746f8..6216b9a1b 100644 --- a/linux/r128_drv.h +++ b/linux/r128_drv.h @@ -130,7 +130,14 @@ extern void r128_freelist_reset( drm_device_t *dev ); extern drm_buf_t *r128_freelist_get( drm_device_t *dev ); extern int r128_wait_ring( drm_r128_private_t *dev_priv, int n ); -extern void r128_update_ring_snapshot( drm_r128_private_t *dev_priv ); + +static inline void +r128_update_ring_snapshot( drm_r128_ring_buffer_t *ring ) +{ + ring->space = (*(volatile int *)ring->head - ring->tail) * sizeof(u32); + if ( ring->space <= 0 ) + ring->space += ring->size; +} extern int r128_do_cce_idle( drm_r128_private_t *dev_priv ); extern int r128_do_cleanup_cce( drm_device_t *dev ); @@ -415,9 +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; \ - if ( ring->space <= 0 ) \ - ring->space += ring->size; \ + r128_update_ring_snapshot( ring ); \ if ( ring->space >= ring->high_mark ) \ goto __ring_space_done; \ udelay( 1 ); \ @@ -462,7 +467,7 @@ do { \ DRM_INFO( "BEGIN_RING( %d ) in %s\n", \ (n), __FUNCTION__ ); \ } \ - if ( dev_priv->ring.space < (n) * sizeof(u32) ) { \ + if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \ r128_wait_ring( dev_priv, (n) * sizeof(u32) ); \ } \ dev_priv->ring.space -= (n) * sizeof(u32); \ diff --git a/linux/r128_state.c b/linux/r128_state.c index fa16f3ced..9fc6b485c 100644 --- a/linux/r128_state.c +++ b/linux/r128_state.c @@ -372,8 +372,6 @@ static void r128_cce_dispatch_clear( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - r128_update_ring_snapshot( dev_priv ); - if ( dev_priv->page_flipping && dev_priv->current_page == 1 ) { unsigned int tmp = flags; @@ -477,8 +475,6 @@ static void r128_cce_dispatch_swap( drm_device_t *dev ) RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - r128_update_ring_snapshot( dev_priv ); - #if R128_PERFORMANCE_BOXES /* Do some trivial performance monitoring... */ @@ -535,8 +531,6 @@ static void r128_cce_dispatch_flip( drm_device_t *dev ) RING_LOCALS; DRM_DEBUG( "%s: page=%d\n", __FUNCTION__, dev_priv->current_page ); - r128_update_ring_snapshot( dev_priv ); - #if R128_PERFORMANCE_BOXES /* Do some trivial performance monitoring... */ @@ -587,8 +581,6 @@ static void r128_cce_dispatch_vertex( drm_device_t *dev, DRM_DEBUG( "%s: buf=%d nbox=%d\n", __FUNCTION__, buf->idx, sarea_priv->nbox ); - r128_update_ring_snapshot( dev_priv ); - if ( 0 ) r128_print_dirty( "dispatch_vertex", sarea_priv->dirty ); @@ -656,8 +648,6 @@ static void r128_cce_dispatch_indirect( drm_device_t *dev, DRM_DEBUG( "indirect: buf=%d s=0x%x e=0x%x\n", buf->idx, start, end ); - r128_update_ring_snapshot( dev_priv ); - if ( start != end ) { int offset = buf->bus_address + start; int dwords = (end - start + 3) / sizeof(u32); @@ -722,8 +712,6 @@ static void r128_cce_dispatch_indices( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "indices: s=%d e=%d c=%d\n", start, end, count ); - r128_update_ring_snapshot( dev_priv ); - if ( 0 ) r128_print_dirty( "dispatch_indices", sarea_priv->dirty ); @@ -799,8 +787,6 @@ static int r128_cce_dispatch_blit( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - r128_update_ring_snapshot( dev_priv ); - /* The compiler won't optimize away a division by a variable, * even if the only legal values are powers of two. Thus, we'll * use a shift instead. @@ -911,8 +897,6 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - r128_update_ring_snapshot( dev_priv ); - count = depth->n; if ( copy_from_user( &x, depth->x, sizeof(x) ) ) { return -EFAULT; @@ -1006,8 +990,6 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - r128_update_ring_snapshot( dev_priv ); - count = depth->n; x = kmalloc( count * sizeof(*x), 0 ); @@ -1123,8 +1105,6 @@ static int r128_cce_dispatch_read_span( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - r128_update_ring_snapshot( dev_priv ); - count = depth->n; if ( copy_from_user( &x, depth->x, sizeof(x) ) ) { return -EFAULT; @@ -1167,8 +1147,6 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - r128_update_ring_snapshot( dev_priv ); - count = depth->n; if ( count > dev_priv->depth_pitch ) { count = dev_priv->depth_pitch; @@ -1236,8 +1214,6 @@ static void r128_cce_dispatch_stipple( drm_device_t *dev, u32 *stipple ) RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - r128_update_ring_snapshot( dev_priv ); - BEGIN_RING( 33 ); OUT_RING( CCE_PACKET0( R128_BRUSH_DATA0, 31 ) ); diff --git a/linux/radeon_cp.c b/linux/radeon_cp.c index c80665caf..ed8b1bbca 100644 --- a/linux/radeon_cp.c +++ b/linux/radeon_cp.c @@ -1166,13 +1166,9 @@ int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n ) int i; for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { - ring->space = *ring->head - ring->tail; - if ( ring->space <= 0 ) - ring->space += ring->size; - - if ( ring->space >= n ) + radeon_update_ring_snapshot( ring ); + if ( ring->space > n ) return 0; - udelay( 1 ); } @@ -1181,17 +1177,6 @@ int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n ) return -EBUSY; } -void radeon_update_ring_snapshot( drm_radeon_private_t *dev_priv ) -{ - drm_radeon_ring_buffer_t *ring = &dev_priv->ring; - - ring->space = *ring->head - ring->tail; - if ( ring->space == 0 ) - atomic_inc( &dev_priv->idle_count ); - if ( ring->space <= 0 ) - ring->space += ring->size; -} - static int radeon_cp_get_buffers( drm_device_t *dev, drm_dma_t *d ) { int i; diff --git a/linux/radeon_drv.c b/linux/radeon_drv.c index 1aa889aee..dba2037f9 100644 --- a/linux/radeon_drv.c +++ b/linux/radeon_drv.c @@ -36,11 +36,11 @@ #define DRIVER_NAME "radeon" #define DRIVER_DESC "ATI Radeon" -#define DRIVER_DATE "20010305" +#define DRIVER_DATE "20010308" #define DRIVER_MAJOR 1 #define DRIVER_MINOR 0 -#define DRIVER_PATCHLEVEL 0 +#define DRIVER_PATCHLEVEL 1 #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { radeon_cp_buffers, 1, 0 }, \ diff --git a/linux/radeon_drv.h b/linux/radeon_drv.h index d279b0467..f176bb560 100644 --- a/linux/radeon_drv.h +++ b/linux/radeon_drv.h @@ -146,7 +146,14 @@ extern void radeon_freelist_reset( drm_device_t *dev ); extern drm_buf_t *radeon_freelist_get( drm_device_t *dev ); extern int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n ); -extern void radeon_update_ring_snapshot( drm_radeon_private_t *dev_priv ); + +static inline void +radeon_update_ring_snapshot( drm_radeon_ring_buffer_t *ring ) +{ + ring->space = (*(volatile int *)ring->head - ring->tail) * sizeof(u32); + if ( ring->space <= 0 ) + ring->space += ring->size; +} extern int radeon_do_cp_idle( drm_radeon_private_t *dev_priv ); extern int radeon_do_cleanup_cp( drm_device_t *dev ); @@ -601,9 +608,7 @@ do { \ drm_radeon_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; \ - if ( ring->space <= 0 ) \ - ring->space += ring->size; \ + radeon_update_ring_snapshot( ring ); \ if ( ring->space >= ring->high_mark ) \ goto __ring_space_done; \ udelay( 1 ); \ @@ -657,7 +662,7 @@ do { \ DRM_INFO( "BEGIN_RING( %d ) in %s\n", \ n, __FUNCTION__ ); \ } \ - if ( dev_priv->ring.space < (n) * sizeof(u32) ) { \ + if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \ radeon_wait_ring( dev_priv, (n) * sizeof(u32) ); \ } \ dev_priv->ring.space -= (n) * sizeof(u32); \ diff --git a/linux/radeon_state.c b/linux/radeon_state.c index ff1b3512f..9360c43b0 100644 --- a/linux/radeon_state.c +++ b/linux/radeon_state.c @@ -498,8 +498,6 @@ static void radeon_cp_dispatch_clear( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - radeon_update_ring_snapshot( dev_priv ); - if ( dev_priv->page_flipping && dev_priv->current_page == 1 ) { unsigned int tmp = flags; @@ -656,8 +654,6 @@ static void radeon_cp_dispatch_swap( drm_device_t *dev ) RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - radeon_update_ring_snapshot( dev_priv ); - #if RADEON_PERFORMANCE_BOXES /* Do some trivial performance monitoring... */ @@ -725,8 +721,6 @@ static void radeon_cp_dispatch_flip( drm_device_t *dev ) RING_LOCALS; DRM_DEBUG( "%s: page=%d\n", __FUNCTION__, dev_priv->current_page ); - radeon_update_ring_snapshot( dev_priv ); - #if RADEON_PERFORMANCE_BOXES /* Do some trivial performance monitoring... */ @@ -777,8 +771,6 @@ static void radeon_cp_dispatch_vertex( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "%s: nbox=%d\n", __FUNCTION__, sarea_priv->nbox ); - radeon_update_ring_snapshot( dev_priv ); - if ( 0 ) radeon_print_dirty( "dispatch_vertex", sarea_priv->dirty ); @@ -845,8 +837,6 @@ static void radeon_cp_dispatch_indirect( drm_device_t *dev, DRM_DEBUG( "indirect: buf=%d s=0x%x e=0x%x\n", buf->idx, start, end ); - radeon_update_ring_snapshot( dev_priv ); - if ( start != end ) { int offset = (dev_priv->agp_buffers_offset + buf->offset + start); @@ -909,8 +899,6 @@ static void radeon_cp_dispatch_indices( drm_device_t *dev, RING_LOCALS; DRM_DEBUG( "indices: s=%d e=%d c=%d\n", start, end, count ); - radeon_update_ring_snapshot( dev_priv ); - if ( 0 ) radeon_print_dirty( "dispatch_indices", sarea_priv->dirty ); @@ -1066,8 +1054,10 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev, image->height -= height; image->data = (char *)image->data + size; - if ( copy_to_user( tex->image, image, sizeof(*image) ) ) + if ( copy_to_user( tex->image, image, sizeof(*image) ) ) { + DRM_ERROR( "EFAULT on tex->image\n" ); return -EFAULT; + } } else if ( size < 4 ) { size = 4; } @@ -1101,16 +1091,21 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev, /* Texture image width is larger than the minimum, so we * can upload it directly. */ - if ( copy_from_user( buffer, data, dwords * sizeof(u32) ) ) + if ( copy_from_user( buffer, data, dwords * sizeof(u32) ) ) { + DRM_ERROR( "EFAULT on data, %d dwords\n", dwords ); return -EFAULT; + } } else { /* Texture image width is less than the minimum, so we * need to pad out each image scanline to the minimum * width. */ for ( i = 0 ; i < tex->height ; i++ ) { - if ( copy_from_user( buffer, data, tex_width ) ) + if ( copy_from_user( buffer, data, tex_width ) ) { + DRM_ERROR( "EFAULT on pad, %d bytes\n", + tex_width ); return -EFAULT; + } buffer += 8; data += tex_width; } @@ -1143,8 +1138,6 @@ static void radeon_cp_dispatch_stipple( drm_device_t *dev, u32 *stipple ) RING_LOCALS; DRM_DEBUG( "%s\n", __FUNCTION__ ); - radeon_update_ring_snapshot( dev_priv ); - BEGIN_RING( 35 ); OUT_RING( CP_PACKET0( RADEON_RE_STIPPLE_ADDR, 0 ) ); @@ -1180,7 +1173,6 @@ int radeon_cp_clear( struct inode *inode, struct file *filp, sizeof(clear) ) ) return -EFAULT; - RING_SPACE_TEST_WITH_RETURN( dev_priv ); if ( sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS ) |