All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, Daniel Scally <djrscally@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>
Subject: Re: [PATCH 2/2] media: i2c: ov7251: Introduce 1 ms delay between regulators and en GPIO
Date: Thu, 23 Jan 2025 15:25:31 +0200	[thread overview]
Message-ID: <Z5JDS2EGT1cWCBGW@smile.fi.intel.com> (raw)
In-Reply-To: <Z5Hw3CUBnSgfNJMS@kekkonen.localdomain>

On Thu, Jan 23, 2025 at 07:33:48AM +0000, Sakari Ailus wrote:
> On Wed, Jan 22, 2025 at 06:36:52PM +0200, Andy Shevchenko wrote:
> > On Wed, Jan 22, 2025 at 11:54:11AM +0000, Sakari Ailus wrote:
> > > On Mon, Jan 20, 2025 at 07:23:07PM +0200, Andy Shevchenko wrote:
> > > > On Mon, Jan 20, 2025 at 12:11:23PM +0200, Sakari Ailus wrote:
> > > > > Lift the xshutdown (enable) GPIO 1 ms after enabling the regulators, as
> > > > > required by the sensor's power-up sequence.

...

> > > > > +	usleep_range(1000, 1100);
> > > > 
> > > > Why not fsleep() ?
> > > 
> > > Could be, but fsleep() uses a range that is as large as the delay is.
> > 
> > fsleep() is recommended way as it knows much better the implementation details
> > of the delay APIs and which one to choose based on input. As recently stated by
> > the fix series to delay APIs the fsleep() will give up to 25% on top of the
> > asked delay, meaning in this case somewhat 250us. Taking it into account the
> > resulting values I do not think usleep_range() should be here. I.o.w. I do not
> > see enough justification for _not_ using fsleep().
> > 
> > Also note that fsleep() ranges try to keep balance between oversleep and power
> > consumption. Your delay is rather tough as sometimes 100us is almost the time
> > needed to go to the deep sleep for the CPU package and return from it.
> 
> Have you looked at what fsleep() does?

Definitely, and also read the (updated) documentation. So, let me repeat:
I do not see any justification for usleep_range() here and how 150us overhead
(on top of what you proposed) makes any difference.

> I agree most of the time it's the best choice when you need to sleep (at
> least) some time, but generally sensor power-up time is critical.

Why? I don't see this in the commit message. Please also answer the question
"what is the bad thing happen if we delay slightly more?" and the question of
how this will cope with the case when HRTIMER is off in the kernel.

> I'm fine using 1000 for both, too.

In accordance with the documentation one has to consider

fsleep(1000)
msleep(1)
usleep_range(1000, 1100)

(in this order), so I prefer that we use fsleep() if there is no good
justification for the other one(s).

Also just noticed that in the commit message you even used "ms" units and not
"us", which pretty much suggests that tough range for usleep_range() is not
justified.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-01-23 13:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20 10:11 [PATCH 1/2] media: i2c: ov7251: Set enable GPIO low in probe Sakari Ailus
2025-01-20 10:11 ` [PATCH 2/2] media: i2c: ov7251: Introduce 1 ms delay between regulators and en GPIO Sakari Ailus
2025-01-20 10:39   ` Dave Stevenson
2025-01-20 17:23   ` Andy Shevchenko
2025-01-22 11:54     ` Sakari Ailus
2025-01-22 16:36       ` Andy Shevchenko
2025-01-23  7:33         ` Sakari Ailus
2025-01-23 13:25           ` Andy Shevchenko [this message]
2025-01-20 10:37 ` [PATCH 1/2] media: i2c: ov7251: Set enable GPIO low in probe Dave Stevenson
2025-01-20 17:24 ` Andy Shevchenko

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=Z5JDS2EGT1cWCBGW@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=djrscally@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.