Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3783451ybi; Mon, 29 Jul 2019 12:32:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw21s0G7YOdZbr8ri//zeZtnTDoGuwI7Z5fwJKCOTEVosQ53xqboiryvPAnoWTjJ0OOA3l6 X-Received: by 2002:a63:6901:: with SMTP id e1mr74914187pgc.390.1564428762895; Mon, 29 Jul 2019 12:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428762; cv=none; d=google.com; s=arc-20160816; b=ci9M6EBol1wajRJ9fvLysWzD9v1d1uJfuwQnTz83qbvkKCDisgqbpPwuWhczm9KyRV DCqX/NBX/vMYe0+y4yzLDYTX156hZcIxsN9eryJpGDs/n/Vyg15P7RkZjSimrVEWUOeW MtTUiEE0iNFUdJnDVbBXSdzBoNU1syPDPay0PpDr7KX6J+/IugdnWFn3v1YyehShepDb pMyb6G9yFctk0F01dCgc4K9oJYUhAWm/OWfUJW5XwC2vNBIoXfu6ijXkaGrwxwBCt10H 66fM005G1AIccsaSWe4ckoIlFGmHDPmltRuFSrWPZVqQtgEjQhxoJoKfTbZyS1PtWOjR Ks3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c4SqolN1A8JMS2Lc7jS9WFljfnr028L4osNL4+kPR7I=; b=XkfkILndhSdGnHXmOJ4xZNupviSnXaQEf9tGR8M2SpZFfrzXE25csN9gTbTgX2+4PE fJvYLJYvHiDIuxwbDxbGCc1LOxwwpCFOOgqKyPUWa6i0PS2USg5cIp3zS2fjVZwdMCM2 xOYFctfjPX1zS/dd820APdGx0eQ0P0U9nrsBLfJOpyjZ/hJPvK2OWasdF/1vlJPOuKTW vk20/1Zq3Y+NiL34UacDfC17Jtb6FgmKieVp1zNfbo8mPQLy/R7kd+RDTFwSmtHsZXpL Tuixz12LKRA5+4LnVSRHkoKtR67e3X3tYZ5yQPlj6omUO1DzJm/MQA0dOBxJUwIrYA/5 cRVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="sB/nFHA3"; 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 h38si9285195pgi.327.2019.07.29.12.32.27; Mon, 29 Jul 2019 12:32:42 -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; dkim=pass header.i=@kernel.org header.s=default header.b="sB/nFHA3"; 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 S1729828AbfG2T0v (ORCPT + 99 others); Mon, 29 Jul 2019 15:26:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:39268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727100AbfG2T0t (ORCPT ); Mon, 29 Jul 2019 15:26:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 356CD2070B; Mon, 29 Jul 2019 19:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428408; bh=/Awqggy1rrV2zfN1OOcYs6XMNfo1uQguhLsPUXJXf84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sB/nFHA3TKviFBVhotigrUNqgSt99ZODyDRgz291beA7doZ/BCon27Z+1Frxl+wUb 1+rmk+NLZkap4nc/C9XVQaQ1DzJ4GHBfzsxYHT39x3B7827bgN3LnEHXXBQAkygATw TOloy13d4n1hpN3/Wp6pgs5TxPdnmO1pXZ1xG5GQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Zabel , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 067/293] media: coda: fix mpeg2 sequence number handling Date: Mon, 29 Jul 2019 21:19:18 +0200 Message-Id: <20190729190829.791135972@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 56d159a4ec6d8da7313aac6fcbb95d8fffe689ba ] Sequence number handling assumed that the BIT processor frame number starts counting at 1, but this is not true for the MPEG-2 decoder, which starts at 0. Fix the sequence counter offset detection to handle this. Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/coda/coda-bit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c index 6eee55430d46..43eb5d51cf23 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c @@ -1679,6 +1679,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx) v4l2_err(&dev->v4l2_dev, "CODA_COMMAND_SEQ_INIT timeout\n"); return ret; } + ctx->sequence_offset = ~0U; ctx->initialized = 1; /* Update kfifo out pointer from coda bitstream read pointer */ @@ -2095,7 +2096,9 @@ static void coda_finish_decode(struct coda_ctx *ctx) v4l2_err(&dev->v4l2_dev, "decoded frame index out of range: %d\n", decoded_idx); } else { - val = coda_read(dev, CODA_RET_DEC_PIC_FRAME_NUM) - 1; + val = coda_read(dev, CODA_RET_DEC_PIC_FRAME_NUM); + if (ctx->sequence_offset == -1) + ctx->sequence_offset = val; val -= ctx->sequence_offset; spin_lock_irqsave(&ctx->buffer_meta_lock, flags); if (!list_empty(&ctx->buffer_meta_list)) { -- 2.20.1