From patchwork Wed Dec 16 13:32:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 7861891 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 6E6F6BEEE1 for ; Wed, 16 Dec 2015 13:35:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D80A2034A for ; Wed, 16 Dec 2015 13:35:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 15827202FF for ; Wed, 16 Dec 2015 13:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754438AbbLPNfU (ORCPT ); Wed, 16 Dec 2015 08:35:20 -0500 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:60619 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932562AbbLPNeu (ORCPT ); Wed, 16 Dec 2015 08:34:50 -0500 Received: from lanttu.localdomain (unknown [192.168.15.166]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id C1F7B600A9; Wed, 16 Dec 2015 15:34:47 +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 14/23] media: Keep using the same graph walk object for a given pipeline Date: Wed, 16 Dec 2015 15:32:29 +0200 Message-Id: <1450272758-29446-15-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 Initialise a given graph walk object once, and then keep using it whilst the same pipeline is running. Once the pipeline is stopped, release the graph walk object. Signed-off-by: Sakari Ailus --- drivers/media/media-entity.c | 17 +++++++++++------ include/media/media-entity.h | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 2dd60d75..ddf3c23 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -488,10 +488,10 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, 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); @@ -592,7 +592,9 @@ error: 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); @@ -616,9 +618,11 @@ void media_entity_pipeline_stop(struct media_entity *entity) { 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))) { @@ -627,7 +631,8 @@ void media_entity_pipeline_stop(struct media_entity *entity) entity->pipe = NULL; } - media_entity_graph_walk_cleanup(graph); + if (!--pipe->streaming_count) + media_entity_graph_walk_cleanup(graph); mutex_unlock(&mdev->graph_mutex); } diff --git a/include/media/media-entity.h b/include/media/media-entity.h index c29ddc2..251eddf 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -119,9 +119,11 @@ struct media_entity_graph { /* * 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; };