File qemu-pci-atomics-enable-mf.diff of Package qemu

From: Kurt Garloff <kurt@garloff.de>
Subject: Don't disable PCIe atomics routing for mlutifunction devices

As inclused in the comment: The PCIe atomics routing does not hurt,
even if some subfunctions don't require it.
Graphics cards often have an audio device next to the GPU, so this
actually causes them not to have PCIe atomics support. ROCm does
however require PCIe atomics support for amdgpus.

Tested with Radeon 7900 XTX.

Signed-off-by: Kurt Garloff <kurt@garloff.de>

diff -uNrp qemu-10.2.0.orig/hw/vfio/pci.c qemu-10.2.0.atomics/hw/vfio/pci.c
--- qemu-10.2.0.orig/hw/vfio/pci.c	2026-02-21 18:37:01.322617066 +0000
+++ qemu-10.2.0.atomics/hw/vfio/pci.c	2026-03-04 22:51:14.194912289 +0000
@@ -2111,17 +2111,19 @@ static void vfio_pci_enable_rp_atomics(V
     uint8_t *pos;
 
     /*
-     * PCIe Atomic Ops completer support is only added automatically for single
-     * function devices downstream of a root port supporting DEVCAP2.  Support
-     * is added during realize and, if added, removed during device exit.  The
-     * single function requirement avoids conflicting requirements should a
-     * slot be composed of multiple devices with differing capabilities.
+     * PCIe Atomic Ops completer support is added automatically for devices
+     * downstream of a root port supporting DEVCAP2.  Support is added during
+     * realize and, if added, removed during device exit.
+     * Note that we previously only did this for multifunction devices to
+     * avoid conflicts; this restriction was unnecessary as routing atomics
+     * will not harm and won't be generated by devices not requiring it anyhow.
+     * The restictions hurt many discrete graphics cards which have an audio
+     * device next to the GPU.
      */
     if (pci_bus_is_root(bus) || !parent || !parent->exp.exp_cap ||
         pcie_cap_get_type(parent) != PCI_EXP_TYPE_ROOT_PORT ||
         pcie_cap_get_version(parent) != PCI_EXP_FLAGS_VER2 ||
-        pdev->devfn ||
-        pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
+        pdev->devfn) {
         return;
     }
 
openSUSE Build Service is sponsored by