Lines Matching refs:hpdev
978 static void get_pcichild(struct hv_pci_dev *hpdev) in get_pcichild() argument
980 refcount_inc(&hpdev->refs); in get_pcichild()
983 static void put_pcichild(struct hv_pci_dev *hpdev) in put_pcichild() argument
985 if (refcount_dec_and_test(&hpdev->refs)) in put_pcichild()
986 kfree(hpdev); in put_pcichild()
1059 static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_read_config() argument
1063 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_read_config()
1069 memcpy(val, ((u8 *)&hpdev->desc.v_id) + where, size); in _hv_pcifront_read_config()
1072 memcpy(val, ((u8 *)&hpdev->desc.rev) + where - in _hv_pcifront_read_config()
1076 memcpy(val, (u8 *)&hpdev->desc.subsystem_id + where - in _hv_pcifront_read_config()
1091 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
1093 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_read_config()
1113 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
1115 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_read_config()
1120 static u16 hv_pcifront_get_vendor_id(struct hv_pci_dev *hpdev) in hv_pcifront_get_vendor_id() argument
1124 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
1127 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1130 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in hv_pcifront_get_vendor_id()
1140 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
1152 static void _hv_pcifront_write_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_write_config() argument
1156 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_write_config()
1162 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
1164 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_write_config()
1184 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
1186 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_write_config()
1207 struct hv_pci_dev *hpdev; in hv_pcifront_read_config() local
1209 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
1210 if (!hpdev) in hv_pcifront_read_config()
1213 _hv_pcifront_read_config(hpdev, where, size, val); in hv_pcifront_read_config()
1215 put_pcichild(hpdev); in hv_pcifront_read_config()
1235 struct hv_pci_dev *hpdev; in hv_pcifront_write_config() local
1237 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
1238 if (!hpdev) in hv_pcifront_write_config()
1241 _hv_pcifront_write_config(hpdev, where, size, val); in hv_pcifront_write_config()
1243 put_pcichild(hpdev); in hv_pcifront_write_config()
1487 struct hv_pci_dev *hpdev; in hv_register_block_invalidate() local
1489 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1490 if (!hpdev) in hv_register_block_invalidate()
1493 hpdev->block_invalidate = block_invalidate; in hv_register_block_invalidate()
1494 hpdev->invalidate_context = context; in hv_register_block_invalidate()
1496 put_pcichild(hpdev); in hv_register_block_invalidate()
1502 static void hv_int_desc_free(struct hv_pci_dev *hpdev, in hv_int_desc_free() argument
1519 int_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_int_desc_free()
1521 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1541 struct hv_pci_dev *hpdev; in hv_msi_free() local
1554 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1555 if (!hpdev) { in hv_msi_free()
1560 hv_int_desc_free(hpdev, int_desc); in hv_msi_free()
1561 put_pcichild(hpdev); in hv_msi_free()
1731 struct hv_pci_dev *hpdev; in hv_compose_msi_msg() local
1776 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1777 if (!hpdev) in hv_compose_msi_msg()
1784 hv_int_desc_free(hpdev, int_desc); in hv_compose_msi_msg()
1805 put_pcichild(hpdev); in hv_compose_msi_msg()
1836 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1845 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1853 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1868 ret = vmbus_sendpacket_getid(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1893 if (hv_pcifront_get_vendor_id(hpdev) == 0xFFFF) { in hv_compose_msi_msg()
1914 if (hpdev->state == hv_pcichild_ejecting) { in hv_compose_msi_msg()
1945 put_pcichild(hpdev); in hv_compose_msi_msg()
1962 put_pcichild(hpdev); in hv_compose_msi_msg()
2051 struct hv_pci_dev *hpdev; in survey_child_resources() local
2076 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
2078 if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO) in survey_child_resources()
2082 if (hpdev->probed_bar[i] != 0) { in survey_child_resources()
2088 bar_val = hpdev->probed_bar[i]; in survey_child_resources()
2091 ((u64)hpdev->probed_bar[++i] << 32); in survey_child_resources()
2128 struct hv_pci_dev *hpdev; in prepopulate_bars() local
2159 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2160 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, &command); in prepopulate_bars()
2162 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2, command); in prepopulate_bars()
2167 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
2169 bar_val = hpdev->probed_bar[i]; in prepopulate_bars()
2175 ((u64)hpdev->probed_bar[i + 1] in prepopulate_bars()
2186 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
2191 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
2198 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
2239 struct hv_pci_dev *hpdev; in hv_pci_assign_slots() local
2243 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
2244 if (hpdev->pci_slot) in hv_pci_assign_slots()
2247 slot_nr = PCI_SLOT(wslot_to_devfn(hpdev->desc.win_slot.slot)); in hv_pci_assign_slots()
2248 snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser); in hv_pci_assign_slots()
2249 hpdev->pci_slot = pci_create_slot(hbus->bridge->bus, slot_nr, in hv_pci_assign_slots()
2251 if (IS_ERR(hpdev->pci_slot)) { in hv_pci_assign_slots()
2253 hpdev->pci_slot = NULL; in hv_pci_assign_slots()
2263 struct hv_pci_dev *hpdev; in hv_pci_remove_slots() local
2265 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
2266 if (!hpdev->pci_slot) in hv_pci_remove_slots()
2268 pci_destroy_slot(hpdev->pci_slot); in hv_pci_remove_slots()
2269 hpdev->pci_slot = NULL; in hv_pci_remove_slots()
2334 struct hv_pci_dev *hpdev; member
2357 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
2362 completion->hpdev->probed_bar[i] = in q_resource_requirements()
2384 struct hv_pci_dev *hpdev; in new_pcichild_device() local
2394 hpdev = kzalloc(sizeof(*hpdev), GFP_KERNEL); in new_pcichild_device()
2395 if (!hpdev) in new_pcichild_device()
2398 hpdev->hbus = hbus; in new_pcichild_device()
2402 comp_pkt.hpdev = hpdev; in new_pcichild_device()
2420 hpdev->desc = *desc; in new_pcichild_device()
2421 refcount_set(&hpdev->refs, 1); in new_pcichild_device()
2422 get_pcichild(hpdev); in new_pcichild_device()
2425 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2427 return hpdev; in new_pcichild_device()
2430 kfree(hpdev); in new_pcichild_device()
2451 struct hv_pci_dev *iter, *hpdev = NULL; in get_pcichild_wslot() local
2456 hpdev = iter; in get_pcichild_wslot()
2457 get_pcichild(hpdev); in get_pcichild_wslot()
2463 return hpdev; in get_pcichild_wslot()
2494 struct hv_pci_dev *hpdev; in pci_devices_present_work() local
2527 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2528 hpdev->reported_missing = true; in pci_devices_present_work()
2538 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2539 if ((hpdev->desc.win_slot.slot == new_desc->win_slot.slot) && in pci_devices_present_work()
2540 (hpdev->desc.v_id == new_desc->v_id) && in pci_devices_present_work()
2541 (hpdev->desc.d_id == new_desc->d_id) && in pci_devices_present_work()
2542 (hpdev->desc.ser == new_desc->ser)) { in pci_devices_present_work()
2543 hpdev->reported_missing = false; in pci_devices_present_work()
2550 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2551 if (!hpdev) in pci_devices_present_work()
2561 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2562 if (hpdev->reported_missing) { in pci_devices_present_work()
2564 put_pcichild(hpdev); in pci_devices_present_work()
2565 list_move_tail(&hpdev->list_entry, &removed); in pci_devices_present_work()
2574 hpdev = list_first_entry(&removed, struct hv_pci_dev, in pci_devices_present_work()
2576 list_del(&hpdev->list_entry); in pci_devices_present_work()
2578 if (hpdev->pci_slot) in pci_devices_present_work()
2579 pci_destroy_slot(hpdev->pci_slot); in pci_devices_present_work()
2581 put_pcichild(hpdev); in pci_devices_present_work()
2742 struct hv_pci_dev *hpdev; in hv_eject_device_work() local
2751 hpdev = container_of(work, struct hv_pci_dev, wrk); in hv_eject_device_work()
2752 hbus = hpdev->hbus; in hv_eject_device_work()
2754 WARN_ON(hpdev->state != hv_pcichild_ejecting); in hv_eject_device_work()
2762 wslot = wslot_to_devfn(hpdev->desc.win_slot.slot); in hv_eject_device_work()
2772 list_del(&hpdev->list_entry); in hv_eject_device_work()
2775 if (hpdev->pci_slot) in hv_eject_device_work()
2776 pci_destroy_slot(hpdev->pci_slot); in hv_eject_device_work()
2781 ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_eject_device_work()
2787 put_pcichild(hpdev); in hv_eject_device_work()
2789 put_pcichild(hpdev); in hv_eject_device_work()
2790 put_pcichild(hpdev); in hv_eject_device_work()
2802 static void hv_pci_eject_device(struct hv_pci_dev *hpdev) in hv_pci_eject_device() argument
2804 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device()
2812 hpdev->state = hv_pcichild_ejecting; in hv_pci_eject_device()
2813 get_pcichild(hpdev); in hv_pci_eject_device()
2814 INIT_WORK(&hpdev->wrk, hv_eject_device_work); in hv_pci_eject_device()
2815 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2843 struct hv_pci_dev *hpdev; in hv_pci_onchannelcallback() local
2946 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2948 if (hpdev) { in hv_pci_onchannelcallback()
2949 hv_pci_eject_device(hpdev); in hv_pci_onchannelcallback()
2950 put_pcichild(hpdev); in hv_pci_onchannelcallback()
2962 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2964 if (hpdev) { in hv_pci_onchannelcallback()
2965 if (hpdev->block_invalidate) { in hv_pci_onchannelcallback()
2966 hpdev->block_invalidate( in hv_pci_onchannelcallback()
2967 hpdev->invalidate_context, in hv_pci_onchannelcallback()
2970 put_pcichild(hpdev); in hv_pci_onchannelcallback()
3337 struct hv_pci_dev *hpdev; in hv_send_resources_allocated() local
3353 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
3354 if (!hpdev) in hv_send_resources_allocated()
3367 res_assigned->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
3373 res_assigned2->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
3375 put_pcichild(hpdev); in hv_send_resources_allocated()
3412 struct hv_pci_dev *hpdev; in hv_send_resources_released() local
3417 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3418 if (!hpdev) in hv_send_resources_released()
3423 pkt.wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_released()
3425 put_pcichild(hpdev); in hv_send_resources_released()
3730 struct hv_pci_dev *hpdev, *tmp; in hv_pci_bus_exit() local
3748 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3749 list_move_tail(&hpdev->list_entry, &removed); in hv_pci_bus_exit()
3753 list_for_each_entry_safe(hpdev, tmp, &removed, list_entry) { in hv_pci_bus_exit()
3754 list_del(&hpdev->list_entry); in hv_pci_bus_exit()
3755 if (hpdev->pci_slot) in hv_pci_bus_exit()
3756 pci_destroy_slot(hpdev->pci_slot); in hv_pci_bus_exit()
3758 put_pcichild(hpdev); in hv_pci_bus_exit()
3759 put_pcichild(hpdev); in hv_pci_bus_exit()