tree: https://gitee.com/openeuler/kernel.git OLK-5.10 head: 6adee00913b51cd59245584085cdaca64f74465c commit: c7e03fb97fd2cfc439080387ea755846bc138a7f [830/30000] arm64: watchdog: add switch to select sdei_watchdog/pmu_watchdog config: arm64-randconfig-002-20240302 (https://download.01.org/0day-ci/archive/20240303/202403031229.ycxCdpan-lkp@i...) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240303/202403031229.ycxCdpan-lkp@i...)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot lkp@intel.com | Closes: https://lore.kernel.org/oe-kbuild-all/202403031229.ycxCdpan-lkp@intel.com/
All warnings (new ones prefixed by >>):
arch/arm64/kernel/watchdog_sdei.c:28:5: warning: no previous prototype for 'watchdog_sdei_enable' [-Wmissing-prototypes]
28 | int watchdog_sdei_enable(unsigned int cpu) | ^~~~~~~~~~~~~~~~~~~~
arch/arm64/kernel/watchdog_sdei.c:52:6: warning: no previous prototype for 'watchdog_sdei_disable' [-Wmissing-prototypes]
52 | void watchdog_sdei_disable(unsigned int cpu) | ^~~~~~~~~~~~~~~~~~~~~
arch/arm64/kernel/watchdog_sdei.c:114:12: warning: no previous prototype for 'watchdog_sdei_probe' [-Wmissing-prototypes]
114 | int __init watchdog_sdei_probe(void) | ^~~~~~~~~~~~~~~~~~~
vim +/watchdog_sdei_enable +28 arch/arm64/kernel/watchdog_sdei.c
27
28 int watchdog_sdei_enable(unsigned int cpu)
29 { 30 int ret; 31 32 if (!sdei_watchdog_registered) 33 return -EINVAL; 34 35 #ifdef CONFIG_HARDLOCKUP_CHECK_TIMESTAMP 36 refresh_hld_last_timestamp(); 37 #endif 38 39 __this_cpu_write(last_check_time, ktime_get_mono_fast_ns()); 40 sdei_api_set_secure_timer_period(watchdog_thresh); 41 42 ret = sdei_api_event_enable(sdei_watchdog_event_num); 43 if (ret) { 44 pr_err("Enable NMI Watchdog failed on cpu%d\n", 45 smp_processor_id()); 46 return ret; 47 } 48 49 return 0; 50 } 51
52 void watchdog_sdei_disable(unsigned int cpu)
53 { 54 int ret; 55 56 if (!sdei_watchdog_registered) 57 return; 58 59 ret = sdei_api_event_disable(sdei_watchdog_event_num); 60 if (ret) 61 pr_err("Disable NMI Watchdog failed on cpu%d\n", 62 smp_processor_id()); 63 } 64 65 static int sdei_watchdog_callback(u32 event, 66 struct pt_regs *regs, void *arg) 67 { 68 ktime_t delta, now = ktime_get_mono_fast_ns(); 69 70 delta = now - __this_cpu_read(last_check_time); 71 __this_cpu_write(last_check_time, now); 72 73 /* 74 * Set delta to 4/5 of the actual watchdog threshold period so the 75 * hrtimer is guaranteed to fire at least once within the real 76 * watchdog threshold. 77 */ 78 if (delta < watchdog_thresh * (u64)NSEC_PER_SEC * 4 / 5) { 79 pr_err(FW_BUG "SDEI Watchdog event triggered too soon, " 80 "time to last check:%lld ns\n", delta); 81 WARN_ON(1); 82 return 0; 83 } 84 85 watchdog_hardlockup_check(regs); 86 87 return 0; 88 } 89 NOKPROBE_SYMBOL(sdei_watchdog_callback); 90 91 static void sdei_nmi_watchdog_bind(void *data) 92 { 93 int ret; 94 95 ret = sdei_api_event_interrupt_bind(SDEI_NMI_WATCHDOG_HWIRQ); 96 if (ret < 0) 97 pr_err("SDEI bind failed on cpu%d, return %d\n", 98 smp_processor_id(), ret); 99 } 100 101 static int __init disable_sdei_nmi_watchdog_setup(char *str) 102 { 103 disable_sdei_nmi_watchdog = true; 104 return 1; 105 } 106 __setup("disable_sdei_nmi_watchdog", disable_sdei_nmi_watchdog_setup); 107 108 void sdei_watchdog_clear_eoi(void) 109 { 110 if (sdei_watchdog_registered) 111 sdei_api_clear_eoi(SDEI_NMI_WATCHDOG_HWIRQ); 112 } 113
114 int __init watchdog_sdei_probe(void)
115 { 116 int ret; 117 118 if (!is_hyp_mode_available()) { 119 pr_err("Disable SDEI NMI Watchdog in VM\n"); 120 return -EINVAL; 121 } 122 123 sdei_watchdog_event_num = sdei_api_event_interrupt_bind(SDEI_NMI_WATCHDOG_HWIRQ); 124 if (sdei_watchdog_event_num < 0) { 125 pr_err("Bind interrupt failed. Firmware may not support SDEI !\n"); 126 return sdei_watchdog_event_num; 127 } 128 129 /* 130 * After we introduced 'sdei_api_set_secure_timer_period', we disselect 131 * 'CONFIG_HARDLOCKUP_CHECK_TIMESTAMP'. So we need to make sure that 132 * firmware can set the period of the secure timer and the timer 133 * interrupt doesn't trigger too soon. 134 */ 135 if (sdei_api_set_secure_timer_period(watchdog_thresh)) { 136 pr_err("Firmware doesn't support setting the secure timer period, please update your BIOS !\n"); 137 return -EINVAL; 138 } 139 140 on_each_cpu(sdei_nmi_watchdog_bind, NULL, true); 141 142 ret = sdei_event_register(sdei_watchdog_event_num, 143 sdei_watchdog_callback, NULL); 144 if (ret) { 145 pr_err("SDEI Watchdog register callback failed\n"); 146 return ret; 147 } 148 149 sdei_watchdog_registered = true; 150 pr_info("SDEI Watchdog registered successfully\n"); 151 152 return 0; 153 } 154