Lines Matching refs:bus
47 u8 bus; member
149 u8 bus, slot, stride; member
156 unsigned int seg, bus, slot; in parse_phantom_dev() local
164 s = parse_pci(str, &seg, &bus, &slot, NULL); in parse_phantom_dev()
169 phantom.bus = bus; in parse_phantom_dev()
252 u8 bus = pdev->bus; in check_pdev() local
259 val = pci_conf_read16(seg, bus, dev, func, PCI_COMMAND); in check_pdev()
261 pci_conf_write16(seg, bus, dev, func, PCI_COMMAND, in check_pdev()
263 val = pci_conf_read16(seg, bus, dev, func, PCI_STATUS); in check_pdev()
267 seg, bus, dev, func, val, val & ~PCI_STATUS_CHECK); in check_pdev()
268 pci_conf_write16(seg, bus, dev, func, PCI_STATUS, in check_pdev()
273 switch ( pci_conf_read8(seg, bus, dev, func, PCI_HEADER_TYPE) & 0x7f ) in check_pdev()
278 val = pci_conf_read16(seg, bus, dev, func, PCI_BRIDGE_CONTROL); in check_pdev()
280 pci_conf_write16(seg, bus, dev, func, PCI_BRIDGE_CONTROL, in check_pdev()
282 val = pci_conf_read16(seg, bus, dev, func, PCI_SEC_STATUS); in check_pdev()
287 seg, bus, dev, func, val, val & ~PCI_STATUS_CHECK); in check_pdev()
288 pci_conf_write16(seg, bus, dev, func, PCI_SEC_STATUS, in check_pdev()
300 static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn) in alloc_pdev() argument
305 if ( pdev->bus == bus && pdev->devfn == devfn ) in alloc_pdev()
313 *((u8*) &pdev->bus) = bus; in alloc_pdev()
318 if ( pci_find_cap_offset(pseg->nr, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), in alloc_pdev()
335 switch ( pdev->type = pdev_type(pseg->nr, bus, devfn) ) in alloc_pdev()
343 sec_bus = pci_conf_read8(pseg->nr, bus, PCI_SLOT(devfn), in alloc_pdev()
345 sub_bus = pci_conf_read8(pseg->nr, bus, PCI_SLOT(devfn), in alloc_pdev()
352 pseg->bus2bridge[sec_bus].bus = bus; in alloc_pdev()
359 pos = pci_find_cap_offset(pseg->nr, bus, PCI_SLOT(devfn), in alloc_pdev()
362 cap = pci_conf_read16(pseg->nr, bus, PCI_SLOT(devfn), in alloc_pdev()
377 phantom_devs[i].bus == bus && in alloc_pdev()
394 pseg->nr, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pdev->type); in alloc_pdev()
414 sec_bus = pci_conf_read8(pseg->nr, pdev->bus, dev, func, in free_pdev()
416 sub_bus = pci_conf_read8(pseg->nr, pdev->bus, dev, func, in free_pdev()
421 pseg->bus2bridge[sec_bus] = pseg->bus2bridge[pdev->bus]; in free_pdev()
442 int __init pci_hide_device(int bus, int devfn) in pci_hide_device() argument
448 pdev = alloc_pdev(get_pseg(0), bus, devfn); in pci_hide_device()
459 int __init pci_ro_device(int seg, int bus, int devfn) in pci_ro_device() argument
466 pdev = alloc_pdev(pseg, bus, devfn); in pci_ro_device()
480 __set_bit(PCI_BDF2(bus, devfn), pseg->ro_map); in pci_ro_device()
486 struct pci_dev *pci_get_pdev(int seg, int bus, int devfn) in pci_get_pdev() argument
492 ASSERT(seg != -1 || bus == -1); in pci_get_pdev()
493 ASSERT(bus != -1 || devfn == -1); in pci_get_pdev()
505 if ( (pdev->bus == bus || bus == -1) && in pci_get_pdev()
514 struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn) in pci_get_real_pdev() argument
519 if ( seg < 0 || bus < 0 || devfn < 0 ) in pci_get_real_pdev()
522 for ( pdev = pci_get_pdev(seg, bus, devfn), stride = 4; in pci_get_real_pdev()
527 pdev = pci_get_pdev(seg, bus, devfn & ~(8 - stride)); in pci_get_real_pdev()
536 int bus, int devfn) in pci_get_pdev_by_domain() argument
541 ASSERT(seg != -1 || bus == -1); in pci_get_pdev_by_domain()
542 ASSERT(bus != -1 || devfn == -1); in pci_get_pdev_by_domain()
554 if ( (pdev->bus == bus || bus == -1) && in pci_get_pdev_by_domain()
572 u8 bus = pdev->bus; in pci_enable_acs() local
579 pos = pci_find_ext_capability(seg, bus, pdev->devfn, PCI_EXT_CAP_ID_ACS); in pci_enable_acs()
583 cap = pci_conf_read16(seg, bus, dev, func, pos + PCI_ACS_CAP); in pci_enable_acs()
584 ctrl = pci_conf_read16(seg, bus, dev, func, pos + PCI_ACS_CTRL); in pci_enable_acs()
598 pci_conf_write16(seg, bus, dev, func, pos + PCI_ACS_CTRL, ctrl); in pci_enable_acs()
605 int pci_add_device(u16 seg, u8 bus, u8 devfn, in pci_add_device() argument
620 pdev = pci_get_pdev(seg, info->physfn.bus, info->physfn.devfn); in pci_add_device()
625 pci_add_device(seg, info->physfn.bus, info->physfn.devfn, in pci_add_device()
637 ret = xsm_resource_plug_pci(XSM_PRIV, (seg << 16) | (bus << 8) | devfn); in pci_add_device()
647 pdev = alloc_pdev(pseg, bus, devfn); in pci_add_device()
665 unsigned int pos = pci_find_ext_capability(seg, bus, devfn, in pci_add_device()
667 u16 ctrl = pci_conf_read16(seg, bus, slot, func, pos + PCI_SRIOV_CTRL); in pci_add_device()
679 u32 bar = pci_conf_read32(seg, bus, slot, func, idx); in pci_add_device()
688 seg, bus, slot, func, i); in pci_add_device()
691 pci_conf_write32(seg, bus, slot, func, idx, ~0); in pci_add_device()
700 seg, bus, slot, func); in pci_add_device()
703 hi = pci_conf_read32(seg, bus, slot, func, idx + 4); in pci_add_device()
704 pci_conf_write32(seg, bus, slot, func, idx + 4, ~0); in pci_add_device()
706 pdev->vf_rlen[i] = pci_conf_read32(seg, bus, slot, func, idx) & in pci_add_device()
711 pdev->vf_rlen[i] |= (u64)pci_conf_read32(seg, bus, in pci_add_device()
714 pci_conf_write32(seg, bus, slot, func, idx + 4, hi); in pci_add_device()
718 pci_conf_write32(seg, bus, slot, func, idx, bar); in pci_add_device()
729 seg, bus, slot, func, ctrl); in pci_add_device()
757 seg, bus, slot, func); in pci_add_device()
764 seg, bus, slot, func); in pci_add_device()
770 int pci_remove_device(u16 seg, u8 bus, u8 devfn) in pci_remove_device() argument
776 ret = xsm_resource_unplug_pci(XSM_PRIV, (seg << 16) | (bus << 8) | devfn); in pci_remove_device()
787 if ( pdev->bus == bus && pdev->devfn == devfn ) in pci_remove_device()
795 seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); in pci_remove_device()
854 u8 bus, devfn; in pci_release_devices() local
866 bus = pdev->bus; in pci_release_devices()
868 if ( deassign_device(d, pdev->seg, bus, devfn) ) in pci_release_devices()
870 d->domain_id, pdev->seg, bus, in pci_release_devices()
881 enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn) in pdev_type() argument
885 int pos = pci_find_cap_offset(seg, bus, d, f, PCI_CAP_ID_EXP); in pdev_type()
887 class_device = pci_conf_read16(seg, bus, d, f, PCI_CLASS_DEVICE); in pdev_type()
893 creg = pci_conf_read16(seg, bus, d, f, pos + PCI_EXP_FLAGS); in pdev_type()
918 int find_upstream_bridge(u16 seg, u8 *bus, u8 *devfn, u8 *secbus) in find_upstream_bridge() argument
924 if ( *bus == 0 ) in find_upstream_bridge()
930 if ( !pseg->bus2bridge[*bus].map ) in find_upstream_bridge()
935 while ( pseg->bus2bridge[*bus].map ) in find_upstream_bridge()
937 *secbus = *bus; in find_upstream_bridge()
938 *devfn = pseg->bus2bridge[*bus].devfn; in find_upstream_bridge()
939 *bus = pseg->bus2bridge[*bus].bus; in find_upstream_bridge()
952 bool_t __init pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func) in pci_device_detect() argument
956 vendor = pci_conf_read32(seg, bus, dev, func, PCI_VENDOR_ID); in pci_device_detect()
964 void pci_check_disable_device(u16 seg, u8 bus, u8 devfn) in pci_check_disable_device() argument
971 pdev = pci_get_real_pdev(seg, bus, devfn); in pci_check_disable_device()
989 cword = pci_conf_read16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), in pci_check_disable_device()
991 pci_conf_write16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), in pci_check_disable_device()
1002 int bus, dev, func; in _scan_pci_devices() local
1004 for ( bus = 0; bus < 256; bus++ ) in _scan_pci_devices()
1010 if ( !pci_device_detect(pseg->nr, bus, dev, func) ) in _scan_pci_devices()
1017 pdev = alloc_pdev(pseg, bus, PCI_DEVFN(dev, func)); in _scan_pci_devices()
1021 pseg->nr, bus, dev, func); in _scan_pci_devices()
1025 if ( !func && !(pci_conf_read8(pseg->nr, bus, dev, func, in _scan_pci_devices()
1062 pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), in setup_one_hwdom_device()
1075 int bus, devfn; in _setup_hwdom_pci_devices() local
1077 for ( bus = 0; bus < 256; bus++ ) in _setup_hwdom_pci_devices()
1081 struct pci_dev *pdev = pci_get_pdev(pseg->nr, bus, devfn); in _setup_hwdom_pci_devices()
1100 pdev->domain->domain_id, pseg->nr, bus, in _setup_hwdom_pci_devices()
1139 return ACPI_HEST_SEGMENT(p->bus) == pdev->seg && in hest_match_pci()
1140 ACPI_HEST_BUS(p->bus) == pdev->bus && in hest_match_pci()
1148 unsigned int pos = pci_find_cap_offset(pdev->seg, pdev->bus, in hest_match_type()
1152 u8 pcie = MASK_EXTR(pci_conf_read16(pdev->seg, pdev->bus, in hest_match_type()
1165 return pci_conf_read16(pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn), in hest_match_type()
1225 return pci_find_cap_offset(pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn), in pcie_aer_get_firmware_first()
1242 pseg->nr, pdev->bus, in _dump_pci_devices()
1310 pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), rc); in iommu_add_device()
1355 pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), rc); in iommu_remove_device()
1366 static int device_assigned(u16 seg, u8 bus, u8 devfn) in device_assigned() argument
1371 pdev = pci_get_pdev_by_domain(hardware_domain, seg, bus, devfn); in device_assigned()
1377 static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) in assign_device() argument
1404 pdev = pci_get_pdev_by_domain(hardware_domain, seg, bus, devfn); in assign_device()
1407 rc = pci_get_pdev(seg, bus, devfn) ? -EBUSY : -ENODEV; in assign_device()
1427 d->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), in assign_device()
1440 int deassign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) in deassign_device() argument
1450 pdev = pci_get_pdev_by_domain(d, seg, bus, devfn); in deassign_device()
1465 d->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), ret); in deassign_device()
1476 d->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); in deassign_device()
1489 struct domain *d, u16 seg, u8 bus, u8 devfn, in iommu_get_device_group() argument
1502 group_id = ops->get_device_group_id(seg, bus, devfn); in iommu_get_device_group()
1508 ((pdev->bus == bus) && (pdev->devfn == devfn)) ) in iommu_get_device_group()
1511 if ( xsm_get_device_group(XSM_HOOK, (seg << 16) | (pdev->bus << 8) | pdev->devfn) ) in iommu_get_device_group()
1514 sdev_id = ops->get_device_group_id(seg, pdev->bus, pdev->devfn); in iommu_get_device_group()
1518 bdf |= (pdev->bus & 0xff) << 16; in iommu_get_device_group()
1555 d->domain_id, pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn), in iommu_dev_iotlb_flush_timeout()
1568 u8 bus, devfn; in iommu_do_pci_domctl() local
1586 bus = PCI_BUS(domctl->u.get_device_group.machine_sbdf); in iommu_do_pci_domctl()
1591 ret = iommu_get_device_group(d, seg, bus, devfn, sdevs, max_sdevs); in iommu_do_pci_domctl()
1637 bus = PCI_BUS(machine_sbdf); in iommu_do_pci_domctl()
1640 ret = device_assigned(seg, bus, devfn); in iommu_do_pci_domctl()
1647 seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); in iommu_do_pci_domctl()
1653 ret = assign_device(d, seg, bus, devfn, flags); in iommu_do_pci_domctl()
1660 seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), in iommu_do_pci_domctl()
1688 bus = PCI_BUS(machine_sbdf); in iommu_do_pci_domctl()
1692 ret = deassign_device(d, seg, bus, devfn); in iommu_do_pci_domctl()
1697 seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), in iommu_do_pci_domctl()