ppc-for-6.0 queue 20210106
The following changes since commit 52d25464605dc20022ad94aa8bc8e8473e600833:
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210104' into staging (2021-01-05 16:18:20 +0000)
are available in the Git repository at:
https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.0-20210106
for you to fetch changes up to 5cbd51a5a58098444ffa246ece2013849be04299:
ppc440_pcix: Fix up pci config access (2021-01-06 11:09:59 +1100)
----------------------------------------------------------------
ppc patch queue 2021-01-06
First pull request for 2021, which has a bunch of things accumulated over the holidays. Includes:
* A number of cleanups to sam460ex and ppc440 code from BALATON Zoltan
* Several fixes for builds with --without-default-devices from Greg Kurz
* Fixes for some DRC reset problems from Greg Kurz
* QOM conversion of the PPC 4xx UIC devices from Peter Maydell
* Some other assorted fixes and cleanups
----------------------------------------------------------------
BALATON Zoltan via (5):
ppc4xx: Move common dependency on serial to common option
sam460ex: Remove FDT_PPC dependency from KConfig
ppc440_pcix: Improve comment for IRQ mapping
ppc440_pcix: Fix register write trace event
ppc440_pcix: Fix up pci config access
Cédric Le Goater (1):
spapr/xive: Make spapr_xive_pic_print_info() static
Greg Kurz (12):
spapr: DRC lookup cannot fail
spapr: Fix DR properties of the root node
spapr: Allow memory unplug to always succeed
spapr: Fix buffer overflow in spapr_numa_associativity_init()
spapr: Call spapr_drc_reset() for all DRCs at CAS
spapr: Fix reset of transient DR connectors
spapr: Introduce spapr_drc_reset_all()
spapr: Use spapr_drc_reset_all() at machine reset
spapr: Add drc_ prefix to the DRC realize and unrealize functions
ppc: Fix build with --without-default-devices
ppc: Simplify reverse dependencies of POWERNV and PSERIES on XICS and XIVE
pnv: Fix reverse dependency on PCI express root ports
Peter Maydell (4):
hw/ppc/ppc4xx_devs: Make code style fixes to UIC code
ppc: Convert PPC UIC to a QOM device hw/ppc/virtex_ml507: Drop use of ppcuic_init() hw/ppc/ppc440_bamboo: Drop use of ppcuic_init()
MAINTAINERS | 2 + hw/intc/Kconfig | 17 +-- hw/intc/meson.build | 13 +- hw/intc/ppc-uic.c | 321 ++++++++++++++++++++++++++++++++++++++++++++ hw/intc/spapr_xive.c | 2 +- hw/pci-host/Kconfig | 5 + hw/pci-host/meson.build | 2 +- hw/ppc/Kconfig | 29 +--- hw/ppc/ppc440_bamboo.c | 38 ++++-- hw/ppc/ppc440_pcix.c | 50 ++++--- hw/ppc/ppc4xx_devs.c | 262 +++++------------------------------- hw/ppc/spapr.c | 44 +++--- hw/ppc/spapr_drc.c | 63 +++++++-- hw/ppc/spapr_events.c | 3 +- hw/ppc/spapr_hcall.c | 33 +---- hw/ppc/trace-events | 1 + hw/ppc/virtex_ml507.c | 21 ++- include/hw/intc/ppc-uic.h | 73 ++++++++++ include/hw/pci-host/spapr.h | 2 - include/hw/ppc/spapr.h | 6 +- include/hw/ppc/spapr_drc.h | 10 +- include/hw/ppc/spapr_xive.h | 2 - 22 files changed, 616 insertions(+), 383 deletions(-) create mode 100644 hw/intc/ppc-uic.c create mode 100644 include/hw/intc/ppc-uic.h
[PULL 03/22] hw/ppc/virtex_ml507: Drop use of ppcuic_init()
From: Peter Maydell <[email protected]>
Switch the virtex_ml507 board to directly creating and configuring the UIC, rather than doing it via the old ppcuic_init() helper function.
This fixes a trivial Coverity-detected memory leak where we were leaking the array of IRQs returned by ppcuic_init().
Message-Id: <[email protected]>
--- hw/ppc/virtex_ml507.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
hw/ppc/virtex_ml507.c +16 -5
@@ -43,6 +43,7 @@#include "qemu/option.h" #include "exec/address-spaces.h" +#include "hw/intc/ppc-uic.h" #include "hw/ppc/ppc.h" #include "hw/ppc/ppc4xx.h" #include "hw/qdev-properties.h"
@@ -95,7 +96,8 @@ static PowerPCCPU *ppc440_init_xilinx(const char *cpu_type, uint32_t sysclk) {PowerPCCPU *cpu;CPUPPCState *env; -qemu_irq *irqs; +DeviceState *uicdev; +SysBusDevice *uicsbd; cpu =POWERPC_CPU (cpu_create (cpu_type)); env = &cpu->env;
@@ -105,10 +107,19 @@ static PowerPCCPU *ppc440_init_xilinx(const char *cpu_type, uint32_t sysclk)ppc_dcr_init (env,NULL ,NULL );/* interrupt controller */ - irqs =g_new0 (qemu_irq,PPCUIC_OUTPUT_NB ); - irqs[PPCUIC_OUTPUT_INT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]; - irqs[PPCUIC_OUTPUT_CINT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]; -ppcuic_init (env, irqs,0x0C0 ,0 ,1 ); + uicdev =qdev_new (TYPE_PPC_UIC ); + uicsbd =SYS_BUS_DEVICE (uicdev); + +object_property_set_link (OBJECT (uicdev),"cpu" ,OBJECT (cpu), + &error_fatal); +sysbus_realize_and_unref (uicsbd, &error_fatal); + +sysbus_connect_irq (uicsbd,PPCUIC_OUTPUT_INT , + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]); +sysbus_connect_irq (uicsbd,PPCUIC_OUTPUT_CINT , + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]); + +/* This board doesn't wire anything up to the inputs of the UIC. */ return cpu; }
Signature · 1 line
2.29.2
[PULL 02/22] ppc: Convert PPC UIC to a QOM device
In reply to David GibsonFrom: Peter Maydell <[email protected]>
Currently the PPC UIC ("Universal Interrupt Controller") is implemented as a non-QOM device in ppc4xx_devs.c. Convert it to a proper QOM device in hw/intc.
The ppcuic_init() function is retained for the moment with its current interface; in subsequent commits this will be tidied up to avoid the allocation of an irq array.
This conversion adds VMState support.
It leaves the LOG_UIC() macro as-is to maximise the extent to which this is simply code-movement rather than a rewrite (in new code it would be better to use tracepoints).
The default property values for dcr-base and use-vectors are set to match those use by most of our boards with a UIC.
Message-Id: <[email protected]>
--- MAINTAINERS | 2 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 1 + hw/intc/ppc-uic.c | 321 ++++++++++++++++++++++++++++++++++++++ hw/ppc/Kconfig | 1 + hw/ppc/ppc4xx_devs.c | 267 ++++--------------------------- include/hw/intc/ppc-uic.h | 73 +++++++++ 7 files changed, 431 insertions(+), 237 deletions(-) create mode 100644 hw/intc/ppc-uic.c create mode 100644 include/hw/intc/ppc-uic.h
MAINTAINERS +2 -0
@@ -1680,6 +1680,8 @@ F: hw/ppc/ppc4*.c F: hw/i2c/ppc4xx_i2c.c F: include/hw/ppc/ppc4xx.h F: include/hw/i2c/ppc4xx_i2c.h +F: hw/intc/ppc-uic.c +F: include/hw/intc/ppc-uic.h Character devices M: Marc-André Lureau <[email protected]>
hw/intc/Kconfig +3 -0
@@ -62,6 +62,9 @@ config S390_FLIC_KVM config OMPIC bool +config PPC_UIC + bool + config RX_ICU bool
hw/intc/meson.build +1 -0
@@ -41,6 +41,7 @@ specific_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_intc.c')) specific_ss.add(when: 'CONFIG_OMPIC', if_true: files('ompic.c')) specific_ss.add(when: 'CONFIG_OPENPIC_KVM', if_true: files('openpic_kvm.c')) specific_ss.add(when: 'CONFIG_POWERNV', if_true: files('xics_pnv.c', 'pnv_xive.c')) +specific_ss.add(when: 'CONFIG_PPC_UIC', if_true: files('ppc-uic.c')) specific_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_ic.c', 'bcm2836_control.c')) specific_ss.add(when: 'CONFIG_RX_ICU', if_true: files('rx_icu.c')) specific_ss.add(when: 'CONFIG_S390_FLIC', if_true: files('s390_flic.c'))
hw/intc/ppc-uic.c new file +321 -0
321 lines not on this page · raw message
hw/ppc/Kconfig +1 -0
@@ -53,6 +53,7 @@ config PPC4XX bool select BITBANG_I2C select PCI + select PPC_UIC config SAM460EX bool
hw/ppc/ppc4xx_devs.c +30 -237
289 lines not on this page · raw message
include/hw/intc/ppc-uic.h new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
2.29.2
[PULL 04/22] hw/ppc/ppc440_bamboo: Drop use of ppcuic_init()
In reply to David GibsonFrom: Peter Maydell <[email protected]>
Switch the bamboo board to directly creating and configuring the UIC, rather than doing it via the old ppcuic_init() helper function.
Message-Id: <[email protected]>
--- hw/ppc/ppc440_bamboo.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-)
hw/ppc/ppc440_bamboo.c +27 -11
@@ -33,6 +33,9 @@#include "sysemu/qtest.h" #include "sysemu/reset.h" #include "hw/sysbus.h" +#include "hw/intc/ppc-uic.h" +#include "hw/qdev-properties.h" +#include "qapi/error.h" #define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
@@ -168,13 +171,13 @@ static void bamboo_init(MachineState *machine)MemoryRegion *ram_memories =g_new (MemoryRegion,PPC440EP_SDRAM_NR_BANKS );hwaddr ram_bases[PPC440EP_SDRAM_NR_BANKS ];hwaddr ram_sizes[PPC440EP_SDRAM_NR_BANKS ]; -qemu_irq *pic; -qemu_irq *irqs;PCIBus *pcibus;PowerPCCPU *cpu;CPUPPCState *env;target_long initrd_size =0 ;DeviceState *dev; +DeviceState *uicdev; +SysBusDevice *uicsbd;int success;int i;
@@ -192,10 +195,17 @@ static void bamboo_init(MachineState *machine)ppc_dcr_init (env,NULL ,NULL );/* interrupt controller */ - irqs =g_new0 (qemu_irq,PPCUIC_OUTPUT_NB ); - irqs[PPCUIC_OUTPUT_INT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]; - irqs[PPCUIC_OUTPUT_CINT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]; - pic =ppcuic_init (env, irqs,0x0C0 ,0 ,1 ); + uicdev =qdev_new (TYPE_PPC_UIC ); + uicsbd =SYS_BUS_DEVICE (uicdev); + +object_property_set_link (OBJECT (uicdev),"cpu" ,OBJECT (cpu), + &error_fatal); +sysbus_realize_and_unref (uicsbd, &error_fatal); + +sysbus_connect_irq (uicsbd,PPCUIC_OUTPUT_INT , + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]); +sysbus_connect_irq (uicsbd,PPCUIC_OUTPUT_CINT , + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]);/* SDRAM controller */ memset (ram_bases,0 ,sizeof (ram_bases));
@@ -203,14 +213,18 @@ static void bamboo_init(MachineState *machine)ppc4xx_sdram_banks (machine->ram,PPC440EP_SDRAM_NR_BANKS , ram_memories, ram_bases, ram_sizes, ppc440ep_sdram_bank_sizes);/* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. */ -ppc4xx_sdram_init (env, pic[14 ],PPC440EP_SDRAM_NR_BANKS , ram_memories, +ppc4xx_sdram_init (env, +qdev_get_gpio_in (uicdev,14 ), +PPC440EP_SDRAM_NR_BANKS , ram_memories, ram_bases, ram_sizes,1 );/* PCI */ dev =sysbus_create_varargs (TYPE_PPC4xx_PCI_HOST_BRIDGE,PPC440EP_PCI_CONFIG , - pic[pci_irq_nrs[0 ]], pic[pci_irq_nrs[1 ]], - pic[pci_irq_nrs[2 ]], pic[pci_irq_nrs[3 ]], +qdev_get_gpio_in (uicdev, pci_irq_nrs[0 ]), +qdev_get_gpio_in (uicdev, pci_irq_nrs[1 ]), +qdev_get_gpio_in (uicdev, pci_irq_nrs[2 ]), +qdev_get_gpio_in (uicdev, pci_irq_nrs[3 ]),NULL ); pcibus = (PCIBus *)qdev_get_child_bus (dev,"pci.0" );if (!pcibus) {
@@ -223,12 +237,14 @@ static void bamboo_init(MachineState *machine)memory_region_add_subregion (get_system_memory (),PPC440EP_PCI_IO , isa);if (serial_hd (0 ) !=NULL ) { -serial_mm_init (address_space_mem,0xef600300 ,0 , pic[0 ], +serial_mm_init (address_space_mem,0xef600300 ,0 , +qdev_get_gpio_in (uicdev,0 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ),DEVICE_BIG_ENDIAN ); }if (serial_hd (1 ) !=NULL ) { -serial_mm_init (address_space_mem,0xef600400 ,0 , pic[1 ], +serial_mm_init (address_space_mem,0xef600400 ,0 , +qdev_get_gpio_in (uicdev,1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ),DEVICE_BIG_ENDIAN ); }
Signature · 1 line
2.29.2
[PULL 01/22] hw/ppc/ppc4xx_devs: Make code style fixes to UIC code
In reply to David GibsonFrom: Peter Maydell <[email protected]>
In a following commit we will move the PPC UIC implementation to its own file in hw/intc. To prevent checkpatch complaining about that code-motion, fix up the minor style issues first.
Message-Id: <[email protected]>
--- hw/ppc/ppc4xx_devs.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
hw/ppc/ppc4xx_devs.c +15 -10
@@ -105,7 +105,7 @@ struct ppcuic_t {qemu_irq *irqs; }; -static void ppcuic_trigger_irq (ppcuic_t *uic) +static void ppcuic_trigger_irq (ppcuic_t *uic) {uint32_t ir, cr;int start, end, inc, i;
@@ -156,26 +156,28 @@ static void ppcuic_trigger_irq (ppcuic_t *uic) } } -static void ppcuic_set_irq (void *opaque,int irq_num,int level) +static void ppcuic_set_irq (void *opaque,int irq_num,int level) {ppcuic_t *uic;uint32_t mask, sr; uic = opaque; - mask =1U << (31 -irq_num); + mask =1U << (31 - irq_num);LOG_UIC ("%s: irq %d level %d uicsr %08" PRIx32" mask %08" PRIx32" => %08" PRIx32" %08" PRIx32"\n" , __func__, irq_num, level, uic->uicsr, mask, uic->uicsr & mask, level << irq_num); -if (irq_num <0 || irq_num >31 ) +if (irq_num <0 || irq_num >31 ) {return ; + } sr = uic->uicsr;/* Update status register */ if (uic->uictr & mask) {/* Edge sensitive interrupt */ -if (level ==1 ) +if (level ==1 ) { uic->uicsr |= mask; + } }else {/* Level sensitive interrupt */ if (level ==1 ) {
@@ -188,11 +190,12 @@ static void ppcuic_set_irq (void *opaque, int irq_num, int level) }LOG_UIC ("%s: irq %d level %d sr %" PRIx32" => " "%08" PRIx32"\n" , __func__, irq_num, level, uic->uicsr, sr); -if (sr != uic->uicsr) +if (sr != uic->uicsr) {ppcuic_trigger_irq (uic); + } } -static uint32_t dcr_read_uic (void *opaque,int dcrn) +static uint32_t dcr_read_uic (void *opaque,int dcrn) {ppcuic_t *uic;uint32_t ret;
@@ -220,13 +223,15 @@ static uint32_t dcr_read_uic (void *opaque, int dcrn) ret = uic->uicsr & uic->uicer;break ;case DCR_UICVR : -if (!uic->use_vectors) +if (!uic->use_vectors) { goto no_read; + } ret = uic->uicvr;break ;case DCR_UICVCR : -if (!uic->use_vectors) +if (!uic->use_vectors) { goto no_read; + } ret = uic->uicvcr;break ;default :
@@ -238,7 +243,7 @@ static uint32_t dcr_read_uic (void *opaque, int dcrn)return ret; } -static void dcr_write_uic (void *opaque,int dcrn,uint32_t val) +static void dcr_write_uic (void *opaque,int dcrn,uint32_t val) {ppcuic_t *uic;
Signature · 1 line
2.29.2
[PULL 07/22] spapr: Fix DR properties of the root node
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Section 13.5.2 of LoPAPR mandates various DR related indentifiers for all hot-pluggable entities to be exposed in the "ibm,drc-indexes", "ibm,drc-power-domains", "ibm,drc-names" and "ibm,drc-types" properties of their parent node. These properties are created with spapr_dt_drc().
PHBs and LMBs are both children of the machine. Their DR identifiers are thus supposed to be exposed in the afore mentioned properties of the root node.
When PHB hot-plug support was added, an extra call to spapr_dt_drc() was introduced: this overwrites the existing properties, previously populated with the LMB identifiers, and they end up containing only PHB identifiers. This went unseen so far because linux doesn't care, but this is still not conformant with LoPAPR.
Fortunately spapr_dt_drc() is able to handle multiple DR entity types at the same time. Use that to handle DR indentifiers for PHBs and LMBs with a single call to spapr_dt_drc(). While here also account for PMEM DR identifiers, which were forgotten when NVDIMM hot-plug support was added. Also add an assert to prevent further misuse of spapr_dt_drc().
With -m 1G,maxmem=2G,slots=8 passed on the QEMU command line we get:
Without this patch:
/proc/device-tree/ibm,drc-indexes
0000001f 20000001 20000002 20000003 20000000 20000005 20000006 20000007 20000004 20000009 20000008 20000010 20000011 20000012 20000013 20000014 20000015 20000016 20000017 20000018 20000019 2000000a 2000000b 2000000c 2000000d 2000000e 2000000f 2000001a 2000001b 2000001c 2000001d 2000001e
These are the DRC indexes for the 31 possible PHBs.
With this patch:
/proc/device-tree/ibm,drc-indexes
0000002b 90000000 90000001 90000002 90000003 90000004 90000005 90000006 90000007 20000001 20000002 20000003 20000000 20000005 20000006 20000007 20000004 20000009 20000008 20000010 20000011 20000012 20000013 20000014 20000015 20000016 20000017 20000018 20000019 2000000a 2000000b 2000000c 2000000d 2000000e 2000000f 2000001a 2000001b 2000001c 2000001d 2000001e 80000004 80000005 80000006 80000007
And now we also have the 4 ((2G - 1G) / 256M) LMBs and the 8 (slots) PMEMs.
Message-Id: <[email protected]>
--- hw/ppc/spapr.c | 21 ++++++++++++--------- hw/ppc/spapr_drc.c | 6 ++++++ 2 files changed, 18 insertions(+), 9 deletions(-)
hw/ppc/spapr.c +12 -9
@@ -1120,6 +1120,7 @@ void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space)MachineState *machine =MACHINE (spapr);MachineClass *mc =MACHINE_GET_CLASS (machine);SpaprMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine); +uint32_t root_drc_type_mask =0 ;int ret;void *fdt;SpaprPhbState *phb;
@@ -1194,8 +1195,18 @@ void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space)spapr_dt_cpus (fdt, spapr); +/* ibm,drc-indexes and friends */ if (smc->dr_lmb_enabled) { -_FDT (spapr_dt_drc (fdt,0 ,NULL ,SPAPR_DR_CONNECTOR_TYPE_LMB )); + root_drc_type_mask |=SPAPR_DR_CONNECTOR_TYPE_LMB ; + } +if (smc->dr_phb_enabled) { + root_drc_type_mask |=SPAPR_DR_CONNECTOR_TYPE_PHB ; + } +if (mc->nvdimm_supported) { + root_drc_type_mask |=SPAPR_DR_CONNECTOR_TYPE_PMEM ; + } +if (root_drc_type_mask) { +_FDT (spapr_dt_drc (fdt,0 ,NULL , root_drc_type_mask)); }if (mc->has_hotpluggable_cpus) {
@@ -1233,14 +1244,6 @@ void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space) } } -if (smc->dr_phb_enabled) { - ret =spapr_dt_drc (fdt,0 ,NULL ,SPAPR_DR_CONNECTOR_TYPE_PHB ); -if (ret <0 ) { -error_report ("Couldn't set up PHB DR device tree properties" ); -exit (1 ); - } - } -/* NVDIMM devices */ if (mc->nvdimm_supported) {spapr_dt_persistent_memory (spapr, fdt);
hw/ppc/spapr_drc.c +6 -0
@@ -832,6 +832,12 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask)GString *drc_names, *drc_types;int ret; +/* +* This should really be only called once per node since it overwrites +* the OF properties if they already exist. +*/ +g_assert (!fdt_get_property (fdt, offset,"ibm,drc-indexes" ,NULL )); +/* the first entry of each properties is a 32-bit integer encoding * the number of elements in the array. we won't know this until * we complete the iteration through all the matching DRCs, but
Signature · 1 line
2.29.2
[PULL 09/22] spapr: Fix buffer overflow in spapr_numa_associativity_init()
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Running a guest with 128 NUMA nodes crashes QEMU:
../../util/error.c:59: error_setv: Assertion `*errp == NULL' failed.
The crash happens when setting the FWNMI migration blocker:
2861 if (spapr_get_cap(spapr, SPAPR_CAP_FWNMI) == SPAPR_CAP_ON) {
2862 /* Create the error string for live migration blocker */
2863 error_setg(&spapr->fwnmi_migration_blocker,
2864 "A machine check is being handled during migration. The handler"
2865 "may run and log hardware error on the destination");
2866 }
Inspection reveals that papr->fwnmi_migration_blocker isn't NULL:
(gdb) p spapr->fwnmi_migration_blocker
$1 = (Error *) 0x8000000004000000
Since this is the only place where papr->fwnmi_migration_blocker is set, this means someone wrote there in our back. Further analysis points to spapr_numa_associativity_init(), especially the part that initializes the associative arrays for NVLink GPUs:
max_nodes_with_gpus = nb_numa_nodes + NVGPU_MAX_NUM;
ie. max_nodes_with_gpus = 128 + 6, but the array isn't sized to accommodate the 6 extra nodes:
struct SpaprMachineState {
.
.
.
uint32_t numa_assoc_array[MAX_NODES][NUMA_ASSOC_SIZE];
Error *fwnmi_migration_blocker;
};and the following loops happily overwrite spapr->fwnmi_migration_blocker, and probably more:
for (i = nb_numa_nodes; i < max_nodes_with_gpus; i++) {
spapr->numa_assoc_array[i][0] = cpu_to_be32(MAX_DISTANCE_REF_POINTS);
for (j = 1; j < MAX_DISTANCE_REF_POINTS; j++) {
uint32_t gpu_assoc = smc->pre_5_1_assoc_refpoints ?
SPAPR_GPU_NUMA_ID : cpu_to_be32(i);
spapr->numa_assoc_array[i][j] = gpu_assoc;
}
spapr->numa_assoc_array[i][MAX_DISTANCE_REF_POINTS] = cpu_to_be32(i);
}Fix the size of the array. This requires "hw/ppc/spapr.h" to see NVGPU_MAX_NUM. Including "hw/pci-host/spapr.h" introduces a circular dependency that breaks the build, so this moves the definition of NVGPU_MAX_NUM to "hw/ppc/spapr.h" instead.
Message-Id: <[email protected]>
--- include/hw/pci-host/spapr.h | 2 -- include/hw/ppc/spapr.h | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-)
include/hw/pci-host/spapr.h +0 -2
@@ -115,8 +115,6 @@ struct SpaprPhbState {#define SPAPR_PCI_NV2RAM64_WIN_BASE SPAPR_PCI_LIMIT#define SPAPR_PCI_NV2RAM64_WIN_SIZE (2 * TiB)/* For up to 6 GPUs 256GB each */ -/* Max number of these GPUsper a physical box */ -#define NVGPU_MAX_NUM 6/* Max number of NVLinks per GPU in any physical box */ #define NVGPU_MAX_LINKS 3
include/hw/ppc/spapr.h +4 -1
@@ -112,6 +112,9 @@ typedef enum {#define NUMA_ASSOC_SIZE (MAX_DISTANCE_REF_POINTS + 1)#define VCPU_ASSOC_SIZE (NUMA_ASSOC_SIZE + 1) +/* Max number of these GPUsper a physical box */ +#define NVGPU_MAX_NUM 6 +typedef struct SpaprCapabilities SpaprCapabilities ;struct SpaprCapabilities {uint8_t caps[SPAPR_CAP_NUM ];
@@ -240,7 +243,7 @@ struct SpaprMachineState {unsigned gpu_numa_id;SpaprTpmProxy *tpm_proxy; -uint32_t numa_assoc_array[MAX_NODES ][NUMA_ASSOC_SIZE ]; +uint32_t numa_assoc_array[MAX_NODES +NVGPU_MAX_NUM ][NUMA_ASSOC_SIZE ];Error *fwnmi_migration_blocker; };
Signature · 1 line
2.29.2
[PULL 06/22] spapr/xive: Make spapr_xive_pic_print_info() static
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
Message-Id: <[email protected]>
--- hw/intc/spapr_xive.c | 2 +- include/hw/ppc/spapr_xive.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
hw/intc/spapr_xive.c +1 -1
@@ -156,7 +156,7 @@ static void spapr_xive_end_pic_print_info(SpaprXive *xive, XiveEND *end,#define spapr_xive_in_kernel (xive) \ (kvm_irqchip_in_kernel() && (xive)->fd != -1) -void spapr_xive_pic_print_info (SpaprXive *xive,Monitor *mon) +static void spapr_xive_pic_print_info (SpaprXive *xive,Monitor *mon) {XiveSource *xsrc = &xive->source;int i;
include/hw/ppc/spapr_xive.h +0 -2
@@ -66,8 +66,6 @@ typedef struct SpaprXiveClass {*/ #define SPAPR_XIVE_BLOCK_ID 0x0 -void spapr_xive_pic_print_info (SpaprXive *xive,Monitor *mon); -struct SpaprMachineState ;void spapr_xive_hcall_init (struct SpaprMachineState *spapr);void spapr_xive_mmio_set_enabled (SpaprXive *xive,bool enable);
Signature · 1 line
2.29.2
[PULL 12/22] spapr: Introduce spapr_drc_reset_all()
In reply to David GibsonFrom: Greg Kurz <[email protected]>
No need to expose the way DRCs are traversed outside of spapr_drc.c.
Message-Id: <[email protected]>
--- hw/ppc/spapr_drc.c | 31 +++++++++++++++++++++++++++++ hw/ppc/spapr_hcall.c | 40 ++++++-------------------------------- include/hw/ppc/spapr_drc.h | 6 ++++++ 3 files changed, 43 insertions(+), 34 deletions(-)
hw/ppc/spapr_drc.c +31 -0
@@ -949,6 +949,37 @@ out:return ret; } +void spapr_drc_reset_all (SpaprMachineState *spapr) +{ +Object *drc_container; +ObjectProperty *prop; +ObjectPropertyIterator iter; + + drc_container =container_get (object_get_root (),DRC_CONTAINER_PATH ); +restart: +object_property_iter_init (&iter, drc_container); +while ((prop =object_property_iter_next (&iter))) { +SpaprDrc *drc; + +if (!strstart (prop->type,"link<" ,NULL )) { +continue ; + } + drc =SPAPR_DR_CONNECTOR (object_property_get_link (drc_container, + prop->name, + &error_abort)); + +/* +* This will complete any pending plug/unplug requests. +* In case of a unplugged PHB or PCI bridge, this will +* cause some DRCs to be destroyed and thus potentially +* invalidate the iterator. +*/ +if (spapr_drc_reset (drc)) { + goto restart; + } + } +} +/* * RTAS calls */
hw/ppc/spapr_hcall.c +6 -34
@@ -1632,39 +1632,6 @@ static uint32_t cas_check_pvr(PowerPCCPU *cpu, uint32_t max_compat,return best_compat; } -static void spapr_handle_transient_dev_before_cas (SpaprMachineState *spapr) -{ -Object *drc_container; -ObjectProperty *prop; -ObjectPropertyIterator iter; - - drc_container =container_get (object_get_root (),"/dr-connector" ); -restart: -object_property_iter_init (&iter, drc_container); -while ((prop =object_property_iter_next (&iter))) { -SpaprDrc *drc; - -if (!strstart (prop->type,"link<" ,NULL )) { -continue ; - } - drc =SPAPR_DR_CONNECTOR (object_property_get_link (drc_container, - prop->name, - &error_abort)); - -/* -* This will complete any pending plug/unplug requests. -* In case of a unplugged PHB or PCI bridge, this will -* cause some DRCs to be destroyed and thus potentially -* invalidate the iterator. -*/ -if (spapr_drc_reset (drc)) { - goto restart; - } - } - -spapr_clear_pending_hotplug_events (spapr); -} - target_ulong do_client_architecture_support(PowerPCCPU *cpu, SpaprMachineState *spapr, target_ulong vec,
@@ -1822,7 +1789,12 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,spapr_irq_update_active_intc (spapr); -spapr_handle_transient_dev_before_cas (spapr); +/* +* Process all pending hot-plug/unplug requests now. An updated full +* rendered FDT will be returned to the guest. +*/ +spapr_drc_reset_all (spapr); +spapr_clear_pending_hotplug_events (spapr);/* * If spapr_machine_reset() did not set up a HPT but one is necessary
include/hw/ppc/spapr_drc.h +6 -0
@@ -245,6 +245,12 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask);void spapr_drc_attach (SpaprDrc *drc,DeviceState *d);void spapr_drc_detach (SpaprDrc *drc); +/* +* Reset all DRCs, causing pending hot-plug/unplug requests to complete. +* Safely handles potential DRC removal (eg. PHBs or PCI bridges). +*/ +void spapr_drc_reset_all (struct SpaprMachineState *spapr); +static inline bool spapr_drc_unplug_requested (SpaprDrc *drc) {return drc->unplug_requested;
Signature · 1 line
2.29.2
[PULL 10/22] spapr: Call spapr_drc_reset() for all DRCs at CAS
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Non-transient DRCs are either in the empty or the ready state, which means spapr_drc_reset() doesn't change their state. It is thus not needed to do any checking. Call spapr_drc_reset() unconditionally and squash spapr_drc_transient() into its only user, spapr_drc_needed().
Message-Id: <[email protected]>
--- hw/ppc/spapr_drc.c | 8 ++------ hw/ppc/spapr_hcall.c | 7 ++++--- include/hw/ppc/spapr_drc.h | 3 --- 3 files changed, 6 insertions(+), 12 deletions(-)
hw/ppc/spapr_drc.c +2 -6
@@ -462,8 +462,9 @@ static const VMStateDescription vmstate_spapr_drc_unplug_requested = { } }; -bool spapr_drc_transient (SpaprDrc *drc) +static bool spapr_drc_needed (void *opaque) { +SpaprDrc *drc = opaque;SpaprDrcClass *drck =SPAPR_DR_CONNECTOR_GET_CLASS (drc);/*
@@ -483,11 +484,6 @@ bool spapr_drc_transient(SpaprDrc *drc)spapr_drc_unplug_requested (drc); } -static bool spapr_drc_needed (void *opaque) -{ -return spapr_drc_transient (opaque); -} -static const VMStateDescription vmstate_spapr_drc = { .name ="spapr_drc" , .version_id =1 ,
hw/ppc/spapr_hcall.c +4 -3
@@ -1650,9 +1650,10 @@ static void spapr_handle_transient_dev_before_cas(SpaprMachineState *spapr) prop->name, &error_abort)); -if (spapr_drc_transient (drc)) { -spapr_drc_reset (drc); - } +/* +* This will complete any pending plug/unplug requests. +*/ +spapr_drc_reset (drc); }spapr_clear_pending_hotplug_events (spapr);
include/hw/ppc/spapr_drc.h +0 -3
@@ -244,9 +244,6 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask);void spapr_drc_attach (SpaprDrc *drc,DeviceState *d);void spapr_drc_detach (SpaprDrc *drc); -/* Returns true if a hot plug/unplug request is pending */ -bool spapr_drc_transient (SpaprDrc *drc); -static inline bool spapr_drc_unplug_requested (SpaprDrc *drc) {return drc->unplug_requested;
Signature · 1 line
2.29.2
[PULL 08/22] spapr: Allow memory unplug to always succeed
In reply to David GibsonFrom: Greg Kurz <[email protected]>
It is currently impossible to hot-unplug a memory device between machine reset and CAS.
(qemu) device_del dimm1
Error: Memory hot unplug not supported for this guest
This limitation was introduced in order to provide an explicit error path for older guests that didn't support hot-plug event sources (and thus memory hot-unplug).
The linux kernel has been supporting these since 4.11. All recent enough guests are thus capable of handling the removal of a memory device at all time, including during early boot.
Lift the limitation for the latest machine type. This means that trying to unplug memory from a guest that doesn't support it will likely just do nothing and the memory will only get removed at next reboot. Such older guests can still get the existing behavior by using an older machine type.
Message-Id: <[email protected]>
--- hw/ppc/spapr.c | 6 +++++- hw/ppc/spapr_events.c | 3 ++- include/hw/ppc/spapr.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +5 -1
@@ -4069,7 +4069,8 @@ static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,SpaprMachineClass *smc =SPAPR_MACHINE_CLASS (mc);if (object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) { -if (spapr_ovec_test (sms->ov5_cas,OV5_HP_EVT )) { +if (!smc->pre_6_0_memory_unplug || +spapr_ovec_test (sms->ov5_cas,OV5_HP_EVT )) {spapr_memory_unplug_request (hotplug_dev, dev, errp); }else {/* NOTE: this means there is a window after guest reset, prior to
@@ -4555,8 +4556,11 @@ DEFINE_SPAPR_MACHINE(6_0, "6.0", true);*/ static void spapr_machine_5_2_class_options (MachineClass *mc) { +SpaprMachineClass *smc =SPAPR_MACHINE_CLASS (mc); +spapr_machine_6_0_class_options (mc);compat_props_add (mc->compat_props, hw_compat_5_2, hw_compat_5_2_len); + smc->pre_6_0_memory_unplug = true; } DEFINE_SPAPR_MACHINE(5_2, "5.2", false);
hw/ppc/spapr_events.c +2 -1
@@ -658,7 +658,8 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,/* we should not be using count_indexed value unless the guest * supports dedicated hotplug event source */ -g_assert (spapr_ovec_test (spapr->ov5_cas,OV5_HP_EVT )); +g_assert (!SPAPR_MACHINE_GET_CLASS (spapr)->pre_6_0_memory_unplug || +spapr_ovec_test (spapr->ov5_cas,OV5_HP_EVT )); hp->drc_id.count_indexed.count =cpu_to_be32 (drc_id->count_indexed.count); hp->drc_id.count_indexed.index =
include/hw/ppc/spapr.h +1 -0
@@ -139,6 +139,7 @@ struct SpaprMachineClass {hwaddr rma_limit;/* clamp the RMA to this size */ bool pre_5_1_assoc_refpoints;bool pre_5_2_numa_associativity; +bool pre_6_0_memory_unplug; bool (*phb_placement)(SpaprMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,
Signature · 1 line
2.29.2
[PULL 14/22] spapr: Add drc_ prefix to the DRC realize and unrealize functions
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Use a less generic name for an easier experience with tools such as cscope or grep.
Message-Id: <[email protected]>
--- hw/ppc/spapr_drc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/ppc/spapr_drc.c +6 -6
@@ -503,7 +503,7 @@ static const VMStateDescription vmstate_spapr_drc = { } }; -static void realize (DeviceState *d,Error **errp) +static void drc_realize (DeviceState *d,Error **errp) {SpaprDrc *drc =SPAPR_DR_CONNECTOR (d);Object *root_container;
@@ -530,7 +530,7 @@ static void realize(DeviceState *d, Error **errp)trace_spapr_drc_realize_complete (spapr_drc_index (drc)); } -static void unrealize (DeviceState *d) +static void drc_unrealize (DeviceState *d) {SpaprDrc *drc =SPAPR_DR_CONNECTOR (d);Object *root_container;
@@ -579,8 +579,8 @@ static void spapr_dr_connector_class_init(ObjectClass *k, void *data) {DeviceClass *dk =DEVICE_CLASS (k); - dk->realize = realize; - dk->unrealize = unrealize; + dk->realize = drc_realize; + dk->unrealize = drc_unrealize;/* * Reason: DR connector needs to be wired to either the machine or to a * PHB in spapr_dr_connector_new().
@@ -628,7 +628,7 @@ static void realize_physical(DeviceState *d, Error **errp)SpaprDrcPhysical *drcp =SPAPR_DRC_PHYSICAL (d);Error *local_err =NULL ; -realize (d, &local_err); +drc_realize (d, &local_err);if (local_err) {error_propagate (errp, local_err);return ;
@@ -644,7 +644,7 @@ static void unrealize_physical(DeviceState *d) {SpaprDrcPhysical *drcp =SPAPR_DRC_PHYSICAL (d); -unrealize (d); +drc_unrealize (d);vmstate_unregister (VMSTATE_IF (drcp), &vmstate_spapr_drc_physical, drcp);qemu_unregister_reset (drc_physical_reset, drcp); }
Signature · 1 line
2.29.2
[PULL 17/22] pnv: Fix reverse dependency on PCI express root ports
In reply to David GibsonFrom: Greg Kurz <[email protected]>
qemu-system-ppc64 built with --without-default-devices crashes:
Type 'pnv-phb4-root-port' is missing its parent 'pcie-root-port-base' Aborted (core dumped)
Have POWERNV to select PCIE_PORT. This is done through a new PCI_POWERNV config in hw/pci-host/Kconfig since POWERNV doesn't have a direct dependency on PCI. For this reason, PCI_EXPRESS and MSI_NONBROKEN are also moved under PCI_POWERNV.
Message-Id: <[email protected]>
--- hw/pci-host/Kconfig | 5 +++++ hw/pci-host/meson.build | 2 +- hw/ppc/Kconfig | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-)
hw/pci-host/Kconfig +5 -0
@@ -60,3 +60,8 @@ config PCI_BONITO select PCI select UNIMP bool + +config PCI_POWERNV + select PCI_EXPRESS + select MSI_NONBROKEN + select PCIE_PORT
hw/pci-host/meson.build +1 -1
@@ -23,7 +23,7 @@ pci_ss.add(when: 'CONFIG_VERSATILE_PCI', if_true: files('versatile.c')) softmmu_ss.add_all(when: 'CONFIG_PCI', if_true: pci_ss) -specific_ss.add(when: 'CONFIG_POWERNV', if_true: files( +specific_ss.add(when: 'CONFIG_PCI_POWERNV', if_true: files( 'pnv_phb3.c', 'pnv_phb3_msi.c', 'pnv_phb3_pbcq.c',
hw/ppc/Kconfig +1 -2
@@ -29,8 +29,7 @@ config POWERNV select XICS select XIVE select FDT_PPC - select PCI_EXPRESS - select MSI_NONBROKEN + select PCI_POWERNV config PPC405 bool
Signature · 1 line
2.29.2
[PULL 05/22] spapr: DRC lookup cannot fail
In reply to David GibsonFrom: Greg Kurz <[email protected]>
All memory DRC objects are created during machine init. It is thus safe to assume spapr_drc_by_id() cannot return NULL when hot-plug/unplugging memory.
Make this clear with an assertion, like the code already does a few lines above when looping over memory DRCs. This fixes Coverity reports 1437757 and 1437758.
Message-Id: <[email protected]>
--- hw/ppc/spapr.c | 2 ++ 1 file changed, 2 insertions(+)
hw/ppc/spapr.c +2 -0
@@ -3437,6 +3437,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,if (dedicated_hp_event_source) { drc =spapr_drc_by_id (TYPE_SPAPR_DRC_LMB , addr_start /SPAPR_MEMORY_BLOCK_SIZE ); +g_assert (drc);spapr_hotplug_req_add_by_count_indexed (SPAPR_DR_CONNECTOR_TYPE_LMB , nr_lmbs,spapr_drc_index (drc));
@@ -3677,6 +3678,7 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev, drc =spapr_drc_by_id (TYPE_SPAPR_DRC_LMB , addr_start /SPAPR_MEMORY_BLOCK_SIZE ); +g_assert (drc);spapr_hotplug_req_remove_by_count_indexed (SPAPR_DR_CONNECTOR_TYPE_LMB , nr_lmbs,spapr_drc_index (drc)); }
Signature · 1 line
2.29.2
[PULL 19/22] sam460ex: Remove FDT_PPC dependency from KConfig
In reply to David GibsonFrom: BALATON Zoltan via <[email protected]>
Dependency on FDT_PPC was added in commit b0048f76095 ("hw/ppc/Kconfig: Only select FDT helper for machines using it") but it does not seem to be really necessary so remove it again.
Message-Id: <7461a20b129a912aeacdb9ad115a55f0b84c8726.1609636173.git.balaton@eik.bme.hu>
--- hw/ppc/Kconfig | 1 - 1 file changed, 1 deletion(-)
hw/ppc/Kconfig +0 -1
@@ -64,7 +64,6 @@ config SAM460EX select SMBUS_EEPROM select USB_EHCI_SYSBUS select USB_OHCI - select FDT_PPC config PREP bool
Signature · 1 line
2.29.2
[PULL 11/22] spapr: Fix reset of transient DR connectors
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Documentation of object_property_iter_init() clearly stipulates that "it is forbidden to modify the property list while iterating". But this is exactly what we do when resetting transient DR connectors during CAS. The call to spapr_drc_reset() can finalize the hot-unplug sequence of a PHB or a PCI bridge, both of which will then in turn destroy their PCI DRCs. This could potentially invalidate the iterator. It is pure luck that this haven't caused any issues so far.
Change spapr_drc_reset() to return true if it caused a device to be removed. Restart from scratch in this case. This can potentially increase the overall DRC reset time, especially with a high maxmem which generates a lot of LMB DRCs. But this kind of setup is rare, and so is the use case of rebooting a guest while doing hot-unplug.
Message-Id: <[email protected]>
--- hw/ppc/spapr_drc.c | 6 +++++- hw/ppc/spapr_hcall.c | 8 +++++++- include/hw/ppc/spapr_drc.h | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-)
hw/ppc/spapr_drc.c +5 -1
@@ -417,9 +417,10 @@ void spapr_drc_detach(SpaprDrc *drc)spapr_drc_release (drc); } -void spapr_drc_reset (SpaprDrc *drc) +bool spapr_drc_reset (SpaprDrc *drc) {SpaprDrcClass *drck =SPAPR_DR_CONNECTOR_GET_CLASS (drc); +bool unplug_completed = false;trace_spapr_drc_reset (spapr_drc_index (drc));
@@ -428,6 +429,7 @@ void spapr_drc_reset(SpaprDrc *drc)*/ if (drc->unplug_requested) {spapr_drc_release (drc); + unplug_completed = true; }if (drc->dev) {
@@ -444,6 +446,8 @@ void spapr_drc_reset(SpaprDrc *drc) drc->ccs_offset =-1 ; drc->ccs_depth =-1 ; } + +return unplug_completed; }static bool spapr_drc_unplug_requested_needed (void *opaque)
hw/ppc/spapr_hcall.c +7 -1
@@ -1639,6 +1639,7 @@ static void spapr_handle_transient_dev_before_cas(SpaprMachineState *spapr)ObjectPropertyIterator iter; drc_container =container_get (object_get_root (),"/dr-connector" ); +restart:object_property_iter_init (&iter, drc_container);while ((prop =object_property_iter_next (&iter))) {SpaprDrc *drc;
@@ -1652,8 +1653,13 @@ static void spapr_handle_transient_dev_before_cas(SpaprMachineState *spapr)/* * This will complete any pending plug/unplug requests. +* In case of a unplugged PHB or PCI bridge, this will +* cause some DRCs to be destroyed and thus potentially +* invalidate the iterator. */ -spapr_drc_reset (drc); +if (spapr_drc_reset (drc)) { + goto restart; + } }spapr_clear_pending_hotplug_events (spapr);
include/hw/ppc/spapr_drc.h +2 -1
@@ -224,7 +224,8 @@ static inline bool spapr_drc_hotplugged(DeviceState *dev)return dev->hotplugged && !runstate_check (RUN_STATE_INMIGRATE ); } -void spapr_drc_reset (SpaprDrc *drc); +/* Returns true if an unplug request completed */ +bool spapr_drc_reset (SpaprDrc *drc);uint32_t spapr_drc_index (SpaprDrc *drc);SpaprDrcType spapr_drc_type (SpaprDrc *drc);
Signature · 1 line
2.29.2
[PULL 15/22] ppc: Fix build with --without-default-devices
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Linking of the qemu-system-ppc64 fails on a POWER9 host when --without-default-devices is passed to configure:
$ ./configure --without-default-devices \
--target-list=ppc64-softmmu && make...
libqemu-ppc64-softmmu.fa.p/hw_ppc_e500.c.o: In function `ppce500_init_mpic_kvm':/home/greg/Work/qemu/qemu-ppc/build/../hw/ppc/e500.c:777: undefined reference to kvm_openpic_connect_vcpu' libqemu-ppc64-softmmu.fa.p/hw_ppc_spapr_irq.c.o: In function spapr_irq_check':/home/greg/Work/qemu/qemu-ppc/build/../hw/ppc/spapr_irq.c:189: undefined reference to xics_kvm_has_broken_disconnect' libqemu-ppc64-softmmu.fa.p/hw_intc_spapr_xive.c.o: In function spapr_xive_post_load':/home/greg/Work/qemu/qemu-ppc/build/../hw/intc/spapr_xive.c:530: undefined reference to `kvmppc_xive_post_load'
... and tons of other symbols belonging to the KVM backend of the openpic, XICS and XIVE interrupt controllers.
It turns out that OPENPIC_KVM, XICS_KVM and XIVE_KVM are marked to depend on KVM but this has no effect when minikconf runs in allnoconfig mode. Such reverse dependencies should rather be handled with a 'select' statement, eg.
config OPENPIC
select OPENPIC_KVM if KVM
or even better by getting rid of the intermediate _KVM config and directly checking CONFIG_KVM in the meson.build file:
specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_OPENPIC'],
if_true: files('openpic_kvm.c'))Go for the latter with OPENPIC, XICS and XIVE.
This went unnoticed so far because CI doesn't test the build with --without-default-devices and KVM enabled on a POWER host.
Message-Id: <[email protected]>
--- hw/intc/Kconfig | 10 ---------- hw/intc/meson.build | 9 ++++++--- hw/ppc/Kconfig | 5 ----- 3 files changed, 6 insertions(+), 18 deletions(-)
hw/intc/Kconfig +0 -10
@@ -30,11 +30,6 @@ config ARM_GIC_KVM default y depends on ARM_GIC && KVM -config OPENPIC_KVM - bool - default y - depends on OPENPIC && KVM - config XICS bool depends on POWERNV || PSERIES
@@ -43,11 +38,6 @@ config XICS_SPAPR bool select XICS -config XICS_KVM - bool - default y - depends on XICS && KVM - config ALLWINNER_A10_PIC bool
hw/intc/meson.build +6 -3
@@ -39,7 +39,8 @@ specific_ss.add(when: 'CONFIG_LOONGSON_LIOINTC', if_true: files('loongson_lioint specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_gic.c')) specific_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_intc.c')) specific_ss.add(when: 'CONFIG_OMPIC', if_true: files('ompic.c')) -specific_ss.add(when: 'CONFIG_OPENPIC_KVM', if_true: files('openpic_kvm.c')) +specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_OPENPIC'], + if_true: files('openpic_kvm.c')) specific_ss.add(when: 'CONFIG_POWERNV', if_true: files('xics_pnv.c', 'pnv_xive.c')) specific_ss.add(when: 'CONFIG_PPC_UIC', if_true: files('ppc-uic.c')) specific_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_ic.c', 'bcm2836_control.c'))
@@ -50,8 +51,10 @@ specific_ss.add(when: 'CONFIG_SH4', if_true: files('sh_intc.c')) specific_ss.add(when: 'CONFIG_SIFIVE_CLINT', if_true: files('sifive_clint.c')) specific_ss.add(when: 'CONFIG_SIFIVE_PLIC', if_true: files('sifive_plic.c')) specific_ss.add(when: 'CONFIG_XICS', if_true: files('xics.c')) -specific_ss.add(when: 'CONFIG_XICS_KVM', if_true: files('xics_kvm.c')) +specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XICS'], + if_true: files('xics_kvm.c')) specific_ss.add(when: 'CONFIG_XICS_SPAPR', if_true: files('xics_spapr.c')) specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) -specific_ss.add(when: 'CONFIG_XIVE_KVM', if_true: files('spapr_xive_kvm.c')) +specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], + if_true: files('spapr_xive_kvm.c')) specific_ss.add(when: 'CONFIG_XIVE_SPAPR', if_true: files('spapr_xive.c'))
hw/ppc/Kconfig +0 -5
@@ -139,11 +139,6 @@ config XIVE_SPAPR depends on PSERIES select XIVE -config XIVE_KVM - bool - default y - depends on XIVE_SPAPR && KVM - # Only used by 64-bit targets config FW_CFG_PPC bool
Signature · 1 line
2.29.2
[PULL 13/22] spapr: Use spapr_drc_reset_all() at machine reset
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Documentation of object_child_foreach_recursive() clearly stipulates that "it is forbidden to add or remove children from @obj from the @fn callback". But this is exactly what we do during machine reset. The call to spapr_drc_reset() can finalize the hot-unplug sequence of a PHB or a PCI bridge, both of which will then in turn destroy their PCI DRCs. This could potentially invalidate the iterator used by do_object_child_foreach(). It is pure luck that this haven't caused any issues so far.
Use spapr_drc_reset_all() since it can cope with DRC removal.
Message-Id: <[email protected]>
--- hw/ppc/spapr.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
hw/ppc/spapr.c +1 -14
@@ -1566,19 +1566,6 @@ void spapr_setup_hpt(SpaprMachineState *spapr) } } -static int spapr_reset_drcs (Object *child,void *opaque) -{ -SpaprDrc *drc = - (SpaprDrc *)object_dynamic_cast (child, -TYPE_SPAPR_DR_CONNECTOR ); - -if (drc) { -spapr_drc_reset (drc); - } - -return 0 ; -} -static void spapr_machine_reset (MachineState *machine) {SpaprMachineState *spapr =SPAPR_MACHINE (machine);
@@ -1633,7 +1620,7 @@ static void spapr_machine_reset(MachineState *machine)* will crash QEMU if the DIMM holding the vring goes away). To avoid such * situations, we reset DRCs after all devices have been reset. */ -object_child_foreach_recursive (object_get_root (), spapr_reset_drcs,NULL ); +spapr_drc_reset_all (spapr);spapr_clear_pending_events (spapr);
Signature · 1 line
2.29.2
[PULL 18/22] ppc4xx: Move common dependency on serial to common option
In reply to David GibsonFrom: BALATON Zoltan via <[email protected]>
All machines that select SERIAL also select PPC4XX so we can just add this common dependency there once.
Message-Id: <94f1eb7cfb7f315bd883d825f3ce7e0cfc2f2b69.1609636173.git.balaton@eik.bme.hu>
--- hw/ppc/Kconfig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/ppc/Kconfig +1 -4
@@ -36,7 +36,6 @@ config PPC405 select M48T59 select PFLASH_CFI02 select PPC4XX - select SERIAL config PPC440 bool
@@ -45,7 +44,6 @@ config PPC440 imply E1000_PCI select PCI_EXPRESS select PPC4XX - select SERIAL select FDT_PPC config PPC4XX
@@ -53,6 +51,7 @@ config PPC4XX select BITBANG_I2C select PCI select PPC_UIC + select SERIAL config SAM460EX bool
@@ -61,7 +60,6 @@ config SAM460EX select IDE_SII3112 select M41T80 select PPC440 - select SERIAL select SM501 select SMBUS_EEPROM select USB_EHCI_SYSBUS
@@ -123,7 +121,6 @@ config VIRTEX bool select PPC4XX select PFLASH_CFI01 - select SERIAL select XILINX select XILINX_ETHLITE select FDT_PPC
Signature · 1 line
2.29.2
[PULL 16/22] ppc: Simplify reverse dependencies of POWERNV and PSERIES on XICS and XIVE
In reply to David GibsonFrom: Greg Kurz <[email protected]>
Have PSERIES to select XICS and XIVE, and directly check PSERIES in hw/intc/meson.build to enable build of the XICS and XIVE sPAPR backends, like POWERNV already does. This allows to get rid of the intermediate XICS_SPAPR and XIVE_SPAPR.
Message-Id: <[email protected]>
--- hw/intc/Kconfig | 4 +--- hw/intc/meson.build | 3 +-- hw/ppc/Kconfig | 14 ++------------ 3 files changed, 4 insertions(+), 17 deletions(-)
hw/intc/Kconfig +1 -3
@@ -32,11 +32,9 @@ config ARM_GIC_KVM config XICS bool - depends on POWERNV || PSERIES -config XICS_SPAPR +config XIVE bool - select XICS config ALLWINNER_A10_PIC bool
hw/intc/meson.build +1 -2
@@ -53,8 +53,7 @@ specific_ss.add(when: 'CONFIG_SIFIVE_PLIC', if_true: files('sifive_plic.c')) specific_ss.add(when: 'CONFIG_XICS', if_true: files('xics.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XICS'], if_true: files('xics_kvm.c')) -specific_ss.add(when: 'CONFIG_XICS_SPAPR', if_true: files('xics_spapr.c')) +specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('xics_spapr.c', 'spapr_xive.c')) specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) -specific_ss.add(when: 'CONFIG_XIVE_SPAPR', if_true: files('spapr_xive.c'))
hw/ppc/Kconfig +2 -12
@@ -7,8 +7,8 @@ config PSERIES select PCI select SPAPR_VSCSI select VFIO if LINUX # needed by spapr_pci_vfio.c - select XICS_SPAPR - select XIVE_SPAPR + select XICS + select XIVE select MSI_NONBROKEN select FDT_PPC select CHRP_NVRAM
@@ -129,16 +129,6 @@ config VIRTEX select XILINX_ETHLITE select FDT_PPC -config XIVE - bool - depends on POWERNV || PSERIES - -config XIVE_SPAPR - bool - default y - depends on PSERIES - select XIVE - # Only used by 64-bit targets config FW_CFG_PPC bool
Signature · 1 line
2.29.2
[PULL 21/22] ppc440_pcix: Fix register write trace event
In reply to David GibsonFrom: BALATON Zoltan via <[email protected]>
The trace event for pci_host_config_write() was also using the trace event for read. Add corresponding trace and correct this.
Message-Id: <a6c7dcf7153cc537123ed8ceac060f2f64a883cb.1609636173.git.balaton@eik.bme.hu>
--- hw/ppc/ppc440_pcix.c | 2 +- hw/ppc/trace-events | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
hw/ppc/ppc440_pcix.c +1 -1
@@ -169,7 +169,7 @@ static void ppc440_pcix_reg_write4(void *opaque, hwaddr addr, {struct PPC440PCIXState *s = opaque; -trace_ppc440_pcix_reg_read (addr, val); +trace_ppc440_pcix_reg_write (addr, val, size);switch (addr) { case PCI_VENDOR_ID ... PCI_MAX_LAT:stl_le_p (s->dev->config + addr, val);
hw/ppc/trace-events +1 -0
@@ -96,3 +96,4 @@ ppc440_pcix_set_irq(int irq_num) "PCI irq %d" ppc440_pcix_update_pim(int idx, uint64_t size, uint64_t la) "Added window %d of size=0x%" PRIx64 " to CPU=0x%" PRIx64 ppc440_pcix_update_pom(int idx, uint32_t size, uint64_t la, uint64_t pcia) "Added window %d of size=0x%x from CPU=0x%" PRIx64 " to PCI=0x%" PRIx64 ppc440_pcix_reg_read(uint64_t addr, uint32_t val) "addr 0x%" PRIx64 " = 0x%" PRIx32 +ppc440_pcix_reg_write(uint64_t addr, uint32_t val, uint32_t size) "addr 0x%" PRIx64 " = 0x%" PRIx32 " size 0x%" PRIx32
Signature · 1 line
2.29.2
[PULL 20/22] ppc440_pcix: Improve comment for IRQ mapping
In reply to David GibsonFrom: BALATON Zoltan via <[email protected]>
The code mapping all PCI interrupts to a single CPU IRQ works but is not trivial so document it in a comment.
Message-Id: <c25c0310510672b58466e795fd701e65e8f1ff97.1609636173.git.balaton@eik.bme.hu>
--- hw/ppc/ppc440_pcix.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
hw/ppc/ppc440_pcix.c +9 -2
@@ -415,8 +415,15 @@ static void ppc440_pcix_reset(DeviceState *dev) s->sts =0 ; } -/* All pins from each slot are tied to a single board IRQ. -* This may need further refactoring for other boards. */ +/* +* All four IRQ[ABCD] pins from all slots are tied to a single board +* IRQ, so our mapping function here maps everything to IRQ 0. +* The code in pci_change_irq_level() tracks the number of times +* the mapped IRQ is asserted and deasserted, so if multiple devices +* assert an IRQ at the same time the behaviour is correct. +* +* This may need further refactoring for boards that use multiple IRQ lines. +*/ static int ppc440_pcix_map_irq (PCIDevice *pci_dev,int irq_num) {trace_ppc440_pcix_map_irq (pci_dev->devfn, irq_num,0 );
Signature · 1 line
2.29.2
[PULL 22/22] ppc440_pcix: Fix up pci config access
In reply to David GibsonFrom: BALATON Zoltan via <[email protected]>
This fixes a long standing issue with MorphOS booting on sam460ex which turns out to be because of suspicious values written to PCI config address that apparently works on real machine but caused wrong access on this device model. This replaces a previous work around for this with a better fix that makes it work.
Message-Id: <6fd215ab2bc5f8d4455cd20ed1a2f059e4415fe5.1609636173.git.balaton@eik.bme.hu>
--- hw/ppc/ppc440_pcix.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
hw/ppc/ppc440_pcix.c +22 -15
@@ -449,28 +449,35 @@ static AddressSpace *ppc440_pcix_set_iommu(PCIBus *b, void *opaque, int devfn)return &s->bm_as; } -/* The default pci_host_data_{read,write} functions in pci/pci_host.c -* deny access to registers without bit 31 set but our clients want -* this to work so we have to override these here */ -static void pci_host_data_write (void *opaque,hwaddr addr, -uint64_t val,unsigned len) +/* +* Some guests on sam460ex write all kinds of garbage here such as +* missing enable bit and low bits set and still expect this to work +* (apparently it does on real hardware because these boot there) so +* we have to override these ops here and fix it up +*/ +static void pci_host_config_write (void *opaque,hwaddr addr, +uint64_t val,unsigned len) {PCIHostState *s = opaque; -pci_data_write (s->bus, s->config_reg | (addr &3 ), val, len); + +if (addr !=0 || len !=4 ) { +return ; + } + s->config_reg = (val &0xfffffffcULL ) | (1UL <<31 ); } -static uint64_t pci_host_data_read (void *opaque, -hwaddr addr,unsigned len) +static uint64_t pci_host_config_read (void *opaque,hwaddr addr, +unsigned len) {PCIHostState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus, s->config_reg | (addr &3 ), len); +uint32_t val = s->config_reg; +return val; } -const MemoryRegionOps ppc440_pcix_host_data_ops = { - .read = pci_host_data_read, - .write = pci_host_data_write, +const MemoryRegionOps ppc440_pcix_host_conf_ops = { + .read = pci_host_config_read, + .write = pci_host_config_write, .endianness =DEVICE_LITTLE_ENDIAN , };
@@ -497,9 +504,9 @@ static void ppc440_pcix_realize(DeviceState *dev, Error **errp)pci_setup_iommu (h->bus, ppc440_pcix_set_iommu, s);memory_region_init (&s->container,OBJECT (s),"pci-container" ,PCI_ALL_SIZE ); -memory_region_init_io (&h->conf_mem,OBJECT (s), &pci_host_conf_le_ops, +memory_region_init_io (&h->conf_mem,OBJECT (s), &ppc440_pcix_host_conf_ops, h,"pci-conf-idx" ,4 ); -memory_region_init_io (&h->data_mem,OBJECT (s), &ppc440_pcix_host_data_ops, +memory_region_init_io (&h->data_mem,OBJECT (s), &pci_host_data_le_ops, h,"pci-conf-data" ,4 );memory_region_init_io (&s->iomem,OBJECT (s), &pci_reg_ops, s,"pci.reg" ,PPC440_REG_SIZE );
Signature · 1 line
2.29.2
Quoted 23 lines · David Gibson
The following changes since commit
52d25464605dc20022ad94aa8bc8e8473e600833:Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210104' into staging (2021-01-05 16:18:20 +0000)
are available in the Git repository at:
https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.0-20210106
for you to fetch changes up to
5cbd51a5a58098444ffa246ece2013849be04299:
ppc440_pcix: Fix up pci config access (2021-01-06 11:09:59 +1100)----------------------------------------------------------------
ppc patch queue 2021-01-06First pull request for 2021, which has a bunch of things accumulated over the holidays. Includes:
* A number of cleanups to sam460ex and ppc440 code from BALATON Zoltan
* Several fixes for builds with --without-default-devices from Greg Kurz
* Fixes for some DRC reset problems from Greg Kurz
* QOM conversion of the PPC 4xx UIC devices from Peter Maydell
* Some other assorted fixes and cleanups
Quoted 4 lines
----------------------------------------------------------------
BALATON Zoltan via (5):
ppc4xx: Move common dependency on serial to common option
sam460ex: RemoveFDT_PPCdependency from KConfig
I've sent a v4 without these pathces
Quoted 3 lines
ppc440_pcix: Improve comment for IRQ mapping
ppc440_pcix: Fix register write trace event
ppc440_pcix: Fix up pci config access
but including another one missing from here so this pull request does not have the latest set of patches. Of course it's difficult for me to tell you when I can't send mail to your domain. We're trying to figure out why.
Regards,
BALATON Zoltan
Quoted 50 lines
Cédric Le Goater (1):
spapr/xive: Makespapr_xive_pic_print_info()staticGreg Kurz (12):
spapr: DRC lookup cannot fail
spapr: Fix DR properties of the root node
spapr: Allow memory unplug to always succeed
spapr: Fix buffer overflow inspapr_numa_associativity_init()
spapr: Callspapr_drc_reset()for all DRCs at CAS
spapr: Fix reset of transient DR connectors
spapr: Introducespapr_drc_reset_all()
spapr: Usespapr_drc_reset_all()at machine reset
spapr: Adddrc_prefix to the DRC realize and unrealize functions
ppc: Fix build with --without-default-devices
ppc: Simplify reverse dependencies of POWERNV and PSERIES on XICS and XIVE
pnv: Fix reverse dependency on PCI express root portsPeter Maydell (4):
hw/ppc/ppc4xx_devs: Make code style fixes to UIC code
ppc: Convert PPC UIC to a QOM device hw/ppc/virtex_ml507: Drop use ofppcuic_init()hw/ppc/ppc440_bamboo: Drop use ofppcuic_init()MAINTAINERS | 2 + hw/intc/Kconfig | 17 +-- hw/intc/meson.build | 13 +- hw/intc/ppc-uic.c | 321 ++++++++++++++++++++++++++++++++++++++++++++ hw/intc/spapr_xive.c | 2 +- hw/pci-host/Kconfig | 5 + hw/pci-host/meson.build | 2 +- hw/ppc/Kconfig | 29 +--- hw/ppc/ppc440_bamboo.c | 38 ++++-- hw/ppc/ppc440_pcix.c | 50 ++++--- hw/ppc/ppc4xx_devs.c | 262 +++++------------------------------- hw/ppc/spapr.c | 44 +++--- hw/ppc/spapr_drc.c | 63 +++++++-- hw/ppc/spapr_events.c | 3 +- hw/ppc/spapr_hcall.c | 33 +---- hw/ppc/trace-events | 1 + hw/ppc/virtex_ml507.c | 21 ++- include/hw/intc/ppc-uic.h | 73 ++++++++++ include/hw/pci-host/spapr.h | 2 - include/hw/ppc/spapr.h | 6 +- include/hw/ppc/spapr_drc.h | 10 +- include/hw/ppc/spapr_xive.h | 2 - 22 files changed, 616 insertions(+), 383 deletions(-)create mode 100644
hw/intc/ppc-uic.c
create mode 100644include/hw/intc/ppc-uic.h
Quoted 24 lines · David Gibson
The following changes since commit
52d25464605dc20022ad94aa8bc8e8473e600833:Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210104' into staging (2021-01-05 16:18:20 +0000)
are available in the Git repository at:
https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.0-20210106
for you to fetch changes up to
5cbd51a5a58098444ffa246ece2013849be04299:
ppc440_pcix: Fix up pci config access (2021-01-06 11:09:59 +1100)----------------------------------------------------------------
ppc patch queue 2021-01-06First pull request for 2021, which has a bunch of things accumulated over the holidays. Includes:
* A number of cleanups to sam460ex and ppc440 code from BALATON Zoltan
* Several fixes for builds with --without-default-devices from Greg Kurz
* Fixes for some DRC reset problems from Greg Kurz
* QOM conversion of the PPC 4xx UIC devices from Peter Maydell
* Some other assorted fixes and cleanups
Quoted 7 lines
----------------------------------------------------------------
BALATON Zoltan via (5):
ppc4xx: Move common dependency on serial to common option
sam460ex: RemoveFDT_PPCdependency from KConfig
ppc440_pcix: Improve comment for IRQ mapping
ppc440_pcix: Fix register write trace event
ppc440_pcix: Fix up pci config access
Applied, thanks. I'm afraid I missed reading Balaton's email before pushing this to master, so the whole set is in there; sorry about that. Would you mind sending a patchset that makes the necessary changes on top of master (reverts or fixes as appropriate)?
Please update the changelog at https://wiki.qemu.org/ChangeLog/6.0
for any user-visible changes.
-- PMM
Quoted 34 lines · Peter Maydell
Quoted 24 lines · David Gibson
The following changes since commit
52d25464605dc20022ad94aa8bc8e8473e600833:Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210104' into staging (2021-01-05 16:18:20 +0000)
are available in the Git repository at:
https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.0-20210106
for you to fetch changes up to
5cbd51a5a58098444ffa246ece2013849be04299:
ppc440_pcix: Fix up pci config access (2021-01-06 11:09:59 +1100)----------------------------------------------------------------
ppc patch queue 2021-01-06First pull request for 2021, which has a bunch of things accumulated over the holidays. Includes:
* A number of cleanups to sam460ex and ppc440 code from BALATON Zoltan
* Several fixes for builds with --without-default-devices from Greg Kurz
* Fixes for some DRC reset problems from Greg Kurz
* QOM conversion of the PPC 4xx UIC devices from Peter Maydell
* Some other assorted fixes and cleanupsQuoted 7 lines
----------------------------------------------------------------
BALATON Zoltan via (5):
ppc4xx: Move common dependency on serial to common option
sam460ex: RemoveFDT_PPCdependency from KConfig
ppc440_pcix: Improve comment for IRQ mapping
ppc440_pcix: Fix register write trace event
ppc440_pcix: Fix up pci config access
Quoted 5 lines
Applied, thanks. I'm afraid I missed reading Balaton's email before pushing this to master, so the whole set is in there; sorry about that. Would you mind sending a patchset that makes the necessary changes on top of master (reverts or fixes as appropriate)?
Sent a fixup series with the two reverts and the missing patch.
Regards,
BALATON Zoltan
Quoted 6 lines
Please update the changelog at https://wiki.qemu.org/ChangeLog/6.0
for any user-visible changes.-- PMM