qemu-e2k/hw
Daniel Henrique Barboza 51254ffb32 spapr_drc.c: introduce unplug_timeout_timer
The LoPAR spec provides no way for the guest kernel to report failure of
hotplug/hotunplug events. This wouldn't be bad if those operations were
granted to always succeed, but that's far for the reality.

What ends up happening is that, in the case of a failed hotunplug,
regardless of whether it was a QEMU error or a guest misbehavior, the
pSeries machine is retaining the unplug state of the device in the
running guest.  This state is cleanup in machine reset, where it is
assumed that this state represents a device that is pending unplug, and
the device is hotunpluged from the board. Until the reset occurs, any
hotunplug operation of the same device is forbid because there is a
pending unplug state.

This behavior has at least one undesirable side effect. A long standing
pending unplug state is, more often than not, the result of a hotunplug
error. The user had to dealt with it, since retrying to unplug the
device is noy allowed, and then in the machine reset we're removing the
device from the guest. This means that we're failing the user twice -
failed to hotunplug when asked, then hotunplugged without notice.

Solutions to this problem range between trying to predict when the
hotunplug will fail and forbid the operation from the QEMU layer, from
opening up the IRQ queue to allow for multiple hotunplug attempts, from
telling the users to 'reboot the machine if something goes wrong'. The
first solution is flawed because we can't fully predict guest behavior
from QEMU, the second solution is a trial and error remediation that
counts on a hope that the unplug will eventually succeed, and the third
is ... well.

This patch introduces a crude, but effective solution to hotunplug
errors in the pSeries machine. For each unplug done, we'll timeout after
some time. If a certain amount of time passes, we'll cleanup the
hotunplug state from the machine.  During the timeout period, any unplug
operations in the same device will still be blocked. After that, we'll
assume that the guest failed the operation, and allow the user to try
again. If the timeout is too short we'll prevent legitimate hotunplug
situations to occur, so we'll need to overestimate the regular time an
unplug operation takes to succeed to account that.

The true solution for the hotunplug errors in the pSeries machines is a
PAPR change to allow for the guest to warn the platform about it. For
now, the work done in this timeout design can be used for the new PAPR
'abort hcall' in the future, given that for both cases we'll need code
to cleanup the existing unplug states of the DRCs.

