Lines Matching +full:bus +full:- +full:err

2  * PCI Stub Driver - Grabs devices in backend to be exported later
46 unsigned char bus; 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()
142 int err = HYPERVISOR_physdev_op(PHYSDEVOP_release_msix, in pcistub_device_release() local
145 if (err && err != -ENOSYS) in pcistub_device_release()
146 dev_warn(&dev->dev, "MSI-X release failed (%d)\n", in pcistub_device_release()
147 err); 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()
234 int bus = PCI_BUS_NUM(sbdf); 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()
275 if (psdev->dev == dev) { in pcistub_get_pci_dev()
287 * - XenBus state has been reconfigure (pci unplug). See xen_pcibk_remove_device
288 * - XenBus state has been disconnected (guest shutdown). See xen_pcibk_xenbus_remove
289 * - 'echo BDF > unbind' on pciback module with no guest attached. See pcistub_remove
290 * - 'echo BDF > unbind' with a guest still using it. See pcistub_remove
306 if (psdev->dev == dev) { in pcistub_put_pci_dev()
323 device_lock_assert(&dev->dev); in pcistub_put_pci_dev()
327 ret = pci_load_saved_state(dev, dev_data->pci_saved_state); in pcistub_put_pci_dev()
336 dev_info(&dev->dev, "Could not reload PCI state\n"); in pcistub_put_pci_dev()
344 dev_data->allow_interrupt_control = 0; in pcistub_put_pci_dev()
348 spin_lock_irqsave(&found_psdev->lock, flags); in pcistub_put_pci_dev()
349 found_psdev->pdev = NULL; in pcistub_put_pci_dev()
350 spin_unlock_irqrestore(&found_psdev->lock, flags); in pcistub_put_pci_dev()
359 /* Match the specified device by domain, bus, slot, func and also if in pcistub_match_one()
362 for (; dev != NULL; dev = dev->bus->self) { in pcistub_match_one()
363 if (pci_domain_nr(dev->bus) == pdev_id->domain in pcistub_match_one()
364 && dev->bus->number == pdev_id->bus in pcistub_match_one()
365 && dev->devfn == pdev_id->devfn) in pcistub_match_one()
369 if (dev == dev->bus->self) in pcistub_match_one()
401 int err = 0; in pcistub_init_device() local
404 return -EINVAL; in pcistub_init_device()
406 dev = psdev->dev; in pcistub_init_device()
408 dev_dbg(&dev->dev, "initializing...\n"); in pcistub_init_device()
413 * here and then to call kfree(pci_get_drvdata(psdev->dev)). in pcistub_init_device()
418 err = -ENOMEM; in pcistub_init_device()
427 sprintf(dev_data->irq_name, DRV_NAME "[%s]", pci_name(dev)); in pcistub_init_device()
429 dev_dbg(&dev->dev, "initializing config\n"); in pcistub_init_device()
432 err = xen_pcibk_config_init_dev(dev); in pcistub_init_device()
433 if (err) in pcistub_init_device()
436 /* HACK: Force device (& ACPI) to determine what IRQ it's on - we in pcistub_init_device()
443 dev_dbg(&dev->dev, "enabling device\n"); in pcistub_init_device()
444 err = pci_enable_device(dev); in pcistub_init_device()
445 if (err) in pcistub_init_device()
448 if (dev->msix_cap) { in pcistub_init_device()
450 .seg = pci_domain_nr(dev->bus), in pcistub_init_device()
451 .bus = dev->bus->number, in pcistub_init_device()
452 .devfn = dev->devfn in pcistub_init_device()
455 err = HYPERVISOR_physdev_op(PHYSDEVOP_prepare_msix, &ppdev); in pcistub_init_device()
456 if (err && err != -ENOSYS) in pcistub_init_device()
457 dev_err(&dev->dev, "MSI-X preparation failed (%d)\n", in pcistub_init_device()
458 err); in pcistub_init_device()
462 dev_dbg(&dev->dev, "save state of device\n"); in pcistub_init_device()
464 dev_data->pci_saved_state = pci_store_saved_state(dev); in pcistub_init_device()
465 if (!dev_data->pci_saved_state) in pcistub_init_device()
466 dev_err(&dev->dev, "Could not store PCI conf saved state!\n"); in pcistub_init_device()
468 dev_dbg(&dev->dev, "resetting (FLR, D3, etc) the device\n"); in pcistub_init_device()
469 err = pcistub_reset_device_state(dev); in pcistub_init_device()
470 if (err) in pcistub_init_device()
477 err = xen_acpi_get_gsi_info(dev, &gsi, &trigger, &polarity); in pcistub_init_device()
478 if (err) { in pcistub_init_device()
479 dev_err(&dev->dev, "Fail to get gsi info!\n"); in pcistub_init_device()
482 err = xen_pvh_setup_gsi(gsi, trigger, polarity); in pcistub_init_device()
483 if (err) in pcistub_init_device()
485 psdev->gsi = gsi; in pcistub_init_device()
492 dev_dbg(&dev->dev, "reset device\n"); in pcistub_init_device()
504 return err; in pcistub_init_device()
517 int err = 0; in pcistub_init_devices_late() local
524 list_del(&psdev->dev_list); in pcistub_init_devices_late()
528 err = pcistub_init_device(psdev); in pcistub_init_devices_late()
529 if (err) { in pcistub_init_devices_late()
530 dev_err(&psdev->dev->dev, in pcistub_init_devices_late()
531 "error %d initializing device\n", err); in pcistub_init_devices_late()
539 list_add_tail(&psdev->dev_list, &pcistub_devices); in pcistub_init_devices_late()
550 int domain, int bus, unsigned int devfn) in pcistub_device_id_add_list() argument
559 if (pci_dev_id->domain == domain && pci_dev_id->bus == bus && in pcistub_device_id_add_list()
560 pci_dev_id->devfn == devfn) { in pcistub_device_id_add_list()
567 new->domain = domain; in pcistub_device_id_add_list()
568 new->bus = bus; in pcistub_device_id_add_list()
569 new->devfn = devfn; in pcistub_device_id_add_list()
570 list_add_tail(&new->slot_list, &pcistub_device_ids); in pcistub_device_id_add_list()
584 int err = 0; in pcistub_seize() local
589 return -ENOMEM; in pcistub_seize()
598 err = pcistub_init_device(psdev); in pcistub_seize()
602 if (!err) in pcistub_seize()
603 list_add(&psdev->dev_list, &pcistub_devices); in pcistub_seize()
605 dev_dbg(&dev->dev, "deferring initialization\n"); in pcistub_seize()
606 list_add(&psdev->dev_list, &seized_devices); in pcistub_seize()
611 if (err) { in pcistub_seize()
615 pcistub_device_id_add_list(pci_dev_id, pci_domain_nr(dev->bus), in pcistub_seize()
616 dev->bus->number, dev->devfn); in pcistub_seize()
618 return err; in pcistub_seize()
625 int err = 0, match; in pcistub_probe() local
628 dev_dbg(&dev->dev, "probing...\n"); in pcistub_probe()
632 if ((dev->driver_override && in pcistub_probe()
633 !strcmp(dev->driver_override, PCISTUB_DRIVER_NAME)) || in pcistub_probe()
636 if (dev->hdr_type != PCI_HEADER_TYPE_NORMAL in pcistub_probe()
637 && dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { in pcistub_probe()
638 dev_err(&dev->dev, "can't export pci devices that " in pcistub_probe()
641 err = -ENODEV; in pcistub_probe()
648 err = -ENOMEM; in pcistub_probe()
653 dev_info(&dev->dev, "seizing device\n"); in pcistub_probe()
654 err = pcistub_seize(dev, pci_dev_id); in pcistub_probe()
657 err = -ENODEV; in pcistub_probe()
660 return err; in pcistub_probe()
670 dev_dbg(&dev->dev, "removing\n"); in pcistub_remove()
677 if (psdev->dev == dev) { in pcistub_remove()
686 dev_dbg(&dev->dev, "found device to remove %s\n", in pcistub_remove()
687 found_psdev->pdev ? "- in-use" : ""); in pcistub_remove()
689 if (found_psdev->pdev) { in pcistub_remove()
692 dev_warn(&dev->dev, "****** removing device %s while still in-use by domain %d! ******\n", in pcistub_remove()
693 pci_name(found_psdev->dev), domid); in pcistub_remove()
694 dev_warn(&dev->dev, "****** driver domain may still access this device's i/o resources!\n"); in pcistub_remove()
695 dev_warn(&dev->dev, "****** shutdown driver domain before binding device\n"); in pcistub_remove()
696 dev_warn(&dev->dev, "****** to other drivers or domains\n"); in pcistub_remove()
700 xen_pcibk_release_pci_dev(found_psdev->pdev, in pcistub_remove()
701 found_psdev->dev, in pcistub_remove()
706 list_del(&found_psdev->dev_list); in pcistub_remove()
728 int err; in kill_domain_by_device() local
733 psdev->pdev->xdev->otherend_id); in kill_domain_by_device()
736 err = xenbus_transaction_start(&xbt); in kill_domain_by_device()
737 if (err) { in kill_domain_by_device()
738 dev_err(&psdev->dev->dev, in kill_domain_by_device()
739 "error %d when start xenbus transaction\n", err); in kill_domain_by_device()
744 err = xenbus_transaction_end(xbt, 0); in kill_domain_by_device()
745 if (err) { in kill_domain_by_device()
746 if (err == -EAGAIN) in kill_domain_by_device()
748 dev_err(&psdev->dev->dev, in kill_domain_by_device()
749 "error %d when end xenbus transaction\n", err); in kill_domain_by_device()
764 struct xen_pcibk_device *pdev = psdev->pdev; in common_process()
765 struct xen_pci_sharedinfo *sh_info = pdev->sh_info; in common_process()
769 aer_op = &(sh_info->aer_op); in common_process()
770 aer_op->cmd = aer_cmd ; in common_process()
772 aer_op->err = state; in common_process()
774 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, in common_process()
775 &aer_op->domain, &aer_op->bus, &aer_op->devfn); 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()
783 aer_cmd, aer_op->domain, aer_op->bus, aer_op->devfn); in common_process()
785 * this flag to judge whether we need to check pci-front give aer in common_process()
788 set_bit(_PCIB_op_pending, (unsigned long *)&pdev->flags); in common_process()
795 (unsigned long *)&sh_info->flags); in common_process()
797 notify_remote_via_irq(pdev->evtchn_irq); in common_process()
804 &sh_info->flags)), 300*HZ); in common_process()
807 if (!test_bit(_PDEVF_op_active, &pdev->flags)) in common_process()
812 (unsigned long *)&sh_info->flags)) { in common_process()
813 dev_err(&psdev->dev->dev, in common_process()
816 (unsigned long *)&sh_info->flags); in common_process()
817 aer_op->err = PCI_ERS_RESULT_NONE; in common_process()
821 clear_bit(_PCIB_op_pending, (unsigned long *)&pdev->flags); in common_process()
823 res = (__force pci_ers_result_t)aer_op->err; in common_process()
840 dev_dbg(&dev->dev, "xen_pcibk_slot_reset(bus:%x,devfn:%x)\n", in xen_pcibk_slot_reset()
841 dev->bus->number, dev->devfn); in xen_pcibk_slot_reset()
844 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_slot_reset()
845 dev->bus->number, in xen_pcibk_slot_reset()
846 PCI_SLOT(dev->devfn), in xen_pcibk_slot_reset()
847 PCI_FUNC(dev->devfn)); in xen_pcibk_slot_reset()
849 if (!psdev || !psdev->pdev) { in xen_pcibk_slot_reset()
850 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_slot_reset()
854 if (!psdev->pdev->sh_info) { in xen_pcibk_slot_reset()
855 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_slot_reset()
862 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_slot_reset()
863 dev_err(&dev->dev, in xen_pcibk_slot_reset()
871 dev_dbg(&dev->dev, in xen_pcibk_slot_reset()
897 dev_dbg(&dev->dev, "xen_pcibk_mmio_enabled(bus:%x,devfn:%x)\n", in xen_pcibk_mmio_enabled()
898 dev->bus->number, dev->devfn); in xen_pcibk_mmio_enabled()
901 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_mmio_enabled()
902 dev->bus->number, in xen_pcibk_mmio_enabled()
903 PCI_SLOT(dev->devfn), in xen_pcibk_mmio_enabled()
904 PCI_FUNC(dev->devfn)); in xen_pcibk_mmio_enabled()
906 if (!psdev || !psdev->pdev) { in xen_pcibk_mmio_enabled()
907 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_mmio_enabled()
911 if (!psdev->pdev->sh_info) { in xen_pcibk_mmio_enabled()
912 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_mmio_enabled()
919 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_mmio_enabled()
920 dev_err(&dev->dev, in xen_pcibk_mmio_enabled()
928 dev_dbg(&dev->dev, in xen_pcibk_mmio_enabled()
954 dev_dbg(&dev->dev, "xen_pcibk_error_detected(bus:%x,devfn:%x)\n", in xen_pcibk_error_detected()
955 dev->bus->number, dev->devfn); in xen_pcibk_error_detected()
958 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_detected()
959 dev->bus->number, in xen_pcibk_error_detected()
960 PCI_SLOT(dev->devfn), in xen_pcibk_error_detected()
961 PCI_FUNC(dev->devfn)); in xen_pcibk_error_detected()
963 if (!psdev || !psdev->pdev) { in xen_pcibk_error_detected()
964 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_error_detected()
968 if (!psdev->pdev->sh_info) { in xen_pcibk_error_detected()
969 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_error_detected()
977 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_detected()
978 dev_dbg(&dev->dev, "guest may have no aer driver, kill it\n"); in xen_pcibk_error_detected()
986 dev_dbg(&dev->dev, in xen_pcibk_error_detected()
1007 dev_dbg(&dev->dev, "xen_pcibk_error_resume(bus:%x,devfn:%x)\n", in xen_pcibk_error_resume()
1008 dev->bus->number, dev->devfn); in xen_pcibk_error_resume()
1011 psdev = pcistub_device_find(pci_domain_nr(dev->bus), in xen_pcibk_error_resume()
1012 dev->bus->number, in xen_pcibk_error_resume()
1013 PCI_SLOT(dev->devfn), in xen_pcibk_error_resume()
1014 PCI_FUNC(dev->devfn)); in xen_pcibk_error_resume()
1016 if (!psdev || !psdev->pdev) { in xen_pcibk_error_resume()
1017 dev_err(&dev->dev, "device is not found/assigned\n"); in xen_pcibk_error_resume()
1021 if (!psdev->pdev->sh_info) { in xen_pcibk_error_resume()
1022 dev_err(&dev->dev, "device is not connected or owned" in xen_pcibk_error_resume()
1029 (unsigned long *)&psdev->pdev->sh_info->flags)) { in xen_pcibk_error_resume()
1030 dev_err(&dev->dev, in xen_pcibk_error_resume()
1067 static inline int str_to_slot(const char *buf, int *domain, int *bus, in str_to_slot() argument
1072 switch (sscanf(buf, " %x:%x:%x.%x %n", domain, bus, slot, func, in str_to_slot()
1075 *func = -1; in str_to_slot()
1076 sscanf(buf, " %x:%x:%x.* %n", domain, bus, slot, &parsed); in str_to_slot()
1079 *slot = *func = -1; in str_to_slot()
1080 sscanf(buf, " %x:%x:*.* %n", domain, bus, &parsed); in str_to_slot()
1088 switch (sscanf(buf, " %x:%x.%x %n", bus, slot, func, &parsed)) { in str_to_slot()
1090 *func = -1; in str_to_slot()
1091 sscanf(buf, " %x:%x.* %n", bus, slot, &parsed); in str_to_slot()
1094 *slot = *func = -1; in str_to_slot()
1095 sscanf(buf, " %x:*.* %n", bus, &parsed); in str_to_slot()
1101 return -EINVAL; in str_to_slot()
1104 static inline int str_to_quirk(const char *buf, int *domain, int *bus, int in str_to_quirk() argument
1109 sscanf(buf, " %x:%x:%x.%x-%x:%x:%x %n", domain, bus, slot, func, in str_to_quirk()
1116 sscanf(buf, " %x:%x.%x-%x:%x:%x %n", bus, slot, func, reg, size, in str_to_quirk()
1121 return -EINVAL; in str_to_quirk()
1124 static int pcistub_device_id_add(int domain, int bus, int slot, int func) in pcistub_device_id_add() argument
1131 rc = pcistub_device_id_add(domain, bus, slot, func); in pcistub_device_id_add()
1137 rc = pcistub_device_id_add(domain, bus, slot, func); in pcistub_device_id_add()
1147 || bus < 0 || bus > 0xff in pcistub_device_id_add()
1150 return -EINVAL; in pcistub_device_id_add()
1154 return -ENOMEM; in pcistub_device_id_add()
1157 domain, bus, slot, func); in pcistub_device_id_add()
1159 pcistub_device_id_add_list(pci_dev_id, domain, bus, devfn); in pcistub_device_id_add()
1164 static int pcistub_device_id_remove(int domain, int bus, int slot, int func) in pcistub_device_id_remove() argument
1167 int err = -ENOENT; in pcistub_device_id_remove() local
1173 if (pci_dev_id->domain == domain && pci_dev_id->bus == bus in pcistub_device_id_remove()
1174 && (slot < 0 || PCI_SLOT(pci_dev_id->devfn) == slot) in pcistub_device_id_remove()
1175 && (func < 0 || PCI_FUNC(pci_dev_id->devfn) == func)) { in pcistub_device_id_remove()
1179 list_del(&pci_dev_id->slot_list); in pcistub_device_id_remove()
1182 err = 0; in pcistub_device_id_remove()
1185 domain, bus, slot, func); in pcistub_device_id_remove()
1190 return err; in pcistub_device_id_remove()
1193 static int pcistub_reg_add(int domain, int bus, int slot, int func, in pcistub_reg_add() argument
1197 int err = 0; in pcistub_reg_add() local
1203 return -EINVAL; in pcistub_reg_add()
1205 psdev = pcistub_device_find(domain, bus, slot, func); in pcistub_reg_add()
1207 err = -ENODEV; in pcistub_reg_add()
1210 dev = psdev->dev; in pcistub_reg_add()
1214 err = -ENOMEM; in pcistub_reg_add()
1218 field->offset = reg; in pcistub_reg_add()
1219 field->size = size; in pcistub_reg_add()
1220 field->mask = mask; in pcistub_reg_add()
1221 field->init = NULL; in pcistub_reg_add()
1222 field->reset = NULL; in pcistub_reg_add()
1223 field->release = NULL; in pcistub_reg_add()
1224 field->clean = xen_pcibk_config_field_free; in pcistub_reg_add()
1226 err = xen_pcibk_config_quirks_add_field(dev, field); in pcistub_reg_add()
1227 if (err) in pcistub_reg_add()
1232 return err; in pcistub_reg_add()
1238 int domain, bus, slot, func; in new_slot_store() local
1239 int err; in new_slot_store() local
1241 err = str_to_slot(buf, &domain, &bus, &slot, &func); in new_slot_store()
1242 if (err) in new_slot_store()
1245 err = pcistub_device_id_add(domain, bus, slot, func); in new_slot_store()
1248 if (!err) in new_slot_store()
1249 err = count; in new_slot_store()
1250 return err; in new_slot_store()
1257 int domain, bus, slot, func; in remove_slot_store() local
1258 int err; in remove_slot_store() local
1260 err = str_to_slot(buf, &domain, &bus, &slot, &func); in remove_slot_store()
1261 if (err) in remove_slot_store()
1264 err = pcistub_device_id_remove(domain, bus, slot, func); in remove_slot_store()
1267 if (!err) in remove_slot_store()
1268 err = count; in remove_slot_store()
1269 return err; in remove_slot_store()
1284 count += scnprintf(buf + count, PAGE_SIZE - count, in slots_show()
1286 pci_dev_id->domain, pci_dev_id->bus, in slots_show()
1287 PCI_SLOT(pci_dev_id->devfn), in slots_show()
1288 PCI_FUNC(pci_dev_id->devfn)); in slots_show()
1307 if (!psdev->dev) in irq_handlers_show()
1309 dev_data = pci_get_drvdata(psdev->dev); in irq_handlers_show()
1313 scnprintf(buf + count, PAGE_SIZE - count, in irq_handlers_show()
1315 pci_name(psdev->dev), in irq_handlers_show()
1316 dev_data->isr_on ? "on" : "off", in irq_handlers_show()
1317 dev_data->ack_intr ? "ack" : "not ack", in irq_handlers_show()
1318 dev_data->handled); in irq_handlers_show()
1330 int domain, bus, slot, func; in irq_handler_state_store() local
1331 int err; in irq_handler_state_store() local
1333 err = str_to_slot(buf, &domain, &bus, &slot, &func); in irq_handler_state_store()
1334 if (err) in irq_handler_state_store()
1335 return err; in irq_handler_state_store()
1337 psdev = pcistub_device_find(domain, bus, slot, func); in irq_handler_state_store()
1339 err = -ENOENT; in irq_handler_state_store()
1343 dev_data = pci_get_drvdata(psdev->dev); in irq_handler_state_store()
1345 err = -ENOENT; in irq_handler_state_store()
1349 dev_dbg(&psdev->dev->dev, "%s fake irq handler: %d->%d\n", in irq_handler_state_store()
1350 dev_data->irq_name, dev_data->isr_on, in irq_handler_state_store()
1351 !dev_data->isr_on); in irq_handler_state_store()
1353 dev_data->isr_on = !(dev_data->isr_on); in irq_handler_state_store()
1354 if (dev_data->isr_on) in irq_handler_state_store()
1355 dev_data->ack_intr = 1; in irq_handler_state_store()
1359 if (!err) in irq_handler_state_store()
1360 err = count; in irq_handler_state_store()
1361 return err; in irq_handler_state_store()
1368 int domain, bus, slot, func, reg, size, mask; in quirks_store() local
1369 int err; in quirks_store() local
1371 err = str_to_quirk(buf, &domain, &bus, &slot, &func, &reg, &size, in quirks_store()
1373 if (err) in quirks_store()
1376 err = pcistub_reg_add(domain, bus, slot, func, reg, size, mask); in quirks_store()
1379 if (!err) in quirks_store()
1380 err = count; in quirks_store()
1381 return err; in quirks_store()
1398 count += scnprintf(buf + count, PAGE_SIZE - count, in quirks_show()
1400 quirk->pdev->bus->number, in quirks_show()
1401 PCI_SLOT(quirk->pdev->devfn), in quirks_show()
1402 PCI_FUNC(quirk->pdev->devfn), in quirks_show()
1403 quirk->devid.vendor, quirk->devid.device, in quirks_show()
1404 quirk->devid.subvendor, in quirks_show()
1405 quirk->devid.subdevice); in quirks_show()
1407 dev_data = pci_get_drvdata(quirk->pdev); in quirks_show()
1409 list_for_each_entry(cfg_entry, &dev_data->config_fields, list) { in quirks_show()
1410 field = cfg_entry->field; in quirks_show()
1414 count += scnprintf(buf + count, PAGE_SIZE - count, in quirks_show()
1416 cfg_entry->base_offset + in quirks_show()
1417 field->offset, field->size, in quirks_show()
1418 field->mask); in quirks_show()
1432 int domain, bus, slot, func; in permissive_store() local
1433 int err; in permissive_store() local
1437 err = str_to_slot(buf, &domain, &bus, &slot, &func); in permissive_store()
1438 if (err) in permissive_store()
1441 psdev = pcistub_device_find(domain, bus, slot, func); in permissive_store()
1443 err = -ENODEV; in permissive_store()
1447 dev_data = pci_get_drvdata(psdev->dev); in permissive_store()
1450 err = -ENXIO; in permissive_store()
1453 if (!dev_data->permissive) { in permissive_store()
1454 dev_data->permissive = 1; in permissive_store()
1456 dev_warn(&psdev->dev->dev, "enabling permissive mode " in permissive_store()
1458 dev_warn(&psdev->dev->dev, in permissive_store()
1464 if (!err) in permissive_store()
1465 err = count; in permissive_store()
1466 return err; in permissive_store()
1479 if (!psdev->dev) in permissive_show()
1481 dev_data = pci_get_drvdata(psdev->dev); in permissive_show()
1482 if (!dev_data || !dev_data->permissive) in permissive_show()
1485 scnprintf(buf + count, PAGE_SIZE - count, "%s\n", in permissive_show()
1486 pci_name(psdev->dev)); in permissive_show()
1496 int domain, bus, slot, func; in allow_interrupt_control_store() local
1497 int err; in allow_interrupt_control_store() local
1501 err = str_to_slot(buf, &domain, &bus, &slot, &func); in allow_interrupt_control_store()
1502 if (err) in allow_interrupt_control_store()
1505 psdev = pcistub_device_find(domain, bus, slot, func); in allow_interrupt_control_store()
1507 err = -ENODEV; in allow_interrupt_control_store()
1511 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_store()
1514 err = -ENXIO; in allow_interrupt_control_store()
1517 dev_data->allow_interrupt_control = 1; in allow_interrupt_control_store()
1521 if (!err) in allow_interrupt_control_store()
1522 err = count; in allow_interrupt_control_store()
1523 return err; in allow_interrupt_control_store()
1538 if (!psdev->dev) in allow_interrupt_control_show()
1540 dev_data = pci_get_drvdata(psdev->dev); in allow_interrupt_control_show()
1541 if (!dev_data || !dev_data->allow_interrupt_control) in allow_interrupt_control_show()
1544 scnprintf(buf + count, PAGE_SIZE - count, "%s\n", in allow_interrupt_control_show()
1545 pci_name(psdev->dev)); in allow_interrupt_control_show()
1573 int err = 0; in pcistub_init() local
1574 int domain, bus, slot, func; in pcistub_init() local
1581 err = sscanf(pci_devs_to_hide + pos, in pcistub_init()
1583 &domain, &bus, &slot, &func, &parsed); in pcistub_init()
1584 switch (err) { in pcistub_init()
1586 func = -1; in pcistub_init()
1589 &domain, &bus, &slot, &parsed); in pcistub_init()
1592 slot = func = -1; in pcistub_init()
1595 &domain, &bus, &parsed); in pcistub_init()
1601 err = sscanf(pci_devs_to_hide + pos, in pcistub_init()
1603 &bus, &slot, &func, &parsed); in pcistub_init()
1604 switch (err) { in pcistub_init()
1606 func = -1; in pcistub_init()
1609 &bus, &slot, &parsed); in pcistub_init()
1612 slot = func = -1; in pcistub_init()
1615 &bus, &parsed); in pcistub_init()
1623 err = pcistub_device_id_add(domain, bus, slot, func); in pcistub_init()
1624 if (err) in pcistub_init()
1635 err = pci_register_driver(&xen_pcibk_pci_driver); in pcistub_init()
1636 if (err < 0) in pcistub_init()
1639 err = driver_create_file(&xen_pcibk_pci_driver.driver, in pcistub_init()
1641 if (!err) in pcistub_init()
1642 err = driver_create_file(&xen_pcibk_pci_driver.driver, in pcistub_init()
1644 if (!err) in pcistub_init()
1645 err = driver_create_file(&xen_pcibk_pci_driver.driver, in pcistub_init()
1647 if (!err) in pcistub_init()
1648 err = driver_create_file(&xen_pcibk_pci_driver.driver, in pcistub_init()
1650 if (!err) in pcistub_init()
1651 err = driver_create_file(&xen_pcibk_pci_driver.driver, in pcistub_init()
1653 if (!err) in pcistub_init()
1654 err = driver_create_file(&xen_pcibk_pci_driver.driver, in pcistub_init()
1657 if (!err) in pcistub_init()
1658 err = driver_create_file(&xen_pcibk_pci_driver.driver, in pcistub_init()
1660 if (!err) in pcistub_init()
1661 err = driver_create_file(&xen_pcibk_pci_driver.driver, in pcistub_init()
1663 if (err) in pcistub_init()
1667 return err; in pcistub_init()
1672 return -EINVAL; in pcistub_init()
1695 if (!psdev->pdev && psdev->dev != pdev in find_vfs()
1696 && pci_physfn(psdev->dev) == pdev) { in find_vfs()
1716 if (!pdev->is_physfn) in pci_stub_notifier()
1723 device_release_driver(&psdev->dev->dev); in pci_stub_notifier()
1735 int err; in xen_pcibk_init() local
1738 return -ENODEV; in xen_pcibk_init()
1740 err = xen_pcibk_config_init(); in xen_pcibk_init()
1741 if (err) in xen_pcibk_init()
1742 return err; in xen_pcibk_init()
1745 err = pcistub_init(); in xen_pcibk_init()
1746 if (err < 0) in xen_pcibk_init()
1747 return err; in xen_pcibk_init()
1751 err = xen_pcibk_xenbus_register(); in xen_pcibk_init()
1752 if (err) in xen_pcibk_init()
1763 return err; in xen_pcibk_init()
1782 MODULE_DESCRIPTION("Xen PCI-device stub driver");
1784 MODULE_ALIAS("xen-backend:pci");