Lines Matching full:hbus
530 struct hv_pcibus_device *hbus; member
573 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus,
664 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_read_config()
692 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
694 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_read_config()
714 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
716 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_read_config()
725 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
728 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
731 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in hv_pcifront_get_vendor_id()
741 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
757 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_write_config()
763 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
765 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_write_config()
785 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
787 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_write_config()
806 struct hv_pcibus_device *hbus = in hv_pcifront_read_config() local
810 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
834 struct hv_pcibus_device *hbus = in hv_pcifront_write_config() local
838 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
935 struct hv_pcibus_device *hbus = in hv_read_config_block() local
962 ret = vmbus_sendpacket(hbus->hdev->channel, read_blk, in hv_read_config_block()
969 ret = wait_for_response(hbus->hdev, &comp_pkt.comp_pkt.host_event); in hv_read_config_block()
975 dev_err(&hbus->hdev->device, in hv_read_config_block()
1015 struct hv_pcibus_device *hbus = in hv_write_config_block() local
1052 ret = vmbus_sendpacket(hbus->hdev->channel, write_blk, pkt_size, in hv_write_config_block()
1058 ret = wait_for_response(hbus->hdev, &comp_pkt.host_event); in hv_write_config_block()
1063 dev_err(&hbus->hdev->device, in hv_write_config_block()
1085 struct hv_pcibus_device *hbus = in hv_register_block_invalidate() local
1090 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1122 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1141 struct hv_pcibus_device *hbus; in hv_msi_free() local
1149 hbus = info->data; in hv_msi_free()
1155 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1216 struct hv_pcibus_device *hbus; in hv_irq_unmask() local
1229 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_irq_unmask()
1232 dev_warn(&hbus->hdev->device, "%s() can not unmask irq %u\n", in hv_irq_unmask()
1237 spin_lock_irqsave(&hbus->retarget_msi_interrupt_lock, flags); in hv_irq_unmask()
1239 params = &hbus->retarget_msi_interrupt_params; in hv_irq_unmask()
1245 params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | in hv_irq_unmask()
1246 (hbus->hdev->dev_instance.b[4] << 16) | in hv_irq_unmask()
1247 (hbus->hdev->dev_instance.b[7] << 8) | in hv_irq_unmask()
1248 (hbus->hdev->dev_instance.b[6] & 0xf8) | in hv_irq_unmask()
1259 if (hbus->protocol_version >= PCI_PROTOCOL_VERSION_1_2) { in hv_irq_unmask()
1301 spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags); in hv_irq_unmask()
1319 if (res && hbus->state != hv_pcibus_removing) in hv_irq_unmask()
1320 dev_err(&hbus->hdev->device, in hv_irq_unmask()
1399 struct hv_pcibus_device *hbus; in hv_compose_msi_msg() local
1433 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_compose_msi_msg()
1434 channel = hbus->hdev->channel; in hv_compose_msi_msg()
1435 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1478 switch (hbus->protocol_version) { in hv_compose_msi_msg()
1501 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1506 ret = vmbus_sendpacket(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1511 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1532 dev_err_once(&hbus->hdev->device, in hv_compose_msi_msg()
1549 hv_pci_onchannelcallback(hbus); in hv_compose_msi_msg()
1558 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1609 * @hbus: The root PCI bus
1620 static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) in hv_pcie_init_irq_domain() argument
1622 hbus->msi_info.chip = &hv_msi_irq_chip; in hv_pcie_init_irq_domain()
1623 hbus->msi_info.ops = &hv_msi_ops; in hv_pcie_init_irq_domain()
1624 hbus->msi_info.flags = (MSI_FLAG_USE_DEF_DOM_OPS | in hv_pcie_init_irq_domain()
1627 hbus->msi_info.handler = handle_edge_irq; in hv_pcie_init_irq_domain()
1628 hbus->msi_info.handler_name = "edge"; in hv_pcie_init_irq_domain()
1629 hbus->msi_info.data = hbus; in hv_pcie_init_irq_domain()
1630 hbus->irq_domain = pci_msi_create_irq_domain(hbus->sysdata.fwnode, in hv_pcie_init_irq_domain()
1631 &hbus->msi_info, in hv_pcie_init_irq_domain()
1633 if (!hbus->irq_domain) { in hv_pcie_init_irq_domain()
1634 dev_err(&hbus->hdev->device, in hv_pcie_init_irq_domain()
1664 * @hbus: Root PCI bus, as understood by this driver
1666 static void survey_child_resources(struct hv_pcibus_device *hbus) in survey_child_resources() argument
1676 event = xchg(&hbus->survey_event, NULL); in survey_child_resources()
1681 if (hbus->low_mmio_space || hbus->high_mmio_space) { in survey_child_resources()
1686 spin_lock_irqsave(&hbus->device_list_lock, flags); in survey_child_resources()
1693 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
1696 dev_err(&hbus->hdev->device, in survey_child_resources()
1715 hbus->high_mmio_space += bar_size; in survey_child_resources()
1717 hbus->low_mmio_space += bar_size; in survey_child_resources()
1722 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in survey_child_resources()
1728 * @hbus: Root PCI bus, as understood by this driver
1738 static void prepopulate_bars(struct hv_pcibus_device *hbus) in prepopulate_bars() argument
1752 if (hbus->low_mmio_space) { in prepopulate_bars()
1753 low_size = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in prepopulate_bars()
1754 low_base = hbus->low_mmio_res->start; in prepopulate_bars()
1757 if (hbus->high_mmio_space) { in prepopulate_bars()
1759 (63 - __builtin_clzll(hbus->high_mmio_space)); in prepopulate_bars()
1760 high_base = hbus->high_mmio_res->start; in prepopulate_bars()
1763 spin_lock_irqsave(&hbus->device_list_lock, flags); in prepopulate_bars()
1776 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1784 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1837 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in prepopulate_bars()
1846 * same ordered workqueue. Therefore hbus->children list will not change
1849 static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) in hv_pci_assign_slots() argument
1855 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
1861 hpdev->pci_slot = pci_create_slot(hbus->pci_bus, slot_nr, in hv_pci_assign_slots()
1873 static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) in hv_pci_remove_slots() argument
1877 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
1888 static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) in hv_pci_assign_numa_node() argument
1891 struct pci_bus *bus = hbus->pci_bus; in hv_pci_assign_numa_node()
1895 hv_dev = get_pcichild_wslot(hbus, devfn_to_wslot(dev->devfn)); in hv_pci_assign_numa_node()
1917 * @hbus: Root PCI bus, as understood by this driver
1921 static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) in create_root_hv_pci_bus() argument
1924 hbus->pci_bus = pci_create_root_bus(&hbus->hdev->device, in create_root_hv_pci_bus()
1927 &hbus->sysdata, in create_root_hv_pci_bus()
1928 &hbus->resources_for_children); in create_root_hv_pci_bus()
1929 if (!hbus->pci_bus) in create_root_hv_pci_bus()
1932 hbus->pci_bus->msi = &hbus->msi_chip; in create_root_hv_pci_bus()
1933 hbus->pci_bus->msi->dev = &hbus->hdev->device; in create_root_hv_pci_bus()
1936 pci_scan_child_bus(hbus->pci_bus); in create_root_hv_pci_bus()
1937 hv_pci_assign_numa_node(hbus); in create_root_hv_pci_bus()
1938 pci_bus_assign_resources(hbus->pci_bus); in create_root_hv_pci_bus()
1939 hv_pci_assign_slots(hbus); in create_root_hv_pci_bus()
1940 pci_bus_add_devices(hbus->pci_bus); in create_root_hv_pci_bus()
1942 hbus->state = hv_pcibus_installed; in create_root_hv_pci_bus()
1969 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
1984 * @hbus: The internal struct tracking this root PCI bus.
1993 static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, in new_pcichild_device() argument
2010 hpdev->hbus = hbus; in new_pcichild_device()
2021 ret = vmbus_sendpacket(hbus->hdev->channel, res_req, in new_pcichild_device()
2029 if (wait_for_response(hbus->hdev, &comp_pkt.host_event)) in new_pcichild_device()
2035 spin_lock_irqsave(&hbus->device_list_lock, flags); in new_pcichild_device()
2037 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2038 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in new_pcichild_device()
2048 * @hbus: Root PCI bus, as understood by this driver
2059 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, in get_pcichild_wslot() argument
2065 spin_lock_irqsave(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2066 list_for_each_entry(iter, &hbus->children, list_entry) { in get_pcichild_wslot()
2073 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2099 * because both are pushed to the ordered workqueue hbus->wq.
2107 struct hv_pcibus_device *hbus; in pci_devices_present_work() local
2114 hbus = dr_wrk->bus; in pci_devices_present_work()
2120 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2121 while (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2122 dr = list_first_entry(&hbus->dr_list, struct hv_dr_state, in pci_devices_present_work()
2127 if (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2132 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2135 put_hvpcibus(hbus); in pci_devices_present_work()
2140 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2141 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2144 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2151 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2152 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2161 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2164 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2166 dev_err(&hbus->hdev->device, in pci_devices_present_work()
2172 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2175 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2184 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2198 switch (hbus->state) { in pci_devices_present_work()
2205 pci_scan_child_bus(hbus->pci_bus); in pci_devices_present_work()
2206 hv_pci_assign_numa_node(hbus); in pci_devices_present_work()
2207 hv_pci_assign_slots(hbus); in pci_devices_present_work()
2213 survey_child_resources(hbus); in pci_devices_present_work()
2220 put_hvpcibus(hbus); in pci_devices_present_work()
2226 * @hbus: Root PCI bus, as understood by this driver
2231 static int hv_pci_start_relations_work(struct hv_pcibus_device *hbus, in hv_pci_start_relations_work() argument
2238 if (hbus->state == hv_pcibus_removing) { in hv_pci_start_relations_work()
2239 dev_info(&hbus->hdev->device, in hv_pci_start_relations_work()
2249 dr_wrk->bus = hbus; in hv_pci_start_relations_work()
2251 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2257 pending_dr = !list_empty(&hbus->dr_list); in hv_pci_start_relations_work()
2258 list_add_tail(&dr->list_entry, &hbus->dr_list); in hv_pci_start_relations_work()
2259 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2264 get_hvpcibus(hbus); in hv_pci_start_relations_work()
2265 queue_work(hbus->wq, &dr_wrk->wrk); in hv_pci_start_relations_work()
2273 * @hbus: Root PCI bus, as understood by this driver
2280 static void hv_pci_devices_present(struct hv_pcibus_device *hbus, in hv_pci_devices_present() argument
2304 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present()
2310 * @hbus: Root PCI bus, as understood by this driver
2315 static void hv_pci_devices_present2(struct hv_pcibus_device *hbus, in hv_pci_devices_present2() argument
2342 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present2()
2358 struct hv_pcibus_device *hbus; in hv_eject_device_work() local
2369 hbus = hpdev->hbus; in hv_eject_device_work()
2374 * must be done without constructs like pci_domain_nr(hbus->pci_bus) in hv_eject_device_work()
2375 * because hbus->pci_bus may not exist yet. in hv_eject_device_work()
2378 pdev = pci_get_domain_bus_and_slot(hbus->sysdata.domain, 0, wslot); in hv_eject_device_work()
2386 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_eject_device_work()
2388 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_eject_device_work()
2397 vmbus_sendpacket(hbus->hdev->channel, ejct_pkt, in hv_eject_device_work()
2408 put_hvpcibus(hbus); in hv_eject_device_work()
2421 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device() local
2422 struct hv_device *hdev = hbus->hdev; in hv_pci_eject_device()
2424 if (hbus->state == hv_pcibus_removing) { in hv_pci_eject_device()
2431 get_hvpcibus(hbus); in hv_pci_eject_device()
2432 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2446 struct hv_pcibus_device *hbus = context; in hv_pci_onchannelcallback() local
2466 ret = vmbus_recvpacket_raw(hbus->hdev->channel, buffer, in hv_pci_onchannelcallback()
2515 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2520 hv_pci_devices_present(hbus, bus_rel); in hv_pci_onchannelcallback()
2529 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2534 hv_pci_devices_present2(hbus, bus_rel2); in hv_pci_onchannelcallback()
2540 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2551 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2564 dev_warn(&hbus->hdev->device, in hv_pci_onchannelcallback()
2572 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2605 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_protocol_negotiation() local
2645 hbus->protocol_version = version[i]; in hv_pci_protocol_negotiation()
2648 hbus->protocol_version); in hv_pci_protocol_negotiation()
2675 * @hbus: Root PCI bus, as understood by this driver
2677 static void hv_pci_free_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_free_bridge_windows() argument
2684 if (hbus->low_mmio_space && hbus->low_mmio_res) { in hv_pci_free_bridge_windows()
2685 hbus->low_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
2686 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_free_bridge_windows()
2687 resource_size(hbus->low_mmio_res)); in hv_pci_free_bridge_windows()
2690 if (hbus->high_mmio_space && hbus->high_mmio_res) { in hv_pci_free_bridge_windows()
2691 hbus->high_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
2692 vmbus_free_mmio(hbus->high_mmio_res->start, in hv_pci_free_bridge_windows()
2693 resource_size(hbus->high_mmio_res)); in hv_pci_free_bridge_windows()
2700 * @hbus: Root PCI bus, as understood by this driver
2722 static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_allocate_bridge_windows() argument
2727 if (hbus->low_mmio_space) { in hv_pci_allocate_bridge_windows()
2728 align = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in hv_pci_allocate_bridge_windows()
2729 ret = vmbus_allocate_mmio(&hbus->low_mmio_res, hbus->hdev, 0, in hv_pci_allocate_bridge_windows()
2731 hbus->low_mmio_space, in hv_pci_allocate_bridge_windows()
2734 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
2736 hbus->low_mmio_space); in hv_pci_allocate_bridge_windows()
2741 hbus->low_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
2742 hbus->low_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
2743 pci_add_resource(&hbus->resources_for_children, in hv_pci_allocate_bridge_windows()
2744 hbus->low_mmio_res); in hv_pci_allocate_bridge_windows()
2747 if (hbus->high_mmio_space) { in hv_pci_allocate_bridge_windows()
2748 align = 1ULL << (63 - __builtin_clzll(hbus->high_mmio_space)); in hv_pci_allocate_bridge_windows()
2749 ret = vmbus_allocate_mmio(&hbus->high_mmio_res, hbus->hdev, in hv_pci_allocate_bridge_windows()
2751 hbus->high_mmio_space, align, in hv_pci_allocate_bridge_windows()
2754 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
2756 hbus->high_mmio_space); in hv_pci_allocate_bridge_windows()
2761 hbus->high_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
2762 hbus->high_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
2763 pci_add_resource(&hbus->resources_for_children, in hv_pci_allocate_bridge_windows()
2764 hbus->high_mmio_res); in hv_pci_allocate_bridge_windows()
2770 if (hbus->low_mmio_res) { in hv_pci_allocate_bridge_windows()
2771 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_allocate_bridge_windows()
2772 resource_size(hbus->low_mmio_res)); in hv_pci_allocate_bridge_windows()
2780 * @hbus: Root PCI bus, as understood by this driver
2787 static int hv_allocate_config_window(struct hv_pcibus_device *hbus) in hv_allocate_config_window() argument
2795 ret = vmbus_allocate_mmio(&hbus->mem_config, hbus->hdev, 0, -1, in hv_allocate_config_window()
2808 hbus->mem_config->flags |= IORESOURCE_BUSY; in hv_allocate_config_window()
2813 static void hv_free_config_window(struct hv_pcibus_device *hbus) in hv_free_config_window() argument
2815 vmbus_free_mmio(hbus->mem_config->start, PCI_CONFIG_MMIO_LENGTH); in hv_free_config_window()
2828 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_enter_d0() local
2851 d0_entry->mmio_base = hbus->mem_config->start; in hv_pci_enter_d0()
2882 hbus->wslot_res_allocated = 255; in hv_pci_enter_d0()
2918 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_query_relations() local
2925 if (cmpxchg(&hbus->survey_event, NULL, &comp)) in hv_pci_query_relations()
2940 * channel callback already scheduled a work to hbus->wq, which can be in hv_pci_query_relations()
2942 * complete(&hbus->survey_event), even after hv_pci_query_relations() in hv_pci_query_relations()
2945 * raw_spin_lock_irqsave(). Flush hbus->wq before we exit from in hv_pci_query_relations()
2947 * -ENODEV, there can't be any more work item scheduled to hbus->wq in hv_pci_query_relations()
2952 flush_workqueue(hbus->wq); in hv_pci_query_relations()
2976 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_allocated() local
2986 size_res = (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) in hv_send_resources_allocated()
2996 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
3005 if (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) { in hv_send_resources_allocated()
3037 hbus->wslot_res_allocated = wslot; in hv_send_resources_allocated()
3053 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_released() local
3059 for (wslot = hbus->wslot_res_allocated; wslot >= 0; wslot--) { in hv_send_resources_released()
3060 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3075 hbus->wslot_res_allocated = wslot - 1; in hv_send_resources_released()
3078 hbus->wslot_res_allocated = -1; in hv_send_resources_released()
3083 static void get_hvpcibus(struct hv_pcibus_device *hbus) in get_hvpcibus() argument
3085 refcount_inc(&hbus->remove_lock); in get_hvpcibus()
3088 static void put_hvpcibus(struct hv_pcibus_device *hbus) in put_hvpcibus() argument
3090 if (refcount_dec_and_test(&hbus->remove_lock)) in put_hvpcibus()
3091 complete(&hbus->remove_event); in put_hvpcibus()
3146 struct hv_pcibus_device *hbus; in hv_pci_probe() local
3155 BUILD_BUG_ON(sizeof(*hbus) > HV_HYP_PAGE_SIZE); in hv_pci_probe()
3161 * alignment of hbus is important because hbus's field in hv_pci_probe()
3166 * hence kmemleak reports the pointer contained in the hbus buffer in hv_pci_probe()
3168 * is tracked by hbus->children) as memory leak (false positive). in hv_pci_probe()
3171 * used to allocate the hbus buffer and we can avoid the kmemleak false in hv_pci_probe()
3173 * kmemleak to track and scan the hbus buffer. in hv_pci_probe()
3175 hbus = kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); in hv_pci_probe()
3176 if (!hbus) in hv_pci_probe()
3178 hbus->state = hv_pcibus_init; in hv_pci_probe()
3179 hbus->wslot_res_allocated = -1; in hv_pci_probe()
3209 hbus->sysdata.domain = dom; in hv_pci_probe()
3211 hbus->hdev = hdev; in hv_pci_probe()
3212 refcount_set(&hbus->remove_lock, 1); in hv_pci_probe()
3213 INIT_LIST_HEAD(&hbus->children); in hv_pci_probe()
3214 INIT_LIST_HEAD(&hbus->dr_list); in hv_pci_probe()
3215 INIT_LIST_HEAD(&hbus->resources_for_children); in hv_pci_probe()
3216 spin_lock_init(&hbus->config_lock); in hv_pci_probe()
3217 spin_lock_init(&hbus->device_list_lock); in hv_pci_probe()
3218 spin_lock_init(&hbus->retarget_msi_interrupt_lock); in hv_pci_probe()
3219 init_completion(&hbus->remove_event); in hv_pci_probe()
3220 hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, in hv_pci_probe()
3221 hbus->sysdata.domain); in hv_pci_probe()
3222 if (!hbus->wq) { in hv_pci_probe()
3228 hv_pci_onchannelcallback, hbus); in hv_pci_probe()
3232 hv_set_drvdata(hdev, hbus); in hv_pci_probe()
3239 ret = hv_allocate_config_window(hbus); in hv_pci_probe()
3243 hbus->cfg_addr = ioremap(hbus->mem_config->start, in hv_pci_probe()
3245 if (!hbus->cfg_addr) { in hv_pci_probe()
3258 hbus->sysdata.fwnode = irq_domain_alloc_named_fwnode(name); in hv_pci_probe()
3260 if (!hbus->sysdata.fwnode) { in hv_pci_probe()
3265 ret = hv_pcie_init_irq_domain(hbus); in hv_pci_probe()
3277 ret = hv_pci_allocate_bridge_windows(hbus); in hv_pci_probe()
3285 prepopulate_bars(hbus); in hv_pci_probe()
3287 hbus->state = hv_pcibus_probed; in hv_pci_probe()
3289 ret = create_root_hv_pci_bus(hbus); in hv_pci_probe()
3296 hv_pci_free_bridge_windows(hbus); in hv_pci_probe()
3300 irq_domain_remove(hbus->irq_domain); in hv_pci_probe()
3302 irq_domain_free_fwnode(hbus->sysdata.fwnode); in hv_pci_probe()
3304 iounmap(hbus->cfg_addr); in hv_pci_probe()
3306 hv_free_config_window(hbus); in hv_pci_probe()
3310 destroy_workqueue(hbus->wq); in hv_pci_probe()
3312 hv_put_dom_num(hbus->sysdata.domain); in hv_pci_probe()
3314 kfree(hbus); in hv_pci_probe()
3320 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_bus_exit() local
3342 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3343 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3345 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3393 struct hv_pcibus_device *hbus; in hv_pci_remove() local
3396 hbus = hv_get_drvdata(hdev); in hv_pci_remove()
3397 if (hbus->state == hv_pcibus_installed) { in hv_pci_remove()
3399 hbus->state = hv_pcibus_removing; in hv_pci_remove()
3401 destroy_workqueue(hbus->wq); in hv_pci_remove()
3402 hbus->wq = NULL; in hv_pci_remove()
3405 * on hbus-wq. We can't race with hv_pci_devices_present() in hv_pci_remove()
3411 pci_stop_root_bus(hbus->pci_bus); in hv_pci_remove()
3412 hv_pci_remove_slots(hbus); in hv_pci_remove()
3413 pci_remove_root_bus(hbus->pci_bus); in hv_pci_remove()
3421 iounmap(hbus->cfg_addr); in hv_pci_remove()
3422 hv_free_config_window(hbus); in hv_pci_remove()
3423 pci_free_resource_list(&hbus->resources_for_children); in hv_pci_remove()
3424 hv_pci_free_bridge_windows(hbus); in hv_pci_remove()
3425 irq_domain_remove(hbus->irq_domain); in hv_pci_remove()
3426 irq_domain_free_fwnode(hbus->sysdata.fwnode); in hv_pci_remove()
3427 put_hvpcibus(hbus); in hv_pci_remove()
3428 wait_for_completion(&hbus->remove_event); in hv_pci_remove()
3430 hv_put_dom_num(hbus->sysdata.domain); in hv_pci_remove()
3432 kfree(hbus); in hv_pci_remove()
3438 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_suspend() local
3448 * items onto hbus->wq in hv_pci_devices_present() and in hv_pci_suspend()
3455 * callback tasklet, sets hbus->state to hv_pcibus_removing, and in hv_pci_suspend()
3458 * hbus->wq and safely closes the vmbus channel. in hv_pci_suspend()
3462 /* Change the hbus state to prevent new work items. */ in hv_pci_suspend()
3463 old_state = hbus->state; in hv_pci_suspend()
3464 if (hbus->state == hv_pcibus_installed) in hv_pci_suspend()
3465 hbus->state = hv_pcibus_removing; in hv_pci_suspend()
3472 flush_workqueue(hbus->wq); in hv_pci_suspend()
3506 static void hv_pci_restore_msi_state(struct hv_pcibus_device *hbus) in hv_pci_restore_msi_state() argument
3508 pci_walk_bus(hbus->pci_bus, hv_pci_restore_msi_msg, NULL); in hv_pci_restore_msi_state()
3513 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_resume() local
3517 hbus->state = hv_pcibus_init; in hv_pci_resume()
3520 hv_pci_onchannelcallback, hbus); in hv_pci_resume()
3525 version[0] = hbus->protocol_version; in hv_pci_resume()
3542 prepopulate_bars(hbus); in hv_pci_resume()
3544 hv_pci_restore_msi_state(hbus); in hv_pci_resume()
3546 hbus->state = hv_pcibus_installed; in hv_pci_resume()