dm: passthrough opregion to uos gpu

This commit is contained in:
Zhipeng Gong 2018-10-18 09:23:09 +08:00 committed by Zhao Yakui
parent 3a0f83ed73
commit e5b21a2e90
3 changed files with 24 additions and 0 deletions

View File

@ -298,6 +298,10 @@ acrn_prepare_zeropage(struct vmctx *ctx, int setup_size)
/* Create/add e820 table entries in zeropage */
zeropage->e820_nentries = acrn_create_e820_table(ctx, zeropage->e820);
if (opregion_start != 0) {
zeropage->e820_nentries = add_e820_entry(zeropage->e820, zeropage->e820_nentries,
opregion_start, OPREGION_SIZE, E820_TYPE_RESERVED);
}
return 0;
}

View File

@ -89,6 +89,8 @@ struct mmio_map {
size_t size;
};
uint32_t opregion_start = 0;
struct passthru_dev {
struct pci_vdev *dev;
struct pcibar bar[PCI_BARMAX + 1];
@ -848,6 +850,12 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
if (error < 0)
goto done;
if (ptdev->phys_bdf == PCI_BDF_GPU) {
opregion_start = read_config(ptdev->phys_dev, PCIR_ASLS_CTL, 4);
printf("Opregion start=%x\n", opregion_start);
opregion_start = ALIGN_DOWN(opregion_start, 4096);
}
/* If ptdev support MSI/MSIX, stop here to skip virtual INTx setup.
* Forge Guest to use MSI/MSIX in this case to mitigate IRQ sharing
* issue
@ -1000,6 +1008,13 @@ passthru_cfgread(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
*rv &= ~PCIM_GMCH_CTL_GMS;
}
if ((PCI_BDF(dev->bus, dev->slot, dev->func) == PCI_BDF_GPU)
&& (coff == PCIR_ASLS_CTL)) {
printf("passthrough opregion = %x\n", ptdev->phys_bdf);
vm_unmap_ptdev_mmio(ctx, 0, 2, 0, opregion_start, OPREGION_SIZE, opregion_start);
vm_map_ptdev_mmio(ctx, 0, 2, 0, opregion_start, OPREGION_SIZE, opregion_start);
}
return 0;
}

View File

@ -143,4 +143,9 @@ void vm_reset_watchdog(struct vmctx *ctx);
int vm_ioeventfd(struct vmctx *ctx, struct acrn_ioeventfd *args);
int vm_irqfd(struct vmctx *ctx, struct acrn_irqfd *args);
extern uint32_t opregion_start;
#define OPREGION_SIZE 0x3000
#define PCIR_ASLS_CTL 0xFC
#endif /* _VMMAPI_H_ */