All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Fred Gao <fred.gao@intel.com>
Cc: kvm@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	Zhenyu Wang <zhenyuw@linux.intel.com>,
	Xiong Zhang <xiong.y.zhang@intel.com>,
	Hang Yuan <hang.yuan@linux.intel.com>,
	Stuart Summers <stuart.summers@intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH v2] vfio/pci: Refine Intel IGD OpRegion support
Date: Tue, 29 Sep 2020 16:06:24 -0600	[thread overview]
Message-ID: <20200929160624.767f0d9e@x1.home> (raw)
In-Reply-To: <20200929161038.15465-1-fred.gao@intel.com>

On Wed, 30 Sep 2020 00:10:38 +0800
Fred Gao <fred.gao@intel.com> wrote:

> Bypass the IGD initialization for Intel's dgfx devices with own expansion
> ROM and the host/LPC bridge config space are no longer accessed.
> 
> v2: simply test if discrete or integrated gfx device
>     with root bus. (Alex Williamson)
> 
> Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> Cc: Xiong Zhang <xiong.y.zhang@intel.com>
> Cc: Hang Yuan <hang.yuan@linux.intel.com>
> Cc: Stuart Summers <stuart.summers@intel.com>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> Signed-off-by: Fred Gao <fred.gao@intel.com>
> ---
>  drivers/vfio/pci/vfio_pci.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index f634c81998bb..9258ccfadb79 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -336,10 +336,11 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
>  	if (!vfio_vga_disabled() && vfio_pci_is_vga(pdev))
>  		vdev->has_vga = true;
>  
> -
> +	/* Intel's dgfx should not appear on root bus */
>  	if (vfio_pci_is_vga(pdev) &&
>  	    pdev->vendor == PCI_VENDOR_ID_INTEL &&
> -	    IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
> +	    IS_ENABLED(CONFIG_VFIO_PCI_IGD) &&
> +	    pci_is_root_bus(pdev->bus)) {
>  		ret = vfio_pci_igd_init(vdev);
>  		if (ret) {
>  			pci_warn(pdev, "Failed to setup Intel IGD regions\n");


The comment seems rather misplaced here, it only refers to one switch,
several lines down within the set of conditions, but looks like a
header for the entire branch.  I think it would be better to either
expand the comment to describe the entire branch, including the
exclusion, or try to fit the exclusion comment alongside the test, ie.

	/*
	 * Intel IGD requires quirks to support guest drivers.  IGD is
	 * identified as an Intel VGA device on the root bus.
	 */

Or
	    pci_is_root_bus(pdev->bus)) { /* Skip discrete gfx */

The commit title should really include something about excluding
discrete graphics from IGD quirks as well.  It might help downstreams
backport it for support.

It also occurs to me that relying on the physical topology only works
at the bare metal level.  We could for example assign a dgfx device at
address 00:02.0 in the guest.  Nested assignment of that device would
trigger calling vfio_pci_igd_init() and fail.  I see igd has a PCIe
capability type of PCI_EXP_TYPE_RC_END and I'd expect dgfx to have a
type of PCI_EXP_TYPE_LEG_END, but unfortunately QEMU does too good of a
job emulating the PCIe capability and will mangle these to suit the
guest topology.  I wonder then if our best course is to make the above
branch more lenient, for example pruning the failure paths such that we
could use -ENODEV as a non-terminal error like is done for the NVLink
quirks below this code block.  Failure to find an OpRegion might be our
differentiation, where on bare metal we might have both igd and dgfx,
so we'd need the root bus test, but assigning dgfx to a VM and placing
it on the VM root bus wouldn't generate an OpRegion, so both levels
would take the dgfx path.  IGD placed on a non-root bus in the guest
could probably just be considered a misconfiguration by the user...
Thanks,

Alex


WARNING: multiple messages have this Message-ID (diff)
From: Alex Williamson <alex.williamson@redhat.com>
To: Fred Gao <fred.gao@intel.com>
Cc: Hang Yuan <hang.yuan@linux.intel.com>,
	kvm@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [Intel-gfx] [PATCH v2] vfio/pci: Refine Intel IGD OpRegion support
Date: Tue, 29 Sep 2020 16:06:24 -0600	[thread overview]
Message-ID: <20200929160624.767f0d9e@x1.home> (raw)
In-Reply-To: <20200929161038.15465-1-fred.gao@intel.com>

On Wed, 30 Sep 2020 00:10:38 +0800
Fred Gao <fred.gao@intel.com> wrote:

> Bypass the IGD initialization for Intel's dgfx devices with own expansion
> ROM and the host/LPC bridge config space are no longer accessed.
> 
> v2: simply test if discrete or integrated gfx device
>     with root bus. (Alex Williamson)
> 
> Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> Cc: Xiong Zhang <xiong.y.zhang@intel.com>
> Cc: Hang Yuan <hang.yuan@linux.intel.com>
> Cc: Stuart Summers <stuart.summers@intel.com>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> Signed-off-by: Fred Gao <fred.gao@intel.com>
> ---
>  drivers/vfio/pci/vfio_pci.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index f634c81998bb..9258ccfadb79 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -336,10 +336,11 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
>  	if (!vfio_vga_disabled() && vfio_pci_is_vga(pdev))
>  		vdev->has_vga = true;
>  
> -
> +	/* Intel's dgfx should not appear on root bus */
>  	if (vfio_pci_is_vga(pdev) &&
>  	    pdev->vendor == PCI_VENDOR_ID_INTEL &&
> -	    IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
> +	    IS_ENABLED(CONFIG_VFIO_PCI_IGD) &&
> +	    pci_is_root_bus(pdev->bus)) {
>  		ret = vfio_pci_igd_init(vdev);
>  		if (ret) {
>  			pci_warn(pdev, "Failed to setup Intel IGD regions\n");


The comment seems rather misplaced here, it only refers to one switch,
several lines down within the set of conditions, but looks like a
header for the entire branch.  I think it would be better to either
expand the comment to describe the entire branch, including the
exclusion, or try to fit the exclusion comment alongside the test, ie.

	/*
	 * Intel IGD requires quirks to support guest drivers.  IGD is
	 * identified as an Intel VGA device on the root bus.
	 */

Or
	    pci_is_root_bus(pdev->bus)) { /* Skip discrete gfx */

The commit title should really include something about excluding
discrete graphics from IGD quirks as well.  It might help downstreams
backport it for support.

It also occurs to me that relying on the physical topology only works
at the bare metal level.  We could for example assign a dgfx device at
address 00:02.0 in the guest.  Nested assignment of that device would
trigger calling vfio_pci_igd_init() and fail.  I see igd has a PCIe
capability type of PCI_EXP_TYPE_RC_END and I'd expect dgfx to have a
type of PCI_EXP_TYPE_LEG_END, but unfortunately QEMU does too good of a
job emulating the PCIe capability and will mangle these to suit the
guest topology.  I wonder then if our best course is to make the above
branch more lenient, for example pruning the failure paths such that we
could use -ENODEV as a non-terminal error like is done for the NVLink
quirks below this code block.  Failure to find an OpRegion might be our
differentiation, where on bare metal we might have both igd and dgfx,
so we'd need the root bus test, but assigning dgfx to a VM and placing
it on the VM root bus wouldn't generate an OpRegion, so both levels
would take the dgfx path.  IGD placed on a non-root bus in the guest
could probably just be considered a misconfiguration by the user...
Thanks,

Alex

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2020-09-29 22:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 16:10 [PATCH v2] vfio/pci: Refine Intel IGD OpRegion support Fred Gao
2020-09-29 16:10 ` [Intel-gfx] " Fred Gao
2020-09-29  8:49 ` Zhenyu Wang
2020-09-29  8:49   ` [Intel-gfx] " Zhenyu Wang
2020-09-29 19:19 ` [Intel-gfx] ✓ Fi.CI.IGT: success for vfio/pci: Refine Intel IGD OpRegion support (rev2) Patchwork
2020-09-29 22:06 ` Alex Williamson [this message]
2020-09-29 22:06   ` [Intel-gfx] [PATCH v2] vfio/pci: Refine Intel IGD OpRegion support Alex Williamson
2020-11-02 11:48 ` [Intel-gfx] ✓ Fi.CI.BAT: success for vfio/pci: Refine Intel IGD OpRegion support (rev3) Patchwork
2020-11-02 16:13 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2020-11-02 18:01 ` [PATCH v3] vfio/pci: Bypass IGD init in case of -ENODEV Fred Gao
2020-11-02 18:01   ` [Intel-gfx] " Fred Gao
2020-11-03 18:21   ` Alex Williamson
2020-11-03 18:21     ` [Intel-gfx] " 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=20200929160624.767f0d9e@x1.home \
    --to=alex.williamson@redhat.com \
    --cc=fred.gao@intel.com \
    --cc=hang.yuan@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=kvm@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=stuart.summers@intel.com \
    --cc=xiong.y.zhang@intel.com \
    --cc=zhenyuw@linux.intel.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 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.