Lines Matching refs:dev

54 	struct pci_dev *dev;  member
70 static struct pcistub_device *pcistub_device_alloc(struct pci_dev *dev) in pcistub_device_alloc() argument
74 dev_dbg(&dev->dev, "pcistub_device_alloc\n"); in pcistub_device_alloc()
80 psdev->dev = pci_dev_get(dev); in pcistub_device_alloc()
81 if (!psdev->dev) { in pcistub_device_alloc()
96 struct pci_dev *dev; in pcistub_device_release() local
100 dev = psdev->dev; in pcistub_device_release()
101 dev_data = pci_get_drvdata(dev); in pcistub_device_release()
103 dev_dbg(&dev->dev, "pcistub_device_release\n"); in pcistub_device_release()
105 xen_unregister_device_domain_owner(dev); in pcistub_device_release()
110 __pci_reset_function_locked(dev); in pcistub_device_release()
112 pci_load_and_free_saved_state(dev, &dev_data->pci_saved_state)) in pcistub_device_release()
113 dev_info(&dev->dev, "Could not reload PCI state\n"); in pcistub_device_release()
115 pci_restore_state(dev); in pcistub_device_release()
117 if (dev->msix_cap) { in pcistub_device_release()
119 .seg = pci_domain_nr(dev->bus), in pcistub_device_release()
120 .bus = dev->bus->number, in pcistub_device_release()
121 .devfn = dev->devfn in pcistub_device_release()
127 dev_warn(&dev->dev, "MSI-X release failed (%d)\n", in pcistub_device_release()
132 xen_pcibk_reset_device(dev); in pcistub_device_release()
135 pci_set_drvdata(dev, NULL); in pcistub_device_release()
138 xen_pcibk_config_free_dyn_fields(dev); in pcistub_device_release()
139 xen_pcibk_config_free_dev(dev); in pcistub_device_release()
141 pci_clear_dev_assigned(dev); in pcistub_device_release()
142 pci_dev_put(dev); in pcistub_device_release()
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()
200 pci_dev = psdev->dev; in pcistub_device_get_pci_dev()
229 struct pci_dev *dev) in pcistub_get_pci_dev() argument
238 if (psdev->dev == dev) { in pcistub_get_pci_dev()
259 void pcistub_put_pci_dev(struct pci_dev *dev) in pcistub_put_pci_dev() argument
269 if (psdev->dev == dev) { in pcistub_put_pci_dev()
286 device_lock_assert(&dev->dev); in pcistub_put_pci_dev()
287 __pci_reset_function_locked(dev); in pcistub_put_pci_dev()
289 dev_data = pci_get_drvdata(dev); in pcistub_put_pci_dev()
290 ret = pci_load_saved_state(dev, dev_data->pci_saved_state); in pcistub_put_pci_dev()
297 pci_restore_state(dev); in pcistub_put_pci_dev()
299 dev_info(&dev->dev, "Could not reload PCI state\n"); in pcistub_put_pci_dev()
301 xen_pcibk_reset_device(dev); in pcistub_put_pci_dev()
304 xen_pcibk_config_reset_dev(dev); in pcistub_put_pci_dev()
305 xen_pcibk_config_free_dyn_fields(dev); in pcistub_put_pci_dev()
309 xen_unregister_device_domain_owner(dev); in pcistub_put_pci_dev()
319 static int pcistub_match_one(struct pci_dev *dev, in pcistub_match_one() argument
325 for (; dev != NULL; dev = dev->bus->self) { in pcistub_match_one()
326 if (pci_domain_nr(dev->bus) == pdev_id->domain in pcistub_match_one()
327 && dev->bus->number == pdev_id->bus in pcistub_match_one()
328 && dev->devfn == pdev_id->devfn) in pcistub_match_one()
332 if (dev == dev->bus->self) in pcistub_match_one()
339 static int pcistub_match(struct pci_dev *dev) in pcistub_match() argument
347 if (pcistub_match_one(dev, pdev_id)) { in pcistub_match()
357 static int pcistub_init_device(struct pci_dev *dev) in pcistub_init_device() argument
362 dev_dbg(&dev->dev, "initializing...\n"); in pcistub_init_device()
370 + strlen(pci_name(dev)) + 1, GFP_KERNEL); in pcistub_init_device()
375 pci_set_drvdata(dev, dev_data); in pcistub_init_device()
381 sprintf(dev_data->irq_name, DRV_NAME "[%s]", pci_name(dev)); in pcistub_init_device()
383 dev_dbg(&dev->dev, "initializing config\n"); in pcistub_init_device()
386 err = xen_pcibk_config_init_dev(dev); in pcistub_init_device()
397 dev_dbg(&dev->dev, "enabling device\n"); in pcistub_init_device()
398 err = pci_enable_device(dev); in pcistub_init_device()
402 if (dev->msix_cap) { in pcistub_init_device()
404 .seg = pci_domain_nr(dev->bus), in pcistub_init_device()
405 .bus = dev->bus->number, in pcistub_init_device()
406 .devfn = dev->devfn in pcistub_init_device()
411 dev_err(&dev->dev, "MSI-X preparation failed (%d)\n", in pcistub_init_device()
416 dev_dbg(&dev->dev, "save state of device\n"); in pcistub_init_device()
417 pci_save_state(dev); in pcistub_init_device()
418 dev_data->pci_saved_state = pci_store_saved_state(dev); in pcistub_init_device()
420 dev_err(&dev->dev, "Could not store PCI conf saved state!\n"); in pcistub_init_device()
422 dev_dbg(&dev->dev, "resetting (FLR, D3, etc) the device\n"); in pcistub_init_device()
423 __pci_reset_function_locked(dev); in pcistub_init_device()
424 pci_restore_state(dev); in pcistub_init_device()
429 dev_dbg(&dev->dev, "reset device\n"); in pcistub_init_device()
430 xen_pcibk_reset_device(dev); in pcistub_init_device()
432 pci_set_dev_assigned(dev); in pcistub_init_device()
436 xen_pcibk_config_free_dev(dev); in pcistub_init_device()
439 pci_set_drvdata(dev, NULL); in pcistub_init_device()
465 err = pcistub_init_device(psdev->dev); in pcistub_init_devices_late()
467 dev_err(&psdev->dev->dev, in pcistub_init_devices_late()
516 static int pcistub_seize(struct pci_dev *dev, in pcistub_seize() argument
523 psdev = pcistub_device_alloc(dev); in pcistub_seize()
535 err = pcistub_init_device(psdev->dev); in pcistub_seize()
542 dev_dbg(&dev->dev, "deferring initialization\n"); in pcistub_seize()
552 pcistub_device_id_add_list(pci_dev_id, pci_domain_nr(dev->bus), in pcistub_seize()
553 dev->bus->number, dev->devfn); in pcistub_seize()
560 static int pcistub_probe(struct pci_dev *dev, const struct pci_device_id *id) in pcistub_probe() argument
565 dev_dbg(&dev->dev, "probing...\n"); in pcistub_probe()
567 match = pcistub_match(dev); in pcistub_probe()
569 if ((dev->driver_override && in pcistub_probe()
570 !strcmp(dev->driver_override, PCISTUB_DRIVER_NAME)) || in pcistub_probe()
573 if (dev->hdr_type != PCI_HEADER_TYPE_NORMAL in pcistub_probe()
574 && dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { in pcistub_probe()
575 dev_err(&dev->dev, "can't export pci devices that " in pcistub_probe()
590 dev_info(&dev->dev, "seizing device\n"); in pcistub_probe()
591 err = pcistub_seize(dev, pci_dev_id); in pcistub_probe()
602 static void pcistub_remove(struct pci_dev *dev) in pcistub_remove() argument
607 dev_dbg(&dev->dev, "removing\n"); in pcistub_remove()
611 xen_pcibk_config_quirk_release(dev); in pcistub_remove()
614 if (psdev->dev == dev) { in pcistub_remove()
623 dev_dbg(&dev->dev, "found device to remove %s\n", in pcistub_remove()
627 int domid = xen_find_device_domain_owner(dev); in pcistub_remove()
629 dev_warn(&dev->dev, "****** removing device %s while still in-use by domain %d! ******\n", in pcistub_remove()
630 pci_name(found_psdev->dev), domid); in pcistub_remove()
631 dev_warn(&dev->dev, "****** driver domain may still access this device's i/o resources!\n"); in pcistub_remove()
632 dev_warn(&dev->dev, "****** shutdown driver domain before binding device\n"); in pcistub_remove()
633 dev_warn(&dev->dev, "****** to other drivers or domains\n"); in pcistub_remove()
638 found_psdev->dev, in pcistub_remove()
675 dev_err(&psdev->dev->dev, in kill_domain_by_device()
685 dev_err(&psdev->dev->dev, in kill_domain_by_device()
711 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, in common_process()
714 dev_err(&psdev->dev->dev, "failed to get pcifront device\n"); in common_process()
719 dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n", in common_process()
750 dev_err(&psdev->dev->dev, in common_process()
771 static pci_ers_result_t xen_pcibk_slot_reset(struct pci_dev *dev) in xen_pcibk_slot_reset() argument
777 dev_dbg(&dev->dev, "xen_pcibk_slot_reset(bus:%x,devfn:%x)\n", in xen_pcibk_slot_reset()
778 dev->bus->number, dev->devfn); in xen_pcibk_slot_reset()
781 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_slot_reset()
782 dev->bus->number, in xen_pcibk_slot_reset()
783 PCI_SLOT(dev->devfn), in xen_pcibk_slot_reset()
784 PCI_FUNC(dev->devfn)); in xen_pcibk_slot_reset()
787 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_slot_reset()
792 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_slot_reset()
800 dev_err(&dev->dev, in xen_pcibk_slot_reset()
808 dev_dbg(&dev->dev, in xen_pcibk_slot_reset()
828 static pci_ers_result_t xen_pcibk_mmio_enabled(struct pci_dev *dev) in xen_pcibk_mmio_enabled() argument
834 dev_dbg(&dev->dev, "xen_pcibk_mmio_enabled(bus:%x,devfn:%x)\n", in xen_pcibk_mmio_enabled()
835 dev->bus->number, dev->devfn); in xen_pcibk_mmio_enabled()
838 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_mmio_enabled()
839 dev->bus->number, in xen_pcibk_mmio_enabled()
840 PCI_SLOT(dev->devfn), in xen_pcibk_mmio_enabled()
841 PCI_FUNC(dev->devfn)); in xen_pcibk_mmio_enabled()
844 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_mmio_enabled()
849 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_mmio_enabled()
857 dev_err(&dev->dev, in xen_pcibk_mmio_enabled()
865 dev_dbg(&dev->dev, in xen_pcibk_mmio_enabled()
884 static pci_ers_result_t xen_pcibk_error_detected(struct pci_dev *dev, in xen_pcibk_error_detected() argument
891 dev_dbg(&dev->dev, "xen_pcibk_error_detected(bus:%x,devfn:%x)\n", in xen_pcibk_error_detected()
892 dev->bus->number, dev->devfn); in xen_pcibk_error_detected()
895 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_detected()
896 dev->bus->number, in xen_pcibk_error_detected()
897 PCI_SLOT(dev->devfn), in xen_pcibk_error_detected()
898 PCI_FUNC(dev->devfn)); in xen_pcibk_error_detected()
901 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_error_detected()
906 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_error_detected()
915 dev_dbg(&dev->dev, "guest may have no aer driver, kill it\n"); in xen_pcibk_error_detected()
923 dev_dbg(&dev->dev, in xen_pcibk_error_detected()
940 static void xen_pcibk_error_resume(struct pci_dev *dev) in xen_pcibk_error_resume() argument
944 dev_dbg(&dev->dev, "xen_pcibk_error_resume(bus:%x,devfn:%x)\n", in xen_pcibk_error_resume()
945 dev->bus->number, dev->devfn); in xen_pcibk_error_resume()
948 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_resume()
949 dev->bus->number, in xen_pcibk_error_resume()
950 PCI_SLOT(dev->devfn), in xen_pcibk_error_resume()
951 PCI_FUNC(dev->devfn)); in xen_pcibk_error_resume()
954 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_error_resume()
959 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_error_resume()
967 dev_err(&dev->dev, in xen_pcibk_error_resume()
1136 struct pci_dev *dev; in pcistub_reg_add() local
1147 dev = psdev->dev; in pcistub_reg_add()
1163 err = xen_pcibk_config_quirks_add_field(dev, field); in pcistub_reg_add()
1244 if (!psdev->dev) in irq_handlers_show()
1246 dev_data = pci_get_drvdata(psdev->dev); in irq_handlers_show()
1252 pci_name(psdev->dev), in irq_handlers_show()
1280 dev_data = pci_get_drvdata(psdev->dev); in irq_handler_state_store()
1286 dev_dbg(&psdev->dev->dev, "%s fake irq handler: %d->%d\n", in irq_handler_state_store()
1384 dev_data = pci_get_drvdata(psdev->dev); in permissive_store()
1393 dev_warn(&psdev->dev->dev, "enabling permissive mode " in permissive_store()
1395 dev_warn(&psdev->dev->dev, in permissive_store()
1416 if (!psdev->dev) in permissive_show()
1418 dev_data = pci_get_drvdata(psdev->dev); in permissive_show()
1423 pci_name(psdev->dev)); in permissive_show()
1448 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_store()
1475 if (!psdev->dev) in allow_interrupt_control_show()
1477 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_show()
1482 pci_name(psdev->dev)); in allow_interrupt_control_show()
1632 if (!psdev->pdev && psdev->dev != pdev in find_vfs()
1633 && pci_physfn(psdev->dev) == pdev) { in find_vfs()
1647 struct device *dev = data; in pci_stub_notifier() local
1648 const struct pci_dev *pdev = to_pci_dev(dev); in pci_stub_notifier()
1660 device_release_driver(&psdev->dev->dev); in pci_stub_notifier()