Lines Matching refs:hpdev

612 static void get_pcichild(struct hv_pci_dev *hpdev)  in get_pcichild()  argument
614 refcount_inc(&hpdev->refs); in get_pcichild()
617 static void put_pcichild(struct hv_pci_dev *hpdev) in put_pcichild() argument
619 if (refcount_dec_and_test(&hpdev->refs)) in put_pcichild()
620 kfree(hpdev); in put_pcichild()
693 static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_read_config() argument
697 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_read_config()
703 memcpy(val, ((u8 *)&hpdev->desc.v_id) + where, size); in _hv_pcifront_read_config()
706 memcpy(val, ((u8 *)&hpdev->desc.rev) + where - in _hv_pcifront_read_config()
710 memcpy(val, (u8 *)&hpdev->desc.subsystem_id + where - in _hv_pcifront_read_config()
725 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
727 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_read_config()
747 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
749 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_read_config()
754 static u16 hv_pcifront_get_vendor_id(struct hv_pci_dev *hpdev) in hv_pcifront_get_vendor_id() argument
758 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
761 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
764 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in hv_pcifront_get_vendor_id()
774 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
786 static void _hv_pcifront_write_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_write_config() argument
790 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_write_config()
796 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
798 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_write_config()
818 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
820 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_write_config()
841 struct hv_pci_dev *hpdev; in hv_pcifront_read_config() local
843 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
844 if (!hpdev) in hv_pcifront_read_config()
847 _hv_pcifront_read_config(hpdev, where, size, val); in hv_pcifront_read_config()
849 put_pcichild(hpdev); in hv_pcifront_read_config()
869 struct hv_pci_dev *hpdev; in hv_pcifront_write_config() local
871 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
872 if (!hpdev) in hv_pcifront_write_config()
875 _hv_pcifront_write_config(hpdev, where, size, val); in hv_pcifront_write_config()
877 put_pcichild(hpdev); in hv_pcifront_write_config()
1121 struct hv_pci_dev *hpdev; in hv_register_block_invalidate() local
1123 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1124 if (!hpdev) in hv_register_block_invalidate()
1127 hpdev->block_invalidate = block_invalidate; in hv_register_block_invalidate()
1128 hpdev->invalidate_context = context; in hv_register_block_invalidate()
1130 put_pcichild(hpdev); in hv_register_block_invalidate()
1136 static void hv_int_desc_free(struct hv_pci_dev *hpdev, in hv_int_desc_free() argument
1149 int_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_int_desc_free()
1151 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1171 struct hv_pci_dev *hpdev; in hv_msi_free() local
1184 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1185 if (!hpdev) { in hv_msi_free()
1190 hv_int_desc_free(hpdev, int_desc); in hv_msi_free()
1191 put_pcichild(hpdev); in hv_msi_free()
1425 struct hv_pci_dev *hpdev; in hv_compose_msi_msg() local
1448 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1449 if (!hpdev) in hv_compose_msi_msg()
1456 hv_int_desc_free(hpdev, int_desc); in hv_compose_msi_msg()
1472 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1480 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1487 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1501 ret = vmbus_sendpacket(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1526 if (hv_pcifront_get_vendor_id(hpdev) == 0xFFFF) { in hv_compose_msi_msg()
1547 if (hpdev->state == hv_pcichild_ejecting) { in hv_compose_msi_msg()
1578 put_pcichild(hpdev); in hv_compose_msi_msg()
1586 put_pcichild(hpdev); in hv_compose_msi_msg()
1671 struct hv_pci_dev *hpdev; in survey_child_resources() local
1696 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
1698 if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO) in survey_child_resources()
1702 if (hpdev->probed_bar[i] != 0) { in survey_child_resources()
1708 bar_val = hpdev->probed_bar[i]; in survey_child_resources()
1711 ((u64)hpdev->probed_bar[++i] << 32); in survey_child_resources()
1748 struct hv_pci_dev *hpdev; in prepopulate_bars() local
1779 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1780 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, &command); in prepopulate_bars()
1782 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2, command); in prepopulate_bars()
1787 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1789 bar_val = hpdev->probed_bar[i]; in prepopulate_bars()
1795 ((u64)hpdev->probed_bar[i + 1] in prepopulate_bars()
1806 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1811 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1818 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1827 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, in prepopulate_bars()
1830 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2, in prepopulate_bars()
1854 struct hv_pci_dev *hpdev; in hv_pci_assign_slots() local
1858 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
1859 if (hpdev->pci_slot) in hv_pci_assign_slots()
1862 slot_nr = PCI_SLOT(wslot_to_devfn(hpdev->desc.win_slot.slot)); in hv_pci_assign_slots()
1863 snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser); in hv_pci_assign_slots()
1864 hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, in hv_pci_assign_slots()
1866 if (IS_ERR(hpdev->pci_slot)) { in hv_pci_assign_slots()
1868 hpdev->pci_slot = NULL; in hv_pci_assign_slots()
1878 struct hv_pci_dev *hpdev; in hv_pci_remove_slots() local
1880 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
1881 if (!hpdev->pci_slot) in hv_pci_remove_slots()
1883 pci_destroy_slot(hpdev->pci_slot); in hv_pci_remove_slots()
1884 hpdev->pci_slot = NULL; in hv_pci_remove_slots()
1940 struct hv_pci_dev *hpdev; member
1961 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
1966 completion->hpdev->probed_bar[i] = in q_resource_requirements()
1988 struct hv_pci_dev *hpdev; in new_pcichild_device() local
1998 hpdev = kzalloc(sizeof(*hpdev), GFP_KERNEL); in new_pcichild_device()
1999 if (!hpdev) in new_pcichild_device()
2002 hpdev->hbus = hbus; in new_pcichild_device()
2006 comp_pkt.hpdev = hpdev; in new_pcichild_device()
2024 hpdev->desc = *desc; in new_pcichild_device()
2025 refcount_set(&hpdev->refs, 1); in new_pcichild_device()
2026 get_pcichild(hpdev); in new_pcichild_device()
2029 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2031 return hpdev; in new_pcichild_device()
2034 kfree(hpdev); in new_pcichild_device()
2055 struct hv_pci_dev *iter, *hpdev = NULL; in get_pcichild_wslot() local
2060 hpdev = iter; in get_pcichild_wslot()
2061 get_pcichild(hpdev); in get_pcichild_wslot()
2067 return hpdev; in get_pcichild_wslot()
2098 struct hv_pci_dev *hpdev; in pci_devices_present_work() local
2131 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2132 hpdev->reported_missing = true; in pci_devices_present_work()
2142 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2143 if ((hpdev->desc.win_slot.slot == new_desc->win_slot.slot) && in pci_devices_present_work()
2144 (hpdev->desc.v_id == new_desc->v_id) && in pci_devices_present_work()
2145 (hpdev->desc.d_id == new_desc->d_id) && in pci_devices_present_work()
2146 (hpdev->desc.ser == new_desc->ser)) { in pci_devices_present_work()
2147 hpdev->reported_missing = false; in pci_devices_present_work()
2154 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2155 if (!hpdev) in pci_devices_present_work()
2165 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2166 if (hpdev->reported_missing) { in pci_devices_present_work()
2168 put_pcichild(hpdev); in pci_devices_present_work()
2169 list_move_tail(&hpdev->list_entry, &removed); in pci_devices_present_work()
2178 hpdev = list_first_entry(&removed, struct hv_pci_dev, in pci_devices_present_work()
2180 list_del(&hpdev->list_entry); in pci_devices_present_work()
2182 if (hpdev->pci_slot) in pci_devices_present_work()
2183 pci_destroy_slot(hpdev->pci_slot); in pci_devices_present_work()
2185 put_pcichild(hpdev); in pci_devices_present_work()
2346 struct hv_pci_dev *hpdev; in hv_eject_device_work() local
2355 hpdev = container_of(work, struct hv_pci_dev, wrk); in hv_eject_device_work()
2356 hbus = hpdev->hbus; in hv_eject_device_work()
2358 WARN_ON(hpdev->state != hv_pcichild_ejecting); in hv_eject_device_work()
2366 wslot = wslot_to_devfn(hpdev->desc.win_slot.slot); in hv_eject_device_work()
2376 list_del(&hpdev->list_entry); in hv_eject_device_work()
2379 if (hpdev->pci_slot) in hv_eject_device_work()
2380 pci_destroy_slot(hpdev->pci_slot); in hv_eject_device_work()
2385 ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_eject_device_work()
2391 put_pcichild(hpdev); in hv_eject_device_work()
2393 put_pcichild(hpdev); in hv_eject_device_work()
2394 put_pcichild(hpdev); in hv_eject_device_work()
2406 static void hv_pci_eject_device(struct hv_pci_dev *hpdev) in hv_pci_eject_device() argument
2408 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device()
2416 hpdev->state = hv_pcichild_ejecting; in hv_pci_eject_device()
2417 get_pcichild(hpdev); in hv_pci_eject_device()
2418 INIT_WORK(&hpdev->wrk, hv_eject_device_work); in hv_pci_eject_device()
2419 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2446 struct hv_pci_dev *hpdev; in hv_pci_onchannelcallback() local
2527 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2529 if (hpdev) { in hv_pci_onchannelcallback()
2530 hv_pci_eject_device(hpdev); in hv_pci_onchannelcallback()
2531 put_pcichild(hpdev); in hv_pci_onchannelcallback()
2538 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2540 if (hpdev) { in hv_pci_onchannelcallback()
2541 if (hpdev->block_invalidate) { in hv_pci_onchannelcallback()
2542 hpdev->block_invalidate( in hv_pci_onchannelcallback()
2543 hpdev->invalidate_context, in hv_pci_onchannelcallback()
2546 put_pcichild(hpdev); in hv_pci_onchannelcallback()
2913 struct hv_pci_dev *hpdev; in hv_send_resources_allocated() local
2929 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
2930 if (!hpdev) in hv_send_resources_allocated()
2943 res_assigned->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
2949 res_assigned2->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
2951 put_pcichild(hpdev); in hv_send_resources_allocated()
2988 struct hv_pci_dev *hpdev; in hv_send_resources_released() local
2993 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
2994 if (!hpdev) in hv_send_resources_released()
2999 pkt.wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_released()
3001 put_pcichild(hpdev); in hv_send_resources_released()
3292 struct hv_pci_dev *hpdev, *tmp; in hv_pci_bus_exit() local
3309 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3310 list_move_tail(&hpdev->list_entry, &removed); in hv_pci_bus_exit()
3314 list_for_each_entry_safe(hpdev, tmp, &removed, list_entry) { in hv_pci_bus_exit()
3315 list_del(&hpdev->list_entry); in hv_pci_bus_exit()
3316 if (hpdev->pci_slot) in hv_pci_bus_exit()
3317 pci_destroy_slot(hpdev->pci_slot); in hv_pci_bus_exit()
3319 put_pcichild(hpdev); in hv_pci_bus_exit()
3320 put_pcichild(hpdev); in hv_pci_bus_exit()