driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Sreeram Veluthakkal <srrmvlt@gmail.com>
Cc: driverdevel <devel@driverdev.osuosl.org>,
	Linux Fbdev development list <linux-fbdev@vger.kernel.org>,
	nishadkamdar@gmail.com, Greg KH <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	payal.s.kshirsagar.98@gmail.com
Subject: Re: [PATCH] FBTFT: fb_agm1264k: usleep_range is preferred over udelay
Date: Tue, 10 Sep 2019 09:59:50 +0200	[thread overview]
Message-ID: <CAMuHMdXz568p=GFJmz6MfuxDxA_QkLMrGcK2hG3C99ReL1fH5A@mail.gmail.com> (raw)
In-Reply-To: <20190909115006.GB3437@sreeram-MS-7B98>

Hi Sreeram,

On Tue, Sep 10, 2019 at 2:25 AM Sreeram Veluthakkal <srrmvlt@gmail.com> wrote:
> On Mon, Sep 09, 2019 at 10:56:25AM +0100, Greg KH wrote:
> > On Sun, Sep 08, 2019 at 08:26:05PM -0500, Sreeram Veluthakkal wrote:
> > > This patch fixes the issue:
> > > FILE: drivers/staging/fbtft/fb_agm1264k-fl.c:88:
> > > CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.rst
> > > +       udelay(20);
> > >
> > > Signed-off-by: Sreeram Veluthakkal <srrmvlt@gmail.com>

Thanks for your patch!

> > > --- a/drivers/staging/fbtft/fb_agm1264k-fl.c
> > > +++ b/drivers/staging/fbtft/fb_agm1264k-fl.c
> > > @@ -85,7 +85,7 @@ static void reset(struct fbtft_par *par)
> > >     dev_dbg(par->info->device, "%s()\n", __func__);
> > >
> > >     gpiod_set_value(par->gpio.reset, 0);
> > > -   udelay(20);
> > > +   usleep_range(20, 40);
> >
> > Is it "safe" to wait 40?  This kind of change you can only do if you
> > know this is correct.  Have you tested this with hardware?
> >
> > thanks,
> >
> > greg k-h
>
> Hi Greg, No I haven't tested it, I don't have the hw. I dug depeer in to the usleep_range
>
> https://github.com/torvalds/linux/blob/master/kernel/time/timer.c#L1993
>         u64 delta = (u64)(max - min) * NSEC_PER_USEC;
>
>  * The @delta argument gives the kernel the freedom to schedule the
>  * actual wakeup to a time that is both power and performance friendly.
>  * The kernel give the normal best effort behavior for "@expires+@delta",
>  * but may decide to fire the timer earlier, but no earlier than @expires.
>
> My understanding is that keeping delta 0 (min=max=20) would be equivalent.
> I can revise the patch to usleep_range(20, 20) or usleep_range(20, 21) for a 1 usec delta.
> What do you suggest?

Please read the comment above the line you're referring to:

 * In non-atomic context where the exact wakeup time is flexible, use
 * usleep_range() instead of udelay().  The sleep improves responsiveness
 * by avoiding the CPU-hogging busy-wait of udelay(), and the range reduces
 * power usage by allowing hrtimers to take advantage of an already-
 * scheduled interrupt instead of scheduling a new one just for this sleep.

Is this function always called in non-atomic context?
If it  may be called in atomic context, replacing the udelay() call by a
usleep*() call will break the driver.

See also "the first and most important question" in
Documentation/timers/timers-howto.rst, as referred to by the checkpatch.pl
message.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

      reply	other threads:[~2019-09-10  8:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09  1:26 [PATCH] FBTFT: fb_agm1264k: usleep_range is preferred over udelay Sreeram Veluthakkal
2019-09-09  9:56 ` Greg KH
2019-09-09 11:50   ` Sreeram Veluthakkal
2019-09-10  7:59     ` Geert Uytterhoeven [this message]

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='CAMuHMdXz568p=GFJmz6MfuxDxA_QkLMrGcK2hG3C99ReL1fH5A@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nishadkamdar@gmail.com \
    --cc=payal.s.kshirsagar.98@gmail.com \
    --cc=srrmvlt@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).