diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-08 16:05:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-08 16:05:56 -0500 |
commit | b11ecb2785b94e931b445fc0ae3e7447e16b2c49 (patch) | |
tree | fc4f6fe211fe2bf0d27ca98b93e7349a566dd4e4 | |
parent | 1c169383c8b6375f37c17ebd8f9e350d820f2ad3 (diff) | |
parent | 99975cc6ada0d5f2675e83abecae05aba5f437d2 (diff) |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
pull virtio/vhost fixes from Michael Tsirkin:
"This fixes a couple of bugs triggered by hot-unplug of virtio devices,
as well as a regression in vhost-net"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
vhost/net: length miscalculation
virtio_pci: document why we defer kfree
virtio_pci: defer kfree until release callback
virtio_pci: device-specific release callback
virtio: make del_vqs idempotent
-rw-r--r-- | drivers/vhost/net.c | 2 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_common.c | 10 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_common.h | 1 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_legacy.c | 12 |
4 files changed, 13 insertions, 12 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 14419a8ccbb6..d415d69dc237 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c | |||
@@ -538,7 +538,7 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, | |||
538 | ++headcount; | 538 | ++headcount; |
539 | seg += in; | 539 | seg += in; |
540 | } | 540 | } |
541 | heads[headcount - 1].len = cpu_to_vhost32(vq, len - datalen); | 541 | heads[headcount - 1].len = cpu_to_vhost32(vq, len + datalen); |
542 | *iovcount = seg; | 542 | *iovcount = seg; |
543 | if (unlikely(log)) | 543 | if (unlikely(log)) |
544 | *log_num = nlogs; | 544 | *log_num = nlogs; |
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 2ef9529809d8..9756f21b809e 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c | |||
@@ -282,6 +282,7 @@ void vp_del_vqs(struct virtio_device *vdev) | |||
282 | 282 | ||
283 | vp_free_vectors(vdev); | 283 | vp_free_vectors(vdev); |
284 | kfree(vp_dev->vqs); | 284 | kfree(vp_dev->vqs); |
285 | vp_dev->vqs = NULL; | ||
285 | } | 286 | } |
286 | 287 | ||
287 | static int vp_try_to_find_vqs(struct virtio_device *vdev, unsigned nvqs, | 288 | static int vp_try_to_find_vqs(struct virtio_device *vdev, unsigned nvqs, |
@@ -421,15 +422,6 @@ int vp_set_vq_affinity(struct virtqueue *vq, int cpu) | |||
421 | return 0; | 422 | return 0; |
422 | } | 423 | } |
423 | 424 | ||
424 | void virtio_pci_release_dev(struct device *_d) | ||
425 | { | ||
426 | /* | ||
427 | * No need for a release method as we allocate/free | ||
428 | * all devices together with the pci devices. | ||
429 | * Provide an empty one to avoid getting a warning from core. | ||
430 | */ | ||
431 | } | ||
432 | |||
433 | #ifdef CONFIG_PM_SLEEP | 425 | #ifdef CONFIG_PM_SLEEP |
434 | static int virtio_pci_freeze(struct device *dev) | 426 | static int virtio_pci_freeze(struct device *dev) |
435 | { | 427 | { |
diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h index adddb647b21d..5a497289b7e9 100644 --- a/drivers/virtio/virtio_pci_common.h +++ b/drivers/virtio/virtio_pci_common.h | |||
@@ -126,7 +126,6 @@ const char *vp_bus_name(struct virtio_device *vdev); | |||
126 | * - ignore the affinity request if we're using INTX | 126 | * - ignore the affinity request if we're using INTX |
127 | */ | 127 | */ |
128 | int vp_set_vq_affinity(struct virtqueue *vq, int cpu); | 128 | int vp_set_vq_affinity(struct virtqueue *vq, int cpu); |
129 | void virtio_pci_release_dev(struct device *); | ||
130 | 129 | ||
131 | int virtio_pci_legacy_probe(struct pci_dev *pci_dev, | 130 | int virtio_pci_legacy_probe(struct pci_dev *pci_dev, |
132 | const struct pci_device_id *id); | 131 | const struct pci_device_id *id); |
diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c index 6c76f0f5658c..a5486e65e04b 100644 --- a/drivers/virtio/virtio_pci_legacy.c +++ b/drivers/virtio/virtio_pci_legacy.c | |||
@@ -211,6 +211,17 @@ static const struct virtio_config_ops virtio_pci_config_ops = { | |||
211 | .set_vq_affinity = vp_set_vq_affinity, | 211 | .set_vq_affinity = vp_set_vq_affinity, |
212 | }; | 212 | }; |
213 | 213 | ||
214 | static void virtio_pci_release_dev(struct device *_d) | ||
215 | { | ||
216 | struct virtio_device *vdev = dev_to_virtio(_d); | ||
217 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | ||
218 | |||
219 | /* As struct device is a kobject, it's not safe to | ||
220 | * free the memory (including the reference counter itself) | ||
221 | * until it's release callback. */ | ||
222 | kfree(vp_dev); | ||
223 | } | ||
224 | |||
214 | /* the PCI probing function */ | 225 | /* the PCI probing function */ |
215 | int virtio_pci_legacy_probe(struct pci_dev *pci_dev, | 226 | int virtio_pci_legacy_probe(struct pci_dev *pci_dev, |
216 | const struct pci_device_id *id) | 227 | const struct pci_device_id *id) |
@@ -302,5 +313,4 @@ void virtio_pci_legacy_remove(struct pci_dev *pci_dev) | |||
302 | pci_iounmap(pci_dev, vp_dev->ioaddr); | 313 | pci_iounmap(pci_dev, vp_dev->ioaddr); |
303 | pci_release_regions(pci_dev); | 314 | pci_release_regions(pci_dev); |
304 | pci_disable_device(pci_dev); | 315 | pci_disable_device(pci_dev); |
305 | kfree(vp_dev); | ||
306 | } | 316 | } |