lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 17 May 2022 18:25:44 +0530
From:   Smitha T Murthy <smitha.t@...sung.com>
To:     linux-arm-kernel@...ts.infradead.org, linux-media@...r.kernel.org,
        linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Cc:     m.szyprowski@...sung.com, andrzej.hajda@...el.com,
        mchehab@...nel.org, hverkuil-cisco@...all.nl,
        ezequiel@...guardiasur.com.ar, jernej.skrabec@...il.com,
        benjamin.gaignard@...labora.com, stanimir.varbanov@...aro.org,
        dillon.minfei@...il.com, david.plowman@...pberrypi.com,
        mark.rutland@....com, robh+dt@...nel.org, krzk+dt@...nel.org,
        andi@...zian.org, alim.akhtar@...sung.com,
        aswani.reddy@...sung.com, pankaj.dubey@...sung.com,
        Smitha T Murthy <smitha.t@...sung.com>, linux-fsd@...la.com
Subject: [PATCH 16/20] media: s5p-mfc: Fix to handle reference queue during
 finishing

On receiving last buffer driver puts MFC to
MFCINST_FINISHING state which in turn skips
transferring of frame from SRC to REF queue.
This causes driver to stop MFC encoding and
last frame is lost.

This patch guarantees safe handling of frames
during MFCINST_FINISHING and correct clearing
of workbit to avoid early stopping of encoding.

Cc: linux-fsd@...la.com
Signed-off-by: Smitha T Murthy <smitha.t@...sung.com>
---
 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
index 95e18f1cabb0..91b7ff07feff 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -1411,6 +1411,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
 	unsigned long mb_y_addr, mb_c_addr, mb_c_1_addr;
 	int slice_type;
 	unsigned int strm_size;
+	bool src_ready;
 
 	slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev);
 	strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev);
@@ -1464,7 +1465,8 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
 			}
 		}
 	}
-	if ((ctx->src_queue_cnt > 0) && (ctx->state == MFCINST_RUNNING)) {
+	if ((ctx->src_queue_cnt > 0) && (ctx->state == MFCINST_RUNNING ||
+				ctx->state == MFCINST_FINISHING)) {
 		mb_entry = list_entry(ctx->src_queue.next, struct s5p_mfc_buf,
 									list);
 		if (mb_entry->flags & MFC_BUF_FLAG_USED) {
@@ -1495,7 +1497,13 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
 		vb2_set_plane_payload(&mb_entry->b->vb2_buf, 0, strm_size);
 		vb2_buffer_done(&mb_entry->b->vb2_buf, VB2_BUF_STATE_DONE);
 	}
-	if ((ctx->src_queue_cnt == 0) || (ctx->dst_queue_cnt == 0))
+
+	src_ready = true;
+	if ((ctx->state == MFCINST_RUNNING) && (ctx->src_queue_cnt == 0))
+		src_ready = false;
+	if ((ctx->state == MFCINST_FINISHING) && (ctx->ref_queue_cnt == 0))
+		src_ready = false;
+	if ((!src_ready) || (ctx->dst_queue_cnt == 0))
 		clear_work_bit(ctx);
 
 	return 0;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