Skip to content

Commit a10fba0

Browse files
fengidrimstsirkin
authored andcommitted
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 <[email protected]> Acked-by: Hans de Goede <[email protected]> Reviewed-by: Mathieu Poirier <[email protected]> Acked-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 04ca0b0 commit a10fba0

File tree

10 files changed

+22
-10
lines changed

10 files changed

+22
-10
lines changed

arch/um/drivers/virtio_uml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ static struct virtqueue *vu_setup_vq(struct virtio_device *vdev,
10111011

10121012
static int vu_find_vqs(struct virtio_device *vdev, unsigned nvqs,
10131013
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,
10151015
struct irq_affinity *desc)
10161016
{
10171017
struct virtio_uml_device *vu_dev = to_virtio_uml_device(vdev);

drivers/platform/mellanox/mlxbf-tmfifo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ static int mlxbf_tmfifo_virtio_find_vqs(struct virtio_device *vdev,
928928
struct virtqueue *vqs[],
929929
vq_callback_t *callbacks[],
930930
const char * const names[],
931+
u32 sizes[],
931932
const bool *ctx,
932933
struct irq_affinity *desc)
933934
{

drivers/remoteproc/remoteproc_virtio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
158158
struct virtqueue *vqs[],
159159
vq_callback_t *callbacks[],
160160
const char * const names[],
161+
u32 sizes[],
161162
const bool * ctx,
162163
struct irq_affinity *desc)
163164
{

drivers/s390/virtio/virtio_ccw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ static int virtio_ccw_find_vqs(struct virtio_device *vdev, unsigned nvqs,
635635
struct virtqueue *vqs[],
636636
vq_callback_t *callbacks[],
637637
const char * const names[],
638+
u32 sizes[],
638639
const bool *ctx,
639640
struct irq_affinity *desc)
640641
{

drivers/virtio/virtio_mmio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ static int vm_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
474474
struct virtqueue *vqs[],
475475
vq_callback_t *callbacks[],
476476
const char * const names[],
477+
u32 sizes[],
477478
const bool *ctx,
478479
struct irq_affinity *desc)
479480
{

drivers/virtio/virtio_pci_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int vp_find_vqs_intx(struct virtio_device *vdev, unsigned int nvqs,
396396
/* the config->find_vqs() implementation */
397397
int vp_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
398398
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,
400400
struct irq_affinity *desc)
401401
{
402402
int err;

drivers/virtio/virtio_pci_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void vp_del_vqs(struct virtio_device *vdev);
110110
/* the config->find_vqs() implementation */
111111
int vp_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
112112
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,
114114
struct irq_affinity *desc);
115115
const char *vp_bus_name(struct virtio_device *vdev);
116116

drivers/virtio/virtio_pci_modern.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,15 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
347347
static int vp_modern_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
348348
struct virtqueue *vqs[],
349349
vq_callback_t *callbacks[],
350-
const char * const names[], const bool *ctx,
350+
const char * const names[],
351+
u32 sizes[],
352+
const bool *ctx,
351353
struct irq_affinity *desc)
352354
{
353355
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
354356
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);
356359

357360
if (rc)
358361
return rc;

drivers/virtio/virtio_vdpa.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ static int virtio_vdpa_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
269269
struct virtqueue *vqs[],
270270
vq_callback_t *callbacks[],
271271
const char * const names[],
272+
u32 sizes[],
272273
const bool *ctx,
273274
struct irq_affinity *desc)
274275
{

include/linux/virtio_config.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct virtio_shm_region {
5555
* include a NULL entry for vqs that do not need a callback
5656
* names: array of virtqueue names (mainly for debugging)
5757
* include a NULL entry for vqs unused by driver
58+
* sizes: array of virtqueue sizes
5859
* Returns 0 on success or error status
5960
* @del_vqs: free virtqueues found by find_vqs().
6061
* @synchronize_cbs: synchronize with the virtqueue callbacks (optional)
@@ -103,7 +104,9 @@ struct virtio_config_ops {
103104
void (*reset)(struct virtio_device *vdev);
104105
int (*find_vqs)(struct virtio_device *, unsigned nvqs,
105106
struct virtqueue *vqs[], vq_callback_t *callbacks[],
106-
const char * const names[], const bool *ctx,
107+
const char * const names[],
108+
u32 sizes[],
109+
const bool *ctx,
107110
struct irq_affinity *desc);
108111
void (*del_vqs)(struct virtio_device *);
109112
void (*synchronize_cbs)(struct virtio_device *);
@@ -212,7 +215,7 @@ struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev,
212215
const char *names[] = { n };
213216
struct virtqueue *vq;
214217
int err = vdev->config->find_vqs(vdev, 1, &vq, callbacks, names, NULL,
215-
NULL);
218+
NULL, NULL);
216219
if (err < 0)
217220
return ERR_PTR(err);
218221
return vq;
@@ -224,7 +227,8 @@ int virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs,
224227
const char * const names[],
225228
struct irq_affinity *desc)
226229
{
227-
return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, NULL, desc);
230+
return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, NULL,
231+
NULL, desc);
228232
}
229233

230234
static inline
@@ -233,8 +237,8 @@ int virtio_find_vqs_ctx(struct virtio_device *vdev, unsigned nvqs,
233237
const char * const names[], const bool *ctx,
234238
struct irq_affinity *desc)
235239
{
236-
return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, ctx,
237-
desc);
240+
return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, NULL,
241+
ctx, desc);
238242
}
239243

240244
/**

0 commit comments

Comments
 (0)