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()
2071 * @hbus: The root PCI bus
2082 static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) in hv_pcie_init_irq_domain() argument
2084 hbus->msi_info.chip = &hv_msi_irq_chip; in hv_pcie_init_irq_domain()
2085 hbus->msi_info.ops = &hv_msi_ops; in hv_pcie_init_irq_domain()
2086 hbus->msi_info.flags = (MSI_FLAG_USE_DEF_DOM_OPS | in hv_pcie_init_irq_domain()
2089 hbus->msi_info.handler = FLOW_HANDLER; in hv_pcie_init_irq_domain()
2090 hbus->msi_info.handler_name = FLOW_NAME; in hv_pcie_init_irq_domain()
2091 hbus->msi_info.data = hbus; in hv_pcie_init_irq_domain()
2092 hbus->irq_domain = pci_msi_create_irq_domain(hbus->fwnode, in hv_pcie_init_irq_domain()
2093 &hbus->msi_info, in hv_pcie_init_irq_domain()
2095 if (!hbus->irq_domain) { in hv_pcie_init_irq_domain()
2096 dev_err(&hbus->hdev->device, in hv_pcie_init_irq_domain()
2101 dev_set_msi_domain(&hbus->bridge->dev, hbus->irq_domain); in hv_pcie_init_irq_domain()
2128 * @hbus: Root PCI bus, as understood by this driver
2130 static void survey_child_resources(struct hv_pcibus_device *hbus) in survey_child_resources() argument
2140 event = xchg(&hbus->survey_event, NULL); in survey_child_resources()
2145 if (hbus->low_mmio_space || hbus->high_mmio_space) { in survey_child_resources()
2150 spin_lock_irqsave(&hbus->device_list_lock, flags); in survey_child_resources()
2157 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
2160 dev_err(&hbus->hdev->device, in survey_child_resources()
2179 hbus->high_mmio_space += bar_size; in survey_child_resources()
2181 hbus->low_mmio_space += bar_size; in survey_child_resources()
2186 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in survey_child_resources()
2192 * @hbus: Root PCI bus, as understood by this driver
2202 static void prepopulate_bars(struct hv_pcibus_device *hbus) in prepopulate_bars() argument
2216 if (hbus->low_mmio_space) { in prepopulate_bars()
2217 low_size = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in prepopulate_bars()
2218 low_base = hbus->low_mmio_res->start; in prepopulate_bars()
2221 if (hbus->high_mmio_space) { in prepopulate_bars()
2223 (63 - __builtin_clzll(hbus->high_mmio_space)); in prepopulate_bars()
2224 high_base = hbus->high_mmio_res->start; in prepopulate_bars()
2227 spin_lock_irqsave(&hbus->device_list_lock, flags); in prepopulate_bars()
2240 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2248 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2306 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in prepopulate_bars()
2315 * same ordered workqueue. Therefore hbus->children list will not change
2318 static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) in hv_pci_assign_slots() argument
2324 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
2330 hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, in hv_pci_assign_slots()
2342 static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) in hv_pci_remove_slots() argument
2346 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
2357 static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) in hv_pci_assign_numa_node() argument
2360 struct pci_bus *bus = hbus->bridge->bus; in hv_pci_assign_numa_node()
2364 hv_dev = get_pcichild_wslot(hbus, devfn_to_wslot(dev->devfn)); in hv_pci_assign_numa_node()
2386 * @hbus: Root PCI bus, as understood by this driver
2390 static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) in create_root_hv_pci_bus() argument
2393 struct pci_host_bridge *bridge = hbus->bridge; in create_root_hv_pci_bus()
2395 bridge->dev.parent = &hbus->hdev->device; in create_root_hv_pci_bus()
2396 bridge->sysdata = &hbus->sysdata; in create_root_hv_pci_bus()
2404 hv_pci_assign_numa_node(hbus); in create_root_hv_pci_bus()
2406 hv_pci_assign_slots(hbus); in create_root_hv_pci_bus()
2409 hbus->state = hv_pcibus_installed; in create_root_hv_pci_bus()
2438 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
2453 * @hbus: The internal struct tracking this root PCI bus.
2462 static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, in new_pcichild_device() argument
2479 hpdev->hbus = hbus; in new_pcichild_device()
2490 ret = vmbus_sendpacket(hbus->hdev->channel, res_req, in new_pcichild_device()
2498 if (wait_for_response(hbus->hdev, &comp_pkt.host_event)) in new_pcichild_device()
2504 spin_lock_irqsave(&hbus->device_list_lock, flags); in new_pcichild_device()
2506 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2507 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in new_pcichild_device()
2517 * @hbus: Root PCI bus, as understood by this driver
2528 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, in get_pcichild_wslot() argument
2534 spin_lock_irqsave(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2535 list_for_each_entry(iter, &hbus->children, list_entry) { in get_pcichild_wslot()
2542 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2568 * because both are pushed to the ordered workqueue hbus->wq.
2576 struct hv_pcibus_device *hbus; in pci_devices_present_work() local
2583 hbus = dr_wrk->bus; in pci_devices_present_work()
2589 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2590 while (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2591 dr = list_first_entry(&hbus->dr_list, struct hv_dr_state, in pci_devices_present_work()
2596 if (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2601 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2606 mutex_lock(&hbus->state_lock); in pci_devices_present_work()
2609 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2610 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2613 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2620 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2621 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2630 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2633 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2635 dev_err(&hbus->hdev->device, in pci_devices_present_work()
2641 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2644 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2653 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2667 switch (hbus->state) { in pci_devices_present_work()
2674 pci_scan_child_bus(hbus->bridge->bus); in pci_devices_present_work()
2675 hv_pci_assign_numa_node(hbus); in pci_devices_present_work()
2676 hv_pci_assign_slots(hbus); in pci_devices_present_work()
2682 survey_child_resources(hbus); in pci_devices_present_work()
2689 mutex_unlock(&hbus->state_lock); in pci_devices_present_work()
2696 * @hbus: Root PCI bus, as understood by this driver
2701 static int hv_pci_start_relations_work(struct hv_pcibus_device *hbus, in hv_pci_start_relations_work() argument
2708 if (hbus->state == hv_pcibus_removing) { in hv_pci_start_relations_work()
2709 dev_info(&hbus->hdev->device, in hv_pci_start_relations_work()
2719 dr_wrk->bus = hbus; in hv_pci_start_relations_work()
2721 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2727 pending_dr = !list_empty(&hbus->dr_list); in hv_pci_start_relations_work()
2728 list_add_tail(&dr->list_entry, &hbus->dr_list); in hv_pci_start_relations_work()
2729 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2734 queue_work(hbus->wq, &dr_wrk->wrk); in hv_pci_start_relations_work()
2741 * @hbus: Root PCI bus, as understood by this driver
2748 static void hv_pci_devices_present(struct hv_pcibus_device *hbus, in hv_pci_devices_present() argument
2772 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present()
2778 * @hbus: Root PCI bus, as understood by this driver
2783 static void hv_pci_devices_present2(struct hv_pcibus_device *hbus, in hv_pci_devices_present2() argument
2810 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present2()
2826 struct hv_pcibus_device *hbus; in hv_eject_device_work() local
2837 hbus = hpdev->hbus; in hv_eject_device_work()
2839 mutex_lock(&hbus->state_lock); in hv_eject_device_work()
2844 * must be done without constructs like pci_domain_nr(hbus->bridge->bus) in hv_eject_device_work()
2845 * because hbus->bridge->bus may not exist yet. in hv_eject_device_work()
2848 pdev = pci_get_domain_bus_and_slot(hbus->bridge->domain_nr, 0, wslot); in hv_eject_device_work()
2856 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_eject_device_work()
2858 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_eject_device_work()
2867 vmbus_sendpacket(hbus->hdev->channel, ejct_pkt, in hv_eject_device_work()
2878 mutex_unlock(&hbus->state_lock); in hv_eject_device_work()
2891 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device() local
2892 struct hv_device *hdev = hbus->hdev; in hv_pci_eject_device()
2894 if (hbus->state == hv_pcibus_removing) { in hv_pci_eject_device()
2901 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2915 struct hv_pcibus_device *hbus = context; in hv_pci_onchannelcallback() local
2916 struct vmbus_channel *chan = hbus->hdev->channel; in hv_pci_onchannelcallback()
2970 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3001 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3006 hv_pci_devices_present(hbus, bus_rel); in hv_pci_onchannelcallback()
3016 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3021 hv_pci_devices_present2(hbus, bus_rel2); in hv_pci_onchannelcallback()
3028 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3032 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
3044 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3048 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
3061 dev_warn(&hbus->hdev->device, in hv_pci_onchannelcallback()
3069 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3102 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_protocol_negotiation() local
3142 hbus->protocol_version = version[i]; in hv_pci_protocol_negotiation()
3145 hbus->protocol_version); in hv_pci_protocol_negotiation()
3172 * @hbus: Root PCI bus, as understood by this driver
3174 static void hv_pci_free_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_free_bridge_windows() argument
3181 if (hbus->low_mmio_space && hbus->low_mmio_res) { in hv_pci_free_bridge_windows()
3182 hbus->low_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3183 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_free_bridge_windows()
3184 resource_size(hbus->low_mmio_res)); in hv_pci_free_bridge_windows()
3187 if (hbus->high_mmio_space && hbus->high_mmio_res) { in hv_pci_free_bridge_windows()
3188 hbus->high_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3189 vmbus_free_mmio(hbus->high_mmio_res->start, in hv_pci_free_bridge_windows()
3190 resource_size(hbus->high_mmio_res)); in hv_pci_free_bridge_windows()
3197 * @hbus: Root PCI bus, as understood by this driver
3219 static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_allocate_bridge_windows() argument
3224 if (hbus->low_mmio_space) { in hv_pci_allocate_bridge_windows()
3225 align = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in hv_pci_allocate_bridge_windows()
3226 ret = vmbus_allocate_mmio(&hbus->low_mmio_res, hbus->hdev, 0, in hv_pci_allocate_bridge_windows()
3228 hbus->low_mmio_space, in hv_pci_allocate_bridge_windows()
3231 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3233 hbus->low_mmio_space); in hv_pci_allocate_bridge_windows()
3238 hbus->low_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3239 hbus->low_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3240 pci_add_resource(&hbus->bridge->windows, hbus->low_mmio_res); in hv_pci_allocate_bridge_windows()
3243 if (hbus->high_mmio_space) { in hv_pci_allocate_bridge_windows()
3244 align = 1ULL << (63 - __builtin_clzll(hbus->high_mmio_space)); in hv_pci_allocate_bridge_windows()
3245 ret = vmbus_allocate_mmio(&hbus->high_mmio_res, hbus->hdev, in hv_pci_allocate_bridge_windows()
3247 hbus->high_mmio_space, align, in hv_pci_allocate_bridge_windows()
3250 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3252 hbus->high_mmio_space); in hv_pci_allocate_bridge_windows()
3257 hbus->high_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3258 hbus->high_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3259 pci_add_resource(&hbus->bridge->windows, hbus->high_mmio_res); in hv_pci_allocate_bridge_windows()
3265 if (hbus->low_mmio_res) { in hv_pci_allocate_bridge_windows()
3266 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_allocate_bridge_windows()
3267 resource_size(hbus->low_mmio_res)); in hv_pci_allocate_bridge_windows()
3275 * @hbus: Root PCI bus, as understood by this driver
3282 static int hv_allocate_config_window(struct hv_pcibus_device *hbus) in hv_allocate_config_window() argument
3290 ret = vmbus_allocate_mmio(&hbus->mem_config, hbus->hdev, 0, -1, in hv_allocate_config_window()
3303 hbus->mem_config->flags |= IORESOURCE_BUSY; in hv_allocate_config_window()
3308 static void hv_free_config_window(struct hv_pcibus_device *hbus) in hv_free_config_window() argument
3310 vmbus_free_mmio(hbus->mem_config->start, PCI_CONFIG_MMIO_LENGTH); in hv_free_config_window()
3323 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_enter_d0() local
3346 d0_entry->mmio_base = hbus->mem_config->start; in hv_pci_enter_d0()
3377 hbus->wslot_res_allocated = 255; in hv_pci_enter_d0()
3413 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_query_relations() local
3420 if (cmpxchg(&hbus->survey_event, NULL, &comp)) in hv_pci_query_relations()
3435 * channel callback already scheduled a work to hbus->wq, which can be in hv_pci_query_relations()
3437 * complete(&hbus->survey_event), even after hv_pci_query_relations() in hv_pci_query_relations()
3440 * raw_spin_lock_irqsave(). Flush hbus->wq before we exit from in hv_pci_query_relations()
3442 * -ENODEV, there can't be any more work item scheduled to hbus->wq in hv_pci_query_relations()
3447 flush_workqueue(hbus->wq); in hv_pci_query_relations()
3471 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_allocated() local
3481 size_res = (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) in hv_send_resources_allocated()
3491 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
3500 if (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) { in hv_send_resources_allocated()
3532 hbus->wslot_res_allocated = wslot; in hv_send_resources_allocated()
3548 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_released() local
3554 for (wslot = hbus->wslot_res_allocated; wslot >= 0; wslot--) { in hv_send_resources_released()
3555 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3570 hbus->wslot_res_allocated = wslot - 1; in hv_send_resources_released()
3573 hbus->wslot_res_allocated = -1; in hv_send_resources_released()
3631 struct hv_pcibus_device *hbus; in hv_pci_probe() local
3640 hbus = kzalloc(sizeof(*hbus), GFP_KERNEL); in hv_pci_probe()
3641 if (!hbus) in hv_pci_probe()
3644 hbus->bridge = bridge; in hv_pci_probe()
3645 mutex_init(&hbus->state_lock); in hv_pci_probe()
3646 hbus->state = hv_pcibus_init; in hv_pci_probe()
3647 hbus->wslot_res_allocated = -1; in hv_pci_probe()
3677 hbus->bridge->domain_nr = dom; in hv_pci_probe()
3679 hbus->sysdata.domain = dom; in hv_pci_probe()
3680 hbus->use_calls = !!(ms_hyperv.hints & HV_X64_USE_MMIO_HYPERCALLS); in hv_pci_probe()
3689 hbus->sysdata.parent = hdev->device.parent; in hv_pci_probe()
3690 hbus->use_calls = false; in hv_pci_probe()
3693 hbus->hdev = hdev; in hv_pci_probe()
3694 INIT_LIST_HEAD(&hbus->children); in hv_pci_probe()
3695 INIT_LIST_HEAD(&hbus->dr_list); in hv_pci_probe()
3696 spin_lock_init(&hbus->config_lock); in hv_pci_probe()
3697 spin_lock_init(&hbus->device_list_lock); in hv_pci_probe()
3698 hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, in hv_pci_probe()
3699 hbus->bridge->domain_nr); in hv_pci_probe()
3700 if (!hbus->wq) { in hv_pci_probe()
3710 hv_pci_onchannelcallback, hbus); in hv_pci_probe()
3714 hv_set_drvdata(hdev, hbus); in hv_pci_probe()
3721 ret = hv_allocate_config_window(hbus); in hv_pci_probe()
3725 hbus->cfg_addr = ioremap(hbus->mem_config->start, in hv_pci_probe()
3727 if (!hbus->cfg_addr) { in hv_pci_probe()
3740 hbus->fwnode = irq_domain_alloc_named_fwnode(name); in hv_pci_probe()
3742 if (!hbus->fwnode) { in hv_pci_probe()
3747 ret = hv_pcie_init_irq_domain(hbus); in hv_pci_probe()
3755 mutex_lock(&hbus->state_lock); in hv_pci_probe()
3761 ret = hv_pci_allocate_bridge_windows(hbus); in hv_pci_probe()
3769 prepopulate_bars(hbus); in hv_pci_probe()
3771 hbus->state = hv_pcibus_probed; in hv_pci_probe()
3773 ret = create_root_hv_pci_bus(hbus); in hv_pci_probe()
3777 mutex_unlock(&hbus->state_lock); in hv_pci_probe()
3781 hv_pci_free_bridge_windows(hbus); in hv_pci_probe()
3785 mutex_unlock(&hbus->state_lock); in hv_pci_probe()
3787 irq_domain_remove(hbus->irq_domain); in hv_pci_probe()
3789 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_probe()
3791 iounmap(hbus->cfg_addr); in hv_pci_probe()
3793 hv_free_config_window(hbus); in hv_pci_probe()
3797 destroy_workqueue(hbus->wq); in hv_pci_probe()
3799 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_probe()
3801 kfree(hbus); in hv_pci_probe()
3807 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_bus_exit() local
3831 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3832 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3834 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3890 struct hv_pcibus_device *hbus; in hv_pci_remove() local
3892 hbus = hv_get_drvdata(hdev); in hv_pci_remove()
3893 if (hbus->state == hv_pcibus_installed) { in hv_pci_remove()
3895 hbus->state = hv_pcibus_removing; in hv_pci_remove()
3897 destroy_workqueue(hbus->wq); in hv_pci_remove()
3898 hbus->wq = NULL; in hv_pci_remove()
3901 * on hbus-wq. We can't race with hv_pci_devices_present() in hv_pci_remove()
3907 pci_stop_root_bus(hbus->bridge->bus); in hv_pci_remove()
3908 hv_pci_remove_slots(hbus); in hv_pci_remove()
3909 pci_remove_root_bus(hbus->bridge->bus); in hv_pci_remove()
3917 iounmap(hbus->cfg_addr); in hv_pci_remove()
3918 hv_free_config_window(hbus); in hv_pci_remove()
3919 hv_pci_free_bridge_windows(hbus); in hv_pci_remove()
3920 irq_domain_remove(hbus->irq_domain); in hv_pci_remove()
3921 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_remove()
3923 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_remove()
3925 kfree(hbus); in hv_pci_remove()
3930 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_suspend() local
3940 * items onto hbus->wq in hv_pci_devices_present() and in hv_pci_suspend()
3947 * callback tasklet, sets hbus->state to hv_pcibus_removing, and in hv_pci_suspend()
3950 * hbus->wq and safely closes the vmbus channel. in hv_pci_suspend()
3954 /* Change the hbus state to prevent new work items. */ in hv_pci_suspend()
3955 old_state = hbus->state; in hv_pci_suspend()
3956 if (hbus->state == hv_pcibus_installed) in hv_pci_suspend()
3957 hbus->state = hv_pcibus_removing; in hv_pci_suspend()
3964 flush_workqueue(hbus->wq); in hv_pci_suspend()
4006 static void hv_pci_restore_msi_state(struct hv_pcibus_device *hbus) in hv_pci_restore_msi_state() argument
4008 pci_walk_bus(hbus->bridge->bus, hv_pci_restore_msi_msg, NULL); in hv_pci_restore_msi_state()
4013 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_resume() local
4017 hbus->state = hv_pcibus_init; in hv_pci_resume()
4024 hv_pci_onchannelcallback, hbus); in hv_pci_resume()
4029 version[0] = hbus->protocol_version; in hv_pci_resume()
4038 mutex_lock(&hbus->state_lock); in hv_pci_resume()
4048 prepopulate_bars(hbus); in hv_pci_resume()
4050 hv_pci_restore_msi_state(hbus); in hv_pci_resume()
4052 hbus->state = hv_pcibus_installed; in hv_pci_resume()
4053 mutex_unlock(&hbus->state_lock); in hv_pci_resume()
4057 mutex_unlock(&hbus->state_lock); in hv_pci_resume()