mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-27 15:56:54 +00:00
HV: unify the sharing mode and partition mode coding style for similar functions
Both sharing mode and partition mode should follow the same coding logic/style for similar functions: vdev cfgread/cfgwrite: should all return -ENODEV if the pci reg access is not handled by it, but previously the partition mode code is not following this logic vpci cfgread/cfgwrite: if the vdev cfgread/cfgwrite does not handle this reg, pass on to next vdev cfgread/cfgwrite, if no vdev handles that req, passthru to physical pci device Tracked-On: #2534 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
026250fd8a
commit
71ce4c255e
@ -117,14 +117,12 @@ static int32_t vmsi_remap(const struct pci_vdev *vdev, bool enable)
|
||||
|
||||
int32_t vmsi_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val)
|
||||
{
|
||||
int32_t ret;
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
/* For PIO access, we emulate Capability Structures only */
|
||||
if (msicap_access(vdev, offset)) {
|
||||
*val = pci_vdev_read_cfg(vdev, offset, bytes);
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = -ENODEV;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -167,14 +167,12 @@ static int32_t vmsix_remap_one_entry(const struct pci_vdev *vdev, uint32_t index
|
||||
|
||||
int32_t vmsix_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val)
|
||||
{
|
||||
int32_t ret;
|
||||
int32_t ret = -ENODEV;
|
||||
/* For PIO access, we emulate Capability Structures only */
|
||||
|
||||
if (msixcap_access(vdev, offset)) {
|
||||
*val = pci_vdev_read_cfg(vdev, offset, bytes);
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = -ENODEV;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -183,7 +181,7 @@ int32_t vmsix_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t byt
|
||||
int32_t vmsix_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val)
|
||||
{
|
||||
uint32_t msgctrl;
|
||||
int32_t ret;
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
/* Writing MSI-X Capability Structure */
|
||||
if (msixcap_access(vdev, offset)) {
|
||||
@ -207,8 +205,6 @@ int32_t vmsix_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, u
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = -ENODEV;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -149,7 +149,8 @@ void partition_mode_cfgread(struct acrn_vpci *vpci, union pci_bdf vbdf,
|
||||
}
|
||||
} else {
|
||||
if (vdev_pt_cfgread(vdev, offset, bytes, val) != 0) {
|
||||
pr_err("vdev_pt_cfgread failed!");
|
||||
/* Not handled by any handlers, passthru to physical device */
|
||||
*val = pci_pdev_read_cfg(vdev->pdev->bdf, offset, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,7 +168,8 @@ void partition_mode_cfgwrite(struct acrn_vpci *vpci, union pci_bdf vbdf,
|
||||
}
|
||||
} else {
|
||||
if (vdev_pt_cfgwrite(vdev, offset, bytes, val) != 0){
|
||||
pr_err("vdev_pt_cfgwrite failed!");
|
||||
/* Not handled by any handlers, passthru to physical device */
|
||||
pci_pdev_write_cfg(vdev->pdev->bdf, offset, bytes, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,14 +105,15 @@ void vdev_pt_deinit(const 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 ret = -ENODEV;
|
||||
|
||||
/* PCI BARs is emulated */
|
||||
if (pci_bar_access(offset)) {
|
||||
*val = pci_vdev_read_cfg(vdev, offset, bytes);
|
||||
} else {
|
||||
*val = pci_pdev_read_cfg(vdev->pdev->bdf, offset, bytes);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void vdev_pt_remap_bar(struct pci_vdev *vdev, uint32_t idx,
|
||||
@ -178,14 +179,14 @@ static void vdev_pt_cfgwrite_bar(struct pci_vdev *vdev, uint32_t offset,
|
||||
int32_t vdev_pt_cfgwrite(struct pci_vdev *vdev, uint32_t offset,
|
||||
uint32_t bytes, uint32_t val)
|
||||
{
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
/* PCI BARs are emulated */
|
||||
if (pci_bar_access(offset)) {
|
||||
vdev_pt_cfgwrite_bar(vdev, offset, bytes, val);
|
||||
} else {
|
||||
/* Write directly to physical device's config space */
|
||||
pci_pdev_write_cfg(vdev->pdev->bdf, offset, bytes, val);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -45,14 +45,12 @@ static struct pci_vdev *sharing_mode_find_vdev_sos(union pci_bdf pbdf)
|
||||
void sharing_mode_cfgread(__unused struct acrn_vpci *vpci, union pci_bdf bdf,
|
||||
uint32_t offset, uint32_t bytes, uint32_t *val)
|
||||
{
|
||||
struct pci_vdev *vdev;
|
||||
struct pci_vdev *vdev = sharing_mode_find_vdev_sos(bdf);
|
||||
|
||||
vdev = sharing_mode_find_vdev_sos(bdf);
|
||||
*val = ~0U;
|
||||
|
||||
/* vdev == NULL: Could be hit for PCI enumeration from guests */
|
||||
if (vdev == NULL) {
|
||||
*val = ~0U;
|
||||
} else {
|
||||
if (vdev != NULL) {
|
||||
if ((vmsi_cfgread(vdev, offset, bytes, val) != 0)
|
||||
&& (vmsix_cfgread(vdev, offset, bytes, val) != 0)
|
||||
) {
|
||||
@ -65,9 +63,8 @@ void sharing_mode_cfgread(__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)
|
||||
{
|
||||
struct pci_vdev *vdev;
|
||||
struct pci_vdev *vdev = sharing_mode_find_vdev_sos(bdf);
|
||||
|
||||
vdev = sharing_mode_find_vdev_sos(bdf);
|
||||
if (vdev != NULL) {
|
||||
if ((vmsi_cfgwrite(vdev, offset, bytes, val) != 0)
|
||||
&& (vmsix_cfgwrite(vdev, offset, bytes, val) != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user