aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-io.c
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2008-03-28 04:34:45 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:09:47 -0400
commitad0992e97c5416e431e19dcfd4f6c84448dc1bc2 (patch)
treeea90956680289c0797b715422e9d1c889f38f3d5 /drivers/media/video/pvrusb2/pvrusb2-io.c
parentbe9cbb7c559eddea19604abafb89faf9c8666715 (diff)
V4L/DVB (7699): pvrusb2: Implement statistics for USB I/O performance / tracking
Implement a mechanism in the pvrusb2 driver for gathering statistics on the stream buffering, including bytes transferred, buffers handled, buffers in flight, etc. This is useful for debugging certain classes of streaming issues and for determining if the buffer pool size is generally correct for the driver. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-io.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
index a9889ff96ecc..7aff8b720064 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -80,6 +80,10 @@ struct pvr2_stream {
80 /* Tracking state for tolerating errors */ 80 /* Tracking state for tolerating errors */
81 unsigned int fail_count; 81 unsigned int fail_count;
82 unsigned int fail_tolerance; 82 unsigned int fail_tolerance;
83
84 unsigned int buffers_processed;
85 unsigned int buffers_failed;
86 unsigned int bytes_processed;
83}; 87};
84 88
85struct pvr2_buffer { 89struct pvr2_buffer {
@@ -446,6 +450,8 @@ static void buffer_complete(struct urb *urb)
446 (urb->status == -ENOENT) || 450 (urb->status == -ENOENT) ||
447 (urb->status == -ECONNRESET) || 451 (urb->status == -ECONNRESET) ||
448 (urb->status == -ESHUTDOWN)) { 452 (urb->status == -ESHUTDOWN)) {
453 (sp->buffers_processed)++;
454 sp->bytes_processed += urb->actual_length;
449 bp->used_count = urb->actual_length; 455 bp->used_count = urb->actual_length;
450 if (sp->fail_count) { 456 if (sp->fail_count) {
451 pvr2_trace(PVR2_TRACE_TOLERANCE, 457 pvr2_trace(PVR2_TRACE_TOLERANCE,
@@ -457,11 +463,13 @@ static void buffer_complete(struct urb *urb)
457 // We can tolerate this error, because we're below the 463 // We can tolerate this error, because we're below the
458 // threshold... 464 // threshold...
459 (sp->fail_count)++; 465 (sp->fail_count)++;
466 (sp->buffers_failed)++;
460 pvr2_trace(PVR2_TRACE_TOLERANCE, 467 pvr2_trace(PVR2_TRACE_TOLERANCE,
461 "stream %p ignoring error %d" 468 "stream %p ignoring error %d"
462 " - fail count increased to %u", 469 " - fail count increased to %u",
463 sp,urb->status,sp->fail_count); 470 sp,urb->status,sp->fail_count);
464 } else { 471 } else {
472 (sp->buffers_failed)++;
465 bp->status = urb->status; 473 bp->status = urb->status;
466 } 474 }
467 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 475 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
@@ -515,6 +523,28 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp,
515 } while(0); mutex_unlock(&sp->mutex); 523 } while(0); mutex_unlock(&sp->mutex);
516} 524}
517 525
526void pvr2_stream_get_stats(struct pvr2_stream *sp,
527 struct pvr2_stream_stats *stats,
528 int zero_counts)
529{
530 unsigned long irq_flags;
531 spin_lock_irqsave(&sp->list_lock,irq_flags);
532 if (stats) {
533 stats->buffers_in_queue = sp->q_count;
534 stats->buffers_in_idle = sp->i_count;
535 stats->buffers_in_ready = sp->r_count;
536 stats->buffers_processed = sp->buffers_processed;
537 stats->buffers_failed = sp->buffers_failed;
538 stats->bytes_processed = sp->bytes_processed;
539 }
540 if (zero_counts) {
541 sp->buffers_processed = 0;
542 sp->buffers_failed = 0;
543 sp->bytes_processed = 0;
544 }
545 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
546}
547
518/* Query / set the nominal buffer count */ 548/* Query / set the nominal buffer count */
519int pvr2_stream_get_buffer_count(struct pvr2_stream *sp) 549int pvr2_stream_get_buffer_count(struct pvr2_stream *sp)
520{ 550{