Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp405349rwn; Wed, 14 Sep 2022 23:56:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mmBNvLXoL3C/6MWEyecU29HfYOwXKcV7CeOZ6qNKUCogQoqX+/R0eUB7upRI8IpxCE0+H X-Received: by 2002:a17:907:3f90:b0:77e:9281:ee9e with SMTP id hr16-20020a1709073f9000b0077e9281ee9emr11691634ejc.74.1663225013935; Wed, 14 Sep 2022 23:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663225013; cv=none; d=google.com; s=arc-20160816; b=FcGNZEMMBZGao0tjSW/7/MvtXrGemnZu6aqEfYn9xKIq/aumwcWA6m5JAFhnKWH1D9 jq2dh85gorn3xvymhtS0kqIOSCaHWVNXn+WAoSY3LpLpSFzfKAvGTEFANgtst/IQ4gD0 /FAzYuTTpq38qM3NfBmWRDe7350bDPFpHIiIvNHnRbH+NMoXrjAsbKFxI/xTI+IzbrpQ lRfWr8fQNtFKAWsI44yMBJoHenmxcYMQ6HrSy/Pz7jEkADqJ963dx4pbt/QVpU1ZhKAm U4cuRkeXUPuUBsNLb0BvD6x9H59R55kK8OJNBJGNeYJZGYySYYiol69Q89HEw61c62XD /7ng== 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=ANMKC6ZkFGtwmZlRf0rejmnqaZVDZSrENWv39ZoGVFk=; b=TNorMJdn8F3eXsLNCViPLf/3t4Wy2+PmBrnUnGCAJ2Nzu2kcUM6WVkjZd+i6Pl1L6T 0JK1D/KOdyg9S4qLpGSkJxAJ4BOpVvtEHe+p7BCFvGGojXm9eNq9dDbdw6ERKt0zNtEl VDr5ubWo1IHOOk+EcTEpWS5euBeNikx5pY9983MwL0r+SqR6q1fZq8mBYonpAg9ULt5u ESFOZBlO+g8D89LV9eOOC3Bx/yixjo9tYw3YrDZK6s2ylUG+l9sqfk6vIuNsRbZh9d53 Xcwh09AuANnM6jlYDa0wyfh2ZTOTgFGmuVWklkElIDTLxgZCiObfvqOFnHaX74rc2SQC QxCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=cI1YZLhJ; 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 i21-20020a170906251500b0077c6f26aa3bsi8893185ejb.656.2022.09.14.23.56.27; Wed, 14 Sep 2022 23:56:53 -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=cI1YZLhJ; 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 S229895AbiIOGoc (ORCPT + 99 others); Thu, 15 Sep 2022 02:44:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbiIOGoK (ORCPT ); Thu, 15 Sep 2022 02:44:10 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58A258C448; Wed, 14 Sep 2022 23:44:05 -0700 (PDT) X-UUID: 1ed0e7d690ab4912b13a4a1b6106f72d-20220915 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=ANMKC6ZkFGtwmZlRf0rejmnqaZVDZSrENWv39ZoGVFk=; b=cI1YZLhJGknzgH8BqWTiyC3wCC77z+91s9zmSCiV6tSG5HCYEuiyNVRC87nvuvlCI4RzlZ2xkKUoBX51ogIuJritknYkZItVz0oJnSiX4mOZdr7tIqHBZuGhwJcABLCz0R5D+OL+Mavt9Sshsw1OyUfm1xhiNsowQEp5BzRbyJo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11,REQID:8a7f745d-dacf-439a-bc42-ffba0eae0d9f,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.11,REQID:8a7f745d-dacf-439a-bc42-ffba0eae0d9f,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:39a5ff1,CLOUDID:ea90bb5d-5ed4-4e28-8b00-66ed9f042fbd,B ulkID:220915144401EF89AHW3,BulkQuantity:0,Recheck:0,SF:28|17|19|48,TC:nil, Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 1ed0e7d690ab4912b13a4a1b6106f72d-20220915 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 165052958; Thu, 15 Sep 2022 14:43:58 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) 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; Thu, 15 Sep 2022 14:43:56 +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; Thu, 15 Sep 2022 14:43:55 +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: [V14,04/15] mtk-jpegenc: add jpegenc timeout func interface Date: Thu, 15 Sep 2022 14:43:32 +0800 Message-ID: <20220915064337.2686-5-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915064337.2686-1-irui.wang@mediatek.com> References: <20220915064337.2686-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 | 10 ++++++++ .../platform/mediatek/jpeg/mtk_jpeg_enc_hw.c | 25 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h index 1e0ba466303b..98de83c9ea4c 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, @@ -99,6 +105,8 @@ struct mtk_jpegenc_clk { * @master_dev: mtk_jpeg_dev device * @venc_clk: jpeg encode clock * @jpegenc_irq: jpeg encode irq num + * @job_timeout_work: encode timeout workqueue + * @hw_param: jpeg encode hw parameters */ struct mtk_jpegenc_comp_dev { struct device *dev; @@ -107,6 +115,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 3dcf83d6d95e..95812f60ab9f 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) @@ -276,6 +298,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