All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomita Moeko <tomitamoeko@gmail.com>
To: "Cédric Le Goater" <clg@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>
Cc: qemu-devel@nongnu.org, "Corvin Köhne" <c.koehne@beckhoff.com>
Subject: Re: [PATCH] vfio/igd: Check host PCI address when probing
Date: Mon, 14 Apr 2025 01:23:56 +0800	[thread overview]
Message-ID: <3e9743ab-bf81-4d92-8ea0-e01ac58a234b@gmail.com> (raw)
In-Reply-To: <046a2961-23b1-4ef2-8673-9b9deedbbbdf@redhat.com>


On 4/10/25 15:34, Cédric Le Goater wrote:
> + Corvin
> 
> On 4/9/25 19: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.
>>
>> 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.
> 
> Maintaining a list of PCI IDs for Intel GPU devices as Corvin was
> proposing in [1] is not a viable solution ?
> 
> Thanks,
> 
> C.
> 
> [1] https://lore.kernel.org/qemu-devel/20250206121341.118337-1-corvin.koehne@gmail.com/

I checked Intel doc, probably maintaining an device ID list is the only
possible way. But given that intel is moving to xe driver, generation
becomes unclear, I'd like to propose a list with quirk flags for igd.

static const struct igd_device igd_devices[] = {
    INTEL_SNB_IDS(IGD_DEVICE, OPREGION_QUIRK | BDSM_QUIRK),
    INTEL_TGL_IDS(IGD_DEVICE, OPREGION_QUIRK | BDSM64_QUIRK),
}

Matching in the list is more time consuming than current switch-case,
it's better to have a new field to cache it.

I will go with Corvin's first 2 patches with reordering suggested by
Cornelia.

Thanks,
Moeko
  
>> 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
>>
>>> +
>>>   /*
>>>    * This presumes the device is already known to be an Intel VGA device, so we
>>>    * take liberties in which device ID bits match which generation.  This should
>>> @@ -427,13 +434,7 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)
>>>       VFIOConfigMirrorQuirk *ggc_mirror, *bdsm_mirror;
>>>       int gen;
>>>   -    /*
>>> -     * This must be an Intel VGA device at address 00:02.0 for us to even
>>> -     * consider enabling legacy mode. Some driver have dependencies on the PCI
>>> -     * bus address.
>>> -     */
>>> -    if (!vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, PCI_ANY_ID) ||
>>> -        !vfio_is_vga(vdev) || nr != 0) {
>>> +    if (nr != 0 || !vfio_is_igd(vdev)) {
>>>           return;
>>>       }
>>>   @@ -490,13 +491,7 @@ static bool vfio_pci_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
>>>       bool legacy_mode_enabled = false;
>>>       Error *err = NULL;
>>>   -    /*
>>> -     * This must be an Intel VGA device at address 00:02.0 for us to even
>>> -     * consider enabling legacy mode.  The vBIOS has dependencies on the
>>> -     * PCI bus address.
>>> -     */
>>> -    if (!vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, PCI_ANY_ID) ||
>>> -        !vfio_is_vga(vdev)) {
>>> +    if (!vfio_is_igd(vdev)) {
>>>           return true;
>>>       }
>>>   
>>
> 


  reply	other threads:[~2025-04-13 17:24 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 [this message]
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

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=3e9743ab-bf81-4d92-8ea0-e01ac58a234b@gmail.com \
    --to=tomitamoeko@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=c.koehne@beckhoff.com \
    --cc=clg@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.