From patchwork Fri Jun 30 04:11:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Xiong Y" X-Patchwork-Id: 9819287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BDCFA603D7 for ; Fri, 30 Jun 2017 11:13:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFF7828632 for ; Fri, 30 Jun 2017 11:13:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A481B28639; Fri, 30 Jun 2017 11:13:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34A3E28632 for ; Fri, 30 Jun 2017 11:13:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQtpa-0000An-BV; Fri, 30 Jun 2017 11:11:22 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQtpY-0000AN-Vh for xen-devel@lists.xensource.com; Fri, 30 Jun 2017 11:11:21 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id AD/14-03406-8D136595; Fri, 30 Jun 2017 11:11:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeJIrShJLcpLzFFi42Jpa+tw1L1uGBZ pMO2+hsW9Ke/ZHRg9tvftYg9gjGLNzEvKr0hgzVj9/iVrwQaZivMft7M1MF4Q7WLk4hASmMYo ceXBdsYuRk4OCQFeiSPLZrBC2P4SD5qfsIPYQgJVEnc+bmUBsdkEtCXW/j3FBmKLCChKrFv9D izOLBAtcWfuarB6YYF4iauti5lBbBYBVYkbs2+DzecVcJc4+eQL1C45iZvnOsFqOAU8JFas/M sEsctd4uXkVWwTGHkXMDKsYtQoTi0qSy3SNTTQSyrKTM8oyU3MzAHyzPRyU4uLE9NTcxKTivW S83M3MQLDgQEIdjDeWxZwiFGSg0lJlHfltdBIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8wQZh kUKCRanpqRVpmTnAwIRJS3DwKInwPnoK1MpbXJCYW5yZDpE6xWjMcWzGz29MHKtmAkkhlrz8v FQpcd4+kEkCIKUZpXlwg2ARc4lRVkqYlxHoNCGegtSi3MwSVPlXjOIcjErCvJbA+BPiycwrgd v3CugUJqBThGeEgJxSkoiQkmpg1H4Ssu+vhNyOyZ19lkGshpduHb4RwrdY4btxmQs/07ue78u aArUWPp3Ou5zxtlZ7wWudmydncUaYBUTF5x21+ZGUfSVy962ZG9Um3eeevi3C7/6qq9oT5W3+ stj7bHL81HZ6Pb/kfYtFCy2j5y2rfdn+vWWl7qoNDx+HPfinYnE39vnxqW/OzFRiKc5INNRiL ipOBABT8m5nkwIAAA== X-Env-Sender: xiong.y.zhang@intel.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1498821076!52106899!2 X-Originating-IP: [134.134.136.65] X-SpamReason: No, hits=1.3 required=7.0 tests=BODY_RANDOM_LONG, DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57082 invoked from network); 30 Jun 2017 11:11:19 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 30 Jun 2017 11:11:19 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jun 2017 04:10:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,286,1496127600"; d="scan'208";a="987176532" Received: from test-kbl.bj.intel.com ([10.238.158.145]) by orsmga003.jf.intel.com with ESMTP; 30 Jun 2017 04:10:45 -0700 From: Xiong Zhang To: xen-devel@lists.xensource.com Date: Fri, 30 Jun 2017 12:11:27 +0800 Message-Id: <1498795887-23149-2-git-send-email-xiong.y.zhang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498795887-23149-1-git-send-email-xiong.y.zhang@intel.com> References: <1498795887-23149-1-git-send-email-xiong.y.zhang@intel.com> Cc: Xiong Zhang , ian.jackson@eu.citrix.com, wei.liu2@citrix.com Subject: [Xen-devel] [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Wei Liu --- 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;