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