msm_ringbuffer.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __MSM_RINGBUFFER_H__
  18. #define __MSM_RINGBUFFER_H__
  19. #include "msm_drv.h"
  20. #define rbmemptr(ring, member) \
  21. ((ring)->memptrs_iova + offsetof(struct msm_rbmemptrs, member))
  22. struct msm_rbmemptrs {
  23. volatile uint32_t rptr;
  24. volatile uint32_t fence;
  25. };
  26. struct msm_ringbuffer {
  27. struct msm_gpu *gpu;
  28. int id;
  29. struct drm_gem_object *bo;
  30. uint32_t *start, *end, *cur;
  31. struct list_head submits;
  32. uint64_t iova;
  33. uint32_t seqno;
  34. uint32_t hangcheck_fence;
  35. struct msm_rbmemptrs *memptrs;
  36. uint64_t memptrs_iova;
  37. struct msm_fence_context *fctx;
  38. };
  39. struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id,
  40. void *memptrs, uint64_t memptrs_iova);
  41. void msm_ringbuffer_destroy(struct msm_ringbuffer *ring);
  42. /* ringbuffer helpers (the parts that are same for a3xx/a2xx/z180..) */
  43. static inline void
  44. OUT_RING(struct msm_ringbuffer *ring, uint32_t data)
  45. {
  46. if (ring->cur == ring->end)
  47. ring->cur = ring->start;
  48. *(ring->cur++) = data;
  49. }
  50. #endif /* __MSM_RINGBUFFER_H__ */