qemu-patch-raspberry4/hw/ppc
Daniel Henrique Barboza fe1831eff8 spapr_drc.c: use DRC reconfiguration to cleanup DIMM unplug state
Handling errors in memory hotunplug in the pSeries machine is more
complex than any other device type, because there are all the
complications that other devices has, and more.

For instance, determining a timeout for a DIMM hotunplug must consider
if it's a Hash-MMU or a Radix-MMU guest, because Hash guests takes
longer to hotunplug DIMMs. The size of the DIMM is also a factor, given
that longer DIMMs naturally takes longer to be hotunplugged from the
kernel. And there's also the guest memory usage to be considered: if
there's a process that is consuming memory that would be lost by the
DIMM unplug, the kernel will postpone the unplug process until the
process finishes, and then initiate the regular hotunplug process. The
first two considerations are manageable, but the last one is a deal
breaker.

There is no sane way for the pSeries machine to determine the memory
load in the guest when attempting a DIMM hotunplug - and even if there
was a way, the guest can start using all the RAM in the middle of the
unplug process and invalidate our previous assumptions - and in result
we can't even begin to calculate a timeout for the operation. This means
that we can't implement a viable timeout mechanism for memory unplug in
pSeries.

Going back to why we would consider an unplug timeout, the reason is
that we can't know if the kernel is giving up the unplug. Turns out
that, sometimes, we can. Consider a failed memory hotunplug attempt
where the kernel will error out with the following message:

'pseries-hotplug-mem: Memory indexed-count-remove failed, adding any
removed LMBs'

This happens when there is a LMB that the kernel gave up in removing,
and the LMBs previously marked for removal are now being added back.
This happens in the pseries kernel in [1], dlpar_memory_remove_by_ic()
into dlpar_add_lmb(), and after that update_lmb_associativity_index().
In this function, the kernel is configuring the LMB DRC connector again.
Note that this is a valid usage in LOPAR, as stated in section
"ibm,configure-connector RTAS Call":

'A subsequent sequence of calls to ibm,configure-connector with the same
entry from the “ibm,drc-indexes” or “ibm,drc-info” property will restart
the configuration of devices which were not completely configured.'

We can use this kernel behavior in our favor. If a DRC connector
reconfiguration for a LMB that we marked as unplug pending happens, this
indicates that the kernel changed its mind about the unplug and is
reasserting that it will keep using all the LMBs of the DIMM. In this
case, it's safe to assume that the whole DIMM device unplug was
cancelled.

This patch hops into rtas_ibm_configure_connector() and, in the scenario
described above, clear the unplug state for the DIMM device. This will
not solve all the problems we still have with memory unplug, but it will
cover this case where the kernel reconfigures LMBs after a failed
unplug. We are a bit more resilient, without using an unreliable
timeout, and we didn't make the remaining error cases any worse.

