Skip to content

Commit f873b84

Browse files
donshengacrnsi
authored andcommitted
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>
1 parent cf48b9c commit f873b84

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

hypervisor/dm/vpci/pci_pt.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <logmsg.h>
3737
#include "vpci_priv.h"
3838

39-
static inline uint32_t pci_bar_base(uint32_t bar)
39+
static inline uint32_t get_bar_base(uint32_t bar)
4040
{
4141
return bar & PCIM_BAR_MEM_BASE;
4242
}
@@ -60,6 +60,8 @@ int32_t vdev_pt_cfgread(const struct pci_vdev *vdev, uint32_t offset,
6060

6161
/**
6262
* @pre vdev != NULL
63+
* @pre vdev->vpci != NULL
64+
* @pre vdev->vpci->vm != NULL
6365
* @pre vdev->pdev != NULL
6466
* @pre vdev->pdev->msix.table_bar < (PCI_BAR_COUNT - 1U)
6567
*/
@@ -75,7 +77,7 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
7577

7678
vm_config = get_vm_config(vm->vm_id);
7779

78-
ASSERT(vdev->pdev->msix.table_bar < (PCI_BAR_COUNT - 1U), "msix->table_bar out of range");
80+
ASSERT(vdev->pdev->msix.table_bar < (PCI_BAR_COUNT - 1U), "msix->table_bar is out of range");
7981

8082

8183
/* Mask all table entries */
@@ -87,21 +89,21 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
8789

8890
bar = &pdev->bar[msix->table_bar];
8991
if (bar != NULL) {
90-
vdev->msix.mmio_hpa = bar->base;
92+
msix->mmio_hpa = bar->base;
9193
if (vm_config->load_order == PRE_LAUNCHED_VM) {
92-
vdev->msix.mmio_gpa = vdev->bar[msix->table_bar].base;
94+
msix->mmio_gpa = vdev->bar[msix->table_bar].base;
9395
} else {
94-
vdev->msix.mmio_gpa = sos_vm_hpa2gpa(bar->base);
96+
msix->mmio_gpa = sos_vm_hpa2gpa(bar->base);
9597
}
96-
vdev->msix.mmio_size = bar->size;
98+
msix->mmio_size = bar->size;
9799
}
98100

99101

100102
/*
101103
* For SOS:
102104
* --------
103105
* MSI-X Table BAR Contains:
104-
* Other Info + Tables + PBA Ohter info already mapped into EPT (since SOS)
106+
* Other Info + Tables + PBA Other info already mapped into EPT (since SOS)
105107
* Tables are handled by HV MMIO handler (4k adjusted up and down)
106108
* and remaps interrupts
107109
* PBA already mapped into EPT (since SOS)
@@ -138,10 +140,10 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
138140
*/
139141

140142

141-
if (msix->mmio_gpa != 0U) {
143+
if (msix->mmio_gpa != 0UL) {
142144
if (vm_config->load_order == PRE_LAUNCHED_VM) {
143-
addr_hi = vdev->msix.mmio_gpa + vdev->msix.mmio_size;
144-
addr_lo = vdev->msix.mmio_gpa;
145+
addr_hi = msix->mmio_gpa + msix->mmio_size;
146+
addr_lo = msix->mmio_gpa;
145147
} else {
146148
/*
147149
* 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,
226228
new_bar = new_bar_uos & mask;
227229
if (bar_update_normal) {
228230
if (is_msix_table_bar) {
229-
vdev->bar[idx].base = pci_bar_base(new_bar);
231+
vdev->bar[idx].base = get_bar_base(new_bar);
230232
vdev_pt_remap_msix_table_bar(vdev);
231233
} else {
232234
vdev_pt_remap_generic_bar(vdev, idx,
233-
pci_bar_base(new_bar));
235+
get_bar_base(new_bar));
234236

235-
vdev->bar[idx].base = pci_bar_base(new_bar);
237+
vdev->bar[idx].base = get_bar_base(new_bar);
236238
}
237239
}
238240
break;

0 commit comments

Comments
 (0)