Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp168145rwe; Fri, 26 Aug 2022 02:53:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wqQWw072+Cukr9FeaF+0XWLKDVyCxNgFSDG18sLT9RzGXlyfONnASnb/O9HF6aL8vR8Xj X-Received: by 2002:a17:903:489:b0:172:abe8:fed1 with SMTP id jj9-20020a170903048900b00172abe8fed1mr3079447plb.71.1661507616790; Fri, 26 Aug 2022 02:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661507616; cv=none; d=google.com; s=arc-20160816; b=Z5q0o47BPS21LBhfH+PSEz1PIHKeTTm4iTAf6kUNMk8F1MWsWZYNJFpAiqowQE+15K wS7viMP6FJFv3O5zPtbjZminatnEhxI6rQP7sV24Jaon6FHykXlgUIzH0JEgpIPQtKnc ZLglEM34Fy8arUA/HwcdMm2zMY/GwGCcaHCAjppJdx0vczdcZeHFpSJVHWHALv8C3nlE B12GUQjSAi/O0dmBHuysjpxMwS0WMTAqG0YoWrfCoFdGbEtTlMxJdzqy4hM4Gz3pdfsF tkdm9EX4xUPLAD+u+k1a5DAjRTdTemik49CAOliBrdcsOrUN5vBiv8cw7ct2ypIg1Jl+ k3PQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q0mrgZFzVjI3vXS+/kdgd/qatwh1EhrnJriYf6CL6Z0=; b=qcD5uAbR/PwZkP6YiTUxFF0E1x0OcJnfLJkK3wM+VGuqhzdHVPEzg7cjxkX0WIS2sq JweYD7/LKPaXmT5L4OlzoK4/n/QW82+0g6nuDJ82XmiQMWP5WewCa5Ak+6R+eOlI7M/v 11YH2eq9Resx2nYJ4iRDQlBnr4LvmNT057vyveKkdD+t18zKynKsWJ22H0lx0st3hUYH E4VcIcrX5SxFyeHuvsjtoz8w9kLm57iVfDddap65Qh6JXoxtmsXpP21rFvNOK/ATZx/A bwUaJLiPGxcPCfacvc5foKwGaPGieU2D5zopqTyq63SP0vjCWvXm+CUdAGoApdVeFPcW JzTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=AEq4o+pC; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn17-20020a17090b38d100b001f14520fd96si1714524pjb.19.2022.08.26.02.53.25; Fri, 26 Aug 2022 02:53:36 -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=@mediatek.com header.s=dk header.b=AEq4o+pC; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344049AbiHZJbX (ORCPT + 99 others); Fri, 26 Aug 2022 05:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343876AbiHZJam (ORCPT ); Fri, 26 Aug 2022 05:30:42 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6583014D3A; Fri, 26 Aug 2022 02:30:20 -0700 (PDT) X-UUID: 095550e6143842d9aac7f30283b4cbc1-20220826 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Q0mrgZFzVjI3vXS+/kdgd/qatwh1EhrnJriYf6CL6Z0=; b=AEq4o+pCR2FKSlKHwHWSmkfvYpU6RFl4PEDCVUmLD86MlXKR6G80Jum0qd1EafrpgjPxV2iJAbRv1TkT7NHRiBivLwW+KT6zUNqDfZ84aSXqLvyfHVhBa6gMDLLHKhumHN9t6Ka/KDfA/6Wy4YfSQjL1AjNrE+jUr5bqqQWBIgs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.10,REQID:e3d71da4-95e5-43e2-a87a-83fb9c19ee7b,OB:0,L OB:0,IP:0,URL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Releas e_Ham,ACTION:release,TS:-25 X-CID-META: VersionHash:84eae18,CLOUDID:1051b4cf-20bd-4e5e-ace8-00692b7ab380,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File: nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 095550e6143842d9aac7f30283b4cbc1-20220826 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 904293156; Fri, 26 Aug 2022 17:30:13 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Fri, 26 Aug 2022 17:30:04 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 26 Aug 2022 17:30:02 +0800 From: Irui Wang To: Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tzung-Bi Shih , , , , kyrie wu CC: , , , , , , Tomasz Figa , , , irui wang Subject: [V13,4/7] mtk-jpegenc: add jpegenc timeout func interface Date: Fri, 26 Aug 2022 17:29:53 +0800 Message-ID: <20220826092956.10340-5-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220826092956.10340-1-irui.wang@mediatek.com> References: <20220826092956.10340-1-irui.wang@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_CSS 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: kyrie wu Generalizes jpegenc timeout func interfaces to handle HW timeout. Signed-off-by: kyrie wu Signed-off-by: irui wang --- .../platform/mediatek/jpeg/mtk_jpeg_core.h | 8 ++++++ .../platform/mediatek/jpeg/mtk_jpeg_enc_hw.c | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h index 4aaddf0301d1..caa9370ac8ac 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h @@ -75,6 +75,12 @@ struct mtk_jpeg_variant { u32 cap_q_default_fourcc; }; +struct mtk_jpeg_hw_param { + struct vb2_v4l2_buffer *src_buffer; + struct vb2_v4l2_buffer *dst_buffer; + struct mtk_jpeg_ctx *curr_ctx; +}; + enum mtk_jpegenc_hw_id { MTK_JPEGENC_HW0, MTK_JPEGENC_HW1, @@ -105,6 +111,8 @@ struct mtk_jpegenc_comp_dev { struct mtk_jpeg_dev *master_dev; struct mtk_jpegenc_clk venc_clk; int jpegenc_irq; + struct delayed_work job_timeout_work; + struct mtk_jpeg_hw_param hw_param; }; /** diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c index 749851590a75..4d0d254bd574 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c @@ -185,6 +185,26 @@ void mtk_jpeg_set_enc_params(struct mtk_jpeg_ctx *ctx, void __iomem *base) } EXPORT_SYMBOL_GPL(mtk_jpeg_set_enc_params); +static void mtk_jpegenc_timeout_work(struct work_struct *work) +{ + struct delayed_work *dly_work = to_delayed_work(work); + struct mtk_jpegenc_comp_dev *cjpeg = + container_of(dly_work, + struct mtk_jpegenc_comp_dev, + job_timeout_work); + enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR; + struct vb2_v4l2_buffer *src_buf, *dst_buf; + + src_buf = cjpeg->hw_param.src_buffer; + dst_buf = cjpeg->hw_param.dst_buffer; + v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, true); + + mtk_jpeg_enc_reset(cjpeg->reg_base); + clk_disable_unprepare(cjpeg->venc_clk.clks->clk); + pm_runtime_put(cjpeg->dev); + v4l2_m2m_buf_done(src_buf, buf_state); +} + static irqreturn_t mtk_jpegenc_hw_irq_handler(int irq, void *priv) { struct vb2_v4l2_buffer *src_buf, *dst_buf; @@ -196,6 +216,8 @@ static irqreturn_t mtk_jpegenc_hw_irq_handler(int irq, void *priv) struct mtk_jpegenc_comp_dev *jpeg = priv; struct mtk_jpeg_dev *master_jpeg = jpeg->master_dev; + cancel_delayed_work(&jpeg->job_timeout_work); + irq_status = readl(jpeg->reg_base + JPEG_ENC_INT_STS) & JPEG_ENC_INT_STATUS_MASK_ALLIRQ; if (irq_status) @@ -278,6 +300,9 @@ static int mtk_jpegenc_hw_probe(struct platform_device *pdev) master_dev->enc_hw_dev[i] = NULL; } + INIT_DELAYED_WORK(&dev->job_timeout_work, + mtk_jpegenc_timeout_work); + jpegenc_clk = &dev->venc_clk; jpegenc_clk->clk_num = devm_clk_bulk_get_all(&pdev->dev, -- 2.18.0