spi: spi-mem: Estimate the time taken by operations
authorMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 10 Jan 2025 14:45:22 +0000 (15:45 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 10 Jan 2025 15:20:04 +0000 (15:20 +0000)
commit226d6cb3cb799aae46d0dd19a521133997d9db11
tree8d784802bded1cebb51a5baa2463dcc0611703ba
parentf0006897a96c736623ddeb9b68c3880eb5cdebe7
spi: spi-mem: Estimate the time taken by operations

In the SPI-NAND layer, we currently make list of operation variants from
the fastest one to the slowest and there is a bit of logic in the core
to go over them and pick the first one that is supported by the
controller, ie. the fastest one among the supported ops.

This kind of logic only works if all operations run at the same
frequency, but as soon as we introduce per operation max frequencies it
is not longer as obvious which operation will be faster, especially
since it also depends on the PCB/controller frequency limitation.

One way to make this choice more clever is to go over all the
variants and for each of them derive an indicator which will help derive
the theoretical best. In this case, we derive a theoretical duration for
the entire operation and we take the smallest one.

Add a helper that parses the spi-mem operation and returns this value.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20250110-winbond-6-11-rc1-quad-support-v3-20-7ab4bd56cf6e@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-mem.c
include/linux/spi/spi-mem.h