All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Nicholas Mc Guire <der.herr@hofr.at>
Cc: David Airlie <airlied@linux.ie>,
	intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	Nicholas Mc Guire <hofrat@osadl.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH] drm/i915: use udelay for very small delays
Date: Thu, 15 Dec 2016 11:33:11 +0200	[thread overview]
Message-ID: <87r359pmeg.fsf@intel.com> (raw)
In-Reply-To: <20161215085651.GA25256@osadl.at>

On Thu, 15 Dec 2016, Nicholas Mc Guire <der.herr@hofr.at> wrote:
> On Thu, Dec 15, 2016 at 10:47:57AM +0200, Jani Nikula wrote:
>> On Thu, 15 Dec 2016, Nicholas Mc Guire <hofrat@osadl.org> wrote:
>> > usleep_range() is intended for delays in the 10us to 10ms range that need
>> > good precision. a useleep_range(1, will effectively be no more than an
>> > imprecise udelay with some added cache disruption as it will fire more or
>> > less immediately - use udelay() here.
>> >
>> > Fixes: commit be4fc046bed3 ("drm/i915: add VLV DSI PLL Calculations")
>> > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
>> > ---
>> >
>> > Problem located by coccinelle
>> >
>> > The requirement of waiting at least 0.5 us is assured with the udelay(1)
>> > here which should be more effective than a usleep_range() - would 
>> > ndelay(500) make sense here ?
>> 
>> This is in the modeset path, i.e. pretty slow anyway. In this case, the
>> point is not to try hard to minimize the wait, the point is to guarantee
>> "at least 0.5 us" has passed. If the CPU can do something else,
>> including dozing off, in the mean time, great. I think we should stick
>> with usleep_range().
>
> well in that case maybe an acceptable solution would be to set it to 
> some suitable range 10,20 us ? or if not critical preferably even with a large
> upper limit.

I'd be fine with 10, 50 here. Please do send the patch, Cc: me.

>> 
>> I think the question is, how do we express this in code? IMO udelay() is
>> not the answer.
>
> if the delay need to be kept short then no - then its not the answer
> but usleep_ranges(1,2) I think is effectively just an inefficient version
> of udelay(1), by the time the timer is setup and the task gives
> up the cpu the timer would fire.
>
>> 
>> And why doesn't usleep_range() kernel-doc mention anything about the
>> ranges?
>> 
>
> interesting - that might be part of the reason there are many findings
> Documentation/timers/timers-howto.txt does
>
>         SLEEPING FOR ~USECS OR SMALL MSECS ( 10us - 20ms):
>                 * Use usleep_range

I'd appreciate short additions to the kernel-doc documentation of each
function to document the approximate range it's appropriate for. People
will know where to look if their use doesn't fall in that range.

Thanks,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Nicholas Mc Guire <der.herr@hofr.at>
Cc: Nicholas Mc Guire <hofrat@osadl.org>,
	Daniel Vetter <daniel.vetter@intel.com>,
	ymohanma <yogesh.mohan.marimuthu@intel.com>,
	David Airlie <airlied@linux.ie>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/i915: use udelay for very small delays
Date: Thu, 15 Dec 2016 11:33:11 +0200	[thread overview]
Message-ID: <87r359pmeg.fsf@intel.com> (raw)
In-Reply-To: <20161215085651.GA25256@osadl.at>

On Thu, 15 Dec 2016, Nicholas Mc Guire <der.herr@hofr.at> wrote:
> On Thu, Dec 15, 2016 at 10:47:57AM +0200, Jani Nikula wrote:
>> On Thu, 15 Dec 2016, Nicholas Mc Guire <hofrat@osadl.org> wrote:
>> > usleep_range() is intended for delays in the 10us to 10ms range that need
>> > good precision. a useleep_range(1, will effectively be no more than an
>> > imprecise udelay with some added cache disruption as it will fire more or
>> > less immediately - use udelay() here.
>> >
>> > Fixes: commit be4fc046bed3 ("drm/i915: add VLV DSI PLL Calculations")
>> > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
>> > ---
>> >
>> > Problem located by coccinelle
>> >
>> > The requirement of waiting at least 0.5 us is assured with the udelay(1)
>> > here which should be more effective than a usleep_range() - would 
>> > ndelay(500) make sense here ?
>> 
>> This is in the modeset path, i.e. pretty slow anyway. In this case, the
>> point is not to try hard to minimize the wait, the point is to guarantee
>> "at least 0.5 us" has passed. If the CPU can do something else,
>> including dozing off, in the mean time, great. I think we should stick
>> with usleep_range().
>
> well in that case maybe an acceptable solution would be to set it to 
> some suitable range 10,20 us ? or if not critical preferably even with a large
> upper limit.

I'd be fine with 10, 50 here. Please do send the patch, Cc: me.

>> 
>> I think the question is, how do we express this in code? IMO udelay() is
>> not the answer.
>
> if the delay need to be kept short then no - then its not the answer
> but usleep_ranges(1,2) I think is effectively just an inefficient version
> of udelay(1), by the time the timer is setup and the task gives
> up the cpu the timer would fire.
>
>> 
>> And why doesn't usleep_range() kernel-doc mention anything about the
>> ranges?
>> 
>
> interesting - that might be part of the reason there are many findings
> Documentation/timers/timers-howto.txt does
>
>         SLEEPING FOR ~USECS OR SMALL MSECS ( 10us - 20ms):
>                 * Use usleep_range

I'd appreciate short additions to the kernel-doc documentation of each
function to document the approximate range it's appropriate for. People
will know where to look if their use doesn't fall in that range.

Thanks,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center

  reply	other threads:[~2016-12-15  9:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-15  4:03 [PATCH] drm/i915: use udelay for very small delays Nicholas Mc Guire
2016-12-15  8:47 ` Jani Nikula
2016-12-15  8:47   ` Jani Nikula
2016-12-15  8:56   ` Nicholas Mc Guire
2016-12-15  9:33     ` Jani Nikula [this message]
2016-12-15  9:33       ` Jani Nikula
2016-12-15  8:57   ` Jani Nikula
2016-12-15  8:57     ` Jani Nikula
2016-12-15 17:15 ` ✓ Fi.CI.BAT: success for " Patchwork

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=87r359pmeg.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=der.herr@hofr.at \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hofrat@osadl.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.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 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.