Change init for pt_pci_host return value.
PATCH 1/2 Change init for pt_pci_host return value.
With an init of -1 all the return value smaller than a double word will be prefixed with "f"s.
--- hw/pass-through.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/pass-through.c +1 -1
@@ -2085,7 +2085,7 @@ struct pci_dev *pt_pci_get_dev(int bus, int dev, int fn)u32 pt_pci_host_read (struct pci_dev *pci_dev,u32 addr,int len) { -u32 val =-1 ; +u32 val =0 ;pci_access_init ();pci_read_block (pci_dev, addr, (u8 *) &val, len);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH 2/2 intel gpu passthrough: Expose vendor specific pci cap on host bridge.
Some versions of the Windows Intel GPU driver expect the vendor PCI capability to be there on the host bridge config space when passing through a Intel GPU.
From: Ross Philipson <[email protected]>
--- hw/pt-graphics.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-)
hw/pt-graphics.c +44 -5
@@ -60,6 +60,42 @@ void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int l } } +#define PCI_INTEL_VENDOR_CAP 0x34 +#define PCI_INTEL_VENDOR_CAP_TYPE 0x09 +static uint32_t igd_pci_read_vendor_cap (PCIDevice *pci_dev,uint32_t config_addr,int len, +uint32_t val) +{ +struct pci_dev *pci_dev_host_bridge =pt_pci_get_dev (0 ,0 ,0 ); +uint32_t vendor_cap =0 ; +uint32_t cap_type =0 ; +uint32_t cap_size =0 ; + + vendor_cap =pt_pci_host_read (pci_dev_host_bridge,PCI_INTEL_VENDOR_CAP ,1 ); +if (!vendor_cap) +return -1 ; + + cap_type =pt_pci_host_read (pci_dev_host_bridge, vendor_cap,1 ); +if (cap_type !=PCI_INTEL_VENDOR_CAP_TYPE ) +return -1 ; + +if (config_addr ==PCI_INTEL_VENDOR_CAP ) +return vendor_cap; + +/* Remove the next capability link */ +if (config_addr == vendor_cap +1 ) +return 0 ; + + cap_size =pt_pci_host_read (pci_dev_host_bridge, vendor_cap +2 ,1 ); +if (config_addr >= vendor_cap && + config_addr + len < vendor_cap + cap_size) + { +return pt_pci_host_read (pci_dev_host_bridge, config_addr, len); + } + +/* -1, this function doesn't deal with this config space offset */ +return -1 ; +} +uint32_t igd_pci_read (PCIDevice *pci_dev,uint32_t config_addr,int len) {struct pci_dev *pci_dev_host_bridge =pt_pci_get_dev (0 ,0 ,0 );
@@ -82,14 +118,17 @@ uint32_t igd_pci_read(PCIDevice *pci_dev, uint32_t config_addr, int len)case 0xa4 :/* SNB: graphics base of stolen memory */ case 0xa8 :/* SNB: base of GTT stolen memory */ val =pt_pci_host_read (pci_dev_host_bridge, config_addr, len); -#ifdef PT_DEBUG_PCI_CONFIG_ACCESS -PT_LOG_DEV (pci_dev,"addr=%x len=%x val=%x\n" , - config_addr, len, val); -#endif break ;default : - val =pci_default_read_config (pci_dev, config_addr, len); + val =igd_pci_read_vendor_cap (pci_dev, config_addr, len, val); +if (val ==-1 ) + val =pci_default_read_config (pci_dev, config_addr, len); + } +#ifdef PT_DEBUG_PCI_CONFIG_ACCESS +PT_LOG_DEV (pci_dev,"addr=%x len=%x val=%x\n" , + config_addr, len, val); +#endif return val; }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 2/2] intel gpu passthrough: Expose vendor specific pci cap on host bridge.
Quoted 46 lines · Jean Guyader
Some versions of the Windows Intel GPU driver expect the vendor PCI capability to be there on the host bridge config space when passing through a Intel GPU.
From: Ross Philipson <[email protected]>
Signed-off-by Jean Guyader <[email protected]>Acked-by Ross Philipson <[email protected]>--- hw/pt-graphics.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-)hw/pt-graphics.c +25
-0@@ -60,6 +60,42 @@ void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int l } } +#define PCI_INTEL_VENDOR_CAP 0x34 +#define PCI_INTEL_VENDOR_CAP_TYPE 0x09 +static uint32_t igd_pci_read_vendor_cap (PCIDevice *pci_dev,uint32_t config_addr,int len, +uint32_t val) +{ +struct pci_dev *pci_dev_host_bridge =pt_pci_get_dev (0 ,0 ,0 ); +uint32_t vendor_cap =0 ; +uint32_t cap_type =0 ; +uint32_t cap_size =0 ; + + vendor_cap =pt_pci_host_read (pci_dev_host_bridge,PCI_INTEL_VENDOR_CAP ,1 ); +if (!vendor_cap) +return -1 ; + + cap_type =pt_pci_host_read (pci_dev_host_bridge, vendor_cap,1 ); +if (cap_type !=PCI_INTEL_VENDOR_CAP_TYPE ) +return -1 ; + +if (config_addr ==PCI_INTEL_VENDOR_CAP ) +return vendor_cap; + +/* Remove the next capability link */ +if (config_addr == vendor_cap +1 ) +return 0 ; +
hw/pt-graphics.c void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int l · line 97
Quoted 10 lines
hw/pt-graphics.c +10
-0+ cap_size =pt_pci_host_read (pci_dev_host_bridge, vendor_cap +2 ,1 ); +if (config_addr >= vendor_cap && + config_addr + len < vendor_cap + cap_size) + { +return pt_pci_host_read (pci_dev_host_bridge, config_addr, len); + } + +/* -1, this function doesn't deal with this config space offset */ +return -1 ; +}
You are passing val to igd_pci_read_vendor_cap without actually using it.
Also you are returning -1 from a function that returns uint32_t.
I would change the prototype of igd_pci_read_vendor_cap to:
static int igd_pci_read_vendor_cap(PCIDevice *pci_dev, uint32_t config_addr, int len,
uint32_t *val)
return only 0 or error and set *val to the correct value.
Quoted 26 lines
hw/pt-graphics.c +8
-5uint32_t igd_pci_read (PCIDevice *pci_dev,uint32_t config_addr,int len) {struct pci_dev *pci_dev_host_bridge =pt_pci_get_dev (0 ,0 ,0 );@@ -82,14 +118,17 @@ uint32_t igd_pci_read(PCIDevice *pci_dev, uint32_t config_addr, int len)case 0xa4 :/* SNB: graphics base of stolen memory */ case 0xa8 :/* SNB: base of GTT stolen memory */ val =pt_pci_host_read (pci_dev_host_bridge, config_addr, len); -#ifdef PT_DEBUG_PCI_CONFIG_ACCESS -PT_LOG_DEV (pci_dev,"addr=%x len=%x val=%x\n" , - config_addr, len, val); -#endif break ;default : - val =pci_default_read_config (pci_dev, config_addr, len); + val =igd_pci_read_vendor_cap (pci_dev, config_addr, len, val); +if (val ==-1 ) + val =pci_default_read_config (pci_dev, config_addr, len); + } +#ifdef PT_DEBUG_PCI_CONFIG_ACCESS +PT_LOG_DEV (pci_dev,"addr=%x len=%x val=%x\n" , + config_addr, len, val); +#endif return val; }
Re: [PATCH 2/2] intel gpu passthrough: Expose vendor specific pci cap on host bridge.
Quoted 62 lines · Stefano Stabellini
Quoted 46 lines · Jean Guyader
Some versions of the Windows Intel GPU driver expect the vendor PCI capability to be there on the host bridge config space when passing through a Intel GPU.
From: Ross Philipson <[email protected]>
Signed-off-by Jean Guyader <[email protected]>Acked-by Ross Philipson <[email protected]>--- hw/pt-graphics.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-)hw/pt-graphics.c +25
-0@@ -60,6 +60,42 @@ void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int l } } +#define PCI_INTEL_VENDOR_CAP 0x34 +#define PCI_INTEL_VENDOR_CAP_TYPE 0x09 +static uint32_t igd_pci_read_vendor_cap (PCIDevice *pci_dev,uint32_t config_addr,int len, +uint32_t val) +{ +struct pci_dev *pci_dev_host_bridge =pt_pci_get_dev (0 ,0 ,0 ); +uint32_t vendor_cap =0 ; +uint32_t cap_type =0 ; +uint32_t cap_size =0 ; + + vendor_cap =pt_pci_host_read (pci_dev_host_bridge,PCI_INTEL_VENDOR_CAP ,1 ); +if (!vendor_cap) +return -1 ; + + cap_type =pt_pci_host_read (pci_dev_host_bridge, vendor_cap,1 ); +if (cap_type !=PCI_INTEL_VENDOR_CAP_TYPE ) +return -1 ; + +if (config_addr ==PCI_INTEL_VENDOR_CAP ) +return vendor_cap; + +/* Remove the next capability link */ +if (config_addr == vendor_cap +1 ) +return 0 ; +hw/pt-graphics.c void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int l · line 97
Quoted 10 lines
hw/pt-graphics.c +10
-0+ cap_size =pt_pci_host_read (pci_dev_host_bridge, vendor_cap +2 ,1 ); +if (config_addr >= vendor_cap && + config_addr + len < vendor_cap + cap_size) + { +return pt_pci_host_read (pci_dev_host_bridge, config_addr, len); + } + +/* -1, this function doesn't deal with this config space offset */ +return -1 ; +}You are passing val to
igd_pci_read_vendor_capwithout actually using it.
Also you are returning -1 from a function that returnsuint32_t.
Quoted 9 lines
I would change the prototype of
igd_pci_read_vendor_capto:static int igd_pci_read_vendor_cap(PCIDevice
*pci_dev,uint32_tconfig_addr, int len,uint32_t *val)return only 0 or error and set *val to the correct value.
Thanks for the review.
I'll update the patch and send a new series.
Jean
Quoted 2 lines · Jean Guyader
With an init of -1 all the return value smaller than a double word will be prefixed with "f"s.
ack