mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-01 09:42:10 +00:00
dm:passthrough graphics stolen memory to uos gpu
gop driver and uos IGD driver will use graphics stolen memory(gsm) when enable GVT-d. This patch pass-thru gsm to uos gpu. After set physical GPU gsm size 64MB in host BIOS: Here is the steps: (1) set gsm gpa(guest physical addrress) 0xDB000000; (2) get gsm hpa(host physical addrress); (3) build EPT mapping for gsm. v1 -> v2: * initialize the EPT mapping for passthrough GPU gsm region in passthru_init instead of reading the BDSM config space v2 -> v3: * add EPT unmap when deinit * change some micro name Tracked-On: #4360 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: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: Wu Binbin <binbin.wu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
f9f64d356f
commit
4d882731ce
@ -101,6 +101,9 @@ const struct e820_entry e820_default_entries[NUM_E820_ENTRIES] = {
|
||||
* For ACRN, we simply hard code to 64MB and static
|
||||
* reserved the memory region to avoid more efforts in OVMF,
|
||||
* and user *must* align the native BIOS setting to 64MB.
|
||||
*
|
||||
* GPU_GSM_GPA micro in passthrough.c should
|
||||
+ * align with this address here.
|
||||
*/
|
||||
.baseaddr = 0xDB000000,
|
||||
.length = 0x4000000,
|
||||
|
@ -69,6 +69,10 @@
|
||||
*/
|
||||
#define AUDIO_NHLT_HACK 1
|
||||
|
||||
#define GPU_GSM_SIZE 0x4000000
|
||||
/* set gsm gpa=0xDB000000, which is reserved in e820 table */
|
||||
#define GPU_GSM_GPA 0xDB000000
|
||||
|
||||
extern uint64_t audio_nhlt_len;
|
||||
|
||||
/* reference count for libpciaccess init/deinit */
|
||||
@ -81,6 +85,8 @@ struct mmio_map {
|
||||
size_t size;
|
||||
};
|
||||
|
||||
uint32_t gsm_start_hpa = 0;
|
||||
|
||||
struct passthru_dev {
|
||||
struct pci_vdev *dev;
|
||||
struct pcibar bar[PCI_BARMAX + 1];
|
||||
@ -861,6 +867,14 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
if (error < 0)
|
||||
goto done;
|
||||
|
||||
if (ptdev->phys_bdf == PCI_BDF_GPU) {
|
||||
/* get gsm hpa */
|
||||
gsm_start_hpa = read_config(ptdev->phys_dev, PCIR_BDSM, 4);
|
||||
gsm_start_hpa &= PCIM_BDSM_GSM_MASK;
|
||||
/* initialize the EPT mapping for passthrough GPU gsm region */
|
||||
vm_map_ptdev_mmio(ctx, 0, 2, 0, GPU_GSM_GPA, GPU_GSM_SIZE, gsm_start_hpa);
|
||||
}
|
||||
|
||||
/* 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
|
||||
@ -946,6 +960,10 @@ passthru_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
ptdev->bar[i].addr);
|
||||
}
|
||||
|
||||
if (ptdev->phys_bdf == PCI_BDF_GPU) {
|
||||
vm_unmap_ptdev_mmio(ctx, 0, 2, 0, GPU_GSM_GPA, GPU_GSM_SIZE, gsm_start_hpa);
|
||||
}
|
||||
|
||||
pciaccess_cleanup();
|
||||
free(ptdev);
|
||||
vm_unassign_ptdev(ctx, bus, slot, func);
|
||||
@ -1037,13 +1055,15 @@ passthru_cfgread(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
/* Everything else just read from the device's config space */
|
||||
*rv = read_config(ptdev->phys_dev, coff, bytes);
|
||||
|
||||
/*
|
||||
* return zero for graphics stolen memory since acrn does not have
|
||||
* support for RMRR
|
||||
/* passthru_init has initialized the EPT mapping
|
||||
* for GPU gsm region.
|
||||
* So uos GPU can passthrough physical gsm now.
|
||||
* Here, only need return gsm gpa value for uos.
|
||||
*/
|
||||
if ((PCI_BDF(dev->bus, dev->slot, dev->func) == PCI_BDF_GPU)
|
||||
&& (coff == PCIR_GMCH_CTL)) {
|
||||
*rv &= ~PCIM_GMCH_CTL_GMS;
|
||||
&& (coff == PCIR_BDSM)) {
|
||||
*rv &= ~PCIM_BDSM_GSM_MASK;
|
||||
*rv |= GPU_GSM_GPA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1066,6 +1066,6 @@
|
||||
#define PCIM_OSC_CTL_PCIE_CAP_STRUCT 0x10 /* Various Capability Structures */
|
||||
|
||||
/* Graphics definitions */
|
||||
#define PCIR_GMCH_CTL 0x50 /*GMCH grpahics control register */
|
||||
#define PCIM_GMCH_CTL_GMS 0xFF00 /*GMS - stolen memory bits 15:8 */
|
||||
#define PCIR_BDSM 0x5C /* BDSM graphics base data of stolen memory register */
|
||||
#define PCIM_BDSM_GSM_MASK 0xFFF00000 /* bits 31:20 contains the base address of stolen memory */
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user