From patchwork Fri Jun 10 02:00:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 12876281 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 632F4CCA473 for ; Fri, 10 Jun 2022 02:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242271AbiFJCBS (ORCPT ); Thu, 9 Jun 2022 22:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241068AbiFJCBQ (ORCPT ); Thu, 9 Jun 2022 22:01:16 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70040.outbound.protection.outlook.com [40.107.7.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CA02222A55; Thu, 9 Jun 2022 19:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HeR+1bXBELFGbNkeIZtpaPyfCyZduSiekR2oFA8kigxMKxlZevaErnNj0pKfuFB2D90mm2xI01qvt4sBr4hxmNK87at5ywObhGtL9JGkNiNlNctMOv//l/GaNusliM6ToB7N8HS/rcB6/lroJPx0j8Fb2eCoaPRbn8yojMCblixXm5qEpLR2AbG1iviufsPBjoH/+s3GLrmu8fsJLELg4UMqxBKCPO5HVW/cVS1XmNwdoaSbPfsC1N6JGYb41FIGpleZqhTzeLhWF7234E7lguyIywt/oBFmmZ8SdzzTfKDZD46zRHqRv/63/cF8QHvONGu6XR4LiMeUUQr6GQS0pA== 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=N6u4hEEhYn54Ul9LclNgtG/hmf57LAryMt/Wmds0Rrg=; b=MxeTaXj9PL36FHvURoFX/0LuNkAmk9+KLsZVosIitOAbnQeSdlXJ+txxyTVSIYI4VbkTi2DusZrLpiUcyYyFivltJxlOws9OsEGmeeXJAFOjNHuLKvuvJRKEA1zZ8GaiQ11eaKFvsxVLz/m3qFWm0anYguK9jPmW6HQF0/x5cRczjEJ3sG2kxmUzbPJIwKqOCSKWc+7AasN3z5CEUz4q10LWhDNH54gRPhProPNo6qhee3QPp0ZEm2Jd7jI8CExtkV0b7sJrDa4P+9ACMZM4E0bq5wa+jGvxdrw7UecS/GuJYBxv3dZ+uVQhAAufbjN+IRZg5q/H8MEvCaYHwH2v0g== 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=N6u4hEEhYn54Ul9LclNgtG/hmf57LAryMt/Wmds0Rrg=; b=f9gLSjnhb4VV8FiD+iuI0u7AZcxy+hwSdf/eZgDHdGmQsVlTQzWfG64wHjfGecz7ksuHkAjtmB9jegsm9Sv0DthPlBhJP1G3UFkvPCp10ODqjtacpjx130FVRFWs07MYwv6dwQ6OVcpcfwGhfDX7zAxYwOuFxp0QYKlVoWzVGxI= 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 DB8PR04MB6811.eurprd04.prod.outlook.com (2603:10a6:10:fa::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 02:01:13 +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.5332.014; Fri, 10 Jun 2022 02:01:13 +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 v2] media: imx-jpeg: Disable slot interrupt when frame done Date: Fri, 10 Jun 2022 10:00:57 +0800 Message-Id: <20220610020057.18124-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.36.1 X-ClientProxiedBy: SI2PR02CA0030.apcprd02.prod.outlook.com (2603:1096:4:195::17) 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: 3faf1d6a-820e-4407-625f-08da4a85186a X-MS-TrafficTypeDiagnostic: DB8PR04MB6811: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: tZD6xT/siZRNUzMOTS5lcI6F5NUxZr+lPA8y03ThfTQsa6z/ivzywSx+MeHNjUyQLJIj8toSVxZ64UO1ddgT3A10B8STouGiEd8/y/vr5DzAg3YpUA/4kCMlrYLgqeWL97pt/LGdyK+S9nnVXFXeomJh6SqWBzjRYr9dMtQZm/dYUgkxZuGiHY/7m6QBNhUFlW6rcsS/y9yP8YsJZ1Kggb8MJFK/Qfoa9mLi2F3If7x6YNVC7SDvmiykROq0FmPN7fFvRED5Gq5bFEfqW4z3Xxsb/kc8q5xrhOIPI6ksA+ZcCkoQGAh+dTNSdqZbyuvB56OCbBXmIJZBKXfLE290flnuPVp/QRwrYw5rNHu8f1uaZ74ND0H/fJkcXG2326WR5wEl1cK2yqJP/yqt35+/+G/J0j1Sq8LYR54eIZA1aaqiZHkR+LDTLP8VWblLU5W/NsEXzIAKt7ZzTLInXAmeGke2aMBJPGiRIc55WZ4gR0VZsjHO0DjfbF/aGx7c43G7o6CeukYnV05hX/eTkg3IbhZi0ZVkIbWolqfypokcA4W+wk5z+vtifEsAkGrPgjbJLFq2g1HvA/GJyJpN4+u35YBfMnWfRuoqvhiF5vQj6qbfGaSZJrEl7sPbOUMbOtNPcnkuUrtqEYp62QogwNh/VVAKshbxKyf464Ztacm6ucASxBzZGx0rZ25w6/mYepfIFAXsh8LgJVh3XB76r1VsDg== 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)(2906002)(6506007)(6486002)(186003)(8936002)(6666004)(52116002)(316002)(38100700002)(2616005)(83380400001)(36756003)(5660300002)(44832011)(38350700002)(7416002)(86362001)(508600001)(6512007)(4326008)(8676002)(26005)(66476007)(66556008)(66946007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CxPD2wqH7rMG572IkiCo7+qXcSitFVdEMY5G4kR9LqS4lObYJSeRZn4j2+NjHAJfAh0ePXER5yJNwxcjSiFyTsjmkjGpc6Hfd3+JPCjULqxIwSg338GVHgEa1v6sjUPtAlsDqrrsOqXoJbnTMDhaQxMoDNN9WrZ87h9jIdt16Q0k0X22xjBWyVMjFUPu8CBedj88Nf88mbaUmC1/aHfQd+g2+IdW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G2a5bxGYlMrk1ClrWcwXqnyoXA8rqDJsLrLZnx7xb+rI39j6uXVadk+WLr/iu5g9YTBPzgEqHdXs5D1XYO5kudz2Vcly+LLnCasGdWFEjJBPsYfCwds7BrSXBZ+9DiroeWCvIH41l0fZJOGPD0GTs8isflcKg7mjRfAQ/f3tgj4X2N+vdOg8YXTGgpNqFonSnC2UyEK6xpB6Wbuz6D63a8f0J9llHcNiQRo/1WzEBmOii97TMRAf08ZxbOoEBAoQlbXEHACP+ibOHdBYHmWtP/2qbc/uDKGam4xeKWDsHu9M7IdsKR3tW6aYsWvUqLj1Hf/30RVOKRYSU2KYAhBwtNT01s2XXhmzVxB2z4c/AD332oS2PT+ZH+PSgdl91O4W383pN75fQuetkxsMFUA4YfDQEDcSZslq1RcqxbrnaZykgL/lujvEe35sZ71U/5l7maC9kLg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3faf1d6a-820e-4407-625f-08da4a85186a X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 02:01:12.8952 (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: kAbWxKNaUtAYZVN6FDOt1nYTkGUEgOVY73HPq7DvxPq+H6nuP1fUd1wFhaPRaX2/8Z2WBm/1CKvkpI0BKrTg/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6811 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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 --- 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 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..c65d480c27ff 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -592,15 +592,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);