Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1128737ybi; Fri, 2 Aug 2019 09:45:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyczf5p7EEqiU8K8D3yny7C8jWi2qpIQ0WNQ8PbSJf69K7P0U0q8LIXuKzkVjbHwF10IgVx X-Received: by 2002:a62:7a8a:: with SMTP id v132mr60479313pfc.103.1564764326884; Fri, 02 Aug 2019 09:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564764326; cv=none; d=google.com; s=arc-20160816; b=GTXUTQQ+8cQWnpxz/xcFyG72QbpXroAJV1306TIN12bWfRng3PJDjlP/9HXMeChUyl Pfhrsc5nlRsWBNJKHpL+aN2Z96k7yH5t+sBy83vzDlGDqpjb979Csm2zCJLNJMxGeOjL YXboYMQgxGRuCAam8+XtL1D128FXKqjLBumLhVjE0r2KxLqceGtwL+VJyhRv3HQ61q3q nwOmWMw+u7MQK8+aVwNkMp3qfFoZw99eaKquQ5wUCkezo4g8RBNwDyBSSQzEZxuLl/q1 KrJ1W3oYDrhyJvYkW+puqmAS9HIJDFFodUeWMHxXJwvAiT3rtHKro9xuprEouwc+zgFB dUJw== 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=xz5jDu+Pc0yzJx35TZWodfMsfNFxdBgy85P9G70f9TU=; b=luPdN30eR2XYfeGkcMb9jyjDZWUNL9r9t5I4vJKOSb91eioxBNHZPlHVzD249Ir5IA TqMrmnv8pPsVa70g8pIOwD8dxXxV2huKWsJiR4oUb691OddwGkrj7VBxqPkm8oGSS0o9 125O87Q2ozhFKmg/cQHTP29nUcEcf/zLV9E8ElCIV4K4JZvWzqao0JvT0FHmN89f16Uc eE/W1H6mN+l5uHj+93tZnlhAg5AHAEcFePv4tPCm15125DE3LagNnWnk2M7fCdccKqBK J1kBLzhbTfdClaDsgvjExcj3LnOtZynG3+Fw6cs73+t2mGW4ir6LGLhQunnafdwLxP9R SgxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zJUcV2TQ; 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 b24si855839pgh.41.2019.08.02.09.45.11; Fri, 02 Aug 2019 09:45:26 -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=zJUcV2TQ; 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 S2404988AbfHBJmu (ORCPT + 99 others); Fri, 2 Aug 2019 05:42:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:45310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404978AbfHBJmr (ORCPT ); Fri, 2 Aug 2019 05:42:47 -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 4435120880; Fri, 2 Aug 2019 09:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738966; bh=s7r6NELEe5AW6tUCCOHo36l4AASce67jjMnPj/LE3pk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zJUcV2TQfbAGDmraRZ8mf2noH9KJ4wYojoRKG8fU0EftortqmIFy1+Yzx0CMsR/kA 2s+Xfo9OHxqFd/e2qYUfgiNJ1cda2pgm+09LKjD/c3PXqkDwGBqHrvwGRakgiptWns mHdB0Ykq24nHT/Y3NeDZ7uTI+va7JKqET/pfwow4= 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.9 050/223] media: coda: fix mpeg2 sequence number handling Date: Fri, 2 Aug 2019 11:34:35 +0200 Message-Id: <20190802092242.147357776@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 717ee9a6a80e..1b8024f86b0f 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