All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: linux-media@vger.kernel.org
Cc: laurent.pinchart@ideasonboard.com, mchehab@osg.samsung.com,
	hverkuil@xs4all.nl, javier@osg.samsung.com
Subject: [PATCH v2 06/22] media: Move media graph state for streamon/off to the pipeline
Date: Sun, 29 Nov 2015 21:20:07 +0200	[thread overview]
Message-ID: <1448824823-10372-7-git-send-email-sakari.ailus@iki.fi> (raw)
In-Reply-To: <1448824823-10372-1-git-send-email-sakari.ailus@iki.fi>

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>
---
 drivers/media/media-entity.c | 16 ++++++++--------
 include/media/media-entity.h |  6 ++++++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index fceaf44..667ab32 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -456,16 +456,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);
 
@@ -546,9 +546,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;
@@ -582,13 +582,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;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 8fd888f..4b5ca39 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -113,7 +113,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;
 };
 
 /**
-- 
2.1.4


  parent reply	other threads:[~2015-11-29 19:22 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-29 19:20 [PATCH v2 00/22] Unrestricted media entity ID range support Sakari Ailus
2015-11-29 19:20 ` [PATCH v2 01/22] media: Enforce single entity->pipe in a pipeline Sakari Ailus
2015-11-29 19:20 ` [PATCH v2 02/22] media: Introduce internal index for media entities Sakari Ailus
2015-11-29 19:20 ` [PATCH v2 03/22] media: Add an API to manage entity enumerations Sakari Ailus
2015-12-12 15:09   ` Mauro Carvalho Chehab
2015-12-13 22:12     ` Sakari Ailus
2015-12-14  0:54       ` Mauro Carvalho Chehab
2015-12-15 23:16         ` Sakari Ailus
2015-12-16  8:04           ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 04/22] media: Move struct media_entity_graph definition up Sakari Ailus
2015-12-12 15:12   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 05/22] media: Add KernelDoc documentation for struct media_entity_graph Sakari Ailus
2015-12-12 15:15   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` Sakari Ailus [this message]
2015-11-29 19:20 ` [PATCH v2 07/22] media: Amend media graph walk API by init and cleanup functions Sakari Ailus
2015-12-12 15:18   ` Mauro Carvalho Chehab
2015-12-12 15:19   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 08/22] media: Use the new media_entity_graph_walk_start() Sakari Ailus
2015-12-12 15:18   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 09/22] v4l: omap3isp: Use the new media_entity_graph_walk_start() interface Sakari Ailus
2015-12-12 15:20   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 10/22] v4l: exynos4-is: " Sakari Ailus
2015-12-12 15:21   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 11/22] v4l: xilinx: " Sakari Ailus
2015-12-12 15:22   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 12/22] v4l: vsp1: " Sakari Ailus
2015-12-12 15:24   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 13/22] media: Use entity enums in graph walk Sakari Ailus
2015-12-12 15:25   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 14/22] media: Keep using the same graph walk object for a given pipeline Sakari Ailus
2015-12-12 15:26   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 15/22] v4l: omap3isp: Use media entity enumeration API Sakari Ailus
2015-12-12 15:29   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 16/22] v4l: vsp1: " Sakari Ailus
2015-12-12 15:31   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 17/22] staging: v4l: omap4iss: Fix sub-device power management code Sakari Ailus
2015-11-29 19:20 ` [PATCH v2 18/22] staging: v4l: omap4iss: Use media entity enum API Sakari Ailus
2015-12-12 15:33   ` Mauro Carvalho Chehab
2015-11-29 19:20 ` [PATCH v2 19/22] staging: v4l: omap4iss: Use the new media_entity_graph_walk_start() interface Sakari Ailus
2015-11-29 19:20 ` [PATCH v2 20/22] staging: v4l: davinci_vpbe: " Sakari Ailus
2015-11-29 19:20 ` [PATCH v2 21/22] media: Rename MEDIA_ENTITY_ENUM_MAX_ID as MEDIA_ENTITY_ENUM_STACK_ALLOC Sakari Ailus
2015-11-29 19:20 ` [PATCH v2 22/22] media: Update media graph walk documentation for the changed API Sakari Ailus
2015-12-12 15:35   ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448824823-10372-7-git-send-email-sakari.ailus@iki.fi \
    --to=sakari.ailus@iki.fi \
    --cc=hverkuil@xs4all.nl \
    --cc=javier@osg.samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.