[PATCH v11 03/19] spi: parse spi-max-post-config-frequency-hz into post_config_max_speed_hz
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Nov 5 03:18:16 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] spi: unclamped post_config_max_speed_hz in __spi_setup()
--
commit 3a575dbc26c781e2f3bb4d2e533de6da92715c51
Author: Santhosh Kumar K <s-k6 at ti.com>
spi: parse spi-max-post-config-frequency-hz into post_config_max_speed_hz
This commit adds post_config_max_speed_hz to struct spi_device and parses
it from the spi-max-post-config-frequency-hz device tree property in
of_spi_parse_dt(). This allows SPI devices to specify a higher target
clock frequency to be used after controller-side configuration such as PHY
tuning.
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index c29ffac59c8f0..3f6add21154ed 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -2825,6 +2825,8 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
> /* Device speed */
> if (!of_property_read_u32(nc, "spi-max-frequency", &value))
> spi->max_speed_hz = value;
> + if (!of_property_read_u32(nc, "spi-max-post-config-frequency-hz", &value))
> + spi->post_config_max_speed_hz = value;
[Severity: Medium]
As reported by Sashiko on v4 [1], when a device tree node specifies a
spi-max-post-config-frequency-hz value that exceeds the parent controller's
spi->controller->max_speed_hz limit, can spi->post_config_max_speed_hz
remain uncapped?
During device registration, of_register_spi_device() calls of_spi_parse_dt()
and then spi_add_device() -> __spi_add_device() -> __spi_setup(). In
__spi_setup(), spi->max_speed_hz is clamped to the controller's maximum
speed, but spi->post_config_max_speed_hz is not:
drivers/spi/spi.c:__spi_setup() {
...
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;
...
}
Should __spi_setup() also clamp spi->post_config_max_speed_hz to
spi->controller->max_speed_hz when both are non-zero, so that
post-configuration SPI-MEM operations and PHY tuning do not request a
frequency above the controller's hardware limit?
[1] https://lore.kernel.org/r/20260618075445.389E11F000E9@smtp.kernel.org
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105105832.2134313-1-s-k6@ti.com?part=3
More information about the linux-mtd
mailing list