Commit 972fa54966 for qemu.org
commit 972fa54966eaece897d17ea5d33eef33fc232884
Author: Jared Rossi <jrossi@linux.ibm.com>
Date: Mon Aug 31 15:49:12 2026 -0400
pc-bios/s390-ccw: Check if a PCI function is already enabled before trying to enable it
Enabling a PCI function that is already configured will result in an error.
Simply check if the device has already been enabled, and if so, return
without doing anything further; otherwise, enable it as usual.
Also, because enable_pci_function() prints its own message, let's remove
the duplicate message emitted during the virtio PCI setup steps.
Reviewed-by: Zhuoying Cai <zycai@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20260831194919.3830270-2-jrossi@linux.ibm.com
Signed-off-by: Eric Farman <farman@linux.ibm.com>
diff --git a/pc-bios/s390-ccw/clp.c b/pc-bios/s390-ccw/clp.c
index ca9565d8de..7917f13345 100644
--- a/pc-bios/s390-ccw/clp.c
+++ b/pc-bios/s390-ccw/clp.c
@@ -82,6 +82,10 @@ int enable_pci_function(uint32_t *fhandle)
{
ClpReqRspSetPci rrb;
+ if (*fhandle & CLP_FHLIST_MASK_CONFIG) {
+ return 0; /* already enabled */
+ }
+
rrb.request.hdr.len = sizeof(ClpReqSetPci);
rrb.request.hdr.cmd = 0x05;
rrb.request.fh = *fhandle;
diff --git a/pc-bios/s390-ccw/virtio-pci.c b/pc-bios/s390-ccw/virtio-pci.c
index f501252c81..231ab6e04d 100644
--- a/pc-bios/s390-ccw/virtio-pci.c
+++ b/pc-bios/s390-ccw/virtio-pci.c
@@ -452,7 +452,6 @@ int virtio_pci_setup_device(void)
VDev *vdev = virtio_get_device();
if (enable_pci_function(&vdev->pci_fh)) {
- puts("Failed to enable PCI function");
return -ENODEV;
}