* [PATCH 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission
@ 2017-06-30 4:11 Xiong Zhang
2017-06-30 4:11 ` [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Xiong Zhang
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Xiong Zhang @ 2017-06-30 4:11 UTC (permalink / raw)
To: xen-devel; +Cc: Xiong Zhang, ian.jackson, wei.liu2
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
---
tools/libxl/libxl_pci.c | 45 +++++++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index b14df16..cefd7d8 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -531,6 +531,32 @@ static uint16_t sysfs_dev_get_device(libxl__gc *gc, libxl_device_pci *pcidev)
return pci_device_device;
}
+static int sysfs_dev_get_class(libxl__gc *gc, libxl_device_pci *pcidev,
+ unsigned long *class)
+{
+ char *pci_device_class_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/class",
+ pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+ int read_items;
+
+ FILE *f = fopen(pci_device_class_path, "r");
+ if (!f) {
+ LOGE(ERROR,
+ "pci device "PCI_BDF" does not have class attribute",
+ pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+ return ERROR_FAIL;
+ }
+ read_items = fscanf(f, "0x%lx\n", class);
+ fclose(f);
+ if (read_items != 1) {
+ LOGE(ERROR,
+ "cannot read class of pci device "PCI_BDF,
+ pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+ return ERROR_FAIL;
+ }
+
+ return 0;
+}
+
typedef struct {
uint16_t vendor;
uint16_t device;
@@ -1652,27 +1678,10 @@ int libxl__grant_vga_iomem_permission(libxl__gc *gc, const uint32_t domid,
uint64_t vga_iomem_start = 0xa0000 >> XC_PAGE_SHIFT;
uint32_t stubdom_domid;
libxl_device_pci *pcidev = &d_config->pcidevs[i];
- char *pci_device_class_path =
- GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/class",
- pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
- int read_items;
unsigned long pci_device_class;
- FILE *f = fopen(pci_device_class_path, "r");
- if (!f) {
- LOGED(ERROR, domid,
- "pci device "PCI_BDF" does not have class attribute",
- pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
- continue;
- }
- read_items = fscanf(f, "0x%lx\n", &pci_device_class);
- fclose(f);
- if (read_items != 1) {
- LOGED(ERROR, domid,
- "cannot read class of pci device "PCI_BDF,
- pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+ if (sysfs_dev_get_class(gc, pcidev, &pci_device_class))
continue;
- }
if (pci_device_class != 0x030000) /* VGA class */
continue;
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID 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 2017-06-30 13:54 ` 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 2 siblings, 1 reply; 9+ messages in thread From: Xiong Zhang @ 2017-06-30 4:11 UTC (permalink / raw) To: xen-devel; +Cc: Xiong Zhang, ian.jackson, wei.liu2 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 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID 2017-06-30 4:11 ` [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Xiong Zhang @ 2017-06-30 13:54 ` Wei Liu 0 siblings, 0 replies; 9+ messages in thread From: Wei Liu @ 2017-06-30 13:54 UTC (permalink / raw) To: Xiong Zhang; +Cc: ian.jackson, xen-devel, wei.liu2 On Fri, Jun 30, 2017 at 12:11:27PM +0800, Xiong Zhang wrote: > 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> Acked-by: Wei Liu <wei.liu2@citrix.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission 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 ` [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Xiong Zhang @ 2017-06-30 13:53 ` Wei Liu 2017-07-02 19:25 ` [PATCH v2 " Xiong Zhang 2 siblings, 0 replies; 9+ messages in thread From: Wei Liu @ 2017-06-30 13:53 UTC (permalink / raw) To: Xiong Zhang; +Cc: ian.jackson, xen-devel, wei.liu2 On Fri, Jun 30, 2017 at 12:11:26PM +0800, Xiong Zhang wrote: It would be better in the future you say "No functional change" here. > Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> > --- > tools/libxl/libxl_pci.c | 45 +++++++++++++++++++++++++++------------------ > 1 file changed, 27 insertions(+), 18 deletions(-) > > diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c > index b14df16..cefd7d8 100644 > --- a/tools/libxl/libxl_pci.c > +++ b/tools/libxl/libxl_pci.c > @@ -531,6 +531,32 @@ static uint16_t sysfs_dev_get_device(libxl__gc *gc, libxl_device_pci *pcidev) > return pci_device_device; > } > > +static int sysfs_dev_get_class(libxl__gc *gc, libxl_device_pci *pcidev, > + unsigned long *class) > +{ > + char *pci_device_class_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/class", > + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); > + int read_items; > + > + FILE *f = fopen(pci_device_class_path, "r"); > + if (!f) { > + LOGE(ERROR, > + "pci device "PCI_BDF" does not have class attribute", > + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); > + return ERROR_FAIL; > + } > + read_items = fscanf(f, "0x%lx\n", class); > + fclose(f); > + if (read_items != 1) { > + LOGE(ERROR, > + "cannot read class of pci device "PCI_BDF, > + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); > + return ERROR_FAIL; > + } > + Please use "goto out" style error handling. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission 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 ` [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Xiong Zhang 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 ` 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 2 siblings, 2 replies; 9+ messages in thread From: Xiong Zhang @ 2017-07-02 19:25 UTC (permalink / raw) To: xen-devel; +Cc: Xiong Zhang, ian.jackson, wei.liu2 No functional change. Just extract this function for next patch and avoid code repetition. Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> --- Changes in v2: -Add No functional change in commit message -Use 'goto out' style error handling --- tools/libxl/libxl_pci.c | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index b14df16..d109930 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -531,6 +531,34 @@ static uint16_t sysfs_dev_get_device(libxl__gc *gc, libxl_device_pci *pcidev) return pci_device_device; } +static int sysfs_dev_get_class(libxl__gc *gc, libxl_device_pci *pcidev, + unsigned long *class) +{ + char *pci_device_class_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/class", + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + int read_items, ret = 0; + + FILE *f = fopen(pci_device_class_path, "r"); + if (!f) { + LOGE(ERROR, + "pci device "PCI_BDF" does not have class attribute", + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + ret = ERROR_FAIL; + goto out; + } + read_items = fscanf(f, "0x%lx\n", class); + fclose(f); + if (read_items != 1) { + LOGE(ERROR, + "cannot read class of pci device "PCI_BDF, + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + ret = ERROR_FAIL; + } + +out: + return ret; +} + typedef struct { uint16_t vendor; uint16_t device; @@ -1652,27 +1680,10 @@ int libxl__grant_vga_iomem_permission(libxl__gc *gc, const uint32_t domid, uint64_t vga_iomem_start = 0xa0000 >> XC_PAGE_SHIFT; uint32_t stubdom_domid; libxl_device_pci *pcidev = &d_config->pcidevs[i]; - char *pci_device_class_path = - GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/class", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); - int read_items; unsigned long pci_device_class; - FILE *f = fopen(pci_device_class_path, "r"); - if (!f) { - LOGED(ERROR, domid, - "pci device "PCI_BDF" does not have class attribute", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + if (sysfs_dev_get_class(gc, pcidev, &pci_device_class)) continue; - } - read_items = fscanf(f, "0x%lx\n", &pci_device_class); - fclose(f); - if (read_items != 1) { - LOGED(ERROR, domid, - "cannot read class of pci device "PCI_BDF, - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); - continue; - } if (pci_device_class != 0x030000) /* VGA class */ continue; -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID 2017-07-02 19:25 ` [PATCH v2 " Xiong Zhang @ 2017-07-02 19:25 ` 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 1 sibling, 0 replies; 9+ messages in thread From: Xiong Zhang @ 2017-07-02 19:25 UTC (permalink / raw) To: xen-devel; +Cc: Xiong Zhang, ian.jackson, wei.liu2 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> Acked-by: Wei Liu <wei.liu2@citrix.com> --- Changes in v2: -Add Acked-by: Wei Liu <wei.liu2@citrix.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 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; -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission 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 ` Wei Liu 2017-07-04 11:30 ` Roger Pau Monné 1 sibling, 1 reply; 9+ messages in thread From: Wei Liu @ 2017-07-04 11:07 UTC (permalink / raw) To: Xiong Zhang; +Cc: ian.jackson, xen-devel, wei.liu2 On Mon, Jul 03, 2017 at 03:25:52AM +0800, Xiong Zhang wrote: > No functional change. Just extract this function for next patch and avoid > code repetition. > > Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Note to self: maybe add some blank lines while committing. > --- > Changes in v2: > -Add No functional change in commit message > -Use 'goto out' style error handling > --- > tools/libxl/libxl_pci.c | 47 +++++++++++++++++++++++++++++------------------ > 1 file changed, 29 insertions(+), 18 deletions(-) > > diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c > index b14df16..d109930 100644 > --- a/tools/libxl/libxl_pci.c > +++ b/tools/libxl/libxl_pci.c > @@ -531,6 +531,34 @@ static uint16_t sysfs_dev_get_device(libxl__gc *gc, libxl_device_pci *pcidev) > return pci_device_device; > } > > +static int sysfs_dev_get_class(libxl__gc *gc, libxl_device_pci *pcidev, > + unsigned long *class) > +{ > + char *pci_device_class_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/class", > + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); > + int read_items, ret = 0; > + > + FILE *f = fopen(pci_device_class_path, "r"); > + if (!f) { > + LOGE(ERROR, > + "pci device "PCI_BDF" does not have class attribute", > + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); > + ret = ERROR_FAIL; > + goto out; > + } Here. > + read_items = fscanf(f, "0x%lx\n", class); Here. > + fclose(f); Here. > + if (read_items != 1) { > + LOGE(ERROR, > + "cannot read class of pci device "PCI_BDF, > + pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); > + ret = ERROR_FAIL; > + } > + > +out: > + return ret; > +} > + _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission 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 0 siblings, 1 reply; 9+ messages in thread From: Roger Pau Monné @ 2017-07-04 11:30 UTC (permalink / raw) To: Wei Liu; +Cc: Xiong Zhang, xen-devel, ian.jackson On Tue, Jul 04, 2017 at 12:07:30PM +0100, Wei Liu wrote: > On Mon, Jul 03, 2017 at 03:25:52AM +0800, Xiong Zhang wrote: > > No functional change. Just extract this function for next patch and avoid > > code repetition. > > > > Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> > > Acked-by: Wei Liu <wei.liu2@citrix.com> > > Note to self: maybe add some blank lines while committing. Not that I intend this patch to fix this, but poking ad sysfs nodes should be done in libxl_linux.c. Roger. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission 2017-07-04 11:30 ` Roger Pau Monné @ 2017-07-04 11:34 ` Wei Liu 0 siblings, 0 replies; 9+ messages in thread From: Wei Liu @ 2017-07-04 11:34 UTC (permalink / raw) To: Roger Pau Monné; +Cc: Xiong Zhang, ian.jackson, xen-devel, Wei Liu On Tue, Jul 04, 2017 at 12:30:58PM +0100, Roger Pau Monné wrote: > On Tue, Jul 04, 2017 at 12:07:30PM +0100, Wei Liu wrote: > > On Mon, Jul 03, 2017 at 03:25:52AM +0800, Xiong Zhang wrote: > > > No functional change. Just extract this function for next patch and avoid > > > code repetition. > > > > > > Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> > > > > Acked-by: Wei Liu <wei.liu2@citrix.com> > > > > Note to self: maybe add some blank lines while committing. > > Not that I intend this patch to fix this, but poking ad sysfs nodes > should be done in libxl_linux.c. Indeed. Patches welcome... > > Roger. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-07-04 11:34 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Xiong Zhang 2017-06-30 13:54 ` 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
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).