mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-26 07:21:37 +00:00
hv: vpci: fix "Procedure has more than one exit point"
IEC 61508,ISO 26262 standards highly recommend single-exit rule. Tracked-On: #861 Signed-off-by: Zide Chen <zide.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
c547e9cfb4
commit
3515ca1e65
@ -118,6 +118,7 @@ static int32_t vmsi_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t by
|
||||
bool message_changed = false;
|
||||
bool enable;
|
||||
uint32_t msgctrl;
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
/* Writing MSI Capability Structure */
|
||||
if (msicap_access(vdev, offset)) {
|
||||
@ -144,10 +145,10 @@ static int32_t vmsi_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t by
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void populate_msi_struct(struct pci_vdev *vdev)
|
||||
@ -158,10 +159,7 @@ void populate_msi_struct(struct pci_vdev *vdev)
|
||||
union pci_bdf pbdf = vdev->pdev.bdf;
|
||||
|
||||
/* Has new Capabilities list? */
|
||||
if ((pci_pdev_read_cfg(pbdf, PCIR_STATUS, 2U) & PCIM_STATUS_CAPPRESENT) == 0U) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pci_pdev_read_cfg(pbdf, PCIR_STATUS, 2U) & PCIM_STATUS_CAPPRESENT) != 0U) {
|
||||
ptr = (uint8_t)pci_pdev_read_cfg(pbdf, PCIR_CAP_PTR, 1U);
|
||||
while ((ptr != 0U) && (ptr != 0xFFU)) {
|
||||
cap = (uint8_t)pci_pdev_read_cfg(pbdf, ptr + PCICAP_ID, 1U);
|
||||
@ -216,6 +214,7 @@ void populate_msi_struct(struct pci_vdev *vdev)
|
||||
ptr = (uint8_t)pci_pdev_read_cfg(pbdf, ptr + PCICAP_NEXTPTR, 1U);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t vmsi_deinit(struct pci_vdev *vdev)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ static inline void enable_disable_msix(struct pci_vdev *vdev, bool enable)
|
||||
static int32_t vmsix_remap(struct pci_vdev *vdev, bool enable)
|
||||
{
|
||||
uint32_t index;
|
||||
int32_t ret;
|
||||
int32_t ret = 0;
|
||||
|
||||
/* disable MSI-X during configuration */
|
||||
enable_disable_msix(vdev, false);
|
||||
@ -107,17 +107,19 @@ static int32_t vmsix_remap(struct pci_vdev *vdev, bool enable)
|
||||
for (index = 0U; index < vdev->msix.table_count; index++) {
|
||||
ret = vmsix_remap_entry(vdev, index, enable);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If MSI Enable is being set, make sure INTxDIS bit is set */
|
||||
if (ret == 0) {
|
||||
if (enable) {
|
||||
enable_disable_pci_intx(vdev->pdev.bdf, false);
|
||||
}
|
||||
enable_disable_msix(vdev, enable);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Do MSI-X remap for one MSI-X table entry only */
|
||||
@ -263,6 +265,7 @@ static int32_t vmsix_table_mmio_access_handler(struct io_request *io_req, void *
|
||||
{
|
||||
struct mmio_request *mmio = &io_req->reqs.mmio;
|
||||
struct pci_vdev *vdev;
|
||||
int32_t ret = 0;
|
||||
uint64_t offset;
|
||||
uint64_t hva;
|
||||
|
||||
@ -277,9 +280,8 @@ static int32_t vmsix_table_mmio_access_handler(struct io_request *io_req, void *
|
||||
/* Only DWORD and QWORD are permitted */
|
||||
if ((mmio->size != 4U) && (mmio->size != 8U)) {
|
||||
pr_err("%s, Only DWORD and QWORD are permitted", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
stac();
|
||||
/* MSI-X PBA and Capability Table could be in the same range */
|
||||
if (mmio->direction == REQUEST_READ) {
|
||||
@ -299,8 +301,9 @@ static int32_t vmsix_table_mmio_access_handler(struct io_request *io_req, void *
|
||||
}
|
||||
clac();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void decode_msix_table_bar(struct pci_vdev *vdev)
|
||||
|
@ -35,16 +35,17 @@ static struct pci_vdev sharing_mode_vdev_array[CONFIG_MAX_PCI_DEV_NUM];
|
||||
|
||||
struct pci_vdev *sharing_mode_find_vdev(union pci_bdf pbdf)
|
||||
{
|
||||
struct pci_vdev *vdev = NULL;
|
||||
uint32_t i;
|
||||
|
||||
/* in VM0, it uses phys BDF */
|
||||
for (i = 0U; i < num_pci_vdev; i++) {
|
||||
if (sharing_mode_vdev_array[i].pdev.bdf.value == pbdf.value) {
|
||||
return &sharing_mode_vdev_array[i];
|
||||
vdev = &sharing_mode_vdev_array[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return vdev;
|
||||
}
|
||||
|
||||
static void sharing_mode_cfgread(__unused struct acrn_vpci *vpci, union pci_bdf bdf,
|
||||
|
Loading…
Reference in New Issue
Block a user