Lines Matching full:hbus
559 struct hv_pcibus_device *hbus; member
618 struct hv_pcibus_device *hbus; in hv_arch_irq_unmask() local
631 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_arch_irq_unmask()
634 dev_warn(&hbus->hdev->device, "%s() can not unmask irq %u\n", in hv_arch_irq_unmask()
647 params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | in hv_arch_irq_unmask()
648 (hbus->hdev->dev_instance.b[4] << 16) | in hv_arch_irq_unmask()
649 (hbus->hdev->dev_instance.b[7] << 8) | in hv_arch_irq_unmask()
650 (hbus->hdev->dev_instance.b[6] & 0xf8) | in hv_arch_irq_unmask()
654 if (hbus->protocol_version >= PCI_PROTOCOL_VERSION_1_2) { in hv_arch_irq_unmask()
714 if (!hv_result_success(res) && hbus->state != hv_pcibus_removing) in hv_arch_irq_unmask()
715 dev_err(&hbus->hdev->device, in hv_arch_irq_unmask()
960 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus,
1111 struct hv_pcibus_device *hbus = hpdev->hbus; in _hv_pcifront_read_config() local
1112 struct device *dev = &hbus->hdev->device; in _hv_pcifront_read_config()
1143 spin_lock_irqsave(&hbus->config_lock, flags); in _hv_pcifront_read_config()
1144 if (hbus->use_calls) { in _hv_pcifront_read_config()
1145 phys_addr_t addr = hbus->mem_config->start + offset; in _hv_pcifront_read_config()
1147 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in _hv_pcifront_read_config()
1151 void __iomem *addr = hbus->cfg_addr + offset; in _hv_pcifront_read_config()
1154 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in _hv_pcifront_read_config()
1175 spin_unlock_irqrestore(&hbus->config_lock, flags); in _hv_pcifront_read_config()
1183 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pcifront_get_vendor_id() local
1184 struct device *dev = &hbus->hdev->device; in hv_pcifront_get_vendor_id()
1189 spin_lock_irqsave(&hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1191 if (hbus->use_calls) { in hv_pcifront_get_vendor_id()
1192 phys_addr_t addr = hbus->mem_config->start + in hv_pcifront_get_vendor_id()
1195 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in hv_pcifront_get_vendor_id()
1200 void __iomem *addr = hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
1203 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in hv_pcifront_get_vendor_id()
1214 spin_unlock_irqrestore(&hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1229 struct hv_pcibus_device *hbus = hpdev->hbus; in _hv_pcifront_write_config() local
1230 struct device *dev = &hbus->hdev->device; in _hv_pcifront_write_config()
1238 spin_lock_irqsave(&hbus->config_lock, flags); in _hv_pcifront_write_config()
1240 if (hbus->use_calls) { in _hv_pcifront_write_config()
1241 phys_addr_t addr = hbus->mem_config->start + offset; in _hv_pcifront_write_config()
1243 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in _hv_pcifront_write_config()
1247 void __iomem *addr = hbus->cfg_addr + offset; in _hv_pcifront_write_config()
1250 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in _hv_pcifront_write_config()
1271 spin_unlock_irqrestore(&hbus->config_lock, flags); in _hv_pcifront_write_config()
1291 struct hv_pcibus_device *hbus = in hv_pcifront_read_config() local
1295 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
1319 struct hv_pcibus_device *hbus = in hv_pcifront_write_config() local
1323 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
1420 struct hv_pcibus_device *hbus = in hv_read_config_block() local
1447 ret = vmbus_sendpacket(hbus->hdev->channel, read_blk, in hv_read_config_block()
1454 ret = wait_for_response(hbus->hdev, &comp_pkt.comp_pkt.host_event); in hv_read_config_block()
1460 dev_err(&hbus->hdev->device, in hv_read_config_block()
1500 struct hv_pcibus_device *hbus = in hv_write_config_block() local
1537 ret = vmbus_sendpacket(hbus->hdev->channel, write_blk, pkt_size, in hv_write_config_block()
1543 ret = wait_for_response(hbus->hdev, &comp_pkt.host_event); in hv_write_config_block()
1548 dev_err(&hbus->hdev->device, in hv_write_config_block()
1570 struct hv_pcibus_device *hbus = in hv_register_block_invalidate() local
1575 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1607 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1626 struct hv_pcibus_device *hbus; in hv_msi_free() local
1634 hbus = info->data; in hv_msi_free()
1640 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1815 struct hv_pcibus_device *hbus; in hv_compose_msi_msg() local
1860 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_compose_msi_msg()
1861 channel = hbus->hdev->channel; in hv_compose_msi_msg()
1862 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1919 switch (hbus->protocol_version) { in hv_compose_msi_msg()
1949 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1954 ret = vmbus_sendpacket_getid(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1959 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1980 dev_err_once(&hbus->hdev->device, in hv_compose_msi_msg()
1997 hv_pci_onchannelcallback(hbus); in hv_compose_msi_msg()
2006 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
2070 * @hbus: The root PCI bus
2081 static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) in hv_pcie_init_irq_domain() argument
2083 hbus->msi_info.chip = &hv_msi_irq_chip; in hv_pcie_init_irq_domain()
2084 hbus->msi_info.ops = &hv_msi_ops; in hv_pcie_init_irq_domain()
2085 hbus->msi_info.flags = (MSI_FLAG_USE_DEF_DOM_OPS | in hv_pcie_init_irq_domain()
2088 hbus->msi_info.handler = FLOW_HANDLER; in hv_pcie_init_irq_domain()
2089 hbus->msi_info.handler_name = FLOW_NAME; in hv_pcie_init_irq_domain()
2090 hbus->msi_info.data = hbus; in hv_pcie_init_irq_domain()
2091 hbus->irq_domain = pci_msi_create_irq_domain(hbus->fwnode, in hv_pcie_init_irq_domain()
2092 &hbus->msi_info, in hv_pcie_init_irq_domain()
2094 if (!hbus->irq_domain) { in hv_pcie_init_irq_domain()
2095 dev_err(&hbus->hdev->device, in hv_pcie_init_irq_domain()
2100 dev_set_msi_domain(&hbus->bridge->dev, hbus->irq_domain); in hv_pcie_init_irq_domain()
2127 * @hbus: Root PCI bus, as understood by this driver
2129 static void survey_child_resources(struct hv_pcibus_device *hbus) in survey_child_resources() argument
2139 event = xchg(&hbus->survey_event, NULL); in survey_child_resources()
2144 if (hbus->low_mmio_space || hbus->high_mmio_space) { in survey_child_resources()
2149 spin_lock_irqsave(&hbus->device_list_lock, flags); in survey_child_resources()
2156 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
2159 dev_err(&hbus->hdev->device, in survey_child_resources()
2178 hbus->high_mmio_space += bar_size; in survey_child_resources()
2180 hbus->low_mmio_space += bar_size; in survey_child_resources()
2185 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in survey_child_resources()
2191 * @hbus: Root PCI bus, as understood by this driver
2201 static void prepopulate_bars(struct hv_pcibus_device *hbus) in prepopulate_bars() argument
2215 if (hbus->low_mmio_space) { in prepopulate_bars()
2216 low_size = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in prepopulate_bars()
2217 low_base = hbus->low_mmio_res->start; in prepopulate_bars()
2220 if (hbus->high_mmio_space) { in prepopulate_bars()
2222 (63 - __builtin_clzll(hbus->high_mmio_space)); in prepopulate_bars()
2223 high_base = hbus->high_mmio_res->start; in prepopulate_bars()
2226 spin_lock_irqsave(&hbus->device_list_lock, flags); in prepopulate_bars()
2239 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2247 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2305 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in prepopulate_bars()
2314 * same ordered workqueue. Therefore hbus->children list will not change
2317 static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) in hv_pci_assign_slots() argument
2323 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
2329 hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, in hv_pci_assign_slots()
2341 static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) in hv_pci_remove_slots() argument
2345 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
2356 static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) in hv_pci_assign_numa_node() argument
2359 struct pci_bus *bus = hbus->bridge->bus; in hv_pci_assign_numa_node()
2363 hv_dev = get_pcichild_wslot(hbus, devfn_to_wslot(dev->devfn)); in hv_pci_assign_numa_node()
2385 * @hbus: Root PCI bus, as understood by this driver
2389 static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) in create_root_hv_pci_bus() argument
2392 struct pci_host_bridge *bridge = hbus->bridge; in create_root_hv_pci_bus()
2394 bridge->dev.parent = &hbus->hdev->device; in create_root_hv_pci_bus()
2395 bridge->sysdata = &hbus->sysdata; in create_root_hv_pci_bus()
2403 hv_pci_assign_numa_node(hbus); in create_root_hv_pci_bus()
2405 hv_pci_assign_slots(hbus); in create_root_hv_pci_bus()
2408 hbus->state = hv_pcibus_installed; in create_root_hv_pci_bus()
2437 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
2452 * @hbus: The internal struct tracking this root PCI bus.
2461 static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, in new_pcichild_device() argument
2478 hpdev->hbus = hbus; in new_pcichild_device()
2489 ret = vmbus_sendpacket(hbus->hdev->channel, res_req, in new_pcichild_device()
2497 if (wait_for_response(hbus->hdev, &comp_pkt.host_event)) in new_pcichild_device()
2503 spin_lock_irqsave(&hbus->device_list_lock, flags); in new_pcichild_device()
2505 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2506 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in new_pcichild_device()
2516 * @hbus: Root PCI bus, as understood by this driver
2527 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, in get_pcichild_wslot() argument
2533 spin_lock_irqsave(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2534 list_for_each_entry(iter, &hbus->children, list_entry) { in get_pcichild_wslot()
2541 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2567 * because both are pushed to the ordered workqueue hbus->wq.
2575 struct hv_pcibus_device *hbus; in pci_devices_present_work() local
2582 hbus = dr_wrk->bus; in pci_devices_present_work()
2588 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2589 while (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2590 dr = list_first_entry(&hbus->dr_list, struct hv_dr_state, in pci_devices_present_work()
2595 if (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2600 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2605 mutex_lock(&hbus->state_lock); in pci_devices_present_work()
2608 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2609 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2612 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2619 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2620 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2629 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2632 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2634 dev_err(&hbus->hdev->device, in pci_devices_present_work()
2640 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2643 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2652 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2666 switch (hbus->state) { in pci_devices_present_work()
2673 pci_scan_child_bus(hbus->bridge->bus); in pci_devices_present_work()
2674 hv_pci_assign_numa_node(hbus); in pci_devices_present_work()
2675 hv_pci_assign_slots(hbus); in pci_devices_present_work()
2681 survey_child_resources(hbus); in pci_devices_present_work()
2688 mutex_unlock(&hbus->state_lock); in pci_devices_present_work()
2695 * @hbus: Root PCI bus, as understood by this driver
2700 static int hv_pci_start_relations_work(struct hv_pcibus_device *hbus, in hv_pci_start_relations_work() argument
2707 if (hbus->state == hv_pcibus_removing) { in hv_pci_start_relations_work()
2708 dev_info(&hbus->hdev->device, in hv_pci_start_relations_work()
2718 dr_wrk->bus = hbus; in hv_pci_start_relations_work()
2720 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2726 pending_dr = !list_empty(&hbus->dr_list); in hv_pci_start_relations_work()
2727 list_add_tail(&dr->list_entry, &hbus->dr_list); in hv_pci_start_relations_work()
2728 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2733 queue_work(hbus->wq, &dr_wrk->wrk); in hv_pci_start_relations_work()
2740 * @hbus: Root PCI bus, as understood by this driver
2747 static void hv_pci_devices_present(struct hv_pcibus_device *hbus, in hv_pci_devices_present() argument
2771 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present()
2777 * @hbus: Root PCI bus, as understood by this driver
2782 static void hv_pci_devices_present2(struct hv_pcibus_device *hbus, in hv_pci_devices_present2() argument
2809 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present2()
2825 struct hv_pcibus_device *hbus; in hv_eject_device_work() local
2836 hbus = hpdev->hbus; in hv_eject_device_work()
2838 mutex_lock(&hbus->state_lock); in hv_eject_device_work()
2843 * must be done without constructs like pci_domain_nr(hbus->bridge->bus) in hv_eject_device_work()
2844 * because hbus->bridge->bus may not exist yet. in hv_eject_device_work()
2847 pdev = pci_get_domain_bus_and_slot(hbus->bridge->domain_nr, 0, wslot); in hv_eject_device_work()
2855 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_eject_device_work()
2857 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_eject_device_work()
2866 vmbus_sendpacket(hbus->hdev->channel, ejct_pkt, in hv_eject_device_work()
2877 mutex_unlock(&hbus->state_lock); in hv_eject_device_work()
2890 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device() local
2891 struct hv_device *hdev = hbus->hdev; in hv_pci_eject_device()
2893 if (hbus->state == hv_pcibus_removing) { in hv_pci_eject_device()
2900 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2914 struct hv_pcibus_device *hbus = context; in hv_pci_onchannelcallback() local
2915 struct vmbus_channel *chan = hbus->hdev->channel; in hv_pci_onchannelcallback()
2969 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3000 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3005 hv_pci_devices_present(hbus, bus_rel); in hv_pci_onchannelcallback()
3015 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3020 hv_pci_devices_present2(hbus, bus_rel2); in hv_pci_onchannelcallback()
3027 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3031 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
3043 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3047 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
3060 dev_warn(&hbus->hdev->device, in hv_pci_onchannelcallback()
3068 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3101 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_protocol_negotiation() local
3141 hbus->protocol_version = version[i]; in hv_pci_protocol_negotiation()
3144 hbus->protocol_version); in hv_pci_protocol_negotiation()
3171 * @hbus: Root PCI bus, as understood by this driver
3173 static void hv_pci_free_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_free_bridge_windows() argument
3180 if (hbus->low_mmio_space && hbus->low_mmio_res) { in hv_pci_free_bridge_windows()
3181 hbus->low_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3182 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_free_bridge_windows()
3183 resource_size(hbus->low_mmio_res)); in hv_pci_free_bridge_windows()
3186 if (hbus->high_mmio_space && hbus->high_mmio_res) { in hv_pci_free_bridge_windows()
3187 hbus->high_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3188 vmbus_free_mmio(hbus->high_mmio_res->start, in hv_pci_free_bridge_windows()
3189 resource_size(hbus->high_mmio_res)); in hv_pci_free_bridge_windows()
3196 * @hbus: Root PCI bus, as understood by this driver
3218 static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_allocate_bridge_windows() argument
3223 if (hbus->low_mmio_space) { in hv_pci_allocate_bridge_windows()
3224 align = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in hv_pci_allocate_bridge_windows()
3225 ret = vmbus_allocate_mmio(&hbus->low_mmio_res, hbus->hdev, 0, in hv_pci_allocate_bridge_windows()
3227 hbus->low_mmio_space, in hv_pci_allocate_bridge_windows()
3230 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3232 hbus->low_mmio_space); in hv_pci_allocate_bridge_windows()
3237 hbus->low_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3238 hbus->low_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3239 pci_add_resource(&hbus->bridge->windows, hbus->low_mmio_res); in hv_pci_allocate_bridge_windows()
3242 if (hbus->high_mmio_space) { in hv_pci_allocate_bridge_windows()
3243 align = 1ULL << (63 - __builtin_clzll(hbus->high_mmio_space)); in hv_pci_allocate_bridge_windows()
3244 ret = vmbus_allocate_mmio(&hbus->high_mmio_res, hbus->hdev, in hv_pci_allocate_bridge_windows()
3246 hbus->high_mmio_space, align, in hv_pci_allocate_bridge_windows()
3249 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3251 hbus->high_mmio_space); in hv_pci_allocate_bridge_windows()
3256 hbus->high_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3257 hbus->high_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3258 pci_add_resource(&hbus->bridge->windows, hbus->high_mmio_res); in hv_pci_allocate_bridge_windows()
3264 if (hbus->low_mmio_res) { in hv_pci_allocate_bridge_windows()
3265 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_allocate_bridge_windows()
3266 resource_size(hbus->low_mmio_res)); in hv_pci_allocate_bridge_windows()
3274 * @hbus: Root PCI bus, as understood by this driver
3281 static int hv_allocate_config_window(struct hv_pcibus_device *hbus) in hv_allocate_config_window() argument
3289 ret = vmbus_allocate_mmio(&hbus->mem_config, hbus->hdev, 0, -1, in hv_allocate_config_window()
3302 hbus->mem_config->flags |= IORESOURCE_BUSY; in hv_allocate_config_window()
3307 static void hv_free_config_window(struct hv_pcibus_device *hbus) in hv_free_config_window() argument
3309 vmbus_free_mmio(hbus->mem_config->start, PCI_CONFIG_MMIO_LENGTH); in hv_free_config_window()
3322 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_enter_d0() local
3345 d0_entry->mmio_base = hbus->mem_config->start; in hv_pci_enter_d0()
3376 hbus->wslot_res_allocated = 255; in hv_pci_enter_d0()
3412 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_query_relations() local
3419 if (cmpxchg(&hbus->survey_event, NULL, &comp)) in hv_pci_query_relations()
3434 * channel callback already scheduled a work to hbus->wq, which can be in hv_pci_query_relations()
3436 * complete(&hbus->survey_event), even after hv_pci_query_relations() in hv_pci_query_relations()
3439 * raw_spin_lock_irqsave(). Flush hbus->wq before we exit from in hv_pci_query_relations()
3441 * -ENODEV, there can't be any more work item scheduled to hbus->wq in hv_pci_query_relations()
3446 flush_workqueue(hbus->wq); in hv_pci_query_relations()
3470 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_allocated() local
3480 size_res = (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) in hv_send_resources_allocated()
3490 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
3499 if (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) { in hv_send_resources_allocated()
3531 hbus->wslot_res_allocated = wslot; in hv_send_resources_allocated()
3547 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_released() local
3553 for (wslot = hbus->wslot_res_allocated; wslot >= 0; wslot--) { in hv_send_resources_released()
3554 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3569 hbus->wslot_res_allocated = wslot - 1; in hv_send_resources_released()
3572 hbus->wslot_res_allocated = -1; in hv_send_resources_released()
3630 struct hv_pcibus_device *hbus; in hv_pci_probe() local
3639 hbus = kzalloc(sizeof(*hbus), GFP_KERNEL); in hv_pci_probe()
3640 if (!hbus) in hv_pci_probe()
3643 hbus->bridge = bridge; in hv_pci_probe()
3644 mutex_init(&hbus->state_lock); in hv_pci_probe()
3645 hbus->state = hv_pcibus_init; in hv_pci_probe()
3646 hbus->wslot_res_allocated = -1; in hv_pci_probe()
3676 hbus->bridge->domain_nr = dom; in hv_pci_probe()
3678 hbus->sysdata.domain = dom; in hv_pci_probe()
3679 hbus->use_calls = !!(ms_hyperv.hints & HV_X64_USE_MMIO_HYPERCALLS); in hv_pci_probe()
3688 hbus->sysdata.parent = hdev->device.parent; in hv_pci_probe()
3689 hbus->use_calls = false; in hv_pci_probe()
3692 hbus->hdev = hdev; in hv_pci_probe()
3693 INIT_LIST_HEAD(&hbus->children); in hv_pci_probe()
3694 INIT_LIST_HEAD(&hbus->dr_list); in hv_pci_probe()
3695 spin_lock_init(&hbus->config_lock); in hv_pci_probe()
3696 spin_lock_init(&hbus->device_list_lock); in hv_pci_probe()
3697 hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, in hv_pci_probe()
3698 hbus->bridge->domain_nr); in hv_pci_probe()
3699 if (!hbus->wq) { in hv_pci_probe()
3709 hv_pci_onchannelcallback, hbus); in hv_pci_probe()
3713 hv_set_drvdata(hdev, hbus); in hv_pci_probe()
3720 ret = hv_allocate_config_window(hbus); in hv_pci_probe()
3724 hbus->cfg_addr = ioremap(hbus->mem_config->start, in hv_pci_probe()
3726 if (!hbus->cfg_addr) { in hv_pci_probe()
3739 hbus->fwnode = irq_domain_alloc_named_fwnode(name); in hv_pci_probe()
3741 if (!hbus->fwnode) { in hv_pci_probe()
3746 ret = hv_pcie_init_irq_domain(hbus); in hv_pci_probe()
3754 mutex_lock(&hbus->state_lock); in hv_pci_probe()
3760 ret = hv_pci_allocate_bridge_windows(hbus); in hv_pci_probe()
3768 prepopulate_bars(hbus); in hv_pci_probe()
3770 hbus->state = hv_pcibus_probed; in hv_pci_probe()
3772 ret = create_root_hv_pci_bus(hbus); in hv_pci_probe()
3776 mutex_unlock(&hbus->state_lock); in hv_pci_probe()
3780 hv_pci_free_bridge_windows(hbus); in hv_pci_probe()
3784 mutex_unlock(&hbus->state_lock); in hv_pci_probe()
3786 irq_domain_remove(hbus->irq_domain); in hv_pci_probe()
3788 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_probe()
3790 iounmap(hbus->cfg_addr); in hv_pci_probe()
3792 hv_free_config_window(hbus); in hv_pci_probe()
3796 destroy_workqueue(hbus->wq); in hv_pci_probe()
3798 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_probe()
3800 kfree(hbus); in hv_pci_probe()
3806 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_bus_exit() local
3830 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3831 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3833 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3889 struct hv_pcibus_device *hbus; in hv_pci_remove() local
3891 hbus = hv_get_drvdata(hdev); in hv_pci_remove()
3892 if (hbus->state == hv_pcibus_installed) { in hv_pci_remove()
3894 hbus->state = hv_pcibus_removing; in hv_pci_remove()
3896 destroy_workqueue(hbus->wq); in hv_pci_remove()
3897 hbus->wq = NULL; in hv_pci_remove()
3900 * on hbus-wq. We can't race with hv_pci_devices_present() in hv_pci_remove()
3906 pci_stop_root_bus(hbus->bridge->bus); in hv_pci_remove()
3907 hv_pci_remove_slots(hbus); in hv_pci_remove()
3908 pci_remove_root_bus(hbus->bridge->bus); in hv_pci_remove()
3916 iounmap(hbus->cfg_addr); in hv_pci_remove()
3917 hv_free_config_window(hbus); in hv_pci_remove()
3918 hv_pci_free_bridge_windows(hbus); in hv_pci_remove()
3919 irq_domain_remove(hbus->irq_domain); in hv_pci_remove()
3920 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_remove()
3922 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_remove()
3924 kfree(hbus); in hv_pci_remove()
3929 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_suspend() local
3939 * items onto hbus->wq in hv_pci_devices_present() and in hv_pci_suspend()
3946 * callback tasklet, sets hbus->state to hv_pcibus_removing, and in hv_pci_suspend()
3949 * hbus->wq and safely closes the vmbus channel. in hv_pci_suspend()
3953 /* Change the hbus state to prevent new work items. */ in hv_pci_suspend()
3954 old_state = hbus->state; in hv_pci_suspend()
3955 if (hbus->state == hv_pcibus_installed) in hv_pci_suspend()
3956 hbus->state = hv_pcibus_removing; in hv_pci_suspend()
3963 flush_workqueue(hbus->wq); in hv_pci_suspend()
4005 static void hv_pci_restore_msi_state(struct hv_pcibus_device *hbus) in hv_pci_restore_msi_state() argument
4007 pci_walk_bus(hbus->bridge->bus, hv_pci_restore_msi_msg, NULL); in hv_pci_restore_msi_state()
4012 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_resume() local
4016 hbus->state = hv_pcibus_init; in hv_pci_resume()
4023 hv_pci_onchannelcallback, hbus); in hv_pci_resume()
4028 version[0] = hbus->protocol_version; in hv_pci_resume()
4037 mutex_lock(&hbus->state_lock); in hv_pci_resume()
4047 prepopulate_bars(hbus); in hv_pci_resume()
4049 hv_pci_restore_msi_state(hbus); in hv_pci_resume()
4051 hbus->state = hv_pcibus_installed; in hv_pci_resume()
4052 mutex_unlock(&hbus->state_lock); in hv_pci_resume()
4056 mutex_unlock(&hbus->state_lock); in hv_pci_resume()