Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter
@ 2026-05-22  7:16 Chin-Ting Kuo
  2026-05-22  7:16 ` [PATCH v2 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path Chin-Ting Kuo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chin-Ting Kuo @ 2026-05-22  7:16 UTC (permalink / raw)
  To: clg, broonie, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, david.laight.linux, BMC-SW

This series fixes two sparse warnings reported by the kernel test robot.
The first patch fixes missing __iomem annotation on an MMIO pointer
parameter, which also caused a redundant cast at the call site.
A VLA function parameter warning is also fixed in this patch series.

Changes in v2:
  - Add parentheses to row-major index for clarity.

Chin-Ting Kuo (2):
  spi: aspeed: Fix missing __iomem annotation in output transfer path
  spi: aspeed: Replace VLA parameter with flat pointer in calibration
    helper

 drivers/spi/spi-aspeed-smc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path
  2026-05-22  7:16 [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Chin-Ting Kuo
@ 2026-05-22  7:16 ` Chin-Ting Kuo
  2026-05-22  7:16 ` [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
  2026-05-22 11:01 ` [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Chin-Ting Kuo @ 2026-05-22  7:16 UTC (permalink / raw)
  To: clg, broonie, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, david.laight.linux, BMC-SW
  Cc: kernel test robot

The dst parameter of aspeed_spi_user_transfer_tx() is an MMIO address
obtained from chip->ahb_base, but it was typed as void * instead of
void __iomem *.  This caused a sparse warning report. Fix the
parameter type to void __iomem * and drop the now-unnecessary
cast at the call site.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605180441.uD3toFRJ-lkp@intel.com/
Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/spi/spi-aspeed-smc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index c21323e07d3c..808659a1f460 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -891,7 +891,7 @@ static int aspeed_spi_user_unprepare_msg(struct spi_controller *ctlr,
 static void aspeed_spi_user_transfer_tx(struct aspeed_spi *aspi,
 					struct spi_device *spi,
 					const u8 *tx_buf, u8 *rx_buf,
-					void *dst, u32 len)
+					void __iomem *dst, u32 len)
 {
 	const struct aspeed_spi_data *data = aspi->data;
 	bool full_duplex_transfer = data->full_duplex && tx_buf == rx_buf;
@@ -936,7 +936,7 @@ static int aspeed_spi_user_transfer(struct spi_controller *ctlr,
 			aspeed_spi_set_io_mode(chip, CTRL_IO_QUAD_DATA);
 
 		aspeed_spi_user_transfer_tx(aspi, spi, tx_buf, rx_buf,
-					    (void *)ahb_base, xfer->len);
+					    ahb_base, xfer->len);
 	}
 
 	if (rx_buf && rx_buf != tx_buf) {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-22  7:16 [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Chin-Ting Kuo
  2026-05-22  7:16 ` [PATCH v2 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path Chin-Ting Kuo
@ 2026-05-22  7:16 ` Chin-Ting Kuo
  2026-05-22  8:19   ` David Laight
  2026-05-22 11:01 ` [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Chin-Ting Kuo @ 2026-05-22  7:16 UTC (permalink / raw)
  To: clg, broonie, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, david.laight.linux, BMC-SW
  Cc: kernel test robot

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.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605180441.uD3toFRJ-lkp@intel.com/
Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/spi/spi-aspeed-smc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 808659a1f460..027caa2eeb5c 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -1467,8 +1467,7 @@ static int aspeed_spi_do_calibration(struct aspeed_spi_chip *chip)
  * must contains the highest number of consecutive "pass"
  * results and not span across multiple rows.
  */
-static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols,
-					       u8 buf[rows][cols])
+static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols, u8 *buf)
 {
 	int r = 0, c = 0;
 	int max = 0;
@@ -1478,7 +1477,7 @@ static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols,
 		for (j = 0; j < cols;) {
 			int k = j;
 
-			while (k < cols && buf[i][k])
+			while (k < cols && buf[(i * cols) + k])
 				k++;
 
 			if (k - j > max) {
@@ -1541,7 +1540,7 @@ static int aspeed_spi_ast2600_calibrate(struct aspeed_spi_chip *chip, u32 hdiv,
 		}
 	}
 
-	calib_point = aspeed_spi_ast2600_optimized_timing(6, 17, calib_res);
+	calib_point = aspeed_spi_ast2600_optimized_timing(6, 17, &calib_res[0][0]);
 	/* No good setting for this frequency */
 	if (calib_point == 0)
 		return -1;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-22  7:16 ` [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
@ 2026-05-22  8:19   ` David Laight
  2026-05-22 15:48     ` Chin-Ting Kuo
  0 siblings, 1 reply; 6+ messages in thread
From: David Laight @ 2026-05-22  8:19 UTC (permalink / raw)
  To: Chin-Ting Kuo
  Cc: clg, broonie, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, BMC-SW, kernel test robot

On Fri, 22 May 2026 15:16:21 +0800
Chin-Ting Kuo <chin-ting_kuo@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.

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.

-- David


> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605180441.uD3toFRJ-lkp@intel.com/
> Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
> Reviewed-by: Cédric Le Goater <clg@kaod.org>
> ---
>  drivers/spi/spi-aspeed-smc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index 808659a1f460..027caa2eeb5c 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -1467,8 +1467,7 @@ static int aspeed_spi_do_calibration(struct aspeed_spi_chip *chip)
>   * must contains the highest number of consecutive "pass"
>   * results and not span across multiple rows.
>   */
> -static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols,
> -					       u8 buf[rows][cols])
> +static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols, u8 *buf)
>  {
>  	int r = 0, c = 0;
>  	int max = 0;
> @@ -1478,7 +1477,7 @@ static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols,
>  		for (j = 0; j < cols;) {
>  			int k = j;
>  
> -			while (k < cols && buf[i][k])
> +			while (k < cols && buf[(i * cols) + k])
>  				k++;
>  
>  			if (k - j > max) {
> @@ -1541,7 +1540,7 @@ static int aspeed_spi_ast2600_calibrate(struct aspeed_spi_chip *chip, u32 hdiv,
>  		}
>  	}
>  
> -	calib_point = aspeed_spi_ast2600_optimized_timing(6, 17, calib_res);
> +	calib_point = aspeed_spi_ast2600_optimized_timing(6, 17, &calib_res[0][0]);
>  	/* No good setting for this frequency */
>  	if (calib_point == 0)
>  		return -1;



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter
  2026-05-22  7:16 [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Chin-Ting Kuo
  2026-05-22  7:16 ` [PATCH v2 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path Chin-Ting Kuo
  2026-05-22  7:16 ` [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
@ 2026-05-22 11:01 ` Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-05-22 11:01 UTC (permalink / raw)
  To: clg, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, david.laight.linux, BMC-SW,
	Chin-Ting Kuo

On Fri, 22 May 2026 15:16:19 +0800, Chin-Ting Kuo wrote:
> spi: aspeed: Fix __iomem annotation and VLA parameter
> 
> This series fixes two sparse warnings reported by the kernel test robot.
> The first patch fixes missing __iomem annotation on an MMIO pointer
> parameter, which also caused a redundant cast at the call site.
> A VLA function parameter warning is also fixed in this patch series.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2

Thanks!

[1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path
      https://git.kernel.org/broonie/spi/c/5c3091e23f8f
[2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
      https://git.kernel.org/broonie/spi/c/94f5efbaa751

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-22  8:19   ` David Laight
@ 2026-05-22 15:48     ` Chin-Ting Kuo
  0 siblings, 0 replies; 6+ messages in thread
From: Chin-Ting Kuo @ 2026-05-22 15:48 UTC (permalink / raw)
  To: David Laight
  Cc: clg@kaod.org, broonie@kernel.org, joel@jms.id.au,
	andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org,
	openbmc@lists.ozlabs.org, linux-spi@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, BMC-SW, kernel test robot

Hi David,

> -----Original Message-----
> From: David Laight <david.laight.linux@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@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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-22 17:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22  7:16 [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Chin-Ting Kuo
2026-05-22  7:16 ` [PATCH v2 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path Chin-Ting Kuo
2026-05-22  7:16 ` [PATCH v2 2/2] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
2026-05-22  8:19   ` David Laight
2026-05-22 15:48     ` Chin-Ting Kuo
2026-05-22 11:01 ` [PATCH v2 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox