Skip to content

Commit

Permalink
blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL
Browse files Browse the repository at this point in the history
commit c005390 upstream.

While pci_irq_get_affinity should never fail for SMP kernel that
implement the affinity mapping, it will always return NULL in the
UP case, so provide a fallback mapping of all queues to CPU 0 in
that case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Christoph Hellwig authored and gregkh committed Aug 25, 2017
1 parent 6c7f375 commit d8c20af
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion block/blk-mq-pci.c
Expand Up @@ -36,12 +36,18 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev)
for (queue = 0; queue < set->nr_hw_queues; queue++) {
mask = pci_irq_get_affinity(pdev, queue);
if (!mask)
return -EINVAL;
goto fallback;

for_each_cpu(cpu, mask)
set->mq_map[cpu] = queue;
}

return 0;

fallback:
WARN_ON_ONCE(set->nr_hw_queues > 1);
for_each_possible_cpu(cpu)
set->mq_map[cpu] = 0;
return 0;
}
EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues);

0 comments on commit d8c20af

Please sign in to comment.