^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #ifndef _DRM_AUTH_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #define _DRM_AUTH_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Internal Header for the Direct Rendering Manager
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright 2016 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Author: Daniel Vetter <daniel.vetter@ffwll.ch>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Permission is hereby granted, free of charge, to any person obtaining a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * copy of this software and associated documentation files (the "Software"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * to deal in the Software without restriction, including without limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * the rights to use, copy, modify, merge, publish, distribute, sublicense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * and/or sell copies of the Software, and to permit persons to whom the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Software is furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * The above copyright notice and this permission notice (including the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * paragraph) shall be included in all copies or substantial portions of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * OTHER DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/idr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct drm_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct drm_hw_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Legacy DRI1 locking data structure. Only here instead of in drm_legacy.h for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * include ordering reasons.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * DO NOT USE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct drm_lock_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct drm_hw_lock *hw_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct drm_file *file_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) wait_queue_head_t lock_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned long lock_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) spinlock_t spinlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) uint32_t kernel_waiters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) uint32_t user_waiters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int idle_has_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * struct drm_master - drm master structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * @refcount: Refcount for this master object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @dev: Link back to the DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @driver_priv: Pointer to driver-private information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * @lessor: Lease holder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * @lessee_id: id for lessees. Owners always have id 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * @lessee_list: other lessees of the same master
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * @lessees: drm_masters leasing from this one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * @leases: Objects leased to this drm_master.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * @lessee_idr: All lessees under this owner (only used where lessor == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Note that master structures are only relevant for the legacy/primary device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * nodes, hence there can only be one per device, not one per drm_minor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct drm_master {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct kref refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct drm_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @unique: Unique identifier: e.g. busid. Protected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * &drm_device.master_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) char *unique;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * @unique_len: Length of unique field. Protected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * &drm_device.master_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int unique_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * @magic_map: Map of used authentication tokens. Protected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * &drm_device.master_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct idr magic_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) void *driver_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /* Tree of display resource leases, each of which is a drm_master struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * All of these get activated simultaneously, so drm_device master points
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * at the top of the tree (for which lessor is NULL). Protected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * &drm_device.mode_config.idr_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct drm_master *lessor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) int lessee_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct list_head lessee_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct list_head lessees;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct idr leases;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct idr lessee_idr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* private: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #if IS_ENABLED(CONFIG_DRM_LEGACY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct drm_lock_data lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct drm_master *drm_master_get(struct drm_master *master);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) void drm_master_put(struct drm_master **master);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) bool drm_is_current_master(struct drm_file *fpriv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct drm_master *drm_master_create(struct drm_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #endif