nouveau_fence.h 2.8 KB

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