Linux Media Controller development
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: <linux-media@vger.kernel.org>, Benoit Parrot <bparrot@ti.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Subject: Re: [PATCH 14/16] media: ti-vpe: cal: improve wait for CIO resetdone
Date: Tue, 17 Mar 2020 13:34:58 +0200	[thread overview]
Message-ID: <0c3296cb-e0f8-e97e-74fa-be766aa08b77@ti.com> (raw)
In-Reply-To: <20200316124319.GG4732@pendragon.ideasonboard.com>

On 16/03/2020 14:43, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Fri, Mar 13, 2020 at 01:41:19PM +0200, Tomi Valkeinen wrote:
>> Sometimes waiting for ComplexIO resetdone timeouts. Testing shows that
>> sometimes we need to wait more than what the current code does. It is
>> not clear how long this wait can be, but it is based on how quickly the
>> sensor provides a valid clock, and how quickly CAL syncs to it.
>>
>> Change the code to make it more obvious how long we'll wait, and set a
>> wider range for usleep_range. Increase the timeout to 750ms.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> ---
>>   drivers/media/platform/ti-vpe/cal.c | 13 +++++++------
>>   1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
>> index 319312770eea..929f9b3ca4f9 100644
>> --- a/drivers/media/platform/ti-vpe/cal.c
>> +++ b/drivers/media/platform/ti-vpe/cal.c
>> @@ -824,20 +824,21 @@ static void csi2_phy_init(struct cal_ctx *ctx)
>>   
>>   static void csi2_wait_complexio_reset(struct cal_ctx *ctx)
>>   {
>> -	int i;
>> +	unsigned long timeout;
>>   
>> -	for (i = 0; i < 250; i++) {
>> +	timeout = jiffies + msecs_to_jiffies(750);
>> +	while (time_before(jiffies, timeout)) {
>>   		if (reg_read_field(ctx->dev,
>>   				   CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port),
>>   				   CAL_CSI2_COMPLEXIO_CFG_RESET_DONE_MASK) ==
>>   		    CAL_CSI2_COMPLEXIO_CFG_RESET_DONE_RESETCOMPLETED)
>>   			break;
>> -		usleep_range(1000, 1100);
>> +		usleep_range(500, 5000);
>>   	}
> 
> How about using readx_poll_timeout() ?

There's no function that directly fits readx_poll_timeout's accessor function, so I think using 
readl_poll_timeout and calculating the address manually would be the way to use *_poll_timeout.

But it does skip the register access functions the driver uses (reg_read/write).

So... It would be nice to use *_poll_timeout, but I'm not sure if it worth breaking the register 
access model the driver uses.

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  reply	other threads:[~2020-03-17 11:35 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13 11:41 [PATCH 01/16] media: ti-vpe: cal: fix use of wrong macro Tomi Valkeinen
2020-03-13 11:41 ` [PATCH 02/16] media: ti-vpe: cal: use runtime_resume for errata handling Tomi Valkeinen
2020-03-16 12:28   ` Laurent Pinchart
2020-03-17  8:54     ` Tomi Valkeinen
2020-03-13 11:41 ` [PATCH 03/16] media: ti-vpe: cal: catch error irqs and print errors Tomi Valkeinen
2020-03-16 10:06   ` Hans Verkuil
2020-03-16 10:51     ` Hans Verkuil
2020-03-16 12:00       ` Tomi Valkeinen
2020-03-16 12:16         ` Hans Verkuil
2020-03-16 12:22   ` Laurent Pinchart
2020-03-17  8:56     ` Tomi Valkeinen
2020-03-13 11:41 ` [PATCH 04/16] media: ti-vpe: cal: print errors on timeouts Tomi Valkeinen
2020-03-13 11:41 ` [PATCH 05/16] media: ti-vpe: cal: simplify irq handling Tomi Valkeinen
2020-03-13 11:41 ` [PATCH 06/16] media: ti-vpe: cal: remove useless CAL_GEN_* macros Tomi Valkeinen
2020-03-16 12:24   ` Laurent Pinchart
2020-03-13 11:41 ` [PATCH 07/16] media: ti-vpe: cal: remove unused defines Tomi Valkeinen
2020-03-16 12:31   ` Laurent Pinchart
2020-03-13 11:41 ` [PATCH 08/16] media: ti-vpe: cal: use reg_write_field Tomi Valkeinen
2020-03-16 12:32   ` Laurent Pinchart
2020-03-13 11:41 ` [PATCH 09/16] media: ti-vpe: cal: cleanup CIO power enable/disable Tomi Valkeinen
2020-03-16 12:35   ` Laurent Pinchart
2020-03-13 11:41 ` [PATCH 10/16] media: ti-vpe: cal: fix dummy read to phy Tomi Valkeinen
2020-03-16 12:36   ` Laurent Pinchart
2020-03-13 11:41 ` [PATCH 11/16] media: ti-vpe: cal: program number of lines properly Tomi Valkeinen
2020-03-16 12:37   ` Laurent Pinchart
2020-03-16 13:13     ` Tomi Valkeinen
2020-03-13 11:41 ` [PATCH 12/16] media: ti-vpe: cal: set DMA max seg size Tomi Valkeinen
2020-03-16 12:39   ` Laurent Pinchart
2020-03-13 11:41 ` [PATCH 13/16] media: ti-vpe: cal: move code to separate functions Tomi Valkeinen
2020-03-16 12:41   ` Laurent Pinchart
2020-03-17  9:04     ` Tomi Valkeinen
2020-03-13 11:41 ` [PATCH 14/16] media: ti-vpe: cal: improve wait for CIO resetdone Tomi Valkeinen
2020-03-16 10:05   ` Hans Verkuil
2020-03-16 10:11     ` Tomi Valkeinen
2020-03-16 12:43   ` Laurent Pinchart
2020-03-17 11:34     ` Tomi Valkeinen [this message]
2020-03-13 11:41 ` [PATCH 15/16] media: ti-vpe: cal: improve wait for stop-state Tomi Valkeinen
2020-03-16 12:45   ` Laurent Pinchart
2020-03-17 11:44     ` Tomi Valkeinen
2020-03-13 11:41 ` [PATCH 16/16] media: ti-vpe: cal: fix stop state timeout Tomi Valkeinen
2020-03-16 12:49   ` Laurent Pinchart
2020-03-16 12:28 ` [PATCH 01/16] media: ti-vpe: cal: fix use of wrong macro Laurent Pinchart

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=0c3296cb-e0f8-e97e-74fa-be766aa08b77@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=bparrot@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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