Lines Matching full:hbus

540 	struct hv_pcibus_device *hbus;  member
583 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus,
674 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_read_config()
702 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
704 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_read_config()
724 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
726 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_read_config()
735 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
738 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
741 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in hv_pcifront_get_vendor_id()
751 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
767 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_write_config()
773 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
775 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_write_config()
795 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
797 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_write_config()
816 struct hv_pcibus_device *hbus = in hv_pcifront_read_config() local
820 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
844 struct hv_pcibus_device *hbus = in hv_pcifront_write_config() local
848 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
945 struct hv_pcibus_device *hbus = in hv_read_config_block() local
972 ret = vmbus_sendpacket(hbus->hdev->channel, read_blk, in hv_read_config_block()
979 ret = wait_for_response(hbus->hdev, &comp_pkt.comp_pkt.host_event); in hv_read_config_block()
985 dev_err(&hbus->hdev->device, in hv_read_config_block()
1025 struct hv_pcibus_device *hbus = in hv_write_config_block() local
1062 ret = vmbus_sendpacket(hbus->hdev->channel, write_blk, pkt_size, in hv_write_config_block()
1068 ret = wait_for_response(hbus->hdev, &comp_pkt.host_event); in hv_write_config_block()
1073 dev_err(&hbus->hdev->device, in hv_write_config_block()
1095 struct hv_pcibus_device *hbus = in hv_register_block_invalidate() local
1100 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1128 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1147 struct hv_pcibus_device *hbus; in hv_msi_free() local
1155 hbus = info->data; in hv_msi_free()
1161 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1199 struct hv_pcibus_device *hbus; in hv_irq_unmask() local
1212 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_irq_unmask()
1214 spin_lock_irqsave(&hbus->retarget_msi_interrupt_lock, flags); in hv_irq_unmask()
1216 params = &hbus->retarget_msi_interrupt_params; in hv_irq_unmask()
1221 params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | in hv_irq_unmask()
1222 (hbus->hdev->dev_instance.b[4] << 16) | in hv_irq_unmask()
1223 (hbus->hdev->dev_instance.b[7] << 8) | in hv_irq_unmask()
1224 (hbus->hdev->dev_instance.b[6] & 0xf8) | in hv_irq_unmask()
1235 if (hbus->protocol_version >= PCI_PROTOCOL_VERSION_1_2) { in hv_irq_unmask()
1277 spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags); in hv_irq_unmask()
1295 if (res && hbus->state != hv_pcibus_removing) in hv_irq_unmask()
1296 dev_err(&hbus->hdev->device, in hv_irq_unmask()
1376 struct hv_pcibus_device *hbus; in hv_compose_msi_msg() local
1398 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_compose_msi_msg()
1399 channel = hbus->hdev->channel; in hv_compose_msi_msg()
1400 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1420 switch (hbus->protocol_version) { in hv_compose_msi_msg()
1441 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1446 ret = vmbus_sendpacket(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1451 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1472 dev_err_once(&hbus->hdev->device, in hv_compose_msi_msg()
1489 hv_pci_onchannelcallback(hbus); in hv_compose_msi_msg()
1493 dev_err_once(&hbus->hdev->device, in hv_compose_msi_msg()
1504 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1555 * @hbus: The root PCI bus
1566 static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) in hv_pcie_init_irq_domain() argument
1568 hbus->msi_info.chip = &hv_msi_irq_chip; in hv_pcie_init_irq_domain()
1569 hbus->msi_info.ops = &hv_msi_ops; in hv_pcie_init_irq_domain()
1570 hbus->msi_info.flags = (MSI_FLAG_USE_DEF_DOM_OPS | in hv_pcie_init_irq_domain()
1573 hbus->msi_info.handler = handle_edge_irq; in hv_pcie_init_irq_domain()
1574 hbus->msi_info.handler_name = "edge"; in hv_pcie_init_irq_domain()
1575 hbus->msi_info.data = hbus; in hv_pcie_init_irq_domain()
1576 hbus->irq_domain = pci_msi_create_irq_domain(hbus->sysdata.fwnode, in hv_pcie_init_irq_domain()
1577 &hbus->msi_info, in hv_pcie_init_irq_domain()
1579 if (!hbus->irq_domain) { in hv_pcie_init_irq_domain()
1580 dev_err(&hbus->hdev->device, in hv_pcie_init_irq_domain()
1610 * @hbus: Root PCI bus, as understood by this driver
1612 static void survey_child_resources(struct hv_pcibus_device *hbus) in survey_child_resources() argument
1622 event = xchg(&hbus->survey_event, NULL); in survey_child_resources()
1627 if (hbus->low_mmio_space || hbus->high_mmio_space) { in survey_child_resources()
1632 spin_lock_irqsave(&hbus->device_list_lock, flags); in survey_child_resources()
1639 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
1642 dev_err(&hbus->hdev->device, in survey_child_resources()
1661 hbus->high_mmio_space += bar_size; in survey_child_resources()
1663 hbus->low_mmio_space += bar_size; in survey_child_resources()
1668 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in survey_child_resources()
1674 * @hbus: Root PCI bus, as understood by this driver
1684 static void prepopulate_bars(struct hv_pcibus_device *hbus) in prepopulate_bars() argument
1698 if (hbus->low_mmio_space) { in prepopulate_bars()
1699 low_size = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in prepopulate_bars()
1700 low_base = hbus->low_mmio_res->start; in prepopulate_bars()
1703 if (hbus->high_mmio_space) { in prepopulate_bars()
1705 (63 - __builtin_clzll(hbus->high_mmio_space)); in prepopulate_bars()
1706 high_base = hbus->high_mmio_res->start; in prepopulate_bars()
1709 spin_lock_irqsave(&hbus->device_list_lock, flags); in prepopulate_bars()
1722 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1730 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1783 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in prepopulate_bars()
1792 * same ordered workqueue. Therefore hbus->children list will not change
1795 static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) in hv_pci_assign_slots() argument
1801 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
1807 hpdev->pci_slot = pci_create_slot(hbus->pci_bus, slot_nr, in hv_pci_assign_slots()
1819 static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) in hv_pci_remove_slots() argument
1823 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
1834 static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) in hv_pci_assign_numa_node() argument
1837 struct pci_bus *bus = hbus->pci_bus; in hv_pci_assign_numa_node()
1841 hv_dev = get_pcichild_wslot(hbus, devfn_to_wslot(dev->devfn)); in hv_pci_assign_numa_node()
1854 * @hbus: Root PCI bus, as understood by this driver
1858 static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) in create_root_hv_pci_bus() argument
1861 hbus->pci_bus = pci_create_root_bus(&hbus->hdev->device, in create_root_hv_pci_bus()
1864 &hbus->sysdata, in create_root_hv_pci_bus()
1865 &hbus->resources_for_children); in create_root_hv_pci_bus()
1866 if (!hbus->pci_bus) in create_root_hv_pci_bus()
1869 hbus->pci_bus->msi = &hbus->msi_chip; in create_root_hv_pci_bus()
1870 hbus->pci_bus->msi->dev = &hbus->hdev->device; in create_root_hv_pci_bus()
1873 pci_scan_child_bus(hbus->pci_bus); in create_root_hv_pci_bus()
1874 hv_pci_assign_numa_node(hbus); in create_root_hv_pci_bus()
1875 pci_bus_assign_resources(hbus->pci_bus); in create_root_hv_pci_bus()
1876 hv_pci_assign_slots(hbus); in create_root_hv_pci_bus()
1877 pci_bus_add_devices(hbus->pci_bus); in create_root_hv_pci_bus()
1879 hbus->state = hv_pcibus_installed; in create_root_hv_pci_bus()
1906 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
1921 * @hbus: The internal struct tracking this root PCI bus.
1930 static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, in new_pcichild_device() argument
1947 hpdev->hbus = hbus; in new_pcichild_device()
1958 ret = vmbus_sendpacket(hbus->hdev->channel, res_req, in new_pcichild_device()
1966 if (wait_for_response(hbus->hdev, &comp_pkt.host_event)) in new_pcichild_device()
1972 spin_lock_irqsave(&hbus->device_list_lock, flags); in new_pcichild_device()
1974 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
1975 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in new_pcichild_device()
1985 * @hbus: Root PCI bus, as understood by this driver
1996 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, in get_pcichild_wslot() argument
2002 spin_lock_irqsave(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2003 list_for_each_entry(iter, &hbus->children, list_entry) { in get_pcichild_wslot()
2010 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2036 * because both are pushed to the ordered workqueue hbus->wq.
2044 struct hv_pcibus_device *hbus; in pci_devices_present_work() local
2051 hbus = dr_wrk->bus; in pci_devices_present_work()
2057 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2058 while (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2059 dr = list_first_entry(&hbus->dr_list, struct hv_dr_state, in pci_devices_present_work()
2064 if (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2069 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2072 put_hvpcibus(hbus); in pci_devices_present_work()
2077 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2078 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2081 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2088 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2089 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2098 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2101 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2103 dev_err(&hbus->hdev->device, in pci_devices_present_work()
2109 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2112 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2121 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2135 switch (hbus->state) { in pci_devices_present_work()
2142 pci_scan_child_bus(hbus->pci_bus); in pci_devices_present_work()
2143 hv_pci_assign_numa_node(hbus); in pci_devices_present_work()
2144 hv_pci_assign_slots(hbus); in pci_devices_present_work()
2150 survey_child_resources(hbus); in pci_devices_present_work()
2157 put_hvpcibus(hbus); in pci_devices_present_work()
2163 * @hbus: Root PCI bus, as understood by this driver
2168 static int hv_pci_start_relations_work(struct hv_pcibus_device *hbus, in hv_pci_start_relations_work() argument
2175 if (hbus->state == hv_pcibus_removing) { in hv_pci_start_relations_work()
2176 dev_info(&hbus->hdev->device, in hv_pci_start_relations_work()
2186 dr_wrk->bus = hbus; in hv_pci_start_relations_work()
2188 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2194 pending_dr = !list_empty(&hbus->dr_list); in hv_pci_start_relations_work()
2195 list_add_tail(&dr->list_entry, &hbus->dr_list); in hv_pci_start_relations_work()
2196 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2201 get_hvpcibus(hbus); in hv_pci_start_relations_work()
2202 queue_work(hbus->wq, &dr_wrk->wrk); in hv_pci_start_relations_work()
2210 * @hbus: Root PCI bus, as understood by this driver
2217 static void hv_pci_devices_present(struct hv_pcibus_device *hbus, in hv_pci_devices_present() argument
2241 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present()
2247 * @hbus: Root PCI bus, as understood by this driver
2252 static void hv_pci_devices_present2(struct hv_pcibus_device *hbus, in hv_pci_devices_present2() argument
2279 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present2()
2295 struct hv_pcibus_device *hbus; in hv_eject_device_work() local
2306 hbus = hpdev->hbus; in hv_eject_device_work()
2313 * must be done without constructs like pci_domain_nr(hbus->pci_bus) in hv_eject_device_work()
2314 * because hbus->pci_bus may not exist yet. in hv_eject_device_work()
2317 pdev = pci_get_domain_bus_and_slot(hbus->sysdata.domain, 0, wslot); in hv_eject_device_work()
2325 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_eject_device_work()
2327 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_eject_device_work()
2336 vmbus_sendpacket(hbus->hdev->channel, ejct_pkt, in hv_eject_device_work()
2347 put_hvpcibus(hbus); in hv_eject_device_work()
2360 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device() local
2361 struct hv_device *hdev = hbus->hdev; in hv_pci_eject_device()
2363 if (hbus->state == hv_pcibus_removing) { in hv_pci_eject_device()
2371 get_hvpcibus(hbus); in hv_pci_eject_device()
2372 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2386 struct hv_pcibus_device *hbus = context; in hv_pci_onchannelcallback() local
2406 ret = vmbus_recvpacket_raw(hbus->hdev->channel, buffer, in hv_pci_onchannelcallback()
2455 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2460 hv_pci_devices_present(hbus, bus_rel); in hv_pci_onchannelcallback()
2469 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2474 hv_pci_devices_present2(hbus, bus_rel2); in hv_pci_onchannelcallback()
2480 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2491 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2504 dev_warn(&hbus->hdev->device, in hv_pci_onchannelcallback()
2512 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2545 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_protocol_negotiation() local
2585 hbus->protocol_version = version[i]; in hv_pci_protocol_negotiation()
2588 hbus->protocol_version); in hv_pci_protocol_negotiation()
2615 * @hbus: Root PCI bus, as understood by this driver
2617 static void hv_pci_free_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_free_bridge_windows() argument
2624 if (hbus->low_mmio_space && hbus->low_mmio_res) { in hv_pci_free_bridge_windows()
2625 hbus->low_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
2626 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_free_bridge_windows()
2627 resource_size(hbus->low_mmio_res)); in hv_pci_free_bridge_windows()
2630 if (hbus->high_mmio_space && hbus->high_mmio_res) { in hv_pci_free_bridge_windows()
2631 hbus->high_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
2632 vmbus_free_mmio(hbus->high_mmio_res->start, in hv_pci_free_bridge_windows()
2633 resource_size(hbus->high_mmio_res)); in hv_pci_free_bridge_windows()
2640 * @hbus: Root PCI bus, as understood by this driver
2662 static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_allocate_bridge_windows() argument
2667 if (hbus->low_mmio_space) { in hv_pci_allocate_bridge_windows()
2668 align = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in hv_pci_allocate_bridge_windows()
2669 ret = vmbus_allocate_mmio(&hbus->low_mmio_res, hbus->hdev, 0, in hv_pci_allocate_bridge_windows()
2671 hbus->low_mmio_space, in hv_pci_allocate_bridge_windows()
2674 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
2676 hbus->low_mmio_space); in hv_pci_allocate_bridge_windows()
2681 hbus->low_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
2682 hbus->low_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
2683 pci_add_resource(&hbus->resources_for_children, in hv_pci_allocate_bridge_windows()
2684 hbus->low_mmio_res); in hv_pci_allocate_bridge_windows()
2687 if (hbus->high_mmio_space) { in hv_pci_allocate_bridge_windows()
2688 align = 1ULL << (63 - __builtin_clzll(hbus->high_mmio_space)); in hv_pci_allocate_bridge_windows()
2689 ret = vmbus_allocate_mmio(&hbus->high_mmio_res, hbus->hdev, in hv_pci_allocate_bridge_windows()
2691 hbus->high_mmio_space, align, in hv_pci_allocate_bridge_windows()
2694 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
2696 hbus->high_mmio_space); in hv_pci_allocate_bridge_windows()
2701 hbus->high_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
2702 hbus->high_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
2703 pci_add_resource(&hbus->resources_for_children, in hv_pci_allocate_bridge_windows()
2704 hbus->high_mmio_res); in hv_pci_allocate_bridge_windows()
2710 if (hbus->low_mmio_res) { in hv_pci_allocate_bridge_windows()
2711 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_allocate_bridge_windows()
2712 resource_size(hbus->low_mmio_res)); in hv_pci_allocate_bridge_windows()
2720 * @hbus: Root PCI bus, as understood by this driver
2727 static int hv_allocate_config_window(struct hv_pcibus_device *hbus) in hv_allocate_config_window() argument
2735 ret = vmbus_allocate_mmio(&hbus->mem_config, hbus->hdev, 0, -1, in hv_allocate_config_window()
2748 hbus->mem_config->flags |= IORESOURCE_BUSY; in hv_allocate_config_window()
2753 static void hv_free_config_window(struct hv_pcibus_device *hbus) in hv_free_config_window() argument
2755 vmbus_free_mmio(hbus->mem_config->start, PCI_CONFIG_MMIO_LENGTH); in hv_free_config_window()
2768 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_enter_d0() local
2789 d0_entry->mmio_base = hbus->mem_config->start; in hv_pci_enter_d0()
2824 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_query_relations() local
2831 if (cmpxchg(&hbus->survey_event, NULL, &comp)) in hv_pci_query_relations()
2864 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_allocated() local
2874 size_res = (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) in hv_send_resources_allocated()
2884 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
2893 if (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) { in hv_send_resources_allocated()
2925 hbus->wslot_res_allocated = wslot; in hv_send_resources_allocated()
2941 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_released() local
2947 for (wslot = hbus->wslot_res_allocated; wslot >= 0; wslot--) { in hv_send_resources_released()
2948 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
2963 hbus->wslot_res_allocated = wslot - 1; in hv_send_resources_released()
2966 hbus->wslot_res_allocated = -1; in hv_send_resources_released()
2971 static void get_hvpcibus(struct hv_pcibus_device *hbus) in get_hvpcibus() argument
2973 refcount_inc(&hbus->remove_lock); in get_hvpcibus()
2976 static void put_hvpcibus(struct hv_pcibus_device *hbus) in put_hvpcibus() argument
2978 if (refcount_dec_and_test(&hbus->remove_lock)) in put_hvpcibus()
2979 complete(&hbus->remove_event); in put_hvpcibus()
3034 struct hv_pcibus_device *hbus; in hv_pci_probe() local
3044 BUILD_BUG_ON(sizeof(*hbus) > HV_HYP_PAGE_SIZE); in hv_pci_probe()
3050 * alignment of hbus is important because hbus's field in hv_pci_probe()
3055 * hence kmemleak reports the pointer contained in the hbus buffer in hv_pci_probe()
3057 * is tracked by hbus->children) as memory leak (false positive). in hv_pci_probe()
3060 * used to allocate the hbus buffer and we can avoid the kmemleak false in hv_pci_probe()
3062 * kmemleak to track and scan the hbus buffer. in hv_pci_probe()
3064 hbus = kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); in hv_pci_probe()
3065 if (!hbus) in hv_pci_probe()
3067 hbus->state = hv_pcibus_init; in hv_pci_probe()
3068 hbus->wslot_res_allocated = -1; in hv_pci_probe()
3098 hbus->sysdata.domain = dom; in hv_pci_probe()
3100 hbus->hdev = hdev; in hv_pci_probe()
3101 refcount_set(&hbus->remove_lock, 1); in hv_pci_probe()
3102 INIT_LIST_HEAD(&hbus->children); in hv_pci_probe()
3103 INIT_LIST_HEAD(&hbus->dr_list); in hv_pci_probe()
3104 INIT_LIST_HEAD(&hbus->resources_for_children); in hv_pci_probe()
3105 spin_lock_init(&hbus->config_lock); in hv_pci_probe()
3106 spin_lock_init(&hbus->device_list_lock); in hv_pci_probe()
3107 spin_lock_init(&hbus->retarget_msi_interrupt_lock); in hv_pci_probe()
3108 init_completion(&hbus->remove_event); in hv_pci_probe()
3109 hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, in hv_pci_probe()
3110 hbus->sysdata.domain); in hv_pci_probe()
3111 if (!hbus->wq) { in hv_pci_probe()
3117 hv_pci_onchannelcallback, hbus); in hv_pci_probe()
3121 hv_set_drvdata(hdev, hbus); in hv_pci_probe()
3128 ret = hv_allocate_config_window(hbus); in hv_pci_probe()
3132 hbus->cfg_addr = ioremap(hbus->mem_config->start, in hv_pci_probe()
3134 if (!hbus->cfg_addr) { in hv_pci_probe()
3147 hbus->sysdata.fwnode = irq_domain_alloc_named_fwnode(name); in hv_pci_probe()
3149 if (!hbus->sysdata.fwnode) { in hv_pci_probe()
3154 ret = hv_pcie_init_irq_domain(hbus); in hv_pci_probe()
3190 hbus->wslot_res_allocated = 255; in hv_pci_probe()
3202 ret = hv_pci_allocate_bridge_windows(hbus); in hv_pci_probe()
3210 prepopulate_bars(hbus); in hv_pci_probe()
3212 hbus->state = hv_pcibus_probed; in hv_pci_probe()
3214 ret = create_root_hv_pci_bus(hbus); in hv_pci_probe()
3221 hv_pci_free_bridge_windows(hbus); in hv_pci_probe()
3225 irq_domain_remove(hbus->irq_domain); in hv_pci_probe()
3227 irq_domain_free_fwnode(hbus->sysdata.fwnode); in hv_pci_probe()
3229 iounmap(hbus->cfg_addr); in hv_pci_probe()
3231 hv_free_config_window(hbus); in hv_pci_probe()
3235 destroy_workqueue(hbus->wq); in hv_pci_probe()
3237 hv_put_dom_num(hbus->sysdata.domain); in hv_pci_probe()
3239 kfree(hbus); in hv_pci_probe()
3245 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_bus_exit() local
3264 if (dr && hv_pci_start_relations_work(hbus, dr)) in hv_pci_bus_exit()
3303 struct hv_pcibus_device *hbus; in hv_pci_remove() local
3306 hbus = hv_get_drvdata(hdev); in hv_pci_remove()
3307 if (hbus->state == hv_pcibus_installed) { in hv_pci_remove()
3310 pci_stop_root_bus(hbus->pci_bus); in hv_pci_remove()
3311 hv_pci_remove_slots(hbus); in hv_pci_remove()
3312 pci_remove_root_bus(hbus->pci_bus); in hv_pci_remove()
3314 hbus->state = hv_pcibus_removed; in hv_pci_remove()
3321 iounmap(hbus->cfg_addr); in hv_pci_remove()
3322 hv_free_config_window(hbus); in hv_pci_remove()
3323 pci_free_resource_list(&hbus->resources_for_children); in hv_pci_remove()
3324 hv_pci_free_bridge_windows(hbus); in hv_pci_remove()
3325 irq_domain_remove(hbus->irq_domain); in hv_pci_remove()
3326 irq_domain_free_fwnode(hbus->sysdata.fwnode); in hv_pci_remove()
3327 put_hvpcibus(hbus); in hv_pci_remove()
3328 wait_for_completion(&hbus->remove_event); in hv_pci_remove()
3329 destroy_workqueue(hbus->wq); in hv_pci_remove()
3331 hv_put_dom_num(hbus->sysdata.domain); in hv_pci_remove()
3333 kfree(hbus); in hv_pci_remove()
3339 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_suspend() local
3349 * items onto hbus->wq in hv_pci_devices_present() and in hv_pci_suspend()
3356 * callback tasklet, sets hbus->state to hv_pcibus_removing, and in hv_pci_suspend()
3359 * hbus->wq and safely closes the vmbus channel. in hv_pci_suspend()
3363 /* Change the hbus state to prevent new work items. */ in hv_pci_suspend()
3364 old_state = hbus->state; in hv_pci_suspend()
3365 if (hbus->state == hv_pcibus_installed) in hv_pci_suspend()
3366 hbus->state = hv_pcibus_removing; in hv_pci_suspend()
3373 flush_workqueue(hbus->wq); in hv_pci_suspend()
3407 static void hv_pci_restore_msi_state(struct hv_pcibus_device *hbus) in hv_pci_restore_msi_state() argument
3409 pci_walk_bus(hbus->pci_bus, hv_pci_restore_msi_msg, NULL); in hv_pci_restore_msi_state()
3414 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_resume() local
3418 hbus->state = hv_pcibus_init; in hv_pci_resume()
3421 hv_pci_onchannelcallback, hbus); in hv_pci_resume()
3426 version[0] = hbus->protocol_version; in hv_pci_resume()
3443 prepopulate_bars(hbus); in hv_pci_resume()
3445 hv_pci_restore_msi_state(hbus); in hv_pci_resume()
3447 hbus->state = hv_pcibus_installed; in hv_pci_resume()