Lines Matching full:hbus
572 struct hv_pcibus_device *hbus; member
644 struct hv_pcibus_device *hbus; in hv_arch_irq_unmask() local
657 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_arch_irq_unmask()
660 spin_lock_irqsave(&hbus->retarget_msi_interrupt_lock, flags); in hv_arch_irq_unmask()
662 params = &hbus->retarget_msi_interrupt_params; in hv_arch_irq_unmask()
668 params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | in hv_arch_irq_unmask()
669 (hbus->hdev->dev_instance.b[4] << 16) | in hv_arch_irq_unmask()
670 (hbus->hdev->dev_instance.b[7] << 8) | in hv_arch_irq_unmask()
671 (hbus->hdev->dev_instance.b[6] & 0xf8) | in hv_arch_irq_unmask()
682 if (hbus->protocol_version >= PCI_PROTOCOL_VERSION_1_2) { in hv_arch_irq_unmask()
724 spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags); in hv_arch_irq_unmask()
742 if (!hv_result_success(res) && hbus->state != hv_pcibus_removing) in hv_arch_irq_unmask()
743 dev_err(&hbus->hdev->device, in hv_arch_irq_unmask()
988 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus,
1076 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_read_config()
1104 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
1106 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_read_config()
1126 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
1128 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_read_config()
1137 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
1140 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1143 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in hv_pcifront_get_vendor_id()
1153 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1169 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_write_config()
1175 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
1177 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_write_config()
1197 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
1199 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_write_config()
1218 struct hv_pcibus_device *hbus = in hv_pcifront_read_config() local
1222 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
1246 struct hv_pcibus_device *hbus = in hv_pcifront_write_config() local
1250 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
1347 struct hv_pcibus_device *hbus = in hv_read_config_block() local
1374 ret = vmbus_sendpacket(hbus->hdev->channel, read_blk, in hv_read_config_block()
1381 ret = wait_for_response(hbus->hdev, &comp_pkt.comp_pkt.host_event); in hv_read_config_block()
1387 dev_err(&hbus->hdev->device, in hv_read_config_block()
1427 struct hv_pcibus_device *hbus = in hv_write_config_block() local
1464 ret = vmbus_sendpacket(hbus->hdev->channel, write_blk, pkt_size, in hv_write_config_block()
1470 ret = wait_for_response(hbus->hdev, &comp_pkt.host_event); in hv_write_config_block()
1475 dev_err(&hbus->hdev->device, in hv_write_config_block()
1497 struct hv_pcibus_device *hbus = in hv_register_block_invalidate() local
1502 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1534 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1553 struct hv_pcibus_device *hbus; in hv_msi_free() local
1561 hbus = info->data; in hv_msi_free()
1567 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1742 struct hv_pcibus_device *hbus; in hv_compose_msi_msg() local
1787 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_compose_msi_msg()
1788 channel = hbus->hdev->channel; in hv_compose_msi_msg()
1789 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1846 switch (hbus->protocol_version) { in hv_compose_msi_msg()
1876 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1881 ret = vmbus_sendpacket_getid(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1886 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1907 dev_err_once(&hbus->hdev->device, in hv_compose_msi_msg()
1924 hv_pci_onchannelcallback(hbus); in hv_compose_msi_msg()
1928 dev_err_once(&hbus->hdev->device, in hv_compose_msi_msg()
1939 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
2003 * @hbus: The root PCI bus
2014 static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) in hv_pcie_init_irq_domain() argument
2016 hbus->msi_info.chip = &hv_msi_irq_chip; in hv_pcie_init_irq_domain()
2017 hbus->msi_info.ops = &hv_msi_ops; in hv_pcie_init_irq_domain()
2018 hbus->msi_info.flags = (MSI_FLAG_USE_DEF_DOM_OPS | in hv_pcie_init_irq_domain()
2021 hbus->msi_info.handler = FLOW_HANDLER; in hv_pcie_init_irq_domain()
2022 hbus->msi_info.handler_name = FLOW_NAME; in hv_pcie_init_irq_domain()
2023 hbus->msi_info.data = hbus; in hv_pcie_init_irq_domain()
2024 hbus->irq_domain = pci_msi_create_irq_domain(hbus->fwnode, in hv_pcie_init_irq_domain()
2025 &hbus->msi_info, in hv_pcie_init_irq_domain()
2027 if (!hbus->irq_domain) { in hv_pcie_init_irq_domain()
2028 dev_err(&hbus->hdev->device, in hv_pcie_init_irq_domain()
2033 dev_set_msi_domain(&hbus->bridge->dev, hbus->irq_domain); in hv_pcie_init_irq_domain()
2060 * @hbus: Root PCI bus, as understood by this driver
2062 static void survey_child_resources(struct hv_pcibus_device *hbus) in survey_child_resources() argument
2072 event = xchg(&hbus->survey_event, NULL); in survey_child_resources()
2077 if (hbus->low_mmio_space || hbus->high_mmio_space) { in survey_child_resources()
2082 spin_lock_irqsave(&hbus->device_list_lock, flags); in survey_child_resources()
2089 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
2092 dev_err(&hbus->hdev->device, in survey_child_resources()
2111 hbus->high_mmio_space += bar_size; in survey_child_resources()
2113 hbus->low_mmio_space += bar_size; in survey_child_resources()
2118 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in survey_child_resources()
2124 * @hbus: Root PCI bus, as understood by this driver
2134 static void prepopulate_bars(struct hv_pcibus_device *hbus) in prepopulate_bars() argument
2148 if (hbus->low_mmio_space) { in prepopulate_bars()
2149 low_size = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in prepopulate_bars()
2150 low_base = hbus->low_mmio_res->start; in prepopulate_bars()
2153 if (hbus->high_mmio_space) { in prepopulate_bars()
2155 (63 - __builtin_clzll(hbus->high_mmio_space)); in prepopulate_bars()
2156 high_base = hbus->high_mmio_res->start; in prepopulate_bars()
2159 spin_lock_irqsave(&hbus->device_list_lock, flags); in prepopulate_bars()
2172 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2180 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2238 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in prepopulate_bars()
2247 * same ordered workqueue. Therefore hbus->children list will not change
2250 static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) in hv_pci_assign_slots() argument
2256 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
2262 hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, in hv_pci_assign_slots()
2274 static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) in hv_pci_remove_slots() argument
2278 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
2289 static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) in hv_pci_assign_numa_node() argument
2292 struct pci_bus *bus = hbus->bridge->bus; in hv_pci_assign_numa_node()
2296 hv_dev = get_pcichild_wslot(hbus, devfn_to_wslot(dev->devfn)); in hv_pci_assign_numa_node()
2318 * @hbus: Root PCI bus, as understood by this driver
2322 static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) in create_root_hv_pci_bus() argument
2325 struct pci_host_bridge *bridge = hbus->bridge; in create_root_hv_pci_bus()
2327 bridge->dev.parent = &hbus->hdev->device; in create_root_hv_pci_bus()
2328 bridge->sysdata = &hbus->sysdata; in create_root_hv_pci_bus()
2336 hv_pci_assign_numa_node(hbus); in create_root_hv_pci_bus()
2338 hv_pci_assign_slots(hbus); in create_root_hv_pci_bus()
2341 hbus->state = hv_pcibus_installed; in create_root_hv_pci_bus()
2370 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
2385 * @hbus: The internal struct tracking this root PCI bus.
2394 static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, in new_pcichild_device() argument
2411 hpdev->hbus = hbus; in new_pcichild_device()
2422 ret = vmbus_sendpacket(hbus->hdev->channel, res_req, in new_pcichild_device()
2430 if (wait_for_response(hbus->hdev, &comp_pkt.host_event)) in new_pcichild_device()
2436 spin_lock_irqsave(&hbus->device_list_lock, flags); in new_pcichild_device()
2438 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2439 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in new_pcichild_device()
2449 * @hbus: Root PCI bus, as understood by this driver
2460 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, in get_pcichild_wslot() argument
2466 spin_lock_irqsave(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2467 list_for_each_entry(iter, &hbus->children, list_entry) { in get_pcichild_wslot()
2474 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2500 * because both are pushed to the ordered workqueue hbus->wq.
2508 struct hv_pcibus_device *hbus; in pci_devices_present_work() local
2515 hbus = dr_wrk->bus; in pci_devices_present_work()
2521 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2522 while (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2523 dr = list_first_entry(&hbus->dr_list, struct hv_dr_state, in pci_devices_present_work()
2528 if (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2533 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2539 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2540 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2543 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2550 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2551 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2560 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2563 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2565 dev_err(&hbus->hdev->device, in pci_devices_present_work()
2571 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2574 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2583 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2597 switch (hbus->state) { in pci_devices_present_work()
2604 pci_scan_child_bus(hbus->bridge->bus); in pci_devices_present_work()
2605 hv_pci_assign_numa_node(hbus); in pci_devices_present_work()
2606 hv_pci_assign_slots(hbus); in pci_devices_present_work()
2612 survey_child_resources(hbus); in pci_devices_present_work()
2624 * @hbus: Root PCI bus, as understood by this driver
2629 static int hv_pci_start_relations_work(struct hv_pcibus_device *hbus, in hv_pci_start_relations_work() argument
2636 if (hbus->state == hv_pcibus_removing) { in hv_pci_start_relations_work()
2637 dev_info(&hbus->hdev->device, in hv_pci_start_relations_work()
2647 dr_wrk->bus = hbus; in hv_pci_start_relations_work()
2649 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2655 pending_dr = !list_empty(&hbus->dr_list); in hv_pci_start_relations_work()
2656 list_add_tail(&dr->list_entry, &hbus->dr_list); in hv_pci_start_relations_work()
2657 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2662 queue_work(hbus->wq, &dr_wrk->wrk); in hv_pci_start_relations_work()
2669 * @hbus: Root PCI bus, as understood by this driver
2676 static void hv_pci_devices_present(struct hv_pcibus_device *hbus, in hv_pci_devices_present() argument
2700 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present()
2706 * @hbus: Root PCI bus, as understood by this driver
2711 static void hv_pci_devices_present2(struct hv_pcibus_device *hbus, in hv_pci_devices_present2() argument
2738 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present2()
2754 struct hv_pcibus_device *hbus; in hv_eject_device_work() local
2765 hbus = hpdev->hbus; in hv_eject_device_work()
2772 * must be done without constructs like pci_domain_nr(hbus->bridge->bus) in hv_eject_device_work()
2773 * because hbus->bridge->bus may not exist yet. in hv_eject_device_work()
2776 pdev = pci_get_domain_bus_and_slot(hbus->bridge->domain_nr, 0, wslot); in hv_eject_device_work()
2784 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_eject_device_work()
2786 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_eject_device_work()
2795 vmbus_sendpacket(hbus->hdev->channel, ejct_pkt, in hv_eject_device_work()
2817 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device() local
2818 struct hv_device *hdev = hbus->hdev; in hv_pci_eject_device()
2820 if (hbus->state == hv_pcibus_removing) { in hv_pci_eject_device()
2828 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2842 struct hv_pcibus_device *hbus = context; in hv_pci_onchannelcallback() local
2843 struct vmbus_channel *chan = hbus->hdev->channel; in hv_pci_onchannelcallback()
2897 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2928 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2933 hv_pci_devices_present(hbus, bus_rel); in hv_pci_onchannelcallback()
2943 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2948 hv_pci_devices_present2(hbus, bus_rel2); in hv_pci_onchannelcallback()
2955 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2959 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2971 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2975 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2988 dev_warn(&hbus->hdev->device, in hv_pci_onchannelcallback()
2996 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3029 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_protocol_negotiation() local
3069 hbus->protocol_version = version[i]; in hv_pci_protocol_negotiation()
3072 hbus->protocol_version); in hv_pci_protocol_negotiation()
3099 * @hbus: Root PCI bus, as understood by this driver
3101 static void hv_pci_free_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_free_bridge_windows() argument
3108 if (hbus->low_mmio_space && hbus->low_mmio_res) { in hv_pci_free_bridge_windows()
3109 hbus->low_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3110 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_free_bridge_windows()
3111 resource_size(hbus->low_mmio_res)); in hv_pci_free_bridge_windows()
3114 if (hbus->high_mmio_space && hbus->high_mmio_res) { in hv_pci_free_bridge_windows()
3115 hbus->high_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3116 vmbus_free_mmio(hbus->high_mmio_res->start, in hv_pci_free_bridge_windows()
3117 resource_size(hbus->high_mmio_res)); in hv_pci_free_bridge_windows()
3124 * @hbus: Root PCI bus, as understood by this driver
3146 static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_allocate_bridge_windows() argument
3151 if (hbus->low_mmio_space) { in hv_pci_allocate_bridge_windows()
3152 align = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in hv_pci_allocate_bridge_windows()
3153 ret = vmbus_allocate_mmio(&hbus->low_mmio_res, hbus->hdev, 0, in hv_pci_allocate_bridge_windows()
3155 hbus->low_mmio_space, in hv_pci_allocate_bridge_windows()
3158 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3160 hbus->low_mmio_space); in hv_pci_allocate_bridge_windows()
3165 hbus->low_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3166 hbus->low_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3167 pci_add_resource(&hbus->bridge->windows, hbus->low_mmio_res); in hv_pci_allocate_bridge_windows()
3170 if (hbus->high_mmio_space) { in hv_pci_allocate_bridge_windows()
3171 align = 1ULL << (63 - __builtin_clzll(hbus->high_mmio_space)); in hv_pci_allocate_bridge_windows()
3172 ret = vmbus_allocate_mmio(&hbus->high_mmio_res, hbus->hdev, in hv_pci_allocate_bridge_windows()
3174 hbus->high_mmio_space, align, in hv_pci_allocate_bridge_windows()
3177 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3179 hbus->high_mmio_space); in hv_pci_allocate_bridge_windows()
3184 hbus->high_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3185 hbus->high_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3186 pci_add_resource(&hbus->bridge->windows, hbus->high_mmio_res); in hv_pci_allocate_bridge_windows()
3192 if (hbus->low_mmio_res) { in hv_pci_allocate_bridge_windows()
3193 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_allocate_bridge_windows()
3194 resource_size(hbus->low_mmio_res)); in hv_pci_allocate_bridge_windows()
3202 * @hbus: Root PCI bus, as understood by this driver
3209 static int hv_allocate_config_window(struct hv_pcibus_device *hbus) in hv_allocate_config_window() argument
3217 ret = vmbus_allocate_mmio(&hbus->mem_config, hbus->hdev, 0, -1, in hv_allocate_config_window()
3230 hbus->mem_config->flags |= IORESOURCE_BUSY; in hv_allocate_config_window()
3235 static void hv_free_config_window(struct hv_pcibus_device *hbus) in hv_free_config_window() argument
3237 vmbus_free_mmio(hbus->mem_config->start, PCI_CONFIG_MMIO_LENGTH); in hv_free_config_window()
3250 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_enter_d0() local
3271 d0_entry->mmio_base = hbus->mem_config->start; in hv_pci_enter_d0()
3306 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_query_relations() local
3313 if (cmpxchg(&hbus->survey_event, NULL, &comp)) in hv_pci_query_relations()
3346 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_allocated() local
3356 size_res = (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) in hv_send_resources_allocated()
3366 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
3375 if (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) { in hv_send_resources_allocated()
3407 hbus->wslot_res_allocated = wslot; in hv_send_resources_allocated()
3423 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_released() local
3429 for (wslot = hbus->wslot_res_allocated; wslot >= 0; wslot--) { in hv_send_resources_released()
3430 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3445 hbus->wslot_res_allocated = wslot - 1; in hv_send_resources_released()
3448 hbus->wslot_res_allocated = -1; in hv_send_resources_released()
3506 struct hv_pcibus_device *hbus; in hv_pci_probe() local
3516 BUILD_BUG_ON(sizeof(*hbus) > HV_HYP_PAGE_SIZE); in hv_pci_probe()
3526 * alignment of hbus is important because hbus's field in hv_pci_probe()
3531 * hence kmemleak reports the pointer contained in the hbus buffer in hv_pci_probe()
3533 * is tracked by hbus->children) as memory leak (false positive). in hv_pci_probe()
3536 * used to allocate the hbus buffer and we can avoid the kmemleak false in hv_pci_probe()
3538 * kmemleak to track and scan the hbus buffer. in hv_pci_probe()
3540 hbus = kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); in hv_pci_probe()
3541 if (!hbus) in hv_pci_probe()
3544 hbus->bridge = bridge; in hv_pci_probe()
3545 hbus->state = hv_pcibus_init; in hv_pci_probe()
3546 hbus->wslot_res_allocated = -1; in hv_pci_probe()
3576 hbus->bridge->domain_nr = dom; in hv_pci_probe()
3578 hbus->sysdata.domain = dom; in hv_pci_probe()
3587 hbus->sysdata.parent = hdev->device.parent; in hv_pci_probe()
3590 hbus->hdev = hdev; in hv_pci_probe()
3591 INIT_LIST_HEAD(&hbus->children); in hv_pci_probe()
3592 INIT_LIST_HEAD(&hbus->dr_list); in hv_pci_probe()
3593 spin_lock_init(&hbus->config_lock); in hv_pci_probe()
3594 spin_lock_init(&hbus->device_list_lock); in hv_pci_probe()
3595 spin_lock_init(&hbus->retarget_msi_interrupt_lock); in hv_pci_probe()
3596 hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, in hv_pci_probe()
3597 hbus->bridge->domain_nr); in hv_pci_probe()
3598 if (!hbus->wq) { in hv_pci_probe()
3608 hv_pci_onchannelcallback, hbus); in hv_pci_probe()
3612 hv_set_drvdata(hdev, hbus); in hv_pci_probe()
3619 ret = hv_allocate_config_window(hbus); in hv_pci_probe()
3623 hbus->cfg_addr = ioremap(hbus->mem_config->start, in hv_pci_probe()
3625 if (!hbus->cfg_addr) { in hv_pci_probe()
3638 hbus->fwnode = irq_domain_alloc_named_fwnode(name); in hv_pci_probe()
3640 if (!hbus->fwnode) { in hv_pci_probe()
3645 ret = hv_pcie_init_irq_domain(hbus); in hv_pci_probe()
3681 hbus->wslot_res_allocated = 255; in hv_pci_probe()
3693 ret = hv_pci_allocate_bridge_windows(hbus); in hv_pci_probe()
3701 prepopulate_bars(hbus); in hv_pci_probe()
3703 hbus->state = hv_pcibus_probed; in hv_pci_probe()
3705 ret = create_root_hv_pci_bus(hbus); in hv_pci_probe()
3712 hv_pci_free_bridge_windows(hbus); in hv_pci_probe()
3716 irq_domain_remove(hbus->irq_domain); in hv_pci_probe()
3718 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_probe()
3720 iounmap(hbus->cfg_addr); in hv_pci_probe()
3722 hv_free_config_window(hbus); in hv_pci_probe()
3726 destroy_workqueue(hbus->wq); in hv_pci_probe()
3728 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_probe()
3730 kfree(hbus); in hv_pci_probe()
3736 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_bus_exit() local
3760 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3761 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3763 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3821 struct hv_pcibus_device *hbus; in hv_pci_remove() local
3824 hbus = hv_get_drvdata(hdev); in hv_pci_remove()
3825 if (hbus->state == hv_pcibus_installed) { in hv_pci_remove()
3827 hbus->state = hv_pcibus_removing; in hv_pci_remove()
3829 destroy_workqueue(hbus->wq); in hv_pci_remove()
3830 hbus->wq = NULL; in hv_pci_remove()
3833 * on hbus-wq. We can't race with hv_pci_devices_present() in hv_pci_remove()
3839 pci_stop_root_bus(hbus->bridge->bus); in hv_pci_remove()
3840 hv_pci_remove_slots(hbus); in hv_pci_remove()
3841 pci_remove_root_bus(hbus->bridge->bus); in hv_pci_remove()
3849 iounmap(hbus->cfg_addr); in hv_pci_remove()
3850 hv_free_config_window(hbus); in hv_pci_remove()
3851 hv_pci_free_bridge_windows(hbus); in hv_pci_remove()
3852 irq_domain_remove(hbus->irq_domain); in hv_pci_remove()
3853 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_remove()
3855 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_remove()
3857 kfree(hbus); in hv_pci_remove()
3863 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_suspend() local
3873 * items onto hbus->wq in hv_pci_devices_present() and in hv_pci_suspend()
3880 * callback tasklet, sets hbus->state to hv_pcibus_removing, and in hv_pci_suspend()
3883 * hbus->wq and safely closes the vmbus channel. in hv_pci_suspend()
3887 /* Change the hbus state to prevent new work items. */ in hv_pci_suspend()
3888 old_state = hbus->state; in hv_pci_suspend()
3889 if (hbus->state == hv_pcibus_installed) in hv_pci_suspend()
3890 hbus->state = hv_pcibus_removing; in hv_pci_suspend()
3897 flush_workqueue(hbus->wq); in hv_pci_suspend()
3936 static void hv_pci_restore_msi_state(struct hv_pcibus_device *hbus) in hv_pci_restore_msi_state() argument
3938 pci_walk_bus(hbus->bridge->bus, hv_pci_restore_msi_msg, NULL); in hv_pci_restore_msi_state()
3943 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_resume() local
3947 hbus->state = hv_pcibus_init; in hv_pci_resume()
3954 hv_pci_onchannelcallback, hbus); in hv_pci_resume()
3959 version[0] = hbus->protocol_version; in hv_pci_resume()
3976 prepopulate_bars(hbus); in hv_pci_resume()
3978 hv_pci_restore_msi_state(hbus); in hv_pci_resume()
3980 hbus->state = hv_pcibus_installed; in hv_pci_resume()