linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sowjanya Komatineni <skomatineni@nvidia.com>
To: Dmitry Osipenko <digetx@gmail.com>,
	Thierry Reding <thierry.reding@gmail.com>
Cc: <jonathanh@nvidia.com>, <frankc@nvidia.com>, <hverkuil@xs4all.nl>,
	<sakari.ailus@iki.fi>, <robh+dt@kernel.org>,
	<helen.koike@collabora.com>, <gregkh@linuxfoundation.org>,
	<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Date: Thu, 6 Aug 2020 10:52:38 -0700	[thread overview]
Message-ID: <ed79b201-85ba-f725-c5fa-fcde0761bc3d@nvidia.com> (raw)
In-Reply-To: <c6ef5e77-2b0a-1712-ca58-dbd8d232e1f1@nvidia.com>


On 8/6/20 10:44 AM, Sowjanya Komatineni wrote:
>
> On 8/6/20 10:27 AM, Dmitry Osipenko wrote:
>> 06.08.2020 20:12, Sowjanya Komatineni пишет:
>>> On 8/6/20 9:41 AM, Sowjanya Komatineni wrote:
>>>> On 8/6/20 9:10 AM, Dmitry Osipenko wrote:
>>>>> 06.08.2020 18:59, Sowjanya Komatineni пишет:
>>>>> ...
>>>>>>>> Confirmed from HW designer, calibration FSM to finish takes worst
>>>>>>>> case
>>>>>>>> 72uS so by the time it gets to sensor stream it will be done its
>>>>>>>> sequence and will be waiting for DONE bit.
>>>>>>>>
>>>>>>>> So disabling MIPI CAL clock on sensor stream fails is safe.
>>>>>>> 72us is quite a lot of time, what will happen if LP-11 happens 
>>>>>>> before
>>>>>>> FSM finished calibration?
>>>>>>>
>>>>>>> Maybe the finish_calibration() needs to split into two parts:
>>>>>>>
>>>>>>>     1. wait for CAL_STATUS_ACTIVE before enabling sensor
>>>>>>>     2. wait for CAL_STATUS_DONE after enabling sensor
>>>>>> I don't think we need to split for active and done. Active will 
>>>>>> be 1 as
>>>>>> long as other pads are in calibration as well.
>>>>>>
>>>>>> We cant use active status check for specific pads under calibration.
>>>>>> This is common bit for all pads.
>>>>> Does hardware have a single FSM block shared by all pads or there 
>>>>> is FSM
>>>>> per group of pads?
>>>> MIPI CAL status register has DONE bits for individual pads status and
>>>> single ACTIVE bit.
>>>>
>>>> ACTIVE bit set to 1 indicates auto calibration is active which is the
>>>> case even when other pads (other CSI pads from other ports streaming
>>>> in case of parallel stream) are under calibration. Also DSI is shared
>>>> as well.
>>>>
>>>> We do calibration for individual pads. So, we should not rely on
>>>> ACTIVE bit.
>>>>
>>>>
>>>> MIPI driver checks for condition ACTIVE == 1 && DONE == 1 from the
>>>> beginning.
>>>>
>>>> But I think this also should be fixed as in case of parallel streams
>>>> calibration can happen in parallel waiting for ACTIVE to be cleared
>>>> makes all calibration callers to wait for longer than needed as ACTIVE
>>>> is common for all pads.
>>>>
>>>>>> Unfortunately HW don't have separate status indicating when 
>>>>>> sequence is
>>>>>> done to indicate its waiting for LP11.
>>>>>>
>>>>>>
>>>>>> To avoid all this, will remove cancel_calibration() totally and use
>>>>>> same
>>>>>> finish calibration even in case of stream failure then.
>>>>>>
>>>>> What about to add 72us delay to the end of start_calibration() in 
>>>>> order
>>>>> to ensure that FSM is finished before LP-11?
>>>> Why we should add 72uS in start_calibration() when can use same
>>>> finish_calibration() for both pass/fail cases?
>>>>
>>>> Only timing loose we see is in case of failure we still wait for 250ms
>>>> and as this is failing case I hope should be ok.
>>>>
>>> Also as we don't need cancel_calibration(), keeping tegra_mipi_wait()
>>> like earlier makes sense I believe as we are letting it finish going
>>> thru sequence.
>>>
>>> So I think below are fixes,
>>>
>>> 1. Existing MIPI driver, tegra_mipi_wait() to not use status ACTIVE bit
>>> to be 0 and use only DONE bit to be 1 for wait condition  as we are
>>> calibrating separately for individual pads and this ACTIVE bit is 
>>> common
>>> for all pads where it will not be 0 in case of other parallel streams
>>> which may also be under calibration.
>> Yes, looks like it's a mistake of the current MIPI driver that it polls
>> the ACTIVE bit.
>>
>>> 2. No need for separate cancel_calibration. So, probably earlier names
>>> tegra_mipi_calibrate() and tegra_mipi_wait() hols good as we are 
>>> waiting
>>> for calibration sequence to finish irrespective of fail/pass.
>> The new names reflect better what those functions actually do, IMO.
> ok Will keep same names.
>>
>> What about to make finish_calibration() to take an additional argument
>> which corresponds to the awaited HW bits? For example if it's CSIA, then
>> it could be:
>>
>>    tegra_mipi_finish_calibration(csi_chan->mipi, MIPI_CAL_CSIA);
> MIPI device is separate for each stream so waiting for only those 
> corresponding DONE bits happen currently and no need to pass argument.
>>
>>
>> Also, is it okay that DSI and CSI could change MIPI_CAL_CTRL after DSI
>> or CSI already started calibration?
>>
>> Looking at the current start_calibration(), I think the mutex should be
>> kept locked and then finish_calibration() should unlock it.

