qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Tomita Moeko <tomitamoeko@gmail.com>
Cc: "Cédric Le Goater" <clg@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] vfio/igd: Check host PCI address when probing
Date: Mon, 14 Apr 2025 15:51:26 -0600	[thread overview]
Message-ID: <20250414155126.6ad0bd9c.alex.williamson@redhat.com> (raw)
In-Reply-To: <50fe6263-2459-4e49-a6f3-a1166a0846f1@gmail.com>

On Sun, 13 Apr 2025 19:30:10 +0800
Tomita Moeko <tomitamoeko@gmail.com> wrote:

> On 4/10/25 01:18, Alex Williamson wrote:
> > On Wed, 26 Mar 2025 01:22:39 +0800
> > Tomita Moeko <tomitamoeko@gmail.com> wrote:
> >   
> >> So far, all Intel VGA adapters, including discrete GPUs like A770 and
> >> B580, were treated as IGD devices. While this had no functional impact,
> >> a error about "unsupported IGD device" will be printed when passthrough
> >> Intel discrete GPUs.
> >>
> >> Since IGD devices must be at "0000:00:02.0", let's check the host PCI
> >> address when probing.
> >>
> >> Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
> >> ---
> >>  hw/vfio/igd.c | 23 +++++++++--------------
> >>  1 file changed, 9 insertions(+), 14 deletions(-)
> >>
> >> diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
> >> index 265fffc2aa..ff250017b0 100644
> >> --- a/hw/vfio/igd.c
> >> +++ b/hw/vfio/igd.c
> >> @@ -53,6 +53,13 @@
> >>   * headless setup is desired, the OpRegion gets in the way of that.
> >>   */
> >>  
> >> +static bool vfio_is_igd(VFIOPCIDevice *vdev)
> >> +{
> >> +    return vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, PCI_ANY_ID) &&
> >> +           vfio_is_vga(vdev) &&
> >> +           vfio_pci_host_match(&vdev->host, "0000:00:02.0");
> >> +}  
> > 
> > vfio-pci devices can also be specified via sysfsdev= rather than host=,
> > so at a minimum I think we'd need to test against vdev->vbasedev.name,
> > as other callers of vfio_pci_host_match do.  For example building a
> > local PCIHostDeviceAddress and comparing it to name.  This is also not
> > foolproof though if we start taking advantage of devices passed by fd.  
> 
> Sorry for my late reply. Yes `vfio_pci_host_match` does not work for
> sysfsdev of fd, I will drop this change.
> 
> > Could we instead rely PCIe capabilities?  A discrete GPU should
> > identify as either an endpoint or legacy endpoint and IGD should
> > identify as a root complex integrated endpoint, or maybe older versions
> > would lack the PCIe capability altogether.  
> 
> Older generations seems do not have PCIe capabilities in their config
> space, like the sandy bridge spec [1] does not mention it. I don't have
> a sandy bridge box for now to verify it :(

I have a Sandy Bridge i7-2760QM and can confirm there is no PCIe
capability:

# lspci -vvvs 02.0
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) (prog-if 00 [VGA controller])
	Subsystem: Lenovo Device 21d1
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Interrupt: pin A routed to IRQ 35
	Region 0: Memory at f0000000 (64-bit, non-prefetchable) [size=4M]
	Region 2: Memory at e0000000 (64-bit, prefetchable) [size=256M]
	Region 4: I/O ports at 5000 [size=64]
	Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
	Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
		Address: fee00018  Data: 0000
	Capabilities: [d0] Power Management version 2
		Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [a4] PCI Advanced Features
		AFCap: TP+ FLR+
		AFCtrl: FLR-
		AFStatus: TP-
	Kernel driver in use: i915
	Kernel modules: i915

# lspci -xxxs 02.0
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
00: 86 80 26 01 07 04 90 00 09 00 00 03 00 00 00 00
10: 04 00 00 f0 00 00 00 00 0c 00 00 e0 00 00 00 00
20: 01 50 00 00 00 00 00 00 00 00 00 00 aa 17 d1 21
30: 00 00 00 00 90 00 00 00 00 00 00 00 0b 01 00 00
40: 09 00 0c 01 9d 21 00 e2 90 00 00 14 00 00 00 00
50: 11 02 00 00 11 00 00 00 00 00 00 00 01 00 a0 db
60: 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
90: 05 d0 01 00 18 00 e0 fe 00 00 00 00 00 00 00 00
a0: 00 00 00 00 13 00 06 03 00 00 00 00 00 00 00 00
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
d0: 01 a4 22 00 00 00 00 00 00 00 00 00 00 00 00 00
e0: 00 00 00 00 01 00 00 00 00 80 00 00 00 00 00 00
f0: 00 00 00 00 00 00 00 00 00 00 06 00 18 60 ef da

> > Also I think the comments that were dropped below are still valid and
> > useful to transfer to this new helper.  I think those are actually
> > referring to the guest address of 00:02.0 though, which should maybe be
> > a test as well.  Thanks,
> > 
> > Alex  
> 
> Guest address of 00:02.0 is not mandatory, newer drivers does not depend
> on the address (probably thanks to the discrete GPU, they removed these
> hardcode). Though putting it at guest 00:02.0 is still recommended.
> I would prefer not making this a limit.

I suppose it was never enforced beyond the comment, so if you vouch
that it's not mandatory, let's not make it a requirement now.  Thanks,

Alex



      reply	other threads:[~2025-04-14 21:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-25 17:22 [PATCH] vfio/igd: Check host PCI address when probing Tomita Moeko
2025-04-09 17:18 ` Alex Williamson
2025-04-10  7:34   ` Cédric Le Goater
2025-04-13 17:23     ` Tomita Moeko
2025-04-14 22:05       ` Alex Williamson
2025-04-15 17:36         ` Tomita Moeko
2025-04-15 19:04           ` Alex Williamson
2025-04-16 15:45             ` Tomita Moeko
2025-04-16 16:10               ` Alex Williamson
2025-04-16 17:41                 ` Tomita Moeko
2025-04-16 17:57                   ` Alex Williamson
2025-04-13 11:30   ` Tomita Moeko
2025-04-14 21:51     ` Alex Williamson [this message]

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=20250414155126.6ad0bd9c.alex.williamson@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=clg@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tomitamoeko@gmail.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).