Lines Matching refs:hpdev
991 static void get_pcichild(struct hv_pci_dev *hpdev) in get_pcichild() argument
993 refcount_inc(&hpdev->refs); in get_pcichild()
996 static void put_pcichild(struct hv_pci_dev *hpdev) in put_pcichild() argument
998 if (refcount_dec_and_test(&hpdev->refs)) in put_pcichild()
999 kfree(hpdev); in put_pcichild()
1072 static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_read_config() argument
1076 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_read_config()
1082 memcpy(val, ((u8 *)&hpdev->desc.v_id) + where, size); in _hv_pcifront_read_config()
1085 memcpy(val, ((u8 *)&hpdev->desc.rev) + where - in _hv_pcifront_read_config()
1089 memcpy(val, (u8 *)&hpdev->desc.subsystem_id + where - in _hv_pcifront_read_config()
1104 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
1106 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_read_config()
1126 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
1128 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_read_config()
1133 static u16 hv_pcifront_get_vendor_id(struct hv_pci_dev *hpdev) in hv_pcifront_get_vendor_id() argument
1137 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
1140 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1143 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in hv_pcifront_get_vendor_id()
1153 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1165 static void _hv_pcifront_write_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_write_config() argument
1169 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_write_config()
1175 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
1177 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_write_config()
1197 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
1199 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_write_config()
1220 struct hv_pci_dev *hpdev; in hv_pcifront_read_config() local
1222 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
1223 if (!hpdev) in hv_pcifront_read_config()
1226 _hv_pcifront_read_config(hpdev, where, size, val); in hv_pcifront_read_config()
1228 put_pcichild(hpdev); in hv_pcifront_read_config()
1248 struct hv_pci_dev *hpdev; in hv_pcifront_write_config() local
1250 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
1251 if (!hpdev) in hv_pcifront_write_config()
1254 _hv_pcifront_write_config(hpdev, where, size, val); in hv_pcifront_write_config()
1256 put_pcichild(hpdev); in hv_pcifront_write_config()
1500 struct hv_pci_dev *hpdev; in hv_register_block_invalidate() local
1502 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1503 if (!hpdev) in hv_register_block_invalidate()
1506 hpdev->block_invalidate = block_invalidate; in hv_register_block_invalidate()
1507 hpdev->invalidate_context = context; in hv_register_block_invalidate()
1509 put_pcichild(hpdev); in hv_register_block_invalidate()
1515 static void hv_int_desc_free(struct hv_pci_dev *hpdev, in hv_int_desc_free() argument
1532 int_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_int_desc_free()
1534 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1554 struct hv_pci_dev *hpdev; in hv_msi_free() local
1567 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1568 if (!hpdev) { in hv_msi_free()
1573 hv_int_desc_free(hpdev, int_desc); in hv_msi_free()
1574 put_pcichild(hpdev); in hv_msi_free()
1744 struct hv_pci_dev *hpdev; in hv_compose_msi_msg() local
1789 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1790 if (!hpdev) in hv_compose_msi_msg()
1797 hv_int_desc_free(hpdev, int_desc); in hv_compose_msi_msg()
1818 put_pcichild(hpdev); in hv_compose_msi_msg()
1849 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1858 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1866 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1881 ret = vmbus_sendpacket_getid(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1906 if (hv_pcifront_get_vendor_id(hpdev) == 0xFFFF) { in hv_compose_msi_msg()
1927 if (hpdev->state == hv_pcichild_ejecting) { in hv_compose_msi_msg()
1958 put_pcichild(hpdev); in hv_compose_msi_msg()
1975 put_pcichild(hpdev); in hv_compose_msi_msg()
2064 struct hv_pci_dev *hpdev; in survey_child_resources() local
2089 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
2091 if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO) in survey_child_resources()
2095 if (hpdev->probed_bar[i] != 0) { in survey_child_resources()
2101 bar_val = hpdev->probed_bar[i]; in survey_child_resources()
2104 ((u64)hpdev->probed_bar[++i] << 32); in survey_child_resources()
2141 struct hv_pci_dev *hpdev; in prepopulate_bars() local
2172 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2173 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, &command); in prepopulate_bars()
2175 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2, command); in prepopulate_bars()
2180 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2182 bar_val = hpdev->probed_bar[i]; in prepopulate_bars()
2188 ((u64)hpdev->probed_bar[i + 1] in prepopulate_bars()
2199 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
2204 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
2211 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
2252 struct hv_pci_dev *hpdev; in hv_pci_assign_slots() local
2256 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
2257 if (hpdev->pci_slot) in hv_pci_assign_slots()
2260 slot_nr = PCI_SLOT(wslot_to_devfn(hpdev->desc.win_slot.slot)); in hv_pci_assign_slots()
2261 snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser); in hv_pci_assign_slots()
2262 hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, in hv_pci_assign_slots()
2264 if (IS_ERR(hpdev->pci_slot)) { in hv_pci_assign_slots()
2266 hpdev->pci_slot = NULL; in hv_pci_assign_slots()
2276 struct hv_pci_dev *hpdev; in hv_pci_remove_slots() local
2278 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
2279 if (!hpdev->pci_slot) in hv_pci_remove_slots()
2281 pci_destroy_slot(hpdev->pci_slot); in hv_pci_remove_slots()
2282 hpdev->pci_slot = NULL; in hv_pci_remove_slots()
2347 struct hv_pci_dev *hpdev; member
2370 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
2375 completion->hpdev->probed_bar[i] = in q_resource_requirements()
2397 struct hv_pci_dev *hpdev; in new_pcichild_device() local
2407 hpdev = kzalloc(sizeof(*hpdev), GFP_KERNEL); in new_pcichild_device()
2408 if (!hpdev) in new_pcichild_device()
2411 hpdev->hbus = hbus; in new_pcichild_device()
2415 comp_pkt.hpdev = hpdev; in new_pcichild_device()
2433 hpdev->desc = *desc; in new_pcichild_device()
2434 refcount_set(&hpdev->refs, 1); in new_pcichild_device()
2435 get_pcichild(hpdev); in new_pcichild_device()
2438 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2440 return hpdev; in new_pcichild_device()
2443 kfree(hpdev); in new_pcichild_device()
2464 struct hv_pci_dev *iter, *hpdev = NULL; in get_pcichild_wslot() local
2469 hpdev = iter; in get_pcichild_wslot()
2470 get_pcichild(hpdev); in get_pcichild_wslot()
2476 return hpdev; in get_pcichild_wslot()
2507 struct hv_pci_dev *hpdev; in pci_devices_present_work() local
2540 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2541 hpdev->reported_missing = true; in pci_devices_present_work()
2551 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2552 if ((hpdev->desc.win_slot.slot == new_desc->win_slot.slot) && in pci_devices_present_work()
2553 (hpdev->desc.v_id == new_desc->v_id) && in pci_devices_present_work()
2554 (hpdev->desc.d_id == new_desc->d_id) && in pci_devices_present_work()
2555 (hpdev->desc.ser == new_desc->ser)) { in pci_devices_present_work()
2556 hpdev->reported_missing = false; in pci_devices_present_work()
2563 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2564 if (!hpdev) in pci_devices_present_work()
2574 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2575 if (hpdev->reported_missing) { in pci_devices_present_work()
2577 put_pcichild(hpdev); in pci_devices_present_work()
2578 list_move_tail(&hpdev->list_entry, &removed); in pci_devices_present_work()
2587 hpdev = list_first_entry(&removed, struct hv_pci_dev, in pci_devices_present_work()
2589 list_del(&hpdev->list_entry); in pci_devices_present_work()
2591 if (hpdev->pci_slot) in pci_devices_present_work()
2592 pci_destroy_slot(hpdev->pci_slot); in pci_devices_present_work()
2594 put_pcichild(hpdev); in pci_devices_present_work()
2755 struct hv_pci_dev *hpdev; in hv_eject_device_work() local
2764 hpdev = container_of(work, struct hv_pci_dev, wrk); in hv_eject_device_work()
2765 hbus = hpdev->hbus; in hv_eject_device_work()
2767 WARN_ON(hpdev->state != hv_pcichild_ejecting); in hv_eject_device_work()
2775 wslot = wslot_to_devfn(hpdev->desc.win_slot.slot); in hv_eject_device_work()
2785 list_del(&hpdev->list_entry); in hv_eject_device_work()
2788 if (hpdev->pci_slot) in hv_eject_device_work()
2789 pci_destroy_slot(hpdev->pci_slot); in hv_eject_device_work()
2794 ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_eject_device_work()
2800 put_pcichild(hpdev); in hv_eject_device_work()
2802 put_pcichild(hpdev); in hv_eject_device_work()
2803 put_pcichild(hpdev); in hv_eject_device_work()
2815 static void hv_pci_eject_device(struct hv_pci_dev *hpdev) in hv_pci_eject_device() argument
2817 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device()
2825 hpdev->state = hv_pcichild_ejecting; in hv_pci_eject_device()
2826 get_pcichild(hpdev); in hv_pci_eject_device()
2827 INIT_WORK(&hpdev->wrk, hv_eject_device_work); in hv_pci_eject_device()
2828 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2856 struct hv_pci_dev *hpdev; in hv_pci_onchannelcallback() local
2959 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2961 if (hpdev) { in hv_pci_onchannelcallback()
2962 hv_pci_eject_device(hpdev); in hv_pci_onchannelcallback()
2963 put_pcichild(hpdev); in hv_pci_onchannelcallback()
2975 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2977 if (hpdev) { in hv_pci_onchannelcallback()
2978 if (hpdev->block_invalidate) { in hv_pci_onchannelcallback()
2979 hpdev->block_invalidate( in hv_pci_onchannelcallback()
2980 hpdev->invalidate_context, in hv_pci_onchannelcallback()
2983 put_pcichild(hpdev); in hv_pci_onchannelcallback()
3350 struct hv_pci_dev *hpdev; in hv_send_resources_allocated() local
3366 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
3367 if (!hpdev) in hv_send_resources_allocated()
3380 res_assigned->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
3386 res_assigned2->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
3388 put_pcichild(hpdev); in hv_send_resources_allocated()
3425 struct hv_pci_dev *hpdev; in hv_send_resources_released() local
3430 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3431 if (!hpdev) in hv_send_resources_released()
3436 pkt.wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_released()
3438 put_pcichild(hpdev); in hv_send_resources_released()
3743 struct hv_pci_dev *hpdev, *tmp; in hv_pci_bus_exit() local
3761 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3762 list_move_tail(&hpdev->list_entry, &removed); in hv_pci_bus_exit()
3766 list_for_each_entry_safe(hpdev, tmp, &removed, list_entry) { in hv_pci_bus_exit()
3767 list_del(&hpdev->list_entry); in hv_pci_bus_exit()
3768 if (hpdev->pci_slot) in hv_pci_bus_exit()
3769 pci_destroy_slot(hpdev->pci_slot); in hv_pci_bus_exit()
3771 put_pcichild(hpdev); in hv_pci_bus_exit()
3772 put_pcichild(hpdev); in hv_pci_bus_exit()