[PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
Chin-Ting Kuo
chin-ting_kuo at aspeedtech.com
Fri May 22 08:48:41 PDT 2026
Hi David,
> -----Original Message-----
> From: David Laight <david.laight.linux at gmail.com>
> Sent: Friday, May 22, 2026 4:19 PM
> Subject: Re: [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat
> pointer in calibration helper
>
> On Fri, 22 May 2026 15:16:21 +0800
> Chin-Ting Kuo <chin-ting_kuo at aspeedtech.com> wrote:
>
> > aspeed_spi_ast2600_optimized_timing() declared its buffer argument as
> > a variable-length array parameter (u8 buf[rows][cols]), which causes a
> > sparse warning. Replace the VLA parameter with a plain u8 * and
> > compute the 2-D index manually. The corresponding call site is also updated.
>
> This code is all a bit horrid.
> The 6 and 17 (which are also used in the array declaration) have to match the
> TIMING_DELAY_HCYCLE_MAX and TIMING_DELAY_INPUT_MAX values used
> for the loops.
>
The magic numbers 6 and 17 can be derived from
TIMING_DELAY_HCYCLE_MAX and TIMING_DELAY_INPUT_MAX. However, this is
a pre-existing issue unrelated to the current patch. Will address it in a separate
cleanup patch series in the future.
> In any case the code would be more obvious if the 'run length' of test passes
> was counted during the initial loop.
> Looks like it wants at least 4 ones, after you've got that many (and a fail) there
> is little point continuing the delay loop for that hcycle.
>
The intent is to find the center of the longest consecutive pass window across
all hcycle/delay combinations, not just the first window with 4 passes.
The threshold of 4 is the minimum tolerable window size derived from
empirical results, not an early exit hint. Besides, recording all results in
a 2-D array also keeps the data collection and the analysis cleanly separated,
which makes the calibration logic easier to follow and test independently.
Chin-Ting
More information about the linux-arm-kernel
mailing list