[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/88] esp: move buffer and TC logic into separate to/from device
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 10/88] esp: move buffer and TC logic into separate to/from device paths in esp_do_dma() |
Date: |
Fri, 12 Jan 2024 12:53:02 +0000 |
The ultimate aim is to for esp_do_dma() behaviour to be determined by the SCSI
bus phase, in which case it is necessary to have separate to/from device paths.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 65 +++++++++++++++++++++++++++++++--------------------
1 file changed, 40 insertions(+), 25 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 63c828c1b2..9893840255 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -678,14 +678,53 @@ static void esp_do_dma(ESPState *s)
if (to_device) {
if (s->dma_memory_read) {
s->dma_memory_read(s->dma_opaque, s->async_buf, len);
+
+ esp_set_tc(s, esp_get_tc(s) - len);
+ s->async_buf += len;
+ s->async_len -= len;
+ s->ti_size += len;
+
+ if (s->async_len == 0) {
+ scsi_req_continue(s->current_req);
+ /*
+ * If there is still data to be read from the device then
+ * complete the DMA operation immediately. Otherwise defer
+ * until the scsi layer has completed.
+ */
+ return;
+ }
+
+ /* Partially filled a scsi buffer. Complete immediately. */
+ esp_dma_done(s);
+ esp_lower_drq(s);
} else {
esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
esp_raise_drq(s);
- return;
}
} else {
if (s->dma_memory_write) {
s->dma_memory_write(s->dma_opaque, s->async_buf, len);
+
+ esp_set_tc(s, esp_get_tc(s) - len);
+ s->async_buf += len;
+ s->async_len -= len;
+ s->ti_size -= len;
+
+ if (s->async_len == 0) {
+ scsi_req_continue(s->current_req);
+ /*
+ * If there is still data to be read from the device then
+ * complete the DMA operation immediately. Otherwise defer
+ * until the scsi layer has completed.
+ */
+ if (esp_get_tc(s) != 0 || s->ti_size == 0) {
+ return;
+ }
+ }
+
+ /* Partially filled a scsi buffer. Complete immediately. */
+ esp_dma_done(s);
+ esp_lower_drq(s);
} else {
/* Adjust TC for any leftover data in the FIFO */
if (!fifo8_is_empty(&s->fifo)) {
@@ -713,32 +752,8 @@ static void esp_do_dma(ESPState *s)
esp_set_tc(s, esp_get_tc(s) - len);
esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
esp_raise_drq(s);
- return;
}
}
- esp_set_tc(s, esp_get_tc(s) - len);
- s->async_buf += len;
- s->async_len -= len;
- if (to_device) {
- s->ti_size += len;
- } else {
- s->ti_size -= len;
- }
- if (s->async_len == 0) {
- scsi_req_continue(s->current_req);
- /*
- * If there is still data to be read from the device then
- * complete the DMA operation immediately. Otherwise defer
- * until the scsi layer has completed.
- */
- if (to_device || esp_get_tc(s) != 0 || s->ti_size == 0) {
- return;
- }
- }
-
- /* Partially filled a scsi buffer. Complete immediately. */
- esp_dma_done(s);
- esp_lower_drq(s);
}
static void esp_do_nodma(ESPState *s)
--
2.39.2
- [PATCH 02/88] esp: move existing request cancel check into esp_select(), (continued)
- [PATCH 02/88] esp: move existing request cancel check into esp_select(), Mark Cave-Ayland, 2024/01/12
- [PATCH 04/88] esp: remove FIFO clear from esp_select(), Mark Cave-Ayland, 2024/01/12
- [PATCH 06/88] esp: update esp_set_tc() to set STAT_TC flag, Mark Cave-Ayland, 2024/01/12
- [PATCH 05/88] esp: move esp_select() to ESP selection commands from get_cmd(), Mark Cave-Ayland, 2024/01/12
- [PATCH 01/88] esp: don't clear cmdfifo when esp_select() fails in get_cmd(), Mark Cave-Ayland, 2024/01/12
- [PATCH 03/88] esp.c: add FIFO wraparound support to esp_fifo_pop_buf(), Mark Cave-Ayland, 2024/01/12
- [PATCH 07/88] esp: start removal of manual STAT_TC setting when transfer counter reaches zero, Mark Cave-Ayland, 2024/01/12
- [PATCH 08/88] esp: move command execution logic to new esp_run_cmd() function, Mark Cave-Ayland, 2024/01/12
- [PATCH 09/88] esp: update TC check logic in do_dma_pdma_cb() to check for TC == 0, Mark Cave-Ayland, 2024/01/12
- [PATCH 10/88] esp: move buffer and TC logic into separate to/from device paths in esp_do_dma(),
Mark Cave-Ayland <=
- [PATCH 11/88] esp.c: remove unused case from esp_pdma_read(), Mark Cave-Ayland, 2024/01/12
- [PATCH 12/88] esp.c: don't accumulate directly into cmdfifo, Mark Cave-Ayland, 2024/01/12
- [PATCH 13/88] esp.c: decrement the TC during MESSAGE OUT and COMMAND phases, Mark Cave-Ayland, 2024/01/12
- [PATCH 14/88] esp.c: introduce esp_set_phase() helper function, Mark Cave-Ayland, 2024/01/12
- [PATCH 15/88] esp.c: remove another set of manual STAT_TC updates, Mark Cave-Ayland, 2024/01/12
- [PATCH 16/88] esp.c: remove MacOS TI workaround that pads FIFO transfers to ESP_FIFO_SZ, Mark Cave-Ayland, 2024/01/12
- [PATCH 17/88] esp.c: don't reset the TC and ESP_RSEQ state when executing a SCSI command, Mark Cave-Ayland, 2024/01/12
- [PATCH 19/88] esp: remove zero transfer size check from esp_do_dma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 18/88] esp.c: don't clear RFLAGS register when DMA is complete, Mark Cave-Ayland, 2024/01/12
- [PATCH 20/88] esp.c: update condition for esp_dma_done() in esp_do_dma() from device path, Mark Cave-Ayland, 2024/01/12