Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp535113iog; Wed, 15 Jun 2022 07:18:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJc0gcH2J8Sq7ZmKCM8YZGpj+0xBI9PlB2ByiJwcPAQMgmAX1nEubsY8L9ikMnuAHrH/b0 X-Received: by 2002:aa7:9e9c:0:b0:51b:e1b8:271c with SMTP id p28-20020aa79e9c000000b0051be1b8271cmr10229506pfq.73.1655302712896; Wed, 15 Jun 2022 07:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655302712; cv=none; d=google.com; s=arc-20160816; b=k3tAeuU7kke++TZ2biUKI5gtYNF7Xw4eyrjHE/DjhBWZFzBd3ZQdZs5dIQw9lwdz1z LeQIMwcF+7Go3gR5Pz9XRSXieae7HAvG1gB0XlhNZyO9vj0xJQmemjwStaMmOxWshtJr CiacOEiseuLg0CKpDMV+L2VBtSHeaynVMb+wwQU1WDJDSf5UXLus06QoO0WXlduhf7l/ apTyfMBWNUPk7jFsUPmuPW96/EdX3fEXMGhKfWzSjNBCiGNazsTgLQodWu0HNpAyWmL2 m09t4cO4CvteSnSP+ozWSfQ6SV8TvxwujXav3IwlA1uTZSo0oXoTLIKpt0B/g0q6PKcp sSCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=T9eq4r9Pe9t81eYIGkTX5xMWzyZu9wStgr6YkM4XD0g=; b=u7trvLCgHPIV4lOIYoLQ0pU00j9F2nW7+N0MAjlme6kZnRRN7x8pgU50t6xsa3Z/oa r7gWfehvzk5gYizqQFtverCNS3bvIt00Opu5PImcJjZCY0jYsunl6ug8rq3xQ3rWzxys uk82lyoTfgG6MeOybYoldUd2ZVzcoV6nItE6Iq7zGPf9WK79WiYP7f49k/BRjEZoMiOd zjcRxGnNIuWJPt5/g8ysqIKI2KYbcEz7qqSiCMbCbLXwuX3Qs4GI+/xajqR5QsnCbBtJ pECzmsLqC/XCaz7SAwXDup2w8CrLgRxK+jzgaKpRxVi9KVldYwp3Hd4R3o2bG0czn2F3 Ledg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Xp91NeW7; 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=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a1709029b8700b0015bd2c5232esi15463666plp.568.2022.06.15.07.18.13; Wed, 15 Jun 2022 07:18:32 -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=@collabora.com header.s=mail header.b=Xp91NeW7; 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=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356301AbiFOODC (ORCPT + 99 others); Wed, 15 Jun 2022 10:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355945AbiFOOCq (ORCPT ); Wed, 15 Jun 2022 10:02:46 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA045101D; Wed, 15 Jun 2022 07:02:38 -0700 (PDT) Received: from nicolas-tpx395.localdomain (192-222-136-102.qc.cable.ebox.net [192.222.136.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id DF66B6601701; Wed, 15 Jun 2022 15:02:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655301738; bh=A/jvOxm1ICij5K0mIG7oqF5iy6HOnMoo/iFg2qWHY+o=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Xp91NeW7/5pDED1maKh/hv/BrO3shNGUFb2jaEdMzphcwtcjlNybZ+ct8f3IwhDac ZI/OWfjBpJZKrBoklAeASR8Tu7mCBjc99sYoSIPJ0Urj/ds4at6R0RGAq8X/YdOc9q l8yW8bym5tB5LXyiaqIv4I/Cs1Ws8rhasaPXmj4yTo0/cc2I73wnpxAeUhobtyvtLD jbRIWok6C3Y3BMSDsNsenU06cBgVOzTqVuBEsv0HUmYc2S++fOMctZZZKa+JFWCIpr 6zUxp6Q2kTv52QxFTODST5w3r1d0nHz3uRuPUXCICLdGey89ewVi2W6DwOfbxVW3VS no6sEAK760B8w== Message-ID: Subject: Re: [V9,4/7] mtk-jpegenc: add jpegenc timeout func interface From: Nicolas Dufresne To: Irui Wang , Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tzung-Bi Shih , angelogioacchino.delregno@collabora.com, wenst@chromium.org Cc: Project_Global_Chrome_Upstream_Group@mediatek.com, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Tomasz Figa , xia.jiang@mediatek.com, maoguang.meng@mediatek.com, kyrie wu , srv_heupstream@mediatek.com Date: Wed, 15 Jun 2022 10:02:07 -0400 In-Reply-To: <20220613032306.23237-5-irui.wang@mediatek.com> References: <20220613032306.23237-1-irui.wang@mediatek.com> <20220613032306.23237-5-irui.wang@mediatek.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.1 (3.44.1-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Le lundi 13 juin 2022 =C3=A0 11:23 +0800, Irui Wang a =C3=A9crit=C2=A0: > From: kyrie wu >=20 > Generalizes jpegenc timeout func interfaces to handle HW timeout. >=20 > Signed-off-by: kyrie wu > --- > .../platform/mediatek/jpeg/mtk_jpeg_core.h | 8 ++++++ > .../platform/mediatek/jpeg/mtk_jpeg_enc_hw.c | 25 +++++++++++++++++++ > 2 files changed, 33 insertions(+) >=20 > diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drive= rs/media/platform/mediatek/jpeg/mtk_jpeg_core.h > index f6e980fde4ef..0683d80fcea5 100644 > --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h > +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h > @@ -76,6 +76,12 @@ struct mtk_jpeg_variant { > u32 cap_q_default_fourcc; > }; > =20 > +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, > @@ -107,6 +113,8 @@ struct mtk_jpegenc_comp_dev { > struct mtk_jpegenc_clk venc_clk; > int jpegenc_irq; > int hw_id; > + struct delayed_work job_timeout_work; > + struct mtk_jpeg_hw_param hw_param; > }; > =20 > /** > diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c b/dri= vers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c > index 8ac6b031dcd4..99f3db2a393a 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 *ct= x, void __iomem *base) > } > EXPORT_SYMBOL_GPL(mtk_jpeg_set_enc_params); > =20 > +static void mtk_jpegenc_timeout_work(struct work_struct *work) > +{ > + struct delayed_work *dly_work =3D to_delayed_work(work); > + struct mtk_jpegenc_comp_dev *cjpeg =3D > + container_of(dly_work, > + struct mtk_jpegenc_comp_dev, > + job_timeout_work); > + enum vb2_buffer_state buf_state =3D VB2_BUF_STATE_ERROR; > + struct vb2_v4l2_buffer *src_buf, *dst_buf; > + > + src_buf =3D cjpeg->hw_param.src_buffer; > + dst_buf =3D cjpeg->hw_param.dst_buffer; > + dst_buf->vb2_buf.timestamp =3D src_buf->vb2_buf.timestamp; Another case for v4l2_m2m_buf_copy_metadata? As you know early the dst_buf,= you could do that once before you start the encoding, this could possibly remov= e the duplication. > + > + 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 =3D priv; > struct mtk_jpeg_dev *master_jpeg =3D jpeg->master_dev; > =20 > + cancel_delayed_work(&jpeg->job_timeout_work); > + > irq_status =3D readl(jpeg->reg_base + JPEG_ENC_INT_STS) & > JPEG_ENC_INT_STATUS_MASK_ALLIRQ; > if (irq_status) > @@ -272,6 +294,9 @@ static int mtk_jpegenc_hw_probe(struct platform_devic= e *pdev) > dev->plat_dev =3D pdev; > dev->dev =3D &pdev->dev; > =20 > + INIT_DELAYED_WORK(&dev->job_timeout_work, > + mtk_jpegenc_timeout_work); > + > jpegenc_clk =3D &dev->venc_clk; > =20 > jpegenc_clk->clk_num =3D devm_clk_bulk_get_all(&pdev->dev,