All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Subject: [PULL 10/33] esp: ensure PDMA write transfers are flushed from the FIFO to the target immediately
Date: Tue, 15 Jun 2021 15:38:32 +0200	[thread overview]
Message-ID: <20210615133855.775687-11-pbonzini@redhat.com> (raw)
In-Reply-To: <20210615133855.775687-1-pbonzini@redhat.com>

From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

After each PDMA write transfer the MacOS CDROM driver waits until the FIFO is empty
(i.e. its contents have been written out to the SCSI bus) by polling the FIFO count
register until it reads 0. This doesn't work with the current PDMA write
implementation which waits until either the FIFO is full or the transfer is complete
before invoking the PDMA callback to process the FIFO contents.

Change the PDMA write transfer logic so that the PDMA callback is invoked after each
PDMA write to transfer the FIFO contents to the target buffer immediately, and hence
avoid getting stuck in the FIFO count register polling loop.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20210519100803.10293-4-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/esp.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index a0dab319f2..8e314ef156 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -338,9 +338,9 @@ static void do_cmd(ESPState *s)
 
 static void satn_pdma_cb(ESPState *s)
 {
-    s->do_cmd = 0;
-    if (!fifo8_is_empty(&s->cmdfifo)) {
+    if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) {
         s->cmdfifo_cdb_offset = 1;
+        s->do_cmd = 0;
         do_cmd(s);
     }
 }
@@ -369,12 +369,9 @@ static void handle_satn(ESPState *s)
 
 static void s_without_satn_pdma_cb(ESPState *s)
 {
-    uint32_t len;
-
-    s->do_cmd = 0;
-    len = fifo8_num_used(&s->cmdfifo);
-    if (len) {
+    if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) {
         s->cmdfifo_cdb_offset = 0;
+        s->do_cmd = 0;
         do_busid_cmd(s, 0);
     }
 }
@@ -403,8 +400,7 @@ static void handle_s_without_atn(ESPState *s)
 
 static void satn_stop_pdma_cb(ESPState *s)
 {
-    s->do_cmd = 0;
-    if (!fifo8_is_empty(&s->cmdfifo)) {
+    if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) {
         trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo));
         s->do_cmd = 1;
         s->cmdfifo_cdb_offset = 1;
