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=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 CC8BBC3A5A7 for ; Wed, 4 Sep 2019 13:21:33 +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 9C6D922CF7 for ; Wed, 4 Sep 2019 13:21:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Er5UxN2z"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PJ0fgm8d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C6D922CF7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mEeLzMxJ9fLqCgHRnE34nm3oZ3jqMmqiU8KqoxJKyRw=; b=Er5UxN2zAio0XW cT/mMbk6IRQL2vasERJUb7/wfss3zX8uRb3blwoJhGOmVkYdMh+CRIR9Uyhg0XqLD7OA4G7PppqZ3 xvoQmoTqJOUzvgtIDrXiEfaa8VrkNHy4Vxsk3qGv/AIgmCkkFCwlah1ju3997pDDxCbv4m0rdKBSy JneqPZSoTuS9uwb1ryA7VCW6bThHduuF/UeuA/KrAR+1uNtvB6QnjtNnLqb6b3sVZvzaPV+v8vSbF WUbOnjD0HQtw8TJ+d0BTb0q2r6M36K2mr/B43nY++bJx4wV6QXPgKG+w2BaIzOnkoCTXjy7bFJHod dPYFfbTgY2h3sprL/OyA==; 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 1i5VE0-00064g-NQ; Wed, 04 Sep 2019 13:21:28 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i5VCc-0003UA-Ay for linux-arm-kernel@lists.infradead.org; Wed, 04 Sep 2019 13:20:04 +0000 Received: by mail-ed1-x541.google.com with SMTP id v38so16520306edm.7 for ; Wed, 04 Sep 2019 06:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MOV4cHwCeXmCSAFYb8khVqjm5n/Qa64rF9TWXojizKk=; b=PJ0fgm8dX3lI+ptfzwJhpzD5dViSsoSfH04P0c8+uQF9GmGmqOfGKHBsEbf1DZdmh4 90GpHGsJHCeUhKZ+tT+3PuaIkK38Nml2mbUWGZ78/iQhiyLGYkcpP+DFxlQJbR4+u3C3 Z1UjBOmgLjevM+8mMGDEELdpLHigvnd4v0flU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MOV4cHwCeXmCSAFYb8khVqjm5n/Qa64rF9TWXojizKk=; b=VVozcdeXaAakQW4wFQLxzUAdx02B1jQ9/fu+CZ8TawIgdrJ8cxM8LgwX43Mu6E9vKd z/blPlUvdTxgB7/nLIA1x0/LvogDspdwPYp/tj9Z8GyMQjBKIk8doWbGTzSvws5stjNa 3PWmbrX9/fLvD9vemWa/ftAIh36CMng2+5+XWmDy8pG7vdiNlRf5qpWn0ApwMWsBt29L n8ZJys+9hCW6l1a44AToymxQ2prJuky9nCV/vIgAsp6yfA5IInj1S06uL01sZS83EbDa fk8Lo/BKNGlWfWBBpANC7UgVBhfgbDRxqSlhVxf/9PugeDOk0B+iPq4cFp1Q4N6htb+a mBMA== X-Gm-Message-State: APjAAAXcLFxKq4Gnd3NplPm3d7qVRw7dSdIK+SXXNpEI8xSu19RNiyDB YmgqqnnHsg7QGgSAA/6Fo0DnN6ZkKog8wA== X-Google-Smtp-Source: APXvYqwHTWPNoMglrMkKKrarbMyVICQEPnDU3upMpfRGyAAYhtIaobciCIVYMC1K1spoNCOSxUIRIw== X-Received: by 2002:a17:906:2458:: with SMTP id a24mr3583953ejb.69.1567603200359; Wed, 04 Sep 2019 06:20:00 -0700 (PDT) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com. [209.85.128.41]) by smtp.gmail.com with ESMTPSA id j5sm1550938edj.62.2019.09.04.06.20.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Sep 2019 06:20:00 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id t9so3716347wmi.5 for ; Wed, 04 Sep 2019 06:20:00 -0700 (PDT) X-Received: by 2002:a1c:c012:: with SMTP id q18mr2592884wmf.116.1567602782491; Wed, 04 Sep 2019 06:13:02 -0700 (PDT) MIME-Version: 1.0 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> <1567589188.22453.24.camel@mtksdccf07> In-Reply-To: <1567589188.22453.24.camel@mtksdccf07> From: Tomasz Figa Date: Wed, 4 Sep 2019 22:12:51 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH V2 4/4] platform: mtk-isp: Add Mediatek FD driver To: Jerry-ch Chen X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190904_062002_570613_50E707DA X-CRM114-Status: GOOD ( 21.39 ) 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" , =?UTF-8?B?U2VhbiBDaGVuZyAo6YSt5piH5byYKQ==?= , "laurent.pinchart+renesas@ideasonboard.com" , =?UTF-8?B?UnlubiBXdSAo5ZCz6IKy5oGpKQ==?= , srv_heupstream , =?UTF-8?B?UG8tWWFuZyBIdWFuZyAo6buD5p+P6Zm9KQ==?= , "mchehab@kernel.org" , "suleiman@chromium.org" , "shik@chromium.org" , =?UTF-8?B?SnVuZ28gTGluICjmnpfmmI7kv4op?= , =?UTF-8?B?U2ogSHVhbmcgKOm7g+S/oeeSiyk=?= , "yuzhao@chromium.org" , "linux-mediatek@lists.infradead.org" , "zwisler@chromium.org" , "matthias.bgg@gmail.com" , =?UTF-8?B?Q2hyaXN0aWUgWXUgKOa4uOmbheaDoCk=?= , =?UTF-8?B?RnJlZGVyaWMgQ2hlbiAo6Zmz5L+K5YWDKQ==?= , "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 On Wed, Sep 4, 2019 at 6:26 PM Jerry-ch Chen wrote: > > 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. That's true for the case when the wait completed successfully, but we also need to ensure the hardware is stopped even if a timeout happens. > 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. Since it's for handling a timeout, a reset should be more likely to bring the hardware back to a reasonable state. > > 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