[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 25/42] esp: remove CMD pdma_origin
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v3 25/42] esp: remove CMD pdma_origin |
Date: |
Thu, 4 Mar 2021 22:10:46 +0000 |
The cmdbuf is really just a copy of FIFO data (including extra message phase
bytes) so its pdma_origin is effectively TI. Fortunately we already know when
we are receiving a SCSI command since do_cmd == 1 which enables us to
distinguish between the two cases in esp_pdma_read()/esp_pdma_write().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
hw/scsi/esp.c | 22 ++++++++++++----------
include/hw/scsi/esp.h | 1 -
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index c80dc606e8..d5c03f9697 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -143,10 +143,11 @@ static uint8_t esp_pdma_read(ESPState *s)
switch (s->pdma_origin) {
case TI:
- val = s->ti_buf[s->ti_rptr++];
- break;
- case CMD:
- val = s->cmdbuf[s->cmdlen++];
+ if (s->do_cmd) {
+ val = s->cmdbuf[s->cmdlen++];
+ } else {
+ val = s->ti_buf[s->ti_rptr++];
+ }
break;
case ASYNC:
val = s->async_buf[0];
@@ -176,10 +177,11 @@ static void esp_pdma_write(ESPState *s, uint8_t val)
switch (s->pdma_origin) {
case TI:
- s->ti_buf[s->ti_wptr++] = val;
- break;
- case CMD:
- s->cmdbuf[s->cmdlen++] = val;
+ if (s->do_cmd) {
+ s->cmdbuf[s->cmdlen++] = val;
+ } else {
+ s->ti_buf[s->ti_wptr++] = val;
+ }
break;
case ASYNC:
s->async_buf[0] = val;
@@ -240,7 +242,7 @@ static uint32_t get_cmd(ESPState *s)
if (s->dma_memory_read) {
s->dma_memory_read(s->dma_opaque, buf, dmalen);
} else {
- set_pdma(s, CMD);
+ set_pdma(s, TI);
esp_raise_drq(s);
return 0;
}
@@ -471,7 +473,7 @@ static void esp_do_dma(ESPState *s)
if (s->dma_memory_read) {
s->dma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len);
} else {
- set_pdma(s, CMD);
+ set_pdma(s, TI);
s->pdma_cb = do_dma_pdma_cb;
esp_raise_drq(s);
return;
diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h
index 1be4586aff..dbbbb3fc52 100644
--- a/include/hw/scsi/esp.h
+++ b/include/hw/scsi/esp.h
@@ -17,7 +17,6 @@ typedef struct ESPState ESPState;
enum pdma_origin_id {
TI,
- CMD,
ASYNC,
};
--
2.20.1
- [PATCH v3 15/42] esp: introduce esp_pdma_read() and esp_pdma_write() functions, (continued)
- [PATCH v3 15/42] esp: introduce esp_pdma_read() and esp_pdma_write() functions, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 16/42] esp: use pdma_origin directly in esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 17/42] esp: move pdma_len and TC logic into esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 18/42] esp: accumulate SCSI commands for PDMA transfers in cmdbuf instead of pdma_buf, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 19/42] esp: remove buf parameter from do_cmd(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 20/42] esp: remove the buf and buflen parameters from get_cmd(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 21/42] esp: remove redundant pdma_start from ESPState, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 22/42] esp: move PDMA length adjustments into esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 23/42] esp: use ti_wptr/ti_rptr to manage the current FIFO position for PDMA, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 24/42] esp: use in-built TC to determine PDMA transfer length, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 25/42] esp: remove CMD pdma_origin,
Mark Cave-Ayland <=
- [PATCH v3 26/42] esp: rename get_cmd_cb() to esp_select(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 27/42] esp: fix PDMA target selection, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 28/42] esp: use FIFO for PDMA transfers between initiator and device, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 29/42] esp: remove pdma_origin from ESPState, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 30/42] esp: add 4 byte PDMA read and write transfers, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 31/42] esp: implement FIFO flush command, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 32/42] esp: latch individual bits in ESP_RINTR register, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 33/42] esp: defer command completion interrupt on incoming data transfers, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 34/42] esp: remove old deferred command completion mechanism, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 35/42] esp: raise interrupt after every non-DMA byte transferred to the FIFO, Mark Cave-Ayland, 2021/03/04