drm_auth.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #ifndef _DRM_AUTH_H_
  2. #define _DRM_AUTH_H_
  3. /*
  4. * Internal Header for the Direct Rendering Manager
  5. *
  6. * Copyright 2016 Intel Corporation
  7. *
  8. * Author: Daniel Vetter <[email protected]>
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a
  11. * copy of this software and associated documentation files (the "Software"),
  12. * to deal in the Software without restriction, including without limitation
  13. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14. * and/or sell copies of the Software, and to permit persons to whom the
  15. * Software is furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice (including the next
  18. * paragraph) shall be included in all copies or substantial portions of the
  19. * Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  24. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  25. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  26. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  27. * OTHER DEALINGS IN THE SOFTWARE.
  28. */
  29. #include <linux/idr.h>
  30. #include <linux/kref.h>
  31. #include <linux/wait.h>
  32. struct drm_file;
  33. struct drm_hw_lock;
  34. /*
  35. * Legacy DRI1 locking data structure. Only here instead of in drm_legacy.h for
  36. * include ordering reasons.
  37. *
  38. * DO NOT USE.
  39. */
  40. struct drm_lock_data {
  41. struct drm_hw_lock *hw_lock;
  42. struct drm_file *file_priv;
  43. wait_queue_head_t lock_queue;
  44. unsigned long lock_time;
  45. spinlock_t spinlock;
  46. uint32_t kernel_waiters;
  47. uint32_t user_waiters;
  48. int idle_has_lock;
  49. };
  50. /**
  51. * struct drm_master - drm master structure
  52. *
  53. * @refcount: Refcount for this master object.
  54. * @dev: Link back to the DRM device
  55. * @driver_priv: Pointer to driver-private information.
  56. *
  57. * Note that master structures are only relevant for the legacy/primary device
  58. * nodes, hence there can only be one per device, not one per drm_minor.
  59. */
  60. struct drm_master {
  61. struct kref refcount;
  62. struct drm_device *dev;
  63. /**
  64. * @unique: Unique identifier: e.g. busid. Protected by
  65. * &drm_device.master_mutex.
  66. */
  67. char *unique;
  68. /**
  69. * @unique_len: Length of unique field. Protected by
  70. * &drm_device.master_mutex.
  71. */
  72. int unique_len;
  73. /**
  74. * @magic_map: Map of used authentication tokens. Protected by
  75. * &drm_device.master_mutex.
  76. */
  77. struct idr magic_map;
  78. void *driver_priv;
  79. /**
  80. * @lessor:
  81. *
  82. * Lease grantor, only set if this &struct drm_master represents a
  83. * lessee holding a lease of objects from @lessor. Full owners of the
  84. * device have this set to NULL.
  85. *
  86. * The lessor does not change once it's set in drm_lease_create(), and
  87. * each lessee holds a reference to its lessor that it releases upon
  88. * being destroyed in drm_lease_destroy().
  89. *
  90. * See also the :ref:`section on display resource leasing
  91. * <drm_leasing>`.
  92. */
  93. struct drm_master *lessor;
  94. /**
  95. * @lessee_id:
  96. *
  97. * ID for lessees. Owners (i.e. @lessor is NULL) always have ID 0.
  98. * Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.
  99. */
  100. int lessee_id;
  101. /**
  102. * @lessee_list:
  103. *
  104. * List entry of lessees of @lessor, where they are linked to @lessees.
  105. * Not used for owners. Protected by &drm_device.mode_config's
  106. * &drm_mode_config.idr_mutex.
  107. */
  108. struct list_head lessee_list;
  109. /**
  110. * @lessees:
  111. *
  112. * List of drm_masters leasing from this one. Protected by
  113. * &drm_device.mode_config's &drm_mode_config.idr_mutex.
  114. *
  115. * This list is empty if no leases have been granted, or if all lessees
  116. * have been destroyed. Since lessors are referenced by all their
  117. * lessees, this master cannot be destroyed unless the list is empty.
  118. */
  119. struct list_head lessees;
  120. /**
  121. * @leases:
  122. *
  123. * Objects leased to this drm_master. Protected by
  124. * &drm_device.mode_config's &drm_mode_config.idr_mutex.
  125. *
  126. * Objects are leased all together in drm_lease_create(), and are
  127. * removed all together when the lease is revoked.
  128. */
  129. struct idr leases;
  130. /**
  131. * @lessee_idr:
  132. *
  133. * All lessees under this owner (only used where @lessor is NULL).
  134. * Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.
  135. */
  136. struct idr lessee_idr;
  137. /* private: */
  138. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  139. struct drm_lock_data lock;
  140. #endif
  141. };
  142. struct drm_master *drm_master_get(struct drm_master *master);
  143. struct drm_master *drm_file_get_master(struct drm_file *file_priv);
  144. void drm_master_put(struct drm_master **master);
  145. bool drm_is_current_master(struct drm_file *fpriv);
  146. struct drm_master *drm_master_create(struct drm_device *dev);
  147. #endif