@@ -39,8 +39,10 @@ static bool illegal_handler_invoked;
39
39
#define SBI_PMU_TEST_SNAPSHOT BIT(2)
40
40
#define SBI_PMU_TEST_OVERFLOW BIT(3)
41
41
42
+ #define SBI_PMU_OVERFLOW_IRQNUM_DEFAULT 5
42
43
struct test_args {
43
44
int disabled_tests ;
45
+ int overflow_irqnum ;
44
46
};
45
47
46
48
static struct test_args targs ;
@@ -478,7 +480,7 @@ static void test_pmu_events_snaphost(void)
478
480
479
481
static void test_pmu_events_overflow (void )
480
482
{
481
- int num_counters = 0 ;
483
+ int num_counters = 0 , i = 0 ;
482
484
483
485
/* Verify presence of SBI PMU and minimum requrired SBI version */
484
486
verify_sbi_requirement_assert ();
@@ -495,11 +497,15 @@ static void test_pmu_events_overflow(void)
495
497
* Qemu supports overflow for cycle/instruction.
496
498
* This test may fail on any platform that do not support overflow for these two events.
497
499
*/
498
- test_pmu_event_overflow (SBI_PMU_HW_CPU_CYCLES );
499
- GUEST_ASSERT_EQ (vcpu_shared_irq_count , 1 );
500
+ for (i = 0 ; i < targs .overflow_irqnum ; i ++ )
501
+ test_pmu_event_overflow (SBI_PMU_HW_CPU_CYCLES );
502
+ GUEST_ASSERT_EQ (vcpu_shared_irq_count , targs .overflow_irqnum );
503
+
504
+ vcpu_shared_irq_count = 0 ;
500
505
501
- test_pmu_event_overflow (SBI_PMU_HW_INSTRUCTIONS );
502
- GUEST_ASSERT_EQ (vcpu_shared_irq_count , 2 );
506
+ for (i = 0 ; i < targs .overflow_irqnum ; i ++ )
507
+ test_pmu_event_overflow (SBI_PMU_HW_INSTRUCTIONS );
508
+ GUEST_ASSERT_EQ (vcpu_shared_irq_count , targs .overflow_irqnum );
503
509
504
510
GUEST_DONE ();
505
511
}
@@ -621,8 +627,11 @@ static void test_vm_events_overflow(void *guest_code)
621
627
622
628
static void test_print_help (char * name )
623
629
{
624
- pr_info ("Usage: %s [-h] [-t <test name>]\n" , name );
630
+ pr_info ("Usage: %s [-h] [-t <test name>] [-n <number of LCOFI interrupt for overflow test>]\n" ,
631
+ name );
625
632
pr_info ("\t-t: Test to run (default all). Available tests are 'basic', 'events', 'snapshot', 'overflow'\n" );
633
+ pr_info ("\t-n: Number of LCOFI interrupt to trigger for each event in overflow test (default: %d)\n" ,
634
+ SBI_PMU_OVERFLOW_IRQNUM_DEFAULT );
626
635
pr_info ("\t-h: print this help screen\n" );
627
636
}
628
637
@@ -631,7 +640,9 @@ static bool parse_args(int argc, char *argv[])
631
640
int opt ;
632
641
int temp_disabled_tests = SBI_PMU_TEST_BASIC | SBI_PMU_TEST_EVENTS | SBI_PMU_TEST_SNAPSHOT |
633
642
SBI_PMU_TEST_OVERFLOW ;
634
- while ((opt = getopt (argc , argv , "ht:" )) != -1 ) {
643
+ int overflow_interrupts = 0 ;
644
+
645
+ while ((opt = getopt (argc , argv , "ht:n:" )) != -1 ) {
635
646
switch (opt ) {
636
647
case 't' :
637
648
if (!strncmp ("basic" , optarg , 5 ))
@@ -646,12 +657,24 @@ static bool parse_args(int argc, char *argv[])
646
657
goto done ;
647
658
targs .disabled_tests = temp_disabled_tests ;
648
659
break ;
660
+ case 'n' :
661
+ overflow_interrupts = atoi_positive ("Number of LCOFI" , optarg );
662
+ break ;
649
663
case 'h' :
650
664
default :
651
665
goto done ;
652
666
}
653
667
}
654
668
669
+ if (overflow_interrupts > 0 ) {
670
+ if (targs .disabled_tests & SBI_PMU_TEST_OVERFLOW ) {
671
+ pr_info ("-n option is only available for overflow test\n" );
672
+ goto done ;
673
+ } else {
674
+ targs .overflow_irqnum = overflow_interrupts ;
675
+ }
676
+ }
677
+
655
678
return true;
656
679
done :
657
680
test_print_help (argv [0 ]);
@@ -661,6 +684,7 @@ static bool parse_args(int argc, char *argv[])
661
684
int main (int argc , char * argv [])
662
685
{
663
686
targs .disabled_tests = 0 ;
687
+ targs .overflow_irqnum = SBI_PMU_OVERFLOW_IRQNUM_DEFAULT ;
664
688
665
689
if (!parse_args (argc , argv ))
666
690
exit (KSFT_SKIP );
0 commit comments