qemu-e2k/hw
Laurent Vivier df72184ec1 pcie: don't set link state active if the slot is empty
When the pcie slot is initialized, by default PCI_EXP_LNKSTA_DLLLA
(Data Link Layer Link Active) is set in PCI_EXP_LNKSTA
(Link Status) without checking if the slot is empty or not.

This is confusing for the kernel because as it sees the link is up
it tries to read the vendor ID and fails:

(From https://bugzilla.kernel.org/show_bug.cgi?id=211691)

[    1.661105] pcieport 0000:00:02.2: pciehp: Slot Capabilities      : 0x0002007b
[    1.661115] pcieport 0000:00:02.2: pciehp: Slot Status            : 0x0010
[    1.661123] pcieport 0000:00:02.2: pciehp: Slot Control           : 0x07c0
[    1.661138] pcieport 0000:00:02.2: pciehp: Slot #0 AttnBtn+ PwrCtrl+ MRL- AttnInd+ PwrInd+ HotPlug+ Surprise+ Interlock+ NoCompl- IbPresDis- LLActRep+
[    1.662581] pcieport 0000:00:02.2: pciehp: pciehp_get_power_status: SLOTCTRL 6c value read 7c0
[    1.662597] pcieport 0000:00:02.2: pciehp: pciehp_check_link_active: lnk_status = 2204
[    1.662703] pcieport 0000:00:02.2: pciehp: pending interrupts 0x0010 from Slot Status
[    1.662706] pcieport 0000:00:02.2: pciehp: pcie_enable_notification: SLOTCTRL 6c write cmd 1031
[    1.662730] pcieport 0000:00:02.2: pciehp: pciehp_check_link_active: lnk_status = 2204
[    1.662748] pcieport 0000:00:02.2: pciehp: pciehp_check_link_active: lnk_status = 2204
[    1.662750] pcieport 0000:00:02.2: pciehp: Slot(0-2): Link Up
[    2.896132] pcieport 0000:00:02.2: pciehp: pciehp_check_link_status: lnk_status = 2204
[    2.896135] pcieport 0000:00:02.2: pciehp: Slot(0-2): No device found
[    2.896900] pcieport 0000:00:02.2: pciehp: pending interrupts 0x0010 from Slot Status
[    2.896903] pcieport 0000:00:02.2: pciehp: pciehp_power_off_slot: SLOTCTRL 6c write cmd 400
[    3.656901] pcieport 0000:00:02.2: pciehp: pending interrupts 0x0009 from Slot Status

This is really a problem with virtio-net failover that hotplugs a VFIO
card during the boot process. The kernel can shutdown the slot while
QEMU is hotplugging it, and this likely ends by an automatic unplug of
the card. At the end of the boot sequence the card has disappeared.

To fix that, don't set the "Link Active" state in the init function, but
rely on the plug function to do it, as the mechanism has already been
introduced by 2f2b18f60b.

Fixes: 2f2b18f60b ("pcie: set link state inactive/active after hot unplug/plug")
Cc: zhengxiang9@huawei.com
Fixes: 3d67447fe7 ("pcie: Fill PCIESlot link fields to support higher speeds and widths")
Cc: alex.williamson@redhat.com
Fixes: b2101eae63 ("pcie: Set the "link active" in the link status register")
Cc: benh@kernel.crashing.org
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20210212135250.2738750-5-lvivier@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-02-23 10:06:55 -05:00
..
9pfs
acpi
adc
alpha
arm hw/arm: Add I2C sensors and EEPROM for GSJ machine 2021-02-16 13:50:38 +00:00
audio
avr
block hw/block/fdc: Remove the check_media_rate property 2021-02-20 12:36:19 +01:00
char
core
cpu
cris
display
dma
gpio
hppa
hyperv
i2c hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode 2021-02-16 14:12:54 +00:00
i386 vmmouse: put it into the 'input' category 2021-02-20 12:36:19 +01:00
ide hw/ide/ahci: map cmd_fis as DMA_DIRECTION_TO_DEVICE 2021-02-15 15:10:14 +01:00
input
intc hw/intc/loongson_liointc: Fix per core ISR handling 2021-02-21 18:41:46 +01:00
ipack
ipmi
isa vt82c686: Fix superio_cfg_{read,write}() functions 2021-02-21 19:42:34 +01:00
lm32
m68k m68k: import bootinfo headers from linux 2021-02-11 21:56:42 +01:00
mem nvdimm: put it into the 'storage' category 2021-02-20 12:36:19 +01:00
microblaze
mips vt82c686: Move creation of ISA devices to the ISA bridge 2021-02-21 19:42:34 +01:00
misc Fix SPDX-License-Identifier typos 2021-02-20 12:36:19 +01:00
moxie
net failover: really display a warning when the primary device is not found 2021-02-23 10:06:55 -05:00
nios2
nubus
nvram nvram: add nrf51_soc flash read method 2021-02-08 15:15:32 +01:00
openrisc
pci pcie: don't set link state active if the slot is empty 2021-02-23 10:06:55 -05:00
pci-bridge
pci-host Pull request 2021-02-10 15:42:20 +00:00
pcmcia
ppc hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes 2021-02-10 14:50:11 +11:00
rdma
remote multi-process: perform device reset in the remote process 2021-02-10 09:23:28 +00:00
riscv
rtc
rx
s390x
scsi hw/scsi/megasas: Remove pointless parenthesis 2021-02-20 12:36:19 +01:00
sd Pull request trivial patches 20210220 2021-02-21 12:12:18 +00:00
semihosting
sh4
smbios
sparc
sparc64
ssi
timer arm: Update infocenter.arm.com URLs 2021-02-11 11:50:14 +00:00
tpm tpm: put some tpm devices into the correct category 2021-02-20 12:36:19 +01:00
tricore
unicore32
usb u2f-passthru: put it into the 'misc' category 2021-02-20 12:36:19 +01:00
vfio vfio: add quirk device write method 2021-02-08 15:15:32 +01:00
virtio virtio-pmem: put it into the 'storage' category 2021-02-20 12:36:19 +01:00
watchdog
xen
xenpv
xtensa
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