@@ -493,6 +489,11 @@ static void do_dma_pdma_cb(ESPState *s)
     uint32_t n;
 
     if (s->do_cmd) {
+        /* Ensure we have received complete command after SATN and stop */
+        if (esp_get_tc(s) || fifo8_is_empty(&s->cmdfifo)) {
+            return;
+        }
+
         s->ti_size = 0;
         s->do_cmd = 0;
         do_cmd(s);
@@ -1220,7 +1221,6 @@ static void sysbus_esp_pdma_write(void *opaque, hwaddr addr,
 {
     SysBusESPState *sysbus = opaque;
     ESPState *s = ESP(&sysbus->esp);
-    uint32_t dmalen;
 
     trace_esp_pdma_write(size);
 
@@ -1233,10 +1233,7 @@ static void sysbus_esp_pdma_write(void *opaque, hwaddr addr,
         esp_pdma_write(s, val);
         break;
     }
-    dmalen = esp_get_tc(s);
-    if (dmalen == 0 || fifo8_num_free(&s->fifo) < 2) {
-        s->pdma_cb(s);
-    }
+    s->pdma_cb(s);
 }
 
 static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr addr,
-- 
2.31.1




  parent reply	other threads:[~2021-06-15 13:52 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 13:38 [PULL 00/33] Misc patches for 2021-06-15 Paolo Bonzini
2021-06-15 13:38 ` [PULL 01/33] vnc: avoid deprecation warnings for SASL on OS X Paolo Bonzini
2021-06-15 13:38 ` [PULL 02/33] vl: Fix an assert failure in error path Paolo Bonzini
2021-06-15 13:38 ` [PULL 03/33] qemu-config: use qemu_opts_from_qdict Paolo Bonzini
2021-06-15 13:38 ` [PULL 04/33] block/scsi: correctly emulate the VPD block limits page Paolo Bonzini
2021-06-15 13:38 ` [PULL 05/33] runstate: Initialize Error * to NULL Paolo Bonzini
2021-06-15 13:38 ` [PULL 06/33] esp: only assert INTR_DC interrupt flag if selection fails Paolo Bonzini
2021-06-15 13:38 ` [PULL 07/33] esp: only set ESP_RSEQ at the start of the select sequence Paolo Bonzini
2021-06-15 13:38 ` [PULL 08/33] esp: allow non-DMA callback in esp_transfer_data() initial transfer Paolo Bonzini
2021-06-15 13:38 ` [PULL 09/33] esp: handle non-DMA transfers from the target one byte at a time Paolo Bonzini
2021-06-15 13:38 ` Paolo Bonzini [this message]
2021-06-15 13:38 ` [PULL 11/33] esp: revert 75ef849696 "esp: correctly fill bus id with requested lun" Paolo Bonzini
2021-06-15 13:38 ` [PULL 12/33] esp: correctly accumulate extended messages for PDMA Paolo Bonzini
2021-06-15 13:38 ` [PULL 13/33] esp: fix migration version check in esp_is_version_5() Paolo Bonzini
2021-06-15 13:38 ` [PULL 14/33] esp: store lun coming from the MESSAGE OUT phase Paolo Bonzini
2021-06-15 13:38 ` [PULL 15/33] softmmu/physmem: Mark shared anonymous memory RAM_SHARED Paolo Bonzini
2021-06-15 13:38 ` [PULL 16/33] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory Paolo Bonzini
2021-06-15 13:38 ` [PULL 17/33] softmmu/physmem: Fix qemu_ram_remap() " Paolo Bonzini
2021-06-15 13:38 ` [PULL 18/33] util/mmap-alloc: Factor out calculation of the pagesize for the guard page Paolo Bonzini
2021-06-15 13:38 ` [PULL 19/33] util/mmap-alloc: Factor out reserving of a memory region to mmap_reserve() Paolo Bonzini
2021-06-15 13:38 ` [PULL 20/33] util/mmap-alloc: Factor out activating of memory to mmap_activate() Paolo Bonzini
2021-06-15 13:38 ` [PULL 21/33] softmmu/memory: Pass ram_flags to qemu_ram_alloc_from_fd() Paolo Bonzini
2021-06-15 13:38 ` [PULL 22/33] softmmu/memory: Pass ram_flags to memory_region_init_ram_shared_nomigrate() Paolo Bonzini
2021-06-15 13:38 ` [PULL 23/33] softmmu/memory: Pass ram_flags to qemu_ram_alloc() and qemu_ram_alloc_internal() Paolo Bonzini
2021-06-15 13:38 ` [PULL 24/33] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap() Paolo Bonzini
2021-06-15 13:38 ` [PULL 25/33] memory: Introduce RAM_NORESERVE and wire it up in qemu_ram_mmap() Paolo Bonzini
2021-06-15 13:38 ` [PULL 26/33] util/mmap-alloc: Support RAM_NORESERVE via MAP_NORESERVE under Linux Paolo Bonzini
2021-06-15 13:38 ` [PULL 27/33] hostmem: Wire up RAM_NORESERVE via "reserve" property Paolo Bonzini
2021-06-15 13:38 ` [PULL 28/33] qmp: Clarify memory backend properties returned via query-memdev Paolo Bonzini
2021-06-15 13:38 ` [PULL 29/33] qmp: Include "share" property of memory backends Paolo Bonzini
2021-06-15 13:38 ` [PULL 30/33] hmp: Print "share" property of memory backends with "info memdev" Paolo Bonzini
2021-06-15 13:38 ` [PULL 31/33] qmp: Include "reserve" property of memory backends Paolo Bonzini
2021-06-15 13:38 ` [PULL 32/33] hmp: Print "reserve" property of memory backends with "info memdev" Paolo Bonzini
2021-06-15 13:38 ` [PULL 33/33] configure: map x32 to cpu_family x86_64 for meson Paolo Bonzini
2021-06-15 14:17 ` [PULL 00/33] Misc patches for 2021-06-15 Peter Maydell
2021-06-15 16:52   ` Philippe Mathieu-Daudé
2021-06-17 10:06     ` Alex Bennée
2021-06-17 12:55       ` Paolo Bonzini
2021-06-17 15:34       ` Thomas Huth

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=20210615133855.775687-11-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --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.