From patchwork Wed Dec 16 13:32:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 7861751 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D1B16BEEE1 for ; Wed, 16 Dec 2015 13:34:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A8A36202FF for ; Wed, 16 Dec 2015 13:34:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B769D201EF for ; Wed, 16 Dec 2015 13:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933085AbbLPNew (ORCPT ); Wed, 16 Dec 2015 08:34:52 -0500 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:60597 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754518AbbLPNet (ORCPT ); Wed, 16 Dec 2015 08:34:49 -0500 Received: from lanttu.localdomain (unknown [192.168.15.166]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 6A1C1600A1; Wed, 16 Dec 2015 15:34:45 +0200 (EET) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, mchehab@osg.samsung.com, hverkuil@xs4all.nl, javier@osg.samsung.com Subject: [PATCH v3 06/23] media: Move media graph state for streamon/off to the pipeline Date: Wed, 16 Dec 2015 15:32:21 +0200 Message-Id: <1450272758-29446-7-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450272758-29446-1-git-send-email-sakari.ailus@iki.fi> References: <1450272758-29446-1-git-send-email-sakari.ailus@iki.fi> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Mauro Carvalho Chehab --- 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 67eebcb..786a01f 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 3068c30..9315158 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -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; }; /**