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

virtio: find_vqs() add arg sizes

find_vqs() adds a new parameter sizes to specify the size of each vq
vring.

NULL as sizes means that all queues in find_vqs() use the maximum size.
A value in the array is 0, which means that the corresponding queue uses
the maximum size.

In the split scenario, the meaning of size is the largest size, because
it may be limited by memory, the virtio core will try a smaller size.
And the size is power of 2.

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20220801063902.129329-34-xuanzhuo@linux.alibaba.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Xuan Zhuo and committed by
Michael S. Tsirkin
a10fba03 04ca0b0b

+22 -10
+1 -1
arch/um/drivers/virtio_uml.c
··· 1011 1011 1012 1012 static int vu_find_vqs(struct virtio_device *vdev, unsigned nvqs, 1013 1013 struct virtqueue *vqs[], vq_callback_t *callbacks[], 1014 - const char * const names[], const bool *ctx, 1014 + const char * const names[], u32 sizes[], const bool *ctx, 1015 1015 struct irq_affinity *desc) 1016 1016 { 1017 1017 struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev);
+1
drivers/platform/mellanox/mlxbf-tmfifo.c
··· 928 928 struct virtqueue *vqs[], 929 929 vq_callback_t *callbacks[], 930 930 const char * const names[], 931 + u32 sizes[], 931 932 const bool *ctx, 932 933 struct irq_affinity *desc) 933 934 {
+1
drivers/remoteproc/remoteproc_virtio.c
··· 158 158 struct virtqueue *vqs[], 159 159 vq_callback_t *callbacks[], 160 160 const char * const names[], 161 + u32 sizes[], 161 162 const bool * ctx, 162 163 struct irq_affinity *desc) 163 164 {
+1
drivers/s390/virtio/virtio_ccw.c
··· 635 635 struct virtqueue *vqs[], 636 636 vq_callback_t *callbacks[], 637 637 const char * const names[], 638 + u32 sizes[], 638 639 const bool *ctx, 639 640 struct irq_affinity *desc) 640 641 {
+1
drivers/virtio/virtio_mmio.c
··· 474 474 struct virtqueue *vqs[], 475 475 vq_callback_t *callbacks[], 476 476 const char * const names[], 477 + u32 sizes[], 477 478 const bool *ctx, 478 479 struct irq_affinity *desc) 479 480 {
+1 -1
drivers/virtio/virtio_pci_common.c
··· 396 396 /* the config->find_vqs() implementation */ 397 397 int vp_find_vqs(struct virtio_device *vdev, unsigned int nvqs, 398 398 struct virtqueue *vqs[], vq_callback_t *callbacks[], 399 - const char * const names[], const bool *ctx, 399 + const char * const names[], u32 sizes[], const bool *ctx, 400 400 struct irq_affinity *desc) 401 401 { 402 402 int err;
+1 -1
drivers/virtio/virtio_pci_common.h
··· 110 110 /* the config->find_vqs() implementation */ 111 111 int vp_find_vqs(struct virtio_device *vdev, unsigned int nvqs, 112 112 struct virtqueue *vqs[], vq_callback_t *callbacks[], 113 - const char * const names[], const bool *ctx, 113 + const char * const names[], u32 sizes[], const bool *ctx, 114 114 struct irq_affinity *desc); 115 115 const char *vp_bus_name(struct virtio_device *vdev); 116 116
+5 -2
drivers/virtio/virtio_pci_modern.c
··· 347 347 static int vp_modern_find_vqs(struct virtio_device *vdev, unsigned int nvqs, 348 348 struct virtqueue *vqs[], 349 349 vq_callback_t *callbacks[], 350 - const char * const names[], const bool *ctx, 350 + const char * const names[], 351 + u32 sizes[], 352 + const bool *ctx, 351 353 struct irq_affinity *desc) 352 354 { 353 355 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 354 356 struct virtqueue *vq; 355 - int rc = vp_find_vqs(vdev, nvqs, vqs, callbacks, names, ctx, desc); 357 + int rc = vp_find_vqs(vdev, nvqs, vqs, callbacks, names, sizes, ctx, 358 + desc); 356 359 357 360 if (rc) 358 361 return rc;
+1
drivers/virtio/virtio_vdpa.c
··· 269 269 struct virtqueue *vqs[], 270 270 vq_callback_t *callbacks[], 271 271 const char * const names[], 272 + u32 sizes[], 272 273 const bool *ctx, 273 274 struct irq_affinity *desc) 274 275 {
+9 -5
include/linux/virtio_config.h
··· 55 55 * include a NULL entry for vqs that do not need a callback 56 56 * names: array of virtqueue names (mainly for debugging) 57 57 * include a NULL entry for vqs unused by driver 58 + * sizes: array of virtqueue sizes 58 59 * Returns 0 on success or error status 59 60 * @del_vqs: free virtqueues found by find_vqs(). 60 61 * @synchronize_cbs: synchronize with the virtqueue callbacks (optional) ··· 104 103 void (*reset)(struct virtio_device *vdev); 105 104 int (*find_vqs)(struct virtio_device *, unsigned nvqs, 106 105 struct virtqueue *vqs[], vq_callback_t *callbacks[], 107 - const char * const names[], const bool *ctx, 106 + const char * const names[], 107 + u32 sizes[], 108 + const bool *ctx, 108 109 struct irq_affinity *desc); 109 110 void (*del_vqs)(struct virtio_device *); 110 111 void (*synchronize_cbs)(struct virtio_device *); ··· 215 212 const char *names[] = { n }; 216 213 struct virtqueue *vq; 217 214 int err = vdev->config->find_vqs(vdev, 1, &vq, callbacks, names, NULL, 218 - NULL); 215 + NULL, NULL); 219 216 if (err < 0) 220 217 return ERR_PTR(err); 221 218 return vq; ··· 227 224 const char * const names[], 228 225 struct irq_affinity *desc) 229 226 { 230 - return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, NULL, desc); 227 + return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, NULL, 228 + NULL, desc); 231 229 } 232 230 233 231 static inline ··· 237 233 const char * const names[], const bool *ctx, 238 234 struct irq_affinity *desc) 239 235 { 240 - return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, ctx, 241 - desc); 236 + return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, NULL, 237 + ctx, desc); 242 238 } 243 239 244 240 /**