Lines Matching refs:psdev
70 struct pcistub_device *psdev; in pcistub_device_alloc() local
74 psdev = kzalloc(sizeof(*psdev), GFP_KERNEL); in pcistub_device_alloc()
75 if (!psdev) in pcistub_device_alloc()
78 psdev->dev = pci_dev_get(dev); in pcistub_device_alloc()
79 if (!psdev->dev) { in pcistub_device_alloc()
80 kfree(psdev); in pcistub_device_alloc()
84 kref_init(&psdev->kref); in pcistub_device_alloc()
85 spin_lock_init(&psdev->lock); in pcistub_device_alloc()
87 return psdev; in pcistub_device_alloc()
93 struct pcistub_device *psdev; in pcistub_device_release() local
97 psdev = container_of(kref, struct pcistub_device, kref); in pcistub_device_release()
98 dev = psdev->dev; in pcistub_device_release()
141 kfree(psdev); in pcistub_device_release()
144 static inline void pcistub_device_get(struct pcistub_device *psdev) in pcistub_device_get() argument
146 kref_get(&psdev->kref); in pcistub_device_get()
149 static inline void pcistub_device_put(struct pcistub_device *psdev) in pcistub_device_put() argument
151 kref_put(&psdev->kref, pcistub_device_release); in pcistub_device_put()
157 struct pcistub_device *psdev; in pcistub_device_find_locked() local
159 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_device_find_locked()
160 if (psdev->dev != NULL in pcistub_device_find_locked()
161 && domain == pci_domain_nr(psdev->dev->bus) in pcistub_device_find_locked()
162 && bus == psdev->dev->bus->number in pcistub_device_find_locked()
163 && slot == PCI_SLOT(psdev->dev->devfn) in pcistub_device_find_locked()
164 && func == PCI_FUNC(psdev->dev->devfn)) { in pcistub_device_find_locked()
165 return psdev; in pcistub_device_find_locked()
175 struct pcistub_device *psdev; in pcistub_device_find() local
180 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_device_find()
181 if (psdev) in pcistub_device_find()
182 pcistub_device_get(psdev); in pcistub_device_find()
185 return psdev; in pcistub_device_find()
189 struct pcistub_device *psdev) in pcistub_device_get_pci_dev() argument
194 pcistub_device_get(psdev); in pcistub_device_get_pci_dev()
196 spin_lock_irqsave(&psdev->lock, flags); in pcistub_device_get_pci_dev()
197 if (!psdev->pdev) { in pcistub_device_get_pci_dev()
198 psdev->pdev = pdev; in pcistub_device_get_pci_dev()
199 pci_dev = psdev->dev; in pcistub_device_get_pci_dev()
201 spin_unlock_irqrestore(&psdev->lock, flags); in pcistub_device_get_pci_dev()
204 pcistub_device_put(psdev); in pcistub_device_get_pci_dev()
213 struct pcistub_device *psdev; in pcistub_get_pci_dev_by_slot() local
219 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_get_pci_dev_by_slot()
220 if (psdev) in pcistub_get_pci_dev_by_slot()
221 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev_by_slot()
230 struct pcistub_device *psdev; in pcistub_get_pci_dev() local
236 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_get_pci_dev()
237 if (psdev->dev == dev) { in pcistub_get_pci_dev()
238 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev()
260 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_put_pci_dev() local
267 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_put_pci_dev()
268 if (psdev->dev == dev) { in pcistub_put_pci_dev()
269 found_psdev = psdev; in pcistub_put_pci_dev()
449 struct pcistub_device *psdev; in pcistub_init_devices_late() local
456 psdev = container_of(seized_devices.next, in pcistub_init_devices_late()
458 list_del(&psdev->dev_list); in pcistub_init_devices_late()
462 err = pcistub_init_device(psdev->dev); in pcistub_init_devices_late()
464 dev_err(&psdev->dev->dev, in pcistub_init_devices_late()
466 kfree(psdev); in pcistub_init_devices_late()
467 psdev = NULL; in pcistub_init_devices_late()
472 if (psdev) in pcistub_init_devices_late()
473 list_add_tail(&psdev->dev_list, &pcistub_devices); in pcistub_init_devices_late()
516 struct pcistub_device *psdev; in pcistub_seize() local
520 psdev = pcistub_device_alloc(dev); in pcistub_seize()
521 if (!psdev) { in pcistub_seize()
532 err = pcistub_init_device(psdev->dev); in pcistub_seize()
537 list_add(&psdev->dev_list, &pcistub_devices); in pcistub_seize()
540 list_add(&psdev->dev_list, &seized_devices); in pcistub_seize()
547 pcistub_device_put(psdev); in pcistub_seize()
601 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_remove() local
610 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_remove()
611 if (psdev->dev == dev) { in pcistub_remove()
612 found_psdev = psdev; in pcistub_remove()
659 static void kill_domain_by_device(struct pcistub_device *psdev) in kill_domain_by_device() argument
665 BUG_ON(!psdev); in kill_domain_by_device()
667 psdev->pdev->xdev->otherend_id); in kill_domain_by_device()
672 dev_err(&psdev->dev->dev, in kill_domain_by_device()
682 dev_err(&psdev->dev->dev, in kill_domain_by_device()
692 static pci_ers_result_t common_process(struct pcistub_device *psdev, in common_process() argument
698 struct xen_pcibk_device *pdev = psdev->pdev; in common_process()
708 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, in common_process()
711 dev_err(&psdev->dev->dev, in common_process()
717 dev_dbg(&psdev->dev->dev, in common_process()
742 dev_err(&psdev->dev->dev, in common_process()
754 dev_dbg(&psdev->dev->dev, in common_process()
756 xen_pcibk_test_and_schedule_op(psdev->pdev); in common_process()
772 struct pcistub_device *psdev; in xen_pcibk_slot_reset() local
780 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_slot_reset()
785 if (!psdev || !psdev->pdev) { in xen_pcibk_slot_reset()
791 if (!psdev->pdev->sh_info) { in xen_pcibk_slot_reset()
794 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
799 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_slot_reset()
804 result = common_process(psdev, 1, XEN_PCI_OP_aer_slotreset, result); in xen_pcibk_slot_reset()
810 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
813 if (psdev) in xen_pcibk_slot_reset()
814 pcistub_device_put(psdev); in xen_pcibk_slot_reset()
830 struct pcistub_device *psdev; in xen_pcibk_mmio_enabled() local
838 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_mmio_enabled()
843 if (!psdev || !psdev->pdev) { in xen_pcibk_mmio_enabled()
849 if (!psdev->pdev->sh_info) { in xen_pcibk_mmio_enabled()
852 kill_domain_by_device(psdev); in xen_pcibk_mmio_enabled()
857 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_mmio_enabled()
862 result = common_process(psdev, 1, XEN_PCI_OP_aer_mmio, result); in xen_pcibk_mmio_enabled()
868 kill_domain_by_device(psdev); in xen_pcibk_mmio_enabled()
871 if (psdev) in xen_pcibk_mmio_enabled()
872 pcistub_device_put(psdev); in xen_pcibk_mmio_enabled()
888 struct pcistub_device *psdev; in xen_pcibk_error_detected() local
896 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_detected()
901 if (!psdev || !psdev->pdev) { in xen_pcibk_error_detected()
907 if (!psdev->pdev->sh_info) { in xen_pcibk_error_detected()
910 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
916 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_detected()
918 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
921 result = common_process(psdev, error, XEN_PCI_OP_aer_detected, result); in xen_pcibk_error_detected()
927 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
930 if (psdev) in xen_pcibk_error_detected()
931 pcistub_device_put(psdev); in xen_pcibk_error_detected()
944 struct pcistub_device *psdev; in xen_pcibk_error_resume() local
950 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_resume()
955 if (!psdev || !psdev->pdev) { in xen_pcibk_error_resume()
961 if (!psdev->pdev->sh_info) { in xen_pcibk_error_resume()
964 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
969 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_resume()
972 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
975 common_process(psdev, 1, XEN_PCI_OP_aer_resume, in xen_pcibk_error_resume()
978 if (psdev) in xen_pcibk_error_resume()
979 pcistub_device_put(psdev); in xen_pcibk_error_resume()
1138 struct pcistub_device *psdev; in pcistub_reg_add() local
1145 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_reg_add()
1146 if (!psdev) { in pcistub_reg_add()
1150 dev = psdev->dev; in pcistub_reg_add()
1170 if (psdev) in pcistub_reg_add()
1171 pcistub_device_put(psdev); in pcistub_reg_add()
1238 struct pcistub_device *psdev; in irq_handlers_show() local
1244 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in irq_handlers_show()
1247 if (!psdev->dev) in irq_handlers_show()
1249 dev_data = pci_get_drvdata(psdev->dev); in irq_handlers_show()
1255 pci_name(psdev->dev), in irq_handlers_show()
1268 struct pcistub_device *psdev; in irq_handler_state_store() local
1277 psdev = pcistub_device_find(domain, bus, slot, func); in irq_handler_state_store()
1278 if (!psdev) { in irq_handler_state_store()
1283 dev_data = pci_get_drvdata(psdev->dev); in irq_handler_state_store()
1289 dev_dbg(&psdev->dev->dev, "%s fake irq handler: %d->%d\n", in irq_handler_state_store()
1297 if (psdev) in irq_handler_state_store()
1298 pcistub_device_put(psdev); in irq_handler_state_store()
1374 struct pcistub_device *psdev; in permissive_store() local
1381 psdev = pcistub_device_find(domain, bus, slot, func); in permissive_store()
1382 if (!psdev) { in permissive_store()
1387 dev_data = pci_get_drvdata(psdev->dev); in permissive_store()
1396 dev_warn(&psdev->dev->dev, "enabling permissive mode " in permissive_store()
1398 dev_warn(&psdev->dev->dev, in permissive_store()
1402 pcistub_device_put(psdev); in permissive_store()
1411 struct pcistub_device *psdev; in permissive_show() local
1416 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in permissive_show()
1419 if (!psdev->dev) in permissive_show()
1421 dev_data = pci_get_drvdata(psdev->dev); in permissive_show()
1426 pci_name(psdev->dev)); in permissive_show()
1565 struct pcistub_device *psdev = NULL; in find_vfs() local
1570 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in find_vfs()
1571 if (!psdev->pdev && psdev->dev != pdev in find_vfs()
1572 && pci_physfn(psdev->dev) == pdev) { in find_vfs()
1579 return psdev; in find_vfs()
1596 struct pcistub_device *psdev = find_vfs(pdev); in pci_stub_notifier() local
1597 if (!psdev) in pci_stub_notifier()
1599 device_release_driver(&psdev->dev->dev); in pci_stub_notifier()