Thread (38 messages) 38 messages, 4 authors, 2026-09-08

Re: [PATCH v9 03/18] spi: parse spi-max-post-config-frequency-hz into post_config_max_speed_hz

flat view

From: sashiko-bot@kernel.org
Date: 2026-08-25 17:30:45

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The new `post_config_max_speed_hz` property is not clamped to the SPI controller's maximum supported speed during device setup.
- [Medium] `post_config_max_speed_hz` is not copied to ancillary or multiplexed SPI devices, breaking high-speed operations for multi-die packages and proxy devices.
--

commit 5705672f7b6c77c877910c5996844e5029e278fd
Author: Santhosh Kumar K [off-list ref]

spi: parse spi-max-post-config-frequency-hz into post_config_max_speed_hz

This commit adds a post_config_max_speed_hz field to struct spi_device to
support SPI devices operating at distinct pre- and post-configuration clock
rates. The new property is parsed from the spi-max-post-config-frequency-hz
Device Tree property.
quoted hunk ↗ jump to hunk
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 88d17fce02dcb..02fd602f29e8b 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
[ ... ]
quoted hunk ↗ jump to hunk
@@ -195,6 +197,7 @@ struct spi_device {
 	struct device		dev;
 	struct spi_controller	*controller;
 	u32			max_speed_hz;
+	u32			post_config_max_speed_hz;
[Severity: Medium]
Does the new post_config_max_speed_hz need to be clamped to the controller's
maximum supported speed during device setup?

Looking at drivers/spi/spi.c:__spi_setup(), the existing max_speed_hz is
strictly validated against the hardware capabilities:

	if (spi->controller->max_speed_hz &&
	    (!spi->max_speed_hz ||
	     spi->max_speed_hz > spi->controller->max_speed_hz))
		spi->max_speed_hz = spi->controller->max_speed_hz;

Without similar clamping for post_config_max_speed_hz, a misconfigured
Device Tree could inject an arbitrarily large frequency, causing the
underlying controller to configure hardware for an unsupported rate.

[Severity: Medium]
Should post_config_max_speed_hz also be cloned for ancillary or multiplexed
SPI devices to ensure multi-die packages can use post-config speeds?

Looking at drivers/spi/spi.c:spi_new_ancillary_device(), only the primary
max_speed_hz is copied to secondary logical devices:

	/* Take over SPI mode/speed from SPI main device */
	ancillary->max_speed_hz = spi->max_speed_hz;
	ancillary->mode = spi->mode;

A similar omission exists in drivers/spi/spi-mux.c:spi_mux_select():

	/* copy the child device's settings except for the cs */
	priv->spi->max_speed_hz = spi->max_speed_hz;
	priv->spi->mode = spi->mode;

Without cloning this new property, these proxy devices will have a zero
post-config frequency, forcing secondary dies to operate at the slower
pre-configuration rate.
 	u8			bits_per_word;
 	bool			rt;
 #define SPI_NO_TX		BIT(31)		/* No transmit wire */
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260825171737.776052-1-s-k6@ti.com?part=3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help