Lines Matching refs:hpdev
576 static void get_pcichild(struct hv_pci_dev *hpdev)
578 refcount_inc(&hpdev->refs);
581 static void put_pcichild(struct hv_pci_dev *hpdev)
583 if (refcount_dec_and_test(&hpdev->refs))
584 kfree(hpdev);
655 * @hpdev: The PCI driver's representation of the device
660 static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where,
664 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where;
670 memcpy(val, ((u8 *)&hpdev->desc.v_id) + where, size);
673 memcpy(val, ((u8 *)&hpdev->desc.rev) + where -
677 memcpy(val, (u8 *)&hpdev->desc.subsystem_id + where -
692 spin_lock_irqsave(&hpdev->hbus->config_lock, flags);
694 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr);
714 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags);
716 dev_err(&hpdev->hbus->hdev->device,
721 static u16 hv_pcifront_get_vendor_id(struct hv_pci_dev *hpdev)
725 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET +
728 spin_lock_irqsave(&hpdev->hbus->config_lock, flags);
731 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr);
741 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags);
748 * @hpdev: The PCI driver's representation of the device
753 static void _hv_pcifront_write_config(struct hv_pci_dev *hpdev, int where,
757 void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + where;
763 spin_lock_irqsave(&hpdev->hbus->config_lock, flags);
765 writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr);
785 spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags);
787 dev_err(&hpdev->hbus->hdev->device,
808 struct hv_pci_dev *hpdev;
810 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn));
811 if (!hpdev)
814 _hv_pcifront_read_config(hpdev, where, size, val);
816 put_pcichild(hpdev);
836 struct hv_pci_dev *hpdev;
838 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(devfn));
839 if (!hpdev)
842 _hv_pcifront_write_config(hpdev, where, size, val);
844 put_pcichild(hpdev);
1088 struct hv_pci_dev *hpdev;
1090 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn));
1091 if (!hpdev)
1094 hpdev->block_invalidate = block_invalidate;
1095 hpdev->invalidate_context = context;
1097 put_pcichild(hpdev);
1103 static void hv_int_desc_free(struct hv_pci_dev *hpdev,
1120 int_pkt->wslot.slot = hpdev->desc.win_slot.slot;
1122 vmbus_sendpacket(hpdev->hbus->hdev->channel, int_pkt, sizeof(*int_pkt),
1142 struct hv_pci_dev *hpdev;
1155 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn));
1156 if (!hpdev) {
1161 hv_int_desc_free(hpdev, int_desc);
1162 put_pcichild(hpdev);
1401 struct hv_pci_dev *hpdev;
1435 hpdev = get_pcichild_wslot(hbus, devfn_to_wslot(pdev->devfn));
1436 if (!hpdev)
1457 put_pcichild(hpdev);
1482 hpdev->desc.win_slot.slot,
1491 hpdev->desc.win_slot.slot,
1506 ret = vmbus_sendpacket(hpdev->hbus->hdev->channel, &ctxt.int_pkts,
1531 if (hv_pcifront_get_vendor_id(hpdev) == 0xFFFF) {
1577 put_pcichild(hpdev);
1585 put_pcichild(hpdev);
1668 struct hv_pci_dev *hpdev;
1693 list_for_each_entry(hpdev, &hbus->children, list_entry) {
1695 if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO)
1699 if (hpdev->probed_bar[i] != 0) {
1705 bar_val = hpdev->probed_bar[i];
1708 ((u64)hpdev->probed_bar[++i] << 32);
1745 struct hv_pci_dev *hpdev;
1776 list_for_each_entry(hpdev, &hbus->children, list_entry) {
1777 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, &command);
1779 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2, command);
1784 list_for_each_entry(hpdev, &hbus->children, list_entry) {
1786 bar_val = hpdev->probed_bar[i];
1792 ((u64)hpdev->probed_bar[i + 1]
1803 _hv_pcifront_write_config(hpdev,
1808 _hv_pcifront_write_config(hpdev,
1815 _hv_pcifront_write_config(hpdev,
1824 _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2,
1827 _hv_pcifront_write_config(hpdev, PCI_COMMAND, 2,
1851 struct hv_pci_dev *hpdev;
1855 list_for_each_entry(hpdev, &hbus->children, list_entry) {
1856 if (hpdev->pci_slot)
1859 slot_nr = PCI_SLOT(wslot_to_devfn(hpdev->desc.win_slot.slot));
1860 snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser);
1861 hpdev->pci_slot = pci_create_slot(hbus->pci_bus, slot_nr,
1863 if (IS_ERR(hpdev->pci_slot)) {
1865 hpdev->pci_slot = NULL;
1875 struct hv_pci_dev *hpdev;
1877 list_for_each_entry(hpdev, &hbus->children, list_entry) {
1878 if (!hpdev->pci_slot)
1880 pci_destroy_slot(hpdev->pci_slot);
1881 hpdev->pci_slot = NULL;
1948 struct hv_pci_dev *hpdev;
1969 dev_err(&completion->hpdev->hbus->hdev->device,
1974 completion->hpdev->probed_bar[i] =
1996 struct hv_pci_dev *hpdev;
2006 hpdev = kzalloc(sizeof(*hpdev), GFP_KERNEL);
2007 if (!hpdev)
2010 hpdev->hbus = hbus;
2014 comp_pkt.hpdev = hpdev;
2032 hpdev->desc = *desc;
2033 refcount_set(&hpdev->refs, 1);
2034 get_pcichild(hpdev);
2037 list_add_tail(&hpdev->list_entry, &hbus->children);
2039 return hpdev;
2042 kfree(hpdev);
2063 struct hv_pci_dev *iter, *hpdev = NULL;
2068 hpdev = iter;
2069 get_pcichild(hpdev);
2075 return hpdev;
2106 struct hv_pci_dev *hpdev;
2141 list_for_each_entry(hpdev, &hbus->children, list_entry) {
2142 hpdev->reported_missing = true;
2152 list_for_each_entry(hpdev, &hbus->children, list_entry) {
2153 if ((hpdev->desc.win_slot.slot == new_desc->win_slot.slot) &&
2154 (hpdev->desc.v_id == new_desc->v_id) &&
2155 (hpdev->desc.d_id == new_desc->d_id) &&
2156 (hpdev->desc.ser == new_desc->ser)) {
2157 hpdev->reported_missing = false;
2164 hpdev = new_pcichild_device(hbus, new_desc);
2165 if (!hpdev)
2175 list_for_each_entry(hpdev, &hbus->children, list_entry) {
2176 if (hpdev->reported_missing) {
2178 put_pcichild(hpdev);
2179 list_move_tail(&hpdev->list_entry, &removed);
2188 hpdev = list_first_entry(&removed, struct hv_pci_dev,
2190 list_del(&hpdev->list_entry);
2192 if (hpdev->pci_slot)
2193 pci_destroy_slot(hpdev->pci_slot);
2195 put_pcichild(hpdev);
2359 struct hv_pci_dev *hpdev;
2368 hpdev = container_of(work, struct hv_pci_dev, wrk);
2369 hbus = hpdev->hbus;
2377 wslot = wslot_to_devfn(hpdev->desc.win_slot.slot);
2387 list_del(&hpdev->list_entry);
2390 if (hpdev->pci_slot)
2391 pci_destroy_slot(hpdev->pci_slot);
2396 ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot;
2402 put_pcichild(hpdev);
2404 put_pcichild(hpdev);
2405 put_pcichild(hpdev);
2406 /* hpdev has been freed. Do not use it any more. */
2413 * @hpdev: Internal device tracking struct
2419 static void hv_pci_eject_device(struct hv_pci_dev *hpdev)
2421 struct hv_pcibus_device *hbus = hpdev->hbus;
2429 get_pcichild(hpdev);
2430 INIT_WORK(&hpdev->wrk, hv_eject_device_work);
2432 queue_work(hbus->wq, &hpdev->wrk);
2459 struct hv_pci_dev *hpdev;
2540 hpdev = get_pcichild_wslot(hbus,
2542 if (hpdev) {
2543 hv_pci_eject_device(hpdev);
2544 put_pcichild(hpdev);
2551 hpdev = get_pcichild_wslot(hbus,
2553 if (hpdev) {
2554 if (hpdev->block_invalidate) {
2555 hpdev->block_invalidate(
2556 hpdev->invalidate_context,
2559 put_pcichild(hpdev);
2980 struct hv_pci_dev *hpdev;
2996 hpdev = get_pcichild_wslot(hbus, wslot);
2997 if (!hpdev)
3010 res_assigned->wslot.slot = hpdev->desc.win_slot.slot;
3016 res_assigned2->wslot.slot = hpdev->desc.win_slot.slot;
3018 put_pcichild(hpdev);
3055 struct hv_pci_dev *hpdev;
3060 hpdev = get_pcichild_wslot(hbus, wslot);
3061 if (!hpdev)
3066 pkt.wslot.slot = hpdev->desc.win_slot.slot;
3068 put_pcichild(hpdev);
3167 * (i.e. the hpdev struct, which is created in new_pcichild_device() and
3326 struct hv_pci_dev *hpdev, *tmp;
3343 list_for_each_entry_safe(hpdev, tmp, &hbus->children, list_entry)
3344 list_move_tail(&hpdev->list_entry, &removed);
3348 list_for_each_entry_safe(hpdev, tmp, &removed, list_entry) {
3349 list_del(&hpdev->list_entry);
3350 if (hpdev->pci_slot)
3351 pci_destroy_slot(hpdev->pci_slot);
3353 put_pcichild(hpdev);
3354 put_pcichild(hpdev);