All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bin.meng@processmission.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: "Cédric Le Goater" <clg@redhat.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	qemu-block@nongnu.org
Subject: [PATCH v2 01/10] hw/block: m25p80: Fix dummy byte handling for Winbond flash
Date: Tue,  7 Jul 2026 16:34:20 +0800	[thread overview]
Message-ID: <20260707083431.219671-2-bin.meng@processmission.com> (raw)
In-Reply-To: <20260707083431.219671-1-bin.meng@processmission.com>

The m25p80 model uses s->needed_bytes to track how many bytes a
controller must send after an opcode before the flash model can enter
the data phase. For address-bearing commands this includes the address
bytes. For fast-read commands it also includes the dummy phase.

The tricky part is that flash datasheets describe the dummy phase in
clock cycles, while the QEMU SSI interface advances the flash model one
transferred byte at a time. The dummy clock count therefore has to be
converted to the number of SSI bytes that the controller will actually
emit.

Some controllers have drivers that push these dummy bytes into a FIFO.
Other controllers are programmed with a dummy-cycle count and generate
the clocks themselves. The flash model still has to use the same byte
count that a FIFO-style controller or the Linux spi-mem layer would use,
otherwise the model waits too long and drops the first data bytes.

Let's fix the inconsistency from the flash side first. We start from an
easy one, the Winbond flashes.

Per the Windbond W25Q256JV datasheet [1] instruction set table
(chapter 8.1.2, 8.1.3, 8.1.4, 8.1.5), fix the wrong number of
dummy bytes needed for fast read commands.

[1] https://www.winbond.com/resource-files/w25q256jv%20spi%20revb%2009202016.pdf

Fixes: fe8477052831 ("m25p80: Fix QIOR/DIOR handling for Winbond")
Fixes: 3830c7a460b8 ("m25p80: Fix WINBOND fast read command handling")
Fixes: cf6f1efe0b57 ("m25p80: Fast read commands family changes")
Signed-off-by: Bin Meng <bin.meng@processmission.com>
Tested-by: Cédric Le Goater <clg@redhat.com>

---

Changes in v2:
- correct the typo in the commit message: instrunction => instruction

 hw/block/m25p80.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 4a4cda6602..59ecb32c0a 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -1004,7 +1004,7 @@ static void decode_fast_read_cmd(Flash *s)
         s->needed_bytes += 1;
         break;
     case MAN_WINBOND:
-        s->needed_bytes += 8;
+        s->needed_bytes += 1;
         break;
     case MAN_NUMONYX:
         s->needed_bytes += numonyx_extract_cfg_num_dummies(s);
@@ -1099,7 +1099,7 @@ static void decode_qio_read_cmd(Flash *s)
     switch (get_man(s)) {
     case MAN_WINBOND:
         s->needed_bytes += WINBOND_CONTINUOUS_READ_MODE_CMD_LEN;
-        s->needed_bytes += 4;
+        s->needed_bytes += 2;
         break;
     case MAN_SPANSION:
         s->needed_bytes += SPANSION_CONTINUOUS_READ_MODE_CMD_LEN;
-- 
2.53.0



  reply	other threads:[~2026-07-07  8:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  8:34 [PATCH v2 00/10] hw/{block, ssi}: Fix spi-nor flash dummy byte handling Bin Meng via qemu development
2026-07-07  8:34 ` Bin Meng via
2026-07-07  8:34 ` Bin Meng [this message]
2026-07-07  8:34 ` [PATCH v2 02/10] hw/block: m25p80: Fix dummy byte handling for Numonyx/Micron flash Bin Meng
2026-07-07  8:34 ` [PATCH v2 03/10] hw/block: m25p80: Fix dummy byte handling for Macronix flash Bin Meng
2026-07-07  8:34 ` [PATCH v2 04/10] hw/block: m25p80: Fix dummy byte handling for Spansion flash Bin Meng
2026-07-07 12:34   ` Philippe Mathieu-Daudé
2026-07-07 12:51     ` Cédric Le Goater
2026-07-07 14:00       ` Philippe Mathieu-Daudé
2026-07-07 14:05       ` Cédric Le Goater
2026-07-07 14:26         ` Cédric Le Goater
2026-07-07 14:49           ` Bin Meng
2026-07-07 15:05           ` Philippe Mathieu-Daudé
2026-07-07  8:34 ` [PATCH v2 05/10] hw/ssi: npcm7xx_fiu: Correct the dummy cycle emulation logic Bin Meng
2026-07-07  8:34 ` [PATCH v2 06/10] hw/ssi: xilinx_spips: Fix dummy phase handling Bin Meng
2026-07-07  8:34 ` [PATCH v2 07/10] hw/ssi: aspeed_smc: Fix direct-read dummy bytes Bin Meng
2026-07-07  8:34 ` [PATCH v2 08/10] Revert "aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command" Bin Meng
2026-07-07  8:34 ` [PATCH v2 09/10] Revert "aspeed/smc: snoop SPI transfers to fake dummy cycles" Bin Meng
2026-07-07  8:34 ` [PATCH v2 10/10] docs/devel: Document SSI dummy-cycle ownership Bin Meng
2026-07-07 13:10   ` Philippe Mathieu-Daudé
2026-07-07  9:11 ` [PATCH v2 00/10] hw/{block,ssi}: Fix spi-nor flash dummy byte handling Cédric Le Goater

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=20260707083431.219671-2-bin.meng@processmission.com \
    --to=bin.meng@processmission.com \
    --cc=alistair@alistair23.me \
    --cc=clg@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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.