dm:derive the prefetch property of PCI bar for pass-through device

Now the PCI bar uses the hardcoded prefetch property
for the pass-through device.
This doesn't work when trying to load windows GPU driver
for the pass-through GPU device.

For pass-through devices,
set the bar prefetchable property the same as physical bar.

Tracked-On: #4282

Signed-off-by: Junming Liu <junming.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Junming Liu 2020-01-09 18:36:19 +00:00 committed by wenlingz
parent ceb197c993
commit 03f5c639a0
1 changed files with 19 additions and 0 deletions

View File

@ -527,6 +527,7 @@ cfginitbar(struct vmctx *ctx, struct passthru_dev *ptdev)
struct pci_bar_io bar;
enum pcibar_type bartype;
uint64_t base, size;
uint32_t vbar_lo32;
dev = ptdev->dev;
@ -590,6 +591,24 @@ cfginitbar(struct vmctx *ctx, struct passthru_dev *ptdev)
if (error)
return -1;
/*
* For pass-thru devices,
* set the bar prefetchable property the same as physical bar.
*
* the pci bar prefetchable property has set by pci_emul_alloc_pbar,
* here, override the prefetchable property according to the physical bar.
*/
if (bartype == PCIBAR_MEM32 || bartype == PCIBAR_MEM64) {
vbar_lo32 = pci_get_cfgdata32(dev, PCIR_BAR(i));
if (bar.base & PCIM_BAR_MEM_PREFETCH)
vbar_lo32 |= PCIM_BAR_MEM_PREFETCH;
else
vbar_lo32 &= ~PCIM_BAR_MEM_PREFETCH;
pci_set_cfgdata32(dev, PCIR_BAR(i), vbar_lo32);
}
/* The MSI-X table needs special handling */
if (i == ptdev_msix_table_bar(ptdev)) {
error = init_msix_table(ctx, ptdev, base);