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 virtio updates from Michael Tsirkin:
"A small number of improvements all over the place"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
virtio_vdpa: remove redundant check on desc
virtio_fs: store actual queue index in mq_map
virtio_fs: add informative log for new tag discovery
virtio: Make vring_new_virtqueue support packed vring
virtio_pmem: Add freeze/restore callbacks
vdpa/mlx5: Fix suboptimal range on iotlb iteration

+152 -117
+24
drivers/nvdimm/virtio_pmem.c
··· 143 143 virtio_reset_device(vdev); 144 144 } 145 145 146 + static int virtio_pmem_freeze(struct virtio_device *vdev) 147 + { 148 + vdev->config->del_vqs(vdev); 149 + virtio_reset_device(vdev); 150 + 151 + return 0; 152 + } 153 + 154 + static int virtio_pmem_restore(struct virtio_device *vdev) 155 + { 156 + int ret; 157 + 158 + ret = init_vq(vdev->priv); 159 + if (ret) { 160 + dev_err(&vdev->dev, "failed to initialize virtio pmem's vq\n"); 161 + return ret; 162 + } 163 + virtio_device_ready(vdev); 164 + 165 + return 0; 166 + } 167 + 146 168 static unsigned int features[] = { 147 169 VIRTIO_PMEM_F_SHMEM_REGION, 148 170 }; ··· 177 155 .validate = virtio_pmem_validate, 178 156 .probe = virtio_pmem_probe, 179 157 .remove = virtio_pmem_remove, 158 + .freeze = virtio_pmem_freeze, 159 + .restore = virtio_pmem_restore, 180 160 }; 181 161 182 162 module_virtio_driver(virtio_pmem_driver);
+1 -3
drivers/vdpa/mlx5/core/mr.c
··· 368 368 unsigned long lgcd = 0; 369 369 int log_entity_size; 370 370 unsigned long size; 371 - u64 start = 0; 372 371 int err; 373 372 struct page *pg; 374 373 unsigned int nsg; ··· 378 379 struct device *dma = mvdev->vdev.dma_dev; 379 380 380 381 for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); 381 - map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) { 382 + map; map = vhost_iotlb_itree_next(map, mr->start, mr->end - 1)) { 382 383 size = maplen(map, mr); 383 384 lgcd = gcd(lgcd, size); 384 - start += size; 385 385 } 386 386 log_entity_size = ilog2(lgcd); 387 387
+119 -106
drivers/virtio/virtio_ring.c
··· 223 223 #endif 224 224 }; 225 225 226 - static struct virtqueue *__vring_new_virtqueue(unsigned int index, 227 - struct vring_virtqueue_split *vring_split, 228 - struct virtio_device *vdev, 229 - bool weak_barriers, 230 - bool context, 231 - bool (*notify)(struct virtqueue *), 232 - void (*callback)(struct virtqueue *), 233 - const char *name, 234 - struct device *dma_dev); 235 226 static struct vring_desc_extra *vring_alloc_desc_extra(unsigned int num); 236 227 static void vring_free(struct virtqueue *_vq); 237 228 ··· 1126 1135 return 0; 1127 1136 } 1128 1137 1138 + static struct virtqueue *__vring_new_virtqueue_split(unsigned int index, 1139 + struct vring_virtqueue_split *vring_split, 1140 + struct virtio_device *vdev, 1141 + bool weak_barriers, 1142 + bool context, 1143 + bool (*notify)(struct virtqueue *), 1144 + void (*callback)(struct virtqueue *), 1145 + const char *name, 1146 + struct device *dma_dev) 1147 + { 1148 + struct vring_virtqueue *vq; 1149 + int err; 1150 + 1151 + vq = kmalloc(sizeof(*vq), GFP_KERNEL); 1152 + if (!vq) 1153 + return NULL; 1154 + 1155 + vq->packed_ring = false; 1156 + vq->vq.callback = callback; 1157 + vq->vq.vdev = vdev; 1158 + vq->vq.name = name; 1159 + vq->vq.index = index; 1160 + vq->vq.reset = false; 1161 + vq->we_own_ring = false; 1162 + vq->notify = notify; 1163 + vq->weak_barriers = weak_barriers; 1164 + #ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION 1165 + vq->broken = true; 1166 + #else 1167 + vq->broken = false; 1168 + #endif 1169 + vq->dma_dev = dma_dev; 1170 + vq->use_dma_api = vring_use_dma_api(vdev); 1171 + 1172 + vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC) && 1173 + !context; 1174 + vq->event = virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX); 1175 + 1176 + if (virtio_has_feature(vdev, VIRTIO_F_ORDER_PLATFORM)) 1177 + vq->weak_barriers = false; 1178 + 1179 + err = vring_alloc_state_extra_split(vring_split); 1180 + if (err) { 1181 + kfree(vq); 1182 + return NULL; 1183 + } 1184 + 1185 + virtqueue_vring_init_split(vring_split, vq); 1186 + 1187 + virtqueue_init(vq, vring_split->vring.num); 1188 + virtqueue_vring_attach_split(vq, vring_split); 1189 + 1190 + spin_lock(&vdev->vqs_list_lock); 1191 + list_add_tail(&vq->vq.list, &vdev->vqs); 1192 + spin_unlock(&vdev->vqs_list_lock); 1193 + return &vq->vq; 1194 + } 1195 + 1129 1196 static struct virtqueue *vring_create_virtqueue_split( 1130 1197 unsigned int index, 1131 1198 unsigned int num, ··· 1206 1157 if (err) 1207 1158 return NULL; 1208 1159 1209 - vq = __vring_new_virtqueue(index, &vring_split, vdev, weak_barriers, 1160 + vq = __vring_new_virtqueue_split(index, &vring_split, vdev, weak_barriers, 1210 1161 context, notify, callback, name, dma_dev); 1211 1162 if (!vq) { 1212 1163 vring_free_split(&vring_split, vdev, dma_dev); ··· 2104 2055 virtqueue_vring_init_packed(&vq->packed, !!vq->vq.callback); 2105 2056 } 2106 2057 2107 - static struct virtqueue *vring_create_virtqueue_packed( 2108 - unsigned int index, 2109 - unsigned int num, 2110 - unsigned int vring_align, 2111 - struct virtio_device *vdev, 2112 - bool weak_barriers, 2113 - bool may_reduce_num, 2114 - bool context, 2115 - bool (*notify)(struct virtqueue *), 2116 - void (*callback)(struct virtqueue *), 2117 - const char *name, 2118 - struct device *dma_dev) 2058 + static struct virtqueue *__vring_new_virtqueue_packed(unsigned int index, 2059 + struct vring_virtqueue_packed *vring_packed, 2060 + struct virtio_device *vdev, 2061 + bool weak_barriers, 2062 + bool context, 2063 + bool (*notify)(struct virtqueue *), 2064 + void (*callback)(struct virtqueue *), 2065 + const char *name, 2066 + struct device *dma_dev) 2119 2067 { 2120 - struct vring_virtqueue_packed vring_packed = {}; 2121 2068 struct vring_virtqueue *vq; 2122 2069 int err; 2123 2070 2124 - if (vring_alloc_queue_packed(&vring_packed, vdev, num, dma_dev)) 2125 - goto err_ring; 2126 - 2127 2071 vq = kmalloc(sizeof(*vq), GFP_KERNEL); 2128 2072 if (!vq) 2129 - goto err_vq; 2073 + return NULL; 2130 2074 2131 2075 vq->vq.callback = callback; 2132 2076 vq->vq.vdev = vdev; 2133 2077 vq->vq.name = name; 2134 2078 vq->vq.index = index; 2135 2079 vq->vq.reset = false; 2136 - vq->we_own_ring = true; 2080 + vq->we_own_ring = false; 2137 2081 vq->notify = notify; 2138 2082 vq->weak_barriers = weak_barriers; 2139 2083 #ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION ··· 2145 2103 if (virtio_has_feature(vdev, VIRTIO_F_ORDER_PLATFORM)) 2146 2104 vq->weak_barriers = false; 2147 2105 2148 - err = vring_alloc_state_extra_packed(&vring_packed); 2149 - if (err) 2150 - goto err_state_extra; 2106 + err = vring_alloc_state_extra_packed(vring_packed); 2107 + if (err) { 2108 + kfree(vq); 2109 + return NULL; 2110 + } 2151 2111 2152 - virtqueue_vring_init_packed(&vring_packed, !!callback); 2112 + virtqueue_vring_init_packed(vring_packed, !!callback); 2153 2113 2154 - virtqueue_init(vq, num); 2155 - virtqueue_vring_attach_packed(vq, &vring_packed); 2114 + virtqueue_init(vq, vring_packed->vring.num); 2115 + virtqueue_vring_attach_packed(vq, vring_packed); 2156 2116 2157 2117 spin_lock(&vdev->vqs_list_lock); 2158 2118 list_add_tail(&vq->vq.list, &vdev->vqs); 2159 2119 spin_unlock(&vdev->vqs_list_lock); 2160 2120 return &vq->vq; 2121 + } 2161 2122 2162 - err_state_extra: 2163 - kfree(vq); 2164 - err_vq: 2165 - vring_free_packed(&vring_packed, vdev, dma_dev); 2166 - err_ring: 2167 - return NULL; 2123 + static struct virtqueue *vring_create_virtqueue_packed( 2124 + unsigned int index, 2125 + unsigned int num, 2126 + unsigned int vring_align, 2127 + struct virtio_device *vdev, 2128 + bool weak_barriers, 2129 + bool may_reduce_num, 2130 + bool context, 2131 + bool (*notify)(struct virtqueue *), 2132 + void (*callback)(struct virtqueue *), 2133 + const char *name, 2134 + struct device *dma_dev) 2135 + { 2136 + struct vring_virtqueue_packed vring_packed = {}; 2137 + struct virtqueue *vq; 2138 + 2139 + if (vring_alloc_queue_packed(&vring_packed, vdev, num, dma_dev)) 2140 + return NULL; 2141 + 2142 + vq = __vring_new_virtqueue_packed(index, &vring_packed, vdev, weak_barriers, 2143 + context, notify, callback, name, dma_dev); 2144 + if (!vq) { 2145 + vring_free_packed(&vring_packed, vdev, dma_dev); 2146 + return NULL; 2147 + } 2148 + 2149 + to_vvq(vq)->we_own_ring = true; 2150 + 2151 + return vq; 2168 2152 } 2169 2153 2170 2154 static int virtqueue_resize_packed(struct virtqueue *_vq, u32 num) ··· 2718 2650 } 2719 2651 EXPORT_SYMBOL_GPL(vring_interrupt); 2720 2652 2721 - /* Only available for split ring */ 2722 - static struct virtqueue *__vring_new_virtqueue(unsigned int index, 2723 - struct vring_virtqueue_split *vring_split, 2724 - struct virtio_device *vdev, 2725 - bool weak_barriers, 2726 - bool context, 2727 - bool (*notify)(struct virtqueue *), 2728 - void (*callback)(struct virtqueue *), 2729 - const char *name, 2730 - struct device *dma_dev) 2731 - { 2732 - struct vring_virtqueue *vq; 2733 - int err; 2734 - 2735 - if (virtio_has_feature(vdev, VIRTIO_F_RING_PACKED)) 2736 - return NULL; 2737 - 2738 - vq = kmalloc(sizeof(*vq), GFP_KERNEL); 2739 - if (!vq) 2740 - return NULL; 2741 - 2742 - vq->packed_ring = false; 2743 - vq->vq.callback = callback; 2744 - vq->vq.vdev = vdev; 2745 - vq->vq.name = name; 2746 - vq->vq.index = index; 2747 - vq->vq.reset = false; 2748 - vq->we_own_ring = false; 2749 - vq->notify = notify; 2750 - vq->weak_barriers = weak_barriers; 2751 - #ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION 2752 - vq->broken = true; 2753 - #else 2754 - vq->broken = false; 2755 - #endif 2756 - vq->dma_dev = dma_dev; 2757 - vq->use_dma_api = vring_use_dma_api(vdev); 2758 - 2759 - vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC) && 2760 - !context; 2761 - vq->event = virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX); 2762 - 2763 - if (virtio_has_feature(vdev, VIRTIO_F_ORDER_PLATFORM)) 2764 - vq->weak_barriers = false; 2765 - 2766 - err = vring_alloc_state_extra_split(vring_split); 2767 - if (err) { 2768 - kfree(vq); 2769 - return NULL; 2770 - } 2771 - 2772 - virtqueue_vring_init_split(vring_split, vq); 2773 - 2774 - virtqueue_init(vq, vring_split->vring.num); 2775 - virtqueue_vring_attach_split(vq, vring_split); 2776 - 2777 - spin_lock(&vdev->vqs_list_lock); 2778 - list_add_tail(&vq->vq.list, &vdev->vqs); 2779 - spin_unlock(&vdev->vqs_list_lock); 2780 - return &vq->vq; 2781 - } 2782 - 2783 2653 struct virtqueue *vring_create_virtqueue( 2784 2654 unsigned int index, 2785 2655 unsigned int num, ··· 2852 2846 } 2853 2847 EXPORT_SYMBOL_GPL(virtqueue_reset); 2854 2848 2855 - /* Only available for split ring */ 2856 2849 struct virtqueue *vring_new_virtqueue(unsigned int index, 2857 2850 unsigned int num, 2858 2851 unsigned int vring_align, ··· 2865 2860 { 2866 2861 struct vring_virtqueue_split vring_split = {}; 2867 2862 2868 - if (virtio_has_feature(vdev, VIRTIO_F_RING_PACKED)) 2869 - return NULL; 2863 + if (virtio_has_feature(vdev, VIRTIO_F_RING_PACKED)) { 2864 + struct vring_virtqueue_packed vring_packed = {}; 2865 + 2866 + vring_packed.vring.num = num; 2867 + vring_packed.vring.desc = pages; 2868 + return __vring_new_virtqueue_packed(index, &vring_packed, 2869 + vdev, weak_barriers, 2870 + context, notify, callback, 2871 + name, vdev->dev.parent); 2872 + } 2870 2873 2871 2874 vring_init(&vring_split.vring, num, pages, vring_align); 2872 - return __vring_new_virtqueue(index, &vring_split, vdev, weak_barriers, 2875 + return __vring_new_virtqueue_split(index, &vring_split, vdev, weak_barriers, 2873 2876 context, notify, callback, name, 2874 2877 vdev->dev.parent); 2875 2878 }
+1 -2
drivers/virtio/virtio_vdpa.c
··· 364 364 struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vdev); 365 365 struct vdpa_device *vdpa = vd_get_vdpa(vdev); 366 366 const struct vdpa_config_ops *ops = vdpa->config; 367 - struct irq_affinity default_affd = { 0 }; 368 367 struct cpumask *masks; 369 368 struct vdpa_callback cb; 370 369 bool has_affinity = desc && ops->set_vq_affinity; 371 370 int i, err, queue_idx = 0; 372 371 373 372 if (has_affinity) { 374 - masks = create_affinity_masks(nvqs, desc ? desc : &default_affd); 373 + masks = create_affinity_masks(nvqs, desc); 375 374 if (!masks) 376 375 return -ENOMEM; 377 376 }
+7 -6
fs/fuse/virtio_fs.c
··· 243 243 244 244 qid = fsvq->vq->index; 245 245 for (cpu = 0; cpu < nr_cpu_ids; cpu++) { 246 - if (qid < VQ_REQUEST || (fs->mq_map[cpu] == qid - VQ_REQUEST)) { 246 + if (qid < VQ_REQUEST || (fs->mq_map[cpu] == qid)) { 247 247 if (first) 248 248 ret = snprintf(buf + pos, size - pos, "%u", cpu); 249 249 else ··· 522 522 return -EINVAL; 523 523 } 524 524 525 + dev_info(&vdev->dev, "discovered new tag: %s\n", fs->tag); 525 526 return 0; 526 527 } 527 528 ··· 876 875 goto fallback; 877 876 878 877 for_each_cpu(cpu, mask) 879 - fs->mq_map[cpu] = q; 878 + fs->mq_map[cpu] = q + VQ_REQUEST; 880 879 } 881 880 882 881 return; 883 882 fallback: 884 883 /* Attempt to map evenly in groups over the CPUs */ 885 884 masks = group_cpus_evenly(fs->num_request_queues); 886 - /* If even this fails we default to all CPUs use queue zero */ 885 + /* If even this fails we default to all CPUs use first request queue */ 887 886 if (!masks) { 888 887 for_each_possible_cpu(cpu) 889 - fs->mq_map[cpu] = 0; 888 + fs->mq_map[cpu] = VQ_REQUEST; 890 889 return; 891 890 } 892 891 893 892 for (q = 0; q < fs->num_request_queues; q++) { 894 893 for_each_cpu(cpu, &masks[q]) 895 - fs->mq_map[cpu] = q; 894 + fs->mq_map[cpu] = q + VQ_REQUEST; 896 895 } 897 896 kfree(masks); 898 897 } ··· 1488 1487 clear_bit(FR_PENDING, &req->flags); 1489 1488 1490 1489 fs = fiq->priv; 1491 - queue_id = VQ_REQUEST + fs->mq_map[raw_smp_processor_id()]; 1490 + queue_id = fs->mq_map[raw_smp_processor_id()]; 1492 1491 1493 1492 pr_debug("%s: opcode %u unique %#llx nodeid %#llx in.len %u out.len %u queue_id %u\n", 1494 1493 __func__, req->in.h.opcode, req->in.h.unique,