FBTFT: fb_agm1264k: usleep_range is preferred over udelay
Subsystems (3)
PATCH 1/1 FBTFT: fb_agm1264k: usleep_range is preferred over udelay
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);
--- drivers/staging/fbtft/fb_agm1264k-fl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fbtft/fb_agm1264k-fl.c +1 -1
@@ -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 );gpiod_set_value (par->gpio.reset,1 );mdelay (120 ); }
Signature · 1 line
2.17.1
Greg KH
maintainerQuoted 15 lines · Sreeram Veluthakkal
This patch fixes the issue:
FILE:drivers/staging/fbtft/fb_agm1264k-fl.c:88:
CHECK:usleep_rangeis preferred over udelay; seeDocumentation/timers/timers-howto.rst
+ udelay(20);Signed-off-by Sreeram Veluthakkal <[email protected]>--- drivers/staging/fbtft/fb_agm1264k-fl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/fbtft/fb_agm1264k-fl.c +0
-0
drivers/staging/fbtft/fb_agm1264k-fl.c static void reset(struct fbtft_par *par) · line 88
Quoted 5 lines
drivers/staging/fbtft/fb_agm1264k-fl.c +1
-1@@ -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
Quoted 25 lines · Greg KH
Quoted 15 lines · Sreeram Veluthakkal
This patch fixes the issue:
FILE:drivers/staging/fbtft/fb_agm1264k-fl.c:88:
CHECK:usleep_rangeis preferred over udelay; seeDocumentation/timers/timers-howto.rst
+ udelay(20);Signed-off-by Sreeram Veluthakkal <[email protected]>--- drivers/staging/fbtft/fb_agm1264k-fl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/fbtft/fb_agm1264k-fl.c +0
-0drivers/staging/fbtft/fb_agm1264k-fl.c static void reset(struct fbtft_par *par) · line 88
Quoted 5 lines
drivers/staging/fbtft/fb_agm1264k-fl.c +1
-1@@ -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?
Quoted 3 lines
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?
thanks,
Sreeram
Hi Sreeram,
Quoted 8 lines · Sreeram Veluthakkal
Quoted 7 lines · Greg KH
Quoted 6 lines · Sreeram Veluthakkal
This patch fixes the issue:
FILE:drivers/staging/fbtft/fb_agm1264k-fl.c:88:
CHECK:usleep_rangeis preferred over udelay; seeDocumentation/timers/timers-howto.rst
+ udelay(20);Signed-off-by Sreeram Veluthakkal <[email protected]>
Thanks for your patch!
Quoted 21 lines
Quoted 12 lines
drivers/staging/fbtft/fb_agm1264k-fl.c static void reset(struct fbtft_par *par) · line 88
Quoted 8 lines
drivers/staging/fbtft/fb_agm1264k-fl.c +1
-1@@ -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?
Quoted 3 lines
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_rangehttps://github.com/torvalds/linux/blob/master/kernel/time/timer.c#L1993
u64 delta = (u64)(max - min) * NSEC_PER_USEC;
Quoted 8 lines
* 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)orusleep_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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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