drm_auth.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. 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. * @lessor: Lease holder
  57. * @lessee_id: id for lessees. Owners always have id 0
  58. * @lessee_list: other lessees of the same master
  59. * @lessees: drm_masters leasing from this one
  60. * @leases: Objects leased to this drm_master.
  61. * @lessee_idr: All lessees under this owner (only used where lessor == NULL)
  62. *
  63. * Note that master structures are only relevant for the legacy/primary device
  64. * nodes, hence there can only be one per device, not one per drm_minor.
  65. */
  66. struct drm_master {
  67. struct kref refcount;
  68. struct drm_device *dev;
  69. /**
  70. * @unique: Unique identifier: e.g. busid. Protected by
  71. * &drm_device.master_mutex.
  72. */
  73. char *unique;
  74. /**
  75. * @unique_len: Length of unique field. Protected by
  76. * &drm_device.master_mutex.
  77. */
  78. int unique_len;
  79. /**
  80. * @magic_map: Map of used authentication tokens. Protected by
  81. * &drm_device.master_mutex.
  82. */
  83. struct idr magic_map;
  84. void *driver_priv;
  85. /* Tree of display resource leases, each of which is a drm_master struct
  86. * All of these get activated simultaneously, so drm_device master points
  87. * at the top of the tree (for which lessor is NULL). Protected by
  88. * &drm_device.mode_config.idr_mutex.
  89. */
  90. struct drm_master *lessor;
  91. int lessee_id;
  92. struct list_head lessee_list;
  93. struct list_head lessees;
  94. struct idr leases;
  95. struct idr lessee_idr;
  96. /* private: */
  97. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  98. struct drm_lock_data lock;
  99. #endif
  100. };
  101. struct drm_master *drm_master_get(struct drm_master *master);
  102. void drm_master_put(struct drm_master **master);
  103. bool drm_is_current_master(struct drm_file *fpriv);
  104. struct drm_master *drm_master_create(struct drm_device *dev);
  105. #endif