Re: [RFC PATCH v6 6/9] media: tegra: Add Tegra210 Video input driver

From: Dmitry Osipenko
Date: Mon Apr 06 2020 - 16:56:35 EST


06.04.2020 23:55, Sowjanya Komatineni ÐÐÑÐÑ:
>
> On 4/6/20 1:53 PM, Dmitry Osipenko wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> 06.04.2020 23:50, Sowjanya Komatineni ÐÐÑÐÑ:
>>> On 4/6/20 1:45 PM, Dmitry Osipenko wrote:
>>>> External email: Use caution opening links or attachments
>>>>
>>>>
>>>> 04.04.2020 04:25, Sowjanya Komatineni ÐÐÑÐÑ:
>>>>> +static int chan_capture_kthread_start(void *data)
>>>>> +{
>>>>> +ÂÂÂÂ struct tegra_vi_channel *chan = data;
>>>>> +ÂÂÂÂ struct tegra_channel_buffer *buf;
>>>>> +ÂÂÂÂ int err = 0;
>>>>> +ÂÂÂÂ int caps_inflight;
>>>>> +
>>>>> +ÂÂÂÂ set_freezable();
>>>>> +
>>>>> +ÂÂÂÂ while (1) {
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂ try_to_freeze();
>>>>> +
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂ wait_event_interruptible(chan->start_wait,
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ !list_empty(&chan->capture) ||
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ kthread_should_stop());
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂ /*
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂ * Frame start and MW_ACK_DONE syncpoint condition
>>>>> FIFOs are
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂ * of max depth 2. So make sure max 2 capture
>>>>> requests are
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂ * in process by the hardware at a time.
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂ */
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂ while (!(kthread_should_stop() ||
>>>>> list_empty(&chan->capture))) {
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ caps_inflight = chan->capture_reqs -
>>>>> chan->sequence;
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /*
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ * Source is not streaming if error is non-zero.
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ * So, do not dequeue buffers on capture error
>>>>> or when
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ * syncpoint requests in FIFO are full.
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ */
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (err || caps_inflight >= SYNCPT_FIFO_DEPTH)
>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ break;
>>>> Am I understanding correctly that this thread will take 100% CPU,
>>>> spinning here, if more than 2 frame-captures queued?
>>> on more than 2 frames captures, it breaks thread and on next wakeup it
>>> continues
>> The wait_event() won't wait if condition is true.
> condition is checked when waitqueue is woken up

https://elixir.bootlin.com/linux/v5.6.2/source/include/linux/wait.h#L462