Skip to content

Commit 87e7d79

Browse files
yliu80wenlingz
authored andcommitted
hv: refine init_pdev function
Due to SRIOV VF physical device needs to be initialized when VF_ENABLE is set and a SRIOV VF physical device initialization is same with standard PCIe physical device, so expose the init_pdev for SRIOV VF physical device initialization. Tracked-On: #4433 Signed-off-by: Yuan Liu <yuan1.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent abbdef4 commit 87e7d79

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

hypervisor/hw/pci.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ static uint32_t num_pci_pdev;
4949
static struct pci_pdev pci_pdev_array[CONFIG_MAX_PCI_DEV_NUM];
5050
static uint64_t pci_mmcfg_base = DEFAULT_PCI_MMCFG_BASE;
5151

52-
static void init_pdev(uint16_t pbdf, uint32_t drhd_index);
53-
5452
#ifdef CONFIG_ACPI_PARSE_ENABLED
5553
void set_mmcfg_base(uint64_t mmcfg_base)
5654
{
@@ -607,11 +605,22 @@ static void pci_read_cap(struct pci_pdev *pdev)
607605
}
608606
}
609607

610-
static void init_pdev(uint16_t pbdf, uint32_t drhd_index)
608+
/*
609+
* @brief Initialize a pdev data structure.
610+
*
611+
* Initialize a pdev data structure with a physical device BDF(pbdf) and DRHD index(drhd_index).
612+
* The caller of the function init_pdev should guarantee execution atomically.
613+
*
614+
* @param pbdf Physical device BDF
615+
* @param drhd_index DRHD index
616+
*
617+
* @return If there's a successfully initialized pdev return it, otherwise return NULL;
618+
*/
619+
struct pci_pdev *init_pdev(uint16_t pbdf, uint32_t drhd_index)
611620
{
612621
uint8_t hdr_type;
613622
union pci_bdf bdf;
614-
struct pci_pdev *pdev;
623+
struct pci_pdev *pdev = NULL;
615624

616625
if (num_pci_pdev < CONFIG_MAX_PCI_DEV_NUM) {
617626
bdf.value = pbdf;
@@ -640,4 +649,6 @@ static void init_pdev(uint16_t pbdf, uint32_t drhd_index)
640649
} else {
641650
pr_err("%s, failed to alloc pci_pdev!\n", __func__);
642651
}
652+
653+
return pdev;
643654
}

hypervisor/include/hw/pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ void set_mmcfg_base(uint64_t mmcfg_base);
301301
#endif
302302
uint64_t get_mmcfg_base(void);
303303

304+
struct pci_pdev *init_pdev(uint16_t pbdf, uint32_t drhd_index);
304305
uint32_t pci_pdev_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes);
305306
void pci_pdev_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes, uint32_t val);
306307
void enable_disable_pci_intx(union pci_bdf bdf, bool enable);

0 commit comments

Comments
 (0)