Lines Matching refs:hpdev
546 static void get_pcichild(struct hv_pci_dev *hpdev) in get_pcichild() argument
548 refcount_inc(&hpdev->refs); in get_pcichild()
551 static void put_pcichild(struct hv_pci_dev *hpdev) in put_pcichild() argument
553 if (refcount_dec_and_test(&hpdev->refs)) in put_pcichild()
554 kfree(hpdev); in put_pcichild()
630 static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_read_config() argument
634 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_read_config()
640 memcpy(val, ((u8 *)&hpdev->desc.v_id) + where, size); in _hv_pcifront_read_config()
643 memcpy(val, ((u8 *)&hpdev->desc.rev) + where - in _hv_pcifront_read_config()
647 memcpy(val, (u8 *)&hpdev->desc.subsystem_id + where - in _hv_pcifront_read_config()
662 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
664 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_read_config()
684 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_read_config()
686 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_read_config()
691 static u16 hv_pcifront_get_vendor_id(struct hv_pci_dev *hpdev) in hv_pcifront_get_vendor_id() argument
695 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + in hv_pcifront_get_vendor_id()
698 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
701 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in hv_pcifront_get_vendor_id()
711 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in hv_pcifront_get_vendor_id()
723 static void _hv_pcifront_write_config(struct hv_pci_dev *hpdev, int where, in _hv_pcifront_write_config() argument
727 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where; in _hv_pcifront_write_config()
733 spin_lock_irqsave(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
735 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); in _hv_pcifront_write_config()
755 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); in _hv_pcifront_write_config()
757 dev_err(&hpdev->hbus->hdev->device, in _hv_pcifront_write_config()
778 struct hv_pci_dev *hpdev; in hv_pcifront_read_config() local
780 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_read_config()
781 if (!hpdev) in hv_pcifront_read_config()
784 _hv_pcifront_read_config(hpdev, where, size, val); in hv_pcifront_read_config()
786 put_pcichild(hpdev); in hv_pcifront_read_config()
806 struct hv_pci_dev *hpdev; in hv_pcifront_write_config() local
808 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn)); in hv_pcifront_write_config()
809 if (!hpdev) in hv_pcifront_write_config()
812 _hv_pcifront_write_config(hpdev, where, size, val); in hv_pcifront_write_config()
814 put_pcichild(hpdev); in hv_pcifront_write_config()
825 static void hv_int_desc_free(struct hv_pci_dev *hpdev, in hv_int_desc_free() argument
838 int_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_int_desc_free()
840 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt), in hv_int_desc_free()
860 struct hv_pci_dev *hpdev; in hv_msi_free() local
873 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_msi_free()
874 if (!hpdev) { in hv_msi_free()
879 hv_int_desc_free(hpdev, int_desc); in hv_msi_free()
880 put_pcichild(hpdev); in hv_msi_free()
1077 struct hv_pci_dev *hpdev; in hv_compose_msi_msg() local
1099 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn)); in hv_compose_msi_msg()
1100 if (!hpdev) in hv_compose_msi_msg()
1107 hv_int_desc_free(hpdev, int_desc); in hv_compose_msi_msg()
1123 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1130 hpdev->desc.win_slot.slot, in hv_compose_msi_msg()
1144 ret = vmbus_sendpacket(hpdev->hbus->hdev->channel, &ctxt.int_pkts, in hv_compose_msi_msg()
1161 if (hv_pcifront_get_vendor_id(hpdev) == 0xFFFF) { in hv_compose_msi_msg()
1183 if (hpdev->state == hv_pcichild_ejecting) { in hv_compose_msi_msg()
1212 put_pcichild(hpdev); in hv_compose_msi_msg()
1218 put_pcichild(hpdev); in hv_compose_msi_msg()
1309 struct hv_pci_dev *hpdev; in survey_child_resources() local
1334 list_for_each_entry(hpdev, &hbus->children, list_entry) { in survey_child_resources()
1336 if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO) in survey_child_resources()
1340 if (hpdev->probed_bar[i] != 0) { in survey_child_resources()
1346 bar_val = hpdev->probed_bar[i]; in survey_child_resources()
1349 ((u64)hpdev->probed_bar[++i] << 32); in survey_child_resources()
1386 struct hv_pci_dev *hpdev; in prepopulate_bars() local
1408 list_for_each_entry(hpdev, &hbus->children, list_entry) { in prepopulate_bars()
1410 bar_val = hpdev->probed_bar[i]; in prepopulate_bars()
1416 ((u64)hpdev->probed_bar[i + 1] in prepopulate_bars()
1427 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1432 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1439 _hv_pcifront_write_config(hpdev, in prepopulate_bars()
1448 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, in prepopulate_bars()
1451 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2, in prepopulate_bars()
1475 struct hv_pci_dev *hpdev; in hv_pci_assign_slots() local
1479 list_for_each_entry(hpdev, &hbus->children, list_entry) { in hv_pci_assign_slots()
1480 if (hpdev->pci_slot) in hv_pci_assign_slots()
1483 slot_nr = PCI_SLOT(wslot_to_devfn(hpdev->desc.win_slot.slot)); in hv_pci_assign_slots()
1484 snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser); in hv_pci_assign_slots()
1485 hpdev->pci_slot = pci_create_slot(hbus->pci_bus, slot_nr, in hv_pci_assign_slots()
1487 if (IS_ERR(hpdev->pci_slot)) { in hv_pci_assign_slots()
1489 hpdev->pci_slot = NULL; in hv_pci_assign_slots()
1526 struct hv_pci_dev *hpdev; member
1547 dev_err(&completion->hpdev->hbus->hdev->device, in q_resource_requirements()
1552 completion->hpdev->probed_bar[i] = in q_resource_requirements()
1574 struct hv_pci_dev *hpdev; in new_pcichild_device() local
1584 hpdev = kzalloc(sizeof(*hpdev), GFP_KERNEL); in new_pcichild_device()
1585 if (!hpdev) in new_pcichild_device()
1588 hpdev->hbus = hbus; in new_pcichild_device()
1592 comp_pkt.hpdev = hpdev; in new_pcichild_device()
1610 hpdev->desc = *desc; in new_pcichild_device()
1611 refcount_set(&hpdev->refs, 1); in new_pcichild_device()
1612 get_pcichild(hpdev); in new_pcichild_device()
1615 list_add_tail(&hpdev->list_entry, &hbus->children); in new_pcichild_device()
1617 return hpdev; in new_pcichild_device()
1620 kfree(hpdev); in new_pcichild_device()
1641 struct hv_pci_dev *iter, *hpdev = NULL; in get_pcichild_wslot() local
1646 hpdev = iter; in get_pcichild_wslot()
1647 get_pcichild(hpdev); in get_pcichild_wslot()
1653 return hpdev; in get_pcichild_wslot()
1684 struct hv_pci_dev *hpdev; in pci_devices_present_work() local
1719 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
1720 hpdev->reported_missing = true; in pci_devices_present_work()
1730 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
1731 if ((hpdev->desc.win_slot.slot == new_desc->win_slot.slot) && in pci_devices_present_work()
1732 (hpdev->desc.v_id == new_desc->v_id) && in pci_devices_present_work()
1733 (hpdev->desc.d_id == new_desc->d_id) && in pci_devices_present_work()
1734 (hpdev->desc.ser == new_desc->ser)) { in pci_devices_present_work()
1735 hpdev->reported_missing = false; in pci_devices_present_work()
1742 hpdev = new_pcichild_device(hbus, new_desc); in pci_devices_present_work()
1743 if (!hpdev) in pci_devices_present_work()
1753 list_for_each_entry(hpdev, &hbus->children, list_entry) { in pci_devices_present_work()
1754 if (hpdev->reported_missing) { in pci_devices_present_work()
1756 put_pcichild(hpdev); in pci_devices_present_work()
1757 list_move_tail(&hpdev->list_entry, &removed); in pci_devices_present_work()
1766 hpdev = list_first_entry(&removed, struct hv_pci_dev, in pci_devices_present_work()
1768 list_del(&hpdev->list_entry); in pci_devices_present_work()
1769 put_pcichild(hpdev); in pci_devices_present_work()
1864 struct hv_pci_dev *hpdev; in hv_eject_device_work() local
1873 hpdev = container_of(work, struct hv_pci_dev, wrk); in hv_eject_device_work()
1875 WARN_ON(hpdev->state != hv_pcichild_ejecting); in hv_eject_device_work()
1883 wslot = wslot_to_devfn(hpdev->desc.win_slot.slot); in hv_eject_device_work()
1884 pdev = pci_get_domain_bus_and_slot(hpdev->hbus->sysdata.domain, 0, in hv_eject_device_work()
1893 spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags); in hv_eject_device_work()
1894 list_del(&hpdev->list_entry); in hv_eject_device_work()
1895 spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags); in hv_eject_device_work()
1897 if (hpdev->pci_slot) in hv_eject_device_work()
1898 pci_destroy_slot(hpdev->pci_slot); in hv_eject_device_work()
1903 ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; in hv_eject_device_work()
1904 vmbus_sendpacket(hpdev->hbus->hdev->channel, ejct_pkt, in hv_eject_device_work()
1908 put_pcichild(hpdev); in hv_eject_device_work()
1909 put_pcichild(hpdev); in hv_eject_device_work()
1910 put_hvpcibus(hpdev->hbus); in hv_eject_device_work()
1921 static void hv_pci_eject_device(struct hv_pci_dev *hpdev) in hv_pci_eject_device() argument
1923 hpdev->state = hv_pcichild_ejecting; in hv_pci_eject_device()
1924 get_pcichild(hpdev); in hv_pci_eject_device()
1925 INIT_WORK(&hpdev->wrk, hv_eject_device_work); in hv_pci_eject_device()
1926 get_hvpcibus(hpdev->hbus); in hv_pci_eject_device()
1927 queue_work(hpdev->hbus->wq, &hpdev->wrk); in hv_pci_eject_device()
1952 struct hv_pci_dev *hpdev; in hv_pci_onchannelcallback() local
2020 hpdev = get_pcichild_wslot(hbus, in hv_pci_onchannelcallback()
2022 if (hpdev) { in hv_pci_onchannelcallback()
2023 hv_pci_eject_device(hpdev); in hv_pci_onchannelcallback()
2024 put_pcichild(hpdev); in hv_pci_onchannelcallback()
2385 struct hv_pci_dev *hpdev; in hv_send_resources_allocated() local
2401 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_allocated()
2402 if (!hpdev) in hv_send_resources_allocated()
2415 res_assigned->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
2421 res_assigned2->wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_allocated()
2423 put_pcichild(hpdev); in hv_send_resources_allocated()
2458 struct hv_pci_dev *hpdev; in hv_send_resources_released() local
2463 hpdev = get_pcichild_wslot(hbus, wslot); in hv_send_resources_released()
2464 if (!hpdev) in hv_send_resources_released()
2469 pkt.wslot.slot = hpdev->desc.win_slot.slot; in hv_send_resources_released()
2471 put_pcichild(hpdev); in hv_send_resources_released()