At this moment we're adding the basic wiring of the timer into the DRC.
Next patch will use the timer to timeout failed CPU hotunplugs.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210222194531.62717-4-danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-03-10 09:07:09 +11:00
..
9pfs 9pfs: Convert reclaim list to QSLIST 2021-01-22 18:26:40 +01:00
acpi acpi/core: always set SCI_EN when SMM isn't supported 2021-02-23 10:58:42 -05:00
adc hw/adc: Add an ADC module for NPCM7XX 2021-01-12 21:19:02 +00:00
alpha vl: extract softmmu/datadir.c 2020-12-10 12:15:18 -05:00
arm hw/arm/mps2: Update old infocenter.arm.com URLs 2021-03-08 11:54:16 +00:00
audio audio/via-ac97: Simplify code and set user_creatable to false 2021-01-04 23:24:44 +01:00
avr vl: extract softmmu/datadir.c 2020-12-10 12:15:18 -05:00
block hw/block: Introduce TC58128 eeprom Kconfig entry 2021-03-06 16:18:42 +01:00
char hw/char: Introduce SH_SCI Kconfig entry 2021-03-06 16:18:42 +01:00
core acpi/core: always set SCI_EN when SMM isn't supported 2021-02-23 10:58:42 -05:00
cpu cpu/core: Register core-id and nr-threads as class properties 2020-09-22 16:48:29 -04:00
cris cris: do not use ram_size global 2020-12-10 12:15:07 -05:00
display hw/display/sm501: Inline template header into C file 2021-03-10 09:07:08 +11:00
dma esp: rename existing ESP QOM type to SYSBUS_ESP 2021-03-07 10:39:05 +00:00
gpio hw: gpio: implement gpio-pwr driver for qemu reset/poweroff 2021-01-29 10:47:28 +00:00
hppa hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h' 2021-01-04 23:24:44 +01:00
hyperv qdev: Move softmmu properties to qdev-properties-system.h 2020-12-18 15:20:17 -05:00
i2c hw/i2c/npcm7xx_smbus: Simplify npcm7xx_smbus_init() 2021-03-05 15:17:34 +00:00
i386 x86/pvh: extract only 4 bytes of start address for 32 bit kernels 2021-03-06 11:41:54 +01:00
ide hw/ide/ahci: map cmd_fis as DMA_DIRECTION_TO_DEVICE 2021-02-15 15:10:14 +01:00
input Remove superfluous timer_del() calls 2021-01-08 15:13:38 +00:00
intc Renesas patches queue 2021-03-08 15:45:48 +00:00
ipack Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
ipmi Remove superfluous timer_del() calls 2021-01-08 15:13:38 +00:00
isa acpi/core: always set SCI_EN when SMM isn't supported 2021-02-23 10:58:42 -05:00
lm32 vl: extract softmmu/datadir.c 2020-12-10 12:15:18 -05:00
m68k esp: rename existing ESP QOM type to SYSBUS_ESP 2021-03-07 10:39:05 +00:00
mem nvdimm: put it into the 'storage' category 2021-02-20 12:36:19 +01:00
microblaze vl: make qemu_get_machine_opts static 2020-12-15 12:51:55 -05:00
mips esp: rename existing ESP QOM type to SYSBUS_ESP 2021-03-07 10:39:05 +00:00
misc hw/arm/mps2: Update old infocenter.arm.com URLs 2021-03-08 11:54:16 +00:00
moxie moxie: do not use ram_size global 2020-12-10 12:15:08 -05:00
net hw/net: Add npcm7xx emc model 2021-03-05 15:17:34 +00:00
nios2 * New -action option and set-action QMP command (Alejandro) 2020-12-15 21:24:31 +00:00
nubus meson: convert hw/nubus 2020-08-21 06:30:25 -04:00
nvram nvram: add nrf51_soc flash read method 2021-02-08 15:15:32 +01:00
openrisc target/openrisc: Move pic_cpu code into CPU object proper 2020-12-15 12:04:30 +00:00
pci hw/pci: Have safer pcie_bus_realize() by checking error path 2021-03-02 09:16:18 -05:00
pci-bridge Kconfig: Compile PXB for ARM_VIRT 2021-01-17 06:42:54 -05:00
pci-host hw/pci-host: Introduce SH_PCI Kconfig entry 2021-03-06 16:18:42 +01:00
pcmcia pxa2xx: Move QOM macros to header 2020-08-27 14:04:55 -04:00
ppc spapr_drc.c: introduce unplug_timeout_timer 2021-03-10 09:07:09 +11:00
rdma Machine queue, 2020-12-23 2021-01-01 22:57:15 +00:00
remote multi-process: perform device reset in the remote process 2021-02-10 09:23:28 +00:00
riscv hw/riscv: virt: Map high mmio for PCIe 2021-03-04 09:43:29 -05:00
rtc goldfish_rtc: re-arm the alarm after migration 2021-03-04 09:43:29 -05:00
rx rx: move BIOS load from MCU to board 2020-12-10 12:15:06 -05:00
s390x virtio-ccw: commands on revision-less devices 2021-03-04 11:23:35 +01:00
scsi qemu-sparc queue 2021-03-09 13:50:35 +00:00
sd Pull request trivial patches 20210220 2021-02-21 12:12:18 +00:00
semihosting semihosting: Implement SYS_ISERROR 2021-01-18 10:05:06 +00:00
sh4 hw/sh4/sh7750_regs: Replace link to license by its full content 2021-03-06 16:19:03 +01:00
smbios i386: do not use ram_size global 2020-12-10 12:15:08 -05:00
sparc esp: rename existing ESP QOM type to SYSBUS_ESP 2021-03-07 10:39:05 +00:00
sparc64 vl: extract softmmu/datadir.c 2020-12-10 12:15:18 -05:00
ssi hw/ssi: Add SiFive SPI controller support 2021-03-04 09:43:29 -05:00
timer hw/timer: Introduce SH_TIMER Kconfig entry 2021-03-06 16:18:42 +01:00
tpm tpm: put some tpm devices into the correct category 2021-02-20 12:36:19 +01:00
tricore tricore tcg cpus: Fix Lesser GPL version number 2020-11-15 16:40:30 +01:00
unicore32 meson: convert hw/arch* 2020-08-21 06:30:33 -04:00
usb scsi: drop 'result' argument from command_complete callback 2021-02-25 14:14:32 +01:00
vfio vfio-ccw: Do not read region ret_code after write 2021-03-04 11:24:49 +01:00
virtio virtio-mmio: improve virtio-mmio get_dev_path alog 2021-03-05 15:17:34 +00:00
watchdog arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE 2021-01-29 15:54:44 +00:00
xen pci: add romsize property 2021-02-05 08:52:58 -05:00
xenpv meson: convert hw/arch* 2020-08-21 06:30:33 -04:00
xtensa vl: make qemu_get_machine_opts static 2020-12-15 12:51:55 -05:00
Kconfig multi-process: Add config option for multi-process QEMU 2021-02-09 20:53:56 +00:00
meson.build multi-process: setup a machine object for remote device process 2021-02-10 09:23:28 +00:00