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