From: sashiko-bot@kernel.org
To: "Changhuang Liang" <changhuang.liang@starfivetech.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 05/11] spi: dw: update NDF while using enhanced spi mode
Date: Mon, 03 Aug 2026 13:02:43 +0000 [thread overview]
Message-ID: <20260803130244.A642E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803124044.156998-6-changhuang.liang@starfivetech.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The `cfg.ndf` (Number of Data Frames) field is left uninitialized (0) for Transmit Only operations in `dw_spi_exec_mem_op()`, causing the hardware to be erroneously programmed to transmit 0 frames.
- [Medium] The condition to update the NDF register for Transmit Only mode incorrectly checks the static controller capability instead of the actual transfer format.
--
--- Patch [5]: [PATCH v2 05/11] spi: dw: update NDF while using enhanced spi mode ---
commit 5891fe2f8ceff4e681ce6ee14b10868e4b3ce4bc
Author: Sudip Mukherjee <sudip.mukherjee@sifive.com>
spi: dw: update NDF while using enhanced spi mode
This commit updates the driver to configure the Number of Data Frames (NDF)
register during Transmit Only mode on enhanced SPI controllers. It modifies
dw_spi_update_config() to write cfg->ndf to DW_SPI_CTRLR1 when the transfer
mode is DW_SPI_CTRLR0_TMOD_TO and the controller supports enhanced SPI.
> diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
> index f1b7328fed772..d654cb748646a 100644
> --- a/drivers/spi/spi-dw-core.c
> +++ b/drivers/spi/spi-dw-core.c
> @@ -348,6 +348,9 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi,
> if (cfg->tmode == DW_SPI_CTRLR0_TMOD_EPROMREAD ||
> cfg->tmode == DW_SPI_CTRLR0_TMOD_RO)
> dw_writel(dws, DW_SPI_CTRLR1, cfg->ndf ? cfg->ndf - 1 : 0);
> + else if (cfg->tmode == DW_SPI_CTRLR0_TMOD_TO &&
> + dws->caps & DW_SPI_CAP_EMODE)
> + dw_writel(dws, DW_SPI_CTRLR1, cfg->ndf);
[Severity: Medium]
Will this write a 0 to DW_SPI_CTRLR1 for outbound memory operations?
Looking at dw_spi_exec_mem_op(), cfg is initialized to zero, and cfg.ndf is
only assigned for SPI_MEM_DATA_IN:
drivers/spi/spi-dw-core.c:dw_spi_exec_mem_op() {
struct dw_spi_cfg cfg = {0};
...
if (op->data.dir == SPI_MEM_DATA_IN) {
cfg.tmode = DW_SPI_CTRLR0_TMOD_EPROMREAD;
cfg.ndf = op->data.nbytes;
} else {
cfg.tmode = DW_SPI_CTRLR0_TMOD_TO;
}
...
}
For transmit operations (SPI_MEM_DATA_OUT), cfg.ndf remains 0 when it's passed
into dw_spi_update_config(), causing the hardware to be programmed to transmit
0 frames.
[Severity: Medium]
Does this condition correctly identify an Enhanced SPI transfer?
Checking dws->caps & DW_SPI_CAP_EMODE verifies that the controller supports
Enhanced SPI, but it does not check if the current transfer is actually
using it.
Could this cause standard 1-bit SPI memory writes on EMODE-capable controllers
to inappropriately update DW_SPI_CTRLR1 with cfg->ndf?
> /* Note DW APB SSI clock divider doesn't support odd numbers */
> clk_div = (DIV_ROUND_UP(dws->max_freq, cfg->freq) + 1) & 0xfffe;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803124044.156998-1-changhuang.liang@starfivetech.com?part=5
next prev parent reply other threads:[~2026-08-03 13:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 12:40 [PATCH v2 00/11] Add support for StarFive JHB100 SFC Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 01/11] spi: dw: Introduce spi_frf and STD_SPI Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 02/11] spi: dw: update SPI_CTRLR0 register Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 03/11] spi: dw: add check for support of enhanced spi Changhuang Liang
2026-08-03 12:53 ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 04/11] spi: dw: adjust size of mem_op Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 05/11] spi: dw: update NDF while using enhanced spi mode Changhuang Liang
2026-08-03 13:02 ` sashiko-bot [this message]
2026-08-03 12:40 ` [PATCH v2 06/11] spi: dw: Introduce enhanced single/dual/quad/octal spi Changhuang Liang
2026-08-03 12:58 ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 07/11] spi: dw: send cmd and addr to start the spi transfer Changhuang Liang
2026-08-03 12:59 ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 08/11] spi: dw: use irq handler for enhanced spi Changhuang Liang
2026-08-03 12:59 ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 09/11] spi: dw: detect enhanced spi mode Changhuang Liang
2026-08-03 13:07 ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 10/11] spi: dt-bindings: snps,dw-apb-ssi: Add starfive,jhb100-sfc Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 11/11] spi: dw: Add support for StarFive JHB100 SoC SFC Changhuang Liang
2026-08-03 13:07 ` sashiko-bot
2026-08-04 12:53 ` [PATCH v2 00/11] Add support for StarFive JHB100 SFC Mark Brown
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=20260803130244.A642E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=changhuang.liang@starfivetech.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--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