Commit adb8963f authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] v4l: vsp1: Don't sleep in atomic context

The vsp1_entity_is_streaming() function is called in atomic context when
queuing buffers, and sleeps due to a mutex. As the mutex just protects
access to one structure field, fix this by replace the mutex with a
spinlock.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent df5c3e7c
...@@ -24,22 +24,24 @@ ...@@ -24,22 +24,24 @@
bool vsp1_entity_is_streaming(struct vsp1_entity *entity) bool vsp1_entity_is_streaming(struct vsp1_entity *entity)
{ {
unsigned long flags;
bool streaming; bool streaming;
mutex_lock(&entity->lock); spin_lock_irqsave(&entity->lock, flags);
streaming = entity->streaming; streaming = entity->streaming;
mutex_unlock(&entity->lock); spin_unlock_irqrestore(&entity->lock, flags);
return streaming; return streaming;
} }
int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming) int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
{ {
unsigned long flags;
int ret; int ret;
mutex_lock(&entity->lock); spin_lock_irqsave(&entity->lock, flags);
entity->streaming = streaming; entity->streaming = streaming;
mutex_unlock(&entity->lock); spin_unlock_irqrestore(&entity->lock, flags);
if (!streaming) if (!streaming)
return 0; return 0;
...@@ -49,9 +51,9 @@ int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming) ...@@ -49,9 +51,9 @@ int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
ret = v4l2_ctrl_handler_setup(entity->subdev.ctrl_handler); ret = v4l2_ctrl_handler_setup(entity->subdev.ctrl_handler);
if (ret < 0) { if (ret < 0) {
mutex_lock(&entity->lock); spin_lock_irqsave(&entity->lock, flags);
entity->streaming = false; entity->streaming = false;
mutex_unlock(&entity->lock); spin_unlock_irqrestore(&entity->lock, flags);
} }
return ret; return ret;
...@@ -193,7 +195,7 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, ...@@ -193,7 +195,7 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
if (i == ARRAY_SIZE(vsp1_routes)) if (i == ARRAY_SIZE(vsp1_routes))
return -EINVAL; return -EINVAL;
mutex_init(&entity->lock); spin_lock_init(&entity->lock);
entity->vsp1 = vsp1; entity->vsp1 = vsp1;
entity->source_pad = num_pads - 1; entity->source_pad = num_pads - 1;
...@@ -228,6 +230,4 @@ void vsp1_entity_destroy(struct vsp1_entity *entity) ...@@ -228,6 +230,4 @@ void vsp1_entity_destroy(struct vsp1_entity *entity)
if (entity->subdev.ctrl_handler) if (entity->subdev.ctrl_handler)
v4l2_ctrl_handler_free(entity->subdev.ctrl_handler); v4l2_ctrl_handler_free(entity->subdev.ctrl_handler);
media_entity_cleanup(&entity->subdev.entity); media_entity_cleanup(&entity->subdev.entity);
mutex_destroy(&entity->lock);
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#define __VSP1_ENTITY_H__ #define __VSP1_ENTITY_H__
#include <linux/list.h> #include <linux/list.h>
#include <linux/mutex.h> #include <linux/spinlock.h>
#include <media/v4l2-subdev.h> #include <media/v4l2-subdev.h>
...@@ -73,7 +73,7 @@ struct vsp1_entity { ...@@ -73,7 +73,7 @@ struct vsp1_entity {
struct vsp1_video *video; struct vsp1_video *video;
struct mutex lock; /* Protects the streaming field */ spinlock_t lock; /* Protects the streaming field */
bool streaming; bool streaming;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment