1*203fe346SNico Boehr /* SPDX-License-Identifier: GPL-2.0-only */ 2*203fe346SNico Boehr /* 3*203fe346SNico Boehr * External interrupt loop test 4*203fe346SNico Boehr * 5*203fe346SNico Boehr * Copyright IBM Corp. 2022 6*203fe346SNico Boehr * 7*203fe346SNico Boehr * Authors: 8*203fe346SNico Boehr * Nico Boehr <nrb@linux.ibm.com> 9*203fe346SNico Boehr */ 10*203fe346SNico Boehr #include <libcflat.h> 11*203fe346SNico Boehr #include <asm/interrupt.h> 12*203fe346SNico Boehr #include <asm/barrier.h> 13*203fe346SNico Boehr #include <asm/time.h> 14*203fe346SNico Boehr #include <hardware.h> 15*203fe346SNico Boehr #include <bitops.h> 16*203fe346SNico Boehr ext_int_cleanup(struct stack_frame_int * stack)17*203fe346SNico Boehrstatic void ext_int_cleanup(struct stack_frame_int *stack) 18*203fe346SNico Boehr { 19*203fe346SNico Boehr /* 20*203fe346SNico Boehr * Since we form a loop of ext interrupts, this code should never be 21*203fe346SNico Boehr * executed. In case it is executed, something went wrong and we want to 22*203fe346SNico Boehr * print a failure. 23*203fe346SNico Boehr * 24*203fe346SNico Boehr * Because the CPU timer subclass mask is still enabled, the CPU timer 25*203fe346SNico Boehr * interrupt will fire every time we enable external interrupts, 26*203fe346SNico Boehr * preventing us from printing the failure on the console. To avoid 27*203fe346SNico Boehr * this, clear the CPU timer subclass mask here. 28*203fe346SNico Boehr */ 29*203fe346SNico Boehr stack->crs[0] &= ~BIT(CTL0_CPU_TIMER); 30*203fe346SNico Boehr } 31*203fe346SNico Boehr main(void)32*203fe346SNico Boehrint main(void) 33*203fe346SNico Boehr { 34*203fe346SNico Boehr report_prefix_push("panic-loop-extint"); 35*203fe346SNico Boehr 36*203fe346SNico Boehr if (!host_is_qemu() || host_is_tcg()) { 37*203fe346SNico Boehr report_skip("QEMU-KVM-only test"); 38*203fe346SNico Boehr goto out; 39*203fe346SNico Boehr } 40*203fe346SNico Boehr 41*203fe346SNico Boehr expect_ext_int(); 42*203fe346SNico Boehr lowcore.ext_new_psw.mask |= PSW_MASK_EXT; 43*203fe346SNico Boehr 44*203fe346SNico Boehr psw_mask_set_bits(PSW_MASK_EXT); 45*203fe346SNico Boehr 46*203fe346SNico Boehr register_ext_cleanup_func(ext_int_cleanup); 47*203fe346SNico Boehr 48*203fe346SNico Boehr cpu_timer_set_ms(10); 49*203fe346SNico Boehr ctl_set_bit(0, CTL0_CPU_TIMER); 50*203fe346SNico Boehr mdelay(2000); 51*203fe346SNico Boehr 52*203fe346SNico Boehr register_ext_cleanup_func(NULL); 53*203fe346SNico Boehr 54*203fe346SNico Boehr report_fail("survived extint loop"); 55*203fe346SNico Boehr 56*203fe346SNico Boehr out: 57*203fe346SNico Boehr report_prefix_pop(); 58*203fe346SNico Boehr return report_summary(); 59*203fe346SNico Boehr } 60