Merge tag 'block-6.0-2022-09-16' of git://git.kernel.dk/linux-block
[linux-2.6-block.git] / include / linux / arm_sdei.h
CommitLineData
ad6eb31e
JM
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
f96935d3 8#include <acpi/ghes.h>
f9f05395
JM
9
10#ifdef CONFIG_ARM_SDE_INTERFACE
ad6eb31e 11#include <asm/sdei.h>
f9f05395 12#endif
ad6eb31e
JM
13
14/* Arch code should override this to set the entry point from firmware... */
15#ifndef sdei_arch_get_entry_point
16#define sdei_arch_get_entry_point(conduit) (0)
17#endif
18
19/*
20 * When an event occurs sdei_event_handler() will call a user-provided callback
21 * like this in NMI context on the CPU that received the event.
22 */
23typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
24
25/*
26 * Register your callback to claim an event. The event must be described
27 * by firmware.
28 */
29int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg);
30
31/*
32 * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling
33 * it until it succeeds.
34 */
35int sdei_event_unregister(u32 event_num);
36
37int sdei_event_enable(u32 event_num);
38int sdei_event_disable(u32 event_num);
39
f96935d3
JM
40/* GHES register/unregister helpers */
41int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
42 sdei_event_callback *critical_cb);
43int sdei_unregister_ghes(struct ghes *ghes);
44
ad6eb31e
JM
45#ifdef CONFIG_ARM_SDE_INTERFACE
46/* For use by arch code when CPU hotplug notifiers are not appropriate. */
47int sdei_mask_local_cpu(void);
48int sdei_unmask_local_cpu(void);
dc4e8c07 49void __init sdei_init(void);
ad6eb31e
JM
50#else
51static inline int sdei_mask_local_cpu(void) { return 0; }
52static inline int sdei_unmask_local_cpu(void) { return 0; }
dc4e8c07 53static inline void sdei_init(void) { }
ad6eb31e
JM
54#endif /* CONFIG_ARM_SDE_INTERFACE */
55
56
57/*
58 * This struct represents an event that has been registered. The driver
59 * maintains a list of all events, and which ones are registered. (Private
60 * events have one entry in the list, but are registered on each CPU).
61 * A pointer to this struct is passed to firmware, and back to the event
62 * handler. The event handler can then use this to invoke the registered
63 * callback, without having to walk the list.
64 *
65 * For CPU private events, this structure is per-cpu.
66 */
67struct sdei_registered_event {
68 /* For use by arch code: */
69 struct pt_regs interrupted_regs;
70
71 sdei_event_callback *callback;
72 void *callback_arg;
73 u32 event_num;
74 u8 priority;
75};
76
77/* The arch code entry point should then call this when an event arrives. */
78int notrace sdei_event_handler(struct pt_regs *regs,
79 struct sdei_registered_event *arg);
80
81/* arch code may use this to retrieve the extra registers. */
82int sdei_api_event_context(u32 query, u64 *result);
83
84#endif /* __LINUX_ARM_SDEI_H */