dm:add function passthru_gpu_dsm_opregion for passthru_init
Pack GPU DSM(Data Stolen Memory) and Opregion related operations into function passthru_gpu_dsm_opregion to avoid passthru_init too mess. Tracked-On: #4700 Signed-off-by: Junming Liu <junming.liu@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Reviewed-by: Liu XinYun <xinyun.liu@intel.com> Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
b45c24b062
commit
795225d55e
|
@ -401,6 +401,32 @@ pciaccess_init(void)
|
|||
return 0; /* success */
|
||||
}
|
||||
|
||||
/*
|
||||
* passthrough GPU DSM(Data Stolen Memory) and Opregion to guest
|
||||
*/
|
||||
void
|
||||
passthru_gpu_dsm_opregion(struct vmctx *ctx, struct passthru_dev *ptdev,
|
||||
struct acrn_assign_pcidev *pcidev)
|
||||
{
|
||||
uint32_t dsm_phys, opregion_phys;
|
||||
/* get dsm hpa */
|
||||
dsm_phys = read_config(ptdev->phys_dev, PCIR_BDSM, 4);
|
||||
dsm_start_hpa = dsm_phys & PCIM_BDSM_MASK;
|
||||
/* initialize the EPT mapping for passthrough GPU dsm region */
|
||||
vm_map_ptdev_mmio(ctx, 0, 2, 0, GPU_DSM_GPA, GPU_DSM_SIZE, dsm_start_hpa);
|
||||
|
||||
/* get opregion hpa */
|
||||
opregion_phys = read_config(ptdev->phys_dev, PCIR_ASLS_CTL, 4);
|
||||
opregion_start_hpa = opregion_phys & PCIM_ASLS_OPREGION_MASK;
|
||||
/* initialize the EPT mapping for passthrough GPU opregion */
|
||||
vm_map_ptdev_mmio(ctx, 0, 2, 0, GPU_OPREGION_GPA, GPU_OPREGION_SIZE, opregion_start_hpa);
|
||||
|
||||
pci_set_cfgdata32(ptdev->dev, PCIR_BDSM, GPU_DSM_GPA | (dsm_phys & ~PCIM_BDSM_MASK));
|
||||
pci_set_cfgdata32(ptdev->dev, PCIR_ASLS_CTL, GPU_OPREGION_GPA | (opregion_phys & ~PCIM_ASLS_OPREGION_MASK));
|
||||
|
||||
pcidev->type = QUIRK_PTDEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* Passthrough device initialization function:
|
||||
* - initialize virtual config space
|
||||
|
@ -523,25 +549,8 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||
if (error < 0)
|
||||
goto done;
|
||||
|
||||
if (ptdev->phys_bdf == PCI_BDF_GPU) {
|
||||
uint32_t dsm_phys, opregion_phys;
|
||||
/* get dsm hpa */
|
||||
dsm_phys = read_config(ptdev->phys_dev, PCIR_BDSM, 4);
|
||||
dsm_start_hpa = dsm_phys & PCIM_BDSM_MASK;
|
||||
/* initialize the EPT mapping for passthrough GPU dsm region */
|
||||
vm_map_ptdev_mmio(ctx, 0, 2, 0, GPU_DSM_GPA, GPU_DSM_SIZE, dsm_start_hpa);
|
||||
|
||||
/* get opregion hpa */
|
||||
opregion_phys = read_config(ptdev->phys_dev, PCIR_ASLS_CTL, 4);
|
||||
opregion_start_hpa = opregion_phys & PCIM_ASLS_OPREGION_MASK;
|
||||
/* initialize the EPT mapping for passthrough GPU opregion */
|
||||
vm_map_ptdev_mmio(ctx, 0, 2, 0, GPU_OPREGION_GPA, GPU_OPREGION_SIZE, opregion_start_hpa);
|
||||
|
||||
pci_set_cfgdata32(dev, PCIR_BDSM, GPU_DSM_GPA | (dsm_phys & ~PCIM_BDSM_MASK));
|
||||
pci_set_cfgdata32(dev, PCIR_ASLS_CTL, GPU_OPREGION_GPA | (opregion_phys & ~PCIM_ASLS_OPREGION_MASK));
|
||||
|
||||
pcidev.type = QUIRK_PTDEV;
|
||||
}
|
||||
if (ptdev->phys_bdf == PCI_BDF_GPU)
|
||||
passthru_gpu_dsm_opregion(ctx, ptdev, &pcidev);
|
||||
|
||||
pcidev.virt_bdf = PCI_BDF(dev->bus, dev->slot, dev->func);
|
||||
pcidev.phys_bdf = ptdev->phys_bdf;
|
||||
|
|
Loading…
Reference in New Issue