From patchwork Fri Jan 6 12:15:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9500859 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F8436071A for ; Fri, 6 Jan 2017 12:18:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4365820246 for ; Fri, 6 Jan 2017 12:18:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32846284AE; Fri, 6 Jan 2017 12:18:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 860EC28480 for ; Fri, 6 Jan 2017 12:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161361AbdAFMRk (ORCPT ); Fri, 6 Jan 2017 07:17:40 -0500 Received: from mail.kernel.org ([198.145.29.136]:43272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761840AbdAFMQY (ORCPT ); Fri, 6 Jan 2017 07:16:24 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E866203E6; Fri, 6 Jan 2017 12:15:43 +0000 (UTC) Received: from CookieMonster.cookiemonster.local (cpc89244-aztw30-2-0-cust5770.18-1.cable.virginm.net [86.31.182.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 80787203EC; Fri, 6 Jan 2017 12:15:41 +0000 (UTC) From: Kieran Bingham To: laurent.pinchart@ideasonboard.com Cc: linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, Kieran Bingham Subject: [PATCH v4 3/4] v4l: vsp1: Repair suspend resume operations for video pipelines Date: Fri, 6 Jan 2017 12:15:30 +0000 Message-Id: <8f5f1d1a0102c4c5713950d062077f65e38b6b93.1483704413.git-series.kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a suspend/resume action is taken, the pipeline is reset and never reconfigured. To correct this, we establish a new flag pipe->configured and utilise this to establish when we write a full configuration set to the current display list. Signed-off-by: Kieran Bingham --- drivers/media/platform/vsp1/vsp1_drv.c | 4 ++- drivers/media/platform/vsp1/vsp1_pipe.c | 1 +- drivers/media/platform/vsp1/vsp1_pipe.h | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 56 ++++++++++--------------- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index aa237b48ad55..d596cdead1c1 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -413,6 +413,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) int vsp1_reset_wpf(struct vsp1_device *vsp1, unsigned int index) { + struct vsp1_rwpf *wpf = vsp1->wpf[index]; unsigned int timeout; u32 status; @@ -429,6 +430,9 @@ int vsp1_reset_wpf(struct vsp1_device *vsp1, unsigned int index) usleep_range(1000, 2000); } + if (wpf->pipe) + wpf->pipe->configured = false; + if (!timeout) { dev_err(vsp1->dev, "failed to reset wpf.%u\n", index); return -ETIMEDOUT; diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c index 280ba0804699..c568db193fba 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.c +++ b/drivers/media/platform/vsp1/vsp1_pipe.c @@ -216,6 +216,7 @@ void vsp1_pipeline_init(struct vsp1_pipeline *pipe) INIT_LIST_HEAD(&pipe->entities); pipe->state = VSP1_PIPELINE_STOPPED; + pipe->configured = false; } /* Must be called with the pipe irqlock held. */ diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h b/drivers/media/platform/vsp1/vsp1_pipe.h index ac4ad2655551..fff122b4874d 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.h +++ b/drivers/media/platform/vsp1/vsp1_pipe.h @@ -61,6 +61,7 @@ enum vsp1_pipeline_state { * @pipe: the media pipeline * @irqlock: protects the pipeline state * @state: current state + * @configured: true if the pipeline has been set up for video streaming * @wq: wait queue to wait for state change completion * @frame_end: frame end interrupt handler * @lock: protects the pipeline use count and stream count @@ -86,6 +87,7 @@ struct vsp1_pipeline { spinlock_t irqlock; enum vsp1_pipeline_state state; + bool configured; wait_queue_head_t wq; void (*frame_end)(struct vsp1_pipeline *pipe); diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 938ecc2766ed..414303442e7c 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -355,18 +355,14 @@ static void vsp1_video_frame_end(struct vsp1_pipeline *pipe, pipe->buffers_ready |= 1 << video->pipe_index; } -static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe) +static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe, + struct vsp1_dl_list *dl) { struct vsp1_entity *entity; /* Determine this pipelines sizes for image partitioning support. */ vsp1_video_pipeline_setup_partitions(pipe); - /* Prepare the display list. */ - pipe->dl = vsp1_dl_list_get(pipe->output->dlm); - if (!pipe->dl) - return -ENOMEM; - if (pipe->uds) { struct vsp1_uds *uds = to_uds(&pipe->uds->subdev); @@ -386,13 +382,15 @@ static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe) } list_for_each_entry(entity, &pipe->entities, list_pipe) { - vsp1_entity_route_setup(entity, pipe->dl); + vsp1_entity_route_setup(entity, dl); if (entity->ops->configure) - entity->ops->configure(entity, pipe, pipe->dl, + entity->ops->configure(entity, pipe, dl, VSP1_ENTITY_PARAMS_INIT); } + pipe->configured = true; + return 0; } @@ -415,9 +413,16 @@ static void vsp1_video_pipeline_run(struct vsp1_pipeline *pipe) { struct vsp1_device *vsp1 = pipe->output->entity.vsp1; struct vsp1_entity *entity; + struct vsp1_dl_list *dl; - if (!pipe->dl) - pipe->dl = vsp1_dl_list_get(pipe->output->dlm); + dl = vsp1_dl_list_get(pipe->output->dlm); + if (!dl) { + dev_err(vsp1->dev, "Failed to obtain a dl list\n"); + return; + } + + if (!pipe->configured) + vsp1_video_setup_pipeline(pipe, dl); /* * Start with the runtime parameters as the configure operation can @@ -426,45 +431,43 @@ static void vsp1_video_pipeline_run(struct vsp1_pipeline *pipe) */ list_for_each_entry(entity, &pipe->entities, list_pipe) { if (entity->ops->configure) - entity->ops->configure(entity, pipe, pipe->dl, + entity->ops->configure(entity, pipe, dl, VSP1_ENTITY_PARAMS_RUNTIME); } /* Run the first partition */ pipe->current_partition = 0; - vsp1_video_pipeline_run_partition(pipe, pipe->dl); + vsp1_video_pipeline_run_partition(pipe, dl); /* Process consecutive partitions as necessary */ for (pipe->current_partition = 1; pipe->current_partition < pipe->partitions; pipe->current_partition++) { - struct vsp1_dl_list *dl; + struct vsp1_dl_list *child; /* * Partition configuration operations will utilise * the pipe->current_partition variable to determine * the work they should complete. */ - dl = vsp1_dl_list_get(pipe->output->dlm); + child = vsp1_dl_list_get(pipe->output->dlm); /* * An incomplete chain will still function, but output only * the partitions that had a dl available. The frame end * interrupt will be marked on the last dl in the chain. */ - if (!dl) { + if (!child) { dev_err(vsp1->dev, "Failed to obtain a dl list. Frame will be incomplete\n"); break; } - vsp1_video_pipeline_run_partition(pipe, dl); - vsp1_dl_list_add_chain(pipe->dl, dl); + vsp1_video_pipeline_run_partition(pipe, child); + vsp1_dl_list_add_chain(dl, child); } /* Complete, and commit the head display list. */ - vsp1_dl_list_commit(pipe->dl); - pipe->dl = NULL; - + vsp1_dl_list_commit(dl); vsp1_pipeline_run(pipe); } @@ -799,18 +802,10 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) struct vsp1_pipeline *pipe = video->rwpf->pipe; bool start_pipeline = false; unsigned long flags; - int ret; mutex_lock(&pipe->lock); - if (pipe->stream_count == pipe->num_inputs) { - ret = vsp1_video_setup_pipeline(pipe); - if (ret < 0) { - mutex_unlock(&pipe->lock); - return ret; - } - + if (pipe->stream_count == pipe->num_inputs) start_pipeline = true; - } pipe->stream_count++; mutex_unlock(&pipe->lock); @@ -855,9 +850,6 @@ static void vsp1_video_stop_streaming(struct vb2_queue *vq) ret = vsp1_pipeline_stop(pipe); if (ret == -ETIMEDOUT) dev_err(video->vsp1->dev, "pipeline stop timeout\n"); - - vsp1_dl_list_put(pipe->dl); - pipe->dl = NULL; } mutex_unlock(&pipe->lock);