xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Xiong Zhang <xiong.y.zhang@intel.com>
To: xen-devel@lists.xensource.com
Cc: Xiong Zhang <xiong.y.zhang@intel.com>,
	ian.jackson@eu.citrix.com, wei.liu2@citrix.com
Subject: [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID
Date: Fri, 30 Jun 2017 12:11:27 +0800	[thread overview]
Message-ID: <1498795887-23149-2-git-send-email-xiong.y.zhang@intel.com> (raw)
In-Reply-To: <1498795887-23149-1-git-send-email-xiong.y.zhang@intel.com>

IGD passthrough couldn't work on Skylake and Kabylake, because their
Device ID aren't in fixup_ids[]. Currently we need to add every intel
graphic ID into fixup_ids[], it is hard to maintain.

This patch judge intel graphics through vendor id (0x8086) and class
code(0x030000), this could support both the old and new intel graphics,
and reduce maintain work in future.

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
---
 tools/libxl/libxl_pci.c | 59 ++++++++-----------------------------------------
 1 file changed, 9 insertions(+), 50 deletions(-)

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index cefd7d8..7b43622 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -557,46 +557,6 @@ static int sysfs_dev_get_class(libxl__gc *gc, libxl_device_pci *pcidev,
     return 0;
 }
 
-typedef struct {
-    uint16_t vendor;
-    uint16_t device;
-} pci_info;
-
-static const pci_info fixup_ids[] = {
-    /* Intel HSW Classic */
-    {0x8086, 0x0402}, /* HSWGT1D, HSWD_w7 */
-    {0x8086, 0x0406}, /* HSWGT1M, HSWM_w7 */
-    {0x8086, 0x0412}, /* HSWGT2D, HSWD_w7 */
-    {0x8086, 0x0416}, /* HSWGT2M, HSWM_w7 */
-    {0x8086, 0x041E}, /* HSWGT15D, HSWD_w7 */
-    /* Intel HSW ULT */
-    {0x8086, 0x0A06}, /* HSWGT1UT, HSWM_w7 */
-    {0x8086, 0x0A16}, /* HSWGT2UT, HSWM_w7 */
-    {0x8086, 0x0A26}, /* HSWGT3UT, HSWM_w7 */
-    {0x8086, 0x0A2E}, /* HSWGT3UT28W, HSWM_w7 */
-    {0x8086, 0x0A1E}, /* HSWGT2UX, HSWM_w7 */
-    {0x8086, 0x0A0E}, /* HSWGT1ULX, HSWM_w7 */
-    /* Intel HSW CRW */
-    {0x8086, 0x0D26}, /* HSWGT3CW, HSWM_w7 */
-    {0x8086, 0x0D22}, /* HSWGT3CWDT, HSWD_w7 */
-    /* Intel HSW Server */
-    {0x8086, 0x041A}, /* HSWSVGT2, HSWD_w7 */
-    /* Intel HSW SRVR */
-    {0x8086, 0x040A}, /* HSWSVGT1, HSWD_w7 */
-    /* Intel BSW */
-    {0x8086, 0x1606}, /* BDWULTGT1, BDWM_w7 */
-    {0x8086, 0x1616}, /* BDWULTGT2, BDWM_w7 */
-    {0x8086, 0x1626}, /* BDWULTGT3, BDWM_w7 */
-    {0x8086, 0x160E}, /* BDWULXGT1, BDWM_w7 */
-    {0x8086, 0x161E}, /* BDWULXGT2, BDWM_w7 */
-    {0x8086, 0x1602}, /* BDWHALOGT1, BDWM_w7 */
-    {0x8086, 0x1612}, /* BDWHALOGT2, BDWM_w7 */
-    {0x8086, 0x1622}, /* BDWHALOGT3, BDWM_w7 */
-    {0x8086, 0x162B}, /* BDWHALO28W, BDWM_w7 */
-    {0x8086, 0x162A}, /* BDWGT3WRKS, BDWM_w7 */
-    {0x8086, 0x162D}, /* BDWGT3SRVR, BDWM_w7 */
-};
-
 /*
  * Some devices may need some ways to work well. Here like IGD,
  * we have to pass a specific option to qemu.
@@ -604,24 +564,23 @@ static const pci_info fixup_ids[] = {
 bool libxl__is_igd_vga_passthru(libxl__gc *gc,
                                 const libxl_domain_config *d_config)
 {
-    unsigned int i, j, num = ARRAY_SIZE(fixup_ids);
-    uint16_t vendor, device, pt_vendor, pt_device;
+    unsigned int i;
+    uint16_t pt_vendor, pt_device;
+    unsigned long class;
 
     for (i = 0 ; i < d_config->num_pcidevs ; i++) {
         libxl_device_pci *pcidev = &d_config->pcidevs[i];
         pt_vendor = sysfs_dev_get_vendor(gc, pcidev);
         pt_device = sysfs_dev_get_device(gc, pcidev);
 
-        if (pt_vendor == 0xffff || pt_device == 0xffff)
+        if (pt_vendor == 0xffff || pt_device == 0xffff ||
+            pt_vendor != 0x8086)
             continue;
 
-        for (j = 0 ; j < num ; j++) {
-            vendor = fixup_ids[j].vendor;
-            device = fixup_ids[j].device;
-
-            if (pt_vendor == vendor &&  pt_device == device)
-                return true;
-        }
+        if (sysfs_dev_get_class(gc, pcidev, &class))
+            continue;
+        if (class == 0x030000)
+            return true;
     }
 
     return false;
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-06-30  4:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30  4:11 [PATCH 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission Xiong Zhang
2017-06-30  4:11 ` Xiong Zhang [this message]
2017-06-30 13:54   ` [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Wei Liu
2017-06-30 13:53 ` [PATCH 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission Wei Liu
2017-07-02 19:25 ` [PATCH v2 " Xiong Zhang
2017-07-02 19:25   ` [PATCH v2 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Xiong Zhang
2017-07-04 11:07   ` [PATCH v2 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission Wei Liu
2017-07-04 11:30     ` Roger Pau Monné
2017-07-04 11:34       ` Wei Liu

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=1498795887-23149-2-git-send-email-xiong.y.zhang@intel.com \
    --to=xiong.y.zhang@intel.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xensource.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).