qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sven Schnelle <svens@stackframe.org>
To: John Snow <jsnow@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Sven Schnelle <svens@stackframe.org>,
	qemu-devel@nongnu.org, "open list:Floppy" <qemu-block@nongnu.org>,
	Max Reitz <mreitz@redhat.com>
Subject: [PATCH] fdc: support READ command with VERIFY DMA mode
Date: Sun, 20 Oct 2019 08:38:00 +0200	[thread overview]
Message-ID: <20191020063800.29208-1-svens@stackframe.org> (raw)

While working on the Tulip driver i tried to write some Teledisk images to
a floppy image which didn't work. Turned out that Teledisk checks the written
data by issuing a READ command to the FDC but running the DMA controller
in VERIFY mode. As we ignored the DMA request in that case, the DMA transfer
never finished, and Teledisk reported an error.

Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
 hw/block/fdc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index ac5d31e8c1..8a1228df78 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -1733,7 +1733,8 @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction)
             dma_mode_ok = (dma_mode == ISADMA_TRANSFER_WRITE);
             break;
         case FD_DIR_READ:
-            dma_mode_ok = (dma_mode == ISADMA_TRANSFER_READ);
+            dma_mode_ok = (dma_mode == ISADMA_TRANSFER_READ) ||
+                          (dma_mode == ISADMA_TRANSFER_VERIFY);
             break;
         case FD_DIR_VERIFY:
             dma_mode_ok = true;
@@ -1835,8 +1836,11 @@ static int fdctrl_transfer_handler (void *opaque, int nchan,
         switch (fdctrl->data_dir) {
         case FD_DIR_READ:
             /* READ commands */
-            k->write_memory(fdctrl->dma, nchan, fdctrl->fifo + rel_pos,
-                            fdctrl->data_pos, len);
+            if (k->get_transfer_mode(fdctrl->dma, fdctrl->dma_chann) !=
+                ISADMA_TRANSFER_VERIFY) {
+                k->write_memory(fdctrl->dma, nchan, fdctrl->fifo + rel_pos,
+                        fdctrl->data_pos, len);
+            }
             break;
         case FD_DIR_WRITE:
             /* WRITE commands */
-- 
2.23.0



             reply	other threads:[~2019-10-20  6:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-20  6:38 Sven Schnelle [this message]
2019-10-29 11:00 ` [PATCH] fdc: support READ command with VERIFY DMA mode John Snow
2019-10-29 19:10   ` Hervé Poussineau

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=20191020063800.29208-1-svens@stackframe.org \
    --to=svens@stackframe.org \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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 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).