Lines Matching refs:psdev

68 	struct pcistub_device *psdev;  in pcistub_device_alloc()  local
72 psdev = kzalloc(sizeof(*psdev), GFP_ATOMIC); in pcistub_device_alloc()
73 if (!psdev) in pcistub_device_alloc()
76 psdev->dev = pci_dev_get(dev); in pcistub_device_alloc()
77 if (!psdev->dev) { in pcistub_device_alloc()
78 kfree(psdev); in pcistub_device_alloc()
82 kref_init(&psdev->kref); in pcistub_device_alloc()
83 spin_lock_init(&psdev->lock); in pcistub_device_alloc()
85 return psdev; in pcistub_device_alloc()
91 struct pcistub_device *psdev; in pcistub_device_release() local
95 psdev = container_of(kref, struct pcistub_device, kref); in pcistub_device_release()
96 dev = psdev->dev; in pcistub_device_release()
139 kfree(psdev); in pcistub_device_release()
142 static inline void pcistub_device_get(struct pcistub_device *psdev) in pcistub_device_get() argument
144 kref_get(&psdev->kref); in pcistub_device_get()
147 static inline void pcistub_device_put(struct pcistub_device *psdev) in pcistub_device_put() argument
149 kref_put(&psdev->kref, pcistub_device_release); in pcistub_device_put()
155 struct pcistub_device *psdev = NULL; in pcistub_device_find() local
160 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_device_find()
161 if (psdev->dev != NULL in pcistub_device_find()
162 && domain == pci_domain_nr(psdev->dev->bus) in pcistub_device_find()
163 && bus == psdev->dev->bus->number in pcistub_device_find()
164 && slot == PCI_SLOT(psdev->dev->devfn) in pcistub_device_find()
165 && func == PCI_FUNC(psdev->dev->devfn)) { in pcistub_device_find()
166 pcistub_device_get(psdev); in pcistub_device_find()
172 psdev = NULL; in pcistub_device_find()
176 return psdev; in pcistub_device_find()
180 struct pcistub_device *psdev) in pcistub_device_get_pci_dev() argument
185 pcistub_device_get(psdev); in pcistub_device_get_pci_dev()
187 spin_lock_irqsave(&psdev->lock, flags); in pcistub_device_get_pci_dev()
188 if (!psdev->pdev) { in pcistub_device_get_pci_dev()
189 psdev->pdev = pdev; in pcistub_device_get_pci_dev()
190 pci_dev = psdev->dev; in pcistub_device_get_pci_dev()
192 spin_unlock_irqrestore(&psdev->lock, flags); in pcistub_device_get_pci_dev()
195 pcistub_device_put(psdev); in pcistub_device_get_pci_dev()
204 struct pcistub_device *psdev; in pcistub_get_pci_dev_by_slot() local
210 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_get_pci_dev_by_slot()
211 if (psdev->dev != NULL in pcistub_get_pci_dev_by_slot()
212 && domain == pci_domain_nr(psdev->dev->bus) in pcistub_get_pci_dev_by_slot()
213 && bus == psdev->dev->bus->number in pcistub_get_pci_dev_by_slot()
214 && slot == PCI_SLOT(psdev->dev->devfn) in pcistub_get_pci_dev_by_slot()
215 && func == PCI_FUNC(psdev->dev->devfn)) { in pcistub_get_pci_dev_by_slot()
216 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev_by_slot()
228 struct pcistub_device *psdev; in pcistub_get_pci_dev() local
234 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_get_pci_dev()
235 if (psdev->dev == dev) { in pcistub_get_pci_dev()
236 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev()
258 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_put_pci_dev() local
265 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_put_pci_dev()
266 if (psdev->dev == dev) { in pcistub_put_pci_dev()
267 found_psdev = psdev; in pcistub_put_pci_dev()
447 struct pcistub_device *psdev; in pcistub_init_devices_late() local
454 psdev = container_of(seized_devices.next, in pcistub_init_devices_late()
456 list_del(&psdev->dev_list); in pcistub_init_devices_late()
460 err = pcistub_init_device(psdev->dev); in pcistub_init_devices_late()
462 dev_err(&psdev->dev->dev, in pcistub_init_devices_late()
464 kfree(psdev); in pcistub_init_devices_late()
465 psdev = NULL; in pcistub_init_devices_late()
470 if (psdev) in pcistub_init_devices_late()
471 list_add_tail(&psdev->dev_list, &pcistub_devices); in pcistub_init_devices_late()
483 struct pcistub_device *psdev; in pcistub_seize() local
487 psdev = pcistub_device_alloc(dev); in pcistub_seize()
488 if (!psdev) in pcistub_seize()
497 err = pcistub_init_device(psdev->dev); in pcistub_seize()
502 list_add(&psdev->dev_list, &pcistub_devices); in pcistub_seize()
505 list_add(&psdev->dev_list, &seized_devices); in pcistub_seize()
511 pcistub_device_put(psdev); in pcistub_seize()
549 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_remove() local
558 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_remove()
559 if (psdev->dev == dev) { in pcistub_remove()
560 found_psdev = psdev; in pcistub_remove()
607 static void kill_domain_by_device(struct pcistub_device *psdev) in kill_domain_by_device() argument
613 BUG_ON(!psdev); in kill_domain_by_device()
615 psdev->pdev->xdev->otherend_id); in kill_domain_by_device()
620 dev_err(&psdev->dev->dev, in kill_domain_by_device()
630 dev_err(&psdev->dev->dev, in kill_domain_by_device()
640 static pci_ers_result_t common_process(struct pcistub_device *psdev, in common_process() argument
646 struct xen_pcibk_device *pdev = psdev->pdev; in common_process()
656 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, in common_process()
659 dev_err(&psdev->dev->dev, in common_process()
665 dev_dbg(&psdev->dev->dev, in common_process()
690 dev_err(&psdev->dev->dev, in common_process()
702 dev_dbg(&psdev->dev->dev, in common_process()
704 xen_pcibk_test_and_schedule_op(psdev->pdev); in common_process()
720 struct pcistub_device *psdev; in xen_pcibk_slot_reset() local
728 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_slot_reset()
733 if (!psdev || !psdev->pdev) { in xen_pcibk_slot_reset()
739 if (!psdev->pdev->sh_info) { in xen_pcibk_slot_reset()
742 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
747 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_slot_reset()
752 result = common_process(psdev, 1, XEN_PCI_OP_aer_slotreset, result); in xen_pcibk_slot_reset()
758 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
761 if (psdev) in xen_pcibk_slot_reset()
762 pcistub_device_put(psdev); in xen_pcibk_slot_reset()
778 struct pcistub_device *psdev; in xen_pcibk_mmio_enabled() local
786 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_mmio_enabled()
791 if (!psdev || !psdev->pdev) { in xen_pcibk_mmio_enabled()
797 if (!psdev->pdev->sh_info) { in xen_pcibk_mmio_enabled()
800 kill_domain_by_device(psdev); in xen_pcibk_mmio_enabled()
805 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_mmio_enabled()
810 result = common_process(psdev, 1, XEN_PCI_OP_aer_mmio, result); in xen_pcibk_mmio_enabled()
816 kill_domain_by_device(psdev); in xen_pcibk_mmio_enabled()
819 if (psdev) in xen_pcibk_mmio_enabled()
820 pcistub_device_put(psdev); in xen_pcibk_mmio_enabled()
836 struct pcistub_device *psdev; in xen_pcibk_error_detected() local
844 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_detected()
849 if (!psdev || !psdev->pdev) { in xen_pcibk_error_detected()
855 if (!psdev->pdev->sh_info) { in xen_pcibk_error_detected()
858 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
864 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_detected()
866 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
869 result = common_process(psdev, error, XEN_PCI_OP_aer_detected, result); in xen_pcibk_error_detected()
875 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
878 if (psdev) in xen_pcibk_error_detected()
879 pcistub_device_put(psdev); in xen_pcibk_error_detected()
892 struct pcistub_device *psdev; in xen_pcibk_error_resume() local
898 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_resume()
903 if (!psdev || !psdev->pdev) { in xen_pcibk_error_resume()
909 if (!psdev->pdev->sh_info) { in xen_pcibk_error_resume()
912 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
917 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_resume()
920 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
923 common_process(psdev, 1, XEN_PCI_OP_aer_resume, in xen_pcibk_error_resume()
926 if (psdev) in xen_pcibk_error_resume()
927 pcistub_device_put(psdev); in xen_pcibk_error_resume()
1093 struct pcistub_device *psdev; in pcistub_reg_add() local
1100 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_reg_add()
1101 if (!psdev) { in pcistub_reg_add()
1105 dev = psdev->dev; in pcistub_reg_add()
1125 if (psdev) in pcistub_reg_add()
1126 pcistub_device_put(psdev); in pcistub_reg_add()
1193 struct pcistub_device *psdev; in pcistub_irq_handler_show() local
1199 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_irq_handler_show()
1202 if (!psdev->dev) in pcistub_irq_handler_show()
1204 dev_data = pci_get_drvdata(psdev->dev); in pcistub_irq_handler_show()
1210 pci_name(psdev->dev), in pcistub_irq_handler_show()
1224 struct pcistub_device *psdev; in pcistub_irq_handler_switch() local
1233 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_irq_handler_switch()
1234 if (!psdev) { in pcistub_irq_handler_switch()
1239 dev_data = pci_get_drvdata(psdev->dev); in pcistub_irq_handler_switch()
1245 dev_dbg(&psdev->dev->dev, "%s fake irq handler: %d->%d\n", in pcistub_irq_handler_switch()
1253 if (psdev) in pcistub_irq_handler_switch()
1254 pcistub_device_put(psdev); in pcistub_irq_handler_switch()
1332 struct pcistub_device *psdev; in permissive_add() local
1339 psdev = pcistub_device_find(domain, bus, slot, func); in permissive_add()
1340 if (!psdev) { in permissive_add()
1345 dev_data = pci_get_drvdata(psdev->dev); in permissive_add()
1354 dev_warn(&psdev->dev->dev, "enabling permissive mode " in permissive_add()
1356 dev_warn(&psdev->dev->dev, in permissive_add()
1360 pcistub_device_put(psdev); in permissive_add()
1369 struct pcistub_device *psdev; in permissive_show() local
1374 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in permissive_show()
1377 if (!psdev->dev) in permissive_show()
1379 dev_data = pci_get_drvdata(psdev->dev); in permissive_show()
1384 pci_name(psdev->dev)); in permissive_show()
1524 struct pcistub_device *psdev = NULL; in find_vfs() local
1529 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in find_vfs()
1530 if (!psdev->pdev && psdev->dev != pdev in find_vfs()
1531 && pci_physfn(psdev->dev) == pdev) { in find_vfs()
1538 return psdev; in find_vfs()
1555 struct pcistub_device *psdev = find_vfs(pdev); in pci_stub_notifier() local
1556 if (!psdev) in pci_stub_notifier()
1558 device_release_driver(&psdev->dev->dev); in pci_stub_notifier()