Lines Matching refs:psdev
71 struct pcistub_device *psdev; in pcistub_device_alloc() local
75 psdev = kzalloc(sizeof(*psdev), GFP_KERNEL); in pcistub_device_alloc()
76 if (!psdev) in pcistub_device_alloc()
79 psdev->dev = pci_dev_get(dev); in pcistub_device_alloc()
80 if (!psdev->dev) { in pcistub_device_alloc()
81 kfree(psdev); in pcistub_device_alloc()
85 kref_init(&psdev->kref); in pcistub_device_alloc()
86 spin_lock_init(&psdev->lock); in pcistub_device_alloc()
88 return psdev; in pcistub_device_alloc()
94 struct pcistub_device *psdev; in pcistub_device_release() local
98 psdev = container_of(kref, struct pcistub_device, kref); in pcistub_device_release()
99 dev = psdev->dev; in pcistub_device_release()
143 kfree(psdev); in pcistub_device_release()
146 static inline void pcistub_device_get(struct pcistub_device *psdev) in pcistub_device_get() argument
148 kref_get(&psdev->kref); in pcistub_device_get()
151 static inline void pcistub_device_put(struct pcistub_device *psdev) in pcistub_device_put() argument
153 kref_put(&psdev->kref, pcistub_device_release); in pcistub_device_put()
159 struct pcistub_device *psdev; in pcistub_device_find_locked() local
161 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_device_find_locked()
162 if (psdev->dev != NULL in pcistub_device_find_locked()
163 && domain == pci_domain_nr(psdev->dev->bus) in pcistub_device_find_locked()
164 && bus == psdev->dev->bus->number in pcistub_device_find_locked()
165 && slot == PCI_SLOT(psdev->dev->devfn) in pcistub_device_find_locked()
166 && func == PCI_FUNC(psdev->dev->devfn)) { in pcistub_device_find_locked()
167 return psdev; in pcistub_device_find_locked()
177 struct pcistub_device *psdev; in pcistub_device_find() local
182 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_device_find()
183 if (psdev) in pcistub_device_find()
184 pcistub_device_get(psdev); in pcistub_device_find()
187 return psdev; in pcistub_device_find()
191 struct pcistub_device *psdev) in pcistub_device_get_pci_dev() argument
196 pcistub_device_get(psdev); in pcistub_device_get_pci_dev()
198 spin_lock_irqsave(&psdev->lock, flags); in pcistub_device_get_pci_dev()
199 if (!psdev->pdev) { in pcistub_device_get_pci_dev()
200 psdev->pdev = pdev; in pcistub_device_get_pci_dev()
201 pci_dev = psdev->dev; in pcistub_device_get_pci_dev()
203 spin_unlock_irqrestore(&psdev->lock, flags); in pcistub_device_get_pci_dev()
206 pcistub_device_put(psdev); in pcistub_device_get_pci_dev()
215 struct pcistub_device *psdev; in pcistub_get_pci_dev_by_slot() local
221 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_get_pci_dev_by_slot()
222 if (psdev) in pcistub_get_pci_dev_by_slot()
223 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev_by_slot()
232 struct pcistub_device *psdev; in pcistub_get_pci_dev() local
238 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_get_pci_dev()
239 if (psdev->dev == dev) { in pcistub_get_pci_dev()
240 found_dev = pcistub_device_get_pci_dev(pdev, psdev); in pcistub_get_pci_dev()
262 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_put_pci_dev() local
269 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_put_pci_dev()
270 if (psdev->dev == dev) { in pcistub_put_pci_dev()
271 found_psdev = psdev; in pcistub_put_pci_dev()
453 struct pcistub_device *psdev; in pcistub_init_devices_late() local
460 psdev = container_of(seized_devices.next, in pcistub_init_devices_late()
462 list_del(&psdev->dev_list); in pcistub_init_devices_late()
466 err = pcistub_init_device(psdev->dev); in pcistub_init_devices_late()
468 dev_err(&psdev->dev->dev, in pcistub_init_devices_late()
470 kfree(psdev); in pcistub_init_devices_late()
471 psdev = NULL; in pcistub_init_devices_late()
476 if (psdev) in pcistub_init_devices_late()
477 list_add_tail(&psdev->dev_list, &pcistub_devices); in pcistub_init_devices_late()
520 struct pcistub_device *psdev; in pcistub_seize() local
524 psdev = pcistub_device_alloc(dev); in pcistub_seize()
525 if (!psdev) { in pcistub_seize()
536 err = pcistub_init_device(psdev->dev); in pcistub_seize()
541 list_add(&psdev->dev_list, &pcistub_devices); in pcistub_seize()
544 list_add(&psdev->dev_list, &seized_devices); in pcistub_seize()
551 pcistub_device_put(psdev); in pcistub_seize()
605 struct pcistub_device *psdev, *found_psdev = NULL; in pcistub_remove() local
614 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in pcistub_remove()
615 if (psdev->dev == dev) { in pcistub_remove()
616 found_psdev = psdev; in pcistub_remove()
663 static void kill_domain_by_device(struct pcistub_device *psdev) in kill_domain_by_device() argument
669 BUG_ON(!psdev); in kill_domain_by_device()
671 psdev->pdev->xdev->otherend_id); in kill_domain_by_device()
676 dev_err(&psdev->dev->dev, in kill_domain_by_device()
686 dev_err(&psdev->dev->dev, in kill_domain_by_device()
696 static pci_ers_result_t common_process(struct pcistub_device *psdev, in common_process() argument
702 struct xen_pcibk_device *pdev = psdev->pdev; in common_process()
712 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, in common_process()
715 dev_err(&psdev->dev->dev, "failed to get pcifront device\n"); in common_process()
720 dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n", in common_process()
751 dev_err(&psdev->dev->dev, in common_process()
774 struct pcistub_device *psdev; in xen_pcibk_slot_reset() local
782 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_slot_reset()
787 if (!psdev || !psdev->pdev) { in xen_pcibk_slot_reset()
792 if (!psdev->pdev->sh_info) { in xen_pcibk_slot_reset()
795 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
800 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_slot_reset()
805 result = common_process(psdev, 1, XEN_PCI_OP_aer_slotreset, result); in xen_pcibk_slot_reset()
811 kill_domain_by_device(psdev); in xen_pcibk_slot_reset()
814 if (psdev) in xen_pcibk_slot_reset()
815 pcistub_device_put(psdev); in xen_pcibk_slot_reset()
831 struct pcistub_device *psdev; in xen_pcibk_mmio_enabled() local
839 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_mmio_enabled()
844 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()
906 if (!psdev->pdev->sh_info) { in xen_pcibk_error_detected()
909 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
915 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_detected()
917 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
920 result = common_process(psdev, error, XEN_PCI_OP_aer_detected, result); in xen_pcibk_error_detected()
926 kill_domain_by_device(psdev); in xen_pcibk_error_detected()
929 if (psdev) in xen_pcibk_error_detected()
930 pcistub_device_put(psdev); in xen_pcibk_error_detected()
943 struct pcistub_device *psdev; in xen_pcibk_error_resume() local
949 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_resume()
954 if (!psdev || !psdev->pdev) { in xen_pcibk_error_resume()
959 if (!psdev->pdev->sh_info) { in xen_pcibk_error_resume()
962 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
967 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_resume()
970 kill_domain_by_device(psdev); in xen_pcibk_error_resume()
973 common_process(psdev, 1, XEN_PCI_OP_aer_resume, in xen_pcibk_error_resume()
976 if (psdev) in xen_pcibk_error_resume()
977 pcistub_device_put(psdev); in xen_pcibk_error_resume()
1136 struct pcistub_device *psdev; in pcistub_reg_add() local
1143 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_reg_add()
1144 if (!psdev) { in pcistub_reg_add()
1148 dev = psdev->dev; in pcistub_reg_add()
1168 if (psdev) in pcistub_reg_add()
1169 pcistub_device_put(psdev); in pcistub_reg_add()
1236 struct pcistub_device *psdev; in irq_handlers_show() local
1242 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in irq_handlers_show()
1245 if (!psdev->dev) in irq_handlers_show()
1247 dev_data = pci_get_drvdata(psdev->dev); in irq_handlers_show()
1253 pci_name(psdev->dev), in irq_handlers_show()
1266 struct pcistub_device *psdev; in irq_handler_state_store() local
1275 psdev = pcistub_device_find(domain, bus, slot, func); in irq_handler_state_store()
1276 if (!psdev) { in irq_handler_state_store()
1281 dev_data = pci_get_drvdata(psdev->dev); in irq_handler_state_store()
1287 dev_dbg(&psdev->dev->dev, "%s fake irq handler: %d->%d\n", in irq_handler_state_store()
1295 if (psdev) in irq_handler_state_store()
1296 pcistub_device_put(psdev); in irq_handler_state_store()
1372 struct pcistub_device *psdev; in permissive_store() local
1379 psdev = pcistub_device_find(domain, bus, slot, func); in permissive_store()
1380 if (!psdev) { in permissive_store()
1385 dev_data = pci_get_drvdata(psdev->dev); in permissive_store()
1394 dev_warn(&psdev->dev->dev, "enabling permissive mode " in permissive_store()
1396 dev_warn(&psdev->dev->dev, in permissive_store()
1400 pcistub_device_put(psdev); in permissive_store()
1409 struct pcistub_device *psdev; in permissive_show() local
1414 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in permissive_show()
1417 if (!psdev->dev) in permissive_show()
1419 dev_data = pci_get_drvdata(psdev->dev); in permissive_show()
1424 pci_name(psdev->dev)); in permissive_show()
1436 struct pcistub_device *psdev; in allow_interrupt_control_store() local
1443 psdev = pcistub_device_find(domain, bus, slot, func); in allow_interrupt_control_store()
1444 if (!psdev) { in allow_interrupt_control_store()
1449 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_store()
1457 pcistub_device_put(psdev); in allow_interrupt_control_store()
1467 struct pcistub_device *psdev; in allow_interrupt_control_show() local
1473 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in allow_interrupt_control_show()
1476 if (!psdev->dev) in allow_interrupt_control_show()
1478 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_show()
1483 pci_name(psdev->dev)); in allow_interrupt_control_show()
1627 struct pcistub_device *psdev = NULL; in find_vfs() local
1632 list_for_each_entry(psdev, &pcistub_devices, dev_list) { in find_vfs()
1633 if (!psdev->pdev && psdev->dev != pdev in find_vfs()
1634 && pci_physfn(psdev->dev) == pdev) { in find_vfs()
1641 return psdev; in find_vfs()
1658 struct pcistub_device *psdev = find_vfs(pdev); in pci_stub_notifier() local
1659 if (!psdev) in pci_stub_notifier()
1661 device_release_driver(&psdev->dev->dev); in pci_stub_notifier()