From: Michael Walle <mwalle@kernel.org>
To: "Marek Behún" <kabel@kernel.org>, "Tom Rini" <trini@konsulko.com>,
"Pramod Kumar" <pramod.kumar_1@nxp.com>,
"Vladimir Oltean" <olteanv@gmail.com>,
"Alison Wang" <alison.wang@nxp.com>,
"Tang Yuantian" <andy.tang@nxp.com>,
"Mingkai Hu" <mingkai.hu@nxp.com>,
"Priyanka Jain" <priyanka.jain@nxp.com>,
"Wasim Khan" <wasim.khan@nxp.com>,
"Meenakshi Aggarwal" <meenakshi.aggarwal@nxp.com>,
"TsiChung Liew" <Tsi-Chung.Liew@nxp.com>,
"Stefano Babic" <sbabic@nabladev.com>,
"Fabio Estevam" <festevam@gmail.com>,
"NXP i . MX U-Boot Team" <uboot-imx@nxp.com>,
"Peng Fan" <peng.fan@nxp.com>,
"Shengzhou Liu" <Shengzhou.Liu@nxp.com>
Cc: Tomas Alvarez Vanoli <tomas.alvarez-vanoli@hitachienergy.com>,
Jerome Forissier <jerome.forissier@arm.com>,
u-boot@lists.denx.de, Michael Walle <mwalle@kernel.org>
Subject: [PATCH v2 03/11] spi: fsl_espi: fix read transactions
Date: Wed, 6 May 2026 14:34:12 +0200 [thread overview]
Message-ID: <20260506123507.2081751-4-mwalle@kernel.org> (raw)
In-Reply-To: <20260506123507.2081751-1-mwalle@kernel.org>
Since commit 7917c2e35604 ("spi: fsl_espi: fix din offset") MTD is
basically broken because any read transaction will get wrong data. While
the commit in question will fix simple transfers (where both
SPI_XFER_BEGIN and SPI_XFER_END is set), it will break the most common
case, where opcode and address is send first and then data comes as a
second transfer.
This basically reverts commit 7917c2e35604 ("spi: fsl_espi: fix din
offset") and make the fix particular for this simple case. Instead of
providing two buffers for reading and writing, just malloc one which is
used for both. This will work because the data is first written on the
SPI bus and then it will be read (and overwite the written data) into
the same buffer.
Suggested-by: Tomas Alvarez Vanoli <tomas.alvarez-vanoli@hitachienergy.com>
Fixes: 7917c2e35604 ("spi: fsl_espi: fix din offset")
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/spi/fsl_espi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c
index 117e36376b7..c5bc603b5c0 100644
--- a/drivers/spi/fsl_espi.c
+++ b/drivers/spi/fsl_espi.c
@@ -216,13 +216,13 @@ int espi_xfer(struct fsl_spi_slave *fsl, uint cs, unsigned int bitlen,
break;
case SPI_XFER_BEGIN | SPI_XFER_END:
len = data_len;
- buffer = (unsigned char *)malloc(len * 2);
+ buffer = (unsigned char *)malloc(len);
if (!buffer) {
debug("SF: Failed to malloc memory.\n");
return 1;
}
memcpy(buffer, data_out, len);
- rx_offset = len;
+ rx_offset = 0;
cmd_len = 0;
break;
}
@@ -275,7 +275,7 @@ int espi_xfer(struct fsl_spi_slave *fsl, uint cs, unsigned int bitlen,
}
}
if (data_in) {
- memcpy(data_in, buffer + rx_offset, tran_len);
+ memcpy(data_in, buffer + 2 * cmd_len, tran_len);
if (*buffer == 0x0b) {
data_in += tran_len;
data_len -= tran_len;
--
2.47.3
next prev parent reply other threads:[~2026-05-06 12:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 12:34 [PATCH v2 00/11] Generic powerpc fixes and NXP board cleanup Michael Walle
2026-05-06 12:34 ` [PATCH v2 01/11] powerpc: fix call to cpu_init_r Michael Walle
2026-05-06 12:34 ` [PATCH v2 02/11] caam: don't write memory at 0 on PPC Michael Walle
2026-05-06 12:34 ` Michael Walle [this message]
2026-05-06 12:34 ` [PATCH v2 04/11] boards: remove dead fman code Michael Walle
2026-05-06 12:34 ` [PATCH v2 05/11] boards/nxp: remove board_eth_init() Michael Walle
2026-05-06 12:34 ` [PATCH v2 06/11] boards/nxp: remove empty fdt_fixup_board_enet() Michael Walle
2026-05-06 12:34 ` [PATCH v2 07/11] p2041rdb: use the upstream device tree Michael Walle
2026-05-06 12:34 ` [PATCH v2 08/11] p2041rdb: support SDcard boot Michael Walle
2026-05-06 12:34 ` [PATCH v2 09/11] p2041rdb: update README and fix typos Michael Walle
2026-05-06 12:34 ` [PATCH v2 10/11] p2041rdb: remove NAND defconfig Michael Walle
2026-05-06 12:34 ` [PATCH v2 11/11] p2041rdb: convert README to rst Michael Walle
2026-05-08 12:25 ` Quentin Schulz
2026-05-15 4:30 ` [PATCH v2 00/11] Generic powerpc fixes and NXP board cleanup Peng Fan
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=20260506123507.2081751-4-mwalle@kernel.org \
--to=mwalle@kernel.org \
--cc=Shengzhou.Liu@nxp.com \
--cc=Tsi-Chung.Liew@nxp.com \
--cc=alison.wang@nxp.com \
--cc=andy.tang@nxp.com \
--cc=festevam@gmail.com \
--cc=jerome.forissier@arm.com \
--cc=kabel@kernel.org \
--cc=meenakshi.aggarwal@nxp.com \
--cc=mingkai.hu@nxp.com \
--cc=olteanv@gmail.com \
--cc=peng.fan@nxp.com \
--cc=pramod.kumar_1@nxp.com \
--cc=priyanka.jain@nxp.com \
--cc=sbabic@nabladev.com \
--cc=tomas.alvarez-vanoli@hitachienergy.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=uboot-imx@nxp.com \
--cc=wasim.khan@nxp.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.