From patchwork Sun Jul 2 19:25:53 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: 9821879 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 39C006035F for ; Mon, 3 Jul 2017 02:27:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2732F22B27 for ; Mon, 3 Jul 2017 02:27:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BD7A252D5; Mon, 3 Jul 2017 02:27:54 +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 99D0322B27 for ; Mon, 3 Jul 2017 02:27:53 +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 1dRr3m-0000TL-FS; Mon, 03 Jul 2017 02:25:58 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRr3l-0000TB-Ar for xen-devel@lists.xensource.com; Mon, 03 Jul 2017 02:25:57 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 0D/92-02962-43BA9595; Mon, 03 Jul 2017 02:25:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRWlGSWpSXmKPExsVywNykQtd4dWS kwfT/Jhb3prxnd2D02N63iz2AMYo1My8pvyKBNaN96jvmgscyFR1nPrM0ML4X7WLk5BASmM4o MeGYOYgtIcArcWTZDFYI21+i89xSNoiaKonGD9fBbDYBbYm1f0+B2SICihLrVr9jAbGZBaIl7 sxdzQ5iCwskSRzonMEIYrMIqErc3HIUqJ6Dg1fAXaJ5YgDEeDmJm+c6mUFsTgEPieV/1gKVcw GtamGUaDq1mGUCI+8CRoZVjBrFqUVlqUW6hsZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV 6yfm5mxiBwcAABDsYvywLOMQoycGkJMq78lpopBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3vRV kZFCgkWp6akVaZk5wLCESUtw8CiJ8F7zAUrzFhck5hZnpkOkTjEac6ya+fMbE8erCf+/MQmx5 OXnpUqJ8+qDTBIAKc0ozYMbBIuXS4yyUsK8jECnCfEUpBblZpagyr9iFOdgVBLmjV4JNIUnM6 8Ebt8roFOYgE5p6IkAOaUkESEl1cDY2iJYLFb9ulAh+6rGnXaf9m8We5Zyu35OrvTm+jnr8Z8 i/XBXZouvMqnBVpP2Hl0Y9aGmr7P+QAPP/trLz6tuxwjOUr/RP1+cR9V9oo6gh9Lnw588/UQ8 fh/0KTLhzF1RO92eaVbKZ4Un8/82pixLd9JXWBPycf7dXO7PKz4vvXPg0xKdygtKLMUZiYZaz EXFiQDYC4DZkgIAAA== X-Env-Sender: xiong.y.zhang@intel.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1499048753!104431080!1 X-Originating-IP: [192.55.52.120] 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 56887 invoked from network); 3 Jul 2017 02:25:55 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-4.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 Jul 2017 02:25:55 -0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2017 19:25:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,300,1496127600"; d="scan'208";a="121599843" Received: from test-kbl.bj.intel.com ([10.238.158.145]) by fmsmga005.fm.intel.com with ESMTP; 02 Jul 2017 19:25:51 -0700 From: Xiong Zhang To: xen-devel@lists.xensource.com Date: Mon, 3 Jul 2017 03:25:53 +0800 Message-Id: <1499023553-30703-2-git-send-email-xiong.y.zhang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499023553-30703-1-git-send-email-xiong.y.zhang@intel.com> References: <1498795887-23149-1-git-send-email-xiong.y.zhang@intel.com> <1499023553-30703-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 v2 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 --- Changes in v2: -Add 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 d109930..65ad5e5 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -559,46 +559,6 @@ out: return ret; } -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. @@ -606,24 +566,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;