Right mutex_unlock should happen at end of finish_calibration.

With keeping mutex locked in start, we dont have to check for active to 
be 0 to issue start as mutex will keep it locked and other pads 
calibration can only go thru when current one is done.

So instead of below sequence, its simpler to do this way?

start_calibration()

- mutex_lock

- wait for 72uS after start

finish_calibration()

- keep check for ACTIVE = 0 and DONE = 1

- mutex_unlock()

>
> Confirmed with HW designer.
>
> ACTIVE is common bit for all pads where we see it 1 as long as all 
> pads (DSI + all CSI Pads) are under calibration.
>
> While MIPI CAL is doing calibration for certain pads, before issuing 
> other start it has to wait for ACTIVE to be 0.
>
>
> Earlier driver (before split) checks for ACTIVE to be 0 along with 
> DONE bit to be 1 as it does both calibrate and wait in same API.
>
> With the split, looks like we need below sequence to be safe.
>
> 1. tegra_mipi_start_calibration(): wait for ACTIVE to be 0 before 
> issuing START and after issuing start wait for 72uS to let calibration 
> code sequence finish so it will be ready to see LP-11 after that.
>
> In case of parallel streams, call to start_calibration can happen when 
> pads of other stream are under calibration.
>
> 2. tegra_mipi_finish_calibration(): check for DONE bit to be 1
>
>
>

  reply	other threads:[~2020-08-06 17:52 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 15:42 [PATCH v8 00/10] Support for Tegra video capture from external sensor Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 01/10] media: tegra-video: Fix channel format alignment Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 02/10] media: tegra-video: Enable TPG based on kernel config Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 03/10] media: tegra-video: Update format lookup to offset based Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 04/10] dt-bindings: tegra: Update VI and CSI bindings with port info Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 05/10] media: tegra-video: Separate CSI stream enable and disable implementations Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 06/10] media: tegra-video: Add support for external sensor capture Sowjanya Komatineni
2020-08-04  5:57   ` Dmitry Osipenko
2020-08-03 15:42 ` [PATCH v8 07/10] media: tegra-video: Add support for selection ioctl ops Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done Sowjanya Komatineni
2020-08-05 13:46   ` Thierry Reding
2020-08-05 14:05     ` Dmitry Osipenko
2020-08-05 14:19       ` Dmitry Osipenko
2020-08-05 16:33         ` Sowjanya Komatineni
2020-08-05 16:47           ` Dmitry Osipenko
2020-08-05 16:50             ` Sowjanya Komatineni
2020-08-05 16:57               ` Dmitry Osipenko
2020-08-05 17:04                 ` Sowjanya Komatineni
2020-08-05 17:23                   ` Dmitry Osipenko
2020-08-05 17:32                     ` Sowjanya Komatineni
2020-08-05 17:29                   ` Sowjanya Komatineni
2020-08-05 17:34                     ` Dmitry Osipenko
2020-08-05 17:46                       ` Sowjanya Komatineni
2020-08-05 18:06                         ` Sowjanya Komatineni
2020-08-06  0:47                           ` Sowjanya Komatineni
2020-08-06 13:32                             ` Dmitry Osipenko
2020-08-06 15:59                               ` Sowjanya Komatineni
2020-08-06 16:10                                 ` Dmitry Osipenko
2020-08-06 16:41                                   ` Sowjanya Komatineni
2020-08-06 16:45                                     ` Dmitry Osipenko
2020-08-06 16:51                                       ` Sowjanya Komatineni
2020-08-06 17:15                                         ` Dmitry Osipenko
2020-08-06 17:12                                     ` Sowjanya Komatineni
2020-08-06 17:27                                       ` Dmitry Osipenko
2020-08-06 17:44                                         ` Sowjanya Komatineni
2020-08-06 17:52                                           ` Sowjanya Komatineni [this message]
2020-08-06 18:01                                             ` Dmitry Osipenko
2020-08-06 18:07                                               ` Sowjanya Komatineni
2020-08-06 18:18                                                 ` Dmitry Osipenko
2020-08-06 18:44                                                   ` Sowjanya Komatineni
2020-08-06 18:51                                                     ` Sowjanya Komatineni
2020-08-06 16:13                                 ` Dmitry Osipenko
2020-08-06 16:37                                   ` Dmitry Osipenko
2020-08-06 16:42                                     ` Sowjanya Komatineni
2020-08-06 16:43                                       ` Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 09/10] media: tegra-video: Add CSI MIPI pads calibration Sowjanya Komatineni
2020-08-03 15:42 ` [PATCH v8 10/10] media: tegra-video: Compute settle times based on the clock rate Sowjanya Komatineni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ed79b201-85ba-f725-c5fa-fcde0761bc3d@nvidia.com \
    --to=skomatineni@nvidia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=digetx@gmail.com \
    --cc=frankc@nvidia.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).