Mark Cave-Ayland
1454dc765b
esp.c: convert esp_do_dma() to switch statement based upon SCSI phase
...
Currently only the DATA IN and DATA OUT phases are supported.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-39-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:28 +00:00
Mark Cave-Ayland
5a83e83e1c
esp.c: introduce esp_get_phase() function
...
Make use of this new function in all places where the SCSI phase bits are
manually masked from the ESP_RSTAT register.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Message-Id: <20240112125420.514425-38-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:28 +00:00
Mark Cave-Ayland
66fd565733
esp.c: remove s_without_satn_pdma_cb() PDMA callback
...
This can now be handled by the existing do_dma_pdma_cb() function.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-37-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:28 +00:00
Mark Cave-Ayland
1b2e34ca2e
esp.c: move end of SCSI transfer check after TC adjustment in do_dma_pdma_cb()
...
Now it is possible to move the end of SCSI transfer check to after the TC
adjustment in do_dma_pdma_cb() when transferring data from the device
without triggering an assert() in the SCSI code. This brings this check in
line with all the others in esp_do_dma() and do_dma_pdma_cb().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-36-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
4460b86a04
esp.c: update esp_do_dma() bypass if async_len is zero to include non-zero transfer check
...
In the PDMA case the last transfer from the device to the FIFO has occurred
(async_len is zero) but esp_do_dma() is still being called to drain the
remaining FIFO contents.
The additional non-zero transfer check ensures that we still defer the SCSI
layer in the case where we are waiting for data for a TI command or a DMA
enable signal.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-35-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
3c7f3c8b57
esp.c: copy logic for do_cmd transfers from do_dma_pdma_cb() to esp_do_dma()
...
This is so that PDMA transfers can be performend by esp_do_dma() as well as
do_dma_pdma_cb().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-34-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
19e9afb1a3
esp.c: copy PDMA logic for transfers to device from do_dma_pdma_cb() to esp_do_dma()
...
This is so that PDMA transfers can be performend by esp_do_dma() as well as
do_dma_pdma_cb().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-33-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
004826d03e
esp.c: rename esp_dma_done() to esp_dma_ti_check()
...
This is because a single DMA request can be transferred using multiple TI
commands, and so a TC equal to zero may not represent the completion of
the SCSI DMA command.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-32-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
af74b3c15d
esp.c: move TC and FIFO check logic into esp_dma_done()
...
This helps simplify the existing implementation.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-31-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
cb9881999d
esp.c: fix premature end of phase logic esp_command_complete
...
There are two cases here: the first is when the TI command underflows, in which
case we raise INTR_BS to indicate an early change of phase, and the second is
when the TI command overflows because the host requested a transfer for more
data than is available. In the latter case force TC to zero so that the TI
completion logic executes correctly.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-30-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
e4e166c8ef
esp.c: consolidate async_len and TC == 0 checks in do_dma_pdma_cb() and esp_do_dma()
...
Ensure that the async_len checks for requesting data from the SCSI layer and
the TC == 0 checks to detect the end of the DMA transfer are consistent in both
do_dma_pdma_cb() and esp_do_dma(). In particular this involves adding the check
to see if the FIFO is at its low threshold since PDMA and mixed DMA and non-DMA
requests can leave data remaining in the FIFO.
At the same time update all the comments so that they are also consistent between
all similar code paths.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-29-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
a79e767ab1
esp.c: update end of transfer logic at the end of esp_transfer_data()
...
Since esp_dma_done() is called in both cases, and ti_size cannot be zero
(otherwise esp_command_complete() would have been called instead), replace
the conditional logic with a single call to esp_dma_done().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-28-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
fe082b5475
esp.c: remove unneeded if() check in esp_transfer_data()
...
The following ti_cmd checks ensure that only DMA and non-DMA TI commmands will
can call into the esp_do_dma() and esp_do_nodma() callbacks.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-27-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
81ed2ed3e8
esp.c: remove unaligned adjustment in do_dma_pdma_cb() to device path
...
With the latest changes this condition cannot occur anymore and so the logic
can be completely removed.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-26-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
12486e4f6d
esp.c: remove TC adjustment in esp_do_dma() from device path
...
Now that the TC is updated for each PDMA access (rather than once the FIFO is
full) there is no need to adjust the TC at start of each DMA transfer if the
FIFO is not empty.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-25-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
fabcba4966
esp.c: don't immediately raise INTR_BS if SCSI data needed in esp_do_dma()
...
In the case when more data is requested from the SCSI layer during a DMA data
transfer from a device, don't immediately fall through to the TC check logic.
Otherwise when TC is zero INTR_BS will be raised immediately rather than when
the next set of SCSI data is ready.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-24-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
68ef41fb13
esp.c: ensure that the PDMA callback is called for every device read
...
Rather than wait for the FIFO to fill up before calling the PDMA callback, push
that logic directly into the from_device logic in do_dma_pdma_cb().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-23-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
c5bd505524
esp.c: update condition for esp_dma_done() in esp_do_dma() to device path
...
Ensure that esp_dma_done() is only called when TC is zero, which is currently
always the case for DMA transfers.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-22-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
6b7b0030fb
esp.c: update condition for esp_dma_done() in esp_do_dma() from device path
...
No change to the condition itself, other than to clarify that esp_dma_done()
must be called when TC is zero.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-21-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:27 +00:00
Mark Cave-Ayland
27bd0cc044
esp.c: remove zero transfer size check from esp_do_dma()
...
The TI end of transfer interrupt only occurs when the TC reaches zero and is
not related to the SCSI layer transfer.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-20-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
942ee6c83f
esp.c: don't clear RFLAGS register when DMA is complete
...
The internal state of the ESP sequencer is not affected when raising an interrupt
to indicate the end of a DMA transfer.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-19-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
e7a661d117
esp.c: don't reset the TC and ESP_RSEQ state when executing a SCSI command
...
There is no need to manually reset these values as the ESP emulation now
correctly handles them within its existing logic.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-18-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
a1ccceb9c4
esp.c: remove MacOS TI workaround that pads FIFO transfers to ESP_FIFO_SZ
...
This workaround is no longer required with the current code and so can be
removed.
[Note: whilst MacOS itself can boot correctly, removing this hack prevents
a bootable EMILE CDROM from working. This is caused by a separate bug which
will be fixed by a subsequent patch]
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-17-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
f0a24eeed9
esp.c: remove another set of manual STAT_TC updates
...
Following on from the recent changes to when the TC is updated, it is now
possible to remove another set of manual STAT_TC updates so that its state
is now managed within esp_set_tc().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-16-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
abc139cda0
esp.c: introduce esp_set_phase() helper function
...
This function is used to set the current SCSI bus phase in the ESP_RSTAT register
without affecting any of flag bits.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-15-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
a034765161
esp.c: decrement the TC during MESSAGE OUT and COMMAND phases
...
This is to ensure that STAT_TC is triggered during the right parts of the
transfer when it is controlled exclusively by the TC.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-14-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
2572689bc8
esp.c: don't accumulate directly into cmdfifo
...
Instead accumulate in the real FIFO as done in real hardware, and then transfer
to cmdfifo when we're ready to process the MESSAGE OUT and COMMAND phase data.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-13-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
5fd4de7604
esp.c: remove unused case from esp_pdma_read()
...
The do_cmd variable is only set for the MESSAGE OUT and COMMAND phases i.e.
those which involve transfers from the host to the SCSI bus, and so the unused
case can be removed.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-12-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:23 +00:00
Mark Cave-Ayland
f366622366
esp.c: move buffer and TC logic into separate to/from device paths in esp_do_dma()
...
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 >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-11-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:20 +00:00
Mark Cave-Ayland
0f2eb11071
esp.c: update TC check logic in do_dma_pdma_cb() to check for TC == 0
...
Invert the logic so that the end of DMA transfer check becomes one that checks
for TC == 0 in the from device path in do_dma_pdma_cb().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-10-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:15 +00:00
Mark Cave-Ayland
f21fe39d9c
esp.c: move command execution logic to new esp_run_cmd() function
...
This helps to simplify esp_reg_write() and potentially allows for a 2-level
deep FIFO to be implemented in future.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-9-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:13 +00:00
Mark Cave-Ayland
0c5ae734c2
esp.c: start removal of manual STAT_TC setting when transfer counter reaches zero
...
This should be exclusively managed by esp_set_tc() rather than being manually
set in multiple places. Start by removing the occurrences exclusive to PDMA
and command completion which are those that can be currently removed without
affecting any test images.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-8-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:11 +00:00
Mark Cave-Ayland
c5d7df28ea
esp.c: update esp_set_tc() to set STAT_TC flag
...
This flag is set once the transfer counter counts down to zero.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-7-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:09 +00:00
Mark Cave-Ayland
1bcaf71b41
esp.c: move esp_select() to ESP selection commands from get_cmd()
...
Since the DREQ value depends upon the result of the selection process, add a
workaround to each esp_select() to manually assert DREQ durring the MESSAGE OUT
and COMMAND phases.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-6-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:06 +00:00
Mark Cave-Ayland
6fcae98b2c
esp.c: remove FIFO clear from esp_select()
...
The FIFO contents should not be affected by performing SCSI target selection.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-5-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:04 +00:00
Mark Cave-Ayland
49c60d1617
esp.c: add FIFO wraparound support to esp_fifo_pop_buf()
...
The fifo8_pop_buf() function returns a pointer to the FIFO buffer up to the
specified length. Since the FIFO buffer is modelled as an array then once
the FIFO wraps around, only the continuous portion of the buffer can be
returned.
In future the use of continuous and unaligned accesses will advance the
internal FIFO head pointer, so modify esp_fifo_pop_buf() to ensure that
any wraparound content is also returned up to the requested length.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-4-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:04 +00:00
Mark Cave-Ayland
cf40a5e420
esp.c: move existing request cancel check into esp_select()
...
Since get_cmd() can be called multiple times during a mixed FIFO/DMA request,
move the existing request cancel check into esp_select() which always occurs
at the start of new SCSI request.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-3-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:37:02 +00:00
Mark Cave-Ayland
f3ace75be8
esp.c: don't clear cmdfifo when esp_select() fails in get_cmd()
...
The FIFO contents should not be affected if the target selection fails.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Tested-by: Helge Deller <deller@gmx.de >
Tested-by: Thomas Huth <thuth@redhat.com >
Message-Id: <20240112125420.514425-2-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2024-02-13 19:36:59 +00:00
Peter Maydell
05470c3979
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
...
* configure: use a native non-cross compiler for linux-user
* meson: cleanups
* target/i386: miscellaneous cleanups and optimizations
* target/i386: implement CMPccXADD
* target/i386: the sgx_epc_get_section stub is reachable
* esp: check for NULL result from scsi_device_find()
# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmWRImYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroNd7AgAgcyJGiMfUkXqhefplpm06RDXQIa8
# FuoJqPb21lO75DQKfaFRAc4xGLagjJROMJGHMm9HvMu2VlwvOydkQlfFRspENxQ/
# 5XzGdb/X0A7HA/mwUfnMB1AZx0Vs32VI5IBSc6acc9fmgeZ84XQEoM3KBQHUik7X
# mSkE4eltR9gJ+4IaGo4voZtK+YoVD8nEcuqmnKihSPWizev0FsZ49aNMtaYa9qC/
# Xs3kiQd/zPibHDHJu0ulFsNZgxtUcvlLHTCf8gO4dHWxCFLXGubMush83McpRtNB
# Qoh6cTLH+PBXfrxMR3zmTZMNvo8Euls3s07Y8TkNP4vdIIE/kMeMDW1wJw==
# =mq30
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun 31 Dec 2023 08:12:22 GMT
# gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg: issuer "pbonzini@redhat.com "
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org >" [full]
# gpg: aka "Paolo Bonzini <pbonzini@redhat.com >" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1
# Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83
* tag 'for-upstream' of https://gitlab.com/bonzini/qemu : (46 commits)
meson.build: report graphics backends separately
configure, meson: rename targetos to host_os
meson: rename config_all
meson: remove CONFIG_ALL
meson: remove config_targetos
meson: remove CONFIG_POSIX and CONFIG_WIN32 from config_targetos
meson: remove OS definitions from config_targetos
meson: always probe u2f and canokey if the option is enabled
meson: move subdirs to "Collect sources" section
meson: move config-host.h definitions together
meson: move CFI detection code with other compiler flags
meson: keep subprojects together
meson: move accelerator dependency checks together
meson: move option validation together
meson: move program checks together
meson: add more sections to main meson.build
configure: unify again the case arms in probe_target_compiler
configure: remove unnecessary subshell
Makefile: clean qemu-iotests output
meson: use version_compare() to compare version
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2024-01-04 19:55:20 +00:00
Alexandra Diupina
b22f83d8df
esp: check for NULL result from scsi_device_find()
...
Add a 'current_lun' check for a null value
to avoid null pointer dereferencing and
recover host if NULL return
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 4eb8606560
(esp: store lun coming from the MESSAGE OUT phase)
Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru >
Message-ID: <20231229152647.19699-1-adiupina@astralinux.ru >
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
2023-12-31 09:11:27 +01:00
Richard Henderson
2d7b39a64f
hw/scsi: Constify VMState
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231221031652.119827-52-richard.henderson@linaro.org >
2023-12-30 07:38:06 +11:00
Mark Cave-Ayland
77668e4b9b
esp: restrict non-DMA transfer length to that of available data
...
In the case where a SCSI layer transfer is incorrectly terminated, it is
possible for a TI command to cause a SCSI buffer overflow due to the
expected transfer data length being less than the available data in the
FIFO. When this occurs the unsigned async_len variable underflows and
becomes a large offset which writes past the end of the allocated SCSI
buffer.
Restrict the non-DMA transfer length to be the smallest of the expected
transfer length and the available FIFO data to ensure that it is no longer
possible for the SCSI buffer overflow to occur.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1810
Reviewed-by: Thomas Huth <thuth@redhat.com >
Message-ID: <20230913204410.65650-3-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
2023-10-03 10:29:39 +02:00
Mark Cave-Ayland
b86dc5cb0b
esp: use correct type for esp_dma_enable() in sysbus_esp_gpio_demux()
...
The call to esp_dma_enable() was being made with the SYSBUS_ESP type instead of
the ESP type. This meant that when GPIO 1 was being used to trigger a DMA
request from an external DMA controller, the setting of ESPState's dma_enabled
field would clobber unknown memory whilst the dma_cb callback pointer would
typically return NULL so the DMA request would never start.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Thomas Huth <thuth@redhat.com >
Message-ID: <20230913204410.65650-2-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
2023-10-03 10:29:39 +02:00
Stefan Weil
2cb40d446f
Fix several typos in documentation (found by codespell)
...
Those typos are in files which are used to generate the QEMU manual.
Signed-off-by: Stefan Weil <sw@weilnetz.de >
Message-Id: <20221110190825.879620-1-sw@weilnetz.de >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Ani Sinha <ani@anisinha.ca >
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Acked-by: Michael S. Tsirkin <mst@redhat.com >
[thuth: update sentence in can.rst as suggested by Peter]
Signed-off-by: Thomas Huth <thuth@redhat.com >
2022-11-11 09:39:25 +01:00
Peter Maydell
4a5fc890b1
scsi: Use device_cold_reset() and bus_cold_reset()
...
In the SCSI subsystem we currently use the legacy functions
qdev_reset_all() and qbus_reset_all(). These perform a recursive
reset, starting from either a qbus or a qdev. However they do not
permit any of the devices in the tree to use three-phase reset,
because device reset goes through the device_legacy_reset() function
that only calls the single DeviceClass::reset method.
Switch to using the device_cold_reset() and bus_cold_reset()
functions. These also perform a recursive reset, where first the
children are reset and then finally the parent, but they use the new
(...in 2020...) Resettable mechanism, which supports both the old
style single-reset method and also the new 3-phase reset handling.
Since no devices attached to SCSI buses currently try to use 3-phase
reset, this should be a no-behaviour-change commit which just reduces
the use of a deprecated API.
Commit created with:
sed -i -e 's/qdev_reset_all/device_cold_reset/g;s/qbus_reset_all/bus_cold_reset/g' hw/scsi/*.c
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
Message-Id: <20221013160623.1296109-2-peter.maydell@linaro.org >
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
2022-10-18 13:58:04 +02:00
John Millikin
fe9d8927e2
scsi: Add buf_len parameter to scsi_req_new()
...
When a SCSI command is received from the guest, the CDB length implied
by the first byte might exceed the number of bytes the guest sent. In
this case scsi_req_new() will read uninitialized data, causing
unpredictable behavior.
Adds the buf_len parameter to scsi_req_new() and plumbs it through the
call stack.
Signed-off-by: John Millikin <john@john-millikin.com >
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1127
Message-Id: <20220817053458.698416-1-john@john-millikin.com >
[Fill in correct length for adapters other than ESP. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
2022-09-01 07:42:37 +02:00
John Millikin
c6e51f1bb2
esp: Handle CMD_BUSRESET by resetting the SCSI bus
...
Per investigation on the linked ticket, SunOS issues a SCSI bus reset
to the ESP as part of its boot sequence. If this ESP command doesn't
cause devices to assert sense flag UNIT ATTENTION, SunOS will consider
the CD-ROM device to be non-compliant with Common Command Set (CCS).
In this condition, the SunOS installer's early userspace doesn't set
the installation source location to sr0 and the miniroot copy fails.
Signed-off-by: John Millikin <john@john-millikin.com >
Suggested-by: Bill Paul <noisetube@gmail.com >
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/1127
Message-Id: <20220817053846.699310-1-john@john-millikin.com >
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
2022-09-01 07:42:36 +02:00
Mark Cave-Ayland
a7a2208862
esp: recreate ESPState current_req after migration
...
Since PDMA reads/writes are driven by the guest, it is possible that migration
can occur whilst a SCSIRequest is still active. Fortunately active SCSIRequests
are already included in the migration stream and restarted post migration but
this still leaves the reference in ESPState uninitialised.
Implement the SCSIBusInfo .load_request callback to obtain a reference to the
currently active SCSIRequest and use it to recreate ESPState current_req
after migration.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Reviewed-by: Laurent Vivier <laurent@vivier.eu >
Message-Id: <20220305155530.9265-11-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2022-03-09 09:29:10 +00:00
Mark Cave-Ayland
eda59b392d
esp: include the current PDMA callback in the migration stream
...
This involves (re)adding a PDMA-specific subsection to hold the reference to the
current PDMA callback.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Reviewed-by: Laurent Vivier <laurent@vivier.eu >
Message-Id: <20220305155530.9265-10-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2022-03-09 09:29:10 +00:00
Mark Cave-Ayland
77987ef5a3
esp: convert ESPState pdma_cb from a function pointer to an integer
...
This prepares for the inclusion of the current PDMA callback in the migration
stream since the callback is referenced by an integer instead of a function
pointer.
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 >
Message-Id: <20220305155530.9265-9-mark.cave-ayland@ilande.co.uk >
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk >
2022-03-09 09:29:10 +00:00