.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Virtio PCI driver - common functionality for all device versions |
---|
3 | 4 | * |
---|
.. | .. |
---|
11 | 12 | * Anthony Liguori <aliguori@us.ibm.com> |
---|
12 | 13 | * Rusty Russell <rusty@rustcorp.com.au> |
---|
13 | 14 | * Michael S. Tsirkin <mst@redhat.com> |
---|
14 | | - * |
---|
15 | | - * This work is licensed under the terms of the GNU GPL, version 2 or later. |
---|
16 | | - * See the COPYING file in the top-level directory. |
---|
17 | | - * |
---|
18 | 15 | */ |
---|
19 | 16 | |
---|
20 | 17 | #include "virtio_pci_common.h" |
---|
.. | .. |
---|
257 | 254 | |
---|
258 | 255 | if (vp_dev->msix_affinity_masks) { |
---|
259 | 256 | for (i = 0; i < vp_dev->msix_vectors; i++) |
---|
260 | | - if (vp_dev->msix_affinity_masks[i]) |
---|
261 | | - free_cpumask_var(vp_dev->msix_affinity_masks[i]); |
---|
| 257 | + free_cpumask_var(vp_dev->msix_affinity_masks[i]); |
---|
262 | 258 | } |
---|
263 | 259 | |
---|
264 | 260 | if (vp_dev->msix_enabled) { |
---|
.. | .. |
---|
287 | 283 | { |
---|
288 | 284 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
---|
289 | 285 | u16 msix_vec; |
---|
290 | | - int i, err, nvectors, allocated_vectors; |
---|
| 286 | + int i, err, nvectors, allocated_vectors, queue_idx = 0; |
---|
291 | 287 | |
---|
292 | 288 | vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL); |
---|
293 | 289 | if (!vp_dev->vqs) |
---|
.. | .. |
---|
297 | 293 | /* Best option: one for change interrupt, one per vq. */ |
---|
298 | 294 | nvectors = 1; |
---|
299 | 295 | for (i = 0; i < nvqs; ++i) |
---|
300 | | - if (callbacks[i]) |
---|
| 296 | + if (names[i] && callbacks[i]) |
---|
301 | 297 | ++nvectors; |
---|
302 | 298 | } else { |
---|
303 | 299 | /* Second best: one for change, shared for all vqs. */ |
---|
.. | .. |
---|
323 | 319 | msix_vec = allocated_vectors++; |
---|
324 | 320 | else |
---|
325 | 321 | msix_vec = VP_MSIX_VQ_VECTOR; |
---|
326 | | - vqs[i] = vp_setup_vq(vdev, i, callbacks[i], names[i], |
---|
| 322 | + vqs[i] = vp_setup_vq(vdev, queue_idx++, callbacks[i], names[i], |
---|
327 | 323 | ctx ? ctx[i] : false, |
---|
328 | 324 | msix_vec); |
---|
329 | 325 | if (IS_ERR(vqs[i])) { |
---|
.. | .. |
---|
358 | 354 | const char * const names[], const bool *ctx) |
---|
359 | 355 | { |
---|
360 | 356 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
---|
361 | | - int i, err; |
---|
| 357 | + int i, err, queue_idx = 0; |
---|
362 | 358 | |
---|
363 | 359 | vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL); |
---|
364 | 360 | if (!vp_dev->vqs) |
---|
.. | .. |
---|
376 | 372 | vqs[i] = NULL; |
---|
377 | 373 | continue; |
---|
378 | 374 | } |
---|
379 | | - vqs[i] = vp_setup_vq(vdev, i, callbacks[i], names[i], |
---|
| 375 | + vqs[i] = vp_setup_vq(vdev, queue_idx++, callbacks[i], names[i], |
---|
380 | 376 | ctx ? ctx[i] : false, |
---|
381 | 377 | VIRTIO_MSI_NO_VECTOR); |
---|
382 | 378 | if (IS_ERR(vqs[i])) { |
---|