Lines Matching refs:hpdev
585 static void get_pcichild(struct hv_pci_dev *hpdev) in get_pcichild() argument
587 refcount_inc(&hpdev->refs); in get_pcichild()
590 static void put_pcichild(struct hv_pci_dev *hpdev) in put_pcichild() argument
592 if (refcount_dec_and_test(&hpdev->refs)) in put_pcichild()
593 kfree(hpdev); in put_pcichild()
669 static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_read_config() argument
673 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_read_config()
679 memcpy(val, ((u8 *)&hpdev->desc.v_id) + where, size); in _hv_pcifront_read_config()
682 memcpy(val, ((u8 *)&hpdev->desc.rev) + where - in _hv_pcifront_read_config()
686 memcpy(val, (u8 *)&hpdev->desc.subsystem_id + where - in _hv_pcifront_read_config()
701 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
703 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_read_config()
723 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
725 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_read_config()
730 static u16 hv_pcifront_get_vendor_id(struct hv_pci_dev *hpdev) in hv_pcifront_get_vendor_id() argument
734 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
737 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
740 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in hv_pcifront_get_vendor_id()
750 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
762 static void _hv_pcifront_write_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_write_config() argument
766 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_write_config()
772 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
774 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_write_config()
794 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
796 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_write_config()
817 struct hv_pci_dev *hpdev; in hv_pcifront_read_config() local
819 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
820 if (!hpdev) in hv_pcifront_read_config()
823 _hv_pcifront_read_config(hpdev, where, size, val); in hv_pcifront_read_config()
825 put_pcichild(hpdev); in hv_pcifront_read_config()
845 struct hv_pci_dev *hpdev; in hv_pcifront_write_config() local
847 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
848 if (!hpdev) in hv_pcifront_write_config()
851 _hv_pcifront_write_config(hpdev, where, size, val); in hv_pcifront_write_config()
853 put_pcichild(hpdev); in hv_pcifront_write_config()
1097 struct hv_pci_dev *hpdev; in hv_register_block_invalidate() local
1099 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_register_block_invalidate()
1100 if (!hpdev) in hv_register_block_invalidate()
1103 hpdev->block_invalidate = block_invalidate; in hv_register_block_invalidate()
1104 hpdev->invalidate_context = context; in hv_register_block_invalidate()
1106 put_pcichild(hpdev); in hv_register_block_invalidate()
1112 static void hv_int_desc_free(struct hv_pci_dev *hpdev, in hv_int_desc_free() argument
1129 int_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_int_desc_free()
1131 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
1151 struct hv_pci_dev *hpdev; in hv_msi_free() local
1164 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
1165 if (!hpdev) { in hv_msi_free()
1170 hv_int_desc_free(hpdev, int_desc); in hv_msi_free()
1171 put_pcichild(hpdev); in hv_msi_free()
1405 struct hv_pci_dev *hpdev; in hv_compose_msi_msg() local
1439 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1440 if (!hpdev) in hv_compose_msi_msg()
1461 put_pcichild(hpdev); in hv_compose_msi_msg()
1486 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1495 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1510 ret = vmbus_sendpacket(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1535 if (hv_pcifront_get_vendor_id(hpdev) == 0xFFFF) { in hv_compose_msi_msg()
1556 if (hpdev->state == hv_pcichild_ejecting) { in hv_compose_msi_msg()
1587 put_pcichild(hpdev); in hv_compose_msi_msg()
1595 put_pcichild(hpdev); in hv_compose_msi_msg()
1678 struct hv_pci_dev *hpdev; in survey_child_resources() local
1703 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
1705 if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO) in survey_child_resources()
1709 if (hpdev->probed_bar[i] != 0) { in survey_child_resources()
1715 bar_val = hpdev->probed_bar[i]; in survey_child_resources()
1718 ((u64)hpdev->probed_bar[++i] << 32); in survey_child_resources()
1755 struct hv_pci_dev *hpdev; in prepopulate_bars() local
1786 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1787 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, &command); in prepopulate_bars()
1789 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2, command); in prepopulate_bars()
1794 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1796 bar_val = hpdev->probed_bar[i]; in prepopulate_bars()
1802 ((u64)hpdev->probed_bar[i + 1] in prepopulate_bars()
1813 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1818 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1825 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1834 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, in prepopulate_bars()
1837 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2, in prepopulate_bars()
1861 struct hv_pci_dev *hpdev; in hv_pci_assign_slots() local
1865 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
1866 if (hpdev->pci_slot) in hv_pci_assign_slots()
1869 slot_nr = PCI_SLOT(wslot_to_devfn(hpdev->desc.win_slot.slot)); in hv_pci_assign_slots()
1870 snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser); in hv_pci_assign_slots()
1871 hpdev->pci_slot = pci_create_slot(hbus->pci_bus, slot_nr, in hv_pci_assign_slots()
1873 if (IS_ERR(hpdev->pci_slot)) { in hv_pci_assign_slots()
1875 hpdev->pci_slot = NULL; in hv_pci_assign_slots()
1885 struct hv_pci_dev *hpdev; in hv_pci_remove_slots() local
1887 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_remove_slots()
1888 if (!hpdev->pci_slot) in hv_pci_remove_slots()
1890 pci_destroy_slot(hpdev->pci_slot); in hv_pci_remove_slots()
1891 hpdev->pci_slot = NULL; in hv_pci_remove_slots()
1958 struct hv_pci_dev *hpdev; member
1979 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
1984 completion->hpdev->probed_bar[i] = in q_resource_requirements()
2006 struct hv_pci_dev *hpdev; in new_pcichild_device() local
2016 hpdev = kzalloc(sizeof(*hpdev), GFP_KERNEL); in new_pcichild_device()
2017 if (!hpdev) in new_pcichild_device()
2020 hpdev->hbus = hbus; in new_pcichild_device()
2024 comp_pkt.hpdev = hpdev; in new_pcichild_device()
2042 hpdev->desc = *desc; in new_pcichild_device()
2043 refcount_set(&hpdev->refs, 1); in new_pcichild_device()
2044 get_pcichild(hpdev); in new_pcichild_device()
2047 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
2049 return hpdev; in new_pcichild_device()
2052 kfree(hpdev); in new_pcichild_device()
2073 struct hv_pci_dev *iter, *hpdev = NULL; in get_pcichild_wslot() local
2078 hpdev = iter; in get_pcichild_wslot()
2079 get_pcichild(hpdev); in get_pcichild_wslot()
2085 return hpdev; in get_pcichild_wslot()
2116 struct hv_pci_dev *hpdev; in pci_devices_present_work() local
2151 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2152 hpdev->reported_missing = true; in pci_devices_present_work()
2162 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2163 if ((hpdev->desc.win_slot.slot == new_desc->win_slot.slot) && in pci_devices_present_work()
2164 (hpdev->desc.v_id == new_desc->v_id) && in pci_devices_present_work()
2165 (hpdev->desc.d_id == new_desc->d_id) && in pci_devices_present_work()
2166 (hpdev->desc.ser == new_desc->ser)) { in pci_devices_present_work()
2167 hpdev->reported_missing = false; in pci_devices_present_work()
2174 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
2175 if (!hpdev) in pci_devices_present_work()
2185 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
2186 if (hpdev->reported_missing) { in pci_devices_present_work()
2188 put_pcichild(hpdev); in pci_devices_present_work()
2189 list_move_tail(&hpdev->list_entry, &removed); in pci_devices_present_work()
2198 hpdev = list_first_entry(&removed, struct hv_pci_dev, in pci_devices_present_work()
2200 list_del(&hpdev->list_entry); in pci_devices_present_work()
2202 if (hpdev->pci_slot) in pci_devices_present_work()
2203 pci_destroy_slot(hpdev->pci_slot); in pci_devices_present_work()
2205 put_pcichild(hpdev); in pci_devices_present_work()
2369 struct hv_pci_dev *hpdev; in hv_eject_device_work() local
2378 hpdev = container_of(work, struct hv_pci_dev, wrk); in hv_eject_device_work()
2379 hbus = hpdev->hbus; in hv_eject_device_work()
2381 WARN_ON(hpdev->state != hv_pcichild_ejecting); in hv_eject_device_work()
2389 wslot = wslot_to_devfn(hpdev->desc.win_slot.slot); in hv_eject_device_work()
2399 list_del(&hpdev->list_entry); in hv_eject_device_work()
2402 if (hpdev->pci_slot) in hv_eject_device_work()
2403 pci_destroy_slot(hpdev->pci_slot); in hv_eject_device_work()
2408 ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_eject_device_work()
2414 put_pcichild(hpdev); in hv_eject_device_work()
2416 put_pcichild(hpdev); in hv_eject_device_work()
2417 put_pcichild(hpdev); in hv_eject_device_work()
2431 static void hv_pci_eject_device(struct hv_pci_dev *hpdev) in hv_pci_eject_device() argument
2433 struct hv_pcibus_device *hbus = hpdev->hbus; in hv_pci_eject_device()
2441 hpdev->state = hv_pcichild_ejecting; in hv_pci_eject_device()
2442 get_pcichild(hpdev); in hv_pci_eject_device()
2443 INIT_WORK(&hpdev->wrk, hv_eject_device_work); in hv_pci_eject_device()
2445 queue_work(hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
2472 struct hv_pci_dev *hpdev; in hv_pci_onchannelcallback() local
2553 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2555 if (hpdev) { in hv_pci_onchannelcallback()
2556 hv_pci_eject_device(hpdev); in hv_pci_onchannelcallback()
2557 put_pcichild(hpdev); in hv_pci_onchannelcallback()
2564 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2566 if (hpdev) { in hv_pci_onchannelcallback()
2567 if (hpdev->block_invalidate) { in hv_pci_onchannelcallback()
2568 hpdev->block_invalidate( in hv_pci_onchannelcallback()
2569 hpdev->invalidate_context, in hv_pci_onchannelcallback()
2572 put_pcichild(hpdev); in hv_pci_onchannelcallback()
2941 struct hv_pci_dev *hpdev; in hv_send_resources_allocated() local
2957 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
2958 if (!hpdev) in hv_send_resources_allocated()
2971 res_assigned->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
2977 res_assigned2->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
2979 put_pcichild(hpdev); in hv_send_resources_allocated()
3016 struct hv_pci_dev *hpdev; in hv_send_resources_released() local
3021 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
3022 if (!hpdev) in hv_send_resources_released()
3027 pkt.wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_released()
3029 put_pcichild(hpdev); in hv_send_resources_released()
3324 struct hv_pci_dev *hpdev, *tmp; in hv_pci_bus_exit() local
3341 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry) in hv_pci_bus_exit()
3342 list_move_tail(&hpdev->list_entry, &removed); in hv_pci_bus_exit()
3346 list_for_each_entry_safe(hpdev, tmp, &removed, list_entry) { in hv_pci_bus_exit()
3347 list_del(&hpdev->list_entry); in hv_pci_bus_exit()
3348 if (hpdev->pci_slot) in hv_pci_bus_exit()
3349 pci_destroy_slot(hpdev->pci_slot); in hv_pci_bus_exit()
3351 put_pcichild(hpdev); in hv_pci_bus_exit()
3352 put_pcichild(hpdev); in hv_pci_bus_exit()