Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1560231pxb; Thu, 16 Sep 2021 09:55:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrRDTOE1cHlB3FdCg9h+k8GBotZz1FVzFHlb7yzK0A9kb4DOwTJoYCLpWDq5Yu5eCBQY4p X-Received: by 2002:a17:906:144b:: with SMTP id q11mr7496867ejc.78.1631811315658; Thu, 16 Sep 2021 09:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631811315; cv=none; d=google.com; s=arc-20160816; b=hFc8LSoBZLJr0piUso4x8Z5Dkhi636Oo4io32Gw4HedaiQC8v4fxuCUuGDTtqr7tc6 SunWgqVcKsRm5mej1ZZ9klR5w0+rONF64fWCctX+V6tJEPZsCKwVjhgjgbSDfHChiM0D uHpwIxj9I4CX4h0YJZ/vATOwRqT7b7u2FRXn9KUYB8KsjlahGFLDT3xHsxh15eEKOB9t 7qz7Com+y6YueM+nVXw4+9cpfc3wtXBQ0hU2yp09PKFfAVblspAVbYe7TGWU9LhyMTjp cY4poxC15SYxNj75Fd/ITbYZZ4LXmmb40FGHii02bwdVOmjgV2mFcveE1c2lVQO0+Xyf Oc1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YSt+6VBZ5Noi4x8BU3pZK6VpeAA3ztLEAr/1JZ/TBRE=; b=ZsMAsGqg5Q50Q1f6rrQRd51x2SESCPHCSNQJjKgu4YWXn0y/hgIEXaSoNa0t8rUfSw vCfiW777EBMkMg2zatFkjwq5xEGCxp52JEkXMbZpS3c9aTtqoL2HixPKSng7Lqf13fk0 D0/AbWdkUN+1wIQduz8xLrNM5Iw7Ncx4/+GwMjC7uG8vfuqwZsCeaH/wxBenFlsauOZF u0tlDnoImt8C1eliIgJpyrxox7Mmx8eUrINaDDO2ykcflLlB+S9W7ArxdL3B+K9WtStl vm3AgUEXPfNMat1s8xB8Qr1Zo3s8rn8lsnUaogIwVBmp/NAMQlt+8PtqQy3KXqhsFMSW vw3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qwnt+l+g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mm25si3906859ejb.307.2021.09.16.09.54.44; Thu, 16 Sep 2021 09:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qwnt+l+g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345932AbhIPQxB (ORCPT + 99 others); Thu, 16 Sep 2021 12:53:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:59260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244127AbhIPQsG (ORCPT ); Thu, 16 Sep 2021 12:48:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 859A961526; Thu, 16 Sep 2021 16:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809635; bh=YC8/XbiDbaj/RxCg++JrowC1boSNXqHMcH+BfvlVeiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qwnt+l+g4r7PcFtyBicUyFCNd/oHpPmvMV7Z1Bqga3hq+ax6gpACVzEz3MD5ABveo 5BTqJHtVR3++71U9+XcWtfa3mV+a91KIMY7nNlpCWRFEXu4oWWY43Qaxmm/Xa3ylCy beRdLk1aMgBt3ri8xvhkdnxyCautKpBHFdArCiaI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Pinchart , Martin Kepplinger , Rui Miguel Silva , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.13 227/380] media: imx: imx7-media-csi: Fix buffer return upon stream start failure Date: Thu, 16 Sep 2021 17:59:44 +0200 Message-Id: <20210916155811.810102976@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Pinchart [ Upstream commit 0ada1697ed4256b38225319c9896661142a3572d ] When the stream fails to start, the first two buffers in the queue have been moved to the active_vb2_buf array and are returned to vb2 by imx7_csi_dma_unsetup_vb2_buf(). The function is called with the buffer state set to VB2_BUF_STATE_ERROR unconditionally, which is correct when stopping the stream, but not when the start operation fails. In that case, the state should be set to VB2_BUF_STATE_QUEUED. Fix it. Signed-off-by: Laurent Pinchart Tested-by: Martin Kepplinger Reviewed-by: Rui Miguel Silva Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/staging/media/imx/imx7-media-csi.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index f85a2f5f1413..ad1bca3fe047 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -361,6 +361,7 @@ static void imx7_csi_dma_unsetup_vb2_buf(struct imx7_csi *csi, vb->timestamp = ktime_get_ns(); vb2_buffer_done(vb, return_status); + csi->active_vb2_buf[i] = NULL; } } } @@ -386,9 +387,10 @@ static int imx7_csi_dma_setup(struct imx7_csi *csi) return 0; } -static void imx7_csi_dma_cleanup(struct imx7_csi *csi) +static void imx7_csi_dma_cleanup(struct imx7_csi *csi, + enum vb2_buffer_state return_status) { - imx7_csi_dma_unsetup_vb2_buf(csi, VB2_BUF_STATE_ERROR); + imx7_csi_dma_unsetup_vb2_buf(csi, return_status); imx_media_free_dma_buf(csi->dev, &csi->underrun_buf); } @@ -537,9 +539,10 @@ static int imx7_csi_init(struct imx7_csi *csi) return 0; } -static void imx7_csi_deinit(struct imx7_csi *csi) +static void imx7_csi_deinit(struct imx7_csi *csi, + enum vb2_buffer_state return_status) { - imx7_csi_dma_cleanup(csi); + imx7_csi_dma_cleanup(csi, return_status); imx7_csi_init_default(csi); imx7_csi_dmareq_rff_disable(csi); clk_disable_unprepare(csi->mclk); @@ -702,7 +705,7 @@ static int imx7_csi_s_stream(struct v4l2_subdev *sd, int enable) ret = v4l2_subdev_call(csi->src_sd, video, s_stream, 1); if (ret < 0) { - imx7_csi_deinit(csi); + imx7_csi_deinit(csi, VB2_BUF_STATE_QUEUED); goto out_unlock; } @@ -712,7 +715,7 @@ static int imx7_csi_s_stream(struct v4l2_subdev *sd, int enable) v4l2_subdev_call(csi->src_sd, video, s_stream, 0); - imx7_csi_deinit(csi); + imx7_csi_deinit(csi, VB2_BUF_STATE_ERROR); } csi->is_streaming = !!enable; -- 2.30.2