Devicetree
 help / color / mirror / Atom feed
From: Frieder Schrempf <frieder.schrempf@kontron.de>
To: sashiko-reviews@lists.linux.dev, Frieder Schrempf <frieder@fris.de>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 3/3] spi: dw: Use the rx-sample-delay-ns value parsed by the core
Date: Mon, 21 Sep 2026 12:15:57 +0200	[thread overview]
Message-ID: <44936d3a-e684-4f74-bd65-6cc683d13792@kontron.de> (raw)
In-Reply-To: <20260917154647.4CEAE1F00899@smtp.kernel.org>

On 17.09.26 17:46, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] spi: dw: unable to override controller rx-sample-delay-ns to 0
> --
> 
> commit 32c003f916e2933421d0880f812a21d5785775b7
> Author: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> spi: dw: Use the rx-sample-delay-ns value parsed by the core
> 
> This commit drops the private parsing of the rx-sample-delay-ns property
> and uses the value parsed by the core into spi_device.rx_sample_delay_ns.
> It falls back to the controller-wide default when the device does not ask
> for a delay of its own.
> 
>> diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
>> index 206d3f9dd83d4..b86b607cc8179 100644
>> --- a/drivers/spi/spi-dw-core.c
>> +++ b/drivers/spi/spi-dw-core.c
>> @@ -1104,12 +1104,13 @@ static int dw_spi_setup(struct spi_device *spi)
> [ ... ]
>> -		/* Get specific / default rx-sample-delay */
>> -		if (device_property_read_u32(&spi->dev,
>> -					     "rx-sample-delay-ns",
>> -					     &rx_sample_dly_ns) != 0)
>> -			/* Use default controller value */
>> -			rx_sample_dly_ns = dws->def_rx_sample_dly_ns;
>> +		/*
>> +		 * Use the per-device value the core parsed from the peripheral
>> +		 * node, and fall back to the controller-wide default when the
>> +		 * device does not ask for a delay of its own.
>> +		 */
>> +		rx_sample_dly_ns = spi->rx_sample_delay_ns ?:
>> +				   dws->def_rx_sample_dly_ns;
> 
> [Severity: Medium]
> Does this ?: operator prevent configuring an explicit 0 ns delay?
> 
> The previous code used device_property_read_u32() in dw_spi_setup(),
> which allowed an explicit value of 0 to override the controller default:
> 
>     if (device_property_read_u32(...) != 0)
>         rx_sample_dly_ns = dws->def_rx_sample_dly_ns;
> 
> By using the ?: operator, a parsed value of 0 is treated as falsy,
> meaning an explicit rx-sample-delay-ns = <0> in the device tree will
> now fall back to the controller's default instead of overriding it to 0.
> 
> Although the commit message states there are no in-tree users relying
> on this behavior, Device Tree is a stable ABI. Does ignoring the explicit
> override of <0> break backward compatibility for out-of-tree configurations,
> potentially causing SPI RX data corruption on boards that require a 0 ns
> delay?
It is highly unlikely that anyone has an out-of-tree DT with a
controller-level rx-sample-delay-ns set and a chip-level
rx-sample-delay-ns set to zero. I don't think we should continue to
support this configuration that was probably never meant to work like
this, is undocumented and doesn't make sense.

      reply	other threads:[~2026-09-21 10:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 15:37 [PATCH 0/3] spi: Better specification for rx-sample-delay-ns and core parsing Frieder Schrempf
2026-09-17 15:37 ` [PATCH 1/3] dt-bindings: spi: Clarify what rx-sample-delay-ns describes Frieder Schrempf
2026-09-17 22:23   ` Mark Brown
2026-09-21 10:50     ` Frieder Schrempf
2026-09-17 15:37 ` [PATCH 2/3] spi: Parse the rx-sample-delay-ns peripheral property in the core Frieder Schrempf
2026-09-17 15:37 ` [PATCH 3/3] spi: dw: Use the rx-sample-delay-ns value parsed by " Frieder Schrempf
2026-09-17 15:46   ` sashiko-bot
2026-09-21 10:15     ` Frieder Schrempf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44936d3a-e684-4f74-bd65-6cc683d13792@kontron.de \
    --to=frieder.schrempf@kontron.de \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frieder@fris.de \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox