From patchwork Wed Jul 22 22:42:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 6851351 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 66D939F1D4 for ; Thu, 23 Jul 2015 06:20:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 659B2204C9 for ; Thu, 23 Jul 2015 06:20:11 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0BFB12043C for ; Thu, 23 Jul 2015 06:20:10 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 293462660A4; Thu, 23 Jul 2015 08:20:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 7D245265864; Thu, 23 Jul 2015 08:08:56 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id BB036265743; Thu, 23 Jul 2015 00:43:13 +0200 (CEST) Received: from resqmta-po-07v.sys.comcast.net (resqmta-po-07v.sys.comcast.net [96.114.154.166]) by alsa0.perex.cz (Postfix) with ESMTP id 7E0E3265611 for ; Thu, 23 Jul 2015 00:42:55 +0200 (CEST) Received: from resomta-po-08v.sys.comcast.net ([96.114.154.232]) by resqmta-po-07v.sys.comcast.net with comcast id vaiW1q004516pyw01aiv5x; Wed, 22 Jul 2015 22:42:55 +0000 Received: from mail.gonehiking.org ([73.181.52.62]) by resomta-po-08v.sys.comcast.net with comcast id vait1q0041LXgTt01ait8A; Wed, 22 Jul 2015 22:42:55 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id D09C6120449; Wed, 22 Jul 2015 16:42:52 -0600 (MDT) From: Shuah Khan To: mchehab@osg.samsung.com, hans.verkuil@cisco.com, laurent.pinchart@ideasonboard.com, tiwai@suse.de, sakari.ailus@linux.intel.com, perex@perex.cz, crope@iki.fi, arnd@arndb.de, stefanr@s5r6.in-berlin.de, ruchandani.tina@gmail.com, chehabrafael@gmail.com, dan.carpenter@oracle.com, prabhakar.csengg@gmail.com, chris.j.arges@canonical.com, agoode@google.com, pierre-louis.bossart@linux.intel.com, gtmkramer@xs4all.nl, clemens@ladisch.de, daniel@zonque.org, vladcatoi@gmail.com, misterpib@gmail.com, damien@zamaudio.com, pmatilai@laiskiainen.org, takamichiho@gmail.com, normalperson@yhbt.net, bugzilla.frnkcg@spamgourmet.com, joe@oampo.co.uk, calcprogrammer1@gmail.com, jussi@sonarnerd.net, kyungmin.park@samsung.com, s.nawrocki@samsung.com, kgene@kernel.org, hyun.kwon@xilinx.com, michal.simek@xilinx.com, soren.brinkmann@xilinx.com, pawel@osciak.com, m.szyprowski@samsung.com, gregkh@linuxfoundation.org, skd08@gmail.com, nsekhar@ti.com, boris.brezillon@free-electrons.com, Julia.Lawall@lip6.fr, elfring@users.sourceforge.net, p.zabel@pengutronix.de, ricardo.ribalda@gmail.com Date: Wed, 22 Jul 2015 16:42:14 -0600 Message-Id: <84442c1c9f7f725189a935936751fc4117ae9c5f.1437599281.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1437604975; bh=gH+TVIKxzPbXakFLLz33FUMHLsb67p4iLtJ8FXHTzkg=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=P/sCBLAAUaJ3ooeL5aurI4LFitxNB6PhpPEHBaymEOIDakvlJ7r8DugXTLOQGmKrh 8wFrotZU9KD3qFs8cIZAsTMVdA1WnfBajWOy+q/pllZddHWQai9Hntu2o//wvbkIa0 Q9kPsS8PsvSESnBmK6qs+gYed2YcOuuRELKx4QQ7/HGcFWPq3G5ZEymn8ERDpTj/TI 83Y9gysneiLlL3xnSbDaV+mlnbMox7xNxBtzd+EpfC03OfuhcKv6Ka5kM+ABuGTidH uZU28GeHIJsTw6hWgCWd4fhnJFLJvPevci09k6kYYS5lkYFB1gzrObOzUH2rQol3il 6JNqkhLZ0yDdQ== X-Mailman-Approved-At: Thu, 23 Jul 2015 08:08:34 +0200 Cc: devel@driverdev.osuosl.org, alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Subject: [alsa-devel] [PATCH v2 13/19] media: Add irq safe Media Controller start/stop pipeline API X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Add irq safe Media Controller start/stop pipeline API media_entity_pipeline_start_irq() media_entity_pipeline_stop_irq() to be used from inside interrupt context. Signed-off-by: Shuah Khan --- drivers/media/media-entity.c | 80 +++++++++++++++++++++++++++++++++++++------- include/media/media-entity.h | 3 ++ 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 31132573..293cf25 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -210,6 +210,8 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next); /** * media_entity_pipeline_start - Mark a pipeline as streaming + * media_entity_pipeline_start_irq - Mark a pipeline as streaming + * (safe to be used from inside interrupt context) * @entity: Starting entity * @pipe: Media pipeline to be assigned to all entities in the pipeline. * @@ -222,16 +224,18 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next); * pipeline pointer must be identical for all nested calls to * media_entity_pipeline_start(). */ -__must_check int media_entity_pipeline_start(struct media_entity *entity, - struct media_pipeline *pipe) +/* + * __media_entity_pipeline_start() + * Should be called with graph_lock held +*/ +static __must_check int __media_entity_pipeline_start( + struct media_entity *entity, + struct media_pipeline *pipe) { - struct media_device *mdev = entity->parent; struct media_entity_graph graph; struct media_entity *entity_err = entity; int ret; - spin_lock(&mdev->graph_lock); - media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { @@ -303,8 +307,6 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, } } - spin_unlock(&mdev->graph_lock); - return 0; error: @@ -327,14 +329,46 @@ error: break; } - spin_unlock(&mdev->graph_lock); + return ret; +} +/* + * media_entity_pipeline_start - Mark a pipeline as streaming + * (unsafe to be used from inside interrupt context) +*/ +__must_check int media_entity_pipeline_start(struct media_entity *entity, + struct media_pipeline *pipe) +{ + int ret; + + spin_lock(&entity->parent->graph_lock); + ret = __media_entity_pipeline_start(entity, pipe); + spin_unlock(&entity->parent->graph_lock); return ret; } EXPORT_SYMBOL_GPL(media_entity_pipeline_start); +/* + * media_entity_pipeline_start_irq - Mark a pipeline as streaming + * (safe to be used from inside interrupt context) +*/ +__must_check int media_entity_pipeline_start_irq(struct media_entity *entity, + struct media_pipeline *pipe) +{ + int ret; + unsigned long flags; + + spin_lock_irqsave(&entity->parent->graph_lock, flags); + ret = __media_entity_pipeline_start(entity, pipe); + spin_unlock_irqrestore(&entity->parent->graph_lock, flags); + return ret; +} +EXPORT_SYMBOL_GPL(media_entity_pipeline_start_irq); + /** * media_entity_pipeline_stop - Mark a pipeline as not streaming + * media_entity_pipeline_stop_irq - Mark a pipeline as not streaming + * (safe to be used from inside interrupt context) * @entity: Starting entity * * Mark all entities connected to a given entity through enabled links, either @@ -345,13 +379,10 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start); * number of calls to this function are required to mark the pipeline as not * streaming. */ -void media_entity_pipeline_stop(struct media_entity *entity) +static void __media_entity_pipeline_stop(struct media_entity *entity) { - struct media_device *mdev = entity->parent; struct media_entity_graph graph; - spin_lock(&mdev->graph_lock); - media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { @@ -359,11 +390,34 @@ void media_entity_pipeline_stop(struct media_entity *entity) if (entity->stream_count == 0) entity->pipe = NULL; } +} - spin_unlock(&mdev->graph_lock); +/* + * media_entity_pipeline_stop - Mark a pipeline as not streaming + * (unsafe to be used from inside interrupt context) +*/ +void media_entity_pipeline_stop(struct media_entity *entity) +{ + spin_lock(&entity->parent->graph_lock); + __media_entity_pipeline_stop(entity); + spin_unlock(&entity->parent->graph_lock); } EXPORT_SYMBOL_GPL(media_entity_pipeline_stop); +/* + * media_entity_pipeline_stop_irq - Mark a pipeline as not streaming + * (safe to be used from inside interrupt context) +*/ +void media_entity_pipeline_stop_irq(struct media_entity *entity) +{ + unsigned long flags; + + spin_lock_irqsave(&entity->parent->graph_lock, flags); + __media_entity_pipeline_stop(entity); + spin_unlock_irqrestore(&entity->parent->graph_lock, flags); +} +EXPORT_SYMBOL_GPL(media_entity_pipeline_stop_irq); + /* ----------------------------------------------------------------------------- * Module use count */ diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 0c003d8..a4be306 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -151,6 +151,9 @@ media_entity_graph_walk_next(struct media_entity_graph *graph); __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe); void media_entity_pipeline_stop(struct media_entity *entity); +__must_check int media_entity_pipeline_start_irq(struct media_entity *entity, + struct media_pipeline *pipe); +void media_entity_pipeline_stop_irq(struct media_entity *entity); #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \