Skip to content

vcsm-cma fixes for lockdep warnings #6929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct sm_state_t {

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

spinlock_t kernelid_map_lock; /* Spinlock protecting kernelid_map */
struct mutex kernelid_map_lock; /* Mutex protecting kernelid_map */
struct idr kernelid_map;

struct mutex map_lock; /* Global map lock. */
Expand Down Expand Up @@ -129,9 +129,9 @@ static int get_kernel_id(struct vc_sm_buffer *buffer)
{
int handle;

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

return handle;
}
Expand All @@ -143,9 +143,9 @@ static struct vc_sm_buffer *lookup_kernel_id(int handle)

static void free_kernel_id(int handle)
{
spin_lock(&sm_state->kernelid_map_lock);
mutex_lock(&sm_state->kernelid_map_lock);
idr_remove(&sm_state->kernelid_map, handle);
spin_unlock(&sm_state->kernelid_map_lock);
mutex_unlock(&sm_state->kernelid_map_lock);
}

static int vc_sm_cma_seq_file_show(struct seq_file *s, void *v)
Expand Down Expand Up @@ -249,9 +249,9 @@ static void vc_sm_clean_up_dmabuf(struct vc_sm_buffer *buffer)

/* Handle cleaning up imported dmabufs */
if (buffer->import.sgt) {
dma_buf_unmap_attachment(buffer->import.attach,
buffer->import.sgt,
DMA_BIDIRECTIONAL);
dma_buf_unmap_attachment_unlocked(buffer->import.attach,
buffer->import.sgt,
DMA_BIDIRECTIONAL);
buffer->import.sgt = NULL;
}
if (buffer->import.attach) {
Expand Down Expand Up @@ -735,7 +735,7 @@ vc_sm_cma_import_dmabuf_internal(struct vc_sm_privdata_t *private,
goto error;
}

sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
sgt = dma_buf_map_attachment_unlocked(attach, DMA_BIDIRECTIONAL);
if (IS_ERR(sgt)) {
ret = PTR_ERR(sgt);
goto error;
Expand Down Expand Up @@ -845,7 +845,7 @@ vc_sm_cma_import_dmabuf_internal(struct vc_sm_privdata_t *private,
free_kernel_id(import.kernel_id);
kfree(buffer);
if (sgt)
dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
dma_buf_unmap_attachment_unlocked(attach, sgt, DMA_BIDIRECTIONAL);
if (attach)
dma_buf_detach(dma_buf, attach);
dma_buf_put(dma_buf);
Expand Down Expand Up @@ -1494,7 +1494,7 @@ static int bcm2835_vc_sm_cma_probe(struct vchiq_device *device)
sm_state->device = device;
mutex_init(&sm_state->map_lock);

spin_lock_init(&sm_state->kernelid_map_lock);
mutex_init(&sm_state->kernelid_map_lock);
idr_init_base(&sm_state->kernelid_map, 1);

device->dev.dma_parms = devm_kzalloc(&device->dev,
Expand Down