Skip to content

Commit 894abbc

Browse files
6by9pelwell
authored andcommitted
staging: vc04_services: vc-sm-cma: Use a mutex instead of spinlock
There are no contexts where we should be calling the kernelid_map IDR functions where we can't sleep, so switch from using a spinlock to using a mutex. #6815 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 240b9a5 commit 894abbc

File tree

1 file changed

+6
-6
lines changed
  • drivers/staging/vc04_services/vc-sm-cma

1 file changed

+6
-6
lines changed

drivers/staging/vc04_services/vc-sm-cma/vc_sm.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct sm_state_t {
9191

9292
struct sm_instance *sm_handle; /* Handle for videocore service. */
9393

94-
spinlock_t kernelid_map_lock; /* Spinlock protecting kernelid_map */
94+
struct mutex kernelid_map_lock; /* Mutex protecting kernelid_map */
9595
struct idr kernelid_map;
9696

9797
struct mutex map_lock; /* Global map lock. */
@@ -129,9 +129,9 @@ static int get_kernel_id(struct vc_sm_buffer *buffer)
129129
{
130130
int handle;
131131

132-
spin_lock(&sm_state->kernelid_map_lock);
132+
mutex_lock(&sm_state->kernelid_map_lock);
133133
handle = idr_alloc(&sm_state->kernelid_map, buffer, 0, 0, GFP_KERNEL);
134-
spin_unlock(&sm_state->kernelid_map_lock);
134+
mutex_unlock(&sm_state->kernelid_map_lock);
135135

136136
return handle;
137137
}
@@ -143,9 +143,9 @@ static struct vc_sm_buffer *lookup_kernel_id(int handle)
143143

144144
static void free_kernel_id(int handle)
145145
{
146-
spin_lock(&sm_state->kernelid_map_lock);
146+
mutex_lock(&sm_state->kernelid_map_lock);
147147
idr_remove(&sm_state->kernelid_map, handle);
148-
spin_unlock(&sm_state->kernelid_map_lock);
148+
mutex_unlock(&sm_state->kernelid_map_lock);
149149
}
150150

151151
static int vc_sm_cma_seq_file_show(struct seq_file *s, void *v)
@@ -1494,7 +1494,7 @@ static int bcm2835_vc_sm_cma_probe(struct vchiq_device *device)
14941494
sm_state->device = device;
14951495
mutex_init(&sm_state->map_lock);
14961496

1497-
spin_lock_init(&sm_state->kernelid_map_lock);
1497+
mutex_init(&sm_state->kernelid_map_lock);
14981498
idr_init_base(&sm_state->kernelid_map, 1);
14991499

15001500
device->dev.dma_parms = devm_kzalloc(&device->dev,

0 commit comments

Comments
 (0)