hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/virtio/virtio_pci_common.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Virtio PCI driver - common functionality for all device versions
34 *
....@@ -11,10 +12,6 @@
1112 * Anthony Liguori <aliguori@us.ibm.com>
1213 * Rusty Russell <rusty@rustcorp.com.au>
1314 * 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
- *
1815 */
1916
2017 #include "virtio_pci_common.h"
....@@ -257,8 +254,7 @@
257254
258255 if (vp_dev->msix_affinity_masks) {
259256 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]);
262258 }
263259
264260 if (vp_dev->msix_enabled) {
....@@ -287,7 +283,7 @@
287283 {
288284 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
289285 u16 msix_vec;
290
- int i, err, nvectors, allocated_vectors;
286
+ int i, err, nvectors, allocated_vectors, queue_idx = 0;
291287
292288 vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL);
293289 if (!vp_dev->vqs)
....@@ -297,7 +293,7 @@
297293 /* Best option: one for change interrupt, one per vq. */
298294 nvectors = 1;
299295 for (i = 0; i < nvqs; ++i)
300
- if (callbacks[i])
296
+ if (names[i] && callbacks[i])
301297 ++nvectors;
302298 } else {
303299 /* Second best: one for change, shared for all vqs. */
....@@ -323,7 +319,7 @@
323319 msix_vec = allocated_vectors++;
324320 else
325321 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],
327323 ctx ? ctx[i] : false,
328324 msix_vec);
329325 if (IS_ERR(vqs[i])) {
....@@ -358,7 +354,7 @@
358354 const char * const names[], const bool *ctx)
359355 {
360356 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
361
- int i, err;
357
+ int i, err, queue_idx = 0;
362358
363359 vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL);
364360 if (!vp_dev->vqs)
....@@ -376,7 +372,7 @@
376372 vqs[i] = NULL;
377373 continue;
378374 }
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],
380376 ctx ? ctx[i] : false,
381377 VIRTIO_MSI_NO_VECTOR);
382378 if (IS_ERR(vqs[i])) {