From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sowjanya Komatineni Subject: Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver Date: Thu, 30 Apr 2020 13:21:15 -0700 Message-ID: References: <1588197606-32124-1-git-send-email-skomatineni@nvidia.com> <1588197606-32124-7-git-send-email-skomatineni@nvidia.com> <52b98347-4b78-f637-04f4-cc730ad336f3@nvidia.com> <8da0929d-4a58-75b8-381c-511ce66f8d9d@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <8da0929d-4a58-75b8-381c-511ce66f8d9d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Content-Language: en-US Sender: linux-tegra-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Dmitry Osipenko , thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org, frankc-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org, hverkuil-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org, sakari.ailus-X3B1VOXEql0@public.gmane.org, helen.koike-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org Cc: sboyd-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-tegra@vger.kernel.org On 4/30/20 1:21 PM, Dmitry Osipenko wrote: > 30.04.2020 23:09, Sowjanya Komatineni =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> On 4/30/20 1:08 PM, Sowjanya Komatineni wrote: >>> On 4/30/20 1:06 PM, Dmitry Osipenko wrote: >>>> 30.04.2020 01:00, Sowjanya Komatineni =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >>>>> +static int chan_capture_kthread_start(void *data) >>>>> +{ >>>>> +=C2=A0=C2=A0=C2=A0 struct tegra_vi_channel *chan =3D data; >>>>> +=C2=A0=C2=A0=C2=A0 struct tegra_channel_buffer *buf; >>>>> +=C2=A0=C2=A0=C2=A0 int err =3D 0; >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0 set_freezable(); >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0 while (1) { >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 try_to_freeze(); >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Source is not str= eaming if error is non-zero. >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * So, do not dequeu= e buffers on error and let the thread >>>>> sleep >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * till kthread stop= signal is received. >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wait_event_interruptible(= chan->start_wait, >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kthread_should_stop(= ) || >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (!list_empty(&chan->= capture) && >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !err)); >>>> ... >>>>> +static void tegra_channel_buffer_queue(struct vb2_buffer *vb) >>>>> +{ >>>>> +=C2=A0=C2=A0=C2=A0 struct tegra_vi_channel *chan =3D vb2_get_drv_pri= v(vb->vb2_queue); >>>>> +=C2=A0=C2=A0=C2=A0 struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buff= er(vb); >>>>> +=C2=A0=C2=A0=C2=A0 struct tegra_channel_buffer *buf =3D to_tegra_cha= nnel_buffer(vbuf); >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0 /* put buffer into the capture queue */ >>>>> +=C2=A0=C2=A0=C2=A0 spin_lock(&chan->start_lock); >>>>> +=C2=A0=C2=A0=C2=A0 list_add_tail(&buf->queue, &chan->capture); >>>>> +=C2=A0=C2=A0=C2=A0 spin_unlock(&chan->start_lock); >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0 /* wait up kthread for capture */ >>>>> +=C2=A0=C2=A0=C2=A0 wake_up_interruptible(&chan->start_wait); >>>>> +} >>>> The V4L doc says that buffers could be enqueued before streaming is >>>> started. I guess it should be a trouble here, shouldn't it? >>>> >>>> https://elixir.bootlin.com/linux/v5.7-rc3/source/include/media/videobu= f2-core.h#L379 >>>> >>> what trouble are you referring here? >>> >>> I dont think so as we set min buffers needed as 2 always there will be >>> 2 per-queued buffers. >> typo* pre-queued buffers before streaming start >>> But buffers from this queue will be dequeued only when ready to >>> processes in the capture thread > I see now that the threads won't be running until start_streaming() is > invoked, should be okay then. ok. yes threads run only during streaming 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.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 A468BC4724C for ; Thu, 30 Apr 2020 20:22:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BBEA2076D for ; Thu, 30 Apr 2020 20:22:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="e0NoxIpS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbgD3UWp (ORCPT ); Thu, 30 Apr 2020 16:22:45 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:11591 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726745AbgD3UWp (ORCPT ); Thu, 30 Apr 2020 16:22:45 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 30 Apr 2020 13:21:37 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 30 Apr 2020 13:22:44 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 30 Apr 2020 13:22:44 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 30 Apr 2020 20:22:44 +0000 Received: from [10.2.165.152] (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 30 Apr 2020 20:22:43 +0000 Subject: Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver To: Dmitry Osipenko , , , , , , CC: , , , , , References: <1588197606-32124-1-git-send-email-skomatineni@nvidia.com> <1588197606-32124-7-git-send-email-skomatineni@nvidia.com> <52b98347-4b78-f637-04f4-cc730ad336f3@nvidia.com> <8da0929d-4a58-75b8-381c-511ce66f8d9d@gmail.com> From: Sowjanya Komatineni Message-ID: Date: Thu, 30 Apr 2020 13:21:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <8da0929d-4a58-75b8-381c-511ce66f8d9d@gmail.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1588278097; bh=4+/UTSmWZA6aF77P2/8J93AOfTND6l5qFFYe2ctxF4Q=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Transfer-Encoding: Content-Language; b=e0NoxIpSz0QgI/vCC25BgCu4y5yZLE6jyMFQpqWNDabNeROYXEINBIS38hisW58mt 7xFe9s8UqXtWJkj59geL66IxPUXF9AJ3dUuB8N5DMQ1bd1v/VR5ZSpgcO5pP1k1E8G q5dCCNhjEu3KwWtDp9EFBj5WRUXxhBeM3JhE+nWwOtpo0jXgb0pvehrDOrzziotrqc L2dZIzDKVpN4Jv7l2g+c7+CGKb9MSuZeIRWtCunz8ov6PzcRDsk8gqpjBycIrGbh0R iAkv9qC/0ZK2KuR4zDdXQiA9qoDR6i7NjV2rVZqrl89YIqMIarvcraMMoUhu74r5ZS 773zBlkpLz82w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/30/20 1:21 PM, Dmitry Osipenko wrote: > 30.04.2020 23:09, Sowjanya Komatineni =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> On 4/30/20 1:08 PM, Sowjanya Komatineni wrote: >>> On 4/30/20 1:06 PM, Dmitry Osipenko wrote: >>>> 30.04.2020 01:00, Sowjanya Komatineni =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >>>>> +static int chan_capture_kthread_start(void *data) >>>>> +{ >>>>> +=C2=A0=C2=A0=C2=A0 struct tegra_vi_channel *chan =3D data; >>>>> +=C2=A0=C2=A0=C2=A0 struct tegra_channel_buffer *buf; >>>>> +=C2=A0=C2=A0=C2=A0 int err =3D 0; >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0 set_freezable(); >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0 while (1) { >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 try_to_freeze(); >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Source is not str= eaming if error is non-zero. >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * So, do not dequeu= e buffers on error and let the thread >>>>> sleep >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * till kthread stop= signal is received. >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wait_event_interruptible(= chan->start_wait, >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kthread_should_stop(= ) || >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (!list_empty(&chan->= capture) && >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !err)); >>>> ... >>>>> +static void tegra_channel_buffer_queue(struct vb2_buffer *vb) >>>>> +{ >>>>> +=C2=A0=C2=A0=C2=A0 struct tegra_vi_channel *chan =3D vb2_get_drv_pri= v(vb->vb2_queue); >>>>> +=C2=A0=C2=A0=C2=A0 struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buff= er(vb); >>>>> +=C2=A0=C2=A0=C2=A0 struct tegra_channel_buffer *buf =3D to_tegra_cha= nnel_buffer(vbuf); >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0 /* put buffer into the capture queue */ >>>>> +=C2=A0=C2=A0=C2=A0 spin_lock(&chan->start_lock); >>>>> +=C2=A0=C2=A0=C2=A0 list_add_tail(&buf->queue, &chan->capture); >>>>> +=C2=A0=C2=A0=C2=A0 spin_unlock(&chan->start_lock); >>>>> + >>>>> +=C2=A0=C2=A0=C2=A0 /* wait up kthread for capture */ >>>>> +=C2=A0=C2=A0=C2=A0 wake_up_interruptible(&chan->start_wait); >>>>> +} >>>> The V4L doc says that buffers could be enqueued before streaming is >>>> started. I guess it should be a trouble here, shouldn't it? >>>> >>>> https://elixir.bootlin.com/linux/v5.7-rc3/source/include/media/videobu= f2-core.h#L379 >>>> >>> what trouble are you referring here? >>> >>> I dont think so as we set min buffers needed as 2 always there will be >>> 2 per-queued buffers. >> typo* pre-queued buffers before streaming start >>> But buffers from this queue will be dequeued only when ready to >>> processes in the capture thread > I see now that the threads won't be running until start_streaming() is > invoked, should be okay then. ok. yes threads run only during streaming