qemu-patch-raspberry4/hw
Greg Kurz 9cbe305b60 spapr_pci: fix MSI/MSIX selection
In various place we don't correctly check if the device supports MSI or
MSI-X. This can cause devices to be advertised with MSI support, even
if they only support MSI-X (like virtio-pci-* devices for example):

                ethernet@0 {
                        ibm,req#msi = <0x1>; <--- wrong!
			.
			ibm,loc-code = "qemu_virtio-net-pci:0000:00:00.0";
			.
			ibm,req#msi-x = <0x3>;
                };

Worse, this can also cause the "ibm,change-msi" RTAS call to corrupt the
PCI status and cause migration to fail:

  qemu-system-ppc64: get_pci_config_device: Bad config data: i=0x6
    read: 0 device: 10 cmask: 10 wmask: 0 w1cmask:0
                              ^^
           PCI_STATUS_CAP_LIST bit which is assumed to be constant

This patch changes spapr_populate_pci_child_dt() to properly check for
MSI support using msi_present(): this ensures that PCIDevice::msi_cap
was set by msi_init() and that msi_nr_vectors_allocated() will look at
the right place in the config space.

Checking PCIDevice::msix_entries_nr is enough for MSI-X but let's add
a call to msix_present() there as well for consistency.

It also changes rtas_ibm_change_msi() to select the appropriate MSI
type in Function 1 instead of always selecting plain MSI. This new
behaviour is compliant with LoPAPR 1.1, as described in "Table 71.
ibm,change-msi Argument Call Buffer":

  Function 1: If Number Outputs is equal to 3, request to set to a new
           number of MSIs (including set to 0).
           If the “ibm,change-msix-capable” property exists and Number
           Outputs is equal to 4, request is to set to a new number of
           MSI or MSI-X (platform choice) interrupts (including set to
           0).

Since MSI is the the platform default (LoPAPR 6.2.3 MSI Option), let's
check for MSI support first.

And finally, it checks the input parameters are valid, as described in
LoPAPR 1.1 "R1–7.3.10.5.1–3":

  For the MSI option: The platform must return a Status of -3 (Parameter
  error) from ibm,change-msi, with no change in interrupt assignments if
  the PCI configuration address does not support MSI and Function 3 was
  requested (that is, the “ibm,req#msi” property must exist for the PCI
  configuration address in order to use Function 3), or does not support
  MSI-X and Function 4 is requested (that is, the “ibm,req#msi-x” property
  must exist for the PCI configuration address in order to use Function 4),
  or if neither MSIs nor MSI-Xs are supported and Function 1 is requested.

