Re: [PATCH v6 05/17] spi: spi-mem: add execute_tuning callback and spi_mem_execute_tuning()

Miquel Raynal <[email protected]> Wed, 29 Jul 2026 10:37:31 +0200
Newsgroups gmane.linux.kernel.spi.devel,gmane.linux.drivers.devicetree,gmane.linux.kernel,gmane.linux.drivers.mtd
Message-ID <[email protected]>
Hello Santhosh,

On 23/07/2026 at 16:32:07 +0530, Santhosh Kumar K <[email protected]> wrote:

> Add an execute_tuning callback to struct spi_controller_mem_ops. The
> callback receives a mandatory read op template and an optional write op
> template. On success the controller sets op->max_freq in each provided
> template to the validated clock rate.
>
> Add the corresponding spi_mem_execute_tuning() wrapper that checks for
> callback availability and returns -EOPNOTSUPP when the controller has
> not implemented it, allowing callers to handle controllers that do not
> support tuning gracefully.
>
> Reviewed-by: Miquel Raynal <[email protected]>
> Signed-off-by: Santhosh Kumar K <[email protected]>

Sashiko found two issues which I think are easy yet worth fixing:

- [High] spi_mem_execute_tuning() directly invokes the controller callback =
without acquiring the SPI bus locks or ensuring the controller is powered o=
n.
- [High] spi_mem_execute_tuning() does not check if the SPI device is using=
 a GPIO chip select before invoking the hardware tuning callback.

Can you please have a look?

Thanks,
Miqu=C3=A8l