amdgpu_irq.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright 2014 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #ifndef __AMDGPU_IRQ_H__
  24. #define __AMDGPU_IRQ_H__
  25. #include <linux/irqdomain.h>
  26. #include "soc15_ih_clientid.h"
  27. #include "amdgpu_ih.h"
  28. #define AMDGPU_MAX_IRQ_SRC_ID 0x100
  29. #define AMDGPU_MAX_IRQ_CLIENT_ID 0x100
  30. #define AMDGPU_IRQ_CLIENTID_LEGACY 0
  31. #define AMDGPU_IRQ_CLIENTID_MAX SOC15_IH_CLIENTID_MAX
  32. #define AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW 4
  33. struct amdgpu_device;
  34. enum amdgpu_interrupt_state {
  35. AMDGPU_IRQ_STATE_DISABLE,
  36. AMDGPU_IRQ_STATE_ENABLE,
  37. };
  38. struct amdgpu_iv_entry {
  39. unsigned client_id;
  40. unsigned src_id;
  41. unsigned ring_id;
  42. unsigned vmid;
  43. unsigned vmid_src;
  44. uint64_t timestamp;
  45. unsigned timestamp_src;
  46. unsigned pasid;
  47. unsigned pasid_src;
  48. unsigned src_data[AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW];
  49. const uint32_t *iv_entry;
  50. };
  51. struct amdgpu_irq_src {
  52. unsigned num_types;
  53. atomic_t *enabled_types;
  54. const struct amdgpu_irq_src_funcs *funcs;
  55. void *data;
  56. };
  57. struct amdgpu_irq_client {
  58. struct amdgpu_irq_src **sources;
  59. };
  60. /* provided by interrupt generating IP blocks */
  61. struct amdgpu_irq_src_funcs {
  62. int (*set)(struct amdgpu_device *adev, struct amdgpu_irq_src *source,
  63. unsigned type, enum amdgpu_interrupt_state state);
  64. int (*process)(struct amdgpu_device *adev,
  65. struct amdgpu_irq_src *source,
  66. struct amdgpu_iv_entry *entry);
  67. };
  68. struct amdgpu_irq {
  69. bool installed;
  70. spinlock_t lock;
  71. /* interrupt sources */
  72. struct amdgpu_irq_client client[AMDGPU_IRQ_CLIENTID_MAX];
  73. /* status, etc. */
  74. bool msi_enabled; /* msi enabled */
  75. /* interrupt ring */
  76. struct amdgpu_ih_ring ih;
  77. const struct amdgpu_ih_funcs *ih_funcs;
  78. /* gen irq stuff */
  79. struct irq_domain *domain; /* GPU irq controller domain */
  80. unsigned virq[AMDGPU_MAX_IRQ_SRC_ID];
  81. uint32_t srbm_soft_reset;
  82. };
  83. void amdgpu_irq_disable_all(struct amdgpu_device *adev);
  84. irqreturn_t amdgpu_irq_handler(int irq, void *arg);
  85. int amdgpu_irq_init(struct amdgpu_device *adev);
  86. void amdgpu_irq_fini(struct amdgpu_device *adev);
  87. int amdgpu_irq_add_id(struct amdgpu_device *adev,
  88. unsigned client_id, unsigned src_id,
  89. struct amdgpu_irq_src *source);
  90. void amdgpu_irq_dispatch(struct amdgpu_device *adev,
  91. struct amdgpu_iv_entry *entry);
  92. int amdgpu_irq_update(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  93. unsigned type);
  94. int amdgpu_irq_get(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  95. unsigned type);
  96. int amdgpu_irq_put(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  97. unsigned type);
  98. bool amdgpu_irq_enabled(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  99. unsigned type);
  100. void amdgpu_irq_gpu_reset_resume_helper(struct amdgpu_device *adev);
  101. int amdgpu_irq_add_domain(struct amdgpu_device *adev);
  102. void amdgpu_irq_remove_domain(struct amdgpu_device *adev);
  103. unsigned amdgpu_irq_create_mapping(struct amdgpu_device *adev, unsigned src_id);
  104. #endif