diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-11-07 03:49:07 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-11-07 03:49:07 +0000 |
commit | 853d372b68c653cf3cd71e93d4b5b98d5f5a8d53 (patch) | |
tree | 0c2f42ff5e860d093a57e2dc544d8dcae9c172fa /sys/dev/pci/drm/include | |
parent | 372fbe81c09ab874a550e595f19e4ae615d05955 (diff) |
change from rwlock(9) to mutex(9) for linux rwlocks
Linux rwlocks are read/write spin locks which don't sleep.
Fixes a panic claudio@ reported with a WITNESS kernel on inteldrm(4)
'panic: acquiring blockable sleep lock with spinlock or critical section
held (rwlock) drmvma'
Patch from kettenis@ with a small tweak from me. ok kettenis@
Diffstat (limited to 'sys/dev/pci/drm/include')
-rw-r--r-- | sys/dev/pci/drm/include/drm/drm_vma_manager.h | 6 | ||||
-rw-r--r-- | sys/dev/pci/drm/include/linux/rwlock_types.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/drm/include/linux/spinlock.h | 8 |
3 files changed, 7 insertions, 11 deletions
diff --git a/sys/dev/pci/drm/include/drm/drm_vma_manager.h b/sys/dev/pci/drm/include/drm/drm_vma_manager.h index 42a848898f2..3d8c827e322 100644 --- a/sys/dev/pci/drm/include/drm/drm_vma_manager.h +++ b/sys/dev/pci/drm/include/drm/drm_vma_manager.h @@ -50,14 +50,14 @@ struct drm_vma_offset_file { }; struct drm_vma_offset_node { - rwlock_t vm_lock; + struct mutex vm_lock; struct drm_mm_node vm_node; struct rb_root vm_files; bool readonly:1; }; struct drm_vma_offset_manager { - rwlock_t vm_lock; + struct mutex vm_lock; struct drm_mm vm_addr_space_mm; }; @@ -148,7 +148,7 @@ static inline void drm_vma_node_reset(struct drm_vma_offset_node *node) { memset(node, 0, sizeof(*node)); node->vm_files = RB_ROOT; - rw_init(&node->vm_lock, "drmvma"); + mtx_init(&node->vm_lock, IPL_NONE); } /** diff --git a/sys/dev/pci/drm/include/linux/rwlock_types.h b/sys/dev/pci/drm/include/linux/rwlock_types.h index 36b1f7feab1..b2b62469f0d 100644 --- a/sys/dev/pci/drm/include/linux/rwlock_types.h +++ b/sys/dev/pci/drm/include/linux/rwlock_types.h @@ -3,8 +3,4 @@ #ifndef _LINUX_RWLOCK_TYPES_H #define _LINUX_RWLOCK_TYPES_H -#include <sys/rwlock.h> - -typedef struct rwlock rwlock_t; - #endif diff --git a/sys/dev/pci/drm/include/linux/spinlock.h b/sys/dev/pci/drm/include/linux/spinlock.h index 7bc26e1beac..b4bf1ba8015 100644 --- a/sys/dev/pci/drm/include/linux/spinlock.h +++ b/sys/dev/pci/drm/include/linux/spinlock.h @@ -55,9 +55,9 @@ atomic_dec_and_lock(volatile int *v, struct mutex *mtxp) #define assert_spin_locked(mtxp) MUTEX_ASSERT_LOCKED(mtxp) #define spin_trylock_irq(mtxp) mtx_enter_try(mtxp) -#define read_lock(rwl) rw_enter_read(rwl) -#define read_unlock(rwl) rw_exit_read(rwl) -#define write_lock(rwl) rw_enter_write(rwl) -#define write_unlock(rwl) rw_exit_write(rwl) +#define read_lock(mtxp) mtx_enter(mtxp) +#define read_unlock(mtxp) mtx_leave(mtxp) +#define write_lock(mtxp) mtx_enter(mtxp) +#define write_unlock(mtxp) mtx_leave(mtxp) #endif |