qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Robin Voetter <robin@streamhpc.com>
Cc: qemu-devel@nongnu.org
Subject: Re: PCIe atomics in pcie-root-port
Date: Thu, 6 Apr 2023 12:40:09 -0600	[thread overview]
Message-ID: <20230406124009.4a5e7307.alex.williamson@redhat.com> (raw)
In-Reply-To: <b30370f5-0b52-d2de-6e47-8f288a219a43@streamhpc.com>

On Thu, 6 Apr 2023 11:29:34 +0200
Robin Voetter <robin@streamhpc.com> wrote:

> Hello,
> 
> I am trying to use qemu to run ROCm in a virtual machine via GPU 
> passthrough with vfio-pci. While this mostly works out of the box, ROCm 
> requires PCIe atomics to function properly, and it seems like that this 
> is a feature that is missing in qemu. The setup is using a simple PCie 
> topology, where the GPU is connected to a pcie-root-port as follows:
>     -device pcie-root-port,id=pcie.1
>     -device vfio-pci,host=<host_pci_address>,bus=pcie.1
> 
> When the amdgpu kernel module is loaded in the guest, enabling PCIe 
> atomics fails because it requires that PCIe root ports support 32- and 
> 64-bit atomic completion, see commits 430a2368 and 8e6d0b69 in Linux.
> 
> I patched the required flags into the DevCap2 register in qemu and 
> everything seems to work fine. I'm interested in getting this change 
> into qemu proper, but I have some questions about how to do that:
> 
> 1. In order for PCIe atomics to be supported, every bridge in the path 
> between the root complex and the device in question needs to support the 
> routing capability, as well as the device being required to support the 
> atomic requester/completer capabilities of course. When a certain device 
> from the host is connected to a root port in qemu, that path will be 
> abstracted away into the virtual PCIe topology. Should this property 
> from the host be reflected into the virtual path in qemu, or is it 
> better to gate this behind a property of the pcie-root-port? For 
> example, the user could then simply pass -device 
> pcie-root-port,id=pcie.1,atomics=on to make the pcie-root-port report 
> that it supports these operations. If this should be reflected from the 
> host automatically, how should this be tested for? I checked around the 
> source for how for example the link speed is set, but it seems like that 
> is not reflected from the host system automatically either.

I think the typical approach for QEMU would be expose options in the
downstream ports that would then need to be enabled by the user or
management tool, but that's where the complication begins.  At some
point we would want management tools to "do the right thing"
themselves.  Is support for PCIe atomics pervasive enough to default to
enabling support?  How do we handle hotplugged endpoints where the
interconnects do not expose atomics support, or perhaps when they
expose support that doesn't exist?  At some point in the future when we
have migration of devices with atomics, do we need to test all endpoint
to endpoint paths for equivalent atomic support on the migration target?
Are there capabilities on the endpoint that we can virtualize to
disable use of atomics if the host and guest topologies are out of sync?

> 2. Is anything else required to support PCIe atomics, or did I just get 
> lucky that my programs work?

It's been on my todo list for some time to look into supporting atomic
ops, but it suffers from the -ENOTIME syndome.  Thanks,

Alex



  reply	other threads:[~2023-04-06 18:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06  9:29 PCIe atomics in pcie-root-port Robin Voetter
2023-04-06 18:40 ` Alex Williamson [this message]
2023-04-12 16:58   ` Robin Voetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230406124009.4a5e7307.alex.williamson@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=robin@streamhpc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).