Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2996642imm; Sun, 1 Jul 2018 09:59:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKICkMVipxoxeehz3rgwsxacn7tXyRjLGFEZsasc9Gbn/dPr+FbowfCOD9vRhrn8+0dpqI87 X-Received: by 2002:a65:4005:: with SMTP id f5-v6mr18249682pgp.302.1530464365265; Sun, 01 Jul 2018 09:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464365; cv=none; d=google.com; s=arc-20160816; b=BiJ80/vyWbnJGzn+kS67iob6yyniY+H2hbn9X9kl9W2fSszJSOhLaknvdg3FC0xBhw z2+yKllfFCdWBqgMZjuX9SvfLvTXnORMfB1p/7r+VxBdlDqEbSAXDh/bBS+XDcJn3SoA z1P+p34gdxTsXMhYumrQMcJEHQYlEMfK7YrI7IRjV0OvyljNhWwo++uNyjR6ZGdGPFPr lae1HAIWPZbzVzXZyEFnz7KT/s44ekVuyaB3lM0w6o6cdvKle4qiU4Qe5/m2GrCHpvw6 x3cVLGLIA2ae1kJYEEVDiehPtLsby6OiDq+RxeN/xpzH/dj2mSQ4XwP5sUzsrCvk8csv J5rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ztn+Be8uVTvS9JG7Lfk8Mne5ul8qPIlh9QeRROUWU1I=; b=vjZRBw04fORYnYRf+eaQJ3g7jlFuQwWlqJXkDzXgwCTT7KfzTwvAeI0aJbG5Y98IJm XmJjq7+c3GU1YO5KYUlnCAZF5YT6PsJee1BFmj3b4ViS3tjLo0PAF90QdHDnONdYwgNr Bv7FEamZ3w9ysqgMDcoUPtLeWpVaGzXOi5YDBu3sUIigeyHnQ0MBBGS+vGc/9rAoVFgx peIbMcdBm2EJNOX9vF/5JX48/+CM09lqDeluO/3tEfxhV/jtsVO+/a5AIPrkaYawtDEN ZXJax4mQs8n8lvpkqpVrbV9Lp8k/p07TCWo4FOoJjWfCIujJJcYnSrlYdUm4WU9oFnit rkmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6-v6si12277882pgu.644.2018.07.01.09.59.10; Sun, 01 Jul 2018 09:59:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753649AbeGAQoe (ORCPT + 99 others); Sun, 1 Jul 2018 12:44:34 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38050 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753641AbeGAQoa (ORCPT ); Sun, 1 Jul 2018 12:44:30 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BEE8F92B; Sun, 1 Jul 2018 16:44:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kieran Bingham , Laurent Pinchart , Mauro Carvalho Chehab Subject: [PATCH 4.17 173/220] media: vsp1: Release buffers for each video node Date: Sun, 1 Jul 2018 18:23:17 +0200 Message-Id: <20180701160915.467611116@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kieran Bingham commit 83967993f2320575c0ab27a80bf1d7535909c2f4 upstream. Commit 372b2b0399fc ("media: v4l: vsp1: Release buffers in start_streaming error path") introduced a helper to clean up buffers on error paths, but inadvertently changed the code such that only the output WPF buffers were cleaned, rather than the video node being operated on. Since then vsp1_video_cleanup_pipeline() has grown to perform both video node cleanup, as well as pipeline cleanup. Split the implementation into two distinct functions that perform the required work, so that each video node can release its buffers correctly on streamoff. The pipe cleanup that was performed in the vsp1_video_stop_streaming() (releasing the pipe->dl) is moved to the function for clarity. Fixes: 372b2b0399fc ("media: v4l: vsp1: Release buffers in start_streaming error path") Cc: stable@vger.kernel.org # v4.14+ Signed-off-by: Kieran Bingham Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/vsp1/vsp1_video.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -849,9 +849,8 @@ static int vsp1_video_setup_pipeline(str return 0; } -static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe) +static void vsp1_video_release_buffers(struct vsp1_video *video) { - struct vsp1_video *video = pipe->output->video; struct vsp1_vb2_buffer *buffer; unsigned long flags; @@ -861,12 +860,18 @@ static void vsp1_video_cleanup_pipeline( vb2_buffer_done(&buffer->buf.vb2_buf, VB2_BUF_STATE_ERROR); INIT_LIST_HEAD(&video->irqqueue); spin_unlock_irqrestore(&video->irqlock, flags); +} + +static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe) +{ + lockdep_assert_held(&pipe->lock); /* Release our partition table allocation */ - mutex_lock(&pipe->lock); kfree(pipe->part_table); pipe->part_table = NULL; - mutex_unlock(&pipe->lock); + + vsp1_dl_list_put(pipe->dl); + pipe->dl = NULL; } static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) @@ -881,8 +886,9 @@ static int vsp1_video_start_streaming(st if (pipe->stream_count == pipe->num_inputs) { ret = vsp1_video_setup_pipeline(pipe); if (ret < 0) { - mutex_unlock(&pipe->lock); + vsp1_video_release_buffers(video); vsp1_video_cleanup_pipeline(pipe); + mutex_unlock(&pipe->lock); return ret; } @@ -932,13 +938,12 @@ static void vsp1_video_stop_streaming(st if (ret == -ETIMEDOUT) dev_err(video->vsp1->dev, "pipeline stop timeout\n"); - vsp1_dl_list_put(pipe->dl); - pipe->dl = NULL; + vsp1_video_cleanup_pipeline(pipe); } mutex_unlock(&pipe->lock); media_pipeline_stop(&video->video.entity); - vsp1_video_cleanup_pipeline(pipe); + vsp1_video_release_buffers(video); vsp1_video_pipeline_put(pipe); }