um: virt-pci: properly remove PCI device from bus
[ Upstream commit339b84dcd7
] 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:68f5d3f3b6
("um: add PCI over virtio emulation driver") Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e38d2adf11
commit
a02a910576
|
@ -626,22 +626,33 @@ static void um_pci_virtio_remove(struct virtio_device *vdev)
|
|||
struct um_pci_device *dev = vdev->priv;
|
||||
int i;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue