hw/vfio/pci.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
As included in the comment: The PCIe atomics routing does not hurt,
even if some subfunctions of a PCIe device 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. The amdgpu
driver however needs atomics for fully supporting ROCm.
So stop excluding multifunction devices.
Tested with Radeon 7900 XTX.
Signed-off-by: Kurt Garloff <kurt@garloff.de>
---
The amdgpu driver requires them to fully work with ROCm.
The good news is that qemu already has code that detects the capability
of the PCI device and enables the routing of PCI atomics in the
pcie-bridge. This unfortunately did not work on my system, because I
have a RX7900XTX which is a multi-function PCI device with the GPU
and the audio function. I pass through both to the VM.
I could not find any reason to disable PCIe atomics routing even
if some subfunction does not require it -- it does not hurt.
So I took out the check.
With it, the amdgpu driver works nicely in the VM.
Sidenote: I had used patches to manually override the autodetection,
but prefer the automatic detection which is much simpler in both
code and usability.
---
hw/vfio/pci.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 94c174a773..077ff3a6a8 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2112,17 +2112,19 @@ static void vfio_pci_enable_rp_atomics(VFIOPCIDevice *vdev)
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;
}
---
base-commit: 769a37d8bd0c81c39128fc292352f01bad0769f4
change-id: 20260312-enable-multifunc-atomicroute-ca11e3a399d2
Best regards,
--
Kurt Garloff <kurt@garloff.de> [Koeln, Germany]
Hello Kurt,
On 3/12/26 16:48, Kurt Garloff wrote:
> As included in the comment: The PCIe atomics routing does not hurt,
> even if some subfunctions of a PCIe device 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. The amdgpu
> driver however needs atomics for fully supporting ROCm.
> So stop excluding multifunction devices.
>
> Tested with Radeon 7900 XTX.
>
> Signed-off-by: Kurt Garloff <kurt@garloff.de>
> ---
> The amdgpu driver requires them to fully work with ROCm.
>
> The good news is that qemu already has code that detects the capability
> of the PCI device and enables the routing of PCI atomics in the
> pcie-bridge. This unfortunately did not work on my system, because I
> have a RX7900XTX which is a multi-function PCI device with the GPU
> and the audio function. I pass through both to the VM.
>
> I could not find any reason to disable PCIe atomics routing even
> if some subfunction does not require it -- it does not hurt.
> So I took out the check.
Alex explained why it is not that simple here :
https://lore.kernel.org/qemu-devel/8b3e30e6-3c3e-49ab-b9db-8296aaf819d1@app.fastmail.com/
Thanks,
C.
>
> With it, the amdgpu driver works nicely in the VM.
>
> Sidenote: I had used patches to manually override the autodetection,
> but prefer the automatic detection which is much simpler in both
> code and usability.
> ---
> hw/vfio/pci.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 94c174a773..077ff3a6a8 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2112,17 +2112,19 @@ static void vfio_pci_enable_rp_atomics(VFIOPCIDevice *vdev)
> 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;
> }
>
>
> ---
> base-commit: 769a37d8bd0c81c39128fc292352f01bad0769f4
> change-id: 20260312-enable-multifunc-atomicroute-ca11e3a399d2
>
> Best regards,
On Thu, 12 Mar 2026 15:48:05 +0000
Kurt Garloff <kurt@garloff.de> wrote:
> As included in the comment: The PCIe atomics routing does not hurt,
> even if some subfunctions of a PCIe device 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. The amdgpu
> driver however needs atomics for fully supporting ROCm.
> So stop excluding multifunction devices.
NAK. This was discussed recently:
https://lore.kernel.org/all/8b3e30e6-3c3e-49ab-b9db-8296aaf819d1@app.fastmail.com/
Just map the audio function to a separate slot in the VM, the GPU and
audio functions don't need to appear as a multi-function device in the
guest. Thanks,
Alex
> Tested with Radeon 7900 XTX.
>
> Signed-off-by: Kurt Garloff <kurt@garloff.de>
> ---
> The amdgpu driver requires them to fully work with ROCm.
>
> The good news is that qemu already has code that detects the capability
> of the PCI device and enables the routing of PCI atomics in the
> pcie-bridge. This unfortunately did not work on my system, because I
> have a RX7900XTX which is a multi-function PCI device with the GPU
> and the audio function. I pass through both to the VM.
>
> I could not find any reason to disable PCIe atomics routing even
> if some subfunction does not require it -- it does not hurt.
> So I took out the check.
>
> With it, the amdgpu driver works nicely in the VM.
>
> Sidenote: I had used patches to manually override the autodetection,
> but prefer the automatic detection which is much simpler in both
> code and usability.
> ---
> hw/vfio/pci.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 94c174a773..077ff3a6a8 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2112,17 +2112,19 @@ static void vfio_pci_enable_rp_atomics(VFIOPCIDevice *vdev)
> 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;
> }
>
>
> ---
> base-commit: 769a37d8bd0c81c39128fc292352f01bad0769f4
> change-id: 20260312-enable-multifunc-atomicroute-ca11e3a399d2
>
> Best regards,
© 2016 - 2026 Red Hat, Inc.