]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - drivers/gpu/drm/nouveau/nouveau_fence.h
Merge remote-tracking branches 'asoc/topic/ac97', 'asoc/topic/ac97-mfd', 'asoc/topic...
[mirror_ubuntu-focal-kernel.git] / drivers / gpu / drm / nouveau / nouveau_fence.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NOUVEAU_FENCE_H__
3 #define __NOUVEAU_FENCE_H__
4
5 #include <linux/dma-fence.h>
6 #include <nvif/notify.h>
7
8 struct nouveau_drm;
9 struct nouveau_bo;
10
11 struct nouveau_fence {
12 struct dma_fence base;
13
14 struct list_head head;
15
16 bool sysmem;
17
18 struct nouveau_channel __rcu *channel;
19 unsigned long timeout;
20 };
21
22 int nouveau_fence_new(struct nouveau_channel *, bool sysmem,
23 struct nouveau_fence **);
24 void nouveau_fence_unref(struct nouveau_fence **);
25
26 int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
27 bool nouveau_fence_done(struct nouveau_fence *);
28 void nouveau_fence_work(struct dma_fence *, void (*)(void *), void *);
29 int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
30 int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr);
31
32 struct nouveau_fence_chan {
33 spinlock_t lock;
34 struct kref fence_ref;
35
36 struct list_head pending;
37 struct list_head flip;
38
39 int (*emit)(struct nouveau_fence *);
40 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
41 struct nouveau_channel *);
42 u32 (*read)(struct nouveau_channel *);
43 int (*emit32)(struct nouveau_channel *, u64, u32);
44 int (*sync32)(struct nouveau_channel *, u64, u32);
45
46 u32 sequence;
47 u32 context;
48 char name[32];
49
50 struct nvif_notify notify;
51 int notify_ref, dead;
52 };
53
54 struct nouveau_fence_priv {
55 void (*dtor)(struct nouveau_drm *);
56 bool (*suspend)(struct nouveau_drm *);
57 void (*resume)(struct nouveau_drm *);
58 int (*context_new)(struct nouveau_channel *);
59 void (*context_del)(struct nouveau_channel *);
60
61 u32 contexts;
62 u64 context_base;
63 bool uevent;
64 };
65
66 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
67
68 void nouveau_fence_context_new(struct nouveau_channel *, struct nouveau_fence_chan *);
69 void nouveau_fence_context_del(struct nouveau_fence_chan *);
70 void nouveau_fence_context_free(struct nouveau_fence_chan *);
71
72 int nv04_fence_create(struct nouveau_drm *);
73 int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
74
75 int nv10_fence_emit(struct nouveau_fence *);
76 int nv17_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
77 struct nouveau_channel *);
78 u32 nv10_fence_read(struct nouveau_channel *);
79 void nv10_fence_context_del(struct nouveau_channel *);
80 void nv10_fence_destroy(struct nouveau_drm *);
81 int nv10_fence_create(struct nouveau_drm *);
82
83 int nv17_fence_create(struct nouveau_drm *);
84 void nv17_fence_resume(struct nouveau_drm *drm);
85
86 int nv50_fence_create(struct nouveau_drm *);
87 int nv84_fence_create(struct nouveau_drm *);
88 int nvc0_fence_create(struct nouveau_drm *);
89
90 int nouveau_flip_complete(struct nvif_notify *);
91
92 struct nv84_fence_chan {
93 struct nouveau_fence_chan base;
94 struct nvkm_vma vma;
95 struct nvkm_vma vma_gart;
96 };
97
98 struct nv84_fence_priv {
99 struct nouveau_fence_priv base;
100 struct nouveau_bo *bo;
101 struct nouveau_bo *bo_gart;
102 u32 *suspend;
103 struct mutex mutex;
104 };
105
106 int nv84_fence_context_new(struct nouveau_channel *);
107
108 #endif