Re: [PATCH v2 1/2] staging: sm750fb: Replace busy-wait loop with udelay()
From: Greg KH
Date: Mon Mar 16 2026 - 04:17:11 EST
On Mon, Mar 16, 2026 at 03:42:04PM +0800, OaroraEtimis wrote:
> Hi Greg,
>
> Thanks for the review. Sorry for dropping the historical comment in v2. My
> only goal was to fix the -Wunused-but-set-variable warning and prevent the
> loop from being optimized away by the compiler.
>
> I will definitely restore the comment.
>
>
> On Mon, Mar 16, 2026 at 14:11, Greg KH wrote:
>
> > How is "2" the same as this busy loop?
>
> It was a rough estimation. A 600-iteration empty loop on older CPUs
> (~500MHz) took about 2 to 3 microseconds.
>
>
> > And why not fix this properly, as the comment states?
>
> The comment suggests writing to VGA ports (0x3ce/0x3cf) to force a delay. I
> didn't implement this because I don't have the specific hardware or
> datasheets to test it.
>
> I was afraid that introducing direct VGA I/O just to fix a compiler warning
> might cause unexpected hardware regressions *or compatibility issues across
> different platforms.*
>
> Given that I can't test hardware I/O, how would you prefer I handle this in
> v3?
Don't do any logical change that testing without hardware can not be
verified (i.e. whitespace changes).
> 1. Keep the original loop but add cpu_relax() inside to prevent compiler
> optimization. (Safest for the hardware)
Are you sure? Can you sleep at that point in time? What does the
performance of the device then look like?
> 2. Use udelay(2) (or ndelay) and restore the historical comment.
> 3. Migrate the driver to the standard i2c-algo-bit framework (a much heavier
> refactoring).
Number 3 is the best way.
good luck!
greg k-h