Home | History | Annotate | Line # | Download | only in nouveau
nouveau_fence.h revision 1.2.32.1
      1 /*	$NetBSD: nouveau_fence.h,v 1.2.32.1 2019/06/10 22:08:06 christos Exp $	*/
      2 
      3 #ifndef __NOUVEAU_FENCE_H__
      4 #define __NOUVEAU_FENCE_H__
      5 
      6 #include <linux/fence.h>
      7 #include <nvif/notify.h>
      8 
      9 struct nouveau_drm;
     10 struct nouveau_bo;
     11 
     12 struct nouveau_fence {
     13 	struct fence base;
     14 
     15 	struct list_head head;
     16 
     17 	bool sysmem;
     18 
     19 	struct nouveau_channel __rcu *channel;
     20 	unsigned long timeout;
     21 };
     22 
     23 int  nouveau_fence_new(struct nouveau_channel *, bool sysmem,
     24 		       struct nouveau_fence **);
     25 void nouveau_fence_unref(struct nouveau_fence **);
     26 
     27 int  nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
     28 bool nouveau_fence_done(struct nouveau_fence *);
     29 void nouveau_fence_work(struct fence *, void (*)(void *), void *);
     30 int  nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
     31 int  nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr);
     32 
     33 struct nouveau_fence_chan {
     34 	spinlock_t lock;
     35 	struct kref fence_ref;
     36 
     37 	struct list_head pending;
     38 	struct list_head flip;
     39 
     40 	int  (*emit)(struct nouveau_fence *);
     41 	int  (*sync)(struct nouveau_fence *, struct nouveau_channel *,
     42 		     struct nouveau_channel *);
     43 	u32  (*read)(struct nouveau_channel *);
     44 	int  (*emit32)(struct nouveau_channel *, u64, u32);
     45 	int  (*sync32)(struct nouveau_channel *, u64, u32);
     46 
     47 	u32 sequence;
     48 	u32 context;
     49 	char name[32];
     50 
     51 	struct nvif_notify notify;
     52 	int notify_ref, dead;
     53 };
     54 
     55 struct nouveau_fence_priv {
     56 	void (*dtor)(struct nouveau_drm *);
     57 	bool (*suspend)(struct nouveau_drm *);
     58 	void (*resume)(struct nouveau_drm *);
     59 	int  (*context_new)(struct nouveau_channel *);
     60 	void (*context_del)(struct nouveau_channel *);
     61 
     62 	u32 contexts, 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 	struct nvkm_vma dispc_vma[4];
     97 };
     98 
     99 struct nv84_fence_priv {
    100 	struct nouveau_fence_priv base;
    101 	struct nouveau_bo *bo;
    102 	struct nouveau_bo *bo_gart;
    103 	u32 *suspend;
    104 	struct mutex mutex;
    105 };
    106 
    107 u64  nv84_fence_crtc(struct nouveau_channel *, int);
    108 int  nv84_fence_context_new(struct nouveau_channel *);
    109 
    110 #endif
    111