All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Selby Mashiki" <mashikiselby@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] staging: fbtft: fb_ra8875: replace udelay with usleep_range
Date: Thu, 16 Jul 2026 11:19:11 +0000	[thread overview]
Message-ID: <20260716111911.99DE81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716-staging-testing-v1-1-2ebc0c6bb27a@gmail.com>

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

  reply	other threads:[~2026-07-16 11:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20260716111911.99DE81F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mashikiselby@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.