v3d_fence.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /* Copyright (C) 2017-2018 Broadcom */
  3. #include "v3d_drv.h"
  4. struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum v3d_queue queue)
  5. {
  6. struct v3d_fence *fence;
  7. fence = kzalloc(sizeof(*fence), GFP_KERNEL);
  8. if (!fence)
  9. return ERR_PTR(-ENOMEM);
  10. fence->dev = &v3d->drm;
  11. fence->queue = queue;
  12. fence->seqno = ++v3d->queue[queue].emit_seqno;
  13. dma_fence_init(&fence->base, &v3d_fence_ops, &v3d->job_lock,
  14. v3d->queue[queue].fence_context, fence->seqno);
  15. return &fence->base;
  16. }
  17. static const char *v3d_fence_get_driver_name(struct dma_fence *fence)
  18. {
  19. return "v3d";
  20. }
  21. static const char *v3d_fence_get_timeline_name(struct dma_fence *fence)
  22. {
  23. struct v3d_fence *f = to_v3d_fence(fence);
  24. if (f->queue == V3D_BIN)
  25. return "v3d-bin";
  26. else
  27. return "v3d-render";
  28. }
  29. static bool v3d_fence_enable_signaling(struct dma_fence *fence)
  30. {
  31. return true;
  32. }
  33. const struct dma_fence_ops v3d_fence_ops = {
  34. .get_driver_name = v3d_fence_get_driver_name,
  35. .get_timeline_name = v3d_fence_get_timeline_name,
  36. .enable_signaling = v3d_fence_enable_signaling,
  37. /* Each of our fences gets signaled as complete by the IRQ
  38. * handler, so we rely on the core's tracking of signaling.
  39. */
  40. .signaled = NULL,
  41. .wait = dma_fence_default_wait,
  42. .release = dma_fence_free,
  43. };