Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3021833rwb; Mon, 15 Aug 2022 16:19:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hzRrCbaRK2hgJfhHf0284wTD0L7wpDakCitz1gCb5EAmMN/WX6/v5pK90tZiu2zPKt+W1 X-Received: by 2002:a17:907:3f87:b0:731:7702:50b9 with SMTP id hr7-20020a1709073f8700b00731770250b9mr11733172ejc.735.1660605474546; Mon, 15 Aug 2022 16:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605474; cv=none; d=google.com; s=arc-20160816; b=KZF7nPCXlcB+NNaa4LkZX7Fv7LnQGqOZSCEIYEdCu1VnBEmfjkRdJuV94GCkOBywql k52RGiTd1QV1augBq647df7b6+9BW2lvLNSFyZlLMkdqOHhEDLfFhrTAas1EDXfF5KjA ZRIB9njkzMTQ5BMvDKaIToJwVRsSyajAvACwoV0G4iOowJOmsm6+A1D0H5nsxATH2gxg mIwtNmyNNlrFLmIRfNrE6R9lVZ8kF+wMOemvsVq0CNYXf09rGDVOOQ6CJDBD2TobXPrb 171z/FTfpi64g5C1oRzdtqgs6POQ3cZHLaLIpdZc5aQ5QVtvtmqyc32OI9c9jvZNe9W6 y+GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Iu8SjmIdPhL7x+bQr0ch9Iy6ZcHDoH8L8rDCcWDit00=; b=tGtCSiFMpv2x4iA6QpfAO05qsdHPfZ1BQDfXut18kmjUY1ddZrxCJFwqml6kCpW+Ta 24HWr4t/MnsPj3UyUsVgNDOob+iDPulP6FUWXuKFWRoHFjn+dDG8uq5OydivgP75zWDm 5KW2nVYHN/uLnO+VFCkCcJnbhb1cDv+mv3fSKvCmyCU3uDKYhbEsI+q3BVMXBq+WestI FfInJXr5M+0R0Ya57cPNvXhj6ln9DDnG8ydhcqLXyPZ/7yJOIOYL3xLr8mMEktGOjZbl RTZo1KW+u457tOx5lM2CpEfxtSTd1XuTQ3twGXObDa7oeAAmNWzkqQWOWAbwqKMwJ06z njbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rT6rUikw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm22-20020a170907949600b0073151a536f7si8365272ejc.313.2022.08.15.16.17.28; Mon, 15 Aug 2022 16:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rT6rUikw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244061AbiHOVDJ (ORCPT + 99 others); Mon, 15 Aug 2022 17:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346807AbiHOVBI (ORCPT ); Mon, 15 Aug 2022 17:01:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2D92C6EA1; Mon, 15 Aug 2022 12:13:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3B52FB81106; Mon, 15 Aug 2022 19:13:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80CD7C433C1; Mon, 15 Aug 2022 19:13:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590790; bh=SYmROEW95gLMnhGnaxwDmkZqi0WBlA/SO1b/5eSAcH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rT6rUikw2OkqkI4pznK0k7Fb10KpQ23Ns1OBDFgX2/vuSSZj/f9VrEjFtwZaWpruN +bje2/DhEdXNvGcTgj0cHp/xXxgl9xv6lm6PAcW9kR6IYqWDb6HLUFhI/fMHtn7PqM YL4qWEo39Rt2+VzpXKbMb7byPhz0BaHW7IL7t2eo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Qian , Mirela Rabulea , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.18 0372/1095] media: imx-jpeg: Disable slot interrupt when frame done Date: Mon, 15 Aug 2022 19:56:11 +0200 Message-Id: <20220815180445.106739773@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Qian [ Upstream commit 22a2bc88c139dc9757bdb1d0a3665ac27edc79a5 ] The interrupt STMBUF_HALF may be triggered after frame done. It may led to system hang if driver try to access the register after power off. Disable the slot interrupt when frame done. Fixes: 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder") Signed-off-by: Ming Qian Reviewed-by: Mirela Rabulea Tested-by: Mirela Rabulea Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 5 +++++ drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h | 1 + drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 10 ++-------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c index 29c604b1b179..718b7b08f93e 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c @@ -79,6 +79,11 @@ void mxc_jpeg_enable_irq(void __iomem *reg, int slot) writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN)); } +void mxc_jpeg_disable_irq(void __iomem *reg, int slot) +{ + writel(0x0, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN)); +} + void mxc_jpeg_sw_reset(void __iomem *reg) { /* diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h index 12f132a83a23..bf4e1973a066 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h @@ -125,6 +125,7 @@ u32 mxc_jpeg_get_offset(void __iomem *reg, int slot); void mxc_jpeg_enable_slot(void __iomem *reg, int slot); void mxc_jpeg_set_l_endian(void __iomem *reg, int le); void mxc_jpeg_enable_irq(void __iomem *reg, int slot); +void mxc_jpeg_disable_irq(void __iomem *reg, int slot); int mxc_jpeg_set_input(void __iomem *reg, u32 in_buf, u32 bufsize); int mxc_jpeg_set_output(void __iomem *reg, u16 out_pitch, u32 out_buf, u16 w, u16 h); diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index 8c0bd8b75b00..c287eb789fe6 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -593,15 +593,8 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv) dev_dbg(dev, "Irq %d on slot %d.\n", irq, slot); ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev); - if (!ctx) { - dev_err(dev, - "Instance released before the end of transaction.\n"); - /* soft reset only resets internal state, not registers */ - mxc_jpeg_sw_reset(reg); - /* clear all interrupts */ - writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_STATUS)); + if (WARN_ON(!ctx)) goto job_unlock; - } if (slot != ctx->slot) { /* TODO investigate when adding multi-instance support */ @@ -673,6 +666,7 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv) buf_state = VB2_BUF_STATE_DONE; buffers_done: + mxc_jpeg_disable_irq(reg, ctx->slot); jpeg->slot_data[slot].used = false; /* unused, but don't free */ mxc_jpeg_check_and_set_last_buffer(ctx, src_buf, dst_buf); v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); -- 2.35.1