1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NOUVEAU_FENCE_H__
3 #define __NOUVEAU_FENCE_H__
5 #include <linux/dma-fence.h>
6 #include <nvif/notify.h>
11 struct nouveau_fence
{
12 struct dma_fence base
;
14 struct list_head head
;
16 struct nouveau_channel __rcu
*channel
;
17 unsigned long timeout
;
20 int nouveau_fence_new(struct nouveau_channel
*, bool sysmem
,
21 struct nouveau_fence
**);
22 void nouveau_fence_unref(struct nouveau_fence
**);
24 int nouveau_fence_emit(struct nouveau_fence
*, struct nouveau_channel
*);
25 bool nouveau_fence_done(struct nouveau_fence
*);
26 int nouveau_fence_wait(struct nouveau_fence
*, bool lazy
, bool intr
);
27 int nouveau_fence_sync(struct nouveau_bo
*, struct nouveau_channel
*, bool exclusive
, bool intr
);
29 struct nouveau_fence_chan
{
31 struct kref fence_ref
;
33 struct list_head pending
;
34 struct list_head flip
;
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
);
47 struct nvif_notify notify
;
51 struct 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
*);
63 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
65 void nouveau_fence_context_new(struct nouveau_channel
*, struct nouveau_fence_chan
*);
66 void nouveau_fence_context_del(struct nouveau_fence_chan
*);
67 void nouveau_fence_context_free(struct nouveau_fence_chan
*);
69 int nv04_fence_create(struct nouveau_drm
*);
70 int nv04_fence_mthd(struct nouveau_channel
*, u32
, u32
, u32
);
72 int nv10_fence_emit(struct nouveau_fence
*);
73 int nv17_fence_sync(struct nouveau_fence
*, struct nouveau_channel
*,
74 struct nouveau_channel
*);
75 u32
nv10_fence_read(struct nouveau_channel
*);
76 void nv10_fence_context_del(struct nouveau_channel
*);
77 void nv10_fence_destroy(struct nouveau_drm
*);
78 int nv10_fence_create(struct nouveau_drm
*);
80 int nv17_fence_create(struct nouveau_drm
*);
81 void nv17_fence_resume(struct nouveau_drm
*drm
);
83 int nv50_fence_create(struct nouveau_drm
*);
84 int nv84_fence_create(struct nouveau_drm
*);
85 int nvc0_fence_create(struct nouveau_drm
*);
87 int nouveau_flip_complete(struct nvif_notify
*);
89 struct nv84_fence_chan
{
90 struct nouveau_fence_chan base
;
91 struct nouveau_vma
*vma
;
94 struct nv84_fence_priv
{
95 struct nouveau_fence_priv base
;
96 struct nouveau_bo
*bo
;
101 int nv84_fence_context_new(struct nouveau_channel
*);