Takuma Umeya
2011-Apr-05 04:49 UTC
[PATCH] virtio: decrement dev_index when device is unregistered
When virtio device is removed, dev_index does not get decremented. The next device hotplug event results in consuming the next pci to the one that is suppose to be available. Signed-off-by: Takuma Umeya <tumeya at redhat.com> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index efb35aa..67fe71d 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -216,6 +216,7 @@ EXPORT_SYMBOL_GPL(register_virtio_device); void unregister_virtio_device(struct virtio_device *dev) { device_unregister(&dev->dev); + dev_index--; } EXPORT_SYMBOL_GPL(unregister_virtio_device); -- Umeya, Takuma Technical Account Manager Red Hat GSS APAC +81.3.5798.8584 (direct) tumeya at redhat.com
Stefan Hajnoczi
2011-Apr-05 06:21 UTC
[PATCH] virtio: decrement dev_index when device is unregistered
On Tue, Apr 5, 2011 at 5:49 AM, Takuma Umeya <tumeya at redhat.com> wrote:> When virtio device is removed, dev_index does not get decremented. > The next device hotplug event results in consuming the next pci to > the one that is suppose to be available. > > Signed-off-by: Takuma Umeya <tumeya at redhat.com> > > diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c > index efb35aa..67fe71d 100644 > --- a/drivers/virtio/virtio.c > +++ b/drivers/virtio/virtio.c > @@ -216,6 +216,7 @@ EXPORT_SYMBOL_GPL(register_virtio_device); > ?void unregister_virtio_device(struct virtio_device *dev) > ?{ > ? ? ? ?device_unregister(&dev->dev); > + ? ? ? dev_index--;I don't think there is any guarantee that virtio devices are added/removed in first-in-last-out order. That means I could add a virtio-net device (index 0) followed by a virtio-blk device (index 1). Now I remove the virtio-net device (index 0) which causes me to decrement dev_index and hand index 1 out again to the next device. This leaves us with virtio-blk (index 1) and the new device with index 1, which is not unique. Perhaps I missed a constraint which prevents this from occurring? Stefan
Seemingly Similar Threads
- [PATCH] virtio: decrement dev_index when device is unregistered
- [PATCH] virtio_blk: decrement index when blockdevice is removed
- [PATCH] virtio_blk: decrement index when blockdevice is removed
- [PATCH 2/2] virtio: Use ida to allocate virtio index
- [PATCH 2/2] virtio: Use ida to allocate virtio index