Lines Matching +full:pci +full:- +full:domain
2 * PCI Stub Driver - Grabs devices in backend to be exported later
17 #include <linux/pci.h>
22 #include <xen/pci.h>
45 int domain; member
58 struct xen_pcibk_device *pdev;/* non-NULL if struct pci_dev is in use */
80 dev_dbg(&dev->dev, "pcistub_device_alloc\n"); in pcistub_device_alloc()
86 psdev->dev = pci_dev_get(dev); in pcistub_device_alloc()
87 if (!psdev->dev) { 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()
119 dev = psdev->dev; in pcistub_device_release()
122 dev_dbg(&dev->dev, "pcistub_device_release\n"); in pcistub_device_release()
131 pci_load_and_free_saved_state(dev, &dev_data->pci_saved_state)) in pcistub_device_release()
132 dev_info(&dev->dev, "Could not reload PCI state\n"); in pcistub_device_release()
136 if (dev->msix_cap) { in pcistub_device_release()
138 .seg = pci_domain_nr(dev->bus), in pcistub_device_release()
139 .bus = dev->bus->number, in pcistub_device_release()
140 .devfn = dev->devfn in pcistub_device_release()
145 if (err && err != -ENOSYS) in pcistub_device_release()
146 dev_warn(&dev->dev, "MSI-X release failed (%d)\n", in pcistub_device_release()
156 /* Clean-up the device */ in pcistub_device_release()
168 kref_get(&psdev->kref); in pcistub_device_get()
173 kref_put(&psdev->kref, pcistub_device_release); in pcistub_device_put()
176 static struct pcistub_device *pcistub_device_find_locked(int domain, int bus, in pcistub_device_find_locked() argument
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()
194 static struct pcistub_device *pcistub_device_find(int domain, int bus, in pcistub_device_find() argument
202 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_device_find()
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()
233 int domain = (sbdf >> 16) & 0xffff; in pcistub_get_gsi_from_sbdf() local
238 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_get_gsi_from_sbdf()
241 return -ENODEV; in pcistub_get_gsi_from_sbdf()
243 return psdev->gsi; in pcistub_get_gsi_from_sbdf()
248 int domain, int bus, in pcistub_get_pci_dev_by_slot() argument
257 psdev = pcistub_device_find_locked(domain, bus, slot, func); in pcistub_get_pci_dev_by_slot()
267 * - XenBus state has been reconfigure (pci unplug). See xen_pcibk_remove_device
268 * - XenBus state has been disconnected (guest shutdown). See xen_pcibk_xenbus_remove
269 * - 'echo BDF > unbind' on pciback module with no guest attached. See pcistub_remove
270 * - 'echo BDF > unbind' with a guest still using it. See pcistub_remove
286 if (psdev->dev == dev) { in pcistub_put_pci_dev()
301 * (so it's ready for the next domain) in pcistub_put_pci_dev()
303 device_lock_assert(&dev->dev); in pcistub_put_pci_dev()
307 ret = pci_load_saved_state(dev, dev_data->pci_saved_state); in pcistub_put_pci_dev()
316 dev_info(&dev->dev, "Could not reload PCI state\n"); in pcistub_put_pci_dev()
324 dev_data->allow_interrupt_control = 0; in pcistub_put_pci_dev()
328 spin_lock_irqsave(&found_psdev->lock, flags); in pcistub_put_pci_dev()
329 found_psdev->pdev = NULL; in pcistub_put_pci_dev()
330 spin_unlock_irqrestore(&found_psdev->lock, flags); in pcistub_put_pci_dev()
339 /* Match the specified device by domain, bus, slot, func and also if in pcistub_match_one()
342 for (; dev != NULL; dev = dev->bus->self) { in pcistub_match_one()
343 if (pci_domain_nr(dev->bus) == pdev_id->domain in pcistub_match_one()
344 && dev->bus->number == pdev_id->bus in pcistub_match_one()
345 && dev->devfn == pdev_id->devfn) in pcistub_match_one()
349 if (dev == dev->bus->self) in pcistub_match_one()
384 return -EINVAL; in pcistub_init_device()
386 dev = psdev->dev; in pcistub_init_device()
388 dev_dbg(&dev->dev, "initializing...\n"); in pcistub_init_device()
390 /* The PCI backend is not intended to be a module (or to work with in pcistub_init_device()
391 * removable PCI devices (yet). If it were, xen_pcibk_config_free() in pcistub_init_device()
393 * here and then to call kfree(pci_get_drvdata(psdev->dev)). in pcistub_init_device()
398 err = -ENOMEM; in pcistub_init_device()
407 sprintf(dev_data->irq_name, DRV_NAME "[%s]", pci_name(dev)); in pcistub_init_device()
409 dev_dbg(&dev->dev, "initializing config\n"); in pcistub_init_device()
416 /* HACK: Force device (& ACPI) to determine what IRQ it's on - we in pcistub_init_device()
418 * the pci device's true irq (and possibly its other resources) in pcistub_init_device()
423 dev_dbg(&dev->dev, "enabling device\n"); in pcistub_init_device()
428 if (dev->msix_cap) { in pcistub_init_device()
430 .seg = pci_domain_nr(dev->bus), in pcistub_init_device()
431 .bus = dev->bus->number, in pcistub_init_device()
432 .devfn = dev->devfn in pcistub_init_device()
436 if (err && err != -ENOSYS) in pcistub_init_device()
437 dev_err(&dev->dev, "MSI-X preparation failed (%d)\n", in pcistub_init_device()
442 dev_dbg(&dev->dev, "save state of device\n"); in pcistub_init_device()
444 dev_data->pci_saved_state = pci_store_saved_state(dev); in pcistub_init_device()
445 if (!dev_data->pci_saved_state) in pcistub_init_device()
446 dev_err(&dev->dev, "Could not store PCI conf saved state!\n"); in pcistub_init_device()
448 dev_dbg(&dev->dev, "resetting (FLR, D3, etc) the device\n"); in pcistub_init_device()
459 dev_err(&dev->dev, "Fail to get gsi info!\n"); in pcistub_init_device()
465 psdev->gsi = gsi; in pcistub_init_device()
472 dev_dbg(&dev->dev, "reset device\n"); in pcistub_init_device()
504 list_del(&psdev->dev_list); in pcistub_init_devices_late()
510 dev_err(&psdev->dev->dev, in pcistub_init_devices_late()
519 list_add_tail(&psdev->dev_list, &pcistub_devices); in pcistub_init_devices_late()
530 int domain, int bus, unsigned int devfn) in pcistub_device_id_add_list() argument
539 if (pci_dev_id->domain == domain && pci_dev_id->bus == bus && in pcistub_device_id_add_list()
540 pci_dev_id->devfn == devfn) { in pcistub_device_id_add_list()
547 new->domain = domain; in pcistub_device_id_add_list()
548 new->bus = bus; in pcistub_device_id_add_list()
549 new->devfn = devfn; in pcistub_device_id_add_list()
550 list_add_tail(&new->slot_list, &pcistub_device_ids); in pcistub_device_id_add_list()
569 return -ENOMEM; in pcistub_seize()
583 list_add(&psdev->dev_list, &pcistub_devices); in pcistub_seize()
585 dev_dbg(&dev->dev, "deferring initialization\n"); in pcistub_seize()
586 list_add(&psdev->dev_list, &seized_devices); in pcistub_seize()
595 pcistub_device_id_add_list(pci_dev_id, pci_domain_nr(dev->bus), in pcistub_seize()
596 dev->bus->number, dev->devfn); in pcistub_seize()
608 dev_dbg(&dev->dev, "probing...\n"); in pcistub_probe()
612 if ((dev->driver_override && in pcistub_probe()
613 !strcmp(dev->driver_override, PCISTUB_DRIVER_NAME)) || in pcistub_probe()
616 if (dev->hdr_type != PCI_HEADER_TYPE_NORMAL in pcistub_probe()
617 && dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { in pcistub_probe()
618 dev_err(&dev->dev, "can't export pci devices that " in pcistub_probe()
621 err = -ENODEV; in pcistub_probe()
628 err = -ENOMEM; in pcistub_probe()
633 dev_info(&dev->dev, "seizing device\n"); in pcistub_probe()
637 err = -ENODEV; in pcistub_probe()
650 dev_dbg(&dev->dev, "removing\n"); in pcistub_remove()
657 if (psdev->dev == dev) { in pcistub_remove()
666 dev_dbg(&dev->dev, "found device to remove %s\n", in pcistub_remove()
667 found_psdev->pdev ? "- in-use" : ""); in pcistub_remove()
669 if (found_psdev->pdev) { in pcistub_remove()
672 dev_warn(&dev->dev, "****** removing device %s while still in-use by domain %d! ******\n", in pcistub_remove()
673 pci_name(found_psdev->dev), domid); in pcistub_remove()
674 dev_warn(&dev->dev, "****** driver domain may still access this device's i/o resources!\n"); in pcistub_remove()
675 dev_warn(&dev->dev, "****** shutdown driver domain before binding device\n"); in pcistub_remove()
676 dev_warn(&dev->dev, "****** to other drivers or domains\n"); in pcistub_remove()
680 xen_pcibk_release_pci_dev(found_psdev->pdev, in pcistub_remove()
681 found_psdev->dev, in pcistub_remove()
686 list_del(&found_psdev->dev_list); in pcistub_remove()
712 snprintf(nodename, PCI_NODENAME_MAX, "/local/domain/0/backend/pci/%d/0", in kill_domain_by_device()
713 psdev->pdev->xdev->otherend_id); in kill_domain_by_device()
718 dev_err(&psdev->dev->dev, in kill_domain_by_device()
726 if (err == -EAGAIN) in kill_domain_by_device()
728 dev_err(&psdev->dev->dev, in kill_domain_by_device()
744 struct xen_pcibk_device *pdev = psdev->pdev; in common_process()
745 struct xen_pci_sharedinfo *sh_info = pdev->sh_info; in common_process()
749 aer_op = &(sh_info->aer_op); in common_process()
750 aer_op->cmd = aer_cmd ; in common_process()
752 aer_op->err = state; in common_process()
754 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, in common_process()
755 &aer_op->domain, &aer_op->bus, &aer_op->devfn); in common_process()
757 dev_err(&psdev->dev->dev, "failed to get pcifront device\n"); in common_process()
762 dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n", in common_process()
763 aer_cmd, aer_op->domain, aer_op->bus, aer_op->devfn); in common_process()
765 * this flag to judge whether we need to check pci-front give aer in common_process()
768 set_bit(_PCIB_op_pending, (unsigned long *)&pdev->flags); in common_process()
775 (unsigned long *)&sh_info->flags); in common_process()
777 notify_remote_via_irq(pdev->evtchn_irq); in common_process()
784 &sh_info->flags)), 300*HZ); in common_process()
787 if (!test_bit(_PDEVF_op_active, &pdev->flags)) in common_process()
792 (unsigned long *)&sh_info->flags)) { in common_process()
793 dev_err(&psdev->dev->dev, in common_process()
796 (unsigned long *)&sh_info->flags); in common_process()
797 aer_op->err = PCI_ERS_RESULT_NONE; in common_process()
801 clear_bit(_PCIB_op_pending, (unsigned long *)&pdev->flags); in common_process()
803 res = (__force pci_ers_result_t)aer_op->err; in common_process()
811 * @dev: pointer to PCI devices
820 dev_dbg(&dev->dev, "xen_pcibk_slot_reset(bus:%x,devfn:%x)\n", in xen_pcibk_slot_reset()
821 dev->bus->number, dev->devfn); in xen_pcibk_slot_reset()
824 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_slot_reset()
825 dev->bus->number, in xen_pcibk_slot_reset()
826 PCI_SLOT(dev->devfn), in xen_pcibk_slot_reset()
827 PCI_FUNC(dev->devfn)); in xen_pcibk_slot_reset()
829 if (!psdev || !psdev->pdev) { in xen_pcibk_slot_reset()
830 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_slot_reset()
834 if (!psdev->pdev->sh_info) { in xen_pcibk_slot_reset()
835 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_slot_reset()
842 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_slot_reset()
843 dev_err(&dev->dev, in xen_pcibk_slot_reset()
851 dev_dbg(&dev->dev, in xen_pcibk_slot_reset()
867 * @dev: pointer to PCI devices
877 dev_dbg(&dev->dev, "xen_pcibk_mmio_enabled(bus:%x,devfn:%x)\n", in xen_pcibk_mmio_enabled()
878 dev->bus->number, dev->devfn); in xen_pcibk_mmio_enabled()
881 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_mmio_enabled()
882 dev->bus->number, in xen_pcibk_mmio_enabled()
883 PCI_SLOT(dev->devfn), in xen_pcibk_mmio_enabled()
884 PCI_FUNC(dev->devfn)); in xen_pcibk_mmio_enabled()
886 if (!psdev || !psdev->pdev) { in xen_pcibk_mmio_enabled()
887 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_mmio_enabled()
891 if (!psdev->pdev->sh_info) { in xen_pcibk_mmio_enabled()
892 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_mmio_enabled()
899 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_mmio_enabled()
900 dev_err(&dev->dev, in xen_pcibk_mmio_enabled()
908 dev_dbg(&dev->dev, in xen_pcibk_mmio_enabled()
922 * @dev: pointer to PCI devices
923 * @error: the current PCI connection state
934 dev_dbg(&dev->dev, "xen_pcibk_error_detected(bus:%x,devfn:%x)\n", in xen_pcibk_error_detected()
935 dev->bus->number, dev->devfn); in xen_pcibk_error_detected()
938 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_detected()
939 dev->bus->number, in xen_pcibk_error_detected()
940 PCI_SLOT(dev->devfn), in xen_pcibk_error_detected()
941 PCI_FUNC(dev->devfn)); in xen_pcibk_error_detected()
943 if (!psdev || !psdev->pdev) { in xen_pcibk_error_detected()
944 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_error_detected()
948 if (!psdev->pdev->sh_info) { in xen_pcibk_error_detected()
949 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_error_detected()
957 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_detected()
958 dev_dbg(&dev->dev, "guest may have no aer driver, kill it\n"); in xen_pcibk_error_detected()
966 dev_dbg(&dev->dev, in xen_pcibk_error_detected()
980 * @dev: pointer to PCI devices
987 dev_dbg(&dev->dev, "xen_pcibk_error_resume(bus:%x,devfn:%x)\n", in xen_pcibk_error_resume()
988 dev->bus->number, dev->devfn); in xen_pcibk_error_resume()
991 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_resume()
992 dev->bus->number, in xen_pcibk_error_resume()
993 PCI_SLOT(dev->devfn), in xen_pcibk_error_resume()
994 PCI_FUNC(dev->devfn)); in xen_pcibk_error_resume()
996 if (!psdev || !psdev->pdev) { in xen_pcibk_error_resume()
997 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_error_resume()
1001 if (!psdev->pdev->sh_info) { in xen_pcibk_error_resume()
1002 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_error_resume()
1009 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_resume()
1010 dev_err(&dev->dev, in xen_pcibk_error_resume()
1047 static inline int str_to_slot(const char *buf, int *domain, int *bus, in str_to_slot() argument
1052 switch (sscanf(buf, " %x:%x:%x.%x %n", domain, bus, slot, func, in str_to_slot()
1055 *func = -1; in str_to_slot()
1056 sscanf(buf, " %x:%x:%x.* %n", domain, bus, slot, &parsed); in str_to_slot()
1059 *slot = *func = -1; in str_to_slot()
1060 sscanf(buf, " %x:%x:*.* %n", domain, bus, &parsed); in str_to_slot()
1066 /* try again without domain */ in str_to_slot()
1067 *domain = 0; in str_to_slot()
1070 *func = -1; in str_to_slot()
1074 *slot = *func = -1; in str_to_slot()
1081 return -EINVAL; in str_to_slot()
1084 static inline int str_to_quirk(const char *buf, int *domain, int *bus, int in str_to_quirk() argument
1089 sscanf(buf, " %x:%x:%x.%x-%x:%x:%x %n", domain, bus, slot, func, in str_to_quirk()
1094 /* try again without domain */ in str_to_quirk()
1095 *domain = 0; in str_to_quirk()
1096 sscanf(buf, " %x:%x.%x-%x:%x:%x %n", bus, slot, func, reg, size, in str_to_quirk()
1101 return -EINVAL; in str_to_quirk()
1104 static int pcistub_device_id_add(int domain, int bus, int slot, int func) in pcistub_device_id_add() argument
1111 rc = pcistub_device_id_add(domain, bus, slot, func); in pcistub_device_id_add()
1117 rc = pcistub_device_id_add(domain, bus, slot, func); in pcistub_device_id_add()
1124 !pci_domains_supported ? domain : in pcistub_device_id_add()
1126 domain < 0 || domain > 0xffff) in pcistub_device_id_add()
1130 return -EINVAL; in pcistub_device_id_add()
1134 return -ENOMEM; in pcistub_device_id_add()
1137 domain, bus, slot, func); in pcistub_device_id_add()
1139 pcistub_device_id_add_list(pci_dev_id, domain, bus, devfn); in pcistub_device_id_add()
1144 static int pcistub_device_id_remove(int domain, int bus, int slot, int func) in pcistub_device_id_remove() argument
1147 int err = -ENOENT; in pcistub_device_id_remove()
1153 if (pci_dev_id->domain == domain && pci_dev_id->bus == bus in pcistub_device_id_remove()
1154 && (slot < 0 || PCI_SLOT(pci_dev_id->devfn) == slot) in pcistub_device_id_remove()
1155 && (func < 0 || PCI_FUNC(pci_dev_id->devfn) == func)) { in pcistub_device_id_remove()
1159 list_del(&pci_dev_id->slot_list); in pcistub_device_id_remove()
1165 domain, bus, slot, func); in pcistub_device_id_remove()
1173 static int pcistub_reg_add(int domain, int bus, int slot, int func, in pcistub_reg_add() argument
1183 return -EINVAL; in pcistub_reg_add()
1185 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_reg_add()
1187 err = -ENODEV; in pcistub_reg_add()
1190 dev = psdev->dev; in pcistub_reg_add()
1194 err = -ENOMEM; in pcistub_reg_add()
1198 field->offset = reg; in pcistub_reg_add()
1199 field->size = size; in pcistub_reg_add()
1200 field->mask = mask; in pcistub_reg_add()
1201 field->init = NULL; in pcistub_reg_add()
1202 field->reset = NULL; in pcistub_reg_add()
1203 field->release = NULL; in pcistub_reg_add()
1204 field->clean = xen_pcibk_config_field_free; in pcistub_reg_add()
1218 int domain, bus, slot, func; in new_slot_store() local
1221 err = str_to_slot(buf, &domain, &bus, &slot, &func); in new_slot_store()
1225 err = pcistub_device_id_add(domain, bus, slot, func); in new_slot_store()
1237 int domain, bus, slot, func; in remove_slot_store() local
1240 err = str_to_slot(buf, &domain, &bus, &slot, &func); in remove_slot_store()
1244 err = pcistub_device_id_remove(domain, bus, slot, func); in remove_slot_store()
1264 count += scnprintf(buf + count, PAGE_SIZE - count, in slots_show()
1266 pci_dev_id->domain, pci_dev_id->bus, in slots_show()
1267 PCI_SLOT(pci_dev_id->devfn), in slots_show()
1268 PCI_FUNC(pci_dev_id->devfn)); in slots_show()
1287 if (!psdev->dev) in irq_handlers_show()
1289 dev_data = pci_get_drvdata(psdev->dev); in irq_handlers_show()
1293 scnprintf(buf + count, PAGE_SIZE - count, in irq_handlers_show()
1295 pci_name(psdev->dev), in irq_handlers_show()
1296 dev_data->isr_on ? "on" : "off", in irq_handlers_show()
1297 dev_data->ack_intr ? "ack" : "not ack", in irq_handlers_show()
1298 dev_data->handled); in irq_handlers_show()
1310 int domain, bus, slot, func; in irq_handler_state_store() local
1313 err = str_to_slot(buf, &domain, &bus, &slot, &func); in irq_handler_state_store()
1317 psdev = pcistub_device_find(domain, bus, slot, func); in irq_handler_state_store()
1319 err = -ENOENT; in irq_handler_state_store()
1323 dev_data = pci_get_drvdata(psdev->dev); in irq_handler_state_store()
1325 err = -ENOENT; in irq_handler_state_store()
1329 dev_dbg(&psdev->dev->dev, "%s fake irq handler: %d->%d\n", in irq_handler_state_store()
1330 dev_data->irq_name, dev_data->isr_on, in irq_handler_state_store()
1331 !dev_data->isr_on); in irq_handler_state_store()
1333 dev_data->isr_on = !(dev_data->isr_on); in irq_handler_state_store()
1334 if (dev_data->isr_on) in irq_handler_state_store()
1335 dev_data->ack_intr = 1; in irq_handler_state_store()
1348 int domain, bus, slot, func, reg, size, mask; in quirks_store() local
1351 err = str_to_quirk(buf, &domain, &bus, &slot, &func, ®, &size, in quirks_store()
1356 err = pcistub_reg_add(domain, bus, slot, func, reg, size, mask); in quirks_store()
1378 count += scnprintf(buf + count, PAGE_SIZE - count, in quirks_show()
1380 quirk->pdev->bus->number, in quirks_show()
1381 PCI_SLOT(quirk->pdev->devfn), in quirks_show()
1382 PCI_FUNC(quirk->pdev->devfn), in quirks_show()
1383 quirk->devid.vendor, quirk->devid.device, in quirks_show()
1384 quirk->devid.subvendor, in quirks_show()
1385 quirk->devid.subdevice); in quirks_show()
1387 dev_data = pci_get_drvdata(quirk->pdev); in quirks_show()
1389 list_for_each_entry(cfg_entry, &dev_data->config_fields, list) { in quirks_show()
1390 field = cfg_entry->field; in quirks_show()
1394 count += scnprintf(buf + count, PAGE_SIZE - count, in quirks_show()
1396 cfg_entry->base_offset + in quirks_show()
1397 field->offset, field->size, in quirks_show()
1398 field->mask); in quirks_show()
1412 int domain, bus, slot, func; in permissive_store() local
1417 err = str_to_slot(buf, &domain, &bus, &slot, &func); in permissive_store()
1421 psdev = pcistub_device_find(domain, bus, slot, func); in permissive_store()
1423 err = -ENODEV; in permissive_store()
1427 dev_data = pci_get_drvdata(psdev->dev); in permissive_store()
1430 err = -ENXIO; in permissive_store()
1433 if (!dev_data->permissive) { in permissive_store()
1434 dev_data->permissive = 1; in permissive_store()
1436 dev_warn(&psdev->dev->dev, "enabling permissive mode " in permissive_store()
1438 dev_warn(&psdev->dev->dev, in permissive_store()
1459 if (!psdev->dev) in permissive_show()
1461 dev_data = pci_get_drvdata(psdev->dev); in permissive_show()
1462 if (!dev_data || !dev_data->permissive) in permissive_show()
1465 scnprintf(buf + count, PAGE_SIZE - count, "%s\n", in permissive_show()
1466 pci_name(psdev->dev)); in permissive_show()
1476 int domain, bus, slot, func; in allow_interrupt_control_store() local
1481 err = str_to_slot(buf, &domain, &bus, &slot, &func); in allow_interrupt_control_store()
1485 psdev = pcistub_device_find(domain, bus, slot, func); in allow_interrupt_control_store()
1487 err = -ENODEV; in allow_interrupt_control_store()
1491 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_store()
1494 err = -ENXIO; in allow_interrupt_control_store()
1497 dev_data->allow_interrupt_control = 1; in allow_interrupt_control_store()
1518 if (!psdev->dev) in allow_interrupt_control_show()
1520 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_show()
1521 if (!dev_data || !dev_data->allow_interrupt_control) in allow_interrupt_control_show()
1524 scnprintf(buf + count, PAGE_SIZE - count, "%s\n", in allow_interrupt_control_show()
1525 pci_name(psdev->dev)); in allow_interrupt_control_show()
1554 int domain, bus, slot, func; in pcistub_init() local
1563 &domain, &bus, &slot, &func, &parsed); in pcistub_init()
1566 func = -1; in pcistub_init()
1569 &domain, &bus, &slot, &parsed); in pcistub_init()
1572 slot = func = -1; in pcistub_init()
1575 &domain, &bus, &parsed); in pcistub_init()
1580 domain = 0; in pcistub_init()
1586 func = -1; in pcistub_init()
1592 slot = func = -1; in pcistub_init()
1603 err = pcistub_device_id_add(domain, bus, slot, func); in pcistub_init()
1611 /* If we're the first PCI Device Driver to register, we're the in pcistub_init()
1612 * first one to get offered PCI devices as they become in pcistub_init()
1652 return -EINVAL; in pcistub_init()
1660 * get a chance by being the first pci device
1675 if (!psdev->pdev && psdev->dev != pdev in find_vfs()
1676 && pci_physfn(psdev->dev) == pdev) { in find_vfs()
1696 if (!pdev->is_physfn) in pci_stub_notifier()
1703 device_release_driver(&psdev->dev->dev); in pci_stub_notifier()
1718 return -ENODEV; in xen_pcibk_init()
1762 MODULE_DESCRIPTION("Xen PCI-device stub driver");
1764 MODULE_ALIAS("xen-backend:pci");