Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_gvt-d.c
Show All 14 Lines | |||||||||
#include "pci_gvt-d-opregion.h" | #include "pci_gvt-d-opregion.h" | ||||||||
#include "pci_gvt-d.h" | #include "pci_gvt-d.h" | ||||||||
#include "pci_passthru.h" | #include "pci_passthru.h" | ||||||||
#define KB (1024UL) | #define KB (1024UL) | ||||||||
#define MB (1024 * KB) | #define MB (1024 * KB) | ||||||||
#define GB (1024 * MB) | #define GB (1024 * MB) | ||||||||
#define PCIR_BDSM 0x5C /* Base of Data Stolen Memory register */ | |||||||||
#define PCIM_BDSM_GSM_ALIGNMENT \ | #define PCIM_BDSM_GSM_ALIGNMENT \ | ||||||||
0x00100000 /* Graphics Stolen Memory is 1 MB aligned */ | 0x00100000 /* Graphics Stolen Memory is 1 MB aligned */ | ||||||||
#define GVT_D_MAP_GSM 0 | #define GVT_D_MAP_GSM 0 | ||||||||
static vm_paddr_t | static vm_paddr_t | ||||||||
gvt_d_alloc_mmio_memory(const vm_paddr_t host_address, const vm_paddr_t length, | gvt_d_alloc_mmio_memory(const vm_paddr_t host_address, const vm_paddr_t length, | ||||||||
const vm_paddr_t alignment, const enum e820_memory_type type) | const vm_paddr_t alignment, const enum e820_memory_type type) | ||||||||
Show All 37 Lines | |||||||||
* https://github.com/projectacrn/acrn-hypervisor/blob/e28d6fbfdfd556ff1bc3ff330e41d4ddbaa0f897/devicemodel/hw/pci/passthrough.c#L626-L629 | * https://github.com/projectacrn/acrn-hypervisor/blob/e28d6fbfdfd556ff1bc3ff330e41d4ddbaa0f897/devicemodel/hw/pci/passthrough.c#L626-L629 | ||||||||
*/ | */ | ||||||||
static int | static int | ||||||||
gvt_d_setup_gsm(struct pci_devinst *const pi) | gvt_d_setup_gsm(struct pci_devinst *const pi) | ||||||||
{ | { | ||||||||
struct passthru_softc *sc; | struct passthru_softc *sc; | ||||||||
struct passthru_mmio_mapping *gsm; | struct passthru_mmio_mapping *gsm; | ||||||||
size_t sysctl_len; | size_t sysctl_len; | ||||||||
uint64_t bdsm; | |||||||||
markjUnsubmitted Not Done Inline Actions
markj: | |||||||||
int error; | int error; | ||||||||
sc = pi->pi_arg; | sc = pi->pi_arg; | ||||||||
gsm = passthru_get_mmio(sc, GVT_D_MAP_GSM); | gsm = passthru_get_mmio(sc, GVT_D_MAP_GSM); | ||||||||
if (gsm == NULL) { | if (gsm == NULL) { | ||||||||
warnx("%s: Unable to access gsm", __func__); | warnx("%s: Unable to access gsm", __func__); | ||||||||
return (-1); | return (-1); | ||||||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (gsm->gpa != gsm->hpa) { | ||||||||
* Maybe not always possible. As far as we know, no supported | * Maybe not always possible. As far as we know, no supported | ||||||||
* platform requires a 1:1 mapping. For that reason, just log a | * platform requires a 1:1 mapping. For that reason, just log a | ||||||||
* warning. | * warning. | ||||||||
*/ | */ | ||||||||
warnx( | warnx( | ||||||||
"Warning: Unable to reuse host address of Graphics Stolen Memory. GPU passthrough might not work properly."); | "Warning: Unable to reuse host address of Graphics Stolen Memory. GPU passthrough might not work properly."); | ||||||||
} | } | ||||||||
return (0); | bdsm = read_config(passthru_get_sel(sc), PCIR_BDSM, 4); | ||||||||
pci_set_cfgdata32(pi, PCIR_BDSM, | |||||||||
gsm->gpa | (bdsm & (PCIM_BDSM_GSM_ALIGNMENT - 1))); | |||||||||
return (set_pcir_handler(sc, PCIR_BDSM, 4, passthru_cfgread_emulate, | |||||||||
passthru_cfgwrite_emulate)); | |||||||||
} | } | ||||||||
int | int | ||||||||
gvt_d_init(struct pci_devinst *const pi, nvlist_t *const nvl __unused) | gvt_d_init(struct pci_devinst *const pi, nvlist_t *const nvl __unused) | ||||||||
{ | { | ||||||||
int error; | int error; | ||||||||
if ((error = gvt_d_setup_gsm(pi)) != 0) { | if ((error = gvt_d_setup_gsm(pi)) != 0) { | ||||||||
Show All 12 Lines |