HV: rename vdev_pt_cfgwrite_bar to vdev_pt_write_vbar and some misra-c fix
Rename vdev_pt_cfgwrite_bar to vdev_pt_write_vbar Misra-c violation fix: Add missing else for find_vdev() Fix more than one exit (return) in function vdev_pt_cfgwrite_bar/vdev_pt_write_vbar Tracked-On: #3022 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
aba357dd36
commit
4cdaa519a0
|
@ -203,50 +203,48 @@ static void vdev_pt_remap_generic_bar(const struct pci_vdev *vdev, uint32_t idx,
|
|||
/**
|
||||
* @pre vdev != NULL
|
||||
*/
|
||||
static void vdev_pt_cfgwrite_bar(struct pci_vdev *vdev, uint32_t offset,
|
||||
uint32_t bytes, uint32_t new_bar_uos)
|
||||
static void vdev_pt_write_vbar(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t new_bar_uos)
|
||||
{
|
||||
uint32_t idx;
|
||||
uint32_t new_bar, mask;
|
||||
bool bar_update_normal;
|
||||
bool is_msix_table_bar;
|
||||
|
||||
if ((bytes != 4U) || ((offset & 0x3U) != 0U)) {
|
||||
return;
|
||||
}
|
||||
/* Bar access must be 4 bytes aligned */
|
||||
if ((bytes == 4U) && ((offset & 0x3U) == 0U)) {
|
||||
new_bar = 0U;
|
||||
idx = (offset - pci_bar_offset(0U)) >> 2U;
|
||||
mask = ~(vdev->bar[idx].size - 1U);
|
||||
|
||||
new_bar = 0U;
|
||||
idx = (offset - pci_bar_offset(0U)) >> 2U;
|
||||
mask = ~(vdev->bar[idx].size - 1U);
|
||||
switch (vdev->bar[idx].type) {
|
||||
case PCIBAR_NONE:
|
||||
vdev->bar[idx].base = 0UL;
|
||||
break;
|
||||
|
||||
switch (vdev->bar[idx].type) {
|
||||
case PCIBAR_NONE:
|
||||
vdev->bar[idx].base = 0UL;
|
||||
break;
|
||||
case PCIBAR_MEM32:
|
||||
bar_update_normal = (new_bar_uos != (uint32_t)~0U);
|
||||
is_msix_table_bar = (has_msix_cap(vdev) && (idx == vdev->msix.table_bar));
|
||||
new_bar = new_bar_uos & mask;
|
||||
if (bar_update_normal) {
|
||||
if (is_msix_table_bar) {
|
||||
vdev->bar[idx].base = get_bar_base(new_bar);
|
||||
vdev_pt_remap_msix_table_bar(vdev);
|
||||
} else {
|
||||
vdev_pt_remap_generic_bar(vdev, idx,
|
||||
get_bar_base(new_bar));
|
||||
|
||||
case PCIBAR_MEM32:
|
||||
bar_update_normal = (new_bar_uos != (uint32_t)~0U);
|
||||
is_msix_table_bar = (has_msix_cap(vdev) && (idx == vdev->msix.table_bar));
|
||||
new_bar = new_bar_uos & mask;
|
||||
if (bar_update_normal) {
|
||||
if (is_msix_table_bar) {
|
||||
vdev->bar[idx].base = get_bar_base(new_bar);
|
||||
vdev_pt_remap_msix_table_bar(vdev);
|
||||
} else {
|
||||
vdev_pt_remap_generic_bar(vdev, idx,
|
||||
get_bar_base(new_bar));
|
||||
|
||||
vdev->bar[idx].base = get_bar_base(new_bar);
|
||||
vdev->bar[idx].base = get_bar_base(new_bar);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
pr_err("Unknown bar type, idx=%d", idx);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
pr_err("Unknown bar type, idx=%d", idx);
|
||||
break;
|
||||
pci_vdev_write_cfg_u32(vdev, offset, new_bar);
|
||||
}
|
||||
|
||||
pci_vdev_write_cfg_u32(vdev, offset, new_bar);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +259,7 @@ int32_t vdev_pt_write_cfg(struct pci_vdev *vdev, uint32_t offset,
|
|||
|
||||
/* PCI BARs are emulated */
|
||||
if (is_prelaunched_vm(vdev->vpci->vm) && pci_bar_access(offset)) {
|
||||
vdev_pt_cfgwrite_bar(vdev, offset, bytes, val);
|
||||
vdev_pt_write_vbar(vdev, offset, bytes, val);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -317,12 +317,14 @@ static struct pci_vdev *find_vdev_for_sos(union pci_bdf bdf)
|
|||
*/
|
||||
static struct pci_vdev *find_vdev(const struct acrn_vpci *vpci, union pci_bdf bdf)
|
||||
{
|
||||
struct pci_vdev *vdev = NULL;
|
||||
struct pci_vdev *vdev;
|
||||
|
||||
if (is_prelaunched_vm(vpci->vm)) {
|
||||
vdev = pci_find_vdev_by_vbdf(vpci, bdf);
|
||||
} else if (is_sos_vm(vpci->vm)) {
|
||||
vdev = find_vdev_for_sos(bdf);
|
||||
} else {
|
||||
vdev = NULL;
|
||||
}
|
||||
|
||||
return vdev;
|
||||
|
|
Loading…
Reference in New Issue