This ensures that the ret_intr_type variable contains a valid MSI type
for this device, and that spapr_msi_setmsg() won't corrupt the PCI status.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-01-29 14:24:41 +11:00
..
9pfs 9pfs: deprecate handle backend 2018-01-08 11:18:23 +01:00
acpi nvdimm: add 'unarmed' option 2018-01-19 11:18:51 -02:00
adc maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
alpha Merge remote-tracking branch 'origin/master' into HEAD 2018-01-11 22:03:50 +02:00
arm xlnx-zynqmp: Connect the IPI device to the ZynqMP SoC 2018-01-26 11:09:09 +01:00
audio Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
block Block layer patches 2018-01-24 22:55:57 +00:00
bt hw/bt: Replace fprintf(stderr, "*\n" with error_report() 2018-01-22 09:51:00 +01:00
char maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
core linux-user: remove nmi.c and fw-path-provider.c 2018-01-23 14:20:52 +01:00
cpu hw: use "qemu/osdep.h" as first #include in source files 2017-12-18 17:07:02 +03:00
cris cris: use generic cpu_model parsing 2017-10-27 16:03:54 +02:00
display aarch64-softmmu.mak: Use an ARM specific config 2018-01-26 11:09:09 +01:00
dma aarch64-softmmu.mak: Use an ARM specific config 2018-01-26 11:09:09 +01:00
gpio Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
i2c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
i386 possible_cpus: add CPUArchId::type field 2018-01-19 11:18:51 -02:00
ide Pull request for various patches that have been reviewed and 2018-01-23 10:15:09 +00:00
input input: add missing newline from trace-events 2018-01-27 17:27:18 +11:00
intc xlnx-zynqmp-ipi: Initial version of the Xilinx IPI device 2018-01-26 11:09:09 +01:00
ipack pci: Add INTERFACE_CONVENTIONAL_PCI_DEVICE to Conventional PCI devices 2017-10-15 05:54:43 +03:00
ipmi hw/ipmi: Replace fprintf(stderr, "*\n" with error_report() 2018-01-22 09:51:00 +01:00
isa hw/isa: Replace fprintf(stderr, "*\n" with error_report() 2018-01-22 09:51:00 +01:00
lm32 lm32: lm32_boards: use generic cpu_model parsing 2017-10-27 16:03:54 +02:00
m68k m68k: mcf5208: use generic cpu_model parsing 2017-10-27 16:03:54 +02:00
mem nvdimm: add 'unarmed' option 2018-01-19 11:18:51 -02:00
microblaze xlnx-zynqmp-pmu: Connect the IPI device to the PMU 2018-01-26 11:09:09 +01:00
mips Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
misc Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
moxie hw/moxie/moxiesim: Add support for loading a BIOS on moxiesim 2017-12-21 09:30:31 +01:00
net i.MX: Fix FEC/ENET receive funtions 2018-01-25 11:45:28 +00:00
nios2 nios2: remove duplicated includes (in code commented out) 2017-12-18 17:07:02 +03:00
nvram fw_cfg: fix memory corruption when all fw_cfg slots are used 2018-01-19 11:18:51 -02:00
openrisc openrisc: use generic cpu_model parsing 2017-10-27 16:03:54 +02:00
pci pci/shpc: Move function to generic header file 2018-01-18 21:52:38 +02:00
pci-bridge simba: rename PBMPCIBridge and QOM types to reflect simba naming 2018-01-24 19:19:50 +00:00
pci-host uninorth: convert to trace-events 2018-01-27 17:26:46 +11:00
pcmcia hw: Clean up includes 2016-01-29 15:07:25 +00:00
ppc spapr_pci: fix MSI/MSIX selection 2018-01-29 14:24:41 +11:00
s390x s390x: fix storage attributes migration for non-small guests 2018-01-22 11:04:52 +01:00
scsi usb-storage: Fix share-rw option parsing 2018-01-26 07:58:34 +01:00
sd sdhci: fix a NULL pointer dereference due to uninitialized AddresSpace object 2018-01-25 11:45:30 +00:00
sh4 pci: Rename root bus initialization functions for clarity 2017-12-05 19:13:45 +02:00
smbios Merge remote-tracking branch 'origin/master' into HEAD 2018-01-11 22:03:50 +02:00
sparc sun4m: remove include/hw/sparc/sun4m.h and all references to it 2018-01-09 21:48:20 +00:00
sparc64 sun4u: implement power device 2018-01-25 13:39:39 +00:00
ssi xilinx_spips: Correct usage of an uninitialized local variable 2018-01-25 11:45:30 +00:00
timer Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
tpm maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
tricore tricore: use generic cpu_model parsing 2017-10-27 16:04:27 +02:00
unicore32 hw/unicore32: restrict hw addr defines to source file 2017-12-18 17:07:02 +03:00
usb usb-ccid: convert CCIDCardClass::exitfn() -> unrealize() 2018-01-26 07:59:33 +01:00
vfio Merge remote-tracking branch 'origin/master' into HEAD 2018-01-11 22:03:50 +02:00
virtio Revert "virtio: postpone the execution of event_notifier_cleanup function" 2018-01-24 19:20:19 +02:00
watchdog misc: drop old i386 dependency 2017-12-18 17:07:03 +03:00
xen xen: Add only xen-sysdev to dynamic sysbus device list 2018-01-19 11:18:51 -02:00
xenpv Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
xtensa target/xtensa: allow different default CPU for MMU/noMMU 2018-01-22 11:54:23 -08:00
Makefile.objs 9pfs: fix dependencies 2017-08-30 18:23:25 +02:00