[media] media: Move media graph state for streamon/off to the pipeline
authorSakari Ailus <sakari.ailus@iki.fi>
Wed, 16 Dec 2015 13:32:21 +0000 (11:32 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:18 +0000 (12:19 -0200)
The struct media_entity_graph was allocated in the stack, limiting the
number of entities that could be reasonably allocated. Instead, move the
struct to struct media_pipeline which is typically allocated using
kmalloc() instead.

The intent is to keep the enumeration around for later use for the
duration of the streaming. As streaming is eventually stopped, an
unfortunate memory allocation failure would prevent stopping the
streaming. As no memory will need to be allocated, the problem is avoided
altogether.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/media-entity.c
include/media/media-entity.h

index 5e3f32f631876f832e2dbb625ba36067489d39e8..83cfde6dcb1ca1f50d9e9085112551c6acc19b31 100644 (file)
@@ -349,16 +349,16 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
                                             struct media_pipeline *pipe)
 {
        struct media_device *mdev = entity->graph_obj.mdev;
-       struct media_entity_graph graph;
+       struct media_entity_graph *graph = &pipe->graph;
        struct media_entity *entity_err = entity;
        struct media_link *link;
        int ret;
 
        mutex_lock(&mdev->graph_mutex);
 
-       media_entity_graph_walk_start(&graph, entity);
+       media_entity_graph_walk_start(graph, entity);
 
-       while ((entity = media_entity_graph_walk_next(&graph))) {
+       while ((entity = media_entity_graph_walk_next(graph))) {
                DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS);
                DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS);
 
@@ -439,9 +439,9 @@ error:
         * Link validation on graph failed. We revert what we did and
         * return the error.
         */
-       media_entity_graph_walk_start(&graph, entity_err);
+       media_entity_graph_walk_start(graph, entity_err);
 
-       while ((entity_err = media_entity_graph_walk_next(&graph))) {
+       while ((entity_err = media_entity_graph_walk_next(graph))) {
                entity_err->stream_count--;
                if (entity_err->stream_count == 0)
                        entity_err->pipe = NULL;
@@ -463,13 +463,13 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
 void media_entity_pipeline_stop(struct media_entity *entity)
 {
        struct media_device *mdev = entity->graph_obj.mdev;
-       struct media_entity_graph graph;
+       struct media_entity_graph *graph = &entity->pipe->graph;
 
        mutex_lock(&mdev->graph_mutex);
 
-       media_entity_graph_walk_start(&graph, entity);
+       media_entity_graph_walk_start(graph, entity);
 
-       while ((entity = media_entity_graph_walk_next(&graph))) {
+       while ((entity = media_entity_graph_walk_next(graph))) {
                entity->stream_count--;
                if (entity->stream_count == 0)
                        entity->pipe = NULL;
index edfb6163caa3518b974ddb656961bc21b07ec522..4dc3bef72c9dbccc750ba0b06de544cb77c6ef4c 100644 (file)
@@ -116,7 +116,13 @@ struct media_entity_graph {
        int top;
 };
 
+/*
+ * struct media_pipeline - Media pipeline related information
+ *
+ * @graph:     Media graph walk during pipeline start / stop
+ */
 struct media_pipeline {
+       struct media_entity_graph graph;
 };
 
 /**