Lines Matching refs:psdev
72 struct pcistub_device *psdev; in pcistub_device_alloc() local
76 psdev = kzalloc(sizeof(*psdev), GFP_KERNEL); in pcistub_device_alloc()
77 if (!psdev) in pcistub_device_alloc()
80 psdev->dev = pci_dev_get(dev); in pcistub_device_alloc()
81 if (!psdev->dev) { in pcistub_device_alloc()
82 kfree(psdev); in pcistub_device_alloc()
86 kref_init(&psdev->kref); in pcistub_device_alloc()
87 spin_lock_init(&psdev->lock); in pcistub_device_alloc()
89 return psdev; in pcistub_device_alloc()
95 struct pcistub_device *psdev; in pcistub_device_release() local
99 psdev = container_of(kref, struct pcistub_device, kref); in pcistub_device_release()
100 dev = psdev->dev; in pcistub_device_release()
144 kfree(psdev); in pcistub_device_release()
147 static inline void pcistub_device_get(struct pcistub_device *psdev) in pcistub_device_get() argument
149 kref_get(&psdev->kref); in pcistub_device_get()
152 static inline void pcistub_device_put(struct pcistub_device *psdev) in pcistub_device_put() argument
154 kref_put(&psdev->kref, pcistub_device_release); in pcistub_device_put()
160 struct pcistub_device *psdev; in pcistub_device_find_locked() local
162 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_device_find_locked()
163 if (psdev->dev != NULL in pcistub_device_find_locked()
164 && domain == pci_domain_nr(psdev->dev->bus) in pcistub_device_find_locked()
165 && bus == psdev->dev->bus->number in pcistub_device_find_locked()
166 && slot == PCI_SLOT(psdev->dev->devfn) in pcistub_device_find_locked()
167 && func == PCI_FUNC(psdev->dev->devfn)) { in pcistub_device_find_locked()
168 return psdev; in pcistub_device_find_locked()
178 struct pcistub_device *psdev; in pcistub_device_find() local
183 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_device_find()
184 if (psdev) in pcistub_device_find()
185 pcistub_device_get(psdev); in pcistub_device_find()
188 return psdev; in pcistub_device_find()
192 struct pcistub_device *psdev) in pcistub_device_get_pci_dev() argument
197 pcistub_device_get(psdev); in pcistub_device_get_pci_dev()
199 spin_lock_irqsave(&psdev->lock, flags); in pcistub_device_get_pci_dev()
200 if (!psdev->pdev) { in pcistub_device_get_pci_dev()
201 psdev->pdev = pdev; in pcistub_device_get_pci_dev()
202 pci_dev = psdev->dev; in pcistub_device_get_pci_dev()
204 spin_unlock_irqrestore(&psdev->lock, flags); in pcistub_device_get_pci_dev()
207 pcistub_device_put(psdev); in pcistub_device_get_pci_dev()
216 struct pcistub_device *psdev; in pcistub_get_pci_dev_by_slot() local
222 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_get_pci_dev_by_slot()
223 if (psdev) in pcistub_get_pci_dev_by_slot()
224 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev_by_slot()
233 struct pcistub_device *psdev; in pcistub_get_pci_dev() local
239 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_get_pci_dev()
240 if (psdev->dev == dev) { in pcistub_get_pci_dev()
241 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev()
263 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_put_pci_dev() local
270 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_put_pci_dev()
271 if (psdev->dev == dev) { in pcistub_put_pci_dev()
272 found_psdev = psdev; in pcistub_put_pci_dev()
454 struct pcistub_device *psdev; in pcistub_init_devices_late() local
461 psdev = container_of(seized_devices.next, in pcistub_init_devices_late()
463 list_del(&psdev->dev_list); in pcistub_init_devices_late()
467 err = pcistub_init_device(psdev->dev); in pcistub_init_devices_late()
469 dev_err(&psdev->dev->dev, in pcistub_init_devices_late()
471 kfree(psdev); in pcistub_init_devices_late()
472 psdev = NULL; in pcistub_init_devices_late()
477 if (psdev) in pcistub_init_devices_late()
478 list_add_tail(&psdev->dev_list, &pcistub_devices); in pcistub_init_devices_late()
521 struct pcistub_device *psdev; in pcistub_seize() local
525 psdev = pcistub_device_alloc(dev); in pcistub_seize()
526 if (!psdev) { in pcistub_seize()
537 err = pcistub_init_device(psdev->dev); in pcistub_seize()
542 list_add(&psdev->dev_list, &pcistub_devices); in pcistub_seize()
545 list_add(&psdev->dev_list, &seized_devices); in pcistub_seize()
552 pcistub_device_put(psdev); in pcistub_seize()
606 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_remove() local
615 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_remove()
616 if (psdev->dev == dev) { in pcistub_remove()
617 found_psdev = psdev; in pcistub_remove()
664 static void kill_domain_by_device(struct pcistub_device *psdev) in kill_domain_by_device() argument
670 BUG_ON(!psdev); in kill_domain_by_device()
672 psdev->pdev->xdev->otherend_id); in kill_domain_by_device()
677 dev_err(&psdev->dev->dev, in kill_domain_by_device()
687 dev_err(&psdev->dev->dev, in kill_domain_by_device()
697 static pci_ers_result_t common_process(struct pcistub_device *psdev, in common_process() argument
703 struct xen_pcibk_device *pdev = psdev->pdev; in common_process()
713 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, in common_process()
716 dev_err(&psdev->dev->dev, "failed to get pcifront device\n"); in common_process()
721 dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n", in common_process()
752 dev_err(&psdev->dev->dev, in common_process()
775 struct pcistub_device *psdev; in xen_pcibk_slot_reset() local
783 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_slot_reset()
788 if (!psdev || !psdev->pdev) { in xen_pcibk_slot_reset()
793 if (!psdev->pdev->sh_info) { in xen_pcibk_slot_reset()
796 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
801 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_slot_reset()
806 result = common_process(psdev, pci_channel_io_normal, XEN_PCI_OP_aer_slotreset, result); in xen_pcibk_slot_reset()
812 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
815 if (psdev) in xen_pcibk_slot_reset()
816 pcistub_device_put(psdev); in xen_pcibk_slot_reset()
832 struct pcistub_device *psdev; in xen_pcibk_mmio_enabled() local
840 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_mmio_enabled()
845 if (!psdev || !psdev->pdev) { in xen_pcibk_mmio_enabled()
850 if (!psdev->pdev->sh_info) { in xen_pcibk_mmio_enabled()
853 kill_domain_by_device(psdev); in xen_pcibk_mmio_enabled()
858 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_mmio_enabled()
863 result = common_process(psdev, pci_channel_io_normal, XEN_PCI_OP_aer_mmio, result); in xen_pcibk_mmio_enabled()
869 kill_domain_by_device(psdev); in xen_pcibk_mmio_enabled()
872 if (psdev) in xen_pcibk_mmio_enabled()
873 pcistub_device_put(psdev); in xen_pcibk_mmio_enabled()
889 struct pcistub_device *psdev; in xen_pcibk_error_detected() local
897 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_detected()
902 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()
960 if (!psdev->pdev->sh_info) { in xen_pcibk_error_resume()
963 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
968 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_resume()
971 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
974 common_process(psdev, pci_channel_io_normal, XEN_PCI_OP_aer_resume, in xen_pcibk_error_resume()
977 if (psdev) in xen_pcibk_error_resume()
978 pcistub_device_put(psdev); in xen_pcibk_error_resume()
1137 struct pcistub_device *psdev; in pcistub_reg_add() local
1144 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_reg_add()
1145 if (!psdev) { in pcistub_reg_add()
1149 dev = psdev->dev; in pcistub_reg_add()
1169 if (psdev) in pcistub_reg_add()
1170 pcistub_device_put(psdev); in pcistub_reg_add()
1237 struct pcistub_device *psdev; in irq_handlers_show() local
1243 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in irq_handlers_show()
1246 if (!psdev->dev) in irq_handlers_show()
1248 dev_data = pci_get_drvdata(psdev->dev); in irq_handlers_show()
1254 pci_name(psdev->dev), in irq_handlers_show()
1267 struct pcistub_device *psdev; in irq_handler_state_store() local
1276 psdev = pcistub_device_find(domain, bus, slot, func); in irq_handler_state_store()
1277 if (!psdev) { in irq_handler_state_store()
1282 dev_data = pci_get_drvdata(psdev->dev); in irq_handler_state_store()
1288 dev_dbg(&psdev->dev->dev, "%s fake irq handler: %d->%d\n", in irq_handler_state_store()
1296 if (psdev) in irq_handler_state_store()
1297 pcistub_device_put(psdev); in irq_handler_state_store()
1373 struct pcistub_device *psdev; in permissive_store() local
1380 psdev = pcistub_device_find(domain, bus, slot, func); in permissive_store()
1381 if (!psdev) { in permissive_store()
1386 dev_data = pci_get_drvdata(psdev->dev); in permissive_store()
1395 dev_warn(&psdev->dev->dev, "enabling permissive mode " in permissive_store()
1397 dev_warn(&psdev->dev->dev, in permissive_store()
1401 pcistub_device_put(psdev); in permissive_store()
1410 struct pcistub_device *psdev; in permissive_show() local
1415 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in permissive_show()
1418 if (!psdev->dev) in permissive_show()
1420 dev_data = pci_get_drvdata(psdev->dev); in permissive_show()
1425 pci_name(psdev->dev)); in permissive_show()
1437 struct pcistub_device *psdev; in allow_interrupt_control_store() local
1444 psdev = pcistub_device_find(domain, bus, slot, func); in allow_interrupt_control_store()
1445 if (!psdev) { in allow_interrupt_control_store()
1450 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_store()
1458 pcistub_device_put(psdev); in allow_interrupt_control_store()
1468 struct pcistub_device *psdev; in allow_interrupt_control_show() local
1474 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in allow_interrupt_control_show()
1477 if (!psdev->dev) in allow_interrupt_control_show()
1479 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_show()
1484 pci_name(psdev->dev)); in allow_interrupt_control_show()
1628 struct pcistub_device *psdev = NULL; in find_vfs() local
1633 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in find_vfs()
1634 if (!psdev->pdev && psdev->dev != pdev in find_vfs()
1635 && pci_physfn(psdev->dev) == pdev) { in find_vfs()
1642 return psdev; in find_vfs()
1659 struct pcistub_device *psdev = find_vfs(pdev); in pci_stub_notifier() local
1660 if (!psdev) in pci_stub_notifier()
1662 device_release_driver(&psdev->dev->dev); in pci_stub_notifier()