ACPI: processor: Move arch_init_invariance_cppc() call later
[pf-kernel.git] / block / blk-mq-virtio.c
blob68d0945c0b08a2be116125f46c3a56fcdb02aea8
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2016 Christoph Hellwig.
4 */
5 #include <linux/device.h>
6 #include <linux/blk-mq-virtio.h>
7 #include <linux/virtio_config.h>
8 #include <linux/module.h>
9 #include "blk-mq.h"
11 /**
12 * blk_mq_virtio_map_queues - provide a default queue mapping for virtio device
13 * @qmap: CPU to hardware queue map.
14 * @vdev: virtio device to provide a mapping for.
15 * @first_vec: first interrupt vectors to use for queues (usually 0)
17 * This function assumes the virtio device @vdev has at least as many available
18 * interrupt vectors as @set has queues. It will then query the vector
19 * corresponding to each queue for it's affinity mask and built queue mapping
20 * that maps a queue to the CPUs that have irq affinity for the corresponding
21 * vector.
23 void blk_mq_virtio_map_queues(struct blk_mq_queue_map *qmap,
24 struct virtio_device *vdev, int first_vec)
26 const struct cpumask *mask;
27 unsigned int queue, cpu;
29 if (!vdev->config->get_vq_affinity)
30 goto fallback;
32 for (queue = 0; queue < qmap->nr_queues; queue++) {
33 mask = vdev->config->get_vq_affinity(vdev, first_vec + queue);
34 if (!mask)
35 goto fallback;
37 for_each_cpu(cpu, mask)
38 qmap->mq_map[cpu] = qmap->queue_offset + queue;
41 return;
43 fallback:
44 blk_mq_map_queues(qmap);
46 EXPORT_SYMBOL_GPL(blk_mq_virtio_map_queues);