* [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
@ 2026-07-16 11:08 ` Selby Mashiki
0 siblings, 0 replies; 10+ messages in thread
From: Selby Mashiki via B4 Relay @ 2026-07-16 11:08 UTC (permalink / raw)
To: Andy Shevchenko, Greg Kroah-Hartman
Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel,
Selby Mashiki
From: Selby Mashiki <mashikiselby@gmail.com>
udelay() busy-waits for the specified duration, consuming CPU cycles
unnecessarily. usleep_range() is preferred for delays that can sleep,
as it allows the scheduler to run other tasks during the wait.
Replace two instances of udelay(100) with usleep_range(100, 200) to
use the preferred sleeping delay function.
Signed-off-by: Selby Mashiki <mashikiselby@gmail.com>
---
drivers/staging/fbtft/fb_ra8875.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fbtft/fb_ra8875.c b/drivers/staging/fbtft/fb_ra8875.c
index 0ab1de664..d2400bb44 100644
--- a/drivers/staging/fbtft/fb_ra8875.c
+++ b/drivers/staging/fbtft/fb_ra8875.c
@@ -210,7 +210,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
}
len--;
- udelay(100);
+ usleep_range(100, 200);
if (len) {
buf = (u8 *)par->buf;
@@ -231,7 +231,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
/* restore user spi-speed */
par->fbtftops.write = fbtft_write_spi;
- udelay(100);
+ usleep_range(100, 200);
}
static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
---
base-commit: 64276d9bfe4d1fdd5cf2636f1065f7ea55c2defb
change-id: 20260716-staging-testing-b1b81d63d0d1
Best regards,
--
Selby Mashiki <mashikiselby@gmail.com>
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
@ 2026-07-16 11:08 ` Selby Mashiki
0 siblings, 0 replies; 10+ messages in thread
From: Selby Mashiki @ 2026-07-16 11:08 UTC (permalink / raw)
To: Andy Shevchenko, Greg Kroah-Hartman
Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel,
Selby Mashiki
udelay() busy-waits for the specified duration, consuming CPU cycles
unnecessarily. usleep_range() is preferred for delays that can sleep,
as it allows the scheduler to run other tasks during the wait.
Replace two instances of udelay(100) with usleep_range(100, 200) to
use the preferred sleeping delay function.
Signed-off-by: Selby Mashiki <mashikiselby@gmail.com>
---
drivers/staging/fbtft/fb_ra8875.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fbtft/fb_ra8875.c b/drivers/staging/fbtft/fb_ra8875.c
index 0ab1de664..d2400bb44 100644
--- a/drivers/staging/fbtft/fb_ra8875.c
+++ b/drivers/staging/fbtft/fb_ra8875.c
@@ -210,7 +210,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
}
len--;
- udelay(100);
+ usleep_range(100, 200);
if (len) {
buf = (u8 *)par->buf;
@@ -231,7 +231,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
/* restore user spi-speed */
par->fbtftops.write = fbtft_write_spi;
- udelay(100);
+ usleep_range(100, 200);
}
static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
---
base-commit: 64276d9bfe4d1fdd5cf2636f1065f7ea55c2defb
change-id: 20260716-staging-testing-b1b81d63d0d1
Best regards,
--
Selby Mashiki <mashikiselby@gmail.com>
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
2026-07-16 11:08 ` Selby Mashiki
(?)
@ 2026-07-16 11:19 ` sashiko-bot
-1 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-07-16 11:19 UTC (permalink / raw)
To: Selby Mashiki; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Unconditional NULL Pointer Dereference on Big Endian Architectures
- [High] Missing State Restoration on Error Path
- [High] Unaligned Memory Access causing alignment faults
--
--- Patch [1]: [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range ---
commit 0b662df2d1169732bcf1a8f82e3c8a0905497245
Author: Selby Mashiki <mashikiselby@gmail.com>
staging: fbtft: fb_ra8875: replace udelay with usleep_range
udelay() busy-waits for the specified duration, consuming CPU cycles
unnecessarily. usleep_range() is preferred for delays that can sleep,
as it allows the scheduler to run other tasks during the wait.
> diff --git a/drivers/staging/fbtft/fb_ra8875.c b/drivers/staging/fbtft/fb_ra8875.c
> index 0ab1de6647d07..d2400bb44f1c6 100644
> --- a/drivers/staging/fbtft/fb_ra8875.c
> +++ b/drivers/staging/fbtft/fb_ra8875.c
> @@ -210,7 +210,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
> }
> len--;
>
> - udelay(100);
> + usleep_range(100, 200);
>
> if (len) {
> buf = (u8 *)par->buf;
[ ... ]
> @@ -231,7 +231,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
>
> /* restore user spi-speed */
> par->fbtftops.write = fbtft_write_spi;
> - udelay(100);
> + usleep_range(100, 200);
> }
[Severity: High]
This isn't a bug introduced by this patch, but I noticed the error paths
in write_reg8_bus8() return early:
write_reg8_bus8() {
...
ret = par->fbtftops.write(par, par->buf, len + 1);
if (ret < 0) {
va_end(args);
dev_err(par->info->device,
"write() failed and returned %dn", ret);
return;
}
...
}
Does this early return leave par->fbtftops.write pointing to the slower
write_spi function, permanently degrading SPI performance? Should it restore
fbtft_write_spi before returning?
>
> static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
[Severity: Critical]
This is a pre-existing issue, but does write_vmem16_bus8() unconditionally
dereference par->txbuf.buf?
write_vmem16_bus8() {
...
*(u8 *)(par->txbuf.buf) = 0x00;
...
}
If par->txbuf.buf is only dynamically allocated on Little Endian architectures
or when txbuflen > 0, could this cause a kernel panic on Big Endian systems
where it might be NULL?
[Severity: High]
Also a pre-existing issue in write_vmem16_bus8(): is there a risk of alignment
faults on architectures that do not support unaligned memory access?
write_vmem16_bus8() {
...
txbuf16 = par->txbuf.buf + 1;
...
for (i = 0; i < to_copy; i++)
txbuf16[i] = cpu_to_be16(vmem16[i]);
...
}
Since txbuf16 is cast from an odd byte offset (par->txbuf.buf + 1), does the
16-bit assignment in the loop cause an unaligned access?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716-staging-testing-v1-1-2ebc0c6bb27a@gmail.com?part=1
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
2026-07-16 11:08 ` Selby Mashiki
(?)
(?)
@ 2026-07-16 18:37 ` Andy Shevchenko
-1 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2026-07-16 18:37 UTC (permalink / raw)
To: mashikiselby
Cc: Andy Shevchenko, Greg Kroah-Hartman, dri-devel, linux-fbdev,
linux-staging, linux-kernel
On Thu, Jul 16, 2026 at 01:08:33PM +0200, Selby Mashiki via B4 Relay wrote:
> udelay() busy-waits for the specified duration, consuming CPU cycles
> unnecessarily. usleep_range() is preferred for delays that can sleep,
> as it allows the scheduler to run other tasks during the wait.
>
> Replace two instances of udelay(100) with usleep_range(100, 200) to
> use the preferred sleeping delay function.
NAK. Read mailing list archives why.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <20260218174737.86994-1-tomasz.unger.ref@yahoo.pl>]
* [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
[not found] <20260218174737.86994-1-tomasz.unger.ref@yahoo.pl>
@ 2026-02-18 17:47 ` tomasz.unger
2026-02-19 7:30 ` Andy Shevchenko
0 siblings, 1 reply; 10+ messages in thread
From: tomasz.unger @ 2026-02-18 17:47 UTC (permalink / raw)
To: andy, gregkh
Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel, Tomasz Unger
From: Tomasz Unger <tomasz.unger@yahoo.pl>
Signed-off-by: Tomasz Unger <tomasz.unger@yahoo.pl>
---
drivers/staging/fbtft/fb_ra8875.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fbtft/fb_ra8875.c b/drivers/staging/fbtft/fb_ra8875.c
index 0ab1de6647d0..ec4ce534e409 100644
--- a/drivers/staging/fbtft/fb_ra8875.c
+++ b/drivers/staging/fbtft/fb_ra8875.c
@@ -210,7 +210,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
}
len--;
- udelay(100);
+ usleep_range(100, 110);
if (len) {
buf = (u8 *)par->buf;
@@ -231,7 +231,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
/* restore user spi-speed */
par->fbtftops.write = fbtft_write_spi;
- udelay(100);
+ usleep_range(100, 110);
}
static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
2026-02-18 17:47 ` tomasz.unger
@ 2026-02-19 7:30 ` Andy Shevchenko
0 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2026-02-19 7:30 UTC (permalink / raw)
To: tomasz.unger
Cc: andy, gregkh, dri-devel, linux-fbdev, linux-staging, linux-kernel
On Wed, Feb 18, 2026 at 06:47:37PM +0100, tomasz.unger@yahoo.pl wrote:
> From: Tomasz Unger <tomasz.unger@yahoo.pl>
We do not accept changes without explanations.
Also where did you get this idea to convert udelay() to usleep_range()?
The API (in case it's okay to use) should be fsleep() nowadays.
(Note as well that we refer to the functions as 'func()' in the text.)
And last, but not least: have you checked carefully that this is even
possible change? This is quite a change in the behaviour and needs very
good justification and testing.
TL;DR: if any tool suggested this change to you, go and fix that tool
to stop spreading misleading ARs!
P.S.
NAK to all your three patches. Also check https://lore.kernel.org ML
archives on the similar changes in the past, they were all NAKed
(rejected).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
@ 2025-10-20 19:15 Olle Lukowski
2025-10-21 7:37 ` Greg Kroah-Hartman
2025-10-21 8:50 ` Andy Shevchenko
0 siblings, 2 replies; 10+ messages in thread
From: Olle Lukowski @ 2025-10-20 19:15 UTC (permalink / raw)
To: Andy Shevchenko, Greg Kroah-Hartman
Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel,
Olle Lukowski
Replace udelay(100) calls with usleep_range(100, 200) to allow the
scheduler to yield instead of busy-waiting. This is the preferred API for
sleep durations above 10 microseconds.
Signed-off-by: Olle Lukowski <olle@lukowski.dev>
---
This patch replaces udelay() with usleep_range() in fb_ra8875.
---
drivers/staging/fbtft/fb_ra8875.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fbtft/fb_ra8875.c b/drivers/staging/fbtft/fb_ra8875.c
index 0ab1de664..d2400bb44 100644
--- a/drivers/staging/fbtft/fb_ra8875.c
+++ b/drivers/staging/fbtft/fb_ra8875.c
@@ -210,7 +210,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
}
len--;
- udelay(100);
+ usleep_range(100, 200);
if (len) {
buf = (u8 *)par->buf;
@@ -231,7 +231,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
/* restore user spi-speed */
par->fbtftops.write = fbtft_write_spi;
- udelay(100);
+ usleep_range(100, 200);
}
static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
---
base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
change-id: 20251020-staging-fbtft-ra8875-usleep-77306ea543c7
Best regards,
--
Olle Lukowski <olle@lukowski.dev>
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
2025-10-20 19:15 Olle Lukowski
@ 2025-10-21 7:37 ` Greg Kroah-Hartman
2025-10-21 8:12 ` Olle Lukowski
2025-10-21 8:50 ` Andy Shevchenko
1 sibling, 1 reply; 10+ messages in thread
From: Greg Kroah-Hartman @ 2025-10-21 7:37 UTC (permalink / raw)
To: Olle Lukowski
Cc: Andy Shevchenko, dri-devel, linux-fbdev, linux-staging,
linux-kernel
On Mon, Oct 20, 2025 at 10:15:36PM +0300, Olle Lukowski wrote:
> Replace udelay(100) calls with usleep_range(100, 200) to allow the
> scheduler to yield instead of busy-waiting. This is the preferred API for
> sleep durations above 10 microseconds.
As per this type of change, have you tested it on real hardware?
Without that, we can't accept this change, and such checkpatch.pl
comments should be ignored.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
2025-10-21 7:37 ` Greg Kroah-Hartman
@ 2025-10-21 8:12 ` Olle Lukowski
0 siblings, 0 replies; 10+ messages in thread
From: Olle Lukowski @ 2025-10-21 8:12 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Andy Shevchenko, dri-devel, linux-fbdev, linux-staging,
linux-kernel
Hi Greg,
On Tue, Oct 21, 2025 at 09:37:50AM +0200, Greg Kroah-Hartman wrote:
> As per this type of change, have you tested it on real hardware?
> Without that, we can't accept this change, and such checkpatch.pl
> comments should be ignored.
Thanks for clarifying!
I don't have access to the hardware for this driver, so I'll skip these
types of timing-related changes for now and focus on other
non-functional cleanups in staging instead.
Thanks again,
Olle
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
2025-10-20 19:15 Olle Lukowski
2025-10-21 7:37 ` Greg Kroah-Hartman
@ 2025-10-21 8:50 ` Andy Shevchenko
1 sibling, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2025-10-21 8:50 UTC (permalink / raw)
To: Olle Lukowski
Cc: Andy Shevchenko, Greg Kroah-Hartman, dri-devel, linux-fbdev,
linux-staging, linux-kernel
On Mon, Oct 20, 2025 at 10:16 PM Olle Lukowski <olle@lukowski.dev> wrote:
>
> Replace udelay(100) calls with usleep_range(100, 200) to allow the
> scheduler to yield instead of busy-waiting. This is the preferred API for
> sleep durations above 10 microseconds.
...
> - udelay(100);
> + usleep_range(100, 200);
Besides what Greg said, the function in similar changes should be
fsleep(), it will automatically choose the best low-level API for the
given delay.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-07-16 18:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16 11:08 [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range Selby Mashiki via B4 Relay
2026-07-16 11:08 ` Selby Mashiki
2026-07-16 11:19 ` sashiko-bot
2026-07-16 18:37 ` Andy Shevchenko
[not found] <20260218174737.86994-1-tomasz.unger.ref@yahoo.pl>
2026-02-18 17:47 ` tomasz.unger
2026-02-19 7:30 ` Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2025-10-20 19:15 Olle Lukowski
2025-10-21 7:37 ` Greg Kroah-Hartman
2025-10-21 8:12 ` Olle Lukowski
2025-10-21 8:50 ` Andy Shevchenko
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.