From patchwork Tue Jun 7 07:23:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 12871441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF2C7C43334 for ; Tue, 7 Jun 2022 07:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=XfpOMvOzlxS1MljIqj4UDRw5m9PoS9dKV9D3zFcxL5o=; b=mU5g7ZbyRcSnoD hd9n+Lhz0hoEqC1oYULY83tClkszM5oyrq8wDvBx1nlG3Kh4lritXRTqbOKfnUzUL+h1ufVqD/NuN HrsFI7ju17IbbkRSIdGOjVzmWPEpzqMTwjODaJ1s9rqKHm+402Gqr2H8fxKTf9ElxSTfjYRXMh/Yw 8XU1uUHmfeaP5Lb551cgrEzDbL6lLFoMYbiQiv/rm65g8cio8vNWUgF56fYFtS0od/meOvZHPdg/u iR3By5EqS3aCo/SZEsINo61qL8d0DQAzJ3v1GP+bOU+oPlZ+O8Rx+E1b5LLv3gdNLH+Q/6KzJe3aF AkJZCmDBuD8GXX/dzXTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyTZC-005Qmn-8o; Tue, 07 Jun 2022 07:23:54 +0000 Received: from mail-db3eur04on062c.outbound.protection.outlook.com ([2a01:111:f400:fe0c::62c] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyTZ8-005Qe5-68 for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2022 07:23:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IN888fHBm2xxN3w7VFU0GO9gemkYRqga+Ns0yHrSMXzT5ycGYB/V9F8RDYXevQT/RWAWS3xbgdwTzMD9n5mdOkatBZjlOtgYDv3TmEvjbbmiJ9a3X9J+mkESowPZYmCODg6qjgeY/VRU5eS6oFuLuHJmGWAeIL803vlLbnNDIDjkLC1Uf6O5uBT8Pz8u4ud87SsA7/3dFgza+Axow9WFP+IV6BMhJv+WVlhF5nuMjyDKl68u+L2WzeUCmuDiqSOJzAqmRzGiySGDtNmpHo7xd2/eV+a8/+LlQcM3BTNJkw9FI9x7oJczKWWhPIZPrtGjTPs6OV8tkKFRvbYql5INqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p43aOVL41XDfLIKXTvhnmGLZww/3j6qwCGyPvHr+Ydw=; b=WSEDq3AohtqPNTfnXOmwG8C9hFFmYoaJYjEZdBCVdhKeN+uScfzJbWG9yIsu2d/bIjsc2R4sx3YI4lgESUagu4LBqMEQA5NT/Bmf0H8Z7N+M077t80VoXWGiByP+jTCPR9xqW5kJ/Uw2CJbcEqIRWmN+rzhWW3/4KPV6rcfdAQdB/sI+McYp28h4CrUsPJG0irgHvjVOSFR2owMZrPyILy8bw1KCvw5/CuTW3ZvjwPVFJmmKNhrS7SqwqHbCn61/vz7gAIzO5p4QLXtYJb4lWvWQ86d8uc7jnE4K04nxbPQdNoT3NTZX0ESvAF2sWNOMyOi016p6r41MP7vLvxXzbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p43aOVL41XDfLIKXTvhnmGLZww/3j6qwCGyPvHr+Ydw=; b=ddp0gTUl17iK0+0nKioiXS9y+QrL9U4f31+gkG0btwWOs4+5YEi11uNa9p4/uETVvGoqoka/UQ0Pi17b7sCPdql29ZkIS5LoxwPRgNA7EUZAJolsQpHsoTx4LQD1puqEMg0jiWmuq4h0a4+Wi+qUAfCGbH47iRRNVs1tzaWO+IQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM0PR04MB5972.eurprd04.prod.outlook.com (2603:10a6:208:120::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.19; Tue, 7 Jun 2022 07:23:38 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::bc48:7565:c619:62c3]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::bc48:7565:c619:62c3%7]) with mapi id 15.20.5314.019; Tue, 7 Jun 2022 07:23:38 +0000 From: Ming Qian To: mchehab@kernel.org, mirela.rabulea@oss.nxp.com, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: imx-jpeg: Disable slot interrupt when frame done Date: Tue, 7 Jun 2022 15:23:15 +0800 Message-Id: <20220607072315.23209-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.36.1 X-ClientProxiedBy: SI2PR01CA0038.apcprd01.prod.exchangelabs.com (2603:1096:4:193::20) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b79c45b1-6790-452e-1a7c-08da4856a411 X-MS-TrafficTypeDiagnostic: AM0PR04MB5972:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K4jj5/KBlj7qy1bgQbB9qguKlh03tlQXqWL+3pXO/9IYppEa5jFuN118f6FH/a/TVWdWVt1wXq3BFlb+c8uponn7UOI8gVBekCjK0f3Q0N9tYkgF9S6K4DHuk/+bQXnH1O7NnSX0+KoW5EewWNLdOd5uSH6cpRKPtSwZ6po/W9cChBIFsC4aspCNHB19PTJneBEUdjMm6r9X+oNyUk9dOzeRgrvlJoATYYbEpWKqqNACC1QVkwQ/KAv/jfPV0X2AsHPUELGTWYSbkQn8xvHUImybGBvusFf1WbPOxRozd2RzcAY1wFLewv6bfac04UKNScGP67aafWQ4Rw1Wxu5MBmqxFvOC9h2bkEMYt+UE+pgzDIlmDT6wtaHfJLPXrwXDq82eEFSMbXZ2FSZf6qDN/m7uEXJXxemsCYq06+axGLSh7poEVflK5XJDwnV1MB8SchgMSg+dujZspv2d41UinDb6gt5dg95gmlxlrCPipnqGBuXT29jdHdWZejtB0nJPw+9JO17u7GQAjtmWiPS9RWUZPhxX2d/yAn1uY/RtkvuV49fzMu8wkB2+aRAiV4HoWOArkHHxzQCqfeBjnsktaiDBm8fTneKjktImMoEvuS4Z3IEnrGD+wcsa0mNO39k62BAvM92OJHCcRmSa8AsT9QkZCjaMjZndh59PQsZs0YL/4nDkfRAqitZ7NxX1N6XN4HBnRsnNONv7aBxNQkKoXQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB6341.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(7416002)(4326008)(316002)(8676002)(6506007)(44832011)(86362001)(2906002)(5660300002)(66556008)(66946007)(8936002)(66476007)(6512007)(26005)(186003)(1076003)(6486002)(508600001)(52116002)(2616005)(38100700002)(38350700002)(83380400001)(36756003)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Eg4XyMfiv6p6adIC+xVgbASeq6C4dH79sPZjM72JNOaxmjVQS6v70jF+iRFMrI98cWDGYZKX57vFNo5D9a0xxXasJ74WpLVR/K6fKAAAOm7o0ew/QpFBknwPVA6v0ETZH/bKuciGMKWaRhaD0dpJFz+mkY+meirATXPkGK8lBfKg78oJxy31pw8//A/xgze2Ti8jlmSQFFB2RTOGuj4rMLdbFlWzSBUtXKLQr3hs/pEcPt7qUiFqIsn7SgAvpU9Bby80XpkIxjh91+YQNwYhgdP7C0WELlUYLeV54KmrQOBSMNic6BoS1F5nF+7fEz3QrkBLgPDaHX+ckU8kQJYjlxoNgYu3tXqIbl6cAms13Bgxp3cfEOMc9lEBqr+OwT77Opk0ZkUpGWQpx3zyEMRzumLF704TqM6l33GXUUAODc5ptllkSE4St0CR01Hl0gOjND67wSvrDbrW3YgALPvb4hIodNdb64WpZNT9cjag7nLf1cU9pVXiF5rhsSx1HmQ0rrKRJ+jq5Ason5E4FoshweYPuKlizCEEDhx/782sf3bY9c8eyVPmVrfOl/6lFebOOLlbb2VgO9NSrgnfmD5Px/IdGQCmcx4pB2Z21RQpiUg8U5+iHtZioUpT6mpQqBSx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w2KaUBfzMQScycmuh4ZgN7aLQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b79c45b1-6790-452e-1a7c-08da4856a411 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2022 07:23:38.4880 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qazaaOIYP5z8ka2C9ne1u59L3ZMiSnh0ipBoCvde5+g8uwOiCDOvretb7bhk481cQccJ5K3f1ME2mdSf/cq+tA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5972 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220607_002350_240909_2188350C X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 | 11 ++--------- 3 files changed, 8 insertions(+), 9 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 c482228262a3..9418fcf740a8 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 07655502f4bd..ecf3b6562ba2 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h @@ -126,6 +126,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 965021d3c7ef..b1f48835398e 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -592,15 +592,7 @@ 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)); - goto job_unlock; - } + WARN_ON(!ctx); if (slot != ctx->slot) { /* TODO investigate when adding multi-instance support */ @@ -673,6 +665,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);