Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp174009rwe; Fri, 26 Aug 2022 03:01:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR50h3n5T5aNhGu3XJTyTzlMOdtSpovvXKlvQKy1O/Gp6RixbOyDwLdG2s/qKlbnDUJJgfCh X-Received: by 2002:a05:6a00:3406:b0:535:f76f:c971 with SMTP id cn6-20020a056a00340600b00535f76fc971mr3156799pfb.5.1661508103780; Fri, 26 Aug 2022 03:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661508103; cv=none; d=google.com; s=arc-20160816; b=pLtcQGUJ3gVvwSwNtz98kuOJm/14LYxikf7gn3bofKZJjajz64/6vpdKU3hM0D6Pmw QOWUP3n1guIwXphHuRq7UADR4/Sd1Uz8Mt+uo3B7B7Osf8PLfYcS7TPomba7LNP0Y0e/ ocFmoyzS43qm8NOwmZuCPdxFkK+BIrOP+qfD313qWcAkHWerJOxzRq6+8WB0M4viVUDR dKewG15z+XslGxGbNfXM8Vm1k5mLFKPzclsNZOrmDq6/Bj4m8aVG3lbNl5RE1ijwwlaf VsYNW+mLtpz+0QyDDl0XYV2LVLyYzOe6m/FUCVZw9CD9rbGZk7aSjEyYt8V3mm6dHUrp rwHQ== 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=UjhVZ8Y+s50GJFoZPhZrMvYS/u6tJyJht55aHYQiw0w=; b=0yW5cqowp3sg0L25R7cQzZUgVCHeoFzWoNdBRAHldI+zrZpf07lqoKh1wZzB6ZB2PZ YWWPSwnaGMgIDTpgUzcvUrINgj27I1LzZqXT4UcGu7taWnvbwqGyRAuFRMC9KKUOqBlJ lLeiDYfl3CYdGahBGJzl80EdT+suc43xZZ3W/fA8vDpNL3dgMVFnUvFAdHdPNJThvcdJ KwtGsPLobqwLi7+mQ4ULot+2NA+mGmkPeqR5b54BmxlvRQjSUX9Foa01nHVdGCqJ9iq5 QuBserWi86XkIEtDx3g+pVPH/931iEKfu0YYuZwgTmClaJA3m00u55sKLbbDqltaf2GL YUuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="CNxrtTW/"; 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 k15-20020a17090a39cf00b001f583086f04si1532186pjf.112.2022.08.26.03.01.32; Fri, 26 Aug 2022 03:01:43 -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="CNxrtTW/"; 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 S1343829AbiHZJ3k (ORCPT + 99 others); Fri, 26 Aug 2022 05:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343797AbiHZJ3X (ORCPT ); Fri, 26 Aug 2022 05:29:23 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D26DD7CE4; Fri, 26 Aug 2022 02:29:20 -0700 (PDT) X-UUID: 9c3b9ca1d01342f4ab3e15b72b8b69ab-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=UjhVZ8Y+s50GJFoZPhZrMvYS/u6tJyJht55aHYQiw0w=; b=CNxrtTW/u+vCoEqeyubfECU480kIlowbaGvF+tKMKFR35/q4PvmpwxDXrtbgsBOUpB2mMIKT8zpU5+S/HicIALwtx953kdxKmNlKslB3rR5QPxUKhxVvyk2RA0OrS0M61rfwRbiDzYmAefE9eQ7WJ7CX5arvKwQ4fW4toH4A/H0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.10,REQID:0c7bb455-525c-4fc7-b539-2f83fd803063,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:435d3320-1c20-48a5-82a0-25f9c331906d,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: 9c3b9ca1d01342f4ab3e15b72b8b69ab-20220826 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1734174197; Fri, 26 Aug 2022 17:29:13 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n1.mediatek.inc (172.21.101.185) 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:29:12 +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:29:11 +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: [V7,4/8] media: mtk-jpegdec: add jpegdec timeout func interface Date: Fri, 26 Aug 2022 17:29:00 +0800 Message-ID: <20220826092904.10283-5-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220826092904.10283-1-irui.wang@mediatek.com> References: <20220826092904.10283-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 jpegdec timeout func interfaces to handle HW timeout. Signed-off-by: kyrie wu Signed-off-by: irui wang --- .../platform/mediatek/jpeg/mtk_jpeg_core.h | 2 ++ .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h index 80af31ba8c3a..0d2d2baedcf7 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h @@ -169,6 +169,8 @@ struct mtk_jpegdec_comp_dev { struct mtk_jpeg_dev *master_dev; struct mtk_jpegdec_clk jdec_clk; int jpegdec_irq; + struct delayed_work job_timeout_work; + struct mtk_jpeg_hw_param hw_param; }; /** diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c index bc48054d847f..78d14733b269 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c @@ -440,6 +440,25 @@ void mtk_jpeg_dec_set_config(void __iomem *base, } EXPORT_SYMBOL_GPL(mtk_jpeg_dec_set_config); +static void mtk_jpegdec_timeout_work(struct work_struct *work) +{ + enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR; + struct mtk_jpegdec_comp_dev *cjpeg = + container_of(work, struct mtk_jpegdec_comp_dev, + job_timeout_work.work); + 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_dec_reset(cjpeg->reg_base); + clk_disable_unprepare(cjpeg->jdec_clk.clks->clk); + pm_runtime_put(cjpeg->dev); + v4l2_m2m_buf_done(src_buf, buf_state); + v4l2_m2m_buf_done(dst_buf, buf_state); +} + static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv) { struct vb2_v4l2_buffer *src_buf, *dst_buf; @@ -453,6 +472,8 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv) struct mtk_jpegdec_comp_dev *jpeg = priv; struct mtk_jpeg_dev *master_jpeg = jpeg->master_dev; + cancel_delayed_work(&jpeg->job_timeout_work); + irq_status = mtk_jpeg_dec_get_int_status(jpeg->reg_base); dec_irq_ret = mtk_jpeg_dec_enum_result(irq_status); if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW) @@ -540,6 +561,9 @@ static int mtk_jpegdec_hw_probe(struct platform_device *pdev) master_dev->dec_hw_dev[i] = NULL; } + INIT_DELAYED_WORK(&dev->job_timeout_work, + mtk_jpegdec_timeout_work); + jpegdec_clk = &dev->jdec_clk; jpegdec_clk->clk_num = devm_clk_bulk_get_all(&pdev->dev, -- 2.18.0