qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] hw/pflash: fix block write start
@ 2024-05-15  8:43 Gerd Hoffmann
  2024-05-15  9:37 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Gerd Hoffmann @ 2024-05-15  8:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé,
	Kevin Wolf, Hanna Reitz, qemu-block, Gerd Hoffmann

Move the pflash_blk_write_start() call.  We need the offset of the
first data write, not the offset for the setup (number-of-bytes)
write.  Without this fix u-boot can do block writes to the first
flash block only.

While being at it drop a leftover FIXME.

Resolves: #2343
Fixes: fcc79f2e0955 ("hw/pflash: implement update buffer for block writes")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/block/pflash_cfi01.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 1bda8424b907..c8f1cf5a8722 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -518,10 +518,6 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
             break;
         case 0xe8: /* Write to buffer */
             trace_pflash_write(pfl->name, "write to buffer");
-            /* FIXME should save @offset, @width for case 1+ */
-            qemu_log_mask(LOG_UNIMP,
-                          "%s: Write to buffer emulation is flawed\n",
-                          __func__);
             pfl->status |= 0x80; /* Ready! */
             break;
         case 0xf0: /* Probe for AMD flash */
@@ -574,7 +570,6 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
             }
             pfl->counter = value;
             pfl->wcycle++;
-            pflash_blk_write_start(pfl, offset);
             break;
         case 0x60:
             if (cmd == 0xd0) {
@@ -605,6 +600,9 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
         switch (pfl->cmd) {
         case 0xe8: /* Block write */
             /* FIXME check @offset, @width */
+            if (pfl->blk_offset == -1 && pfl->counter) {
+                pflash_blk_write_start(pfl, offset);
+            }
             if (!pfl->ro && (pfl->blk_offset != -1)) {
                 pflash_data_write(pfl, offset, value, width, be);
             } else {
-- 
2.45.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] hw/pflash: fix block write start
  2024-05-15  8:43 [PATCH v3] hw/pflash: fix block write start Gerd Hoffmann
@ 2024-05-15  9:37 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-15  9:37 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel; +Cc: Kevin Wolf, Hanna Reitz, qemu-block

On 15/5/24 10:43, Gerd Hoffmann wrote:
> Move the pflash_blk_write_start() call.  We need the offset of the
> first data write, not the offset for the setup (number-of-bytes)
> write.  Without this fix u-boot can do block writes to the first
> flash block only.

Wow, that is a fast fix :) Thanks!

> While being at it drop a leftover FIXME.
> 
> Resolves: #2343
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2343

I suppose we also need:
Cc: qemu-stable@nongnu.org

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> Fixes: fcc79f2e0955 ("hw/pflash: implement update buffer for block writes")
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   hw/block/pflash_cfi01.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-15  9:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15  8:43 [PATCH v3] hw/pflash: fix block write start Gerd Hoffmann
2024-05-15  9:37 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).