Re: [PATCH v2 1/2] staging: sm750fb: Replace busy-wait loop with udelay()

From: OaroraEtimis

Date: Mon Mar 16 2026 - 03:42:23 EST


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?

1. Keep the original loop but add cpu_relax() inside to prevent compiler optimization. (Safest for the hardware)
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).

I'd appreciate your guidance on the best path forward for this staging driver.

Thanks,
Oarora