On Mon, Mar 12, 2018 at 08:52:02AM +0100, Christoph Hellwig wrote:
> On Sat, Mar 10, 2018 at 11:01:43PM +0800, Ming Lei wrote:
> > > I really dislike this being open coded in drivers. It really should
> > > be helper chared with the blk-mq map building that drivers just use.
> > >
> > > For now just have a low-level blk_pci_map_queues that
> > > blk_mq_pci_map_queues, hpsa and megaraid can share. In the long run
> > > it might make sense to change the blk-mq callout to that low-level
> > > prototype as well.
> >
> > The way for selecting reply queue is needed for non scsi_mq too.
>
> Which still doesn't prevent you from using a common helper.
The only common code is the following part:
+ for (queue = 0; queue < instance->msix_vectors; queue++) {
+ mask = pci_irq_get_affinity(instance->pdev, queue);
+ if (!mask)
+ goto fallback;
+
+ for_each_cpu(cpu, mask)
+ instance->reply_map[cpu] = queue;
+ }
For megraraid_sas, the fallback code need to handle mapping in the
following way for legacy vectors:
for_each_possible_cpu(cpu)
instance->reply_map[cpu] = cpu % instance->msix_vectors;
So not sure if it is worth of a common helper, given there may not be
potential users of the helper.
Thanks,
Ming