From 60c9819ab4fa21ff399c101446efb1cff93ed077 Mon Sep 17 00:00:00 2001 From: Rik Faith Date: Tue, 13 Feb 2001 14:08:25 +0000 Subject: [PATCH] Updated counters for gamma --- linux-core/drmP.h | 2 ++ linux-core/drm_drv.c | 3 --- linux-core/drm_lock.c | 1 - linux-core/drm_proc.c | 7 ++----- linux/drm.h | 9 ++++++--- linux/drmP.h | 2 ++ linux/drm_drv.h | 3 --- linux/drm_lock.h | 1 - linux/drm_proc.h | 7 ++----- linux/gamma_dma.c | 36 +++++++++++----------------------- linux/gamma_drv.c | 8 +++++++- linux/mga_dma.c | 1 - shared-core/drm.h | 9 ++++++--- shared/drm.h | 9 ++++++--- tests/dristat.c | 45 ++++++++++++++++++++++++++++--------------- 15 files changed, 74 insertions(+), 69 deletions(-) diff --git a/linux-core/drmP.h b/linux-core/drmP.h index d984cac0..5ba31d36 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -469,9 +469,11 @@ typedef struct drm_queue { wait_queue_head_t read_queue; /* Processes waiting on block_read */ atomic_t block_write; /* Queue blocked for writes */ wait_queue_head_t write_queue; /* Processes waiting on block_write */ +#if 0 atomic_t total_queued; /* Total queued statistic */ atomic_t total_flushed;/* Total flushes statistic */ atomic_t total_locks; /* Total locks statistics */ +#endif drm_ctx_flags_t flags; /* Context preserving and 2D-only */ drm_waitlist_t waitlist; /* Pending buffers */ wait_queue_head_t flush_queue; /* Processes waiting until flush */ diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 225c6127..8060e323 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -847,9 +847,6 @@ int DRM(lock)( struct inode *inode, struct file *filp, dev->lock.pid = current->pid; dev->lock.lock_time = jiffies; atomic_inc( &dev->counts[_DRM_STAT_LOCKS] ); -#if __HAVE_MULTIPLE_DMA_QUEUES - atomic_inc( &q->total_locks ); -#endif break; /* Got lock */ } diff --git a/linux-core/drm_lock.c b/linux-core/drm_lock.c index 1c089cd2..638096e9 100644 --- a/linux-core/drm_lock.c +++ b/linux-core/drm_lock.c @@ -142,7 +142,6 @@ static int DRM(flush_queue)(drm_device_t *dev, int context) remove_wait_queue(&q->flush_queue, &entry); } atomic_dec(&q->use_count); - atomic_inc(&q->total_flushed); /* NOTE: block_write is still incremented! Use drm_flush_unlock_queue to decrement. */ diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c index defabdf6..634673d9 100644 --- a/linux-core/drm_proc.c +++ b/linux-core/drm_proc.c @@ -242,7 +242,7 @@ static int DRM(_queues_info)(char *buf, char **start, off_t offset, atomic_inc(&q->use_count); DRM_PROC_PRINT_RET(atomic_dec(&q->use_count), "%5d/0x%03x %5d %5d" - " %5d/%c%c/%c%c%c %5Zd %10d %10d %10d\n", + " %5d/%c%c/%c%c%c %5Zd\n", i, q->flags, atomic_read(&q->use_count), @@ -253,10 +253,7 @@ static int DRM(_queues_info)(char *buf, char **start, off_t offset, waitqueue_active(&q->read_queue) ? 'r':'-', waitqueue_active(&q->write_queue) ? 'w':'-', waitqueue_active(&q->flush_queue) ? 'f':'-', - DRM_BUFCOUNT(&q->waitlist), - atomic_read(&q->total_flushed), - atomic_read(&q->total_queued), - atomic_read(&q->total_locks)); + DRM_BUFCOUNT(&q->waitlist)); atomic_dec(&q->use_count); } diff --git a/linux/drm.h b/linux/drm.h index 6885a83a..a238f85c 100644 --- a/linux/drm.h +++ b/linux/drm.h @@ -175,9 +175,12 @@ typedef enum { _DRM_STAT_BYTE, /* Generic byte counter (1024bytes/K) */ _DRM_STAT_COUNT, /* Generic non-byte counter (1000/k) */ - _DRM_STAT_IRQ, - _DRM_STAT_PRIMARY, - _DRM_STAT_SECONDARY + _DRM_STAT_IRQ, /* IRQ */ + _DRM_STAT_PRIMARY, /* Primary DMA bytes */ + _DRM_STAT_SECONDARY, /* Secondary DMA bytes */ + _DRM_STAT_DMA, /* DMA */ + _DRM_STAT_SPECIAL, /* Special DMA (e.g., priority or polled) */ + _DRM_STAT_MISSED /* Missed DMA opportunity */ /* Add to the *END* of the list */ } drm_stat_type_t; diff --git a/linux/drmP.h b/linux/drmP.h index d984cac0..5ba31d36 100644 --- a/linux/drmP.h +++ b/linux/drmP.h @@ -469,9 +469,11 @@ typedef struct drm_queue { wait_queue_head_t read_queue; /* Processes waiting on block_read */ atomic_t block_write; /* Queue blocked for writes */ wait_queue_head_t write_queue; /* Processes waiting on block_write */ +#if 0 atomic_t total_queued; /* Total queued statistic */ atomic_t total_flushed;/* Total flushes statistic */ atomic_t total_locks; /* Total locks statistics */ +#endif drm_ctx_flags_t flags; /* Context preserving and 2D-only */ drm_waitlist_t waitlist; /* Pending buffers */ wait_queue_head_t flush_queue; /* Processes waiting until flush */ diff --git a/linux/drm_drv.h b/linux/drm_drv.h index 225c6127..8060e323 100644 --- a/linux/drm_drv.h +++ b/linux/drm_drv.h @@ -847,9 +847,6 @@ int DRM(lock)( struct inode *inode, struct file *filp, dev->lock.pid = current->pid; dev->lock.lock_time = jiffies; atomic_inc( &dev->counts[_DRM_STAT_LOCKS] ); -#if __HAVE_MULTIPLE_DMA_QUEUES - atomic_inc( &q->total_locks ); -#endif break; /* Got lock */ } diff --git a/linux/drm_lock.h b/linux/drm_lock.h index 1c089cd2..638096e9 100644 --- a/linux/drm_lock.h +++ b/linux/drm_lock.h @@ -142,7 +142,6 @@ static int DRM(flush_queue)(drm_device_t *dev, int context) remove_wait_queue(&q->flush_queue, &entry); } atomic_dec(&q->use_count); - atomic_inc(&q->total_flushed); /* NOTE: block_write is still incremented! Use drm_flush_unlock_queue to decrement. */ diff --git a/linux/drm_proc.h b/linux/drm_proc.h index defabdf6..634673d9 100644 --- a/linux/drm_proc.h +++ b/linux/drm_proc.h @@ -242,7 +242,7 @@ static int DRM(_queues_info)(char *buf, char **start, off_t offset, atomic_inc(&q->use_count); DRM_PROC_PRINT_RET(atomic_dec(&q->use_count), "%5d/0x%03x %5d %5d" - " %5d/%c%c/%c%c%c %5Zd %10d %10d %10d\n", + " %5d/%c%c/%c%c%c %5Zd\n", i, q->flags, atomic_read(&q->use_count), @@ -253,10 +253,7 @@ static int DRM(_queues_info)(char *buf, char **start, off_t offset, waitqueue_active(&q->read_queue) ? 'r':'-', waitqueue_active(&q->write_queue) ? 'w':'-', waitqueue_active(&q->flush_queue) ? 'f':'-', - DRM_BUFCOUNT(&q->waitlist), - atomic_read(&q->total_flushed), - atomic_read(&q->total_queued), - atomic_read(&q->total_locks)); + DRM_BUFCOUNT(&q->waitlist)); atomic_dec(&q->use_count); } diff --git a/linux/gamma_dma.c b/linux/gamma_dma.c index f887bf47..cb4021d1 100644 --- a/linux/gamma_dma.c +++ b/linux/gamma_dma.c @@ -170,16 +170,13 @@ static void gamma_dma_service(int irq, void *device, struct pt_regs *regs) drm_device_t *dev = (drm_device_t *)device; drm_device_dma_t *dma = dev->dma; - atomic_inc(&dev->counts[_DRM_STAT_IRQ]); + atomic_inc(&dev->counts[6]); /* _DRM_STAT_IRQ */ GAMMA_WRITE(GAMMA_GDELAYTIMER, 0xc350/2); /* 0x05S */ GAMMA_WRITE(GAMMA_GCOMMANDINTFLAGS, 8); GAMMA_WRITE(GAMMA_GINTFLAGS, 0x2001); if (gamma_dma_is_ready(dev)) { /* Free previous buffer */ - if (test_and_set_bit(0, &dev->dma_flag)) { - atomic_inc(&dma->total_missed_free); - return; - } + if (test_and_set_bit(0, &dev->dma_flag)) return; if (dma->this_buffer) { gamma_free_buffer(dev, dma->this_buffer); dma->this_buffer = NULL; @@ -204,10 +201,7 @@ static int gamma_do_dma(drm_device_t *dev, int locked) cycles_t dma_start, dma_stop; #endif - if (test_and_set_bit(0, &dev->dma_flag)) { - atomic_inc(&dma->total_missed_dma); - return -EBUSY; - } + if (test_and_set_bit(0, &dev->dma_flag)) return -EBUSY; #if DRM_DMA_HISTOGRAM dma_start = get_cycles(); @@ -255,7 +249,6 @@ static int gamma_do_dma(drm_device_t *dev, int locked) } else { if (!locked && !gamma_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { - atomic_inc(&dma->total_missed_lock); clear_bit(0, &dev->dma_flag); return -EBUSY; } @@ -291,8 +284,8 @@ static int gamma_do_dma(drm_device_t *dev, int locked) gamma_free_buffer(dev, dma->this_buffer); dma->this_buffer = buf; - atomic_add(length, &dma->total_bytes); - atomic_inc(&dma->total_dmas); + atomic_inc(&dev->counts[7]); /* _DRM_STAT_DMA */ + atomic_add(length, &dev->counts[8]); /* _DRM_STAT_PRIMARY */ if (!buf->while_locked && !dev->context_flag && !locked) { if (gamma_lock_free(dev, &dev->lock.hw_lock->lock, @@ -338,10 +331,10 @@ int gamma_dma_schedule(drm_device_t *dev, int locked) if (test_and_set_bit(0, &dev->interrupt_flag)) { /* Not reentrant */ - atomic_inc(&dma->total_missed_sched); + atomic_inc(&dev->counts[10]); /* _DRM_STAT_MISSED */ return -EBUSY; } - missed = atomic_read(&dma->total_missed_sched); + missed = atomic_read(&dev->counts[10]); #if DRM_DMA_HISTOGRAM schedule_start = get_cycles(); @@ -358,11 +351,7 @@ again: because the lock could not be obtained or the DMA engine wasn't ready. Try again. */ - atomic_inc(&dma->total_tried); - if (!(retcode = gamma_do_dma(dev, locked))) { - atomic_inc(&dma->total_hit); - ++processed; - } + if (!(retcode = gamma_do_dma(dev, locked))) ++processed; } else { do { next = gamma_select_queue(dev, @@ -386,12 +375,10 @@ again: } if (--expire) { - if (missed != atomic_read(&dma->total_missed_sched)) { - atomic_inc(&dma->total_lost); + if (missed != atomic_read(&dev->counts[10])) { if (gamma_dma_is_ready(dev)) goto again; } if (processed && gamma_dma_is_ready(dev)) { - atomic_inc(&dma->total_lost); processed = 0; goto again; } @@ -435,7 +422,6 @@ static int gamma_dma_priority(drm_device_t *dev, drm_dma_t *d) } ++must_free; } - atomic_inc(&dma->total_prio); for (i = 0; i < d->send_count; i++) { idx = d->send_indices[i]; @@ -519,8 +505,8 @@ static int gamma_dma_priority(drm_device_t *dev, drm_dma_t *d) buf->time_dispatched = buf->time_queued; #endif gamma_dma_dispatch(dev, address, length); - atomic_add(length, &dma->total_bytes); - atomic_inc(&dma->total_dmas); + atomic_inc(&dev->counts[9]); /* _DRM_STAT_SPECIAL */ + atomic_add(length, &dev->counts[8]); /* _DRM_STAT_PRIMARY */ if (last_buf) { gamma_free_buffer(dev, last_buf); diff --git a/linux/gamma_drv.c b/linux/gamma_drv.c index c1866adf..f243439a 100644 --- a/linux/gamma_drv.c +++ b/linux/gamma_drv.c @@ -60,7 +60,13 @@ #define __HAVE_DMA_FREELIST 1 #define __HAVE_DMA 1 #define __HAVE_DMA_IRQ 1 -#define __HAVE_COUNTER_6 + +#define __HAVE_COUNTERS 10 +#define __HAVE_COUNTER6 _DRM_STAT_IRQ +#define __HAVE_COUNTER7 _DRM_STAT_DMA +#define __HAVE_COUNTER8 _DRM_STAT_PRIMARY +#define __HAVE_COUNTER9 _DRM_STAT_SPECIAL +#define __HAVE_COUNTER10 _DRM_STAT_MISSED #define __HAVE_DMA_READY 1 #define DRIVER_DMA_READY() \ diff --git a/linux/mga_dma.c b/linux/mga_dma.c index 97f33ae0..b3e3b6da 100644 --- a/linux/mga_dma.c +++ b/linux/mga_dma.c @@ -576,7 +576,6 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init ) dev_priv->prim.high_mark = 256 * DMA_BLOCK_SIZE; - spin_lock_init( &dev_priv->prim.flush_lock ); spin_lock_init( &dev_priv->prim.list_lock ); dev_priv->prim.status[0] = dev_priv->primary->offset; diff --git a/shared-core/drm.h b/shared-core/drm.h index 6885a83a..a238f85c 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -175,9 +175,12 @@ typedef enum { _DRM_STAT_BYTE, /* Generic byte counter (1024bytes/K) */ _DRM_STAT_COUNT, /* Generic non-byte counter (1000/k) */ - _DRM_STAT_IRQ, - _DRM_STAT_PRIMARY, - _DRM_STAT_SECONDARY + _DRM_STAT_IRQ, /* IRQ */ + _DRM_STAT_PRIMARY, /* Primary DMA bytes */ + _DRM_STAT_SECONDARY, /* Secondary DMA bytes */ + _DRM_STAT_DMA, /* DMA */ + _DRM_STAT_SPECIAL, /* Special DMA (e.g., priority or polled) */ + _DRM_STAT_MISSED /* Missed DMA opportunity */ /* Add to the *END* of the list */ } drm_stat_type_t; diff --git a/shared/drm.h b/shared/drm.h index 6885a83a..a238f85c 100644 --- a/shared/drm.h +++ b/shared/drm.h @@ -175,9 +175,12 @@ typedef enum { _DRM_STAT_BYTE, /* Generic byte counter (1024bytes/K) */ _DRM_STAT_COUNT, /* Generic non-byte counter (1000/k) */ - _DRM_STAT_IRQ, - _DRM_STAT_PRIMARY, - _DRM_STAT_SECONDARY + _DRM_STAT_IRQ, /* IRQ */ + _DRM_STAT_PRIMARY, /* Primary DMA bytes */ + _DRM_STAT_SECONDARY, /* Secondary DMA bytes */ + _DRM_STAT_DMA, /* DMA */ + _DRM_STAT_SPECIAL, /* Special DMA (e.g., priority or polled) */ + _DRM_STAT_MISSED /* Missed DMA opportunity */ /* Add to the *END* of the list */ } drm_stat_type_t; diff --git a/tests/dristat.c b/tests/dristat.c index 693335b9..f429efd3 100644 --- a/tests/dristat.c +++ b/tests/dristat.c @@ -133,18 +133,18 @@ int drmGetStats(int fd, drmStatsT *stats) if (s.count > sizeof(stats->data)/sizeof(stats->data[0])) return -1; -#define SET_VALUE \ - stats->data[i].long_format = "%-9.9s"; \ - stats->data[i].rate_format = "%8.8s"; \ - stats->data[i].isvalue = 1; \ +#define SET_VALUE \ + stats->data[i].long_format = "%-20.20s"; \ + stats->data[i].rate_format = "%8.8s"; \ + stats->data[i].isvalue = 1; \ stats->data[i].verbose = 0 -#define SET_COUNT \ - stats->data[i].long_format = "%-9.9s"; \ - stats->data[i].rate_format = "%5.5s"; \ - stats->data[i].isvalue = 0; \ - stats->data[i].mult_names = "kgm"; \ - stats->data[i].mult = 1000; \ +#define SET_COUNT \ + stats->data[i].long_format = "%-20.20s"; \ + stats->data[i].rate_format = "%5.5s"; \ + stats->data[i].isvalue = 0; \ + stats->data[i].mult_names = "kgm"; \ + stats->data[i].mult = 1000; \ stats->data[i].verbose = 0 #define SET_BYTE \ @@ -198,13 +198,28 @@ int drmGetStats(int fd, drmStatsT *stats) SET_COUNT; break; case _DRM_STAT_PRIMARY: - stats->data[i].long_name = "Primary"; - stats->data[i].rate_name = "Pri/s"; - SET_COUNT; + stats->data[i].long_name = "Primary Bytes"; + stats->data[i].rate_name = "PB/s"; + SET_BYTE; break; case _DRM_STAT_SECONDARY: - stats->data[i].long_name = "Secondary"; - stats->data[i].rate_name = "Sec/s"; + stats->data[i].long_name = "Secondary Bytes"; + stats->data[i].rate_name = "SB/s"; + SET_BYTE; + break; + case _DRM_STAT_DMA: + stats->data[i].long_name = "DMA"; + stats->data[i].rate_name = "DMA/s"; + SET_COUNT; + break; + case _DRM_STAT_SPECIAL: + stats->data[i].long_name = "Special DMA"; + stats->data[i].rate_name = "dma/s"; + SET_COUNT; + break; + case _DRM_STAT_MISSED: + stats->data[i].long_name = "Miss"; + stats->data[i].rate_name = "Ms/s"; SET_COUNT; break; case _DRM_STAT_VALUE: