Am 27.03.24 um 14:01 schrieb Richard Hughes:
On Wed, 27 Mar 2024 at 11:20, Anastasia Klimchuk aklm@chromium.org wrote:
Also interested to know what other people think?
I also agree with Peter, the "calibrated busy-loop" worked great on 16 bit DOS, but with modern operating systems and CPUs it just doesn't make sense.
Well, it theoretically may not make sense, but the busy-loop waits were sometimes the only reasonable waiting solution on older non-SPI (LPC/FWH/parallel) flash chips.
For example, some chips use the toggle bit detection to check for a finished write. In theory, toggle-bit works like this: Read the same location over and over until the designated toggle bit stops changing, then you know your write is done. Now, some Winbond (AFAIR, it's been some years) have an additional requirement even mentioned in the data sheet: Reread too quickly, and the bit will not toggle, falsely giving the impression that the write is done. On other chips, rereading too slowly would also fool the write-is-done detection. Those old machines hosting affected flash chips usually do not have any highly dynamic frequency scaling not P-cores/E-cores, so the concerns about "doesn't make sense" don't apply here.
You're of course free to declare those chips obsolete, but in that case it may make sense to drop support for them altogether (i.e. refuse write or remove from database, but keep an incompatibility notice) instead of giving people a false hope. Silent breakage may be OK for higher-level software, but it should never be intentionally done for software which can brick your machine.
That said, flashrom for DOS users still exist.
The easiest option for getting rid of all those concerns is to compile a SPI-only non-DOS flashrom and make any delay calibrations dependent on (non-SPI OR DOS). That won't simplify the code, though.
Dropping the DOS code and the non-SPI code is another option. I'm not advocating for that, but if you want to clean up code, that's the simplest way to get rid of all the various warts.
As a side note, it would be interesting to know what the main usage of flashrom is nowadays. I'd expect it to be mostly Chromebooks, possibly some other embedded boards. Focusing on the 99% might yield enormous cleanup opportunities.
Regards, Carl-Daniel