hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/drivers/firmware/arm_sdei.c
....@@ -1140,14 +1140,14 @@
11401140 return true;
11411141 }
11421142
1143
-static int __init sdei_init(void)
1143
+void __init sdei_init(void)
11441144 {
11451145 struct platform_device *pdev;
11461146 int ret;
11471147
11481148 ret = platform_driver_register(&sdei_driver);
11491149 if (ret || !sdei_present_acpi())
1150
- return ret;
1150
+ return;
11511151
11521152 pdev = platform_device_register_simple(sdei_driver.driver.name,
11531153 0, NULL, 0);
....@@ -1157,16 +1157,7 @@
11571157 pr_info("Failed to register ACPI:SDEI platform device %d\n",
11581158 ret);
11591159 }
1160
-
1161
- return ret;
11621160 }
1163
-
1164
-/*
1165
- * On an ACPI system SDEI needs to be ready before HEST:GHES tries to register
1166
- * its events. ACPI is initialised from a subsys_initcall(), GHES is initialised
1167
- * by device_initcall(). We want to be called in the middle.
1168
- */
1169
-subsys_initcall_sync(sdei_init);
11701161
11711162 int sdei_event_handler(struct pt_regs *regs,
11721163 struct sdei_registered_event *arg)
....@@ -1195,3 +1186,22 @@
11951186 return err;
11961187 }
11971188 NOKPROBE_SYMBOL(sdei_event_handler);
1189
+
1190
+void sdei_handler_abort(void)
1191
+{
1192
+ /*
1193
+ * If the crash happened in an SDEI event handler then we need to
1194
+ * finish the handler with the firmware so that we can have working
1195
+ * interrupts in the crash kernel.
1196
+ */
1197
+ if (__this_cpu_read(sdei_active_critical_event)) {
1198
+ pr_warn("still in SDEI critical event context, attempting to finish handler.\n");
1199
+ __sdei_handler_abort();
1200
+ __this_cpu_write(sdei_active_critical_event, NULL);
1201
+ }
1202
+ if (__this_cpu_read(sdei_active_normal_event)) {
1203
+ pr_warn("still in SDEI normal event context, attempting to finish handler.\n");
1204
+ __sdei_handler_abort();
1205
+ __this_cpu_write(sdei_active_normal_event, NULL);
1206
+ }
1207
+}