qemu-e2k/hw
Niklas Cassel eabb921250 hw/ide/ahci: fix legacy software reset
Legacy software contains a standard mechanism for generating a reset to a
Serial ATA device - setting the SRST (software reset) bit in the Device
Control register.

Serial ATA has a more robust mechanism called COMRESET, also referred to
as port reset. A port reset is the preferred mechanism for error
recovery and should be used in place of software reset.

Commit e2a5d9b3d9 ("hw/ide/ahci: simplify and document PxCI handling")
improved the handling of PxCI, such that PxCI gets cleared after handling
a non-NCQ, or NCQ command (instead of incorrectly clearing PxCI after
receiving anything - even a FIS that failed to parse, which should NOT
clear PxCI, so that you can see which command slot that caused an error).

However, simply clearing PxCI after a non-NCQ, or NCQ command, is not
enough, we also need to clear PxCI when receiving a SRST in the Device
Control register.

A legacy software reset is performed by the host sending two H2D FISes,
the first H2D FIS asserts SRST, and the second H2D FIS deasserts SRST.

The first H2D FIS will not get a D2H reply, and requires the FIS to have
the C bit set to one, such that the HBA itself will clear the bit in PxCI.

The second H2D FIS will get a D2H reply once the diagnostic is completed.
The clearing of the bit in PxCI for this command should ideally be done
in ahci_init_d2h() (if it was a legacy software reset that caused the
reset (a COMRESET does not use a command slot)). However, since the reset
value for PxCI is 0, modify ahci_reset_port() to actually clear PxCI to 0,
that way we can avoid complex logic in ahci_init_d2h().

This fixes an issue for FreeBSD where the device would fail to reset.
The problem was not noticed in Linux, because Linux uses a COMRESET
instead of a legacy software reset by default.

Fixes: e2a5d9b3d9 ("hw/ide/ahci: simplify and document PxCI handling")
Reported-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Message-ID: <20231108222657.117984-1-nks@flawful.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2023-11-21 12:45:21 +01:00
..
9pfs
acpi virtio,pc,pci: features, cleanups 2023-10-23 14:45:29 -07:00
adc
alpha hw/pci: modify pci_setup_iommu() to set PCIIOMMUOps 2023-11-03 09:20:31 +01:00
arm hw/arm/virt: fix GIC maintenance IRQ registration 2023-11-13 13:13:49 +00:00
audio hw/audio/virtio-snd.c: spelling: initalize 2023-11-15 11:09:17 +03:00
avr
block hw/xen: automatically assign device index to block devices 2023-11-07 08:54:20 +00:00
char hw/xen: add support for Xen primary console in emulated mode 2023-11-07 08:54:20 +00:00
core igb: Add Function Level Reset to PF and VF 2023-11-13 15:33:37 +08:00
cpu
cris
cxl hw/cxl: spelling fixes: limitaions, potentialy, intialized 2023-11-15 11:09:17 +03:00
display hw/display/vmware_vga: fix probably typo 2023-11-13 16:56:24 +01:00
dma
gpio
hppa hw/hppa: Require at least SeaBIOS-hppa version 12 2023-11-13 09:21:32 -08:00
hyperv vfio queue: 2023-11-07 09:41:52 +08:00
i2c hw/i2c: pmbus: reset page register for out of range reads 2023-11-07 13:08:49 +01:00
i386 hw/i386/pc: Use qdev_prop_set_array() 2023-11-10 18:19:07 +01:00
ide hw/ide/ahci: fix legacy software reset 2023-11-21 12:45:21 +01:00
input target-arm queue: 2023-11-03 10:04:12 +08:00
intc Migration Pull request (20231102) 2023-11-03 09:57:32 +08:00
ipack
ipmi hw/ipmi: Don't call vmstate_register() from instance_init() functions 2023-11-01 16:13:58 +01:00
isa hw/isa/i82378: Propagate error if PC_SPEAKER device creation failed 2023-11-07 13:08:48 +01:00
loongarch
m68k m68k: Instantiate the ESP SCSI controller for the NeXTcube machine 2023-11-02 07:26:06 +01:00
mem hw/mem/memory-device.c: spelling fix: ontaining 2023-11-15 11:59:54 +03:00
microblaze
mips hw/mips: LOONGSON3V depends on UNIMP device 2023-11-13 16:56:06 +01:00
misc hw/misc: Introduce AMD/Xilix Versal TRNG device 2023-11-02 14:42:03 +00:00
net hw/net/cadence_gem.c: spelling fixes: Octects 2023-11-15 12:05:52 +03:00
nios2
nubus
nvme
nvram migration: Use vmstate_register_any() for eeprom93xx 2023-11-01 16:13:58 +01:00
openrisc
pci hw/pci: modify pci_setup_iommu() to set PCIIOMMUOps 2023-11-03 09:20:31 +01:00
pci-bridge hw/pci-bridge/cxl_downstream: Set default link width and link speed 2023-11-07 03:39:11 -05:00
pci-host hw/pci-host/astro: Fix boot for C3700 machine 2023-11-13 09:21:32 -08:00
pcmcia hw/pcmcia/pxa2xx: Inline pxa2xx_pcmcia_init() 2023-10-27 12:48:57 +01:00
ppc spapr/pci: Correct "does not support hotplugging error messages 2023-11-17 10:07:52 +01:00
rdma
remote hw/pci: modify pci_setup_iommu() to set PCIIOMMUOps 2023-11-03 09:20:31 +01:00
riscv target/riscv: Use existing PMU counter mask in FDT generation 2023-11-07 11:06:02 +10:00
rtc mc146818rtc: rtc_set_time(): initialize tm to zeroes 2023-11-06 15:00:27 +00:00
rx hw/rx/rx62n: Use qdev_prop_set_array() 2023-11-10 18:19:13 +01:00
s390x s390x/pci: only limit DMA aperture if vfio DMA limit reported 2023-11-13 11:35:47 +01:00
scsi cpr: relax vhost migration blockers 2023-11-01 16:13:59 +01:00
sd hw/sd: Declare QOM types using DEFINE_TYPES() macro 2023-11-07 13:08:49 +01:00
sensor hw/sensor: add ADM1266 device model 2023-11-07 13:08:49 +01:00
sh4
smbios
sparc
sparc64
ssi hw/ssi: ibex_spi_host: Clear the interrupt even if disabled 2023-11-07 11:06:02 +10:00
timer migration: Use vmstate_register_any() 2023-11-01 16:13:58 +01:00
tpm
tricore
ufs hw/ufs: Modify lu.c to share codes with SCSI subsystem 2023-10-30 10:28:04 +09:00
usb
vfio vfio/common: Move vfio_host_win_add/del into spapr.c 2023-11-06 13:23:23 +01:00
virtio virtio-mem: fix division by zero in virtio_mem_activate_memslots_to_plug() 2023-11-13 09:35:44 +01:00
watchdog hw/watchdog/wdt_aspeed: Remove unused 'hw/misc/aspeed_scu.h' header 2023-11-15 11:09:17 +03:00
xen hw/i386/pc: support '-nic' for xen-net-device 2023-11-07 08:54:20 +00:00
xenpv hw/xen: update Xen PV NIC to XenDevice model 2023-11-07 08:54:20 +00:00
xtensa
Kconfig
meson.build