{"id":2230164,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230164/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260429121816.1026326-4-mwalle@kernel.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.1/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260429121816.1026326-4-mwalle@kernel.org>","date":"2026-04-29T12:17:17","name":"[03/10] spi: fsl_espi: fix read transactions","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"77b5d217b8f8711a3f08b8ae26008432592d52ba","submitter":{"id":86646,"url":"http://patchwork.ozlabs.org/api/1.1/people/86646/?format=json","name":"Michael Walle","email":"mwalle@kernel.org"},"delegate":{"id":55230,"url":"http://patchwork.ozlabs.org/api/1.1/users/55230/?format=json","username":"freenix","first_name":"Peng","last_name":"Fan","email":"van.freenix@gmail.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260429121816.1026326-4-mwalle@kernel.org/mbox/","series":[{"id":502047,"url":"http://patchwork.ozlabs.org/api/1.1/series/502047/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=502047","date":"2026-04-29T12:17:14","name":"Generic powerpc fixes and NXP board cleanup","version":1,"mbox":"http://patchwork.ozlabs.org/series/502047/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230164/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230164/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=RUIvg07w;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.b=\"RUIvg07w\";\n\tdkim-atps=neutral","phobos.denx.de; dmarc=pass (p=quarantine dis=none)\n header.from=kernel.org","phobos.denx.de;\n spf=pass smtp.mailfrom=mwalle@kernel.org"],"Received":["from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5GYz3v3lz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 22:19:03 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 5916084857;\n\tWed, 29 Apr 2026 14:18:45 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id D709B84862; Wed, 29 Apr 2026 14:18:44 +0200 (CEST)","from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id E0E8F84847\n for <u-boot@lists.denx.de>; Wed, 29 Apr 2026 14:18:42 +0200 (CEST)","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n by tor.source.kernel.org (Postfix) with ESMTP id 00BF960128;\n Wed, 29 Apr 2026 12:18:42 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id D15C1C4AF0F;\n Wed, 29 Apr 2026 12:18:37 +0000 (UTC)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n s=k20201202; t=1777465121;\n bh=NF4ioLgIPecSP9IKJC04sirPsPoOo5mF6AgbVlqK7cM=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=RUIvg07w8nPoKKVt6OUmJBw6oXOWWS+E/bf3jGZ52lEh0pCABWJ9POKCaT1ygul2P\n wCc8bIHTGs5RIgwzeuE/VsrzuMs7ZGVBzP2g2OoooU71KDhZKqBlAAnv2+9jxd5swD\n QG9r7LBWBj3q+E14ZpNwYOL1CvKA1mnAQWDqrY4/LT+zCTGhtb+DDJrQx11b6CTZo+\n 19X+Walh6y4e/UYnTb+ELoemI9FFhsf+OVkGttF88GGOEF6pRx5gma5C9FsLSrsLl6\n ohgA87D0LN8KYzS4oPC3OLvtmniV9M7rtZAdqCvG3atslRbU+7Un7TmwexWVOnFt4k\n tZLg98Fz2EF+Q==","From":"Michael Walle <mwalle@kernel.org>","To":"=?utf-8?q?Marek_Beh=C3=BAn?= <kabel@kernel.org>,\n Tom Rini <trini@konsulko.com>, Pramod Kumar <pramod.kumar_1@nxp.com>,\n Vladimir Oltean <olteanv@gmail.com>, Alison Wang <alison.wang@nxp.com>,\n Tang Yuantian <andy.tang@nxp.com>, Mingkai Hu <mingkai.hu@nxp.com>,\n Priyanka Jain <priyanka.jain@nxp.com>, Wasim Khan <wasim.khan@nxp.com>,\n Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>,\n TsiChung Liew <Tsi-Chung.Liew@nxp.com>, Stefano Babic <sbabic@nabladev.com>,\n Fabio Estevam <festevam@gmail.com>,\n \"NXP i . MX U-Boot Team\" <uboot-imx@nxp.com>, Peng Fan <peng.fan@nxp.com>,\n Shengzhou Liu <Shengzhou.Liu@nxp.com>","Cc":"Tomas Alvarez Vanoli <tomas.alvarez-vanoli@hitachienergy.com>,\n Jerome Forissier <jerome.forissier@arm.com>, u-boot@lists.denx.de,\n Michael Walle <mwalle@kernel.org>","Subject":"[PATCH 03/10] spi: fsl_espi: fix read transactions","Date":"Wed, 29 Apr 2026 14:17:17 +0200","Message-ID":"<20260429121816.1026326-4-mwalle@kernel.org>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20260429121816.1026326-1-mwalle@kernel.org>","References":"<20260429121816.1026326-1-mwalle@kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"Since commit 7917c2e35604 (\"spi: fsl_espi: fix din offset\") MTD is\nbasically broken because any read transaction will get wrong data. While\nthe commit in question will fix simple transfers (where both\nSPI_XFER_BEGIN and SPI_XFER_END is set), it will break the most common\ncase, where opcode and address is send first and then data comes as a\nsecond transfer.\n\nThis basically reverts commit 7917c2e35604 (\"spi: fsl_espi: fix din\noffset\") and make the fix particular for this simple case. Instead of\nproviding two buffers for reading and writing, just malloc one which is\nused for both. This will work because the data is first written on the\nSPI bus and then it will be read (and overwite the written data) into\nthe same buffer.\n\nSuggested-by: Tomas Alvarez Vanoli <tomas.alvarez-vanoli@hitachienergy.com>\nFixes: 7917c2e35604 (\"spi: fsl_espi: fix din offset\")\nSigned-off-by: Michael Walle <mwalle@kernel.org>\n---\n drivers/spi/fsl_espi.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)","diff":"diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c\nindex 117e36376b7..c5bc603b5c0 100644\n--- a/drivers/spi/fsl_espi.c\n+++ b/drivers/spi/fsl_espi.c\n@@ -216,13 +216,13 @@ int espi_xfer(struct fsl_spi_slave *fsl,  uint cs, unsigned int bitlen,\n \t\tbreak;\n \tcase SPI_XFER_BEGIN | SPI_XFER_END:\n \t\tlen = data_len;\n-\t\tbuffer = (unsigned char *)malloc(len * 2);\n+\t\tbuffer = (unsigned char *)malloc(len);\n \t\tif (!buffer) {\n \t\t\tdebug(\"SF: Failed to malloc memory.\\n\");\n \t\t\treturn 1;\n \t\t}\n \t\tmemcpy(buffer, data_out, len);\n-\t\trx_offset = len;\n+\t\trx_offset = 0;\n \t\tcmd_len = 0;\n \t\tbreak;\n \t}\n@@ -275,7 +275,7 @@ int espi_xfer(struct fsl_spi_slave *fsl,  uint cs, unsigned int bitlen,\n \t\t\t}\n \t\t}\n \t\tif (data_in) {\n-\t\t\tmemcpy(data_in, buffer + rx_offset, tran_len);\n+\t\t\tmemcpy(data_in, buffer + 2 * cmd_len, tran_len);\n \t\t\tif (*buffer == 0x0b) {\n \t\t\t\tdata_in += tran_len;\n \t\t\t\tdata_len -= tran_len;\n","prefixes":["03/10"]}