Lines Matching full:hbus
558 struct hv_pcibus_device *hbus; member
617 struct hv_pcibus_device *hbus; in hv_arch_irq_unmask() local
630 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_arch_irq_unmask()
633 dev_warn(&hbus->hdev->device, "%s() can not unmask irq %u\n", in hv_arch_irq_unmask()
646 params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | in hv_arch_irq_unmask()
647 (hbus->hdev->dev_instance.b[4] << 16) | in hv_arch_irq_unmask()
648 (hbus->hdev->dev_instance.b[7] << 8) | in hv_arch_irq_unmask()
649 (hbus->hdev->dev_instance.b[6] & 0xf8) | in hv_arch_irq_unmask()
653 if (hbus->protocol_version >= PCI_PROTOCOL_VERSION_1_2) { in hv_arch_irq_unmask()
713 if (!hv_result_success(res) && hbus->state != hv_pcibus_removing) in hv_arch_irq_unmask()
714 dev_err(&hbus->hdev->device, in hv_arch_irq_unmask()
959 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus,
1110 struct hv_pcibus_device *hbus = hpdev->hbus; in _hv_pcifront_read_config() local
1111 struct device *dev = &hbus->hdev->device; in _hv_pcifront_read_config()
1142 spin_lock_irqsave(&hbus->config_lock, flags); in _hv_pcifront_read_config()
1143 if (hbus->use_calls) { in _hv_pcifront_read_config()
1144 phys_addr_t addr = hbus->mem_config->start + offset; in _hv_pcifront_read_config()
1146 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in _hv_pcifront_read_config()
1150 void __iomem *addr = hbus->cfg_addr + offset; in _hv_pcifront_read_config()
1153 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in _hv_pcifront_read_config()
1174 spin_unlock_irqrestore(&hbus->config_lock, flags); in _hv_pcifront_read_config()
1182 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pcifront_get_vendor_id() local
1183 struct device *dev = &hbus->hdev->device; in hv_pcifront_get_vendor_id()
1188 spin_lock_irqsave(&hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1190 if (hbus->use_calls) { in hv_pcifront_get_vendor_id()
1191 phys_addr_t addr = hbus->mem_config->start + in hv_pcifront_get_vendor_id()
1194 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in hv_pcifront_get_vendor_id()
1199 void __iomem *addr = hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
1202 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in hv_pcifront_get_vendor_id()
1213 spin_unlock_irqrestore(&hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1228 struct hv_pcibus_device *hbus = hpdev->hbus; in _hv_pcifront_write_config() local
1229 struct device *dev = &hbus->hdev->device; in _hv_pcifront_write_config()
1237 spin_lock_irqsave(&hbus->config_lock, flags); in _hv_pcifront_write_config()
1239 if (hbus->use_calls) { in _hv_pcifront_write_config()
1240 phys_addr_t addr = hbus->mem_config->start + offset; in _hv_pcifront_write_config()
1242 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in _hv_pcifront_write_config()
1246 void __iomem *addr = hbus->cfg_addr + offset; in _hv_pcifront_write_config()
1249 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in _hv_pcifront_write_config()
1270 spin_unlock_irqrestore(&hbus->config_lock, flags); in _hv_pcifront_write_config()
1290 struct hv_pcibus_device *hbus = in hv_pcifront_read_config() local
1294 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
1318 struct hv_pcibus_device *hbus = in hv_pcifront_write_config() local
1322 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
1419 struct hv_pcibus_device *hbus = in hv_read_config_block() local
1446 ret = vmbus_sendpacket(hbus->hdev->channel, read_blk, in hv_read_config_block()
1453 ret = wait_for_response(hbus->hdev, &comp_pkt.comp_pkt.host_event); in hv_read_config_block()
1459 dev_err(&hbus->hdev->device, in hv_read_config_block()
1499 struct hv_pcibus_device *hbus = in hv_write_config_block() local
1536 ret = vmbus_sendpacket(hbus->hdev->channel, write_blk, pkt_size, in hv_write_config_block()
1542 ret = wait_for_response(hbus->hdev, &comp_pkt.host_event); in hv_write_config_block()
1547 dev_err(&hbus->hdev->device, in hv_write_config_block()
1569 struct hv_pcibus_device *hbus = in hv_register_block_invalidate() local
1574 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1606 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1625 struct hv_pcibus_device *hbus; in hv_msi_free() local
1633 hbus = info->data; in hv_msi_free()
1639 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1814 struct hv_pcibus_device *hbus; in hv_compose_msi_msg() local
1859 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_compose_msi_msg()
1860 channel = hbus->hdev->channel; in hv_compose_msi_msg()
1861 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1918 switch (hbus->protocol_version) { in hv_compose_msi_msg()
1948 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1953 ret = vmbus_sendpacket_getid(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1958 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
1979 dev_err_once(&hbus->hdev->device, in hv_compose_msi_msg()
1996 hv_pci_onchannelcallback(hbus); in hv_compose_msi_msg()
2005 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
2069 * @hbus: The root PCI bus
2080 static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) in hv_pcie_init_irq_domain() argument
2082 hbus->msi_info.chip = &hv_msi_irq_chip; in hv_pcie_init_irq_domain()
2083 hbus->msi_info.ops = &hv_msi_ops; in hv_pcie_init_irq_domain()
2084 hbus->msi_info.flags = (MSI_FLAG_USE_DEF_DOM_OPS | in hv_pcie_init_irq_domain()
2087 hbus->msi_info.handler = FLOW_HANDLER; in hv_pcie_init_irq_domain()
2088 hbus->msi_info.handler_name = FLOW_NAME; in hv_pcie_init_irq_domain()
2089 hbus->msi_info.data = hbus; in hv_pcie_init_irq_domain()
2090 hbus->irq_domain = pci_msi_create_irq_domain(hbus->fwnode, in hv_pcie_init_irq_domain()
2091 &hbus->msi_info, in hv_pcie_init_irq_domain()
2093 if (!hbus->irq_domain) { in hv_pcie_init_irq_domain()
2094 dev_err(&hbus->hdev->device, in hv_pcie_init_irq_domain()
2099 dev_set_msi_domain(&hbus->bridge->dev, hbus->irq_domain); in hv_pcie_init_irq_domain()
2126 * @hbus: Root PCI bus, as understood by this driver
2128 static void survey_child_resources(struct hv_pcibus_device *hbus) in survey_child_resources() argument
2138 event = xchg(&hbus->survey_event, NULL); in survey_child_resources()
2143 if (hbus->low_mmio_space || hbus->high_mmio_space) { in survey_child_resources()
2148 spin_lock_irqsave(&hbus->device_list_lock, flags); in survey_child_resources()
2155 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
2158 dev_err(&hbus->hdev->device, in survey_child_resources()
2177 hbus->high_mmio_space += bar_size; in survey_child_resources()
2179 hbus->low_mmio_space += bar_size; in survey_child_resources()
2184 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in survey_child_resources()
2190 * @hbus: Root PCI bus, as understood by this driver
2200 static void prepopulate_bars(struct hv_pcibus_device *hbus) in prepopulate_bars() argument
2214 if (hbus->low_mmio_space) { in prepopulate_bars()
2215 low_size = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in prepopulate_bars()
2216 low_base = hbus->low_mmio_res->start; in prepopulate_bars()
2219 if (hbus->high_mmio_space) { in prepopulate_bars()
2221 (63 - __builtin_clzll(hbus->high_mmio_space)); in prepopulate_bars()
2222 high_base = hbus->high_mmio_res->start; in prepopulate_bars()
2225 spin_lock_irqsave(&hbus->device_list_lock, flags); in prepopulate_bars()
2238 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2246 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2304 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in prepopulate_bars()
2313 * same ordered workqueue. Therefore hbus->children list will not change
2316 static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) in hv_pci_assign_slots() argument
2322 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
2328 hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, in hv_pci_assign_slots()
2340 static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) in hv_pci_remove_slots() argument
2344 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
2355 static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) in hv_pci_assign_numa_node() argument
2358 struct pci_bus *bus = hbus->bridge->bus; in hv_pci_assign_numa_node()
2362 hv_dev = get_pcichild_wslot(hbus, devfn_to_wslot(dev->devfn)); in hv_pci_assign_numa_node()
2384 * @hbus: Root PCI bus, as understood by this driver
2388 static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) in create_root_hv_pci_bus() argument
2391 struct pci_host_bridge *bridge = hbus->bridge; in create_root_hv_pci_bus()
2393 bridge->dev.parent = &hbus->hdev->device; in create_root_hv_pci_bus()
2394 bridge->sysdata = &hbus->sysdata; in create_root_hv_pci_bus()
2402 hv_pci_assign_numa_node(hbus); in create_root_hv_pci_bus()
2404 hv_pci_assign_slots(hbus); in create_root_hv_pci_bus()
2407 hbus->state = hv_pcibus_installed; in create_root_hv_pci_bus()
2436 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
2451 * @hbus: The internal struct tracking this root PCI bus.
2460 static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, in new_pcichild_device() argument
2477 hpdev->hbus = hbus; in new_pcichild_device()
2488 ret = vmbus_sendpacket(hbus->hdev->channel, res_req, in new_pcichild_device()
2496 if (wait_for_response(hbus->hdev, &comp_pkt.host_event)) in new_pcichild_device()
2502 spin_lock_irqsave(&hbus->device_list_lock, flags); in new_pcichild_device()
2504 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2505 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in new_pcichild_device()
2515 * @hbus: Root PCI bus, as understood by this driver
2526 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, in get_pcichild_wslot() argument
2532 spin_lock_irqsave(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2533 list_for_each_entry(iter, &hbus->children, list_entry) { in get_pcichild_wslot()
2540 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2566 * because both are pushed to the ordered workqueue hbus->wq.
2574 struct hv_pcibus_device *hbus; in pci_devices_present_work() local
2581 hbus = dr_wrk->bus; in pci_devices_present_work()
2587 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2588 while (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2589 dr = list_first_entry(&hbus->dr_list, struct hv_dr_state, in pci_devices_present_work()
2594 if (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2599 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2604 mutex_lock(&hbus->state_lock); in pci_devices_present_work()
2607 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2608 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2611 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2618 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2619 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2628 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2631 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2633 dev_err(&hbus->hdev->device, in pci_devices_present_work()
2639 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2642 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2651 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2665 switch (hbus->state) { in pci_devices_present_work()
2672 pci_scan_child_bus(hbus->bridge->bus); in pci_devices_present_work()
2673 hv_pci_assign_numa_node(hbus); in pci_devices_present_work()
2674 hv_pci_assign_slots(hbus); in pci_devices_present_work()
2680 survey_child_resources(hbus); in pci_devices_present_work()
2687 mutex_unlock(&hbus->state_lock); in pci_devices_present_work()
2694 * @hbus: Root PCI bus, as understood by this driver
2699 static int hv_pci_start_relations_work(struct hv_pcibus_device *hbus, in hv_pci_start_relations_work() argument
2706 if (hbus->state == hv_pcibus_removing) { in hv_pci_start_relations_work()
2707 dev_info(&hbus->hdev->device, in hv_pci_start_relations_work()
2717 dr_wrk->bus = hbus; in hv_pci_start_relations_work()
2719 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2725 pending_dr = !list_empty(&hbus->dr_list); in hv_pci_start_relations_work()
2726 list_add_tail(&dr->list_entry, &hbus->dr_list); in hv_pci_start_relations_work()
2727 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2732 queue_work(hbus->wq, &dr_wrk->wrk); in hv_pci_start_relations_work()
2739 * @hbus: Root PCI bus, as understood by this driver
2746 static void hv_pci_devices_present(struct hv_pcibus_device *hbus, in hv_pci_devices_present() argument
2770 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present()
2776 * @hbus: Root PCI bus, as understood by this driver
2781 static void hv_pci_devices_present2(struct hv_pcibus_device *hbus, in hv_pci_devices_present2() argument
2808 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present2()
2824 struct hv_pcibus_device *hbus; in hv_eject_device_work() local
2835 hbus = hpdev->hbus; in hv_eject_device_work()
2837 mutex_lock(&hbus->state_lock); in hv_eject_device_work()
2842 * must be done without constructs like pci_domain_nr(hbus->bridge->bus) in hv_eject_device_work()
2843 * because hbus->bridge->bus may not exist yet. in hv_eject_device_work()
2846 pdev = pci_get_domain_bus_and_slot(hbus->bridge->domain_nr, 0, wslot); in hv_eject_device_work()
2854 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_eject_device_work()
2856 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_eject_device_work()
2865 vmbus_sendpacket(hbus->hdev->channel, ejct_pkt, in hv_eject_device_work()
2876 mutex_unlock(&hbus->state_lock); in hv_eject_device_work()
2889 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device() local
2890 struct hv_device *hdev = hbus->hdev; in hv_pci_eject_device()
2892 if (hbus->state == hv_pcibus_removing) { in hv_pci_eject_device()
2899 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2913 struct hv_pcibus_device *hbus = context; in hv_pci_onchannelcallback() local
2914 struct vmbus_channel *chan = hbus->hdev->channel; in hv_pci_onchannelcallback()
2968 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
2999 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3004 hv_pci_devices_present(hbus, bus_rel); in hv_pci_onchannelcallback()
3014 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3019 hv_pci_devices_present2(hbus, bus_rel2); in hv_pci_onchannelcallback()
3026 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3030 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
3042 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3046 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
3059 dev_warn(&hbus->hdev->device, in hv_pci_onchannelcallback()
3067 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3100 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_protocol_negotiation() local
3140 hbus->protocol_version = version[i]; in hv_pci_protocol_negotiation()
3143 hbus->protocol_version); in hv_pci_protocol_negotiation()
3170 * @hbus: Root PCI bus, as understood by this driver
3172 static void hv_pci_free_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_free_bridge_windows() argument
3179 if (hbus->low_mmio_space && hbus->low_mmio_res) { in hv_pci_free_bridge_windows()
3180 hbus->low_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3181 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_free_bridge_windows()
3182 resource_size(hbus->low_mmio_res)); in hv_pci_free_bridge_windows()
3185 if (hbus->high_mmio_space && hbus->high_mmio_res) { in hv_pci_free_bridge_windows()
3186 hbus->high_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3187 vmbus_free_mmio(hbus->high_mmio_res->start, in hv_pci_free_bridge_windows()
3188 resource_size(hbus->high_mmio_res)); in hv_pci_free_bridge_windows()
3195 * @hbus: Root PCI bus, as understood by this driver
3217 static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_allocate_bridge_windows() argument
3222 if (hbus->low_mmio_space) { in hv_pci_allocate_bridge_windows()
3223 align = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in hv_pci_allocate_bridge_windows()
3224 ret = vmbus_allocate_mmio(&hbus->low_mmio_res, hbus->hdev, 0, in hv_pci_allocate_bridge_windows()
3226 hbus->low_mmio_space, in hv_pci_allocate_bridge_windows()
3229 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3231 hbus->low_mmio_space); in hv_pci_allocate_bridge_windows()
3236 hbus->low_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3237 hbus->low_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3238 pci_add_resource(&hbus->bridge->windows, hbus->low_mmio_res); in hv_pci_allocate_bridge_windows()
3241 if (hbus->high_mmio_space) { in hv_pci_allocate_bridge_windows()
3242 align = 1ULL << (63 - __builtin_clzll(hbus->high_mmio_space)); in hv_pci_allocate_bridge_windows()
3243 ret = vmbus_allocate_mmio(&hbus->high_mmio_res, hbus->hdev, in hv_pci_allocate_bridge_windows()
3245 hbus->high_mmio_space, align, in hv_pci_allocate_bridge_windows()
3248 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3250 hbus->high_mmio_space); in hv_pci_allocate_bridge_windows()
3255 hbus->high_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3256 hbus->high_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3257 pci_add_resource(&hbus->bridge->windows, hbus->high_mmio_res); in hv_pci_allocate_bridge_windows()
3263 if (hbus->low_mmio_res) { in hv_pci_allocate_bridge_windows()
3264 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_allocate_bridge_windows()
3265 resource_size(hbus->low_mmio_res)); in hv_pci_allocate_bridge_windows()
3273 * @hbus: Root PCI bus, as understood by this driver
3280 static int hv_allocate_config_window(struct hv_pcibus_device *hbus) in hv_allocate_config_window() argument
3288 ret = vmbus_allocate_mmio(&hbus->mem_config, hbus->hdev, 0, -1, in hv_allocate_config_window()
3301 hbus->mem_config->flags |= IORESOURCE_BUSY; in hv_allocate_config_window()
3306 static void hv_free_config_window(struct hv_pcibus_device *hbus) in hv_free_config_window() argument
3308 vmbus_free_mmio(hbus->mem_config->start, PCI_CONFIG_MMIO_LENGTH); in hv_free_config_window()
3321 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_enter_d0() local
3344 d0_entry->mmio_base = hbus->mem_config->start; in hv_pci_enter_d0()
3375 hbus->wslot_res_allocated = 255; in hv_pci_enter_d0()
3411 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_query_relations() local
3418 if (cmpxchg(&hbus->survey_event, NULL, &comp)) in hv_pci_query_relations()
3433 * channel callback already scheduled a work to hbus->wq, which can be in hv_pci_query_relations()
3435 * complete(&hbus->survey_event), even after hv_pci_query_relations() in hv_pci_query_relations()
3438 * raw_spin_lock_irqsave(). Flush hbus->wq before we exit from in hv_pci_query_relations()
3440 * -ENODEV, there can't be any more work item scheduled to hbus->wq in hv_pci_query_relations()
3445 flush_workqueue(hbus->wq); in hv_pci_query_relations()
3469 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_allocated() local
3479 size_res = (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) in hv_send_resources_allocated()
3489 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
3498 if (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) { in hv_send_resources_allocated()
3530 hbus->wslot_res_allocated = wslot; in hv_send_resources_allocated()
3546 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_released() local
3552 for (wslot = hbus->wslot_res_allocated; wslot >= 0; wslot--) { in hv_send_resources_released()
3553 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3568 hbus->wslot_res_allocated = wslot - 1; in hv_send_resources_released()
3571 hbus->wslot_res_allocated = -1; in hv_send_resources_released()
3629 struct hv_pcibus_device *hbus; in hv_pci_probe() local
3638 hbus = kzalloc(sizeof(*hbus), GFP_KERNEL); in hv_pci_probe()
3639 if (!hbus) in hv_pci_probe()
3642 hbus->bridge = bridge; in hv_pci_probe()
3643 mutex_init(&hbus->state_lock); in hv_pci_probe()
3644 hbus->state = hv_pcibus_init; in hv_pci_probe()
3645 hbus->wslot_res_allocated = -1; in hv_pci_probe()
3675 hbus->bridge->domain_nr = dom; in hv_pci_probe()
3677 hbus->sysdata.domain = dom; in hv_pci_probe()
3678 hbus->use_calls = !!(ms_hyperv.hints & HV_X64_USE_MMIO_HYPERCALLS); in hv_pci_probe()
3687 hbus->sysdata.parent = hdev->device.parent; in hv_pci_probe()
3688 hbus->use_calls = false; in hv_pci_probe()
3691 hbus->hdev = hdev; in hv_pci_probe()
3692 INIT_LIST_HEAD(&hbus->children); in hv_pci_probe()
3693 INIT_LIST_HEAD(&hbus->dr_list); in hv_pci_probe()
3694 spin_lock_init(&hbus->config_lock); in hv_pci_probe()
3695 spin_lock_init(&hbus->device_list_lock); in hv_pci_probe()
3696 hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, in hv_pci_probe()
3697 hbus->bridge->domain_nr); in hv_pci_probe()
3698 if (!hbus->wq) { in hv_pci_probe()
3708 hv_pci_onchannelcallback, hbus); in hv_pci_probe()
3712 hv_set_drvdata(hdev, hbus); in hv_pci_probe()
3719 ret = hv_allocate_config_window(hbus); in hv_pci_probe()
3723 hbus->cfg_addr = ioremap(hbus->mem_config->start, in hv_pci_probe()
3725 if (!hbus->cfg_addr) { in hv_pci_probe()
3738 hbus->fwnode = irq_domain_alloc_named_fwnode(name); in hv_pci_probe()
3740 if (!hbus->fwnode) { in hv_pci_probe()
3745 ret = hv_pcie_init_irq_domain(hbus); in hv_pci_probe()
3753 mutex_lock(&hbus->state_lock); in hv_pci_probe()
3759 ret = hv_pci_allocate_bridge_windows(hbus); in hv_pci_probe()
3767 prepopulate_bars(hbus); in hv_pci_probe()
3769 hbus->state = hv_pcibus_probed; in hv_pci_probe()
3771 ret = create_root_hv_pci_bus(hbus); in hv_pci_probe()
3775 mutex_unlock(&hbus->state_lock); in hv_pci_probe()
3779 hv_pci_free_bridge_windows(hbus); in hv_pci_probe()
3783 mutex_unlock(&hbus->state_lock); in hv_pci_probe()
3785 irq_domain_remove(hbus->irq_domain); in hv_pci_probe()
3787 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_probe()
3789 iounmap(hbus->cfg_addr); in hv_pci_probe()
3791 hv_free_config_window(hbus); in hv_pci_probe()
3795 destroy_workqueue(hbus->wq); in hv_pci_probe()
3797 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_probe()
3799 kfree(hbus); in hv_pci_probe()
3805 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_bus_exit() local
3829 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3830 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3832 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3888 struct hv_pcibus_device *hbus; in hv_pci_remove() local
3890 hbus = hv_get_drvdata(hdev); in hv_pci_remove()
3891 if (hbus->state == hv_pcibus_installed) { in hv_pci_remove()
3893 hbus->state = hv_pcibus_removing; in hv_pci_remove()
3895 destroy_workqueue(hbus->wq); in hv_pci_remove()
3896 hbus->wq = NULL; in hv_pci_remove()
3899 * on hbus-wq. We can't race with hv_pci_devices_present() in hv_pci_remove()
3905 pci_stop_root_bus(hbus->bridge->bus); in hv_pci_remove()
3906 hv_pci_remove_slots(hbus); in hv_pci_remove()
3907 pci_remove_root_bus(hbus->bridge->bus); in hv_pci_remove()
3915 iounmap(hbus->cfg_addr); in hv_pci_remove()
3916 hv_free_config_window(hbus); in hv_pci_remove()
3917 hv_pci_free_bridge_windows(hbus); in hv_pci_remove()
3918 irq_domain_remove(hbus->irq_domain); in hv_pci_remove()
3919 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_remove()
3921 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_remove()
3923 kfree(hbus); in hv_pci_remove()
3928 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_suspend() local
3938 * items onto hbus->wq in hv_pci_devices_present() and in hv_pci_suspend()
3945 * callback tasklet, sets hbus->state to hv_pcibus_removing, and in hv_pci_suspend()
3948 * hbus->wq and safely closes the vmbus channel. in hv_pci_suspend()
3952 /* Change the hbus state to prevent new work items. */ in hv_pci_suspend()
3953 old_state = hbus->state; in hv_pci_suspend()
3954 if (hbus->state == hv_pcibus_installed) in hv_pci_suspend()
3955 hbus->state = hv_pcibus_removing; in hv_pci_suspend()
3962 flush_workqueue(hbus->wq); in hv_pci_suspend()
4004 static void hv_pci_restore_msi_state(struct hv_pcibus_device *hbus) in hv_pci_restore_msi_state() argument
4006 pci_walk_bus(hbus->bridge->bus, hv_pci_restore_msi_msg, NULL); in hv_pci_restore_msi_state()
4011 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_resume() local
4015 hbus->state = hv_pcibus_init; in hv_pci_resume()
4022 hv_pci_onchannelcallback, hbus); in hv_pci_resume()
4027 version[0] = hbus->protocol_version; in hv_pci_resume()
4036 mutex_lock(&hbus->state_lock); in hv_pci_resume()
4046 prepopulate_bars(hbus); in hv_pci_resume()
4048 hv_pci_restore_msi_state(hbus); in hv_pci_resume()
4050 hbus->state = hv_pcibus_installed; in hv_pci_resume()
4051 mutex_unlock(&hbus->state_lock); in hv_pci_resume()
4055 mutex_unlock(&hbus->state_lock); in hv_pci_resume()