History

firmware: arm_sdei: Add driver for Software Delegated Exceptions

The Software Delegated Exception Interface (SDEI) is an ARM standard for registering callbacks from the platform firmware into the OS. This is typically used to implement firmware notifications (such as firmware-first RAS) or promote an IRQ that has been promoted to a firmware-assisted NMI. Add the code for detecting the SDEI version and the framework for registering and unregistering events. Subsequent patches will add the arch-specific backend code and the necessary power management hooks. Only shared events are supported, power management, private events and discovery for ACPI systems will be added by later patches.

James Morse committed 8 years ago

Commit ad6eb311 parent 86f04f67 files · +797 −0Browse files

Unified · Split

7 files
  1. MAINTAINERS +9 −0
  2. arch/arm64/include/asm/sdei.h +8 −0
  3. drivers/firmware/Kconfig +8 −0
  4. drivers/firmware/Makefile +1 −0
  5. drivers/firmware/arm_sdei.c +619 −0
  6. include/linux/arm_sdei.h +79 −0
  7. include/uapi/linux/arm_sdei.h +73 −0
MAINTAINERS+9−0
@@ -12618,6 +12618,15 @@ L: linux-media@vger.kernel.org · 12617 unmodified lines
12618S: Supported12618S: Supported
12619F: drivers/media/pci/solo6x10/12619F: drivers/media/pci/solo6x10/
12620 12620
12621SOFTWARE DELEGATED EXCEPTION INTERFACE (SDEI)
12622M: James Morse <james.morse@arm.com>
12623L: linux-arm-kernel@lists.infradead.org
12624S: Maintained
12625F: Documentation/devicetree/bindings/arm/firmware/sdei.txt
12626F: drivers/firmware/arm_sdei.c
12627F: include/linux/sdei.h
12628F: include/uapi/linux/sdei.h
12629
12621SOFTWARE RAID (Multiple Disks) SUPPORT12630SOFTWARE RAID (Multiple Disks) SUPPORT
12622M: Shaohua Li <shli@kernel.org>12631M: Shaohua Li <shli@kernel.org>
12623L: linux-raid@vger.kernel.org12632L: linux-raid@vger.kernel.org
arch/arm64/include/asm/sdei.h+8−0
@@ -0,0 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2017 Arm Ltd.
3#ifndef __ASM_SDEI_H
4#define __ASM_SDEI_H
5
6/* Later patches add the arch specific bits */
7
8#endif /* __ASM_SDEI_H */
drivers/firmware/Kconfig+8−0
@@ -48,6 +48,14 @@ config ARM_SCPI_POWER_DOMAIN · 47 unmodified lines
48 This enables support for the SCPI power domains which can be48 This enables support for the SCPI power domains which can be
49 enabled or disabled via the SCP firmware49 enabled or disabled via the SCP firmware
50 50
51config ARM_SDE_INTERFACE
52 bool "ARM Software Delegated Exception Interface (SDEI)"
53 depends on ARM64
54 help
55 The Software Delegated Exception Interface (SDEI) is an ARM
56 standard for registering callbacks from the platform firmware
57 into the OS. This is typically used to implement RAS notifications.
58
51config EDD59config EDD
52 tristate "BIOS Enhanced Disk Drive calls determine boot disk"60 tristate "BIOS Enhanced Disk Drive calls determine boot disk"
53 depends on X8661 depends on X86
drivers/firmware/Makefile+1−0
@@ -6,6 +6,7 @@ obj-$(CONFIG_ARM_PSCI_FW) += psci.o · 5 unmodified lines
6obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o6obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o
7obj-$(CONFIG_ARM_SCPI_PROTOCOL) += arm_scpi.o7obj-$(CONFIG_ARM_SCPI_PROTOCOL) += arm_scpi.o
8obj-$(CONFIG_ARM_SCPI_POWER_DOMAIN) += scpi_pm_domain.o8obj-$(CONFIG_ARM_SCPI_POWER_DOMAIN) += scpi_pm_domain.o
9obj-$(CONFIG_ARM_SDE_INTERFACE) += arm_sdei.o
9obj-$(CONFIG_DMI) += dmi_scan.o10obj-$(CONFIG_DMI) += dmi_scan.o
10obj-$(CONFIG_DMI_SYSFS) += dmi-sysfs.o11obj-$(CONFIG_DMI_SYSFS) += dmi-sysfs.o
11obj-$(CONFIG_EDD) += edd.o12obj-$(CONFIG_EDD) += edd.o
drivers/firmware/arm_sdei.c+619−0
@@ -0,0 +1,619 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2017 Arm Ltd.
3#define pr_fmt(fmt) "sdei: " fmt
4
5#include <linux/acpi.h>
6#include <linux/arm_sdei.h>
7#include <linux/arm-smccc.h>
8#include <linux/bitops.h>
9#include <linux/compiler.h>
10#include <linux/errno.h>
11#include <linux/hardirq.h>
12#include <linux/kernel.h>
13#include <linux/kprobes.h>
14#include <linux/kvm_host.h>
15#include <linux/list.h>
16#include <linux/mutex.h>
17#include <linux/of.h>
18#include <linux/of_platform.h>
19#include <linux/percpu.h>
20#include <linux/platform_device.h>
21#include <linux/ptrace.h>
22#include <linux/preempt.h>
23#include <linux/slab.h>
24#include <linux/smp.h>
25#include <linux/spinlock.h>
26#include <linux/uaccess.h>
27
28/*
29 * The call to use to reach the firmware.
30 */
31static asmlinkage void (*sdei_firmware_call)(unsigned long function_id,
32 unsigned long arg0, unsigned long arg1,
33 unsigned long arg2, unsigned long arg3,
34 unsigned long arg4, struct arm_smccc_res *res);
35
36/* entry point from firmware to arch asm code */
37static unsigned long sdei_entry_point;
38
39struct sdei_event {
40 struct list_head list;
41 u32 event_num;
42 u8 type;
43 u8 priority;
44
45 /* This pointer is handed to firmware as the event argument. */
46 struct sdei_registered_event *registered;
47};
48
49/* Take the mutex for any API call or modification. Take the mutex first. */
50static DEFINE_MUTEX(sdei_events_lock);
51
52/* and then hold this when modifying the list */
53static DEFINE_SPINLOCK(sdei_list_lock);
54static LIST_HEAD(sdei_list);
55
56static int sdei_to_linux_errno(unsigned long sdei_err)
57{
58 switch (sdei_err) {
59 case SDEI_NOT_SUPPORTED:
60 return -EOPNOTSUPP;
61 case SDEI_INVALID_PARAMETERS:
62 return -EINVAL;
63 case SDEI_DENIED:
64 return -EPERM;
65 case SDEI_PENDING:
66 return -EINPROGRESS;
67 case SDEI_OUT_OF_RESOURCE:
68 return -ENOMEM;
69 }
70
71 /* Not an error value ... */
72 return sdei_err;
73}
74
75/*
76 * If x0 is any of these values, then the call failed, use sdei_to_linux_errno()
77 * to translate.
78 */
79static int sdei_is_err(struct arm_smccc_res *res)
80{
81 switch (res->a0) {
82 case SDEI_NOT_SUPPORTED:
83 case SDEI_INVALID_PARAMETERS:
84 case SDEI_DENIED:
85 case SDEI_PENDING:
86 case SDEI_OUT_OF_RESOURCE:
87 return true;
88 }
89
90 return false;
91}
92
93static int invoke_sdei_fn(unsigned long function_id, unsigned long arg0,
94 unsigned long arg1, unsigned long arg2,
95 unsigned long arg3, unsigned long arg4,
96 u64 *result)
97{
98 int err = 0;
99 struct arm_smccc_res res;
100
101 if (sdei_firmware_call) {
102 sdei_firmware_call(function_id, arg0, arg1, arg2, arg3, arg4,
103 &res);
104 if (sdei_is_err(&res))
105 err = sdei_to_linux_errno(res.a0);
106 } else {
107 /*
108 * !sdei_firmware_call means we failed to probe or called
109 * sdei_mark_interface_broken(). -EIO is not an error returned
110 * by sdei_to_linux_errno() and is used to suppress messages
111 * from this driver.
112 */
113 err = -EIO;
114 res.a0 = SDEI_NOT_SUPPORTED;
115 }
116
117 if (result)
118 *result = res.a0;
119
120 return err;
121}
122
123static struct sdei_event *sdei_event_find(u32 event_num)
124{
125 struct sdei_event *e, *found = NULL;
126
127 lockdep_assert_held(&sdei_events_lock);
128
129 spin_lock(&sdei_list_lock);
130 list_for_each_entry(e, &sdei_list, list) {
131 if (e->event_num == event_num) {
132 found = e;
133 break;
134 }
135 }
136 spin_unlock(&sdei_list_lock);
137
138 return found;
139}
140
141int sdei_api_event_context(u32 query, u64 *result)
142{
143 return invoke_sdei_fn(SDEI_1_0_FN_SDEI_EVENT_CONTEXT, query, 0, 0, 0, 0,
144 result);
145}
146NOKPROBE_SYMBOL(sdei_api_event_context);
147
148static int sdei_api_event_get_info(u32 event, u32 info, u64 *result)
149{
150 return invoke_sdei_fn(SDEI_1_0_FN_SDEI_EVENT_GET_INFO, event, info, 0,
151 0, 0, result);
152}
153
154static struct sdei_event *sdei_event_create(u32 event_num,
155 sdei_event_callback *cb,
156 void *cb_arg)
157{
158 int err;
159 u64 result;
160 struct sdei_event *event;
161 struct sdei_registered_event *reg;
162
163 lockdep_assert_held(&sdei_events_lock);
164
165 event = kzalloc(sizeof(*event), GFP_KERNEL);
166 if (!event)
167 return ERR_PTR(-ENOMEM);
168
169 INIT_LIST_HEAD(&event->list);
170 event->event_num = event_num;
171
172 err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_PRIORITY,
173 &result);
174 if (err) {
175 kfree(event);
176 return ERR_PTR(err);
177 }
178 event->priority = result;
179
180 err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_TYPE,
181 &result);
182 if (err) {
183 kfree(event);
184 return ERR_PTR(err);
185 }
186 event->type = result;
187
188 if (event->type == SDEI_EVENT_TYPE_SHARED) {
189 reg = kzalloc(sizeof(*reg), GFP_KERNEL);
190 if (!reg) {
191 kfree(event);
192 return ERR_PTR(-ENOMEM);
193 }
194
195 reg->event_num = event_num;
196 reg->priority = event->priority;
197
198 reg->callback = cb;
199 reg->callback_arg = cb_arg;
200 event->registered = reg;
201 }
202
203 if (sdei_event_find(event_num)) {
204 kfree(event->registered);
205 kfree(event);
206 event = ERR_PTR(-EBUSY);
207 } else {
208 spin_lock(&sdei_list_lock);
209 list_add(&event->list, &sdei_list);
210 spin_unlock(&sdei_list_lock);
211 }
212
213 return event;
214}
215
216static void sdei_event_destroy(struct sdei_event *event)
217{
218 lockdep_assert_held(&sdei_events_lock);
219
220 spin_lock(&sdei_list_lock);
221 list_del(&event->list);
222 spin_unlock(&sdei_list_lock);
223
224 if (event->type == SDEI_EVENT_TYPE_SHARED)
225 kfree(event->registered);
226
227 kfree(event);
228}
229
230static int sdei_api_get_version(u64 *version)
231{
232 return invoke_sdei_fn(SDEI_1_0_FN_SDEI_VERSION, 0, 0, 0, 0, 0, version);
233}
234
235int sdei_mask_local_cpu(void)
236{
237 int err;
238
239 WARN_ON_ONCE(preemptible());
240
241 err = invoke_sdei_fn(SDEI_1_0_FN_SDEI_PE_MASK, 0, 0, 0, 0, 0, NULL);
242 if (err && err != -EIO) {
243 pr_warn_once("failed to mask CPU[%u]: %d\n",
244 smp_processor_id(), err);
245 return err;
246 }
247
248 return 0;
249}
250
251static void _ipi_mask_cpu(void *ignored)
252{
253 sdei_mask_local_cpu();
254}
255
256int sdei_unmask_local_cpu(void)
257{
258 int err;
259
260 WARN_ON_ONCE(preemptible());
261
262 err = invoke_sdei_fn(SDEI_1_0_FN_SDEI_PE_UNMASK, 0, 0, 0, 0, 0, NULL);
263 if (err && err != -EIO) {
264 pr_warn_once("failed to unmask CPU[%u]: %d\n",
265 smp_processor_id(), err);
266 return err;
267 }
268
269 return 0;
270}
271
272static void _ipi_unmask_cpu(void *ignored)
273{
274 sdei_unmask_local_cpu();
275}
276
277static void _ipi_private_reset(void *ignored)
278{
279 int err;
280
281 err = invoke_sdei_fn(SDEI_1_0_FN_SDEI_PRIVATE_RESET, 0, 0, 0, 0, 0,
282 NULL);
283 if (err && err != -EIO)
284 pr_warn_once("failed to reset CPU[%u]: %d\n",
285 smp_processor_id(), err);
286}
287
288static int sdei_api_shared_reset(void)
289{
290 return invoke_sdei_fn(SDEI_1_0_FN_SDEI_SHARED_RESET, 0, 0, 0, 0, 0,
291 NULL);
292}
293
294static void sdei_mark_interface_broken(void)
295{
296 pr_err("disabling SDEI firmware interface\n");
297 on_each_cpu(&_ipi_mask_cpu, NULL, true);
298 sdei_firmware_call = NULL;
299}
300
301static int sdei_platform_reset(void)
302{
303 int err;
304
305 on_each_cpu(&_ipi_private_reset, NULL, true);
306 err = sdei_api_shared_reset();
307 if (err) {
308 pr_err("Failed to reset platform: %d\n", err);
309 sdei_mark_interface_broken();
310 }
311
312 return err;
313}
314
315static int sdei_api_event_enable(u32 event_num)
316{
317 return invoke_sdei_fn(SDEI_1_0_FN_SDEI_EVENT_ENABLE, event_num, 0, 0, 0,
318 0, NULL);
319}
320
321int sdei_event_enable(u32 event_num)
322{
323 int err = -EINVAL;
324 struct sdei_event *event;
325
326 mutex_lock(&sdei_events_lock);
327 event = sdei_event_find(event_num);
328 if (!event) {
329 mutex_unlock(&sdei_events_lock);
330 return -ENOENT;
331 }
332
333 if (event->type == SDEI_EVENT_TYPE_SHARED)
334 err = sdei_api_event_enable(event->event_num);
335 mutex_unlock(&sdei_events_lock);
336
337 return err;
338}
339EXPORT_SYMBOL(sdei_event_enable);
340
341static int sdei_api_event_disable(u32 event_num)
342{
343 return invoke_sdei_fn(SDEI_1_0_FN_SDEI_EVENT_DISABLE, event_num, 0, 0,
344 0, 0, NULL);
345}
346
347int sdei_event_disable(u32 event_num)
348{
349 int err = -EINVAL;
350 struct sdei_event *event;
351
352 mutex_lock(&sdei_events_lock);
353 event = sdei_event_find(event_num);
354 if (!event) {
355 mutex_unlock(&sdei_events_lock);
356 return -ENOENT;
357 }
358
359 if (event->type == SDEI_EVENT_TYPE_SHARED)
360 err = sdei_api_event_disable(event->event_num);
361 mutex_unlock(&sdei_events_lock);
362
363 return err;
364}
365EXPORT_SYMBOL(sdei_event_disable);
366
367static int sdei_api_event_unregister(u32 event_num)
368{
369 return invoke_sdei_fn(SDEI_1_0_FN_SDEI_EVENT_UNREGISTER, event_num, 0,
370 0, 0, 0, NULL);
371}
372
373static int _sdei_event_unregister(struct sdei_event *event)
374{
375 lockdep_assert_held(&sdei_events_lock);
376
377 if (event->type == SDEI_EVENT_TYPE_SHARED)
378 return sdei_api_event_unregister(event->event_num);
379
380 return -EINVAL;
381}
382
383int sdei_event_unregister(u32 event_num)
384{
385 int err;
386 struct sdei_event *event;
387
388 WARN_ON(in_nmi());
389
390 mutex_lock(&sdei_events_lock);
391 event = sdei_event_find(event_num);
392 do {
393 if (!event) {
394 pr_warn("Event %u not registered\n", event_num);
395 err = -ENOENT;
396 break;
397 }
398
399 err = _sdei_event_unregister(event);
400 if (err)
401 break;
402
403 sdei_event_destroy(event);
404 } while (0);
405 mutex_unlock(&sdei_events_lock);
406
407 return err;
408}
409EXPORT_SYMBOL(sdei_event_unregister);
410
411static int sdei_api_event_register(u32 event_num, unsigned long entry_point,
412 void *arg, u64 flags, u64 affinity)
413{
414 return invoke_sdei_fn(SDEI_1_0_FN_SDEI_EVENT_REGISTER, event_num,
415 (unsigned long)entry_point, (unsigned long)arg,
416 flags, affinity, NULL);
417}
418
419static int _sdei_event_register(struct sdei_event *event)
420{
421 lockdep_assert_held(&sdei_events_lock);
422
423 if (event->type == SDEI_EVENT_TYPE_SHARED)
424 return sdei_api_event_register(event->event_num,
425 sdei_entry_point,
426 event->registered,
427 SDEI_EVENT_REGISTER_RM_ANY, 0);
428
429 return -EINVAL;
430}
431
432int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
433{
434 int err;
435 struct sdei_event *event;
436
437 WARN_ON(in_nmi());
438
439 mutex_lock(&sdei_events_lock);
440 do {
441 if (sdei_event_find(event_num)) {
442 pr_warn("Event %u already registered\n", event_num);
443 err = -EBUSY;
444 break;
445 }
446
447 event = sdei_event_create(event_num, cb, arg);
448 if (IS_ERR(event)) {
449 err = PTR_ERR(event);
450 pr_warn("Failed to create event %u: %d\n", event_num,
451 err);
452 break;
453 }
454
455 err = _sdei_event_register(event);
456 if (err) {
457 sdei_event_destroy(event);
458 pr_warn("Failed to register event %u: %d\n", event_num,
459 err);
460 }
461 } while (0);
462 mutex_unlock(&sdei_events_lock);
463
464 return err;
465}
466EXPORT_SYMBOL(sdei_event_register);
467
468static void sdei_smccc_smc(unsigned long function_id,
469 unsigned long arg0, unsigned long arg1,
470 unsigned long arg2, unsigned long arg3,
471 unsigned long arg4, struct arm_smccc_res *res)
472{
473 arm_smccc_smc(function_id, arg0, arg1, arg2, arg3, arg4, 0, 0, res);
474}
475
476static void sdei_smccc_hvc(unsigned long function_id,
477 unsigned long arg0, unsigned long arg1,
478 unsigned long arg2, unsigned long arg3,
479 unsigned long arg4, struct arm_smccc_res *res)
480{
481 arm_smccc_hvc(function_id, arg0, arg1, arg2, arg3, arg4, 0, 0, res);
482}
483
484static int sdei_get_conduit(struct platform_device *pdev)
485{
486 const char *method;
487 struct device_node *np = pdev->dev.of_node;
488
489 sdei_firmware_call = NULL;
490 if (np) {
491 if (of_property_read_string(np, "method", &method)) {
492 pr_warn("missing \"method\" property\n");
493 return CONDUIT_INVALID;
494 }
495
496 if (!strcmp("hvc", method)) {
497 sdei_firmware_call = &sdei_smccc_hvc;
498 return CONDUIT_HVC;
499 } else if (!strcmp("smc", method)) {
500 sdei_firmware_call = &sdei_smccc_smc;
501 return CONDUIT_SMC;
502 }
503
504 pr_warn("invalid \"method\" property: %s\n", method);
505 }
506
507 return CONDUIT_INVALID;
508}
509
510static int sdei_probe(struct platform_device *pdev)
511{
512 int err;
513 u64 ver = 0;
514 int conduit;
515
516 conduit = sdei_get_conduit(pdev);
517 if (!sdei_firmware_call)
518 return 0;
519
520 err = sdei_api_get_version(&ver);
521 if (err == -EOPNOTSUPP)
522 pr_err("advertised but not implemented in platform firmware\n");
523 if (err) {
524 pr_err("Failed to get SDEI version: %d\n", err);
525 sdei_mark_interface_broken();
526 return err;
527 }
528
529 pr_info("SDEIv%d.%d (0x%x) detected in firmware.\n",
530 (int)SDEI_VERSION_MAJOR(ver), (int)SDEI_VERSION_MINOR(ver),
531 (int)SDEI_VERSION_VENDOR(ver));
532
533 if (SDEI_VERSION_MAJOR(ver) != 1) {
534 pr_warn("Conflicting SDEI version detected.\n");
535 sdei_mark_interface_broken();
536 return -EINVAL;
537 }
538
539 err = sdei_platform_reset();
540 if (err)
541 return err;
542
543 sdei_entry_point = sdei_arch_get_entry_point(conduit);
544 if (!sdei_entry_point) {
545 /* Not supported due to hardware or boot configuration */
546 sdei_mark_interface_broken();
547 return 0;
548 }
549
550 on_each_cpu(&_ipi_unmask_cpu, NULL, false);
551
552 return 0;
553}
554
555static const struct of_device_id sdei_of_match[] = {
556 { .compatible = "arm,sdei-1.0" },
557 {}
558};
559
560static struct platform_driver sdei_driver = {
561 .driver = {
562 .name = "sdei",
563 .of_match_table = sdei_of_match,
564 },
565 .probe = sdei_probe,
566};
567
568static bool __init sdei_present_dt(void)
569{
570 struct platform_device *pdev;
571 struct device_node *np, *fw_np;
572
573 fw_np = of_find_node_by_name(NULL, "firmware");
574 if (!fw_np)
575 return false;
576
577 np = of_find_matching_node(fw_np, sdei_of_match);
578 of_node_put(fw_np);
579 if (!np)
580 return false;
581
582 pdev = of_platform_device_create(np, sdei_driver.driver.name, NULL);
583 of_node_put(np);
584 if (IS_ERR(pdev))
585 return false;
586
587 return true;
588}
589
590static int __init sdei_init(void)
591{
592 if (sdei_present_dt())
593 platform_driver_register(&sdei_driver);
594
595 return 0;
596}
597
598subsys_initcall_sync(sdei_init);
599
600int sdei_event_handler(struct pt_regs *regs,
601 struct sdei_registered_event *arg)
602{
603 int err;
604 mm_segment_t orig_addr_limit;
605 u32 event_num = arg->event_num;
606
607 orig_addr_limit = get_fs();
608 set_fs(USER_DS);
609
610 err = arg->callback(event_num, regs, arg->callback_arg);
611 if (err)
612 pr_err_ratelimited("event %u on CPU %u failed with error: %d\n",
613 event_num, smp_processor_id(), err);
614
615 set_fs(orig_addr_limit);
616
617 return err;
618}
619NOKPROBE_SYMBOL(sdei_event_handler);
include/linux/arm_sdei.h+79−0
@@ -0,0 +1,79 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2017 Arm Ltd.
3#ifndef __LINUX_ARM_SDEI_H
4#define __LINUX_ARM_SDEI_H
5
6#include <uapi/linux/arm_sdei.h>
7
8enum sdei_conduit_types {
9 CONDUIT_INVALID = 0,
10 CONDUIT_SMC,
11 CONDUIT_HVC,
12};
13
14#include <asm/sdei.h>
15
16/* Arch code should override this to set the entry point from firmware... */
17#ifndef sdei_arch_get_entry_point
18#define sdei_arch_get_entry_point(conduit) (0)
19#endif
20
21/*
22 * When an event occurs sdei_event_handler() will call a user-provided callback
23 * like this in NMI context on the CPU that received the event.
24 */
25typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
26
27/*
28 * Register your callback to claim an event. The event must be described
29 * by firmware.
30 */
31int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg);
32
33/*
34 * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling
35 * it until it succeeds.
36 */
37int sdei_event_unregister(u32 event_num);
38
39int sdei_event_enable(u32 event_num);
40int sdei_event_disable(u32 event_num);
41
42#ifdef CONFIG_ARM_SDE_INTERFACE
43/* For use by arch code when CPU hotplug notifiers are not appropriate. */
44int sdei_mask_local_cpu(void);
45int sdei_unmask_local_cpu(void);
46#else
47static inline int sdei_mask_local_cpu(void) { return 0; }
48static inline int sdei_unmask_local_cpu(void) { return 0; }
49#endif /* CONFIG_ARM_SDE_INTERFACE */
50
51
52/*
53 * This struct represents an event that has been registered. The driver
54 * maintains a list of all events, and which ones are registered. (Private
55 * events have one entry in the list, but are registered on each CPU).
56 * A pointer to this struct is passed to firmware, and back to the event
57 * handler. The event handler can then use this to invoke the registered
58 * callback, without having to walk the list.
59 *
60 * For CPU private events, this structure is per-cpu.
61 */
62struct sdei_registered_event {
63 /* For use by arch code: */
64 struct pt_regs interrupted_regs;
65
66 sdei_event_callback *callback;
67 void *callback_arg;
68 u32 event_num;
69 u8 priority;
70};
71
72/* The arch code entry point should then call this when an event arrives. */
73int notrace sdei_event_handler(struct pt_regs *regs,
74 struct sdei_registered_event *arg);
75
76/* arch code may use this to retrieve the extra registers. */
77int sdei_api_event_context(u32 query, u64 *result);
78
79#endif /* __LINUX_ARM_SDEI_H */
include/uapi/linux/arm_sdei.h+73−0
@@ -0,0 +1,73 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/* Copyright (C) 2017 Arm Ltd. */
3#ifndef _UAPI_LINUX_ARM_SDEI_H
4#define _UAPI_LINUX_ARM_SDEI_H
5
6#define SDEI_1_0_FN_BASE 0xC4000020
7#define SDEI_1_0_MASK 0xFFFFFFE0
8#define SDEI_1_0_FN(n) (SDEI_1_0_FN_BASE + (n))
9
10#define SDEI_1_0_FN_SDEI_VERSION SDEI_1_0_FN(0x00)
11#define SDEI_1_0_FN_SDEI_EVENT_REGISTER SDEI_1_0_FN(0x01)
12#define SDEI_1_0_FN_SDEI_EVENT_ENABLE SDEI_1_0_FN(0x02)
13#define SDEI_1_0_FN_SDEI_EVENT_DISABLE SDEI_1_0_FN(0x03)
14#define SDEI_1_0_FN_SDEI_EVENT_CONTEXT SDEI_1_0_FN(0x04)
15#define SDEI_1_0_FN_SDEI_EVENT_COMPLETE SDEI_1_0_FN(0x05)
16#define SDEI_1_0_FN_SDEI_EVENT_COMPLETE_AND_RESUME SDEI_1_0_FN(0x06)
17#define SDEI_1_0_FN_SDEI_EVENT_UNREGISTER SDEI_1_0_FN(0x07)
18#define SDEI_1_0_FN_SDEI_EVENT_STATUS SDEI_1_0_FN(0x08)
19#define SDEI_1_0_FN_SDEI_EVENT_GET_INFO SDEI_1_0_FN(0x09)
20#define SDEI_1_0_FN_SDEI_EVENT_ROUTING_SET SDEI_1_0_FN(0x0A)
21#define SDEI_1_0_FN_SDEI_PE_MASK SDEI_1_0_FN(0x0B)
22#define SDEI_1_0_FN_SDEI_PE_UNMASK SDEI_1_0_FN(0x0C)
23#define SDEI_1_0_FN_SDEI_INTERRUPT_BIND SDEI_1_0_FN(0x0D)
24#define SDEI_1_0_FN_SDEI_INTERRUPT_RELEASE SDEI_1_0_FN(0x0E)
25#define SDEI_1_0_FN_SDEI_PRIVATE_RESET SDEI_1_0_FN(0x11)
26#define SDEI_1_0_FN_SDEI_SHARED_RESET SDEI_1_0_FN(0x12)
27
28#define SDEI_VERSION_MAJOR_SHIFT 48
29#define SDEI_VERSION_MAJOR_MASK 0x7fff
30#define SDEI_VERSION_MINOR_SHIFT 32
31#define SDEI_VERSION_MINOR_MASK 0xffff
32#define SDEI_VERSION_VENDOR_SHIFT 0
33#define SDEI_VERSION_VENDOR_MASK 0xffffffff
34
35#define SDEI_VERSION_MAJOR(x) (x>>SDEI_VERSION_MAJOR_SHIFT & SDEI_VERSION_MAJOR_MASK)
36#define SDEI_VERSION_MINOR(x) (x>>SDEI_VERSION_MINOR_SHIFT & SDEI_VERSION_MINOR_MASK)
37#define SDEI_VERSION_VENDOR(x) (x>>SDEI_VERSION_VENDOR_SHIFT & SDEI_VERSION_VENDOR_MASK)
38
39/* SDEI return values */
40#define SDEI_SUCCESS 0
41#define SDEI_NOT_SUPPORTED -1
42#define SDEI_INVALID_PARAMETERS -2
43#define SDEI_DENIED -3
44#define SDEI_PENDING -5
45#define SDEI_OUT_OF_RESOURCE -10
46
47/* EVENT_REGISTER flags */
48#define SDEI_EVENT_REGISTER_RM_ANY 0
49#define SDEI_EVENT_REGISTER_RM_PE 1
50
51/* EVENT_STATUS return value bits */
52#define SDEI_EVENT_STATUS_RUNNING 2
53#define SDEI_EVENT_STATUS_ENABLED 1
54#define SDEI_EVENT_STATUS_REGISTERED 0
55
56/* EVENT_COMPLETE status values */
57#define SDEI_EV_HANDLED 0
58#define SDEI_EV_FAILED 1
59
60/* GET_INFO values */
61#define SDEI_EVENT_INFO_EV_TYPE 0
62#define SDEI_EVENT_INFO_EV_SIGNALED 1
63#define SDEI_EVENT_INFO_EV_PRIORITY 2
64#define SDEI_EVENT_INFO_EV_ROUTING_MODE 3
65#define SDEI_EVENT_INFO_EV_ROUTING_AFF 4
66
67/* and their results */
68#define SDEI_EVENT_TYPE_PRIVATE 0
69#define SDEI_EVENT_TYPE_SHARED 1
70#define SDEI_EVENT_PRIORITY_NORMAL 0
71#define SDEI_EVENT_PRIORITY_CRITICAL 1
72
73#endif /* _UAPI_LINUX_ARM_SDEI_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t