mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
hw/pci-host/designware: Prevent device attachment on internal PCIe root bus
On the real device, the PCIe root bus is only connected to a PCIe bridge and does not allow for direct attachment of devices. Doing so in QEMU results in no PCI devices being detected by Linux. Instead, PCI devices should plug into the secondary PCIe bus spawned by the internal PCIe bridge. Unfortunately, QEMU defaults to plugging devices into the PCIe root bus. To work around this, every PCI device created on the command line needs an extra `bus=dw-pcie` option which is error prone. Fix that by marking the PCIe root bus as full which makes QEMU decend into the child PCIe bus. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Bernhard Beschow <shentey@gmail.com> Message-id: 20250223114708.1780-3-shentey@gmail.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
b513766ee9
commit
faa2150a52
2 changed files with 24 additions and 1 deletions
|
@ -55,6 +55,17 @@
|
|||
#define DESIGNWARE_PCIE_ATU_DEVFN(x) (((x) >> 16) & 0xff)
|
||||
#define DESIGNWARE_PCIE_ATU_UPPER_TARGET 0x91C
|
||||
|
||||
static void designware_pcie_root_bus_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
BusClass *k = BUS_CLASS(klass);
|
||||
|
||||
/*
|
||||
* Designware has only a single root complex. Enforce the limit on the
|
||||
* parent bus
|
||||
*/
|
||||
k->max_dev = 1;
|
||||
}
|
||||
|
||||
static DesignwarePCIEHost *
|
||||
designware_pcie_root_to_host(DesignwarePCIERoot *root)
|
||||
{
|
||||
|
@ -699,7 +710,7 @@ static void designware_pcie_host_realize(DeviceState *dev, Error **errp)
|
|||
&s->pci.memory,
|
||||
&s->pci.io,
|
||||
0, 4,
|
||||
TYPE_PCIE_BUS);
|
||||
TYPE_DESIGNWARE_PCIE_ROOT_BUS);
|
||||
pci->bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
|
||||
|
||||
memory_region_init(&s->pci.address_space_root,
|
||||
|
@ -754,6 +765,11 @@ static void designware_pcie_host_init(Object *obj)
|
|||
|
||||
static const TypeInfo designware_pcie_types[] = {
|
||||
{
|
||||
.name = TYPE_DESIGNWARE_PCIE_ROOT_BUS,
|
||||
.parent = TYPE_PCIE_BUS,
|
||||
.instance_size = sizeof(DesignwarePCIERootBus),
|
||||
.class_init = designware_pcie_root_bus_class_init,
|
||||
}, {
|
||||
.name = TYPE_DESIGNWARE_PCIE_HOST,
|
||||
.parent = TYPE_PCI_HOST_BRIDGE,
|
||||
.instance_size = sizeof(DesignwarePCIEHost),
|
||||
|
|
|
@ -25,12 +25,19 @@
|
|||
#include "hw/pci/pci_bridge.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_DESIGNWARE_PCIE_ROOT_BUS "designware-pcie-root-BUS"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIERootBus, DESIGNWARE_PCIE_ROOT_BUS)
|
||||
|
||||
#define TYPE_DESIGNWARE_PCIE_HOST "designware-pcie-host"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIEHost, DESIGNWARE_PCIE_HOST)
|
||||
|
||||
#define TYPE_DESIGNWARE_PCIE_ROOT "designware-pcie-root"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIERoot, DESIGNWARE_PCIE_ROOT)
|
||||
|
||||
struct DesignwarePCIERootBus {
|
||||
PCIBus parent;
|
||||
};
|
||||
|
||||
typedef struct DesignwarePCIEViewport {
|
||||
DesignwarePCIERoot *root;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue