Revision 5834a83f hw/vfio_pci.c

b/hw/vfio_pci.c
1891 1891
{
1892 1892
    PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);
1893 1893
    VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
1894
    uint16_t cmd;
1894 1895

  
1895
    if (!vdev->reset_works) {
1896
        return;
1897
    }
1896
    DPRINTF("%s(%04x:%02x:%02x.%x)\n", __func__, vdev->host.domain,
1897
            vdev->host.bus, vdev->host.slot, vdev->host.function);
1898

  
1899
    vfio_disable_interrupts(vdev);
1898 1900

  
1899
    if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) {
1900
        error_report("vfio: Error unable to reset physical device "
1901
                     "(%04x:%02x:%02x.%x): %m\n", vdev->host.domain,
1902
                     vdev->host.bus, vdev->host.slot, vdev->host.function);
1901
    /*
1902
     * Stop any ongoing DMA by disconecting I/O, MMIO, and bus master.
1903
     * Also put INTx Disable in known state.
1904
     */
1905
    cmd = vfio_pci_read_config(pdev, PCI_COMMAND, 2);
1906
    cmd &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
1907
             PCI_COMMAND_INTX_DISABLE);
1908
    vfio_pci_write_config(pdev, PCI_COMMAND, cmd, 2);
1909

  
1910
    if (vdev->reset_works) {
1911
        if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) {
1912
            error_report("vfio: Error unable to reset physical device "
1913
                         "(%04x:%02x:%02x.%x): %m\n", vdev->host.domain,
1914
                         vdev->host.bus, vdev->host.slot, vdev->host.function);
1915
        }
1903 1916
    }
1917

  
1918
    vfio_enable_intx(vdev);
1904 1919
}
1905 1920

  
1906 1921
static Property vfio_pci_dev_properties[] = {

Also available in: Unified diff