[1] arch/powerpc/platforms/pseries/hotplug-memory.c

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210222194531.62717-6-danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-03-10 09:07:09 +11:00
..
e500-ccsr.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
e500.c hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes 2021-02-10 14:50:11 +11:00
e500.h Use OBJECT_DECLARE_TYPE when possible 2020-09-18 14:12:32 -04:00
e500plat.c ppc/e500: use memdev for RAM 2020-02-19 16:50:00 +00:00
fdt.c target/ppc: Split page size information into a separate allocation 2018-04-27 18:05:22 +10:00
fw_cfg.c hw/ppc: Implement fw_cfg_arch_key_name() 2019-05-23 14:10:31 +02:00
Kconfig Revert "ppc4xx: Move common dependency on serial to common option" 2021-01-19 10:20:29 +11:00
mac.h mac_newworld: Allow loading binary ROM image 2020-10-19 08:11:21 +01:00
mac_newworld.c macio: move OpenPIC inside macio-newworld device 2021-01-13 12:21:10 +00:00
mac_oldworld.c macio: move heathrow PIC inside macio-oldworld device 2021-01-13 12:20:37 +00:00
meson.build spapr: Add PEF based confidential guest support 2021-02-08 16:57:38 +11:00
mpc8544_guts.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
mpc8544ds.c ppc/e500: use memdev for RAM 2020-02-19 16:50:00 +00:00
pef.c spapr: PEF: prevent migration 2021-02-08 16:57:38 +11:00
pnv.c ppc/pnv: Set default RAM size to 1 GB 2021-02-10 14:50:11 +11:00
pnv_bmc.c ppc/pnv: Discard internal BMC initialization when BMC is external 2021-02-10 10:43:50 +11:00
pnv_core.c non-virt: Fix Lesser GPL version number 2020-11-15 16:38:24 +01:00
pnv_homer.c ppc/pnv: change the PowerNV machine devices to be non user creatable 2020-02-02 14:07:57 +11:00
pnv_lpc.c ppc/pnv: Introduce a LPC FW memory region attribute to map the PNOR 2021-02-10 10:43:50 +11:00
pnv_occ.c ppc/pnv: change the PowerNV machine devices to be non user creatable 2020-02-02 14:07:57 +11:00
pnv_pnor.c block: Separate blk_is_writable() and blk_supports_write_perm() 2021-01-27 20:45:20 +01:00
pnv_psi.c non-virt: Fix Lesser GPL version number 2020-11-15 16:38:24 +01:00
pnv_xscom.c non-virt: Fix Lesser GPL version number 2020-11-15 16:38:24 +01:00
ppc.c hw/ppc: Do not re-read the clock on pre_save if doing savevm 2020-12-14 15:54:12 +11:00
ppc4xx_devs.c hw/ppc: Remove unused ppcuic_init() 2021-01-19 10:20:29 +11:00
ppc4xx_pci.c hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h' 2021-01-04 23:24:44 +01:00
ppc405.h hw/ppc/ppc405_uc: Drop use of ppcuic_init() 2021-01-19 10:20:29 +11:00
ppc405_boards.c hw/ppc/ppc405_uc: Drop use of ppcuic_init() 2021-01-19 10:20:29 +11:00
ppc405_uc.c hw/ppc/ppc405_uc: Drop use of ppcuic_init() 2021-01-19 10:20:29 +11:00
ppc440.h ppc440_uc: Basic emulation of PPC440 DMA controller 2018-07-03 09:56:52 +10:00
ppc440_bamboo.c hw/ppc/ppc440_bamboo: Drop use of ppcuic_init() 2021-01-06 11:09:59 +11:00
ppc440_pcix.c ppc440_pcix: Fix up pci config access 2021-01-06 11:09:59 +11:00
ppc440_uc.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
ppc_booke.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
ppce500_spin.c powerpc tcg: Fix Lesser GPL version number 2020-11-15 16:38:50 +01:00
prep.c ppc: do not use ram_size global 2020-12-10 12:15:09 -05:00
prep_systemio.c prep: add ppc-parity write method 2021-02-08 15:15:32 +01:00
rs6000_mc.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
sam460ex.c sam460ex: Use type cast macro instead of simple cast 2021-01-19 10:20:29 +11:00
spapr.c spapr_drc.c: use DRC reconfiguration to cleanup DIMM unplug state 2021-03-10 09:07:09 +11:00
spapr_caps.c spapr: Add a return value to spapr_check_pagesize() 2020-10-09 10:15:06 +11:00
spapr_cpu_core.c spapr_cpu_core.c: use g_auto* in spapr_create_vcpu() 2021-01-19 10:20:29 +11:00
spapr_drc.c spapr_drc.c: use DRC reconfiguration to cleanup DIMM unplug state 2021-03-10 09:07:09 +11:00
spapr_events.c spapr: Improve handling of memory unplug with old guests 2021-01-19 10:20:29 +11:00
spapr_hcall.c spapr_hcall.c: make do_client_architecture_support static 2021-01-19 10:20:29 +11:00
spapr_iommu.c memory: Add IOMMUTLBEvent 2020-12-08 13:48:57 -05:00
spapr_irq.c spapr/xics: Drop unused argument to xics_kvm_has_broken_disconnect() 2020-12-14 15:50:55 +11:00
spapr_numa.c spapr_numa.c: fix ibm,max-associativity-domains calculation 2021-02-10 10:43:50 +11:00
spapr_nvdimm.c ppc/spapr: cleanup -machine pseries,nvdimm=X handling 2020-12-15 12:51:53 -05:00
spapr_ovec.c spapr: Improve handling of memory unplug with old guests 2021-01-19 10:20:29 +11:00
spapr_pci.c spapr: rename spapr_drc_detach() to spapr_drc_unplug_request() 2021-03-10 09:07:08 +11:00
spapr_pci_nvlink2.c spapr_numa: move NVLink2 associativity handling to spapr_numa.c 2020-09-08 10:08:43 +10:00
spapr_pci_vfio.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
spapr_rng.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
spapr_rtas.c spapr_rtas.c: fix identation of rtas_ibm_suspend_me() args 2021-01-19 10:20:29 +11:00
spapr_rtas_ddw.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
spapr_rtc.c qom: Drop parameter @errp of object_property_add() & friends 2020-05-15 07:07:58 +02:00
spapr_tpm_proxy.c qdev: Unrealize must not fail 2020-05-15 07:08:14 +02:00
spapr_vio.c ppc: do not use ram_size global 2020-12-10 12:15:09 -05:00
trace-events spapr: rename spapr_drc_detach() to spapr_drc_unplug_request() 2021-03-10 09:07:08 +11:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
virtex_ml507.c hw/ppc/virtex_ml507: Drop use of ppcuic_init() 2021-01-06 11:09:59 +11:00