| .. | .. |
|---|
| 6 | 6 | */ |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| 9 | +#define dev_fmt pr_fmt |
|---|
| 9 | 10 | |
|---|
| 10 | 11 | #include <linux/module.h> |
|---|
| 11 | 12 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 303 | 304 | /* And cleanup up our emulated fields. */ |
|---|
| 304 | 305 | xen_pcibk_config_reset_dev(dev); |
|---|
| 305 | 306 | xen_pcibk_config_free_dyn_fields(dev); |
|---|
| 307 | + |
|---|
| 308 | + dev_data->allow_interrupt_control = 0; |
|---|
| 306 | 309 | |
|---|
| 307 | 310 | xen_unregister_device_domain_owner(dev); |
|---|
| 308 | 311 | |
|---|
| .. | .. |
|---|
| 624 | 627 | if (found_psdev->pdev) { |
|---|
| 625 | 628 | int domid = xen_find_device_domain_owner(dev); |
|---|
| 626 | 629 | |
|---|
| 627 | | - pr_warn("****** removing device %s while still in-use by domain %d! ******\n", |
|---|
| 630 | + dev_warn(&dev->dev, "****** removing device %s while still in-use by domain %d! ******\n", |
|---|
| 628 | 631 | pci_name(found_psdev->dev), domid); |
|---|
| 629 | | - pr_warn("****** driver domain may still access this device's i/o resources!\n"); |
|---|
| 630 | | - pr_warn("****** shutdown driver domain before binding device\n"); |
|---|
| 631 | | - pr_warn("****** to other drivers or domains\n"); |
|---|
| 632 | + dev_warn(&dev->dev, "****** driver domain may still access this device's i/o resources!\n"); |
|---|
| 633 | + dev_warn(&dev->dev, "****** shutdown driver domain before binding device\n"); |
|---|
| 634 | + dev_warn(&dev->dev, "****** to other drivers or domains\n"); |
|---|
| 632 | 635 | |
|---|
| 633 | 636 | /* N.B. This ends up calling pcistub_put_pci_dev which ends up |
|---|
| 634 | 637 | * doing the FLR. */ |
|---|
| .. | .. |
|---|
| 709 | 712 | ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, |
|---|
| 710 | 713 | &aer_op->domain, &aer_op->bus, &aer_op->devfn); |
|---|
| 711 | 714 | if (!ret) { |
|---|
| 712 | | - dev_err(&psdev->dev->dev, |
|---|
| 713 | | - DRV_NAME ": failed to get pcifront device\n"); |
|---|
| 715 | + dev_err(&psdev->dev->dev, "failed to get pcifront device\n"); |
|---|
| 714 | 716 | return PCI_ERS_RESULT_NONE; |
|---|
| 715 | 717 | } |
|---|
| 716 | 718 | wmb(); |
|---|
| 717 | 719 | |
|---|
| 718 | | - dev_dbg(&psdev->dev->dev, |
|---|
| 719 | | - DRV_NAME ": aer_op %x dom %x bus %x devfn %x\n", |
|---|
| 720 | + dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n", |
|---|
| 720 | 721 | aer_cmd, aer_op->domain, aer_op->bus, aer_op->devfn); |
|---|
| 721 | 722 | /*local flag to mark there's aer request, xen_pcibk callback will use |
|---|
| 722 | 723 | * this flag to judge whether we need to check pci-front give aer |
|---|
| .. | .. |
|---|
| 784 | 785 | PCI_FUNC(dev->devfn)); |
|---|
| 785 | 786 | |
|---|
| 786 | 787 | if (!psdev || !psdev->pdev) { |
|---|
| 787 | | - dev_err(&dev->dev, |
|---|
| 788 | | - DRV_NAME " device is not found/assigned\n"); |
|---|
| 788 | + dev_err(&dev->dev, "device is not found/assigned\n"); |
|---|
| 789 | 789 | goto end; |
|---|
| 790 | 790 | } |
|---|
| 791 | 791 | |
|---|
| 792 | 792 | if (!psdev->pdev->sh_info) { |
|---|
| 793 | | - dev_err(&dev->dev, DRV_NAME " device is not connected or owned" |
|---|
| 793 | + dev_err(&dev->dev, "device is not connected or owned" |
|---|
| 794 | 794 | " by HVM, kill it\n"); |
|---|
| 795 | 795 | kill_domain_by_device(psdev); |
|---|
| 796 | 796 | goto end; |
|---|
| .. | .. |
|---|
| 842 | 842 | PCI_FUNC(dev->devfn)); |
|---|
| 843 | 843 | |
|---|
| 844 | 844 | if (!psdev || !psdev->pdev) { |
|---|
| 845 | | - dev_err(&dev->dev, |
|---|
| 846 | | - DRV_NAME " device is not found/assigned\n"); |
|---|
| 845 | + dev_err(&dev->dev, "device is not found/assigned\n"); |
|---|
| 847 | 846 | goto end; |
|---|
| 848 | 847 | } |
|---|
| 849 | 848 | |
|---|
| 850 | 849 | if (!psdev->pdev->sh_info) { |
|---|
| 851 | | - dev_err(&dev->dev, DRV_NAME " device is not connected or owned" |
|---|
| 850 | + dev_err(&dev->dev, "device is not connected or owned" |
|---|
| 852 | 851 | " by HVM, kill it\n"); |
|---|
| 853 | 852 | kill_domain_by_device(psdev); |
|---|
| 854 | 853 | goto end; |
|---|
| .. | .. |
|---|
| 900 | 899 | PCI_FUNC(dev->devfn)); |
|---|
| 901 | 900 | |
|---|
| 902 | 901 | if (!psdev || !psdev->pdev) { |
|---|
| 903 | | - dev_err(&dev->dev, |
|---|
| 904 | | - DRV_NAME " device is not found/assigned\n"); |
|---|
| 902 | + dev_err(&dev->dev, "device is not found/assigned\n"); |
|---|
| 905 | 903 | goto end; |
|---|
| 906 | 904 | } |
|---|
| 907 | 905 | |
|---|
| 908 | 906 | if (!psdev->pdev->sh_info) { |
|---|
| 909 | | - dev_err(&dev->dev, DRV_NAME " device is not connected or owned" |
|---|
| 907 | + dev_err(&dev->dev, "device is not connected or owned" |
|---|
| 910 | 908 | " by HVM, kill it\n"); |
|---|
| 911 | 909 | kill_domain_by_device(psdev); |
|---|
| 912 | 910 | goto end; |
|---|
| .. | .. |
|---|
| 954 | 952 | PCI_FUNC(dev->devfn)); |
|---|
| 955 | 953 | |
|---|
| 956 | 954 | if (!psdev || !psdev->pdev) { |
|---|
| 957 | | - dev_err(&dev->dev, |
|---|
| 958 | | - DRV_NAME " device is not found/assigned\n"); |
|---|
| 955 | + dev_err(&dev->dev, "device is not found/assigned\n"); |
|---|
| 959 | 956 | goto end; |
|---|
| 960 | 957 | } |
|---|
| 961 | 958 | |
|---|
| 962 | 959 | if (!psdev->pdev->sh_info) { |
|---|
| 963 | | - dev_err(&dev->dev, DRV_NAME " device is not connected or owned" |
|---|
| 960 | + dev_err(&dev->dev, "device is not connected or owned" |
|---|
| 964 | 961 | " by HVM, kill it\n"); |
|---|
| 965 | 962 | kill_domain_by_device(psdev); |
|---|
| 966 | 963 | goto end; |
|---|
| .. | .. |
|---|
| 1431 | 1428 | } |
|---|
| 1432 | 1429 | static DRIVER_ATTR_RW(permissive); |
|---|
| 1433 | 1430 | |
|---|
| 1431 | +static ssize_t allow_interrupt_control_store(struct device_driver *drv, |
|---|
| 1432 | + const char *buf, size_t count) |
|---|
| 1433 | +{ |
|---|
| 1434 | + int domain, bus, slot, func; |
|---|
| 1435 | + int err; |
|---|
| 1436 | + struct pcistub_device *psdev; |
|---|
| 1437 | + struct xen_pcibk_dev_data *dev_data; |
|---|
| 1438 | + |
|---|
| 1439 | + err = str_to_slot(buf, &domain, &bus, &slot, &func); |
|---|
| 1440 | + if (err) |
|---|
| 1441 | + goto out; |
|---|
| 1442 | + |
|---|
| 1443 | + psdev = pcistub_device_find(domain, bus, slot, func); |
|---|
| 1444 | + if (!psdev) { |
|---|
| 1445 | + err = -ENODEV; |
|---|
| 1446 | + goto out; |
|---|
| 1447 | + } |
|---|
| 1448 | + |
|---|
| 1449 | + dev_data = pci_get_drvdata(psdev->dev); |
|---|
| 1450 | + /* the driver data for a device should never be null at this point */ |
|---|
| 1451 | + if (!dev_data) { |
|---|
| 1452 | + err = -ENXIO; |
|---|
| 1453 | + goto release; |
|---|
| 1454 | + } |
|---|
| 1455 | + dev_data->allow_interrupt_control = 1; |
|---|
| 1456 | +release: |
|---|
| 1457 | + pcistub_device_put(psdev); |
|---|
| 1458 | +out: |
|---|
| 1459 | + if (!err) |
|---|
| 1460 | + err = count; |
|---|
| 1461 | + return err; |
|---|
| 1462 | +} |
|---|
| 1463 | + |
|---|
| 1464 | +static ssize_t allow_interrupt_control_show(struct device_driver *drv, |
|---|
| 1465 | + char *buf) |
|---|
| 1466 | +{ |
|---|
| 1467 | + struct pcistub_device *psdev; |
|---|
| 1468 | + struct xen_pcibk_dev_data *dev_data; |
|---|
| 1469 | + size_t count = 0; |
|---|
| 1470 | + unsigned long flags; |
|---|
| 1471 | + |
|---|
| 1472 | + spin_lock_irqsave(&pcistub_devices_lock, flags); |
|---|
| 1473 | + list_for_each_entry(psdev, &pcistub_devices, dev_list) { |
|---|
| 1474 | + if (count >= PAGE_SIZE) |
|---|
| 1475 | + break; |
|---|
| 1476 | + if (!psdev->dev) |
|---|
| 1477 | + continue; |
|---|
| 1478 | + dev_data = pci_get_drvdata(psdev->dev); |
|---|
| 1479 | + if (!dev_data || !dev_data->allow_interrupt_control) |
|---|
| 1480 | + continue; |
|---|
| 1481 | + count += |
|---|
| 1482 | + scnprintf(buf + count, PAGE_SIZE - count, "%s\n", |
|---|
| 1483 | + pci_name(psdev->dev)); |
|---|
| 1484 | + } |
|---|
| 1485 | + spin_unlock_irqrestore(&pcistub_devices_lock, flags); |
|---|
| 1486 | + return count; |
|---|
| 1487 | +} |
|---|
| 1488 | +static DRIVER_ATTR_RW(allow_interrupt_control); |
|---|
| 1489 | + |
|---|
| 1434 | 1490 | static void pcistub_exit(void) |
|---|
| 1435 | 1491 | { |
|---|
| 1436 | 1492 | driver_remove_file(&xen_pcibk_pci_driver.driver, &driver_attr_new_slot); |
|---|
| .. | .. |
|---|
| 1440 | 1496 | driver_remove_file(&xen_pcibk_pci_driver.driver, &driver_attr_quirks); |
|---|
| 1441 | 1497 | driver_remove_file(&xen_pcibk_pci_driver.driver, |
|---|
| 1442 | 1498 | &driver_attr_permissive); |
|---|
| 1499 | + driver_remove_file(&xen_pcibk_pci_driver.driver, |
|---|
| 1500 | + &driver_attr_allow_interrupt_control); |
|---|
| 1443 | 1501 | driver_remove_file(&xen_pcibk_pci_driver.driver, |
|---|
| 1444 | 1502 | &driver_attr_irq_handlers); |
|---|
| 1445 | 1503 | driver_remove_file(&xen_pcibk_pci_driver.driver, |
|---|
| .. | .. |
|---|
| 1530 | 1588 | if (!err) |
|---|
| 1531 | 1589 | err = driver_create_file(&xen_pcibk_pci_driver.driver, |
|---|
| 1532 | 1590 | &driver_attr_permissive); |
|---|
| 1591 | + if (!err) |
|---|
| 1592 | + err = driver_create_file(&xen_pcibk_pci_driver.driver, |
|---|
| 1593 | + &driver_attr_allow_interrupt_control); |
|---|
| 1533 | 1594 | |
|---|
| 1534 | 1595 | if (!err) |
|---|
| 1535 | 1596 | err = driver_create_file(&xen_pcibk_pci_driver.driver, |
|---|