intr.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_COUNT
  30. };
  31. struct host1x_syncpt_intr {
  32. spinlock_t lock;
  33. struct list_head wait_head;
  34. char thresh_irq_name[12];
  35. struct work_struct work;
  36. };
  37. struct host1x_waitlist {
  38. struct list_head list;
  39. struct kref refcount;
  40. u32 thresh;
  41. enum host1x_intr_action action;
  42. atomic_t state;
  43. void *data;
  44. int count;
  45. };
  46. /*
  47. * Schedule an action to be taken when a sync point reaches the given threshold.
  48. *
  49. * @id the sync point
  50. * @thresh the threshold
  51. * @action the action to take
  52. * @data a pointer to extra data depending on action, see above
  53. * @waiter waiter structure - assumes ownership
  54. * @ref must be passed if cancellation is possible, else NULL
  55. *
  56. * This is a non-blocking api.
  57. */
  58. int host1x_intr_add_action(struct host1x *host, struct host1x_syncpt *syncpt,
  59. u32 thresh, enum host1x_intr_action action,
  60. void *data, struct host1x_waitlist *waiter,
  61. void **ref);
  62. /*
  63. * Unreference an action submitted to host1x_intr_add_action().
  64. * You must call this if you passed non-NULL as ref.
  65. * @ref the ref returned from host1x_intr_add_action()
  66. */
  67. void host1x_intr_put_ref(struct host1x *host, unsigned int id, void *ref);
  68. /* Initialize host1x sync point interrupt */
  69. int host1x_intr_init(struct host1x *host, unsigned int irq_sync);
  70. /* Deinitialize host1x sync point interrupt */
  71. void host1x_intr_deinit(struct host1x *host);
  72. /* Enable host1x sync point interrupt */
  73. void host1x_intr_start(struct host1x *host);
  74. /* Disable host1x sync point interrupt */
  75. void host1x_intr_stop(struct host1x *host);
  76. irqreturn_t host1x_syncpt_thresh_fn(void *dev_id);
  77. #endif