Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull last minute virtio bugfixes from Michael Tsirkin:
"Minor bugfixes all over the place"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
virtio_balloon: fix shrinker count
virtio_balloon: fix shrinker scan number of pages
virtio_console: allocate inbufs in add_port() only if it is needed
virtio_ring: fix return code on DMA mapping fails

+28 -24
+13 -15
drivers/char/virtio_console.c
··· 1325 1325 port->cons.ws.ws_col = cols; 1326 1326 } 1327 1327 1328 - static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) 1328 + static int fill_queue(struct virtqueue *vq, spinlock_t *lock) 1329 1329 { 1330 1330 struct port_buffer *buf; 1331 - unsigned int nr_added_bufs; 1331 + int nr_added_bufs; 1332 1332 int ret; 1333 1333 1334 1334 nr_added_bufs = 0; 1335 1335 do { 1336 1336 buf = alloc_buf(vq->vdev, PAGE_SIZE, 0); 1337 1337 if (!buf) 1338 - break; 1338 + return -ENOMEM; 1339 1339 1340 1340 spin_lock_irq(lock); 1341 1341 ret = add_inbuf(vq, buf); 1342 1342 if (ret < 0) { 1343 1343 spin_unlock_irq(lock); 1344 1344 free_buf(buf, true); 1345 - break; 1345 + return ret; 1346 1346 } 1347 1347 nr_added_bufs++; 1348 1348 spin_unlock_irq(lock); ··· 1362 1362 char debugfs_name[16]; 1363 1363 struct port *port; 1364 1364 dev_t devt; 1365 - unsigned int nr_added_bufs; 1366 1365 int err; 1367 1366 1368 1367 port = kmalloc(sizeof(*port), GFP_KERNEL); ··· 1420 1421 spin_lock_init(&port->outvq_lock); 1421 1422 init_waitqueue_head(&port->waitqueue); 1422 1423 1423 - /* Fill the in_vq with buffers so the host can send us data. */ 1424 - nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock); 1425 - if (!nr_added_bufs) { 1424 + /* We can safely ignore ENOSPC because it means 1425 + * the queue already has buffers. Buffers are removed 1426 + * only by virtcons_remove(), not by unplug_port() 1427 + */ 1428 + err = fill_queue(port->in_vq, &port->inbuf_lock); 1429 + if (err < 0 && err != -ENOSPC) { 1426 1430 dev_err(port->dev, "Error allocating inbufs\n"); 1427 - err = -ENOMEM; 1428 1431 goto free_device; 1429 1432 } 1430 1433 ··· 2060 2059 INIT_WORK(&portdev->control_work, &control_work_handler); 2061 2060 2062 2061 if (multiport) { 2063 - unsigned int nr_added_bufs; 2064 - 2065 2062 spin_lock_init(&portdev->c_ivq_lock); 2066 2063 spin_lock_init(&portdev->c_ovq_lock); 2067 2064 2068 - nr_added_bufs = fill_queue(portdev->c_ivq, 2069 - &portdev->c_ivq_lock); 2070 - if (!nr_added_bufs) { 2065 + err = fill_queue(portdev->c_ivq, &portdev->c_ivq_lock); 2066 + if (err < 0) { 2071 2067 dev_err(&vdev->dev, 2072 2068 "Error allocating buffers for control queue\n"); 2073 2069 /* ··· 2075 2077 VIRTIO_CONSOLE_DEVICE_READY, 0); 2076 2078 /* Device was functional: we need full cleanup. */ 2077 2079 virtcons_remove(vdev); 2078 - return -ENOMEM; 2080 + return err; 2079 2081 } 2080 2082 } else { 2081 2083 /*
+13 -7
drivers/virtio/virtio_balloon.c
··· 772 772 return blocks_freed << VIRTIO_BALLOON_FREE_PAGE_ORDER; 773 773 } 774 774 775 + static unsigned long leak_balloon_pages(struct virtio_balloon *vb, 776 + unsigned long pages_to_free) 777 + { 778 + return leak_balloon(vb, pages_to_free * VIRTIO_BALLOON_PAGES_PER_PAGE) / 779 + VIRTIO_BALLOON_PAGES_PER_PAGE; 780 + } 781 + 775 782 static unsigned long shrink_balloon_pages(struct virtio_balloon *vb, 776 783 unsigned long pages_to_free) 777 784 { ··· 789 782 * VIRTIO_BALLOON_ARRAY_PFNS_MAX balloon pages, so we call it 790 783 * multiple times to deflate pages till reaching pages_to_free. 791 784 */ 792 - while (vb->num_pages && pages_to_free) { 793 - pages_freed += leak_balloon(vb, pages_to_free) / 794 - VIRTIO_BALLOON_PAGES_PER_PAGE; 795 - pages_to_free -= pages_freed; 796 - } 785 + while (vb->num_pages && pages_freed < pages_to_free) 786 + pages_freed += leak_balloon_pages(vb, 787 + pages_to_free - pages_freed); 788 + 797 789 update_balloon_size(vb); 798 790 799 791 return pages_freed; ··· 805 799 struct virtio_balloon *vb = container_of(shrinker, 806 800 struct virtio_balloon, shrinker); 807 801 808 - pages_to_free = sc->nr_to_scan * VIRTIO_BALLOON_PAGES_PER_PAGE; 802 + pages_to_free = sc->nr_to_scan; 809 803 810 804 if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) 811 805 pages_freed = shrink_free_pages(vb, pages_to_free); ··· 826 820 unsigned long count; 827 821 828 822 count = vb->num_pages / VIRTIO_BALLOON_PAGES_PER_PAGE; 829 - count += vb->num_free_page_blocks >> VIRTIO_BALLOON_FREE_PAGE_ORDER; 823 + count += vb->num_free_page_blocks << VIRTIO_BALLOON_FREE_PAGE_ORDER; 830 824 831 825 return count; 832 826 }
+2 -2
drivers/virtio/virtio_ring.c
··· 583 583 kfree(desc); 584 584 585 585 END_USE(vq); 586 - return -EIO; 586 + return -ENOMEM; 587 587 } 588 588 589 589 static bool virtqueue_kick_prepare_split(struct virtqueue *_vq) ··· 1085 1085 kfree(desc); 1086 1086 1087 1087 END_USE(vq); 1088 - return -EIO; 1088 + return -ENOMEM; 1089 1089 } 1090 1090 1091 1091 static inline int virtqueue_add_packed(struct virtqueue *_vq,