Skip to content

Commit 9cc1f57

Browse files
ZideChen0lijinxia
authored andcommitted
hv: change function parameters: pci_pdev_read_cfg and pci_pdev_write_cfg
In order to allow these functions to be called without an associated struct pci_pdev (for example, at the time of PCI bus enumeration), these two functions can not take the struct vdev as input parameter. Tracked-On: #1568 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Signed-off-by: Zide Chen <zide.chen@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 19e1b96 commit 9cc1f57

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

hypervisor/dm/hw/pci.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ static uint32_t pci_pdev_calc_address(union pci_bdf bdf, uint32_t offset)
4444
return addr;
4545
}
4646

47-
uint32_t pci_pdev_read_cfg(struct pci_pdev *pdev, uint32_t offset, uint32_t bytes)
47+
uint32_t pci_pdev_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes)
4848
{
4949
uint32_t addr;
5050
uint32_t val;
5151

5252
spinlock_obtain(&pci_device_lock);
5353

54-
addr = pci_pdev_calc_address(pdev->bdf, offset);
54+
addr = pci_pdev_calc_address(bdf, offset);
5555

5656
/* Write address to ADDRESS register */
5757
pio_write32(addr, PCI_CONFIG_ADDR);
@@ -73,14 +73,13 @@ uint32_t pci_pdev_read_cfg(struct pci_pdev *pdev, uint32_t offset, uint32_t byte
7373
return val;
7474
}
7575

76-
void pci_pdev_write_cfg(struct pci_pdev *pdev, uint32_t offset, uint32_t bytes,
77-
uint32_t val)
76+
void pci_pdev_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes, uint32_t val)
7877
{
7978
uint32_t addr;
8079

8180
spinlock_obtain(&pci_device_lock);
8281

83-
addr = pci_pdev_calc_address(pdev->bdf, offset);
82+
addr = pci_pdev_calc_address(bdf, offset);
8483

8584
/* Write address to ADDRESS register */
8685
pio_write32(addr, PCI_CONFIG_ADDR);

hypervisor/dm/vpci/pci_priv.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,5 @@ void pci_vdev_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes,
7373

7474
void pci_vdev_cfg_handler(struct vpci *vpci, uint32_t in, union pci_bdf vbdf, uint32_t offset,
7575
uint32_t bytes, uint32_t *val);
76-
uint32_t pci_pdev_read_cfg(struct pci_pdev *pdev, uint32_t offset, uint32_t bytes);
77-
void pci_pdev_write_cfg(struct pci_pdev *pdev, uint32_t offset, uint32_t bytes, uint32_t val);
7876

7977
#endif /* PCI_PRIV_H_ */

hypervisor/dm/vpci/pci_pt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ static int vdev_pt_init(struct pci_vdev *vdev)
7777
ret = assign_iommu_device(vm->iommu, vdev->pdev.bdf.bits.b,
7878
(uint8_t)(vdev->pdev.bdf.value & 0xFFU));
7979

80-
pci_command = pci_pdev_read_cfg(&vdev->pdev, PCIR_COMMAND, 2U);
80+
pci_command = pci_pdev_read_cfg(vdev->pdev.bdf, PCIR_COMMAND, 2U);
8181
/* Disable INTX */
8282
pci_command |= 0x400U;
83-
pci_pdev_write_cfg(&vdev->pdev, PCIR_COMMAND, 2U, pci_command);
83+
pci_pdev_write_cfg(vdev->pdev.bdf, PCIR_COMMAND, 2U, pci_command);
8484

8585
return ret;
8686
}
@@ -109,7 +109,7 @@ static int vdev_pt_cfgread(struct pci_vdev *vdev, uint32_t offset,
109109
if (pci_bar_access(offset)) {
110110
*val = pci_vdev_read_cfg(vdev, offset, bytes);
111111
} else {
112-
*val = pci_pdev_read_cfg(&vdev->pdev, offset, bytes);
112+
*val = pci_pdev_read_cfg(vdev->pdev.bdf, offset, bytes);
113113
}
114114

115115
return 0;
@@ -188,7 +188,7 @@ static int vdev_pt_cfgwrite(struct pci_vdev *vdev, uint32_t offset,
188188
vdev_pt_cfgwrite_bar(vdev, offset, bytes, val);
189189
} else {
190190
/* Write directly to physical device's config space */
191-
pci_pdev_write_cfg(&vdev->pdev, offset, bytes, val);
191+
pci_pdev_write_cfg(vdev->pdev.bdf, offset, bytes, val);
192192
}
193193

194194
return 0;

hypervisor/include/dm/pci.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,7 @@ static inline bool pci_bar_access(uint32_t offset)
157157
}
158158
}
159159

160+
uint32_t pci_pdev_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes);
161+
void pci_pdev_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes, uint32_t val);
162+
160163
#endif /* PCI_H_ */

0 commit comments

Comments
 (0)