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:
@@ -131,14 +131,14 @@ static uint64_t get_pbar_base(const struct pci_pdev *pdev, uint32_t idx)
|
||||
*/
|
||||
int32_t vdev_pt_read_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val)
|
||||
{
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
if (is_bar_offset(vdev->nr_bars, offset)) {
|
||||
/* bar access must be 4 bytes and offset must also be 4 bytes aligned */
|
||||
if ((bytes == 4U) && ((offset & 0x3U) == 0U)) {
|
||||
*val = pci_vdev_read_cfg(vdev, offset, bytes);
|
||||
ret = 0;
|
||||
} else {
|
||||
*val = ~0U;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,15 +442,12 @@ static void vdev_pt_write_vbar(struct pci_vdev *vdev, uint32_t offset, uint32_t
|
||||
*/
|
||||
int32_t vdev_pt_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val)
|
||||
{
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
/* bar write access must be 4 bytes and offset must also be 4 bytes aligned*/
|
||||
if (is_bar_offset(vdev->nr_bars, offset) && (bytes == 4U) && ((offset & 0x3U) == 0U)) {
|
||||
/* bar write access must be 4 bytes and offset must also be 4 bytes aligned */
|
||||
if ((bytes == 4U) && ((offset & 0x3U) == 0U)) {
|
||||
vdev_pt_write_vbar(vdev, offset, val);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user