Lines Matching refs:psdev
78 struct pcistub_device *psdev; in pcistub_device_alloc() local
82 psdev = kzalloc(sizeof(*psdev), GFP_KERNEL); in pcistub_device_alloc()
83 if (!psdev) in pcistub_device_alloc()
86 psdev->dev = pci_dev_get(dev); in pcistub_device_alloc()
87 if (!psdev->dev) { in pcistub_device_alloc()
88 kfree(psdev); in pcistub_device_alloc()
92 kref_init(&psdev->kref); in pcistub_device_alloc()
93 spin_lock_init(&psdev->lock); in pcistub_device_alloc()
95 psdev->gsi = -1; in pcistub_device_alloc()
98 return psdev; in pcistub_device_alloc()
114 struct pcistub_device *psdev; in pcistub_device_release() local
118 psdev = container_of(kref, struct pcistub_device, kref); in pcistub_device_release()
119 dev = psdev->dev; in pcistub_device_release()
163 kfree(psdev); in pcistub_device_release()
166 static inline void pcistub_device_get(struct pcistub_device *psdev) in pcistub_device_get() argument
168 kref_get(&psdev->kref); in pcistub_device_get()
171 static inline void pcistub_device_put(struct pcistub_device *psdev) in pcistub_device_put() argument
173 kref_put(&psdev->kref, pcistub_device_release); in pcistub_device_put()
179 struct pcistub_device *psdev; in pcistub_device_find_locked() local
181 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_device_find_locked()
182 if (psdev->dev != NULL in pcistub_device_find_locked()
183 && domain == pci_domain_nr(psdev->dev->bus) in pcistub_device_find_locked()
184 && bus == psdev->dev->bus->number in pcistub_device_find_locked()
185 && slot == PCI_SLOT(psdev->dev->devfn) in pcistub_device_find_locked()
186 && func == PCI_FUNC(psdev->dev->devfn)) { in pcistub_device_find_locked()
187 return psdev; in pcistub_device_find_locked()
197 struct pcistub_device *psdev; in pcistub_device_find() local
202 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_device_find()
203 if (psdev) in pcistub_device_find()
204 pcistub_device_get(psdev); in pcistub_device_find()
207 return psdev; in pcistub_device_find()
211 struct pcistub_device *psdev) in pcistub_device_get_pci_dev() argument
216 spin_lock_irqsave(&psdev->lock, flags); in pcistub_device_get_pci_dev()
217 if (!psdev->pdev) { in pcistub_device_get_pci_dev()
218 psdev->pdev = pdev; in pcistub_device_get_pci_dev()
219 pci_dev = psdev->dev; in pcistub_device_get_pci_dev()
221 spin_unlock_irqrestore(&psdev->lock, flags); in pcistub_device_get_pci_dev()
224 pcistub_device_get(psdev); in pcistub_device_get_pci_dev()
232 struct pcistub_device *psdev; in pcistub_get_gsi_from_sbdf() local
238 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_get_gsi_from_sbdf()
240 if (!psdev) in pcistub_get_gsi_from_sbdf()
243 return psdev->gsi; in pcistub_get_gsi_from_sbdf()
251 struct pcistub_device *psdev; in pcistub_get_pci_dev_by_slot() local
257 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_get_pci_dev_by_slot()
258 if (psdev) in pcistub_get_pci_dev_by_slot()
259 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev_by_slot()
268 struct pcistub_device *psdev; in pcistub_get_pci_dev() local
274 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_get_pci_dev()
275 if (psdev->dev == dev) { in pcistub_get_pci_dev()
276 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev()
298 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_put_pci_dev() local
305 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_put_pci_dev()
306 if (psdev->dev == dev) { in pcistub_put_pci_dev()
307 found_psdev = psdev; in pcistub_put_pci_dev()
394 static int pcistub_init_device(struct pcistub_device *psdev) in pcistub_init_device() argument
403 if (!psdev) in pcistub_init_device()
406 dev = psdev->dev; in pcistub_init_device()
485 psdev->gsi = gsi; in pcistub_init_device()
515 struct pcistub_device *psdev; in pcistub_init_devices_late() local
522 psdev = container_of(seized_devices.next, in pcistub_init_devices_late()
524 list_del(&psdev->dev_list); in pcistub_init_devices_late()
528 err = pcistub_init_device(psdev); in pcistub_init_devices_late()
530 dev_err(&psdev->dev->dev, in pcistub_init_devices_late()
532 kfree(psdev); in pcistub_init_devices_late()
533 psdev = NULL; in pcistub_init_devices_late()
538 if (psdev) in pcistub_init_devices_late()
539 list_add_tail(&psdev->dev_list, &pcistub_devices); in pcistub_init_devices_late()
582 struct pcistub_device *psdev; in pcistub_seize() local
586 psdev = pcistub_device_alloc(dev); in pcistub_seize()
587 if (!psdev) { in pcistub_seize()
598 err = pcistub_init_device(psdev); in pcistub_seize()
603 list_add(&psdev->dev_list, &pcistub_devices); in pcistub_seize()
606 list_add(&psdev->dev_list, &seized_devices); in pcistub_seize()
613 pcistub_device_put(psdev); in pcistub_seize()
667 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_remove() local
676 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_remove()
677 if (psdev->dev == dev) { in pcistub_remove()
678 found_psdev = psdev; in pcistub_remove()
725 static void kill_domain_by_device(struct pcistub_device *psdev) in kill_domain_by_device() argument
731 BUG_ON(!psdev); in kill_domain_by_device()
733 psdev->pdev->xdev->otherend_id); in kill_domain_by_device()
738 dev_err(&psdev->dev->dev, in kill_domain_by_device()
748 dev_err(&psdev->dev->dev, in kill_domain_by_device()
758 static pci_ers_result_t common_process(struct pcistub_device *psdev, in common_process() argument
764 struct xen_pcibk_device *pdev = psdev->pdev; in common_process()
774 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, in common_process()
777 dev_err(&psdev->dev->dev, "failed to get pcifront device\n"); in common_process()
782 dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n", in common_process()
813 dev_err(&psdev->dev->dev, in common_process()
836 struct pcistub_device *psdev; in xen_pcibk_slot_reset() local
844 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_slot_reset()
849 if (!psdev || !psdev->pdev) { in xen_pcibk_slot_reset()
854 if (!psdev->pdev->sh_info) { in xen_pcibk_slot_reset()
857 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
862 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_slot_reset()
867 result = common_process(psdev, pci_channel_io_normal, XEN_PCI_OP_aer_slotreset, result); in xen_pcibk_slot_reset()
873 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
876 if (psdev) in xen_pcibk_slot_reset()
877 pcistub_device_put(psdev); in xen_pcibk_slot_reset()
893 struct pcistub_device *psdev; in xen_pcibk_mmio_enabled() local
901 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_mmio_enabled()
906 if (!psdev || !psdev->pdev) { in xen_pcibk_mmio_enabled()
911 if (!psdev->pdev->sh_info) { in xen_pcibk_mmio_enabled()
914 kill_domain_by_device(psdev); in xen_pcibk_mmio_enabled()
919 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_mmio_enabled()
924 result = common_process(psdev, pci_channel_io_normal, XEN_PCI_OP_aer_mmio, result); in xen_pcibk_mmio_enabled()
930 kill_domain_by_device(psdev); in xen_pcibk_mmio_enabled()
933 if (psdev) in xen_pcibk_mmio_enabled()
934 pcistub_device_put(psdev); in xen_pcibk_mmio_enabled()
950 struct pcistub_device *psdev; in xen_pcibk_error_detected() local
958 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_detected()
963 if (!psdev || !psdev->pdev) { in xen_pcibk_error_detected()
968 if (!psdev->pdev->sh_info) { in xen_pcibk_error_detected()
971 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
977 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_detected()
979 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
982 result = common_process(psdev, error, XEN_PCI_OP_aer_detected, result); in xen_pcibk_error_detected()
988 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
991 if (psdev) in xen_pcibk_error_detected()
992 pcistub_device_put(psdev); in xen_pcibk_error_detected()
1005 struct pcistub_device *psdev; in xen_pcibk_error_resume() local
1011 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_resume()
1016 if (!psdev || !psdev->pdev) { in xen_pcibk_error_resume()
1021 if (!psdev->pdev->sh_info) { in xen_pcibk_error_resume()
1024 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
1029 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_resume()
1032 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
1035 common_process(psdev, pci_channel_io_normal, XEN_PCI_OP_aer_resume, in xen_pcibk_error_resume()
1038 if (psdev) in xen_pcibk_error_resume()
1039 pcistub_device_put(psdev); in xen_pcibk_error_resume()
1198 struct pcistub_device *psdev; in pcistub_reg_add() local
1205 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_reg_add()
1206 if (!psdev) { in pcistub_reg_add()
1210 dev = psdev->dev; in pcistub_reg_add()
1230 if (psdev) in pcistub_reg_add()
1231 pcistub_device_put(psdev); in pcistub_reg_add()
1298 struct pcistub_device *psdev; in irq_handlers_show() local
1304 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in irq_handlers_show()
1307 if (!psdev->dev) in irq_handlers_show()
1309 dev_data = pci_get_drvdata(psdev->dev); in irq_handlers_show()
1315 pci_name(psdev->dev), in irq_handlers_show()
1328 struct pcistub_device *psdev; in irq_handler_state_store() local
1337 psdev = pcistub_device_find(domain, bus, slot, func); in irq_handler_state_store()
1338 if (!psdev) { in irq_handler_state_store()
1343 dev_data = pci_get_drvdata(psdev->dev); in irq_handler_state_store()
1349 dev_dbg(&psdev->dev->dev, "%s fake irq handler: %d->%d\n", in irq_handler_state_store()
1357 if (psdev) in irq_handler_state_store()
1358 pcistub_device_put(psdev); in irq_handler_state_store()
1434 struct pcistub_device *psdev; in permissive_store() local
1441 psdev = pcistub_device_find(domain, bus, slot, func); in permissive_store()
1442 if (!psdev) { in permissive_store()
1447 dev_data = pci_get_drvdata(psdev->dev); in permissive_store()
1456 dev_warn(&psdev->dev->dev, "enabling permissive mode " in permissive_store()
1458 dev_warn(&psdev->dev->dev, in permissive_store()
1462 pcistub_device_put(psdev); in permissive_store()
1471 struct pcistub_device *psdev; in permissive_show() local
1476 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in permissive_show()
1479 if (!psdev->dev) in permissive_show()
1481 dev_data = pci_get_drvdata(psdev->dev); in permissive_show()
1486 pci_name(psdev->dev)); in permissive_show()
1498 struct pcistub_device *psdev; in allow_interrupt_control_store() local
1505 psdev = pcistub_device_find(domain, bus, slot, func); in allow_interrupt_control_store()
1506 if (!psdev) { in allow_interrupt_control_store()
1511 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_store()
1519 pcistub_device_put(psdev); in allow_interrupt_control_store()
1529 struct pcistub_device *psdev; in allow_interrupt_control_show() local
1535 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in allow_interrupt_control_show()
1538 if (!psdev->dev) in allow_interrupt_control_show()
1540 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_show()
1545 pci_name(psdev->dev)); in allow_interrupt_control_show()
1689 struct pcistub_device *psdev = NULL; in find_vfs() local
1694 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in find_vfs()
1695 if (!psdev->pdev && psdev->dev != pdev in find_vfs()
1696 && pci_physfn(psdev->dev) == pdev) { in find_vfs()
1703 return psdev; in find_vfs()
1720 struct pcistub_device *psdev = find_vfs(pdev); in pci_stub_notifier() local
1721 if (!psdev) in pci_stub_notifier()
1723 device_release_driver(&psdev->dev->dev); in pci_stub_notifier()