drm_auth.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 <daniel.vetter@ffwll.ch>
  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. /**
  34. * struct drm_master - drm master structure
  35. *
  36. * @refcount: Refcount for this master object.
  37. * @dev: Link back to the DRM device
  38. * @driver_priv: Pointer to driver-private information.
  39. *
  40. * Note that master structures are only relevant for the legacy/primary device
  41. * nodes, hence there can only be one per device, not one per drm_minor.
  42. */
  43. struct drm_master {
  44. struct kref refcount;
  45. struct drm_device *dev;
  46. /**
  47. * @unique: Unique identifier: e.g. busid. Protected by
  48. * &drm_device.master_mutex.
  49. */
  50. char *unique;
  51. /**
  52. * @unique_len: Length of unique field. Protected by
  53. * &drm_device.master_mutex.
  54. */
  55. int unique_len;
  56. /**
  57. * @magic_map: Map of used authentication tokens. Protected by
  58. * &drm_device.master_mutex.
  59. */
  60. struct idr magic_map;
  61. void *driver_priv;
  62. /**
  63. * @lessor:
  64. *
  65. * Lease grantor, only set if this &struct drm_master represents a
  66. * lessee holding a lease of objects from @lessor. Full owners of the
  67. * device have this set to NULL.
  68. *
  69. * The lessor does not change once it's set in drm_lease_create(), and
  70. * each lessee holds a reference to its lessor that it releases upon
  71. * being destroyed in drm_lease_destroy().
  72. *
  73. * See also the :ref:`section on display resource leasing
  74. * <drm_leasing>`.
  75. */
  76. struct drm_master *lessor;
  77. /**
  78. * @lessee_id:
  79. *
  80. * ID for lessees. Owners (i.e. @lessor is NULL) always have ID 0.
  81. * Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.
  82. */
  83. int lessee_id;
  84. /**
  85. * @lessee_list:
  86. *
  87. * List entry of lessees of @lessor, where they are linked to @lessees.
  88. * Not used for owners. Protected by &drm_device.mode_config's
  89. * &drm_mode_config.idr_mutex.
  90. */
  91. struct list_head lessee_list;
  92. /**
  93. * @lessees:
  94. *
  95. * List of drm_masters leasing from this one. Protected by
  96. * &drm_device.mode_config's &drm_mode_config.idr_mutex.
  97. *
  98. * This list is empty if no leases have been granted, or if all lessees
  99. * have been destroyed. Since lessors are referenced by all their
  100. * lessees, this master cannot be destroyed unless the list is empty.
  101. */
  102. struct list_head lessees;
  103. /**
  104. * @leases:
  105. *
  106. * Objects leased to this drm_master. Protected by
  107. * &drm_device.mode_config's &drm_mode_config.idr_mutex.
  108. *
  109. * Objects are leased all together in drm_lease_create(), and are
  110. * removed all together when the lease is revoked.
  111. */
  112. struct idr leases;
  113. /**
  114. * @lessee_idr:
  115. *
  116. * All lessees under this owner (only used where @lessor is NULL).
  117. * Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.
  118. */
  119. struct idr lessee_idr;
  120. };
  121. struct drm_master *drm_master_get(struct drm_master *master);
  122. struct drm_master *drm_file_get_master(struct drm_file *file_priv);
  123. void drm_master_put(struct drm_master **master);
  124. bool drm_is_current_master(struct drm_file *fpriv);
  125. struct drm_master *drm_master_create(struct drm_device *dev);
  126. #endif