Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/pci/pci.c
Show First 20 Lines • Show All 6,255 Lines • ▼ Show 20 Lines | pci_get_id_method(device_t dev, device_t child, enum pci_id_type type, | ||||
return (PCIB_GET_ID(device_get_parent(dev), child, type, id)); | return (PCIB_GET_ID(device_get_parent(dev), child, type, id)); | ||||
} | } | ||||
/* Find the upstream port of a given PCI device in a root complex. */ | /* Find the upstream port of a given PCI device in a root complex. */ | ||||
device_t | device_t | ||||
pci_find_pcie_root_port(device_t dev) | pci_find_pcie_root_port(device_t dev) | ||||
{ | { | ||||
struct pci_devinfo *dinfo; | struct pci_devinfo *dinfo; | ||||
devclass_t pci_class; | devclass_t pci_class, vmd_bus_class; | ||||
device_t pcib, bus; | device_t pcib, bus; | ||||
pci_class = devclass_find("pci"); | pci_class = devclass_find("pci"); | ||||
KASSERT(device_get_devclass(device_get_parent(dev)) == pci_class, | vmd_bus_class = devclass_find("vmd_bus"); | ||||
imp: The assert is wrong, but I don't think is the right way to fix it. We want to pass and devclass… | |||||
printf("%s %d\n", device_get_name(device_get_parent(dev)), dev == NULL); | |||||
KASSERT(device_get_devclass(device_get_parent(dev)) == pci_class || | |||||
device_get_devclass(device_get_parent(dev)) == vmd_bus_class, | |||||
("%s: non-pci device %s", __func__, device_get_nameunit(dev))); | ("%s: non-pci device %s", __func__, device_get_nameunit(dev))); | ||||
/* | /* | ||||
* Walk the bridge hierarchy until we find a PCI-e root | * Walk the bridge hierarchy until we find a PCI-e root | ||||
* port or a non-PCI device. | * port or a non-PCI device. | ||||
*/ | */ | ||||
for (;;) { | for (;;) { | ||||
bus = device_get_parent(dev); | bus = device_get_parent(dev); | ||||
KASSERT(bus != NULL, ("%s: null parent of %s", __func__, | KASSERT(bus != NULL, ("%s: null parent of %s", __func__, | ||||
device_get_nameunit(dev))); | device_get_nameunit(dev))); | ||||
pcib = device_get_parent(bus); | pcib = device_get_parent(bus); | ||||
KASSERT(pcib != NULL, ("%s: null bridge of %s", __func__, | KASSERT(pcib != NULL, ("%s: null bridge of %s", __func__, | ||||
device_get_nameunit(bus))); | device_get_nameunit(bus))); | ||||
/* | /* | ||||
* pcib's parent must be a PCI bus for this to be a | * pcib's parent must be a PCI bus for this to be a | ||||
* PCI-PCI bridge. | * PCI-PCI bridge. | ||||
*/ | */ | ||||
if (device_get_devclass(device_get_parent(pcib)) != pci_class) | if (device_get_devclass(device_get_parent(pcib)) != pci_class) | ||||
Not Done Inline ActionsI think this would need it to to be complete general. imp: I think this would need it to to be complete general. | |||||
return (NULL); | return (NULL); | ||||
dinfo = device_get_ivars(pcib); | dinfo = device_get_ivars(pcib); | ||||
if (dinfo->cfg.pcie.pcie_location != 0 && | if (dinfo->cfg.pcie.pcie_location != 0 && | ||||
dinfo->cfg.pcie.pcie_type == PCIEM_TYPE_ROOT_PORT) | dinfo->cfg.pcie.pcie_type == PCIEM_TYPE_ROOT_PORT) | ||||
return (pcib); | return (pcib); | ||||
dev = pcib; | dev = pcib; | ||||
▲ Show 20 Lines • Show All 474 Lines • Show Last 20 Lines |
The assert is wrong, but I don't think is the right way to fix it. We want to pass and devclass that's pci or derived from pci, I think. That may need a new newbus helper function which I'm happy to write if jhb concurs.