aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v10/kernel/fasttimer.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/cris/arch-v10/kernel/fasttimer.c')
-rw-r--r--arch/cris/arch-v10/kernel/fasttimer.c299
1 files changed, 133 insertions, 166 deletions
diff --git a/arch/cris/arch-v10/kernel/fasttimer.c b/arch/cris/arch-v10/kernel/fasttimer.c
index 52bb9b5531e1..ce6f512968a4 100644
--- a/arch/cris/arch-v10/kernel/fasttimer.c
+++ b/arch/cris/arch-v10/kernel/fasttimer.c
@@ -25,6 +25,7 @@
25#include <arch/svinto.h> 25#include <arch/svinto.h>
26#include <asm/fasttimer.h> 26#include <asm/fasttimer.h>
27#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
28#include <linux/seq_file.h>
28 29
29 30
30#define DEBUG_LOG_INCLUDED 31#define DEBUG_LOG_INCLUDED
@@ -489,196 +490,162 @@ void schedule_usleep(unsigned long us)
489} 490}
490 491
491#ifdef CONFIG_PROC_FS 492#ifdef CONFIG_PROC_FS
492static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len
493 ,int *eof, void *data_unused);
494#endif /* CONFIG_PROC_FS */
495
496#ifdef CONFIG_PROC_FS
497
498/* This value is very much based on testing */ 493/* This value is very much based on testing */
499#define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300) 494#define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300)
500 495
501static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len 496static int proc_fasttimer_show(struct seq_file *m, void *v)
502 ,int *eof, void *data_unused)
503{ 497{
504 unsigned long flags; 498 unsigned long flags;
505 int i = 0; 499 int i = 0;
506 int num_to_show; 500 int num_to_show;
507 struct fasttime_t tv; 501 struct fasttime_t tv;
508 struct fast_timer *t, *nextt; 502 struct fast_timer *t, *nextt;
509 static char *bigbuf = NULL; 503
510 static unsigned long used; 504 do_gettimeofday_fast(&tv);
511 505
512 if (!bigbuf && !(bigbuf = vmalloc(BIG_BUF_SIZE))) 506 seq_printf(m, "Fast timers added: %i\n", fast_timers_added);
513 { 507 seq_printf(m, "Fast timers started: %i\n", fast_timers_started);
514 used = 0; 508 seq_printf(m, "Fast timer interrupts: %i\n", fast_timer_ints);
515 if (buf) 509 seq_printf(m, "Fast timers expired: %i\n", fast_timers_expired);
516 buf[0] = '\0'; 510 seq_printf(m, "Fast timers deleted: %i\n", fast_timers_deleted);
517 return 0; 511 seq_printf(m, "Fast timer running: %s\n",
518 } 512 fast_timer_running ? "yes" : "no");
519 513 seq_printf(m, "Current time: %lu.%06lu\n",
520 if (!offset || !used) 514 (unsigned long)tv.tv_jiff,
521 { 515 (unsigned long)tv.tv_usec);
522 do_gettimeofday_fast(&tv);
523
524 used = 0;
525 used += sprintf(bigbuf + used, "Fast timers added: %i\n",
526 fast_timers_added);
527 used += sprintf(bigbuf + used, "Fast timers started: %i\n",
528 fast_timers_started);
529 used += sprintf(bigbuf + used, "Fast timer interrupts: %i\n",
530 fast_timer_ints);
531 used += sprintf(bigbuf + used, "Fast timers expired: %i\n",
532 fast_timers_expired);
533 used += sprintf(bigbuf + used, "Fast timers deleted: %i\n",
534 fast_timers_deleted);
535 used += sprintf(bigbuf + used, "Fast timer running: %s\n",
536 fast_timer_running ? "yes" : "no");
537 used += sprintf(bigbuf + used, "Current time: %lu.%06lu\n",
538 (unsigned long)tv.tv_jiff,
539 (unsigned long)tv.tv_usec);
540#ifdef FAST_TIMER_SANITY_CHECKS 516#ifdef FAST_TIMER_SANITY_CHECKS
541 used += sprintf(bigbuf + used, "Sanity failed: %i\n", 517 seq_printf(m, "Sanity failed: %i\n", sanity_failed);
542 sanity_failed);
543#endif 518#endif
544 used += sprintf(bigbuf + used, "\n"); 519 seq_putc(m, '\n');
545 520
546#ifdef DEBUG_LOG_INCLUDED 521#ifdef DEBUG_LOG_INCLUDED
547 { 522 {
548 int end_i = debug_log_cnt; 523 int end_i = debug_log_cnt;
549 i = 0; 524 i = 0;
550 525
551 if (debug_log_cnt_wrapped) 526 if (debug_log_cnt_wrapped)
552 { 527 i = debug_log_cnt;
553 i = debug_log_cnt; 528
554 } 529 while (i != end_i || debug_log_cnt_wrapped) {
555 530 if (seq_printf(m, debug_log_string[i], debug_log_value[i]) < 0)
556 while ((i != end_i || (debug_log_cnt_wrapped && !used)) && 531 return 0;
557 used+100 < BIG_BUF_SIZE) 532 i = (i+1) % DEBUG_LOG_MAX;
558 { 533 }
559 used += sprintf(bigbuf + used, debug_log_string[i], 534 }
560 debug_log_value[i]); 535 seq_putc(m, '\n');
561 i = (i+1) % DEBUG_LOG_MAX;
562 }
563 }
564 used += sprintf(bigbuf + used, "\n");
565#endif 536#endif
566 537
567 num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started: 538 num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started:
568 NUM_TIMER_STATS); 539 NUM_TIMER_STATS);
569 used += sprintf(bigbuf + used, "Timers started: %i\n", fast_timers_started); 540 seq_printf(m, "Timers started: %i\n", fast_timers_started);
570 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE) ; i++) 541 for (i = 0; i < num_to_show; i++) {
571 { 542 int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
572 int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS;
573 543
574#if 1 //ndef FAST_TIMER_LOG 544#if 1 //ndef FAST_TIMER_LOG
575 used += sprintf(bigbuf + used, "div: %i freq: %i delay: %i" 545 seq_printf(m, "div: %i freq: %i delay: %i"
576 "\n", 546 "\n",
577 timer_div_settings[cur], 547 timer_div_settings[cur],
578 timer_freq_settings[cur], 548 timer_freq_settings[cur],
579 timer_delay_settings[cur] 549 timer_delay_settings[cur]);
580 );
581#endif 550#endif
582#ifdef FAST_TIMER_LOG 551#ifdef FAST_TIMER_LOG
583 t = &timer_started_log[cur]; 552 t = &timer_started_log[cur];
584 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 553 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
585 "d: %6li us data: 0x%08lX" 554 "d: %6li us data: 0x%08lX"
586 "\n", 555 "\n",
587 t->name, 556 t->name,
588 (unsigned long)t->tv_set.tv_jiff, 557 (unsigned long)t->tv_set.tv_jiff,
589 (unsigned long)t->tv_set.tv_usec, 558 (unsigned long)t->tv_set.tv_usec,
590 (unsigned long)t->tv_expires.tv_jiff, 559 (unsigned long)t->tv_expires.tv_jiff,
591 (unsigned long)t->tv_expires.tv_usec, 560 (unsigned long)t->tv_expires.tv_usec,
592 t->delay_us, 561 t->delay_us,
593 t->data 562 t->data) < 0)
594 ); 563 return 0;
595#endif 564#endif
596 } 565 }
597 used += sprintf(bigbuf + used, "\n"); 566 seq_putc(m, '\n');
598 567
599#ifdef FAST_TIMER_LOG 568#ifdef FAST_TIMER_LOG
600 num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added: 569 num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added:
601 NUM_TIMER_STATS); 570 NUM_TIMER_STATS);
602 used += sprintf(bigbuf + used, "Timers added: %i\n", fast_timers_added); 571 seq_printf(m, "Timers added: %i\n", fast_timers_added);
603 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++) 572 for (i = 0; i < num_to_show; i++) {
604 { 573 t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS];
605 t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS]; 574 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
606 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 575 "d: %6li us data: 0x%08lX"
607 "d: %6li us data: 0x%08lX" 576 "\n",
608 "\n", 577 t->name,
609 t->name, 578 (unsigned long)t->tv_set.tv_jiff,
610 (unsigned long)t->tv_set.tv_jiff, 579 (unsigned long)t->tv_set.tv_usec,
611 (unsigned long)t->tv_set.tv_usec, 580 (unsigned long)t->tv_expires.tv_jiff,
612 (unsigned long)t->tv_expires.tv_jiff, 581 (unsigned long)t->tv_expires.tv_usec,
613 (unsigned long)t->tv_expires.tv_usec, 582 t->delay_us,
614 t->delay_us, 583 t->data) < 0)
615 t->data 584 return 0;
616 ); 585 }
617 } 586 seq_putc(m, '\n');
618 used += sprintf(bigbuf + used, "\n"); 587
619 588 num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired:
620 num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired: 589 NUM_TIMER_STATS);
621 NUM_TIMER_STATS); 590 seq_printf(m, "Timers expired: %i\n", fast_timers_expired);
622 used += sprintf(bigbuf + used, "Timers expired: %i\n", fast_timers_expired); 591 for (i = 0; i < num_to_show; i++) {
623 for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++) 592 t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS];
624 { 593 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
625 t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS]; 594 "d: %6li us data: 0x%08lX"
626 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 595 "\n",
627 "d: %6li us data: 0x%08lX" 596 t->name,
628 "\n", 597 (unsigned long)t->tv_set.tv_jiff,
629 t->name, 598 (unsigned long)t->tv_set.tv_usec,
630 (unsigned long)t->tv_set.tv_jiff, 599 (unsigned long)t->tv_expires.tv_jiff,
631 (unsigned long)t->tv_set.tv_usec, 600 (unsigned long)t->tv_expires.tv_usec,
632 (unsigned long)t->tv_expires.tv_jiff, 601 t->delay_us,
633 (unsigned long)t->tv_expires.tv_usec, 602 t->data) < 0)
634 t->delay_us, 603 return 0;
635 t->data 604 }
636 ); 605 seq_putc(m, '\n');
637 }
638 used += sprintf(bigbuf + used, "\n");
639#endif 606#endif
640 607
641 used += sprintf(bigbuf + used, "Active timers:\n"); 608 seq_puts(m, "Active timers:\n");
642 local_irq_save(flags); 609 local_irq_save(flags);
643 t = fast_timer_list; 610 t = fast_timer_list;
644 while (t != NULL && (used+100 < BIG_BUF_SIZE)) 611 while (t) {
645 { 612 nextt = t->next;
646 nextt = t->next; 613 local_irq_restore(flags);
647 local_irq_restore(flags); 614 if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
648 used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " 615 "d: %6li us data: 0x%08lX"
649 "d: %6li us data: 0x%08lX"
650/* " func: 0x%08lX" */ 616/* " func: 0x%08lX" */
651 "\n", 617 "\n",
652 t->name, 618 t->name,
653 (unsigned long)t->tv_set.tv_jiff, 619 (unsigned long)t->tv_set.tv_jiff,
654 (unsigned long)t->tv_set.tv_usec, 620 (unsigned long)t->tv_set.tv_usec,
655 (unsigned long)t->tv_expires.tv_jiff, 621 (unsigned long)t->tv_expires.tv_jiff,
656 (unsigned long)t->tv_expires.tv_usec, 622 (unsigned long)t->tv_expires.tv_usec,
657 t->delay_us, 623 t->delay_us,
658 t->data 624 t->data
659/* , t->function */ 625/* , t->function */
660 ); 626 ) < 0)
661 local_irq_save(flags); 627 return 0;
662 if (t->next != nextt) 628 local_irq_save(flags);
663 { 629 if (t->next != nextt)
664 printk(KERN_WARNING "timer removed!\n"); 630 printk(KERN_WARNING "timer removed!\n");
665 } 631 t = nextt;
666 t = nextt; 632 }
667 } 633 local_irq_restore(flags);
668 local_irq_restore(flags);
669 }
670
671 if (used - offset < len)
672 {
673 len = used - offset;
674 }
675 634
676 memcpy(buf, bigbuf + offset, len); 635 return 0;
677 *start = buf; 636}
678 *eof = 1;
679 637
680 return len; 638static int proc_fasttimer_open(struct inode *inode, struct file *file)
639{
640 return single_open_size(file, proc_fasttimer_show, PDE_DATA(inode), BIG_BUF_SIZE);
681} 641}
642
643static const struct file_operations proc_fasttimer_fops = {
644 .open = proc_fasttimer_open,
645 .read = seq_read,
646 .llseek = seq_lseek,
647 .release = seq_release,
648};
682#endif /* PROC_FS */ 649#endif /* PROC_FS */
683 650
684#ifdef FAST_TIMER_TEST 651#ifdef FAST_TIMER_TEST
@@ -856,7 +823,7 @@ int fast_timer_init(void)
856 } 823 }
857#endif 824#endif
858#ifdef CONFIG_PROC_FS 825#ifdef CONFIG_PROC_FS
859 create_proc_read_entry("fasttimer", 0, NULL, proc_fasttimer_read, NULL); 826 proc_create("fasttimer", 0, NULL, &proc_fasttimer_fops);
860#endif /* PROC_FS */ 827#endif /* PROC_FS */
861 if(request_irq(TIMER1_IRQ_NBR, timer1_handler, 0, 828 if(request_irq(TIMER1_IRQ_NBR, timer1_handler, 0,
862 "fast timer int", NULL)) 829 "fast timer int", NULL))