Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347910
b: refs/heads/master
c: 2007722
h: refs/heads/master
v: v3
  • Loading branch information
Alex Williamson committed Dec 7, 2012
1 parent 9650f3a commit 263a1c0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3a1f7041ddd59ec3aceb042892f811cc76e05288
refs/heads/master: 2007722a606bf9f195217f7afd2fbee4bc202c42
43 changes: 31 additions & 12 deletions trunk/drivers/vfio/pci/vfio_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)

static void vfio_pci_disable(struct vfio_pci_device *vdev)
{
struct pci_dev *pdev = vdev->pdev;
int bar;

pci_disable_device(vdev->pdev);
pci_disable_device(pdev);

vfio_pci_set_irqs_ioctl(vdev, VFIO_IRQ_SET_DATA_NONE |
VFIO_IRQ_SET_ACTION_TRIGGER,
Expand All @@ -104,22 +105,40 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)

vfio_config_free(vdev);

pci_reset_function(vdev->pdev);

if (pci_load_and_free_saved_state(vdev->pdev,
&vdev->pci_saved_state) == 0)
pci_restore_state(vdev->pdev);
else
pr_info("%s: Couldn't reload %s saved state\n",
__func__, dev_name(&vdev->pdev->dev));

for (bar = PCI_STD_RESOURCES; bar <= PCI_STD_RESOURCE_END; bar++) {
if (!vdev->barmap[bar])
continue;
pci_iounmap(vdev->pdev, vdev->barmap[bar]);
pci_release_selected_regions(vdev->pdev, 1 << bar);
pci_iounmap(pdev, vdev->barmap[bar]);
pci_release_selected_regions(pdev, 1 << bar);
vdev->barmap[bar] = NULL;
}

/*
* If we have saved state, restore it. If we can reset the device,
* even better. Resetting with current state seems better than
* nothing, but saving and restoring current state without reset
* is just busy work.
*/
if (pci_load_and_free_saved_state(pdev, &vdev->pci_saved_state)) {
pr_info("%s: Couldn't reload %s saved state\n",
__func__, dev_name(&pdev->dev));

if (!vdev->reset_works)
return;

pci_save_state(pdev);
}

/*
* Disable INTx and MSI, presumably to avoid spurious interrupts
* during reset. Stolen from pci_reset_function()
*/
pci_write_config_word(pdev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE);

if (vdev->reset_works)
__pci_reset_function(pdev);

pci_restore_state(pdev);
}

static void vfio_pci_release(void *device_data)
Expand Down

0 comments on commit 263a1c0

Please sign in to comment.