From: Thomas Huth <thuth@redhat.com>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org,
laurent@vivier.eu, qemu-devel@nongnu.org
Subject: Re: [PATCH 00/88] esp: rework ESP emulation to use a SCSI phase-based state machine
Date: Thu, 25 Jan 2024 09:53:14 +0100 [thread overview]
Message-ID: <64cbc494-0379-494e-93b9-e7f6b140da09@redhat.com> (raw)
In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk>
On 12/01/2024 13.52, Mark Cave-Ayland wrote:
> The ESP SCSI chip fundamentally consists of a FIFO for transferring data to/from
> the SCSI bus along with a command sequencer which automates various processes such
> as selection, message/command transfer and data transfer. What makes this chip
> particularly interesting is that the FIFO is also used as a buffer for DMA transfers
> which makes it possible to mix and match DMA and non-DMA transfers when sending and
> receiving data to/from the SCSI bus.
>
> Whilst the current ESP emulation works well for most cases, there are several
> problems that I've encountered whilst trying to debug various guest issues:
>
>
> 1) Multiple code paths for non-DMA, DMA and pDMA
>
> Consider a SCSI request being submitted by the guest: if it is a DMA SCSI
> request then it takes one path through get_cmd(), and a different path through
> get_cmd() for pDMA. This then leads to the DMA code path being called for DMA
> and the pDMA codepath being called for each FIFO write. Finally once you add
> in the non-DMA path you end up with a total of 5 potential codepaths for any
> given SCSI request.
>
> 2) Manual handling of STAT_TC flag
>
> According to the datasheet the STAT_TC flag in ESP_RSTAT is set when the DMA
> transfer counter reaches zero. The current code handles this manually in
> multiple places, including where it shouldn't be necessary.
>
> 3) Deferred interrupts are used only for reads and not writes
>
> The ESP emulation currently makes use of a deferred interrupt when submitting
> read commands i.e. the interrupt flags are not updated immediately but when
> the QEMU SCSI layer indicates it is ready. This works well for reads, but isn't
> implemented for writes which can cause problems when the host is heavily loaded
> or a large SCSI write is requested.
>
> 4) Padding of pDMA TI transfers to a minimum of 16 bytes
>
> In order to allow Classic MacOS to boot successfully there is a workaround that
> pads all pDMA TI transfers to a minimum of 16 bytes (see commit 7aa6baee7c
> "esp: add support for unaligned accesses"). This feature is not documented and it
> turns out that this is a symptom of incorrect handling of transfer
> overflow/underflow conditions.
>
> 5) Duplication of some non-DMA logic in esp_reg_read() and esp_reg_write()
>
> When reading and writing to the FIFO there is some duplication of logic from
> esp_do_nodma() in esp_reg_read() and esp_reg_write(). This should be eliminated
> in favour of a single state machine for handling non-DMA FIFO accesses in a
> single place.
>
>
> The series here reworks the ESP emulation to use a SCSI phase-based state machine
> with just two paths: one for DMA/pDMA requests, and another for non-DMA requests.
> The pDMA callbacks are completely removed so that there is now only a single path
> for DMA requests. As part of this work the manual STAT_TC handling is removed, and a
> couple of bugs in the SCSI phase selection are fixed to allow proper transfer
> underflow/overflow detection and recovery.
>
> I've tested the series with all of my available ESP images and compatibility is
> greatly improved with these changes: I believe that this series should also fix a
> few GitLab issues including https://gitlab.com/qemu-project/qemu/-/issues/1831,
> https://gitlab.com/qemu-project/qemu/-/issues/611 and
> https://gitlab.com/qemu-project/qemu/-/issues/1127. In addition it allows Aurelien's
> really old SPARC Linux images to boot once again, and also the NeXTCube machine can
> now boot, load its kernel from disk and start to execute it.
FWIW, I did some sanity checking by installing an old Fedora 12 onto a SCSI
disk attached to the am53c974 and dc390 controllers, and everything still
works fine with your patches. Thus feel free to add:
Tested-by: Thomas Huth <thuth@redhat.com>
prev parent reply other threads:[~2024-01-25 8:53 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 12:52 [PATCH 00/88] esp: rework ESP emulation to use a SCSI phase-based state machine Mark Cave-Ayland
2024-01-12 12:52 ` [PATCH 01/88] esp: don't clear cmdfifo when esp_select() fails in get_cmd() Mark Cave-Ayland
2024-01-14 7:36 ` Helge Deller
2024-01-12 12:52 ` [PATCH 02/88] esp: move existing request cancel check into esp_select() Mark Cave-Ayland
2024-01-12 12:52 ` [PATCH 03/88] esp.c: add FIFO wraparound support to esp_fifo_pop_buf() Mark Cave-Ayland
2024-01-12 12:52 ` [PATCH 04/88] esp: remove FIFO clear from esp_select() Mark Cave-Ayland
2024-01-12 12:52 ` [PATCH 05/88] esp: move esp_select() to ESP selection commands from get_cmd() Mark Cave-Ayland
2024-01-12 12:52 ` [PATCH 06/88] esp: update esp_set_tc() to set STAT_TC flag Mark Cave-Ayland
2024-01-12 12:52 ` [PATCH 07/88] esp: start removal of manual STAT_TC setting when transfer counter reaches zero Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 08/88] esp: move command execution logic to new esp_run_cmd() function Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 09/88] esp: update TC check logic in do_dma_pdma_cb() to check for TC == 0 Mark Cave-Ayland
2024-02-01 10:46 ` Paolo Bonzini
2024-02-01 11:25 ` Mark Cave-Ayland
2024-02-01 11:36 ` Paolo Bonzini
2024-02-08 9:46 ` Mark Cave-Ayland
2024-02-08 18:11 ` Paolo Bonzini
2024-02-09 21:28 ` Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 10/88] esp: move buffer and TC logic into separate to/from device paths in esp_do_dma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 11/88] esp.c: remove unused case from esp_pdma_read() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 12/88] esp.c: don't accumulate directly into cmdfifo Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 13/88] esp.c: decrement the TC during MESSAGE OUT and COMMAND phases Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 14/88] esp.c: introduce esp_set_phase() helper function Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 15/88] esp.c: remove another set of manual STAT_TC updates Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 16/88] esp.c: remove MacOS TI workaround that pads FIFO transfers to ESP_FIFO_SZ Mark Cave-Ayland
2024-01-12 12:53 ` [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 12:53 ` [PATCH 18/88] esp.c: don't clear RFLAGS register when DMA is complete Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 19/88] esp: remove zero transfer size check from esp_do_dma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 20/88] esp.c: update condition for esp_dma_done() in esp_do_dma() from device path Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 21/88] esp.c: update condition for esp_dma_done() in esp_do_dma() to " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 22/88] esp.c: ensure that the PDMA callback is called for every device read Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 23/88] esp.c: don't immediately raise INTR_BS if SCSI data needed in esp_do_dma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 24/88] esp.c: remove TC adjustment in esp_do_dma() from device path Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 25/88] esp.c: remove unaligned adjustment in do_dma_pdma_cb() to " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 26/88] esp.c: remove unneeded if() check in esp_transfer_data() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 27/88] esp.c: update end of transfer logic at the end of esp_transfer_data() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 28/88] esp.c: consolidate async_len and TC == 0 checks in do_dma_pdma_cb() and esp_do_dma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 29/88] esp.c: fix premature end of phase logic esp_command_complete Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 30/88] esp.c: move TC and FIFO check logic into esp_dma_done() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 31/88] esp.c: rename esp_dma_done() to esp_dma_ti_check() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 32/88] esp.c: copy PDMA logic for transfers to device from do_dma_pdma_cb() to esp_do_dma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 33/88] esp.c: copy logic for do_cmd transfers " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 34/88] esp.c: update esp_do_dma() bypass if async_len is zero to include non-zero transfer check Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 35/88] esp.c: move end of SCSI transfer check after TC adjustment in do_dma_pdma_cb() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 36/88] esp.c: remove s_without_satn_pdma_cb() PDMA callback Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 37/88] esp.c: introduce esp_get_phase() function Mark Cave-Ayland
2024-02-13 13:49 ` Philippe Mathieu-Daudé
2024-01-12 12:53 ` [PATCH 38/88] esp.c: convert esp_do_dma() to switch statement based upon SCSI phase Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 39/88] esp.c: convert do_dma_pdma_db() " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 40/88] esp.c: convert esp_do_nodma() " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 41/88] esp.c: convert esp_do_dma() do_cmd path to check for SCSI phase instead Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 42/88] esp.c: convert do_dma_pdma_cb() " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 43/88] esp.c: convert esp_do_nodma() " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 44/88] esp.c: convert esp_reg_write() " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 45/88] esp.c: remove do_cmd from ESPState Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 46/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in esp_do_dma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 47/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in do_dma_pdma_cb() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 48/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in esp_do_nodma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 49/88] esp.c: move CMD_SELATN end of message phase detection to esp_do_dma() and do_dma_pdma_cb() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 50/88] esp.c: move CMD_TI " Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 51/88] esp.c: don't use get_cmd() for CMD_SEL DMA commands Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 52/88] esp.c: move CMD_SELATNS end of command logic to esp_do_dma() and do_dma_pdma_cb() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 53/88] esp.c: replace do_dma_pdma_cb() with esp_do_dma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 54/88] esp.c: move CMD_ICCS command logic to esp_do_dma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 55/88] esp.c: always use esp_do_dma() in pdma_cb() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 56/88] esp.c: remove unused PDMA callback implementation Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 57/88] esp.c: rename data_in_ready to to data_ready Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 58/88] esp.c: separate logic based upon ESP command in esp_command_complete() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 59/88] esp.c: separate logic based upon ESP command in esp_transfer_data() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 60/88] esp.c: use deferred interrupts for both DATA IN and DATA OUT phases Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 61/88] esp.c: remove DATA IN phase logic when reading from FIFO Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 62/88] esp.c: zero command register when TI command terminates due to phase change Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 63/88] esp.c: remove unneeded ti_cmd field Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 64/88] esp.c: don't raise INTR_BS interrupt in DATA IN phase until TI command issued Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 65/88] esp.c: move non-DMA TI logic to separate esp_nodma_ti_dataout() function Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 66/88] esp.c: process non-DMA FIFO writes in esp_do_nodma() Mark Cave-Ayland
2024-01-12 12:53 ` [PATCH 67/88] esp.c: replace get_cmd() with esp_do_nodma() Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 68/88] esp.c: move write_response() non-DMA logic to esp_do_nodma() Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 69/88] esp.c: consolidate end of command sequence after ICCS command Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 70/88] esp.c: ensure that STAT_INT is cleared when reading ESP_RINTR Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 71/88] esp.c: don't clear the SCSI phase " Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 72/88] esp.c: handle TC underflow for DMA SCSI requests Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 73/88] esp.c: remove restriction on FIFO read access when DMA memory routines defined Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 74/88] esp.c: handle non-DMA FIFO writes used to terminate DMA commands Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 75/88] esp.c: improve ESP_RSEQ logic consolidation Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 76/88] esp.c: only transfer non-DMA COMMAND phase data for specific commands Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 77/88] esp.c: only transfer non-DMA MESSAGE OUT " Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 78/88] esp.c: consolidate DMA and PDMA logic in DATA OUT phase Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 79/88] esp.c: consolidate DMA and PDMA logic in DATA IN phase Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 80/88] esp.c: consolidate DMA and PDMA logic in MESSAGE OUT phase Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 81/88] esp.c: remove redundant n variable in PDMA COMMAND phase Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 82/88] esp.c: consolidate DMA and PDMA logic in STATUS and MESSAGE IN phases Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 83/88] esp.c: replace n variable with len in esp_do_nodma() Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 84/88] esp.c: implement DMA Transfer Pad command for DATA phases Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 85/88] esp.c: rename irq_data IRQ to drq_irq Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 86/88] esp.c: keep track of the DRQ state during DMA Mark Cave-Ayland
2024-01-12 12:54 ` [PATCH 87/88] esp.c: switch TypeInfo registration to use DEFINE_TYPES() macro Mark Cave-Ayland
2024-02-13 13:48 ` Philippe Mathieu-Daudé
2024-01-12 12:54 ` [PATCH 88/88] esp.c: add my copyright to the file Mark Cave-Ayland
2024-01-22 12:41 ` [PATCH 00/88] esp: rework ESP emulation to use a SCSI phase-based state machine Mark Cave-Ayland
2024-01-25 8:53 ` Thomas Huth [this message]
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=64cbc494-0379-494e-93b9-e7f6b140da09@redhat.com \
--to=thuth@redhat.com \
--cc=fam@euphon.net \
--cc=hpoussin@reactos.org \
--cc=laurent@vivier.eu \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=pbonzini@redhat.com \
--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).