Lines Matching full:hbus

558 	struct hv_pcibus_device *hbus;  member
616 struct hv_pcibus_device *hbus; in hv_irq_retarget_interrupt() local
629 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_irq_retarget_interrupt()
632 dev_warn(&hbus->hdev->device, "%s() can not unmask irq %u\n", in hv_irq_retarget_interrupt()
645 params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | in hv_irq_retarget_interrupt()
646 (hbus->hdev->dev_instance.b[4] << 16) | in hv_irq_retarget_interrupt()
647 (hbus->hdev->dev_instance.b[7] << 8) | in hv_irq_retarget_interrupt()
648 (hbus->hdev->dev_instance.b[6] & 0xf8) | in hv_irq_retarget_interrupt()
652 if (hbus->protocol_version >= PCI_PROTOCOL_VERSION_1_2) { in hv_irq_retarget_interrupt()
712 if (!hv_result_success(res) && hbus->state != hv_pcibus_removing) in hv_irq_retarget_interrupt()
713 dev_err(&hbus->hdev->device, in hv_irq_retarget_interrupt()
1028 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus,
1179 struct hv_pcibus_device *hbus = hpdev->hbus; in _hv_pcifront_read_config() local
1180 struct device *dev = &hbus->hdev->device; in _hv_pcifront_read_config()
1211 spin_lock_irqsave(&hbus->config_lock, flags); in _hv_pcifront_read_config()
1212 if (hbus->use_calls) { in _hv_pcifront_read_config()
1213 phys_addr_t addr = hbus->mem_config->start + offset; in _hv_pcifront_read_config()
1215 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in _hv_pcifront_read_config()
1219 void __iomem *addr = hbus->cfg_addr + offset; in _hv_pcifront_read_config()
1222 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in _hv_pcifront_read_config()
1243 spin_unlock_irqrestore(&hbus->config_lock, flags); in _hv_pcifront_read_config()
1251 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pcifront_get_vendor_id() local
1252 struct device *dev = &hbus->hdev->device; in hv_pcifront_get_vendor_id()
1257 spin_lock_irqsave(&hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1259 if (hbus->use_calls) { in hv_pcifront_get_vendor_id()
1260 phys_addr_t addr = hbus->mem_config->start + in hv_pcifront_get_vendor_id()
1263 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in hv_pcifront_get_vendor_id()
1268 void __iomem *addr = hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
1271 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in hv_pcifront_get_vendor_id()
1282 spin_unlock_irqrestore(&hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1297 struct hv_pcibus_device *hbus = hpdev->hbus; in _hv_pcifront_write_config() local
1298 struct device *dev = &hbus->hdev->device; in _hv_pcifront_write_config()
1306 spin_lock_irqsave(&hbus->config_lock, flags); in _hv_pcifront_write_config()
1308 if (hbus->use_calls) { in _hv_pcifront_write_config()
1309 phys_addr_t addr = hbus->mem_config->start + offset; in _hv_pcifront_write_config()
1311 hv_pci_write_mmio(dev, hbus->mem_config->start, 4, in _hv_pcifront_write_config()
1315 void __iomem *addr = hbus->cfg_addr + offset; in _hv_pcifront_write_config()
1318 writel(hpdev->desc.win_slot.slot, hbus->cfg_addr); in _hv_pcifront_write_config()
1339 spin_unlock_irqrestore(&hbus->config_lock, flags); in _hv_pcifront_write_config()
1359 struct hv_pcibus_device *hbus = in hv_pcifront_read_config() local
1363 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
1387 struct hv_pcibus_device *hbus = in hv_pcifront_write_config() local
1391 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
1488 struct hv_pcibus_device *hbus = in hv_read_config_block() local
1515 ret = vmbus_sendpacket(hbus->hdev->channel, read_blk, in hv_read_config_block()
1522 ret = wait_for_response(hbus->hdev, &comp_pkt.comp_pkt.host_event); in hv_read_config_block()
1528 dev_err(&hbus->hdev->device, in hv_read_config_block()
1568 struct hv_pcibus_device *hbus = in hv_write_config_block() local
1605 ret = vmbus_sendpacket(hbus->hdev->channel, write_blk, pkt_size, in hv_write_config_block()
1611 ret = wait_for_response(hbus->hdev, &comp_pkt.host_event); in hv_write_config_block()
1616 dev_err(&hbus->hdev->device, in hv_write_config_block()
1638 struct hv_pcibus_device *hbus = in hv_register_block_invalidate() local
1643 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1675 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1692 struct hv_pcibus_device *hbus; in hv_msi_free() local
1700 hbus = domain->host_data; in hv_msi_free()
1706 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1878 struct hv_pcibus_device *hbus; in hv_compose_msi_msg() local
1923 hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); in hv_compose_msi_msg()
1924 channel = hbus->hdev->channel; in hv_compose_msi_msg()
1925 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1982 switch (hbus->protocol_version) { in hv_compose_msi_msg()
2012 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
2017 ret = vmbus_sendpacket_getid(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
2022 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
2043 dev_err_once(&hbus->hdev->device, in hv_compose_msi_msg()
2060 hv_pci_onchannelcallback(hbus); in hv_compose_msi_msg()
2069 dev_err(&hbus->hdev->device, in hv_compose_msi_msg()
2195 * @hbus: The root PCI bus
2206 static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus) in hv_pcie_init_irq_domain() argument
2209 .fwnode = hbus->fwnode, in hv_pcie_init_irq_domain()
2211 .host_data = hbus, in hv_pcie_init_irq_domain()
2215 hbus->irq_domain = msi_create_parent_irq_domain(&info, &hv_pcie_msi_parent_ops); in hv_pcie_init_irq_domain()
2216 if (!hbus->irq_domain) { in hv_pcie_init_irq_domain()
2217 dev_err(&hbus->hdev->device, in hv_pcie_init_irq_domain()
2222 dev_set_msi_domain(&hbus->bridge->dev, hbus->irq_domain); in hv_pcie_init_irq_domain()
2249 * @hbus: Root PCI bus, as understood by this driver
2251 static void survey_child_resources(struct hv_pcibus_device *hbus) in survey_child_resources() argument
2261 event = xchg(&hbus->survey_event, NULL); in survey_child_resources()
2266 if (hbus->low_mmio_space || hbus->high_mmio_space) { in survey_child_resources()
2271 spin_lock_irqsave(&hbus->device_list_lock, flags); in survey_child_resources()
2278 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
2281 dev_err(&hbus->hdev->device, in survey_child_resources()
2300 hbus->high_mmio_space += bar_size; in survey_child_resources()
2302 hbus->low_mmio_space += bar_size; in survey_child_resources()
2307 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in survey_child_resources()
2313 * @hbus: Root PCI bus, as understood by this driver
2323 static void prepopulate_bars(struct hv_pcibus_device *hbus) in prepopulate_bars() argument
2337 if (hbus->low_mmio_space) { in prepopulate_bars()
2338 low_size = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in prepopulate_bars()
2339 low_base = hbus->low_mmio_res->start; in prepopulate_bars()
2342 if (hbus->high_mmio_space) { in prepopulate_bars()
2344 (63 - __builtin_clzll(hbus->high_mmio_space)); in prepopulate_bars()
2345 high_base = hbus->high_mmio_res->start; in prepopulate_bars()
2348 spin_lock_irqsave(&hbus->device_list_lock, flags); in prepopulate_bars()
2361 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2369 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2427 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in prepopulate_bars()
2436 * same ordered workqueue. Therefore hbus->children list will not change
2439 static void hv_pci_assign_slots(struct hv_pcibus_device *hbus) in hv_pci_assign_slots() argument
2445 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
2451 hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, in hv_pci_assign_slots()
2463 static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) in hv_pci_remove_slots() argument
2467 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
2478 static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) in hv_pci_assign_numa_node() argument
2481 struct pci_bus *bus = hbus->bridge->bus; in hv_pci_assign_numa_node()
2485 hv_dev = get_pcichild_wslot(hbus, devfn_to_wslot(dev->devfn)); in hv_pci_assign_numa_node()
2507 * @hbus: Root PCI bus, as understood by this driver
2511 static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) in create_root_hv_pci_bus() argument
2514 struct pci_host_bridge *bridge = hbus->bridge; in create_root_hv_pci_bus()
2516 bridge->dev.parent = &hbus->hdev->device; in create_root_hv_pci_bus()
2517 bridge->sysdata = &hbus->sysdata; in create_root_hv_pci_bus()
2525 hv_pci_assign_numa_node(hbus); in create_root_hv_pci_bus()
2527 hv_pci_assign_slots(hbus); in create_root_hv_pci_bus()
2530 hbus->state = hv_pcibus_installed; in create_root_hv_pci_bus()
2559 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
2574 * @hbus: The internal struct tracking this root PCI bus.
2583 static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus, in new_pcichild_device() argument
2600 hpdev->hbus = hbus; in new_pcichild_device()
2611 ret = vmbus_sendpacket(hbus->hdev->channel, res_req, in new_pcichild_device()
2619 if (wait_for_response(hbus->hdev, &comp_pkt.host_event)) in new_pcichild_device()
2625 spin_lock_irqsave(&hbus->device_list_lock, flags); in new_pcichild_device()
2627 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2628 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in new_pcichild_device()
2638 * @hbus: Root PCI bus, as understood by this driver
2649 static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, in get_pcichild_wslot() argument
2655 spin_lock_irqsave(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2656 list_for_each_entry(iter, &hbus->children, list_entry) { in get_pcichild_wslot()
2663 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in get_pcichild_wslot()
2689 * because both are pushed to the ordered workqueue hbus->wq.
2697 struct hv_pcibus_device *hbus; in pci_devices_present_work() local
2704 hbus = dr_wrk->bus; in pci_devices_present_work()
2710 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2711 while (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2712 dr = list_first_entry(&hbus->dr_list, struct hv_dr_state, in pci_devices_present_work()
2717 if (!list_empty(&hbus->dr_list)) { in pci_devices_present_work()
2722 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2727 mutex_lock(&hbus->state_lock); in pci_devices_present_work()
2730 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2731 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2734 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2741 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2742 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2751 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2754 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2756 dev_err(&hbus->hdev->device, in pci_devices_present_work()
2762 spin_lock_irqsave(&hbus->device_list_lock, flags); in pci_devices_present_work()
2765 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2774 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in pci_devices_present_work()
2788 switch (hbus->state) { in pci_devices_present_work()
2795 pci_scan_child_bus(hbus->bridge->bus); in pci_devices_present_work()
2796 hv_pci_assign_numa_node(hbus); in pci_devices_present_work()
2797 hv_pci_assign_slots(hbus); in pci_devices_present_work()
2803 survey_child_resources(hbus); in pci_devices_present_work()
2810 mutex_unlock(&hbus->state_lock); in pci_devices_present_work()
2817 * @hbus: Root PCI bus, as understood by this driver
2822 static int hv_pci_start_relations_work(struct hv_pcibus_device *hbus, in hv_pci_start_relations_work() argument
2829 if (hbus->state == hv_pcibus_removing) { in hv_pci_start_relations_work()
2830 dev_info(&hbus->hdev->device, in hv_pci_start_relations_work()
2840 dr_wrk->bus = hbus; in hv_pci_start_relations_work()
2842 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2848 pending_dr = !list_empty(&hbus->dr_list); in hv_pci_start_relations_work()
2849 list_add_tail(&dr->list_entry, &hbus->dr_list); in hv_pci_start_relations_work()
2850 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_start_relations_work()
2855 queue_work(hbus->wq, &dr_wrk->wrk); in hv_pci_start_relations_work()
2862 * @hbus: Root PCI bus, as understood by this driver
2869 static void hv_pci_devices_present(struct hv_pcibus_device *hbus, in hv_pci_devices_present() argument
2893 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present()
2899 * @hbus: Root PCI bus, as understood by this driver
2904 static void hv_pci_devices_present2(struct hv_pcibus_device *hbus, in hv_pci_devices_present2() argument
2931 if (hv_pci_start_relations_work(hbus, dr)) in hv_pci_devices_present2()
2947 struct hv_pcibus_device *hbus; in hv_eject_device_work() local
2958 hbus = hpdev->hbus; in hv_eject_device_work()
2960 mutex_lock(&hbus->state_lock); in hv_eject_device_work()
2965 * must be done without constructs like pci_domain_nr(hbus->bridge->bus) in hv_eject_device_work()
2966 * because hbus->bridge->bus may not exist yet. in hv_eject_device_work()
2969 pdev = pci_get_domain_bus_and_slot(hbus->bridge->domain_nr, 0, wslot); in hv_eject_device_work()
2977 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_eject_device_work()
2979 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_eject_device_work()
2988 vmbus_sendpacket(hbus->hdev->channel, ejct_pkt, in hv_eject_device_work()
2999 mutex_unlock(&hbus->state_lock); in hv_eject_device_work()
3012 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device() local
3013 struct hv_device *hdev = hbus->hdev; in hv_pci_eject_device()
3015 if (hbus->state == hv_pcibus_removing) { in hv_pci_eject_device()
3022 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
3036 struct hv_pcibus_device *hbus = context; in hv_pci_onchannelcallback() local
3037 struct vmbus_channel *chan = hbus->hdev->channel; in hv_pci_onchannelcallback()
3091 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3122 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3127 hv_pci_devices_present(hbus, bus_rel); in hv_pci_onchannelcallback()
3137 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3142 hv_pci_devices_present2(hbus, bus_rel2); in hv_pci_onchannelcallback()
3149 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3153 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
3165 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3169 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
3182 dev_warn(&hbus->hdev->device, in hv_pci_onchannelcallback()
3190 dev_err(&hbus->hdev->device, in hv_pci_onchannelcallback()
3223 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_protocol_negotiation() local
3263 hbus->protocol_version = version[i]; in hv_pci_protocol_negotiation()
3266 hbus->protocol_version); in hv_pci_protocol_negotiation()
3293 * @hbus: Root PCI bus, as understood by this driver
3295 static void hv_pci_free_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_free_bridge_windows() argument
3302 if (hbus->low_mmio_space && hbus->low_mmio_res) { in hv_pci_free_bridge_windows()
3303 hbus->low_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3304 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_free_bridge_windows()
3305 resource_size(hbus->low_mmio_res)); in hv_pci_free_bridge_windows()
3308 if (hbus->high_mmio_space && hbus->high_mmio_res) { in hv_pci_free_bridge_windows()
3309 hbus->high_mmio_res->flags |= IORESOURCE_BUSY; in hv_pci_free_bridge_windows()
3310 vmbus_free_mmio(hbus->high_mmio_res->start, in hv_pci_free_bridge_windows()
3311 resource_size(hbus->high_mmio_res)); in hv_pci_free_bridge_windows()
3318 * @hbus: Root PCI bus, as understood by this driver
3340 static int hv_pci_allocate_bridge_windows(struct hv_pcibus_device *hbus) in hv_pci_allocate_bridge_windows() argument
3345 if (hbus->low_mmio_space) { in hv_pci_allocate_bridge_windows()
3346 align = 1ULL << (63 - __builtin_clzll(hbus->low_mmio_space)); in hv_pci_allocate_bridge_windows()
3347 ret = vmbus_allocate_mmio(&hbus->low_mmio_res, hbus->hdev, 0, in hv_pci_allocate_bridge_windows()
3349 hbus->low_mmio_space, in hv_pci_allocate_bridge_windows()
3352 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3354 hbus->low_mmio_space); in hv_pci_allocate_bridge_windows()
3359 hbus->low_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3360 hbus->low_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3361 pci_add_resource(&hbus->bridge->windows, hbus->low_mmio_res); in hv_pci_allocate_bridge_windows()
3364 if (hbus->high_mmio_space) { in hv_pci_allocate_bridge_windows()
3365 align = 1ULL << (63 - __builtin_clzll(hbus->high_mmio_space)); in hv_pci_allocate_bridge_windows()
3366 ret = vmbus_allocate_mmio(&hbus->high_mmio_res, hbus->hdev, in hv_pci_allocate_bridge_windows()
3368 hbus->high_mmio_space, align, in hv_pci_allocate_bridge_windows()
3371 dev_err(&hbus->hdev->device, in hv_pci_allocate_bridge_windows()
3373 hbus->high_mmio_space); in hv_pci_allocate_bridge_windows()
3378 hbus->high_mmio_res->flags |= IORESOURCE_WINDOW; in hv_pci_allocate_bridge_windows()
3379 hbus->high_mmio_res->flags &= ~IORESOURCE_BUSY; in hv_pci_allocate_bridge_windows()
3380 pci_add_resource(&hbus->bridge->windows, hbus->high_mmio_res); in hv_pci_allocate_bridge_windows()
3386 if (hbus->low_mmio_res) { in hv_pci_allocate_bridge_windows()
3387 vmbus_free_mmio(hbus->low_mmio_res->start, in hv_pci_allocate_bridge_windows()
3388 resource_size(hbus->low_mmio_res)); in hv_pci_allocate_bridge_windows()
3396 * @hbus: Root PCI bus, as understood by this driver
3403 static int hv_allocate_config_window(struct hv_pcibus_device *hbus) in hv_allocate_config_window() argument
3411 ret = vmbus_allocate_mmio(&hbus->mem_config, hbus->hdev, 0, -1, in hv_allocate_config_window()
3424 hbus->mem_config->flags |= IORESOURCE_BUSY; in hv_allocate_config_window()
3429 static void hv_free_config_window(struct hv_pcibus_device *hbus) in hv_free_config_window() argument
3431 vmbus_free_mmio(hbus->mem_config->start, PCI_CONFIG_MMIO_LENGTH); in hv_free_config_window()
3444 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_enter_d0() local
3467 d0_entry->mmio_base = hbus->mem_config->start; in hv_pci_enter_d0()
3498 hbus->wslot_res_allocated = 255; in hv_pci_enter_d0()
3534 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_query_relations() local
3541 if (cmpxchg(&hbus->survey_event, NULL, &comp)) in hv_pci_query_relations()
3556 * channel callback already scheduled a work to hbus->wq, which can be in hv_pci_query_relations()
3558 * complete(&hbus->survey_event), even after hv_pci_query_relations() in hv_pci_query_relations()
3561 * raw_spin_lock_irqsave(). Flush hbus->wq before we exit from in hv_pci_query_relations()
3563 * -ENODEV, there can't be any more work item scheduled to hbus->wq in hv_pci_query_relations()
3568 flush_workqueue(hbus->wq); in hv_pci_query_relations()
3592 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_allocated() local
3602 size_res = (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) in hv_send_resources_allocated()
3612 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
3621 if (hbus->protocol_version < PCI_PROTOCOL_VERSION_1_2) { in hv_send_resources_allocated()
3653 hbus->wslot_res_allocated = wslot; in hv_send_resources_allocated()
3669 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_send_resources_released() local
3675 for (wslot = hbus->wslot_res_allocated; wslot >= 0; wslot--) { in hv_send_resources_released()
3676 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3691 hbus->wslot_res_allocated = wslot - 1; in hv_send_resources_released()
3694 hbus->wslot_res_allocated = -1; in hv_send_resources_released()
3752 struct hv_pcibus_device *hbus; in hv_pci_probe() local
3761 hbus = kzalloc(sizeof(*hbus), GFP_KERNEL); in hv_pci_probe()
3762 if (!hbus) in hv_pci_probe()
3765 hbus->bridge = bridge; in hv_pci_probe()
3766 mutex_init(&hbus->state_lock); in hv_pci_probe()
3767 hbus->state = hv_pcibus_init; in hv_pci_probe()
3768 hbus->wslot_res_allocated = -1; in hv_pci_probe()
3798 hbus->bridge->domain_nr = dom; in hv_pci_probe()
3800 hbus->sysdata.domain = dom; in hv_pci_probe()
3801 hbus->use_calls = !!(ms_hyperv.hints & HV_X64_USE_MMIO_HYPERCALLS); in hv_pci_probe()
3810 hbus->sysdata.parent = hdev->device.parent; in hv_pci_probe()
3811 hbus->use_calls = false; in hv_pci_probe()
3814 hbus->hdev = hdev; in hv_pci_probe()
3815 INIT_LIST_HEAD(&hbus->children); in hv_pci_probe()
3816 INIT_LIST_HEAD(&hbus->dr_list); in hv_pci_probe()
3817 spin_lock_init(&hbus->config_lock); in hv_pci_probe()
3818 spin_lock_init(&hbus->device_list_lock); in hv_pci_probe()
3819 hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, in hv_pci_probe()
3820 hbus->bridge->domain_nr); in hv_pci_probe()
3821 if (!hbus->wq) { in hv_pci_probe()
3831 hv_pci_onchannelcallback, hbus); in hv_pci_probe()
3835 hv_set_drvdata(hdev, hbus); in hv_pci_probe()
3842 ret = hv_allocate_config_window(hbus); in hv_pci_probe()
3846 hbus->cfg_addr = ioremap(hbus->mem_config->start, in hv_pci_probe()
3848 if (!hbus->cfg_addr) { in hv_pci_probe()
3861 hbus->fwnode = irq_domain_alloc_named_fwnode(name); in hv_pci_probe()
3863 if (!hbus->fwnode) { in hv_pci_probe()
3868 ret = hv_pcie_init_irq_domain(hbus); in hv_pci_probe()
3876 mutex_lock(&hbus->state_lock); in hv_pci_probe()
3882 ret = hv_pci_allocate_bridge_windows(hbus); in hv_pci_probe()
3890 prepopulate_bars(hbus); in hv_pci_probe()
3892 hbus->state = hv_pcibus_probed; in hv_pci_probe()
3894 ret = create_root_hv_pci_bus(hbus); in hv_pci_probe()
3898 mutex_unlock(&hbus->state_lock); in hv_pci_probe()
3902 hv_pci_free_bridge_windows(hbus); in hv_pci_probe()
3906 mutex_unlock(&hbus->state_lock); in hv_pci_probe()
3908 irq_domain_remove(hbus->irq_domain); in hv_pci_probe()
3910 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_probe()
3912 iounmap(hbus->cfg_addr); in hv_pci_probe()
3914 hv_free_config_window(hbus); in hv_pci_probe()
3918 destroy_workqueue(hbus->wq); in hv_pci_probe()
3920 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_probe()
3922 kfree(hbus); in hv_pci_probe()
3928 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_bus_exit() local
3953 spin_lock_irqsave(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
3954 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3956 spin_unlock_irqrestore(&hbus->device_list_lock, flags); in hv_pci_bus_exit()
4012 struct hv_pcibus_device *hbus; in hv_pci_remove() local
4014 hbus = hv_get_drvdata(hdev); in hv_pci_remove()
4015 if (hbus->state == hv_pcibus_installed) { in hv_pci_remove()
4017 hbus->state = hv_pcibus_removing; in hv_pci_remove()
4019 destroy_workqueue(hbus->wq); in hv_pci_remove()
4020 hbus->wq = NULL; in hv_pci_remove()
4023 * on hbus-wq. We can't race with hv_pci_devices_present() in hv_pci_remove()
4029 pci_stop_root_bus(hbus->bridge->bus); in hv_pci_remove()
4030 hv_pci_remove_slots(hbus); in hv_pci_remove()
4031 pci_remove_root_bus(hbus->bridge->bus); in hv_pci_remove()
4039 iounmap(hbus->cfg_addr); in hv_pci_remove()
4040 hv_free_config_window(hbus); in hv_pci_remove()
4041 hv_pci_free_bridge_windows(hbus); in hv_pci_remove()
4042 irq_domain_remove(hbus->irq_domain); in hv_pci_remove()
4043 irq_domain_free_fwnode(hbus->fwnode); in hv_pci_remove()
4045 hv_put_dom_num(hbus->bridge->domain_nr); in hv_pci_remove()
4047 kfree(hbus); in hv_pci_remove()
4052 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_suspend() local
4062 * items onto hbus->wq in hv_pci_devices_present() and in hv_pci_suspend()
4069 * callback tasklet, sets hbus->state to hv_pcibus_removing, and in hv_pci_suspend()
4072 * hbus->wq and safely closes the vmbus channel. in hv_pci_suspend()
4076 /* Change the hbus state to prevent new work items. */ in hv_pci_suspend()
4077 old_state = hbus->state; in hv_pci_suspend()
4078 if (hbus->state == hv_pcibus_installed) in hv_pci_suspend()
4079 hbus->state = hv_pcibus_removing; in hv_pci_suspend()
4086 flush_workqueue(hbus->wq); in hv_pci_suspend()
4122 static void hv_pci_restore_msi_state(struct hv_pcibus_device *hbus) in hv_pci_restore_msi_state() argument
4124 pci_walk_bus(hbus->bridge->bus, hv_pci_restore_msi_msg, NULL); in hv_pci_restore_msi_state()
4129 struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); in hv_pci_resume() local
4133 hbus->state = hv_pcibus_init; in hv_pci_resume()
4140 hv_pci_onchannelcallback, hbus); in hv_pci_resume()
4145 version[0] = hbus->protocol_version; in hv_pci_resume()
4154 mutex_lock(&hbus->state_lock); in hv_pci_resume()
4164 prepopulate_bars(hbus); in hv_pci_resume()
4166 hv_pci_restore_msi_state(hbus); in hv_pci_resume()
4168 hbus->state = hv_pcibus_installed; in hv_pci_resume()
4169 mutex_unlock(&hbus->state_lock); in hv_pci_resume()
4173 mutex_unlock(&hbus->state_lock); in hv_pci_resume()