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