Commit 0c426c47 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] media: Always keep a graph walk large enough around

Re-create the graph walk object as needed in order to have one large enough
available for all entities in the graph.

This enumeration is used for pipeline power management in the future.

[mchehab@osg.samsung.com: fix documentation bug:
 " warning: bad line: graph_mutex"]
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 4f27dba6
...@@ -589,6 +589,26 @@ int __must_check media_device_register_entity(struct media_device *mdev, ...@@ -589,6 +589,26 @@ int __must_check media_device_register_entity(struct media_device *mdev,
spin_unlock(&mdev->lock); spin_unlock(&mdev->lock);
mutex_lock(&mdev->graph_mutex);
if (mdev->entity_internal_idx_max
>= mdev->pm_count_walk.ent_enum.idx_max) {
struct media_entity_graph new = { .top = 0 };
/*
* Initialise the new graph walk before cleaning up
* the old one in order not to spoil the graph walk
* object of the media device if graph walk init fails.
*/
ret = media_entity_graph_walk_init(&new, mdev);
if (ret) {
mutex_unlock(&mdev->graph_mutex);
return ret;
}
media_entity_graph_walk_cleanup(&mdev->pm_count_walk);
mdev->pm_count_walk = new;
}
mutex_unlock(&mdev->graph_mutex);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(media_device_register_entity); EXPORT_SYMBOL_GPL(media_device_register_entity);
...@@ -667,6 +687,7 @@ void media_device_cleanup(struct media_device *mdev) ...@@ -667,6 +687,7 @@ void media_device_cleanup(struct media_device *mdev)
{ {
ida_destroy(&mdev->entity_internal_idx); ida_destroy(&mdev->entity_internal_idx);
mdev->entity_internal_idx_max = 0; mdev->entity_internal_idx_max = 0;
media_entity_graph_walk_cleanup(&mdev->pm_count_walk);
mutex_destroy(&mdev->graph_mutex); mutex_destroy(&mdev->graph_mutex);
} }
EXPORT_SYMBOL_GPL(media_device_cleanup); EXPORT_SYMBOL_GPL(media_device_cleanup);
......
...@@ -306,6 +306,8 @@ struct media_entity_notify { ...@@ -306,6 +306,8 @@ struct media_entity_notify {
* @entity_notify: List of registered entity_notify callbacks * @entity_notify: List of registered entity_notify callbacks
* @lock: Entities list lock * @lock: Entities list lock
* @graph_mutex: Entities graph operation lock * @graph_mutex: Entities graph operation lock
* @pm_count_walk: Graph walk for power state walk. Access serialised using
* graph_mutex.
* *
* @source_priv: Driver Private data for enable/disable source handlers * @source_priv: Driver Private data for enable/disable source handlers
* @enable_source: Enable Source Handler function pointer * @enable_source: Enable Source Handler function pointer
...@@ -373,6 +375,7 @@ struct media_device { ...@@ -373,6 +375,7 @@ struct media_device {
spinlock_t lock; spinlock_t lock;
/* Serializes graph operations. */ /* Serializes graph operations. */
struct mutex graph_mutex; struct mutex graph_mutex;
struct media_entity_graph pm_count_walk;
void *source_priv; void *source_priv;
int (*enable_source)(struct media_entity *entity, int (*enable_source)(struct media_entity *entity,
......
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