Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1006434ybi; Fri, 2 Aug 2019 07:51:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgggxvEFNcBR7hDY1nNY1M+MyFM0U1WyCvJHNG8EgGFmtlSFp1XbEYFNNbGFVQQQ6DQI/B X-Received: by 2002:a63:2cd5:: with SMTP id s204mr106391480pgs.95.1564757512084; Fri, 02 Aug 2019 07:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564757512; cv=none; d=google.com; s=arc-20160816; b=w7sa4DcxrOQ/C0dqUGm+Yo26EWg3p/xv8GraDg6aMXkAAhSGOp/owPXks5bbW9kmk7 v1vVQqfmRZrY8iRYRBtgA6ibyuMcVVTxPTGRVVlpf67k9UeJzgyXcrIhuWlB1fmv1noT xtTfNhsFTQ8aK22TP8X2ldYhuzdLV/6iAiXIrtrPoFIpIrzzkjHFieafgD/RbXXRNS5w jVa1J1KBw2RqYCNyBBSM61/f7S4h4gaPx3zlCQuFBFfe5QCj0kUX8axGAYIvCPNBhBdm ATqT400i9a0uuQCwcvvN81xpK3+jwrK98VchdbFdgRvfCrPv245WUHCOkXz9IpioXXU4 qigA== 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=0UPtG70KRQIYkxFBtk7jhJ9ApgmLgrPCUZbsbT0fEIE=; b=zcJH9G/ULGVPN2wzQ8dEyhewUMN55Y2Mi/R1X9J0FZIKY+fKHJHx3i05+VLZETJf6M l7OmG5TYT5LJYVxO5Tf/mWOkCTqHUJMBGDGApnYqwUfzk3ZV0HcQ3pQqB/lh1I/AME01 gfcqE+yeX3rWg4BORgKxFPZ/UYOVKrT0I5bsVlu+ONmPq5jKFMUE1TxacLAYg/ZF9/bV lZVALPjQYLty50pHS5mXIAFXqpv6xDjzSVhtugZhQeoJhL+EMKCf7Z4p9soBbaJuYnsk e/crp5sI+os3VD/vLqzxOK4ZvWAq9LpigvDbK/aHF84tIbyjdQo4ydG1oCzEJhp84JZl 1MTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WwBMTOHW; 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 v14si38470537pgl.386.2019.08.02.07.51.37; Fri, 02 Aug 2019 07:51:52 -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=WwBMTOHW; 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 S2391036AbfHBJbS (ORCPT + 99 others); Fri, 2 Aug 2019 05:31:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:57230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404671AbfHBJbP (ORCPT ); Fri, 2 Aug 2019 05:31:15 -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 344EC217F5; Fri, 2 Aug 2019 09:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738274; bh=YqByTQJY/F4PMvJGRFZbFmkbM46/euWui8UiP/V6lCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WwBMTOHW+8aKlPWo1pyGP84jfz1usgh2J/eDc8L7Zl66eI+zoFbnwyhtGBHe7UbdR 80GSp+XSlBltxw6u4PttCqH/1ddzSqpeK8fUGzTwafb+Zkz9MdFG29HmENigjkBeIP TRCCeKiHC927NWTppKjGr0dBQNKn+xyePruGiqYM= 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.4 040/158] media: coda: fix mpeg2 sequence number handling Date: Fri, 2 Aug 2019 11:27:41 +0200 Message-Id: <20190802092212.157343108@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@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 a4639813cf35..a7ed2dba7a0e 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c @@ -1581,6 +1581,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx) coda_write(dev, 0, CODA_REG_BIT_BIT_STREAM_PARAM); return -ETIMEDOUT; } + ctx->sequence_offset = ~0U; ctx->initialized = 1; /* Update kfifo out pointer from coda bitstream read pointer */ @@ -1971,7 +1972,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