Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3088618rwb; Mon, 15 Aug 2022 17:51:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR55wPMHV4OinaVySyIMCodGBE/dcuvMzTBKdGQc7TkccSE5dlcZI+h8VvrOIuhg5bo1yVJG X-Received: by 2002:aa7:dbd7:0:b0:43e:8c3b:f444 with SMTP id v23-20020aa7dbd7000000b0043e8c3bf444mr16272692edt.83.1660611063531; Mon, 15 Aug 2022 17:51:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611063; cv=none; d=google.com; s=arc-20160816; b=FCC7wpxn6nMCZhcoqt5pPO6n0+EFaOsW1GK6R10TCtJ00VKr+8phVXTGwR2NlpMEnA ZBQvzNav2KuXq4nLu3b+4NUq8mTMO9YTVlRSMDHw6TmDEyW+6XgGx8SMuPbqHRuwK91X kHyc3ImIyHRsd2lDYIw69zngdjMC+YEyy/DozL056bQJsBVxBTTURuexyQmB/JQPtB+9 b1SpfYTJSPr37L/mjkMhExEPXS44ZK3Jfcl+ZepOYhs8jdrynTcxYfqPvgGo8TTIKVyi IaJgh2OyyNV/Cc/7G6EEqjjGOX4E2/uznwKR/QADfMvl8/O17wMZhh2B6Q7kKue1LUUq 38wQ== 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=/GVPDZPU4f0/xcRTYsJxeLnC3/sjDgqnujWpbDQWBIo=; b=Ez1EVDtGqa1TGSK1XZI3Ja4pMk7k3q7cirHCb3EaciB8e85oV1nmLEWn/9GaL01TDG yE3hm2ul/Bbn3XTMTfYFesopyklPPg4JycaZ3tUmcSfEYgHpCxFX2m00SwWxjkEw6q2E U9n0D7qql4ej4AvpbD26gjpZsLDni1SEnJRy7EYOwpTExHXUizzKMFAXigsUlVPonSn9 zjb3MV4Epqv/HDTjmJlSoa9Vxr6HnEYk98nef92U/rd5l1VR6xjst7R+u/dAXKYwNWIz g5ag5405dH6d3GTnGDspbxyJvDjLtmY4NRcFgzXVMSfWBySGGmpisT64JKlc36ItJnNM c2VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pbea4ZM6; 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 x17-20020a05640226d100b0043d373fd120si9704136edd.47.2022.08.15.17.50.37; Mon, 15 Aug 2022 17:51:03 -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=pbea4ZM6; 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 S240161AbiHOXmn (ORCPT + 99 others); Mon, 15 Aug 2022 19:42:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353659AbiHOXjy (ORCPT ); Mon, 15 Aug 2022 19:39:54 -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 1DDC6153D3C; Mon, 15 Aug 2022 13:10:13 -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 9B620B80EA9; Mon, 15 Aug 2022 20:10:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2209C433D6; Mon, 15 Aug 2022 20:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594210; bh=WTlqPFfrZvu1SVl3BDbBSZq5wF8+vw4pET+mwT6EseM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pbea4ZM61uI7y2Yj0+cHRUu31Uv/GY2J1TC7cELyst94U8WwaPW7NuSy3Oz+BG9eP Yd/TzPj/0mJ/vhUB4HogzqTUmDR2tOB285vUqcPFiIjK/Kj100lf/omxaBalIZnMpl 8kQFn7XAC6QbOXqx7if7sS1aaMeOOc3Z2bcuDvc4= 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.19 0395/1157] media: imx-jpeg: Disable slot interrupt when frame done Date: Mon, 15 Aug 2022 19:55:51 +0200 Message-Id: <20220815180455.483633379@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 5f64cbbe0fa9..645a24fe8bc1 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 9a2fb0dc77a4..35a7cb936653 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