[PATCH v3 04/13] spi: spi-mem: add spi_mem_apply_base_freq_cap()

Santhosh Kumar K s-k6 at ti.com
Thu Jun 4 05:10:26 PDT 2026


Hello Miquel,

On 28/05/26 14:13, Miquel Raynal wrote:
> Hi Santhosh,
> 
>> --- a/drivers/spi/spi-mem.c
>> +++ b/drivers/spi/spi-mem.c
>> @@ -398,7 +398,11 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
>>   	u8 *tmpbuf;
>>   	int ret;
>>   
>> -	/* Make sure the operation frequency is correct before going futher */
>> +	/*
>> +	 * Ops not configured for maximum speed are limited to the conservative
>> +	 * base speed; spi_mem_adjust_op_freq() then caps to the device maximum.
>> +	 */
>> +	spi_mem_apply_base_freq_cap(mem, (struct spi_mem_op *)op);
>>   	spi_mem_adjust_op_freq(mem, (struct spi_mem_op *)op);
> 
> There are many more spi_mem_adjust_op_freq() calls in the core where we would
> not apply the base frequency. Aren't we missing these places? Wouldn't it
> be more appropriate to call spi_mem_apply_base_freq_cap() at the beginning
> of spi_mem_adjust_op_freq() ?

Moving spi_mem_apply_base_freq() into spi_mem_adjust_op_freq() would
affect operation selection.

spi_mem_adjust_op_freq() is used during variant evaluation through
spinand_select_op_variant() and spi_mem_calc_op_duration(). Applying the
cap there would cause all candidates to be evaluated at base_speed_hz
rather than the actual max_speed_hz. As a result, variant selection
could converge on a different operation than the one that would be
optimal.

Keeping the cap in spi_mem_exec_op() restricts it to the execution path,
while allowing operation selection and duration calculations to continue
using the maximum achievable frequency.

Regards,
Santhosh.

> 
> Thanks,
> Miquèl




More information about the linux-mtd mailing list