summaryrefslogtreecommitdiff
path: root/arch/um
diff options
context:
space:
mode:
authorBenjamin Berg <benjamin.berg@intel.com>2023-02-09 12:00:05 +0300
committerRichard Weinberger <richard@nod.at>2023-02-13 12:14:32 +0300
commit339b84dcd7113dd076419ea2a47128cc53450305 (patch)
tree9988cf56ec14540a8e734e25f6c14e49ab5a1f35 /arch/um
parentabdeb4fa5e1b5b4918034f02236fd886f40c20c1 (diff)
downloadlinux-339b84dcd7113dd076419ea2a47128cc53450305.tar.xz
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: 68f5d3f3b654 ("um: add PCI over virtio emulation driver") Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/virt-pci.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
index 035c97aadb38..7699ca5f35d4 100644
--- a/arch/um/drivers/virt-pci.c
+++ b/arch/um/drivers/virt-pci.c
@@ -711,22 +711,33 @@ static void um_pci_virtio_remove(struct virtio_device *vdev)
return;
}
- /* Stop all virtqueues */
- virtio_reset_device(vdev);
- vdev->config->del_vqs(vdev);
-
device_set_wakeup_enable(&vdev->dev, false);
mutex_lock(&um_pci_mtx);
for (i = 0; i < MAX_DEVICES; i++) {
if (um_pci_devices[i].dev != dev)
continue;
+
um_pci_devices[i].dev = NULL;
irq_free_desc(dev->irq);
+
+ break;
}
mutex_unlock(&um_pci_mtx);
- um_pci_rescan();
+ if (i < MAX_DEVICES) {
+ struct pci_dev *pci_dev;
+
+ pci_dev = pci_get_slot(bridge->bus, i);
+ if (pci_dev)
+ pci_stop_and_remove_bus_device_locked(pci_dev);
+ }
+
+ /* Stop all virtqueues */
+ virtio_reset_device(vdev);
+ dev->cmd_vq = NULL;
+ dev->irq_vq = NULL;
+ vdev->config->del_vqs(vdev);
kfree(dev);
}