pci-bridge: avoid linking a single downstream port more than once
PATCH 1/1 pci-bridge: avoid linking a single downstream port more than once
Since the downstream port is not checked, two slots can be linked to a single port. However, this can prevent the driver from detecting the device properly.
It is necessary to ensure that a downstream port is not linked more than once.
Signed-off-by Yao Xingtao <[email protected]>
--- hw/pci-bridge/cxl_downstream.c | 6 ++++++ hw/pci-bridge/pcie_root_port.c | 6 ++++++ hw/pci-bridge/xio3130_downstream.c | 6 ++++++ 3 files changed, 18 insertions(+)
hw/pci-bridge/cxl_downstream.c +6 -0
@@ -153,6 +153,12 @@ static void cxl_dsp_realize(PCIDevice *d, Error **errp) goto err_bridge; } +if (pcie_find_port_by_pn (pci_get_bus (d), p->port) !=NULL ) { + rc = -EBUSY ; +error_setg (errp,"Can't link port, error %d" , rc); + goto err_msi; + } + rc =pcie_cap_init (d,CXL_DOWNSTREAM_PORT_EXP_OFFSET ,PCI_EXP_TYPE_DOWNSTREAM , p->port, errp);
hw/pci-bridge/pcie_root_port.c +6 -0
@@ -89,6 +89,12 @@ static void rp_realize(PCIDevice *d, Error **errp) } } +if (pcie_find_port_by_pn (pci_get_bus (d), p->port) !=NULL ) { + rc = -EBUSY ; +error_setg (errp,"Can't link port, error %d" , rc); + goto err_int; + } + rc =pcie_cap_init (d, rpc->exp_offset,PCI_EXP_TYPE_ROOT_PORT , p->port, errp);if (rc <0 ) {
hw/pci-bridge/xio3130_downstream.c +6 -0
@@ -88,6 +88,12 @@ static void xio3130_downstream_realize(PCIDevice *d, Error **errp) goto err_msi; } +if (pcie_find_port_by_pn (pci_get_bus (d), p->port) !=NULL ) { + rc = -EBUSY ; +error_setg (errp,"Can't link port, error %d" , rc); + goto err_msi; + } + rc =pcie_cap_init (d,XIO3130_EXP_OFFSET ,PCI_EXP_TYPE_DOWNSTREAM , p->port, errp);if (rc <0 ) {
Signature · 1 line
2.37.3