[media] media-entity: protect object creation/removal using spin lock
Some parts of the media controller are using mutexes while others are using spin locks in order to protect creation and removal of elements in the graph. That's wrong! Also, the V4L2 core can remove graph elements on non-interactive context: BUG: sleeping function called from invalid context at include/linux/sched.h:2776 Fix it by always using spin locks for graph element addition/removal, just like entity creation/removal is protected at media-device.c Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
d47109fa45
commit
a08fad1ec8
2 changed files with 9 additions and 9 deletions
|
@ -700,9 +700,9 @@ void media_entity_remove_links(struct media_entity *entity)
|
||||||
if (entity->graph_obj.mdev == NULL)
|
if (entity->graph_obj.mdev == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mutex_lock(&entity->graph_obj.mdev->graph_mutex);
|
spin_lock(&entity->graph_obj.mdev->lock);
|
||||||
__media_entity_remove_links(entity);
|
__media_entity_remove_links(entity);
|
||||||
mutex_unlock(&entity->graph_obj.mdev->graph_mutex);
|
spin_unlock(&entity->graph_obj.mdev->lock);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(media_entity_remove_links);
|
EXPORT_SYMBOL_GPL(media_entity_remove_links);
|
||||||
|
|
||||||
|
@ -792,9 +792,9 @@ int media_entity_setup_link(struct media_link *link, u32 flags)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&link->source->entity->graph_obj.mdev->graph_mutex);
|
spin_lock(&link->source->entity->graph_obj.mdev->lock);
|
||||||
ret = __media_entity_setup_link(link, flags);
|
ret = __media_entity_setup_link(link, flags);
|
||||||
mutex_unlock(&link->source->entity->graph_obj.mdev->graph_mutex);
|
spin_unlock(&link->source->entity->graph_obj.mdev->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -932,9 +932,9 @@ EXPORT_SYMBOL_GPL(__media_remove_intf_link);
|
||||||
|
|
||||||
void media_remove_intf_link(struct media_link *link)
|
void media_remove_intf_link(struct media_link *link)
|
||||||
{
|
{
|
||||||
mutex_lock(&link->graph_obj.mdev->graph_mutex);
|
spin_lock(&link->graph_obj.mdev->lock);
|
||||||
__media_remove_intf_link(link);
|
__media_remove_intf_link(link);
|
||||||
mutex_unlock(&link->graph_obj.mdev->graph_mutex);
|
spin_unlock(&link->graph_obj.mdev->lock);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(media_remove_intf_link);
|
EXPORT_SYMBOL_GPL(media_remove_intf_link);
|
||||||
|
|
||||||
|
@ -954,8 +954,8 @@ void media_remove_intf_links(struct media_interface *intf)
|
||||||
if (intf->graph_obj.mdev == NULL)
|
if (intf->graph_obj.mdev == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mutex_lock(&intf->graph_obj.mdev->graph_mutex);
|
spin_lock(&intf->graph_obj.mdev->lock);
|
||||||
__media_remove_intf_links(intf);
|
__media_remove_intf_links(intf);
|
||||||
mutex_unlock(&intf->graph_obj.mdev->graph_mutex);
|
spin_unlock(&intf->graph_obj.mdev->lock);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(media_remove_intf_links);
|
EXPORT_SYMBOL_GPL(media_remove_intf_links);
|
||||||
|
|
|
@ -88,7 +88,7 @@ struct media_device {
|
||||||
struct list_head pads;
|
struct list_head pads;
|
||||||
struct list_head links;
|
struct list_head links;
|
||||||
|
|
||||||
/* Protects the entities list */
|
/* Protects the graph objects creation/removal */
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
/* Serializes graph operations. */
|
/* Serializes graph operations. */
|
||||||
struct mutex graph_mutex;
|
struct mutex graph_mutex;
|
||||||
|
|
Loading…
Reference in a new issue