]> Git Repo - J-linux.git/blob - drivers/gpu/drm/nouveau/include/nvkm/core/event.h
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / drivers / gpu / drm / nouveau / include / nvkm / core / event.h
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_EVENT_H__
3 #define __NVKM_EVENT_H__
4 #include <core/os.h>
5 struct nvkm_object;
6 struct nvkm_oclass;
7 struct nvkm_uevent;
8
9 struct nvkm_event {
10         const struct nvkm_event_func *func;
11         struct nvkm_subdev *subdev;
12
13         int types_nr;
14         int index_nr;
15
16         spinlock_t refs_lock;
17         rwlock_t list_lock;
18         int *refs;
19
20         struct list_head ntfy;
21 };
22
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);
26 };
27
28 int  __nvkm_event_init(const struct nvkm_event_func *func, struct nvkm_subdev *, int types_nr,
29                        int index_nr, struct nvkm_event *);
30
31 /* Each nvkm_event needs its own lockdep class due to inter-dependencies, to
32  * prevent lockdep false-positives.
33  *
34  * Inlining the spinlock initialisation ensures each is unique.
35  */
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)
39 {
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);
43 }
44
45 void nvkm_event_fini(struct nvkm_event *);
46
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);
51
52 struct nvkm_event_ntfy {
53         struct nvkm_event *event;
54         int id;
55         u32 bits;
56         bool wait;
57         nvkm_event_func func;
58
59         atomic_t allowed;
60         bool running;
61
62         struct list_head head;
63 };
64
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 *);
72
73 typedef int (*nvkm_uevent_func)(struct nvkm_object *, u64 token, u32 bits);
74
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);
77 #endif
This page took 0.033376 seconds and 4 git commands to generate.