diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon.h')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 73e05cb85eca..1668ec1ee770 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -157,6 +157,47 @@ bool radeon_get_bios(struct radeon_device *rdev); | |||
157 | 157 | ||
158 | 158 | ||
159 | /* | 159 | /* |
160 | * Mutex which allows recursive locking from the same process. | ||
161 | */ | ||
162 | struct radeon_mutex { | ||
163 | struct mutex mutex; | ||
164 | struct task_struct *owner; | ||
165 | int level; | ||
166 | }; | ||
167 | |||
168 | static inline void radeon_mutex_init(struct radeon_mutex *mutex) | ||
169 | { | ||
170 | mutex_init(&mutex->mutex); | ||
171 | mutex->owner = NULL; | ||
172 | mutex->level = 0; | ||
173 | } | ||
174 | |||
175 | static inline void radeon_mutex_lock(struct radeon_mutex *mutex) | ||
176 | { | ||
177 | if (mutex_trylock(&mutex->mutex)) { | ||
178 | /* The mutex was unlocked before, so it's ours now */ | ||
179 | mutex->owner = current; | ||
180 | } else if (mutex->owner != current) { | ||
181 | /* Another process locked the mutex, take it */ | ||
182 | mutex_lock(&mutex->mutex); | ||
183 | mutex->owner = current; | ||
184 | } | ||
185 | /* Otherwise the mutex was already locked by this process */ | ||
186 | |||
187 | mutex->level++; | ||
188 | } | ||
189 | |||
190 | static inline void radeon_mutex_unlock(struct radeon_mutex *mutex) | ||
191 | { | ||
192 | if (--mutex->level > 0) | ||
193 | return; | ||
194 | |||
195 | mutex->owner = NULL; | ||
196 | mutex_unlock(&mutex->mutex); | ||
197 | } | ||
198 | |||
199 | |||
200 | /* | ||
160 | * Dummy page | 201 | * Dummy page |
161 | */ | 202 | */ |
162 | struct radeon_dummy_page { | 203 | struct radeon_dummy_page { |
@@ -598,7 +639,7 @@ struct radeon_ib { | |||
598 | * mutex protects scheduled_ibs, ready, alloc_bm | 639 | * mutex protects scheduled_ibs, ready, alloc_bm |
599 | */ | 640 | */ |
600 | struct radeon_ib_pool { | 641 | struct radeon_ib_pool { |
601 | struct mutex mutex; | 642 | struct radeon_mutex mutex; |
602 | struct radeon_sa_manager sa_manager; | 643 | struct radeon_sa_manager sa_manager; |
603 | struct radeon_ib ibs[RADEON_IB_POOL_SIZE]; | 644 | struct radeon_ib ibs[RADEON_IB_POOL_SIZE]; |
604 | bool ready; | 645 | bool ready; |
@@ -1355,47 +1396,6 @@ struct r600_vram_scratch { | |||
1355 | 1396 | ||
1356 | 1397 | ||
1357 | /* | 1398 | /* |
1358 | * Mutex which allows recursive locking from the same process. | ||
1359 | */ | ||
1360 | struct radeon_mutex { | ||
1361 | struct mutex mutex; | ||
1362 | struct task_struct *owner; | ||
1363 | int level; | ||
1364 | }; | ||
1365 | |||
1366 | static inline void radeon_mutex_init(struct radeon_mutex *mutex) | ||
1367 | { | ||
1368 | mutex_init(&mutex->mutex); | ||
1369 | mutex->owner = NULL; | ||
1370 | mutex->level = 0; | ||
1371 | } | ||
1372 | |||
1373 | static inline void radeon_mutex_lock(struct radeon_mutex *mutex) | ||
1374 | { | ||
1375 | if (mutex_trylock(&mutex->mutex)) { | ||
1376 | /* The mutex was unlocked before, so it's ours now */ | ||
1377 | mutex->owner = current; | ||
1378 | } else if (mutex->owner != current) { | ||
1379 | /* Another process locked the mutex, take it */ | ||
1380 | mutex_lock(&mutex->mutex); | ||
1381 | mutex->owner = current; | ||
1382 | } | ||
1383 | /* Otherwise the mutex was already locked by this process */ | ||
1384 | |||
1385 | mutex->level++; | ||
1386 | } | ||
1387 | |||
1388 | static inline void radeon_mutex_unlock(struct radeon_mutex *mutex) | ||
1389 | { | ||
1390 | if (--mutex->level > 0) | ||
1391 | return; | ||
1392 | |||
1393 | mutex->owner = NULL; | ||
1394 | mutex_unlock(&mutex->mutex); | ||
1395 | } | ||
1396 | |||
1397 | |||
1398 | /* | ||
1399 | * Core structure, functions and helpers. | 1399 | * Core structure, functions and helpers. |
1400 | */ | 1400 | */ |
1401 | typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t); | 1401 | typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t); |