intr.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Tegra host1x Interrupt Management
  4. *
  5. * Copyright (c) 2010-2013, NVIDIA Corporation.
  6. */
  7. #ifndef __HOST1X_INTR_H
  8. #define __HOST1X_INTR_H
  9. #include <linux/interrupt.h>
  10. #include <linux/workqueue.h>
  11. struct host1x_syncpt;
  12. struct host1x;
  13. enum host1x_intr_action {
  14. /*
  15. * Perform cleanup after a submit has completed.
  16. * 'data' points to a channel
  17. */
  18. HOST1X_INTR_ACTION_SUBMIT_COMPLETE = 0,
  19. /*
  20. * Wake up a task.
  21. * 'data' points to a wait_queue_head_t
  22. */
  23. HOST1X_INTR_ACTION_WAKEUP,
  24. /*
  25. * Wake up a interruptible task.
  26. * 'data' points to a wait_queue_head_t
  27. */
  28. HOST1X_INTR_ACTION_WAKEUP_INTERRUPTIBLE,
  29. HOST1X_INTR_ACTION_SIGNAL_FENCE,
  30. HOST1X_INTR_ACTION_COUNT
  31. };
  32. struct host1x_syncpt_intr {
  33. spinlock_t lock;
  34. struct list_head wait_head;
  35. char thresh_irq_name[12];
  36. struct work_struct work;
  37. };
  38. struct host1x_waitlist {
  39. struct list_head list;
  40. struct kref refcount;
  41. u32 thresh;
  42. enum host1x_intr_action action;
  43. atomic_t state;
  44. void *data;
  45. int count;
  46. };
  47. /*
  48. * Schedule an action to be taken when a sync point reaches the given threshold.
  49. *
  50. * @id the sync point
  51. * @thresh the threshold
  52. * @action the action to take
  53. * @data a pointer to extra data depending on action, see above
  54. * @waiter waiter structure - assumes ownership
  55. * @ref must be passed if cancellation is possible, else NULL
  56. *
  57. * This is a non-blocking api.
  58. */
  59. int host1x_intr_add_action(struct host1x *host, struct host1x_syncpt *syncpt,
  60. u32 thresh, enum host1x_intr_action action,
  61. void *data, struct host1x_waitlist *waiter,
  62. void **ref);
  63. /*
  64. * Unreference an action submitted to host1x_intr_add_action().
  65. * You must call this if you passed non-NULL as ref.
  66. * @ref the ref returned from host1x_intr_add_action()
  67. * @flush wait until any pending handlers have completed before returning.
  68. */
  69. void host1x_intr_put_ref(struct host1x *host, unsigned int id, void *ref,
  70. bool flush);
  71. /* Initialize host1x sync point interrupt */
  72. int host1x_intr_init(struct host1x *host, unsigned int irq_sync);
  73. /* Deinitialize host1x sync point interrupt */
  74. void host1x_intr_deinit(struct host1x *host);
  75. /* Enable host1x sync point interrupt */
  76. void host1x_intr_start(struct host1x *host);
  77. /* Disable host1x sync point interrupt */
  78. void host1x_intr_stop(struct host1x *host);
  79. irqreturn_t host1x_syncpt_thresh_fn(void *dev_id);
  80. #endif