mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 12:42:54 +00:00
HV: unify the sharing_mode_vpci_deinit and partition_mode_vpci_deinit code
Put the deinit code in deinit_prelaunched_vm_vpci() for both sos and pre-launched VMs, and remove sharing_mode_vpci_deinit() and partition_mode_vpci_deinit(). Rename functions used by deinit(): vhostbridge_deinit --> deinit_vhostbridge vmsi_deinit --> deinit_vmsi vmsix_deinit --> deinit_vmsix post_launched_vm_vpci_deinit --> deinit_post_launched_vm Tracked-On: #3056 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
3a6c63f2d8
commit
19af3bc8aa
@ -92,7 +92,7 @@ void init_vhostbridge(struct pci_vdev *vdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vhostbridge_deinit(__unused const struct pci_vdev *vdev)
|
void deinit_vhostbridge(__unused const struct pci_vdev *vdev)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ int32_t vmsi_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, ui
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vmsi_deinit(const struct pci_vdev *vdev)
|
void deinit_vmsi(const struct pci_vdev *vdev)
|
||||||
{
|
{
|
||||||
if (has_msi_cap(vdev)) {
|
if (has_msi_cap(vdev)) {
|
||||||
ptirq_remove_msix_remapping(vdev->vpci->vm, vdev->vbdf.value, 1U);
|
ptirq_remove_msix_remapping(vdev->vpci->vm, vdev->vbdf.value, 1U);
|
||||||
|
@ -351,7 +351,7 @@ void init_vmsix(struct pci_vdev *vdev)
|
|||||||
* @pre vdev->vpci != NULL
|
* @pre vdev->vpci != NULL
|
||||||
* @pre vdev->vpci->vm != NULL
|
* @pre vdev->vpci->vm != NULL
|
||||||
*/
|
*/
|
||||||
void vmsix_deinit(const struct pci_vdev *vdev)
|
void deinit_vmsix(const struct pci_vdev *vdev)
|
||||||
{
|
{
|
||||||
if (has_msix_cap(vdev)) {
|
if (has_msix_cap(vdev)) {
|
||||||
if (vdev->msix.table_count != 0U) {
|
if (vdev->msix.table_count != 0U) {
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#include "vpci_priv.h"
|
#include "vpci_priv.h"
|
||||||
|
|
||||||
static void init_vdev_for_pdev(struct pci_pdev *pdev, const void *vm);
|
static void init_vdev_for_pdev(struct pci_pdev *pdev, const void *vm);
|
||||||
|
static void deinit_prelaunched_vm_vpci(const struct acrn_vm *vm);
|
||||||
|
static void deinit_postlaunched_vm_vpci(const struct acrn_vm *vm);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -245,15 +247,13 @@ void vpci_cleanup(const struct acrn_vm *vm)
|
|||||||
vm_config = get_vm_config(vm->vm_id);
|
vm_config = get_vm_config(vm->vm_id);
|
||||||
switch (vm_config->load_order) {
|
switch (vm_config->load_order) {
|
||||||
case PRE_LAUNCHED_VM:
|
case PRE_LAUNCHED_VM:
|
||||||
partition_mode_vpci_deinit(vm);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SOS_VM:
|
case SOS_VM:
|
||||||
sharing_mode_vpci_deinit(vm);
|
/* deinit function for both SOS and pre-launched VMs (consider sos also as pre-launched) */
|
||||||
|
deinit_prelaunched_vm_vpci(vm);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case POST_LAUNCHED_VM:
|
case POST_LAUNCHED_VM:
|
||||||
post_launched_vm_vpci_deinit(vm);
|
deinit_postlaunched_vm_vpci(vm);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -305,30 +305,6 @@ static void remove_vdev_pt_iommu_domain(const struct pci_vdev *vdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @pre vm != NULL
|
|
||||||
* @pre vm->vpci.pci_vdev_cnt <= CONFIG_MAX_PCI_DEV_NUM
|
|
||||||
*/
|
|
||||||
void partition_mode_vpci_deinit(const struct acrn_vm *vm)
|
|
||||||
{
|
|
||||||
struct pci_vdev *vdev;
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
for (i = 0U; i < vm->vpci.pci_vdev_cnt; i++) {
|
|
||||||
vdev = (struct pci_vdev *) &(vm->vpci.pci_vdevs[i]);
|
|
||||||
|
|
||||||
if (is_hostbridge(vdev)) {
|
|
||||||
vhostbridge_deinit(vdev);
|
|
||||||
} else {
|
|
||||||
remove_vdev_pt_iommu_domain(vdev);
|
|
||||||
|
|
||||||
vmsi_deinit(vdev);
|
|
||||||
|
|
||||||
vmsix_deinit(vdev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pre vpci != NULL
|
* @pre vpci != NULL
|
||||||
*/
|
*/
|
||||||
@ -499,21 +475,23 @@ static void init_vdev_for_pdev(struct pci_pdev *pdev, const void *vm)
|
|||||||
/**
|
/**
|
||||||
* @pre vm != NULL
|
* @pre vm != NULL
|
||||||
* @pre vm->vpci.pci_vdev_cnt <= CONFIG_MAX_PCI_DEV_NUM
|
* @pre vm->vpci.pci_vdev_cnt <= CONFIG_MAX_PCI_DEV_NUM
|
||||||
* @pre is_sos_vm(vm) == true
|
* @pre is_sos_vm(vm) || is_prelaunched_vm(vm)
|
||||||
*/
|
*/
|
||||||
void sharing_mode_vpci_deinit(const struct acrn_vm *vm)
|
static void deinit_prelaunched_vm_vpci(const struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
struct pci_vdev *vdev;
|
struct pci_vdev *vdev;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0U; i < vm->vpci.pci_vdev_cnt; i++) {
|
for (i = 0U; i < vm->vpci.pci_vdev_cnt; i++) {
|
||||||
vdev = (struct pci_vdev *)&(vm->vpci.pci_vdevs[i]);
|
vdev = (struct pci_vdev *) &(vm->vpci.pci_vdevs[i]);
|
||||||
|
|
||||||
|
deinit_vhostbridge(vdev);
|
||||||
|
deinit_vmsi(vdev);
|
||||||
|
deinit_vmsix(vdev);
|
||||||
|
|
||||||
|
if ((is_prelaunched_vm(vm) && !is_hostbridge(vdev)) || is_sos_vm(vm)) {
|
||||||
remove_vdev_pt_iommu_domain(vdev);
|
remove_vdev_pt_iommu_domain(vdev);
|
||||||
|
}
|
||||||
vmsi_deinit(vdev);
|
|
||||||
|
|
||||||
vmsix_deinit(vdev);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,7 +500,7 @@ void sharing_mode_vpci_deinit(const struct acrn_vm *vm)
|
|||||||
* @pre vm->vpci.pci_vdev_cnt <= CONFIG_MAX_PCI_DEV_NUM
|
* @pre vm->vpci.pci_vdev_cnt <= CONFIG_MAX_PCI_DEV_NUM
|
||||||
* @pre is_postlaunched_vm(vm) == true
|
* @pre is_postlaunched_vm(vm) == true
|
||||||
*/
|
*/
|
||||||
void post_launched_vm_vpci_deinit(const struct acrn_vm *vm)
|
static void deinit_postlaunched_vm_vpci(const struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
struct acrn_vm *sos_vm;
|
struct acrn_vm *sos_vm;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
@ -551,12 +529,13 @@ void post_launched_vm_vpci_deinit(const struct acrn_vm *vm)
|
|||||||
panic("failed to assign iommu device!");
|
panic("failed to assign iommu device!");
|
||||||
}
|
}
|
||||||
|
|
||||||
vmsi_deinit(vdev);
|
deinit_vmsi(vdev);
|
||||||
|
|
||||||
vmsix_deinit(vdev);
|
deinit_vmsix(vdev);
|
||||||
|
|
||||||
/* Move vdev pointers back to SOS*/
|
/* Move vdev pointers back to SOS*/
|
||||||
vdev->vpci = (struct acrn_vpci *) &sos_vm->vpci;
|
vdev->vpci = (struct acrn_vpci *) &sos_vm->vpci;
|
||||||
|
|
||||||
/* vbdf equals to pbdf in sos */
|
/* vbdf equals to pbdf in sos */
|
||||||
vdev->vbdf.value = vdev->pdev->bdf.value;
|
vdev->vbdf.value = vdev->pdev->bdf.value;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ static inline bool is_hostbridge(const struct pci_vdev *vdev)
|
|||||||
void init_vhostbridge(struct pci_vdev *vdev);
|
void init_vhostbridge(struct pci_vdev *vdev);
|
||||||
int32_t vhostbridge_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
int32_t vhostbridge_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
||||||
int32_t vhostbridge_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
int32_t vhostbridge_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
||||||
void vhostbridge_deinit(__unused const struct pci_vdev *vdev);
|
void deinit_vhostbridge(__unused const struct pci_vdev *vdev);
|
||||||
|
|
||||||
void init_vdev_pt(struct pci_vdev *vdev);
|
void init_vdev_pt(struct pci_vdev *vdev);
|
||||||
int32_t vdev_pt_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
int32_t vdev_pt_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
||||||
@ -95,14 +95,14 @@ int32_t vdev_pt_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes,
|
|||||||
void init_vmsi(struct pci_vdev *vdev);
|
void init_vmsi(struct pci_vdev *vdev);
|
||||||
int32_t vmsi_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
int32_t vmsi_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
||||||
int32_t vmsi_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
int32_t vmsi_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
||||||
void vmsi_deinit(const struct pci_vdev *vdev);
|
void deinit_vmsi(const struct pci_vdev *vdev);
|
||||||
|
|
||||||
void init_vmsix(struct pci_vdev *vdev);
|
void init_vmsix(struct pci_vdev *vdev);
|
||||||
void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev);
|
void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev);
|
||||||
int32_t vmsix_table_mmio_access_handler(struct io_request *io_req, void *handler_private_data);
|
int32_t vmsix_table_mmio_access_handler(struct io_request *io_req, void *handler_private_data);
|
||||||
int32_t vmsix_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
int32_t vmsix_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
||||||
int32_t vmsix_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
int32_t vmsix_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
||||||
void vmsix_deinit(const struct pci_vdev *vdev);
|
void deinit_vmsix(const struct pci_vdev *vdev);
|
||||||
|
|
||||||
uint32_t pci_vdev_read_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes);
|
uint32_t pci_vdev_read_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes);
|
||||||
void pci_vdev_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
void pci_vdev_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
||||||
@ -115,13 +115,10 @@ void partition_mode_cfgread(const struct acrn_vpci *vpci, union pci_bdf vbdf,
|
|||||||
uint32_t offset, uint32_t bytes, uint32_t *val);
|
uint32_t offset, uint32_t bytes, uint32_t *val);
|
||||||
void partition_mode_cfgwrite(const struct acrn_vpci *vpci, union pci_bdf vbdf,
|
void partition_mode_cfgwrite(const struct acrn_vpci *vpci, union pci_bdf vbdf,
|
||||||
uint32_t offset, uint32_t bytes, uint32_t val);
|
uint32_t offset, uint32_t bytes, uint32_t val);
|
||||||
void partition_mode_vpci_deinit(const struct acrn_vm *vm);
|
|
||||||
|
|
||||||
void sharing_mode_cfgread(struct acrn_vpci *vpci, union pci_bdf bdf,
|
void sharing_mode_cfgread(struct acrn_vpci *vpci, union pci_bdf bdf,
|
||||||
uint32_t offset, uint32_t bytes, uint32_t *val);
|
uint32_t offset, uint32_t bytes, uint32_t *val);
|
||||||
void sharing_mode_cfgwrite(__unused struct acrn_vpci *vpci, union pci_bdf bdf,
|
void sharing_mode_cfgwrite(__unused struct acrn_vpci *vpci, union pci_bdf bdf,
|
||||||
uint32_t offset, uint32_t bytes, uint32_t val);
|
uint32_t offset, uint32_t bytes, uint32_t val);
|
||||||
void sharing_mode_vpci_deinit(const struct acrn_vm *vm);
|
|
||||||
void post_launched_vm_vpci_deinit(const struct acrn_vm *vm);
|
|
||||||
|
|
||||||
#endif /* VPCI_PRIV_H_ */
|
#endif /* VPCI_PRIV_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user