From patchwork Tue Mar 14 14:21:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minghsiu Tsai X-Patchwork-Id: 9623603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB181604CC for ; Tue, 14 Mar 2017 14:35:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB4D4285A3 for ; Tue, 14 Mar 2017 14:35:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE609285B7; Tue, 14 Mar 2017 14:35:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 42D26285A3 for ; Tue, 14 Mar 2017 14:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=RZl72fgEIEpF2jDEA6xJaCyRx54+4M7ESEdSpjF2tm0=; b=sVXrvxe0s1Yw4/ qJhtM+FQXsCova+FVQh5WWh6Tgqz/lFGJHvHMgJBxz5odLCtgIyCcMt2Ycv9m299wjadzzczi5CCf Hs5q+Qu6NkxbjziIwwXDc3Ba3Bnf+CRajwXaju0y8KGisYZWuIzcI2ZSYNjmNBl+QNO329gUUgBrI FaAf/F8NOQKjSXFLRnK+ywkLGJ2dTsnp+81w+gp1bbKXgVT1kzPE4Hhorq4Wc8B/2XlfyaHi5RP+H 3EsqnyUoI65RRDUBSksZKhO3TZz+7A5b/HbTK9VddX0OCZryHD6AM1U1guzwlvGpICREe32OK2fB8 p6BjUv7qWxT3Bl59CcQQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cnnY7-0002HF-Kb; Tue, 14 Mar 2017 14:35:43 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cnnXk-0000lj-BK; Tue, 14 Mar 2017 14:35:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6XxB/oa+/FpjT5WSFfuFDkdfvEwiPBjaYNEKzZtZ9qY=; b=rhMN1rIaBorFIRlBioeBqnuO/3 i3M50z4diRXRaeTr1ka5NmiTRDR9i5p0L7N8PlD5F7IDJ7FEKT4O/cKf23lMonbS9UT8qCkIFMqCC rE1YGlnV5cY8NPHsFc49YgBmzVDBBWrysZlSGTyBAUIFNRfrcdi+UK5Qm7PU7S7TryisfQLGvHN5l q0473sS5gl8FZ7i8u1owxCpulyFQy1gaP3C/0D2xMo3CgWaDoQEKgpw3y7/7U4X+uiV1eMIPm8UXM 8OiJEt5tDleph0Ev/fKU2wGGHdufh6vSRjypR7p5G55QqRJz5Mgm2tVp3yvOgBEQZYbCOP93NGWDf qIrOTWMg==; Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cnnKp-0001GH-Ge; Tue, 14 Mar 2017 14:22:01 +0000 Received: from mtkhts07.mediatek.inc [(172.21.101.69)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 175498700; Tue, 14 Mar 2017 22:21:28 +0800 Received: from mtkslt302.mediatek.inc (10.21.14.115) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Tue, 14 Mar 2017 22:21:26 +0800 From: Minghsiu Tsai To: Hans Verkuil , , Rob Herring , Mauro Carvalho Chehab , Matthias Brugger , Daniel Kurtz , Pawel Osciak Subject: [PATCH] media: mtk-jpeg: fix continuous log "Context is NULL" Date: Tue, 14 Mar 2017 22:21:22 +0800 Message-ID: <1489501282-52137-1-git-send-email-minghsiu.tsai@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170314_142159_865025_C1A0A09B X-CRM114-Status: GOOD ( 19.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Liu , devicetree@vger.kernel.org, Minghsiu Tsai , Rick Chang , srv_heupstream@mediatek.com, Wu-Cheng Li , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Yingjoe Chen , Eddie Huang , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The symptom is continuous log "mtk-jpeg 18004000.jpegdec: Context is NULL" in kernel log. It is becauese the error handling in irq doesn't clear interrupt. The calling flow like as below when issue happen mtk_jpeg_device_run() mtk_jpeg_job_abort() v4l2_m2m_job_finish() -> m2m_dev->curr_ctx = NULL; mtk_jpeg_dec_irq() v4l2_m2m_get_curr_priv() -> m2m_dev->curr_ctx == NULL -> return NULL log "Context is NULL" There is race condition between job_abort() and irq. In order to simplify code, don't want to add extra flag to maintain state, empty job_abort() and clear interrupt before v4l2_m2m_get_curr_priv() in irq. Signed-off-by: Minghsiu Tsai Reviewed-by: Wu-Cheng Li Tested-by: Wu-Cheng Li Acked-by: Rick Chang --- drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c index b10183f..c02bc7f 100644 --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c @@ -862,15 +862,6 @@ static int mtk_jpeg_job_ready(void *priv) static void mtk_jpeg_job_abort(void *priv) { - struct mtk_jpeg_ctx *ctx = priv; - struct mtk_jpeg_dev *jpeg = ctx->jpeg; - struct vb2_buffer *src_buf, *dst_buf; - - src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); - dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), VB2_BUF_STATE_ERROR); - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), VB2_BUF_STATE_ERROR); - v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); } static struct v4l2_m2m_ops mtk_jpeg_m2m_ops = { @@ -941,6 +932,8 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) u32 dec_ret; int i; + dec_ret = mtk_jpeg_dec_get_int_status(jpeg->dec_reg_base); + dec_irq_ret = mtk_jpeg_dec_enum_result(dec_ret); ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev); if (!ctx) { v4l2_err(&jpeg->v4l2_dev, "Context is NULL\n"); @@ -951,9 +944,6 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf); - dec_ret = mtk_jpeg_dec_get_int_status(jpeg->dec_reg_base); - dec_irq_ret = mtk_jpeg_dec_enum_result(dec_ret); - if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW) mtk_jpeg_dec_reset(jpeg->dec_reg_base);