sde_vm.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __SDE_VM_H__
  6. #define __SDE_VM_H__
  7. #include "msm_drv.h"
  8. struct sde_kms;
  9. /**
  10. * sde_vm_irq_entry - VM irq specification
  11. * @label - VM_IRQ_LABEL assigned by Hyp RM
  12. * @irq - linux mapped irq number
  13. */
  14. struct sde_vm_irq_entry {
  15. u32 label;
  16. u32 irq;
  17. };
  18. /**
  19. * sde_vm_irq_desc - list of IRQ's to be handled
  20. * @n_irq - irq count
  21. * @irq_entries - list of sde_vm_irq_entry
  22. */
  23. struct sde_vm_irq_desc {
  24. u32 n_irq;
  25. struct sde_vm_irq_entry *irq_entries;
  26. };
  27. /**
  28. * sde_vm - VM layer descriptor. Abstract for all the VM's
  29. * @vm_res_lock - mutex to protect resource updates
  30. * @mem_notificaiton_cookie - Hyp RM notification identifier
  31. * @n_irq_lent - irq count
  32. * @io_mem_handle - RM identifier for the IO range
  33. * @sde_kms - handle to sde_kms
  34. */
  35. struct sde_vm {
  36. struct mutex vm_res_lock;
  37. void *mem_notification_cookie;
  38. atomic_t n_irq_lent;
  39. int io_mem_handle;
  40. struct sde_kms *sde_kms;
  41. };
  42. /**
  43. * sde_vm_primary - VM layer descriptor for Primary VM
  44. * @base - parent struct object
  45. * @irq_desc - cache copy of irq list for validating reclaim
  46. */
  47. struct sde_vm_primary {
  48. struct sde_vm base;
  49. struct sde_vm_irq_desc *irq_desc;
  50. };
  51. /**
  52. * sde_vm_trusted - VM layer descriptor for Trusted VM
  53. * @base - parent struct object
  54. * @sgl_desc - hyp RM sgl list descriptor for IO ranges
  55. * @irq_desc - irq list
  56. */
  57. struct sde_vm_trusted {
  58. struct sde_vm base;
  59. struct sde_vm_irq_desc *irq_desc;
  60. struct hh_sgl_desc *sgl_desc;
  61. };
  62. /**
  63. * sde_vm_ops - VM specific function hooks
  64. */
  65. struct sde_vm_ops {
  66. /**
  67. * vm_acquire - hook to handle HW accept
  68. * @kms - handle to sde_kms
  69. * @return - return 0 on success
  70. */
  71. int (*vm_acquire)(struct sde_kms *kms);
  72. /**
  73. * vm_release - hook to handle HW release
  74. * @kms - handle to sde_kms
  75. * @return - return 0 on success
  76. */
  77. int (*vm_release)(struct sde_kms *kms);
  78. /**
  79. * vm_owns_hw - hook to query the HW status of the VM
  80. * @kms - handle to sde_kms
  81. * @return - return true when vm owns the hw
  82. */
  83. bool (*vm_owns_hw)(struct sde_kms *kms);
  84. /**
  85. * vm_prepare_commit - hook to handle operations before the first
  86. commit after acquiring the HW
  87. * @sde_kms - handle to sde_kms
  88. * @state - global atomic state to be parsed
  89. * @return - return 0 on success
  90. */
  91. int (*vm_prepare_commit)(struct sde_kms *sde_kms,
  92. struct drm_atomic_state *state);
  93. /**
  94. * vm_post_commit - hook to handle operations after
  95. last commit before release
  96. * @sde_kms - handle to sde_kms
  97. * @state - global atomic state to be parsed
  98. * @return - return 0 on success
  99. */
  100. int (*vm_post_commit)(struct sde_kms *sde_kms,
  101. struct drm_atomic_state *state);
  102. /**
  103. * vm_deinit - deinitialize VM layer
  104. * @kms - pointer to sde_kms
  105. * @ops - primary VM specific ops functions
  106. */
  107. void (*vm_deinit)(struct sde_kms *kms, struct sde_vm_ops *ops);
  108. };
  109. /**
  110. * sde_vm_primary_init - Initialize primary VM layer
  111. * @kms - pointer to sde_kms
  112. * @ops - primary VM specific ops functions
  113. * @return - 0 on success
  114. */
  115. int sde_vm_primary_init(struct sde_kms *kms, struct sde_vm_ops *ops);
  116. /**
  117. * sde_vm_trusted_init - Initialize Trusted VM layer
  118. * @kms - pointer to sde_kms
  119. * @ops - primary VM specific ops functions
  120. * @return - 0 on success
  121. */
  122. int sde_vm_trusted_init(struct sde_kms *kms, struct sde_vm_ops *ops);
  123. #endif /* __SDE_VM_H__ */