1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_EVENT_H__
3 #define __NVKM_EVENT_H__
10 const struct nvkm_event_func *func;
11 struct nvkm_subdev *subdev;
20 struct list_head ntfy;
23 struct nvkm_event_func {
24 void (*init)(struct nvkm_event *, int type, int index);
25 void (*fini)(struct nvkm_event *, int type, int index);
28 int __nvkm_event_init(const struct nvkm_event_func *func, struct nvkm_subdev *, int types_nr,
29 int index_nr, struct nvkm_event *);
31 /* Each nvkm_event needs its own lockdep class due to inter-dependencies, to
32 * prevent lockdep false-positives.
34 * Inlining the spinlock initialisation ensures each is unique.
36 static __always_inline int
37 nvkm_event_init(const struct nvkm_event_func *func, struct nvkm_subdev *subdev,
38 int types_nr, int index_nr, struct nvkm_event *event)
40 spin_lock_init(&event->refs_lock);
41 rwlock_init(&event->list_lock);
42 return __nvkm_event_init(func, subdev, types_nr, index_nr, event);
45 void nvkm_event_fini(struct nvkm_event *);
47 #define NVKM_EVENT_KEEP 0
48 #define NVKM_EVENT_DROP 1
49 struct nvkm_event_ntfy;
50 typedef int (*nvkm_event_func)(struct nvkm_event_ntfy *, u32 bits);
52 struct nvkm_event_ntfy {
53 struct nvkm_event *event;
62 struct list_head head;
65 void nvkm_event_ntfy(struct nvkm_event *, int id, u32 bits);
66 bool nvkm_event_ntfy_valid(struct nvkm_event *, int id, u32 bits);
67 void nvkm_event_ntfy_add(struct nvkm_event *, int id, u32 bits, bool wait, nvkm_event_func,
68 struct nvkm_event_ntfy *);
69 void nvkm_event_ntfy_del(struct nvkm_event_ntfy *);
70 void nvkm_event_ntfy_allow(struct nvkm_event_ntfy *);
71 void nvkm_event_ntfy_block(struct nvkm_event_ntfy *);
73 typedef int (*nvkm_uevent_func)(struct nvkm_object *, u64 token, u32 bits);
75 int nvkm_uevent_new(const struct nvkm_oclass *, void *argv, u32 argc, struct nvkm_object **);
76 int nvkm_uevent_add(struct nvkm_uevent *, struct nvkm_event *, int id, u32 bits, nvkm_uevent_func);