RE: [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper

Chin-Ting Kuo <[email protected]>
Newsgroups org.ozlabs.lists.openbmc,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-spi,org.ozlabs.lists.linux-aspeed
Message-ID <TYZPR06MB5203714C130A2794585272A7B20F2@TYZPR06MB5203.apcprd06.prod.outlook.com>
Hi David,

> -----Original Message-----
> From: David Laight <[email protected]>
> 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 <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.