Skip to content

Commit 339b84d

Browse files
benzearichardweinberger
authored andcommitted
um: virt-pci: properly remove PCI device from bus
Triggering a bus rescan will not cause the PCI device to be removed. It is required to explicitly stop and remove the device from the bus. Fixes: 68f5d3f ("um: add PCI over virtio emulation driver") Signed-off-by: Benjamin Berg <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent abdeb4f commit 339b84d

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

arch/um/drivers/virt-pci.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,22 +711,33 @@ static void um_pci_virtio_remove(struct virtio_device *vdev)
711711
return;
712712
}
713713

714-
/* Stop all virtqueues */
715-
virtio_reset_device(vdev);
716-
vdev->config->del_vqs(vdev);
717-
718714
device_set_wakeup_enable(&vdev->dev, false);
719715

720716
mutex_lock(&um_pci_mtx);
721717
for (i = 0; i < MAX_DEVICES; i++) {
722718
if (um_pci_devices[i].dev != dev)
723719
continue;
720+
724721
um_pci_devices[i].dev = NULL;
725722
irq_free_desc(dev->irq);
723+
724+
break;
726725
}
727726
mutex_unlock(&um_pci_mtx);
728727

729-
um_pci_rescan();
728+
if (i < MAX_DEVICES) {
729+
struct pci_dev *pci_dev;
730+
731+
pci_dev = pci_get_slot(bridge->bus, i);
732+
if (pci_dev)
733+
pci_stop_and_remove_bus_device_locked(pci_dev);
734+
}
735+
736+
/* Stop all virtqueues */
737+
virtio_reset_device(vdev);
738+
dev->cmd_vq = NULL;
739+
dev->irq_vq = NULL;
740+
vdev->config->del_vqs(vdev);
730741

731742
kfree(dev);
732743
}

0 commit comments

Comments
 (0)