mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 20:22:46 +00:00
HV: cosmetix fix for pci_pt.c
Use local variable msix instead of vdev->msix, vdev_pt_remap_msix_table_bar has already defined a local variable msix (&vdev->msix), use msix instead of vdev->msix to simplify the code. Fix @pre for functions Rename pci_bar_base to get_bar_base Fix typo in comment Tracked-On: #3056 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
cf48b9c38f
commit
f873b843de
@ -36,7 +36,7 @@
|
|||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
#include "vpci_priv.h"
|
#include "vpci_priv.h"
|
||||||
|
|
||||||
static inline uint32_t pci_bar_base(uint32_t bar)
|
static inline uint32_t get_bar_base(uint32_t bar)
|
||||||
{
|
{
|
||||||
return bar & PCIM_BAR_MEM_BASE;
|
return bar & PCIM_BAR_MEM_BASE;
|
||||||
}
|
}
|
||||||
@ -60,6 +60,8 @@ int32_t vdev_pt_cfgread(const struct pci_vdev *vdev, uint32_t offset,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @pre vdev != NULL
|
* @pre vdev != NULL
|
||||||
|
* @pre vdev->vpci != NULL
|
||||||
|
* @pre vdev->vpci->vm != NULL
|
||||||
* @pre vdev->pdev != NULL
|
* @pre vdev->pdev != NULL
|
||||||
* @pre vdev->pdev->msix.table_bar < (PCI_BAR_COUNT - 1U)
|
* @pre vdev->pdev->msix.table_bar < (PCI_BAR_COUNT - 1U)
|
||||||
*/
|
*/
|
||||||
@ -75,7 +77,7 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
|
|||||||
|
|
||||||
vm_config = get_vm_config(vm->vm_id);
|
vm_config = get_vm_config(vm->vm_id);
|
||||||
|
|
||||||
ASSERT(vdev->pdev->msix.table_bar < (PCI_BAR_COUNT - 1U), "msix->table_bar out of range");
|
ASSERT(vdev->pdev->msix.table_bar < (PCI_BAR_COUNT - 1U), "msix->table_bar is out of range");
|
||||||
|
|
||||||
|
|
||||||
/* Mask all table entries */
|
/* Mask all table entries */
|
||||||
@ -87,13 +89,13 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
|
|||||||
|
|
||||||
bar = &pdev->bar[msix->table_bar];
|
bar = &pdev->bar[msix->table_bar];
|
||||||
if (bar != NULL) {
|
if (bar != NULL) {
|
||||||
vdev->msix.mmio_hpa = bar->base;
|
msix->mmio_hpa = bar->base;
|
||||||
if (vm_config->load_order == PRE_LAUNCHED_VM) {
|
if (vm_config->load_order == PRE_LAUNCHED_VM) {
|
||||||
vdev->msix.mmio_gpa = vdev->bar[msix->table_bar].base;
|
msix->mmio_gpa = vdev->bar[msix->table_bar].base;
|
||||||
} else {
|
} else {
|
||||||
vdev->msix.mmio_gpa = sos_vm_hpa2gpa(bar->base);
|
msix->mmio_gpa = sos_vm_hpa2gpa(bar->base);
|
||||||
}
|
}
|
||||||
vdev->msix.mmio_size = bar->size;
|
msix->mmio_size = bar->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,7 +103,7 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
|
|||||||
* For SOS:
|
* For SOS:
|
||||||
* --------
|
* --------
|
||||||
* MSI-X Table BAR Contains:
|
* MSI-X Table BAR Contains:
|
||||||
* Other Info + Tables + PBA Ohter info already mapped into EPT (since SOS)
|
* Other Info + Tables + PBA Other info already mapped into EPT (since SOS)
|
||||||
* Tables are handled by HV MMIO handler (4k adjusted up and down)
|
* Tables are handled by HV MMIO handler (4k adjusted up and down)
|
||||||
* and remaps interrupts
|
* and remaps interrupts
|
||||||
* PBA already mapped into EPT (since SOS)
|
* PBA already mapped into EPT (since SOS)
|
||||||
@ -138,10 +140,10 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (msix->mmio_gpa != 0U) {
|
if (msix->mmio_gpa != 0UL) {
|
||||||
if (vm_config->load_order == PRE_LAUNCHED_VM) {
|
if (vm_config->load_order == PRE_LAUNCHED_VM) {
|
||||||
addr_hi = vdev->msix.mmio_gpa + vdev->msix.mmio_size;
|
addr_hi = msix->mmio_gpa + msix->mmio_size;
|
||||||
addr_lo = vdev->msix.mmio_gpa;
|
addr_lo = msix->mmio_gpa;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* PCI Spec: a BAR may also map other usable address space that is not associated
|
* PCI Spec: a BAR may also map other usable address space that is not associated
|
||||||
@ -226,13 +228,13 @@ static void vdev_pt_cfgwrite_bar(struct pci_vdev *vdev, uint32_t offset,
|
|||||||
new_bar = new_bar_uos & mask;
|
new_bar = new_bar_uos & mask;
|
||||||
if (bar_update_normal) {
|
if (bar_update_normal) {
|
||||||
if (is_msix_table_bar) {
|
if (is_msix_table_bar) {
|
||||||
vdev->bar[idx].base = pci_bar_base(new_bar);
|
vdev->bar[idx].base = get_bar_base(new_bar);
|
||||||
vdev_pt_remap_msix_table_bar(vdev);
|
vdev_pt_remap_msix_table_bar(vdev);
|
||||||
} else {
|
} else {
|
||||||
vdev_pt_remap_generic_bar(vdev, idx,
|
vdev_pt_remap_generic_bar(vdev, idx,
|
||||||
pci_bar_base(new_bar));
|
get_bar_base(new_bar));
|
||||||
|
|
||||||
vdev->bar[idx].base = pci_bar_base(new_bar);
|
vdev->bar[idx].base = get_bar_base(new_bar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user