mutex_lock(&mdev->graph_mutex);
- ret = media_entity_graph_walk_init(&pipe->graph, mdev);
- if (ret) {
- mutex_unlock(&mdev->graph_mutex);
- return ret;
+ if (!pipe->streaming_count++) {
+ ret = media_entity_graph_walk_init(&pipe->graph, mdev);
+ if (ret)
+ goto error_graph_walk_start;
}
media_entity_graph_walk_start(&pipe->graph, entity);
break;
}
- media_entity_graph_walk_cleanup(graph);
+error_graph_walk_start:
+ if (!--pipe->streaming_count)
+ media_entity_graph_walk_cleanup(graph);
mutex_unlock(&mdev->graph_mutex);
{
struct media_device *mdev = entity->graph_obj.mdev;
struct media_entity_graph *graph = &entity->pipe->graph;
+ struct media_pipeline *pipe = entity->pipe;
mutex_lock(&mdev->graph_mutex);
+ WARN_ON(!pipe->streaming_count);
media_entity_graph_walk_start(graph, entity);
while ((entity = media_entity_graph_walk_next(graph))) {
entity->pipe = NULL;
}
- media_entity_graph_walk_cleanup(graph);
+ if (!--pipe->streaming_count)
+ media_entity_graph_walk_cleanup(graph);
mutex_unlock(&mdev->graph_mutex);
}
/*
* struct media_pipeline - Media pipeline related information
*
- * @graph: Media graph walk during pipeline start / stop
+ * @streaming_count: Streaming start count - streaming stop count
+ * @graph: Media graph walk during pipeline start / stop
*/
struct media_pipeline {
+ int streaming_count;
struct media_entity_graph graph;
};