mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-20 16:28:10 +00:00
HV: remove redundant function calling
The caller function has already done the checking to make sure the req is targeted for the called functions, so there is no need to do the same checking in called functions. Remove calling of is_bar_offset() in vdev_pt_read_cfg/vdev_pt_write_cfg: In vpci.c's vpci_read_pt_dev_cfg and vpci_write_dev_cfg, vbar_access is called first to make sure the req is targed for vdev pt (vbar emulation) before dispatching the request to vdev_pt_read_cfg/vdev_pt_write_cfg, so there is no need to call is_bar_offset() again to do the same checking in vdev_pt_read_cfg/vdev_pt_write_cfg. The same goes for msicap_access/msixcap_access vbar_access should only check if the req is for bar access, it should not care about whether the bar access is 4 bytes or 4 bytes aligned. The called function vdev_pt_write_vbar will check and ignore the write access if it is not 4 bytes or 4 bytes aligned, although this is counted as a bar access. vdev_pt_read_vbar will check if the read access is 4 bytes or 4 bytes aligned, although this is counted as a bar access, set read value (*val) to -1 if the access is not 4 bytes (or aligned). Tracked-On: #3475 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -168,51 +168,43 @@ static int32_t vmsix_remap_one_entry(const struct pci_vdev *vdev, uint32_t index
|
||||
*/
|
||||
int32_t vmsix_read_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val)
|
||||
{
|
||||
int32_t ret = -ENODEV;
|
||||
/* For PIO access, we emulate Capability Structures only */
|
||||
*val = pci_vdev_read_cfg(vdev, offset, bytes);
|
||||
|
||||
if (msixcap_access(vdev, offset)) {
|
||||
*val = pci_vdev_read_cfg(vdev, offset, bytes);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writing MSI-X Capability Structure
|
||||
*
|
||||
* @pre vdev != NULL
|
||||
* @pre vdev->pdev != NULL
|
||||
*/
|
||||
int32_t vmsix_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val)
|
||||
{
|
||||
uint32_t msgctrl;
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
/* Writing MSI-X Capability Structure */
|
||||
if (msixcap_access(vdev, offset)) {
|
||||
msgctrl = pci_vdev_read_cfg(vdev, vdev->msix.capoff + PCIR_MSIX_CTRL, 2U);
|
||||
msgctrl = pci_vdev_read_cfg(vdev, vdev->msix.capoff + PCIR_MSIX_CTRL, 2U);
|
||||
|
||||
/* Write to vdev */
|
||||
pci_vdev_write_cfg(vdev, offset, bytes, val);
|
||||
/* Write to vdev */
|
||||
pci_vdev_write_cfg(vdev, offset, bytes, val);
|
||||
|
||||
/* Writing Message Control field? */
|
||||
if ((offset - vdev->msix.capoff) == PCIR_MSIX_CTRL) {
|
||||
if (((msgctrl ^ val) & PCIM_MSIXCTRL_MSIX_ENABLE) != 0U) {
|
||||
if ((val & PCIM_MSIXCTRL_MSIX_ENABLE) != 0U) {
|
||||
(void)vmsix_remap(vdev, true);
|
||||
} else {
|
||||
(void)vmsix_remap(vdev, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (((msgctrl ^ val) & PCIM_MSIXCTRL_FUNCTION_MASK) != 0U) {
|
||||
pci_pdev_write_cfg(vdev->pdev->bdf, offset, 2U, val);
|
||||
/* Writing Message Control field? */
|
||||
if ((offset - vdev->msix.capoff) == PCIR_MSIX_CTRL) {
|
||||
if (((msgctrl ^ val) & PCIM_MSIXCTRL_MSIX_ENABLE) != 0U) {
|
||||
if ((val & PCIM_MSIXCTRL_MSIX_ENABLE) != 0U) {
|
||||
(void)vmsix_remap(vdev, true);
|
||||
} else {
|
||||
(void)vmsix_remap(vdev, false);
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
if (((msgctrl ^ val) & PCIM_MSIXCTRL_FUNCTION_MASK) != 0U) {
|
||||
pci_pdev_write_cfg(vdev->pdev->bdf, offset, 2U, val);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user