From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerry-ch Chen Subject: Re: [RFC PATCH V2 4/4] platform: mtk-isp: Add Mediatek FD driver Date: Wed, 4 Sep 2019 17:26:28 +0800 Message-ID: <1567589188.22453.24.camel@mtksdccf07> References: <1562661672-22439-1-git-send-email-Jerry-Ch.chen@mediatek.com> <1562661672-22439-5-git-send-email-Jerry-Ch.chen@mediatek.com> <20190802082815.GA203993@chromium.org> <1566724680.20680.8.camel@mtksdccf07> <1566957625.20680.33.camel@mtksdccf07> <1567424859.18318.32.camel@mtksdccf07> <1567493081.18318.49.camel@mtksdccf07> <1567511169.18318.65.camel@mtksdccf07> <1567568281.18318.80.camel@mtksdccf07> <1567577389.18318.100.camel@mtksdccf07> <1567584577.22453.11.camel@mtksdccf07> <1567587708.22453.15.camel@mtksdccf07> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+glpam-linux-mediatek=m.gmane.org-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org To: Tomasz Figa Cc: "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Sean Cheng =?UTF-8?Q?=28=E9=84=AD=E6=98=87=E5=BC=98=29?= , "laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org" , Rynn Wu =?UTF-8?Q?=28=E5=90=B3=E8=82=B2=E6=81=A9=29?= , srv_heupstream , Po-Yang Huang =?UTF-8?Q?=28=E9=BB=83=E6=9F=8F=E9=99=BD=29?= , "mchehab-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org" , "suleiman-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org" , "shik-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org" , Jungo Lin =?UTF-8?Q?=28=E6=9E=97=E6=98=8E=E4=BF=8A=29?= , Sj Huang =?UTF-8?Q?=28=E9=BB=83=E4=BF=A1=E7=92=8B=29?= , "yuzhao-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org" , "linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" , zwisler-F7+t8E8rja8pug/h7KTFAQ@public.gmane.org List-Id: devicetree@vger.kernel.org Hi Tomasz, On Wed, 2019-09-04 at 17:03 +0800, Tomasz Figa wrote: > On Wed, Sep 4, 2019 at 6:02 PM Jerry-ch Chen wrote: > > > > Hi Tomasz, > > > > On Wed, 2019-09-04 at 16:25 +0800, Tomasz Figa wrote: > > > On Wed, Sep 4, 2019 at 5:09 PM Jerry-ch Chen wrote: > > > > > > > > Hi Tomasz, > > > > > > > > On Wed, 2019-09-04 at 14:34 +0800, Tomasz Figa wrote: > > > > > On Wed, Sep 4, 2019 at 3:09 PM Jerry-ch Chen wrote: > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > On Wed, 2019-09-04 at 12:15 +0800, Tomasz Figa wrote: > > > > > > > On Wed, Sep 4, 2019 at 12:38 PM Jerry-ch Chen > > > > > > > wrote: > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 20:05 +0800, Tomasz Figa wrote: > > > > > > > > > On Tue, Sep 3, 2019 at 8:46 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 15:04 +0800, Tomasz Figa wrote: > > > > > > > > > > > On Tue, Sep 3, 2019 at 3:44 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 13:19 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > On Mon, Sep 2, 2019 at 8:47 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, 2019-08-30 at 16:33 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > On Wed, Aug 28, 2019 at 11:00 AM Jerry-ch Chen > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Mon, 2019-08-26 at 14:36 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > > > Hi Jerry, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sun, Aug 25, 2019 at 6:18 PM Jerry-ch Chen > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, 2019-08-02 at 16:28 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > > > > > Hi Jerry, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Tue, Jul 09, 2019 at 04:41:12PM +0800, Jerry-ch Chen wrote: [snip] > > > > static void mtk_fd_vb2_stop_streaming(struct vb2_queue *vq) > > > > { > > > > struct mtk_fd_ctx *ctx = vb2_get_drv_priv(vq); > > > > struct mtk_fd_dev *fd = ctx->fd_dev; > > > > struct vb2_v4l2_buffer *vb; > > > > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > > > struct v4l2_m2m_queue_ctx *queue_ctx; > > > > u32 ret; > > > > > > > > if (!fd->fd_irq_done.done) > > > > > > We shouldn't access internal fields of completion. > > > > > > > ret = wait_for_completion_timeout(&fd->fd_irq_done, > > > > msecs_to_jiffies( > > > > MTK_FD_HW_TIMEOUT)); > > > > queue_ctx = V4L2_TYPE_IS_OUTPUT(vq->type) ? > > > > &m2m_ctx->out_q_ctx : > > > > &m2m_ctx->cap_q_ctx; > > > > while ((vb = v4l2_m2m_buf_remove(queue_ctx))) > > > > v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR); > > > > > > > > if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) > > > > mtk_fd_hw_disconnect(fd); > > > > } > > > > > > > > I've also tried to wait completion unconditionally for both queues and > > > > the second time will wait until timeout, as a result, it takes longer to > > > > swap the camera every time and close the camera app. > > > > > > I think it should work better if we call complete_all() instead of complete(). > > > > > Thanks, > > > > I use complete_all(), and it works fine now. > > > > static void mtk_fd_vb2_stop_streaming(struct vb2_queue *vq) > > { > > struct mtk_fd_ctx *ctx = vb2_get_drv_priv(vq); > > struct mtk_fd_dev *fd = ctx->fd_dev; > > struct vb2_v4l2_buffer *vb; > > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > struct v4l2_m2m_queue_ctx *queue_ctx; > > > > wait_for_completion_timeout(&fd->fd_irq_done, > > msecs_to_jiffies(MTK_FD_HW_TIMEOUT)); > > Shouldn't we still send some command to the hardware to stop? Like a > reset. Otherwise we don't know if it isn't still accessing the memory. > I thought no more jobs will be enqueued here when stop_streaming so we don't need it. We still could send an ipi command to reset the HW, and wait for it's callback or we could set the register MTK_FD_REG_OFFSET_HW_ENABLE to zero to disable the HW. Best regards, Jerry > > queue_ctx = V4L2_TYPE_IS_OUTPUT(vq->type) ? > > &m2m_ctx->out_q_ctx : > > &m2m_ctx->cap_q_ctx; > > while ((vb = v4l2_m2m_buf_remove(queue_ctx))) > > v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR); > > > > if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) > > mtk_fd_hw_disconnect(fd); > > } > > > > Best regards, > > Jerry > > > > > Best regards, > > > Tomasz > > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9755DC3A5A7 for ; Wed, 4 Sep 2019 09:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DF0B233A1 for ; Wed, 4 Sep 2019 09:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbfIDJ0p (ORCPT ); Wed, 4 Sep 2019 05:26:45 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:7749 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725840AbfIDJ0p (ORCPT ); Wed, 4 Sep 2019 05:26:45 -0400 X-UUID: 5ecf207a7b104b0294e2bd35771b3ea3-20190904 X-UUID: 5ecf207a7b104b0294e2bd35771b3ea3-20190904 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 174315045; Wed, 04 Sep 2019 17:26:36 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 Sep 2019 17:26:28 +0800 Received: from [172.21.84.99] (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 4 Sep 2019 17:26:27 +0800 Message-ID: <1567589188.22453.24.camel@mtksdccf07> Subject: Re: [RFC PATCH V2 4/4] platform: mtk-isp: Add Mediatek FD driver From: Jerry-ch Chen To: Tomasz Figa CC: "yuzhao@chromium.org" , "zwisler@chromium.org" , "linux-mediatek@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , Sean Cheng =?UTF-8?Q?=28=E9=84=AD=E6=98=87=E5=BC=98=29?= , "Sj Huang =?UTF-8?Q?=28=E9=BB=83=E4=BF=A1=E7=92=8B=29?=" , Christie Yu =?UTF-8?Q?=28=E6=B8=B8=E9=9B=85=E6=83=A0=29?= , Frederic Chen =?UTF-8?Q?=28=E9=99=B3=E4=BF=8A=E5=85=83=29?= , Jungo Lin =?UTF-8?Q?=28=E6=9E=97=E6=98=8E=E4=BF=8A=29?= , Rynn Wu =?UTF-8?Q?=28=E5=90=B3=E8=82=B2=E6=81=A9=29?= , "Po-Yang Huang =?UTF-8?Q?=28=E9=BB=83=E6=9F=8F=E9=99=BD=29?=" , "shik@chromium.org" , "suleiman@chromium.org" , "linux-media@vger.kernel.org" , srv_heupstream , "devicetree@vger.kernel.org" , "laurent.pinchart+renesas@ideasonboard.com" , "hans.verkuil@cisco.com" , "mchehab@kernel.org" , "matthias.bgg@gmail.com" Date: Wed, 4 Sep 2019 17:26:28 +0800 In-Reply-To: References: <1562661672-22439-1-git-send-email-Jerry-Ch.chen@mediatek.com> <1562661672-22439-5-git-send-email-Jerry-Ch.chen@mediatek.com> <20190802082815.GA203993@chromium.org> <1566724680.20680.8.camel@mtksdccf07> <1566957625.20680.33.camel@mtksdccf07> <1567424859.18318.32.camel@mtksdccf07> <1567493081.18318.49.camel@mtksdccf07> <1567511169.18318.65.camel@mtksdccf07> <1567568281.18318.80.camel@mtksdccf07> <1567577389.18318.100.camel@mtksdccf07> <1567584577.22453.11.camel@mtksdccf07> <1567587708.22453.15.camel@mtksdccf07> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Tomasz, On Wed, 2019-09-04 at 17:03 +0800, Tomasz Figa wrote: > On Wed, Sep 4, 2019 at 6:02 PM Jerry-ch Chen wrote: > > > > Hi Tomasz, > > > > On Wed, 2019-09-04 at 16:25 +0800, Tomasz Figa wrote: > > > On Wed, Sep 4, 2019 at 5:09 PM Jerry-ch Chen wrote: > > > > > > > > Hi Tomasz, > > > > > > > > On Wed, 2019-09-04 at 14:34 +0800, Tomasz Figa wrote: > > > > > On Wed, Sep 4, 2019 at 3:09 PM Jerry-ch Chen wrote: > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > On Wed, 2019-09-04 at 12:15 +0800, Tomasz Figa wrote: > > > > > > > On Wed, Sep 4, 2019 at 12:38 PM Jerry-ch Chen > > > > > > > wrote: > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 20:05 +0800, Tomasz Figa wrote: > > > > > > > > > On Tue, Sep 3, 2019 at 8:46 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 15:04 +0800, Tomasz Figa wrote: > > > > > > > > > > > On Tue, Sep 3, 2019 at 3:44 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 13:19 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > On Mon, Sep 2, 2019 at 8:47 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, 2019-08-30 at 16:33 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > On Wed, Aug 28, 2019 at 11:00 AM Jerry-ch Chen > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Mon, 2019-08-26 at 14:36 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > > > Hi Jerry, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sun, Aug 25, 2019 at 6:18 PM Jerry-ch Chen > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, 2019-08-02 at 16:28 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > > > > > Hi Jerry, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Tue, Jul 09, 2019 at 04:41:12PM +0800, Jerry-ch Chen wrote: [snip] > > > > static void mtk_fd_vb2_stop_streaming(struct vb2_queue *vq) > > > > { > > > > struct mtk_fd_ctx *ctx = vb2_get_drv_priv(vq); > > > > struct mtk_fd_dev *fd = ctx->fd_dev; > > > > struct vb2_v4l2_buffer *vb; > > > > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > > > struct v4l2_m2m_queue_ctx *queue_ctx; > > > > u32 ret; > > > > > > > > if (!fd->fd_irq_done.done) > > > > > > We shouldn't access internal fields of completion. > > > > > > > ret = wait_for_completion_timeout(&fd->fd_irq_done, > > > > msecs_to_jiffies( > > > > MTK_FD_HW_TIMEOUT)); > > > > queue_ctx = V4L2_TYPE_IS_OUTPUT(vq->type) ? > > > > &m2m_ctx->out_q_ctx : > > > > &m2m_ctx->cap_q_ctx; > > > > while ((vb = v4l2_m2m_buf_remove(queue_ctx))) > > > > v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR); > > > > > > > > if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) > > > > mtk_fd_hw_disconnect(fd); > > > > } > > > > > > > > I've also tried to wait completion unconditionally for both queues and > > > > the second time will wait until timeout, as a result, it takes longer to > > > > swap the camera every time and close the camera app. > > > > > > I think it should work better if we call complete_all() instead of complete(). > > > > > Thanks, > > > > I use complete_all(), and it works fine now. > > > > static void mtk_fd_vb2_stop_streaming(struct vb2_queue *vq) > > { > > struct mtk_fd_ctx *ctx = vb2_get_drv_priv(vq); > > struct mtk_fd_dev *fd = ctx->fd_dev; > > struct vb2_v4l2_buffer *vb; > > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > struct v4l2_m2m_queue_ctx *queue_ctx; > > > > wait_for_completion_timeout(&fd->fd_irq_done, > > msecs_to_jiffies(MTK_FD_HW_TIMEOUT)); > > Shouldn't we still send some command to the hardware to stop? Like a > reset. Otherwise we don't know if it isn't still accessing the memory. > I thought no more jobs will be enqueued here when stop_streaming so we don't need it. We still could send an ipi command to reset the HW, and wait for it's callback or we could set the register MTK_FD_REG_OFFSET_HW_ENABLE to zero to disable the HW. Best regards, Jerry > > queue_ctx = V4L2_TYPE_IS_OUTPUT(vq->type) ? > > &m2m_ctx->out_q_ctx : > > &m2m_ctx->cap_q_ctx; > > while ((vb = v4l2_m2m_buf_remove(queue_ctx))) > > v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR); > > > > if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) > > mtk_fd_hw_disconnect(fd); > > } > > > > Best regards, > > Jerry > > > > > Best regards, > > > Tomasz > > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0BE2C3A5A8 for ; Wed, 4 Sep 2019 09:26:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 871E822DBF for ; Wed, 4 Sep 2019 09:26:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pTDUIt8y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 871E822DBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5Ge6J+f4K2y1ahdyd1POyjECTpr9v+/q68uzq3jTLXQ=; b=pTDUIt8y2tcB1E pt3/p2wO2kvCxeT+1cLHuh5zAFftFePhymOmex24IUE8bDGowXsM7B1rBOsIaPNB8oX/TRzFjSjf6 AVjkh00ItCsW05Ke1ij+p8uTaC0qqaD58Cu4cZZMSgxW4/hWJqv4/7GJtjQbBu0ERzxinwhCIkZU6 bqmnIvIPyFiCcTP40O2hlPGud0v+xGMqglXsBIrK3ue7vO3AWxaziKNvPyZujSgBnV0j7tYl4dnv6 Jr2iGkSyXYndWYKq6v7lhJaNbmFtWDYzIOUsvkdkDxkk+/ImThayBuzRuKlszGtX8jHZhwirhNOz4 xYoj/S3l+IOcRiurQafw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i5RYn-0003wb-8L; Wed, 04 Sep 2019 09:26:41 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i5RYj-0003vI-9N; Wed, 04 Sep 2019 09:26:38 +0000 X-UUID: c151945e2c45482ebc99748edcf82e4c-20190904 X-UUID: c151945e2c45482ebc99748edcf82e4c-20190904 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 45059580; Wed, 04 Sep 2019 01:26:31 -0800 Received: from MTKMBS02N1.mediatek.inc (172.21.101.77) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 Sep 2019 02:26:29 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 Sep 2019 17:26:28 +0800 Received: from [172.21.84.99] (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 4 Sep 2019 17:26:27 +0800 Message-ID: <1567589188.22453.24.camel@mtksdccf07> Subject: Re: [RFC PATCH V2 4/4] platform: mtk-isp: Add Mediatek FD driver From: Jerry-ch Chen To: Tomasz Figa Date: Wed, 4 Sep 2019 17:26:28 +0800 In-Reply-To: References: <1562661672-22439-1-git-send-email-Jerry-Ch.chen@mediatek.com> <1562661672-22439-5-git-send-email-Jerry-Ch.chen@mediatek.com> <20190802082815.GA203993@chromium.org> <1566724680.20680.8.camel@mtksdccf07> <1566957625.20680.33.camel@mtksdccf07> <1567424859.18318.32.camel@mtksdccf07> <1567493081.18318.49.camel@mtksdccf07> <1567511169.18318.65.camel@mtksdccf07> <1567568281.18318.80.camel@mtksdccf07> <1567577389.18318.100.camel@mtksdccf07> <1567584577.22453.11.camel@mtksdccf07> <1567587708.22453.15.camel@mtksdccf07> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190904_022637_332512_13E7E98E X-CRM114-Status: GOOD ( 19.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devicetree@vger.kernel.org" , Sean Cheng =?UTF-8?Q?=28=E9=84=AD=E6=98=87=E5=BC=98=29?= , "laurent.pinchart+renesas@ideasonboard.com" , Rynn Wu =?UTF-8?Q?=28=E5=90=B3=E8=82=B2=E6=81=A9=29?= , srv_heupstream , Po-Yang Huang =?UTF-8?Q?=28=E9=BB=83=E6=9F=8F=E9=99=BD=29?= , "mchehab@kernel.org" , "suleiman@chromium.org" , "shik@chromium.org" , Jungo Lin =?UTF-8?Q?=28=E6=9E=97=E6=98=8E=E4=BF=8A=29?= , Sj Huang =?UTF-8?Q?=28=E9=BB=83=E4=BF=A1=E7=92=8B=29?= , "yuzhao@chromium.org" , "linux-mediatek@lists.infradead.org" , "zwisler@chromium.org" , "matthias.bgg@gmail.com" , Christie Yu =?UTF-8?Q?=28=E6=B8=B8=E9=9B=85=E6=83=A0=29?= , Frederic Chen =?UTF-8?Q?=28=E9=99=B3=E4=BF=8A=E5=85=83=29?= , "hans.verkuil@cisco.com" , "linux-arm-kernel@lists.infradead.org" , "linux-media@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Tomasz, On Wed, 2019-09-04 at 17:03 +0800, Tomasz Figa wrote: > On Wed, Sep 4, 2019 at 6:02 PM Jerry-ch Chen wrote: > > > > Hi Tomasz, > > > > On Wed, 2019-09-04 at 16:25 +0800, Tomasz Figa wrote: > > > On Wed, Sep 4, 2019 at 5:09 PM Jerry-ch Chen wrote: > > > > > > > > Hi Tomasz, > > > > > > > > On Wed, 2019-09-04 at 14:34 +0800, Tomasz Figa wrote: > > > > > On Wed, Sep 4, 2019 at 3:09 PM Jerry-ch Chen wrote: > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > On Wed, 2019-09-04 at 12:15 +0800, Tomasz Figa wrote: > > > > > > > On Wed, Sep 4, 2019 at 12:38 PM Jerry-ch Chen > > > > > > > wrote: > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 20:05 +0800, Tomasz Figa wrote: > > > > > > > > > On Tue, Sep 3, 2019 at 8:46 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 15:04 +0800, Tomasz Figa wrote: > > > > > > > > > > > On Tue, Sep 3, 2019 at 3:44 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > > > > > On Tue, 2019-09-03 at 13:19 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > On Mon, Sep 2, 2019 at 8:47 PM Jerry-ch Chen wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, 2019-08-30 at 16:33 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > On Wed, Aug 28, 2019 at 11:00 AM Jerry-ch Chen > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Mon, 2019-08-26 at 14:36 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > > > Hi Jerry, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sun, Aug 25, 2019 at 6:18 PM Jerry-ch Chen > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Tomasz, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, 2019-08-02 at 16:28 +0800, Tomasz Figa wrote: > > > > > > > > > > > > > > > > > > > Hi Jerry, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Tue, Jul 09, 2019 at 04:41:12PM +0800, Jerry-ch Chen wrote: [snip] > > > > static void mtk_fd_vb2_stop_streaming(struct vb2_queue *vq) > > > > { > > > > struct mtk_fd_ctx *ctx = vb2_get_drv_priv(vq); > > > > struct mtk_fd_dev *fd = ctx->fd_dev; > > > > struct vb2_v4l2_buffer *vb; > > > > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > > > struct v4l2_m2m_queue_ctx *queue_ctx; > > > > u32 ret; > > > > > > > > if (!fd->fd_irq_done.done) > > > > > > We shouldn't access internal fields of completion. > > > > > > > ret = wait_for_completion_timeout(&fd->fd_irq_done, > > > > msecs_to_jiffies( > > > > MTK_FD_HW_TIMEOUT)); > > > > queue_ctx = V4L2_TYPE_IS_OUTPUT(vq->type) ? > > > > &m2m_ctx->out_q_ctx : > > > > &m2m_ctx->cap_q_ctx; > > > > while ((vb = v4l2_m2m_buf_remove(queue_ctx))) > > > > v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR); > > > > > > > > if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) > > > > mtk_fd_hw_disconnect(fd); > > > > } > > > > > > > > I've also tried to wait completion unconditionally for both queues and > > > > the second time will wait until timeout, as a result, it takes longer to > > > > swap the camera every time and close the camera app. > > > > > > I think it should work better if we call complete_all() instead of complete(). > > > > > Thanks, > > > > I use complete_all(), and it works fine now. > > > > static void mtk_fd_vb2_stop_streaming(struct vb2_queue *vq) > > { > > struct mtk_fd_ctx *ctx = vb2_get_drv_priv(vq); > > struct mtk_fd_dev *fd = ctx->fd_dev; > > struct vb2_v4l2_buffer *vb; > > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > struct v4l2_m2m_queue_ctx *queue_ctx; > > > > wait_for_completion_timeout(&fd->fd_irq_done, > > msecs_to_jiffies(MTK_FD_HW_TIMEOUT)); > > Shouldn't we still send some command to the hardware to stop? Like a > reset. Otherwise we don't know if it isn't still accessing the memory. > I thought no more jobs will be enqueued here when stop_streaming so we don't need it. We still could send an ipi command to reset the HW, and wait for it's callback or we could set the register MTK_FD_REG_OFFSET_HW_ENABLE to zero to disable the HW. Best regards, Jerry > > queue_ctx = V4L2_TYPE_IS_OUTPUT(vq->type) ? > > &m2m_ctx->out_q_ctx : > > &m2m_ctx->cap_q_ctx; > > while ((vb = v4l2_m2m_buf_remove(queue_ctx))) > > v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR); > > > > if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) > > mtk_fd_hw_disconnect(fd); > > } > > > > Best regards, > > Jerry > > > > > Best regards, > > > Tomasz > > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel