Lines Matching refs:hbus
451 struct hv_pcibus *hbus; member
521 struct hv_pcibus *hbus; member
551 wait_for_response(struct hv_pcibus *hbus, struct completion *c) in wait_for_response() argument
554 if (vmbus_chan_is_revoked(hbus->sc->chan)) { in wait_for_response()
555 device_printf(hbus->pcib, in wait_for_response()
626 vmbus_chan_send(hpdev->hbus->sc->chan, VMBUS_CHANPKT_TYPE_INBAND, 0, in hv_int_desc_free()
635 struct hv_pcibus *hbus = hpdev->hbus; in hv_pci_delete_device() local
644 pci_dev = pci_find_dbsf(hbus->pci_domain, in hv_pci_delete_device()
647 device_delete_child(hbus->pci_bus, pci_dev); in hv_pci_delete_device()
651 mtx_lock(&hbus->device_list_lock); in hv_pci_delete_device()
652 TAILQ_REMOVE(&hbus->children, hpdev, link); in hv_pci_delete_device()
653 mtx_unlock(&hbus->device_list_lock); in hv_pci_delete_device()
662 new_pcichild_device(struct hv_pcibus *hbus, struct hv_pcidev_desc *desc) in new_pcichild_device() argument
674 hpdev->hbus = hbus; in new_pcichild_device()
688 ret = vmbus_chan_send(hbus->sc->chan, in new_pcichild_device()
694 if (wait_for_response(hbus, &comp_pkt.host_event)) in new_pcichild_device()
701 mtx_lock(&hbus->device_list_lock); in new_pcichild_device()
702 if (TAILQ_EMPTY(&hbus->children)) in new_pcichild_device()
703 hbus->pci_domain = desc->ser & 0xFFFF; in new_pcichild_device()
704 TAILQ_INSERT_TAIL(&hbus->children, hpdev, link); in new_pcichild_device()
705 mtx_unlock(&hbus->device_list_lock); in new_pcichild_device()
724 struct hv_pcibus *hbus; in pci_devices_present_work() local
732 hbus = dr_wrk->bus; in pci_devices_present_work()
736 mtx_lock(&hbus->device_list_lock); in pci_devices_present_work()
737 while (!TAILQ_EMPTY(&hbus->dr_list)) { in pci_devices_present_work()
738 dr = TAILQ_FIRST(&hbus->dr_list); in pci_devices_present_work()
739 TAILQ_REMOVE(&hbus->dr_list, dr, link); in pci_devices_present_work()
742 if (!TAILQ_EMPTY(&hbus->dr_list)) { in pci_devices_present_work()
747 mtx_unlock(&hbus->device_list_lock); in pci_devices_present_work()
753 mtx_lock(&hbus->device_list_lock); in pci_devices_present_work()
754 TAILQ_FOREACH(hpdev, &hbus->children, link) in pci_devices_present_work()
756 mtx_unlock(&hbus->device_list_lock); in pci_devices_present_work()
763 mtx_lock(&hbus->device_list_lock); in pci_devices_present_work()
764 TAILQ_FOREACH(hpdev, &hbus->children, link) { in pci_devices_present_work()
775 mtx_unlock(&hbus->device_list_lock); in pci_devices_present_work()
781 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
788 TAILQ_FOREACH_SAFE(hpdev, &hbus->children, link, tmp_hpdev) { in pci_devices_present_work()
794 if (hbus->state == hv_pcibus_installed && need_rescan) in pci_devices_present_work()
795 pci_rescan(hbus->pci_bus); in pci_devices_present_work()
798 query_comp = hbus->query_comp; in pci_devices_present_work()
800 hbus->query_comp = NULL; in pci_devices_present_work()
808 get_pcichild_wslot(struct hv_pcibus *hbus, uint32_t wslot) in get_pcichild_wslot() argument
812 mtx_lock(&hbus->device_list_lock); in get_pcichild_wslot()
813 TAILQ_FOREACH(hpdev, &hbus->children, link) { in get_pcichild_wslot()
819 mtx_unlock(&hbus->device_list_lock); in get_pcichild_wslot()
825 hv_pci_devices_present(struct hv_pcibus *hbus, in hv_pci_devices_present() argument
832 if (hbus->detaching && relations->device_count > 0) in hv_pci_devices_present()
844 mtx_lock(&hbus->device_list_lock); in hv_pci_devices_present()
845 TAILQ_INSERT_TAIL(&hbus->dr_list, dr, link); in hv_pci_devices_present()
846 mtx_unlock(&hbus->device_list_lock); in hv_pci_devices_present()
849 dr_wrk->bus = hbus; in hv_pci_devices_present()
851 taskqueue_enqueue(hbus->sc->taskq, &dr_wrk->task); in hv_pci_devices_present()
855 hv_pci_devices_present2(struct hv_pcibus *hbus, in hv_pci_devices_present2() argument
862 if (hbus->detaching && relations->device_count > 0) in hv_pci_devices_present2()
874 mtx_lock(&hbus->device_list_lock); in hv_pci_devices_present2()
875 TAILQ_INSERT_TAIL(&hbus->dr_list, dr, link); in hv_pci_devices_present2()
876 mtx_unlock(&hbus->device_list_lock); in hv_pci_devices_present2()
879 dr_wrk->bus = hbus; in hv_pci_devices_present2()
881 taskqueue_enqueue(hbus->sc->taskq, &dr_wrk->task); in hv_pci_devices_present2()
889 struct hv_pcibus *hbus = hpdev->hbus; in hv_eject_device_work() local
902 vmbus_chan_send(hbus->sc->chan, VMBUS_CHANPKT_TYPE_INBAND, 0, in hv_eject_device_work()
909 struct hv_pcibus *hbus = hpdev->hbus; in hv_pci_eject_device() local
912 if (hbus->detaching) in hv_pci_eject_device()
921 taskq = vmbus_chan_mgmt_tq(hbus->sc->chan); in hv_pci_eject_device()
931 struct hv_pcibus *hbus = sc->hbus; in vmbus_pcib_on_channel_callback() local
1000 hv_pci_devices_present(hbus, bus_rel); in vmbus_pcib_on_channel_callback()
1015 hv_pci_devices_present2(hbus, bus_rel2); in vmbus_pcib_on_channel_callback()
1019 hpdev = get_pcichild_wslot(hbus, in vmbus_pcib_on_channel_callback()
1044 hv_pci_protocol_negotiation(struct hv_pcibus *hbus, in hv_pci_protocol_negotiation() argument
1066 ret = vmbus_chan_send(hbus->sc->chan, in hv_pci_protocol_negotiation()
1071 ret = wait_for_response(hbus, &comp_pkt.host_event); in hv_pci_protocol_negotiation()
1074 device_printf(hbus->pcib, in hv_pci_protocol_negotiation()
1081 hbus->protocol_version = version[i]; in hv_pci_protocol_negotiation()
1082 device_printf(hbus->pcib, in hv_pci_protocol_negotiation()
1084 hbus->protocol_version); in hv_pci_protocol_negotiation()
1090 device_printf(hbus->pcib, in hv_pci_protocol_negotiation()
1099 device_printf(hbus->pcib, in hv_pci_protocol_negotiation()
1108 hv_pci_query_relations(struct hv_pcibus *hbus) in hv_pci_query_relations() argument
1114 ret = vmbus_chan_send(hbus->sc->chan, VMBUS_CHANPKT_TYPE_INBAND, 0, in hv_pci_query_relations()
1120 hv_pci_enter_d0(struct hv_pcibus *hbus) in hv_pci_enter_d0() argument
1144 d0_entry->mmio_base = rman_get_start(hbus->cfg_res); in hv_pci_enter_d0()
1146 ret = vmbus_chan_send(hbus->sc->chan, VMBUS_CHANPKT_TYPE_INBAND, in hv_pci_enter_d0()
1150 ret = wait_for_response(hbus, &comp_pkt.host_event); in hv_pci_enter_d0()
1156 device_printf(hbus->pcib, "vmbus_pcib failed to enable D0\n"); in hv_pci_enter_d0()
1172 hv_send_resources_allocated(struct hv_pcibus *hbus) in hv_send_resources_allocated() argument
1183 size_res = (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_4) in hv_send_resources_allocated()
1189 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
1199 if (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_4) { in hv_send_resources_allocated()
1213 ret = vmbus_chan_send(hbus->sc->chan, in hv_send_resources_allocated()
1218 ret = wait_for_response(hbus, &comp_pkt.host_event); in hv_send_resources_allocated()
1227 device_printf(hbus->pcib, in hv_send_resources_allocated()
1238 hv_send_resources_released(struct hv_pcibus *hbus) in hv_send_resources_released() argument
1246 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
1253 ret = vmbus_chan_send(hbus->sc->chan, in hv_send_resources_released()
1288 struct hv_pcibus *hbus = hpdev->hbus; in _hv_pcifront_read_config() local
1317 mtx_lock(&hbus->config_lock); in _hv_pcifront_read_config()
1320 hv_cfg_write_4(hbus, 0, hpdev->desc.wslot.val); in _hv_pcifront_read_config()
1328 *((uint8_t *)val) = hv_cfg_read_1(hbus, addr); in _hv_pcifront_read_config()
1331 *((uint16_t *)val) = hv_cfg_read_2(hbus, addr); in _hv_pcifront_read_config()
1334 *((uint32_t *)val) = hv_cfg_read_4(hbus, addr); in _hv_pcifront_read_config()
1343 mtx_unlock(&hbus->config_lock); in _hv_pcifront_read_config()
1354 struct hv_pcibus *hbus = hpdev->hbus; in _hv_pcifront_write_config() local
1362 mtx_lock(&hbus->config_lock); in _hv_pcifront_write_config()
1365 hv_cfg_write_4(hbus, 0, hpdev->desc.wslot.val); in _hv_pcifront_write_config()
1373 hv_cfg_write_1(hbus, addr, (uint8_t)val); in _hv_pcifront_write_config()
1376 hv_cfg_write_2(hbus, addr, (uint16_t)val); in _hv_pcifront_write_config()
1379 hv_cfg_write_4(hbus, addr, (uint32_t)val); in _hv_pcifront_write_config()
1389 mtx_unlock(&hbus->config_lock); in _hv_pcifront_write_config()
1407 vmbus_pcib_prepopulate_bars(struct hv_pcibus *hbus) in vmbus_pcib_prepopulate_bars() argument
1412 mtx_lock(&hbus->device_list_lock); in vmbus_pcib_prepopulate_bars()
1413 TAILQ_FOREACH(hpdev, &hbus->children, link) { in vmbus_pcib_prepopulate_bars()
1438 mtx_unlock(&hbus->device_list_lock); in vmbus_pcib_prepopulate_bars()
1444 struct hv_pcibus *hbus = arg; in vmbus_pcib_set_detaching() local
1446 atomic_set_int(&hbus->detaching, 1); in vmbus_pcib_set_detaching()
1450 vmbus_pcib_pre_detach(struct hv_pcibus *hbus) in vmbus_pcib_pre_detach() argument
1454 TASK_INIT(&task, 0, vmbus_pcib_set_detaching, hbus); in vmbus_pcib_pre_detach()
1460 vmbus_chan_run_task(hbus->sc->chan, &task); in vmbus_pcib_pre_detach()
1462 taskqueue_drain_all(hbus->sc->taskq); in vmbus_pcib_pre_detach()
1492 struct hv_pcibus *hbus; in vmbus_pcib_attach() local
1496 hbus = malloc(sizeof(*hbus), M_DEVBUF, M_WAITOK | M_ZERO); in vmbus_pcib_attach()
1497 hbus->pcib = dev; in vmbus_pcib_attach()
1501 hbus->pci_domain = inst_guid->hv_guid[9] | in vmbus_pcib_attach()
1504 mtx_init(&hbus->config_lock, "hbcfg", NULL, MTX_DEF); in vmbus_pcib_attach()
1505 mtx_init(&hbus->device_list_lock, "hbdl", NULL, MTX_DEF); in vmbus_pcib_attach()
1506 TAILQ_INIT(&hbus->children); in vmbus_pcib_attach()
1507 TAILQ_INIT(&hbus->dr_list); in vmbus_pcib_attach()
1509 hbus->cfg_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, in vmbus_pcib_attach()
1513 if (!hbus->cfg_res) { in vmbus_pcib_attach()
1522 sc->hbus = hbus; in vmbus_pcib_attach()
1535 hbus->sc = sc; in vmbus_pcib_attach()
1537 init_completion(&hbus->query_completion); in vmbus_pcib_attach()
1538 hbus->query_comp = &hbus->query_completion; in vmbus_pcib_attach()
1545 ret = hv_pci_protocol_negotiation(hbus, pci_protocol_versions, in vmbus_pcib_attach()
1550 ret = hv_pci_query_relations(hbus); in vmbus_pcib_attach()
1552 ret = wait_for_response(hbus, hbus->query_comp); in vmbus_pcib_attach()
1557 ret = hv_pci_enter_d0(hbus); in vmbus_pcib_attach()
1561 ret = hv_send_resources_allocated(hbus); in vmbus_pcib_attach()
1565 vmbus_pcib_prepopulate_bars(hbus); in vmbus_pcib_attach()
1567 hbus->pci_bus = device_add_child(dev, "pci", DEVICE_UNIT_ANY); in vmbus_pcib_attach()
1568 if (!hbus->pci_bus) { in vmbus_pcib_attach()
1576 hbus->state = hv_pcibus_installed; in vmbus_pcib_attach()
1581 vmbus_pcib_pre_detach(hbus); in vmbus_pcib_attach()
1585 free_completion(&hbus->query_completion); in vmbus_pcib_attach()
1587 bus_release_resource(dev, SYS_RES_MEMORY, 0, hbus->cfg_res); in vmbus_pcib_attach()
1589 mtx_destroy(&hbus->device_list_lock); in vmbus_pcib_attach()
1590 mtx_destroy(&hbus->config_lock); in vmbus_pcib_attach()
1591 free(hbus, M_DEVBUF); in vmbus_pcib_attach()
1602 struct hv_pcibus *hbus = sc->hbus; in vmbus_pcib_detach() local
1607 vmbus_pcib_pre_detach(hbus); in vmbus_pcib_detach()
1609 if (hbus->state == hv_pcibus_installed) in vmbus_pcib_detach()
1614 hv_pci_devices_present(hbus, &relations); in vmbus_pcib_detach()
1616 ret = hv_send_resources_released(hbus); in vmbus_pcib_detach()
1626 taskqueue_drain_all(hbus->sc->taskq); in vmbus_pcib_detach()
1630 free_completion(&hbus->query_completion); in vmbus_pcib_detach()
1632 bus_release_resource(dev, SYS_RES_MEMORY, 0, hbus->cfg_res); in vmbus_pcib_detach()
1634 mtx_destroy(&hbus->device_list_lock); in vmbus_pcib_detach()
1635 mtx_destroy(&hbus->config_lock); in vmbus_pcib_detach()
1636 free(hbus, M_DEVBUF); in vmbus_pcib_detach()
1648 *val = sc->hbus->pci_domain; in vmbus_pcib_read_ivar()
1676 return (pci_domain_alloc_bus(sc->hbus->pci_domain, child, rid, in vmbus_pcib_alloc_resource()
1686 hpdev = get_pcichild_wslot(sc->hbus, devfn_to_wslot(devfn)); in vmbus_pcib_alloc_resource()
1721 return (pci_domain_adjust_bus(sc->hbus->pci_domain, child, r, in vmbus_pcib_adjust_resource()
1733 return (pci_domain_release_bus(sc->hbus->pci_domain, child, r)); in vmbus_pcib_release_resource()
1747 return (pci_domain_activate_bus(sc->hbus->pci_domain, child, in vmbus_pcib_activate_resource()
1758 return (pci_domain_deactivate_bus(sc->hbus->pci_domain, child, in vmbus_pcib_deactivate_resource()
1781 hpdev = get_pcichild_wslot(sc->hbus, devfn_to_wslot(devfn)); in vmbus_pcib_read_config()
1800 hpdev = get_pcichild_wslot(sc->hbus, devfn_to_wslot(devfn)); in vmbus_pcib_write_config()
1901 hpdev = get_pcichild_wslot(sc->hbus, devfn_to_wslot(devfn)); in vmbus_pcib_map_msi()
1932 if (hpdev->hbus->protocol_version < PCI_PROTOCOL_VERSION_1_4 && in vmbus_pcib_map_msi()
1938 vcpu_id, hpdev->hbus->protocol_version); in vmbus_pcib_map_msi()
1947 switch (hpdev->hbus->protocol_version) { in vmbus_pcib_map_msi()