aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_auth.c')
-rw-r--r--drivers/gpu/drm/drm_auth.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index a73462723d2d..ca7a9ef5007b 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -45,14 +45,15 @@
45 * the one with matching magic number, while holding the drm_device::struct_mutex 45 * the one with matching magic number, while holding the drm_device::struct_mutex
46 * lock. 46 * lock.
47 */ 47 */
48static struct drm_file *drm_find_file(struct drm_device * dev, drm_magic_t magic) 48static struct drm_file *drm_find_file(struct drm_master *master, drm_magic_t magic)
49{ 49{
50 struct drm_file *retval = NULL; 50 struct drm_file *retval = NULL;
51 struct drm_magic_entry *pt; 51 struct drm_magic_entry *pt;
52 struct drm_hash_item *hash; 52 struct drm_hash_item *hash;
53 struct drm_device *dev = master->minor->dev;
53 54
54 mutex_lock(&dev->struct_mutex); 55 mutex_lock(&dev->struct_mutex);
55 if (!drm_ht_find_item(&dev->magiclist, (unsigned long)magic, &hash)) { 56 if (!drm_ht_find_item(&master->magiclist, (unsigned long)magic, &hash)) {
56 pt = drm_hash_entry(hash, struct drm_magic_entry, hash_item); 57 pt = drm_hash_entry(hash, struct drm_magic_entry, hash_item);
57 retval = pt->priv; 58 retval = pt->priv;
58 } 59 }
@@ -71,11 +72,11 @@ static struct drm_file *drm_find_file(struct drm_device * dev, drm_magic_t magic
71 * associated the magic number hash key in drm_device::magiclist, while holding 72 * associated the magic number hash key in drm_device::magiclist, while holding
72 * the drm_device::struct_mutex lock. 73 * the drm_device::struct_mutex lock.
73 */ 74 */
74static int drm_add_magic(struct drm_device * dev, struct drm_file * priv, 75static int drm_add_magic(struct drm_master *master, struct drm_file *priv,
75 drm_magic_t magic) 76 drm_magic_t magic)
76{ 77{
77 struct drm_magic_entry *entry; 78 struct drm_magic_entry *entry;
78 79 struct drm_device *dev = master->minor->dev;
79 DRM_DEBUG("%d\n", magic); 80 DRM_DEBUG("%d\n", magic);
80 81
81 entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC); 82 entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC);
@@ -83,11 +84,10 @@ static int drm_add_magic(struct drm_device * dev, struct drm_file * priv,
83 return -ENOMEM; 84 return -ENOMEM;
84 memset(entry, 0, sizeof(*entry)); 85 memset(entry, 0, sizeof(*entry));
85 entry->priv = priv; 86 entry->priv = priv;
86
87 entry->hash_item.key = (unsigned long)magic; 87 entry->hash_item.key = (unsigned long)magic;
88 mutex_lock(&dev->struct_mutex); 88 mutex_lock(&dev->struct_mutex);
89 drm_ht_insert_item(&dev->magiclist, &entry->hash_item); 89 drm_ht_insert_item(&master->magiclist, &entry->hash_item);
90 list_add_tail(&entry->head, &dev->magicfree); 90 list_add_tail(&entry->head, &master->magicfree);
91 mutex_unlock(&dev->struct_mutex); 91 mutex_unlock(&dev->struct_mutex);
92 92
93 return 0; 93 return 0;
@@ -102,20 +102,21 @@ static int drm_add_magic(struct drm_device * dev, struct drm_file * priv,
102 * Searches and unlinks the entry in drm_device::magiclist with the magic 102 * Searches and unlinks the entry in drm_device::magiclist with the magic
103 * number hash key, while holding the drm_device::struct_mutex lock. 103 * number hash key, while holding the drm_device::struct_mutex lock.
104 */ 104 */
105static int drm_remove_magic(struct drm_device * dev, drm_magic_t magic) 105static int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
106{ 106{
107 struct drm_magic_entry *pt; 107 struct drm_magic_entry *pt;
108 struct drm_hash_item *hash; 108 struct drm_hash_item *hash;
109 struct drm_device *dev = master->minor->dev;
109 110
110 DRM_DEBUG("%d\n", magic); 111 DRM_DEBUG("%d\n", magic);
111 112
112 mutex_lock(&dev->struct_mutex); 113 mutex_lock(&dev->struct_mutex);
113 if (drm_ht_find_item(&dev->magiclist, (unsigned long)magic, &hash)) { 114 if (drm_ht_find_item(&master->magiclist, (unsigned long)magic, &hash)) {
114 mutex_unlock(&dev->struct_mutex); 115 mutex_unlock(&dev->struct_mutex);
115 return -EINVAL; 116 return -EINVAL;
116 } 117 }
117 pt = drm_hash_entry(hash, struct drm_magic_entry, hash_item); 118 pt = drm_hash_entry(hash, struct drm_magic_entry, hash_item);
118 drm_ht_remove_item(&dev->magiclist, hash); 119 drm_ht_remove_item(&master->magiclist, hash);
119 list_del(&pt->head); 120 list_del(&pt->head);
120 mutex_unlock(&dev->struct_mutex); 121 mutex_unlock(&dev->struct_mutex);
121 122
@@ -153,9 +154,9 @@ int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
153 ++sequence; /* reserve 0 */ 154 ++sequence; /* reserve 0 */
154 auth->magic = sequence++; 155 auth->magic = sequence++;
155 spin_unlock(&lock); 156 spin_unlock(&lock);
156 } while (drm_find_file(dev, auth->magic)); 157 } while (drm_find_file(file_priv->master, auth->magic));
157 file_priv->magic = auth->magic; 158 file_priv->magic = auth->magic;
158 drm_add_magic(dev, file_priv, auth->magic); 159 drm_add_magic(file_priv->master, file_priv, auth->magic);
159 } 160 }
160 161
161 DRM_DEBUG("%u\n", auth->magic); 162 DRM_DEBUG("%u\n", auth->magic);
@@ -181,9 +182,9 @@ int drm_authmagic(struct drm_device *dev, void *data,
181 struct drm_file *file; 182 struct drm_file *file;
182 183
183 DRM_DEBUG("%u\n", auth->magic); 184 DRM_DEBUG("%u\n", auth->magic);
184 if ((file = drm_find_file(dev, auth->magic))) { 185 if ((file = drm_find_file(file_priv->master, auth->magic))) {
185 file->authenticated = 1; 186 file->authenticated = 1;
186 drm_remove_magic(dev, auth->magic); 187 drm_remove_magic(file_priv->master, auth->magic);
187 return 0; 188 return 0;
188 } 189 }
189 return -EINVAL; 190 return -EINVAL;