blk: refactor queue affinity helpers
Subsystems (16)
v2 cover blk: refactor queue affinity helpers
As Christoph suggested, I introduced a new callback to struct bus_type and hooked up the callbacks directly in virtio and pci subsystem. This looks pretty neat!
I've decided to provide only one version of blk_mq_hctx_map_queues but with an additional argument to pass in a driver specific callback.
Currently, there is only one user of this additional callback. Maybe it would be better to provide an variant of blk_mq_hctx_map_queues for the additional argument. Not sure though. Thoughts?
---
Changes in v2:
- added new callback to struct bus_type and call directly the affinity
helpers from there.
- Link to v1: https://lore.kernel.org/r/[email protected]
Changes in v1:
- renamed blk_mq_dev_map_queues to blk_mq_hctx_map_queues
- squased 'virito: add APIs for retrieving vq affinity' into 'blk-mq: introduce blk_mq_hctx_map_queues'
- moved hisi_sas changed into a new patch
- hisi_sas use define instead of hard coded value
- moved helpers into their matching subsystem, removed blk-mq-pci and blk-mq-virtio files
- fix spelling/typos
- fixed long lines in docu (yep new lines in brief descriptions are supported, tested ti)
- based on the first part of
https://lore.kernel.org/all/[email protected]
---
Daniel Wagner (6):
blk-mq: introduce blk_mq_hctx_map_queues
scsi: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues
scsi: hisi_sas: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues
nvme: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues
virtio: blk/scsi: replace blk_mq_virtio_map_queues with blk_mq_hctx_map_queues
blk-mq: remove unused queue mapping helpers
block/Makefile | 2 -- block/blk-mq-cpumap.c | 40 +++++++++++++++++++++++++++ block/blk-mq-pci.c | 46 ------------------------------- block/blk-mq-virtio.c | 46 ------------------------------- drivers/block/virtio_blk.c | 4 +-- drivers/nvme/host/fc.c | 1 - drivers/nvme/host/pci.c | 3 +- drivers/pci/pci-driver.c | 16 +++++++++++ drivers/scsi/fnic/fnic_main.c | 3 +- drivers/scsi/hisi_sas/hisi_sas.h | 1 - drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 22 +++++++-------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 +-- drivers/scsi/megaraid/megaraid_sas_base.c | 3 +- drivers/scsi/mpi3mr/mpi3mr.h | 1 - drivers/scsi/mpi3mr/mpi3mr_os.c | 3 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +-- drivers/scsi/pm8001/pm8001_init.c | 2 +- drivers/scsi/pm8001/pm8001_sas.h | 1 - drivers/scsi/qla2xxx/qla_nvme.c | 4 +-- drivers/scsi/qla2xxx/qla_os.c | 4 +-- drivers/scsi/smartpqi/smartpqi_init.c | 7 ++--- drivers/scsi/virtio_scsi.c | 3 +- drivers/virtio/virtio.c | 12 ++++++++ include/linux/blk-mq-pci.h | 11 -------- include/linux/blk-mq-virtio.h | 11 -------- include/linux/blk-mq.h | 5 ++++ include/linux/device/bus.h | 3 ++ 27 files changed, 107 insertions(+), 155 deletions(-)
---
base-commit: c9af98a7e8af266bae73e9d662b8341da1ec5824
change-id: 20240912-refactor-blk-affinity-helpers-7089b95b4b10
Best regards,
Signature · 1 line
Daniel Wagner <[email protected]>
PATCH v2 1/6 blk-mq: introduce blk_mq_hctx_map_queues
blk_mq_pci_map_queues and blk_mq_virtio_map_queues will create a CPU to hardware queue mapping based on affinity information. These two function share common code and only differ on how the affinity information is retrieved. Also, those functions are located in the block subsystem where it doesn't really fit in. They are virtio and pci subsystem specific.
Introduce a new callback in struct bus_type to get the affinity mask. The callbacks can then be populated by the subsystem directly.
All but one driver use the subsystem default affinity masks. hisi_sas v2 depends on a driver specific mapping, thus use the optional argument get_queue_affinity to retrieve the mapping.
--- block/blk-mq-cpumap.c | 40 ++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci-driver.c | 16 ++++++++++++++++ drivers/virtio/virtio.c | 12 ++++++++++++ include/linux/blk-mq.h | 5 +++++ include/linux/device/bus.h | 3 +++ 5 files changed, 76 insertions(+)
block/blk-mq-cpumap.c +40 -0
@@ -54,3 +54,43 @@ int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index)return NUMA_NO_NODE ; } + +/** +* blk_mq_hctx_map_queues - Create CPU to hardware queue mapping +* @qmap: CPU to hardware queue map. +* @dev: The device to map queues. +* @offset: Queue offset to use for the device. +* @get_irq_affinity: Optional callback to retrieve queue affinity. +* +* Create a CPU to hardware queue mapping in @qmap. For each queue +* @get_queue_affinity will be called. If @get_queue_affinity is not +* provided, then the bus_type irq_get_affinity callback will be +* used to retrieve the affinity. +*/ +void blk_mq_hctx_map_queues (struct blk_mq_queue_map *qmap, +struct device *dev,unsigned int offset, +get_queue_affinity_fn *get_irq_affinity) +{ +const struct cpumask *mask =NULL ; +unsigned int queue, cpu; + +for (queue =0 ; queue < qmap->nr_queues; queue++) { +if (get_irq_affinity) + mask =get_irq_affinity (dev, queue + offset); +else if (dev->bus->irq_get_affinity) + mask = dev->bus->irq_get_affinity (dev, queue + offset); + +if (!mask) + goto fallback; + +for_each_cpu (cpu, mask) + qmap->mq_map[cpu] = qmap->queue_offset + queue; + } + +return ; + +fallback: +WARN_ON_ONCE (qmap->nr_queues >1 ); +blk_mq_clear_mq_map (qmap); +} +EXPORT_SYMBOL_GPL (blk_mq_hctx_map_queues);
drivers/pci/pci-driver.c +16 -0
@@ -1670,6 +1670,21 @@ static void pci_dma_cleanup(struct device *dev)iommu_device_unuse_default_domain (dev); } +/** +* pci_device_irq_get_affinity - get affinity mask queue mapping for PCI device +* @dev: ptr to dev structure +* @irq_vec: interrupt vector number +* +* This function returns for a queue the affinity mask for a PCI device. +*/ +static const struct cpumask *pci_device_irq_get_affinity (struct device *dev, +unsigned int irq_vec) +{ +struct pci_dev *pdev =to_pci_dev (dev); + +return pci_irq_get_affinity (pdev, irq_vec); +} +const struct bus_type pci_bus_type = { .name ="pci" , .match = pci_bus_match,
@@ -1677,6 +1692,7 @@ const struct bus_type pci_bus_type = { .probe = pci_device_probe, .remove = pci_device_remove, .shutdown = pci_device_shutdown, + .irq_get_affinity = pci_device_irq_get_affinity, .dev_groups = pci_dev_groups, .bus_groups = pci_bus_groups, .drv_groups = pci_drv_groups,
drivers/virtio/virtio.c +12 -0
@@ -377,6 +377,17 @@ static void virtio_dev_remove(struct device *_d)of_node_put (dev->dev.of_node); } +static const struct cpumask *virtio_irq_get_affinity (struct device *_d, +unsigned int irq_veq) +{ +struct virtio_device *dev =dev_to_virtio (_d); + +if (!dev->config->get_vq_affinity) +return NULL ; + +return dev->config->get_vq_affinity (dev, irq_veq); +} +static const struct bus_type virtio_bus = { .name ="virtio" , .match = virtio_dev_match,
@@ -384,6 +395,7 @@ static const struct bus_type virtio_bus = { .uevent = virtio_uevent, .probe = virtio_dev_probe, .remove = virtio_dev_remove, + .irq_get_affinity = virtio_irq_get_affinity, };int __register_virtio_driver (struct virtio_driver *driver,struct module *owner)
include/linux/blk-mq.h +5 -0
@@ -922,7 +922,12 @@ int blk_mq_freeze_queue_wait_timeout(struct request_queue *q,void blk_mq_unfreeze_queue_non_owner (struct request_queue *q);void blk_freeze_queue_start_non_owner (struct request_queue *q); +typedef const struct cpumask *(get_queue_affinity_fn )(struct device *dev, +unsigned int queue);void blk_mq_map_queues (struct blk_mq_queue_map *qmap); +void blk_mq_hctx_map_queues (struct blk_mq_queue_map *qmap, +struct device *dev,unsigned int offset, +get_queue_affinity_fn *get_queue_affinity);void blk_mq_update_nr_hw_queues (struct blk_mq_tag_set *set,int nr_hw_queues);void blk_mq_quiesce_queue_nowait (struct request_queue *q);
include/linux/device/bus.h +3 -0
@@ -48,6 +48,7 @@ struct fwnode_handle;* will never get called until they do. * @remove: Called when a device removed from this bus. * @shutdown: Called at shut-down time to quiesce the device. +* @irq_get_affinity: Get IRQ affinity mask for the device on this bus. * * @online: Called to put the device back online (after offlining it). * @offline: Called to put the device offline for hot-removal. May fail.
@@ -87,6 +88,8 @@ struct bus_type {void (*sync_state)(struct device *dev);void (*remove)(struct device *dev);void (*shutdown)(struct device *dev); +const struct cpumask *(*irq_get_affinity)(struct device *dev, +unsigned int irq_vec);int (*online)(struct device *dev);int (*offline)(struct device *dev);
Signature · 1 line
2.47.0
Re: [PATCH v2 1/6] blk-mq: introduce blk_mq_hctx_map_queues
Quoted 77 lines · Daniel Wagner
blk_mq_pci_map_queuesandblk_mq_virtio_map_queueswill create a CPU to hardware queue mapping based on affinity information. These two function share common code and only differ on how the affinity information is retrieved. Also, those functions are located in the block subsystem where it doesn't really fit in. They are virtio and pci subsystem specific.Introduce a new callback in struct
bus_typeto get the affinity mask. The callbacks can then be populated by the subsystem directly.All but one driver use the subsystem default affinity masks.
hisi_sasv2 depends on a driver specific mapping, thus use the optional argumentget_queue_affinityto retrieve the mapping.Original-by Ming Lei <[email protected]>Signed-off-by Daniel Wagner <[email protected]>--- block/blk-mq-cpumap.c | 40 ++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci-driver.c | 16 ++++++++++++++++ drivers/virtio/virtio.c | 12 ++++++++++++ include/linux/blk-mq.h | 5 +++++ include/linux/device/bus.h | 3 +++ 5 files changed, 76 insertions(+)block/blk-mq-cpumap.c +40
-0@@ -54,3 +54,43 @@ int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index)return NUMA_NO_NODE ; } + +/** +* blk_mq_hctx_map_queues - Create CPU to hardware queue mapping +* @qmap: CPU to hardware queue map. +* @dev: The device to map queues. +* @offset: Queue offset to use for the device. +* @get_irq_affinity: Optional callback to retrieve queue affinity. +* +* Create a CPU to hardware queue mapping in @qmap. For each queue +* @get_queue_affinity will be called. If @get_queue_affinity is not +* provided, then the bus_type irq_get_affinity callback will be +* used to retrieve the affinity. +*/ +void blk_mq_hctx_map_queues (struct blk_mq_queue_map *qmap, +struct device *dev,unsigned int offset, +get_queue_affinity_fn *get_irq_affinity) +{ +const struct cpumask *mask =NULL ; +unsigned int queue, cpu; + +for (queue =0 ; queue < qmap->nr_queues; queue++) { +if (get_irq_affinity) + mask =get_irq_affinity (dev, queue + offset); +else if (dev->bus->irq_get_affinity) + mask = dev->bus->irq_get_affinity (dev, queue + offset); + +if (!mask) + goto fallback; + +for_each_cpu (cpu, mask) + qmap->mq_map[cpu] = qmap->queue_offset + queue; + } + +return ; + +fallback: +WARN_ON_ONCE (qmap->nr_queues >1 ); +blk_mq_clear_mq_map (qmap); +} +EXPORT_SYMBOL_GPL (blk_mq_hctx_map_queues);drivers/pci/pci-driver.c +0
-0
drivers/pci/pci-driver.c static void pci_dma_cleanup(struct device *dev) · line 1678
Quoted 9 lines
drivers/pci/pci-driver.c +6
-0@@ -1670,6 +1670,21 @@ static void pci_dma_cleanup(struct device *dev)iommu_device_unuse_default_domain (dev); } +/** +* pci_device_irq_get_affinity - get affinity mask queue mapping for PCI device +* @dev: ptr to dev structure +* @irq_vec: interrupt vector number +* +* This function returns for a queue the affinity mask for a PCI device.
From the PCI core perspective, this is only the *IRQ* affinity mask. The queue connection is not relevant here and probably confusing.
... - get IRQ affinity mask for device
Return the CPU affinity mask for @dev and @irq_vec.
With the above changes,
Quoted 92 lines
drivers/pci/pci-driver.c +10
-0+*/ +static const struct cpumask *pci_device_irq_get_affinity (struct device *dev, +unsigned int irq_vec) +{ +struct pci_dev *pdev =to_pci_dev (dev); + +return pci_irq_get_affinity (pdev, irq_vec); +} +const struct bus_type pci_bus_type = { .name ="pci" , .match = pci_bus_match,@@ -1677,6 +1692,7 @@ const struct bus_type pci_bus_type = { .probe = pci_device_probe, .remove = pci_device_remove, .shutdown = pci_device_shutdown, + .irq_get_affinity = pci_device_irq_get_affinity, .dev_groups = pci_dev_groups, .bus_groups = pci_bus_groups, .drv_groups = pci_drv_groups,drivers/virtio/virtio.c +12
-0@@ -377,6 +377,17 @@ static void virtio_dev_remove(struct device *_d)of_node_put (dev->dev.of_node); } +static const struct cpumask *virtio_irq_get_affinity (struct device *_d, +unsigned int irq_veq) +{ +struct virtio_device *dev =dev_to_virtio (_d); + +if (!dev->config->get_vq_affinity) +return NULL ; + +return dev->config->get_vq_affinity (dev, irq_veq); +} +static const struct bus_type virtio_bus = { .name ="virtio" , .match = virtio_dev_match,@@ -384,6 +395,7 @@ static const struct bus_type virtio_bus = { .uevent = virtio_uevent, .probe = virtio_dev_probe, .remove = virtio_dev_remove, + .irq_get_affinity = virtio_irq_get_affinity, };int __register_virtio_driver (struct virtio_driver *driver,struct module *owner)include/linux/blk-mq.h +5
-0@@ -922,7 +922,12 @@ int blk_mq_freeze_queue_wait_timeout(struct request_queue *q,void blk_mq_unfreeze_queue_non_owner (struct request_queue *q);void blk_freeze_queue_start_non_owner (struct request_queue *q); +typedef const struct cpumask *(get_queue_affinity_fn )(struct device *dev, +unsigned int queue);void blk_mq_map_queues (struct blk_mq_queue_map *qmap); +void blk_mq_hctx_map_queues (struct blk_mq_queue_map *qmap, +struct device *dev,unsigned int offset, +get_queue_affinity_fn *get_queue_affinity);void blk_mq_update_nr_hw_queues (struct blk_mq_tag_set *set,int nr_hw_queues);void blk_mq_quiesce_queue_nowait (struct request_queue *q);include/linux/device/bus.h +3
-0@@ -48,6 +48,7 @@ struct fwnode_handle;* will never get called until they do. * @remove: Called when a device removed from this bus. * @shutdown: Called at shut-down time to quiesce the device. +* @irq_get_affinity: Get IRQ affinity mask for the device on this bus. * * @online: Called to put the device back online (after offlining it). * @offline: Called to put the device offline for hot-removal. May fail. @@ -87,6 +88,8 @@ struct bus_type {void (*sync_state)(struct device *dev);void (*remove)(struct device *dev);void (*shutdown)(struct device *dev); +const struct cpumask *(*irq_get_affinity)(struct device *dev, +unsigned int irq_vec);int (*online)(struct device *dev);int (*offline)(struct device *dev);Signature · 2 lines
-- 2.47.0
Christoph Hellwig
maintainerRe: [PATCH v2 1/6] blk-mq: introduce blk_mq_hctx_map_queues
In reply to Daniel WagnerQuoted 7 lines · Daniel Wagner
blk_mq_pci_map_queuesandblk_mq_virtio_map_queueswill create a CPU to hardware queue mapping based on affinity information. These two function share common code and only differ on how the affinity information is retrieved. Also, those functions are located in the block subsystem where it doesn't really fit in. They are virtio and pci subsystem specific.
Quoted 6 lines
Introduce a new callback in struct
bus_typeto get the affinity mask. The callbacks can then be populated by the subsystem directly.All but one driver use the subsystem default affinity masks.
hisi_sasv2 depends on a driver specific mapping, thus use the optional argumentget_queue_affinityto retrieve the mapping.
This seems to mix up a few different things:
1) adding a new bus operation
2) implementations of that operation for PCI and virtio
3) a block layer consumer of the operation
all these really should be separate per-subsystem patches.
You'll also need to Cc the driver model maintainers.
Quoted 9 lines
block/blk-mq-cpumap.c +9
-0+void blk_mq_hctx_map_queues (struct blk_mq_queue_map *qmap, +struct device *dev,unsigned int offset, +get_queue_affinity_fn *get_irq_affinity) +{ +const struct cpumask *mask =NULL ; +unsigned int queue, cpu; + +for (queue =0 ; queue < qmap->nr_queues; queue++) { +if (get_irq_affinity)
block/blk-mq-cpumap.c int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index) · line 88
Quoted 10 lines
block/blk-mq-cpumap.c +10
-0+ mask =get_irq_affinity (dev, queue + offset); + else if (dev->bus->irq_get_affinity) + mask = dev->bus->irq_get_affinity (dev, queue + offset); + +if (!mask) + goto fallback; + +for_each_cpu (cpu, mask) + qmap->mq_map[cpu] = qmap->queue_offset + queue; + }
This does different things with a NULL argument vs not. Please split it into two separate helpers. The non-NULL case is only uses in hisi_sas, so it might be worth just open coding it there as well.
drivers/pci/pci-driver.c static void pci_dma_cleanup(struct device *dev) · line 1685
Quoted 6 lines
drivers/pci/pci-driver.c +6
-0+static const struct cpumask *pci_device_irq_get_affinity (struct device *dev, +unsigned int irq_vec) +{ +struct pci_dev *pdev =to_pci_dev (dev); + +return pci_irq_get_affinity (pdev, irq_vec);
Nit: this could be shortened to:
return pci_irq_get_affinity(to_pci_dev(dev), irq_vec);
Re: [PATCH v2 1/6] blk-mq: introduce blk_mq_hctx_map_queues
Quoted 9 lines · Christoph Hellwig
This seems to mix up a few different things:
1) adding a new bus operation
2) implementations of that operation for PCI and virtio
3) a block layer consumer of the operationall these really should be separate per-subsystem patches.
You'll also need to Cc the driver model maintainers.
Ok, will do.
Quoted 15 lines
Quoted 15 lines
block/blk-mq-cpumap.c +15
-0+void blk_mq_hctx_map_queues (struct blk_mq_queue_map *qmap, +struct device *dev,unsigned int offset, +get_queue_affinity_fn *get_irq_affinity) +{ +const struct cpumask *mask =NULL ; +unsigned int queue, cpu; + +for (queue =0 ; queue < qmap->nr_queues; queue++) { +if (get_irq_affinity) + mask =get_irq_affinity (dev, queue + offset); +else if (dev->bus->irq_get_affinity) + mask = dev->bus->irq_get_affinity (dev, queue + offset); + +if (!mask) + goto fallback;
Quoted 8 lines
block/blk-mq-cpumap.c int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index) · line 88
Quoted 4 lines
block/blk-mq-cpumap.c +4
-0+ +for_each_cpu (cpu, mask) + qmap->mq_map[cpu] = qmap->queue_offset + queue; + }This does different things with a NULL argument vs not. Please split it into two separate helpers. The non-NULL case is only uses in
hisi_sas, so it might be worth just open coding it there as well.
I'd like to avoid the open coding case, because this will make the following patches to support the isolated cpu patches more complex. Having a central place where the all the mask operation are, makes it a bit simpler streamlined. But then I could open code that part as well.
Quoted 10 lines
drivers/pci/pci-driver.c static void pci_dma_cleanup(struct device *dev) · line 1685
Quoted 6 lines
drivers/pci/pci-driver.c +6
-0+static const struct cpumask *pci_device_irq_get_affinity (struct device *dev, +unsigned int irq_vec) +{ +struct pci_dev *pdev =to_pci_dev (dev); + +return pci_irq_get_affinity (pdev, irq_vec);Nit: this could be shortened to:
return pci_irq_get_affinity(to_pci_dev(dev), irq_vec);
Ok.
Thanks,
Daniel
PATCH v2 2/6 scsi: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues
In reply to Daniel WagnerFrom: Daniel Wagner <[email protected]>
Replace all users of blk_mq_pci_map_queues with the more generic blk_mq_hctx_map_queues. This in preparation to retire blk_mq_pci_map_queues.
--- drivers/scsi/fnic/fnic_main.c | 3 +-- drivers/scsi/megaraid/megaraid_sas_base.c | 3 +-- drivers/scsi/mpi3mr/mpi3mr.h | 1 - drivers/scsi/mpi3mr/mpi3mr_os.c | 3 ++- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++-- drivers/scsi/pm8001/pm8001_init.c | 2 +- drivers/scsi/pm8001/pm8001_sas.h | 1 - drivers/scsi/qla2xxx/qla_nvme.c | 4 ++-- drivers/scsi/qla2xxx/qla_os.c | 4 ++-- drivers/scsi/smartpqi/smartpqi_init.c | 7 +++---- 10 files changed, 14 insertions(+), 18 deletions(-)
drivers/scsi/fnic/fnic_main.c +1 -2
@@ -16,7 +16,6 @@#include <linux/spinlock.h> #include <linux/workqueue.h> #include <linux/if_ether.h> -#include <linux/blk-mq-pci.h> #include <scsi/fc/fc_fip.h> #include <scsi/scsi_host.h> #include <scsi/scsi_transport.h>
@@ -601,7 +600,7 @@ void fnic_mq_map_queues_cpus(struct Scsi_Host *host)return ; } -blk_mq_pci_map_queues (qmap, l_pdev,FNIC_PCI_OFFSET ); +blk_mq_hctx_map_queues (qmap, &l_pdev->dev,FNIC_PCI_OFFSET ,NULL ); }static int fnic_probe (struct pci_dev *pdev,const struct pci_device_id *ent)
drivers/scsi/megaraid/megaraid_sas_base.c +1 -2
@@ -37,7 +37,6 @@#include <linux/poll.h> #include <linux/vmalloc.h> #include <linux/irq_poll.h> -#include <linux/blk-mq-pci.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h>
@@ -3193,7 +3192,7 @@ static void megasas_map_queues(struct Scsi_Host *shost) map = &shost->tag_set.map[HCTX_TYPE_DEFAULT ]; map->nr_queues = instance->msix_vectors - offset; map->queue_offset =0 ; -blk_mq_pci_map_queues (map, instance->pdev, offset); +blk_mq_hctx_map_queues (map, &instance->pdev->dev, offset,NULL ); qoff += map->nr_queues; offset += map->nr_queues;
drivers/scsi/mpi3mr/mpi3mr.h +0 -1
@@ -12,7 +12,6 @@#include <linux/blkdev.h> #include <linux/blk-mq.h> -#include <linux/blk-mq-pci.h> #include <linux/delay.h> #include <linux/dmapool.h> #include <linux/errno.h>
drivers/scsi/mpi3mr/mpi3mr_os.c +2 -1
@@ -4042,7 +4042,8 @@ static void mpi3mr_map_queues(struct Scsi_Host *shost)*/ map->queue_offset = qoff;if (i !=HCTX_TYPE_POLL ) -blk_mq_pci_map_queues (map, mrioc->pdev, offset); +blk_mq_hctx_map_queues (map, &mrioc->pdev->dev, + offset,NULL );else blk_mq_map_queues (map);
drivers/scsi/mpt3sas/mpt3sas_scsih.c +2 -2
@@ -53,7 +53,6 @@#include <linux/pci.h> #include <linux/interrupt.h> #include <linux/raid_class.h> -#include <linux/blk-mq-pci.h> #include <linux/unaligned.h> #include "mpt3sas_base.h"
@@ -11890,7 +11889,8 @@ static void scsih_map_queues(struct Scsi_Host *shost)*/ map->queue_offset = qoff;if (i !=HCTX_TYPE_POLL ) -blk_mq_pci_map_queues (map, ioc->pdev, offset); +blk_mq_hctx_map_queues (map, &ioc->pdev->dev, + offset,NULL );else blk_mq_map_queues (map);
drivers/scsi/pm8001/pm8001_init.c +1 -1
@@ -101,7 +101,7 @@ static void pm8001_map_queues(struct Scsi_Host *shost)struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT ];if (pm8001_ha->number_of_intr >1 ) { -blk_mq_pci_map_queues (qmap, pm8001_ha->pdev,1 ); +blk_mq_hctx_map_queues (qmap, &pm8001_ha->pdev->dev,1 ,NULL );return ; }
drivers/scsi/pm8001/pm8001_sas.h +0 -1
@@ -56,7 +56,6 @@#include <scsi/sas_ata.h> #include <linux/atomic.h> #include <linux/blk-mq.h> -#include <linux/blk-mq-pci.h> #include "pm8001_defs.h" #define DRV_NAME "pm80xx"
drivers/scsi/qla2xxx/qla_nvme.c +2 -2
@@ -8,7 +8,6 @@#include <linux/delay.h> #include <linux/nvme.h> #include <linux/nvme-fc.h> -#include <linux/blk-mq-pci.h> #include <linux/blk-mq.h> static struct nvme_fc_port_template qla_nvme_fc_transport;
@@ -841,7 +840,8 @@ static void qla_nvme_map_queues(struct nvme_fc_local_port *lport, {struct scsi_qla_host *vha = lport->private; -blk_mq_pci_map_queues (map, vha->hw->pdev, vha->irq_offset); +blk_mq_hctx_map_queues (map, &vha->hw->pdev->dev, + vha->irq_offset,NULL ); }static void qla_nvme_localport_delete (struct nvme_fc_local_port *lport)
drivers/scsi/qla2xxx/qla_os.c +2 -2
@@ -13,7 +13,6 @@#include <linux/mutex.h> #include <linux/kobject.h> #include <linux/slab.h> -#include <linux/blk-mq-pci.h> #include <linux/refcount.h> #include <linux/crash_dump.h> #include <linux/trace_events.h>
@@ -8070,7 +8069,8 @@ static void qla2xxx_map_queues(struct Scsi_Host *shost)if (USER_CTRL_IRQ (vha->hw) || !vha->hw->mqiobase)blk_mq_map_queues (qmap);else -blk_mq_pci_map_queues (qmap, vha->hw->pdev, vha->irq_offset); +blk_mq_hctx_map_queues (qmap, &vha->hw->pdev->dev, + vha->irq_offset,NULL ); }struct scsi_host_template qla2xxx_driver_template = {
drivers/scsi/smartpqi/smartpqi_init.c +3 -4
@@ -19,7 +19,6 @@#include <linux/bcd.h> #include <linux/reboot.h> #include <linux/cciss_ioctl.h> -#include <linux/blk-mq-pci.h> #include <scsi/scsi_host.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_device.h>
@@ -6547,10 +6546,10 @@ static void pqi_map_queues(struct Scsi_Host *shost)struct pqi_ctrl_info *ctrl_info =shost_to_hba (shost);if (!ctrl_info->disable_managed_interrupts) -return blk_mq_pci_map_queues (&shost->tag_set.map[HCTX_TYPE_DEFAULT ], - ctrl_info->pci_dev,0 ); +blk_mq_hctx_map_queues (&shost->tag_set.map[HCTX_TYPE_DEFAULT ], + &ctrl_info->pci_dev->dev,0 ,NULL );else -return blk_mq_map_queues (&shost->tag_set.map[HCTX_TYPE_DEFAULT ]); +blk_mq_map_queues (&shost->tag_set.map[HCTX_TYPE_DEFAULT ]); }static inline bool pqi_is_tape_changer_device (struct pqi_scsi_dev *device)
Signature · 1 line
2.47.0
Re: [PATCH v2 2/6] scsi: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues
Looks good:
PATCH v2 3/6 scsi: hisi_sas: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues
In reply to Daniel WagnerFrom: Daniel Wagner <[email protected]>
Replace all users of blk_mq_pci_map_queues with the more generic blk_mq_hctx_map_queues. This in preparation to retire blk_mq_pci_map_queues.
For his_sas_v2_hw.c needs its own callback for retrieving the affinity. The generic bus_type get queue affinity callback is using pci_irq_get_affinity and not irq_data_get_affinity_mask.
This allows it to replace the open code loop withblk_mq_hctx_map_queues at least.
--- drivers/scsi/hisi_sas/hisi_sas.h | 1 - drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 22 +++++++++++----------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +0 -1
@@ -9,7 +9,6 @@#include <linux/acpi.h> #include <linux/blk-mq.h> -#include <linux/blk-mq-pci.h> #include <linux/clk.h> #include <linux/debugfs.h> #include <linux/dmapool.h>
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +11 -11
@@ -3372,7 +3372,7 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba)for (queue_no =0 ; queue_no < hisi_hba->cq_nvecs; queue_no++) {struct hisi_sas_cq *cq = &hisi_hba->cq[queue_no]; - cq->irq_no = hisi_hba->irq_map[queue_no +96 ]; + cq->irq_no = hisi_hba->irq_map[queue_no +CQ0_IRQ_INDEX ]; rc = devm_request_threaded_irq(dev, cq->irq_no, cq_interrupt_v2_hw, cq_thread_v2_hw, IRQF_ONESHOT,
@@ -3549,21 +3549,21 @@ static const struct attribute_group *sdev_groups_v2_hw[] = {NULL }; +static const struct cpumask *hisi_hba_get_queue_affinity (struct device *dev, +unsigned int queue) +{ +struct hisi_hba *hba = dev->driver_data; + +return irq_get_affinity_mask (hba->irq_map[queue]); +} +static void map_queues_v2_hw (struct Scsi_Host *shost) {struct hisi_hba *hisi_hba =shost_priv (shost);struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT ]; -const struct cpumask *mask; -unsigned int queue, cpu; -for (queue =0 ; queue < qmap->nr_queues; queue++) { - mask =irq_get_affinity_mask (hisi_hba->irq_map[96 + queue]); -if (!mask) -continue ; - -for_each_cpu (cpu, mask) - qmap->mq_map[cpu] = qmap->queue_offset + queue; - } +blk_mq_hctx_map_queues (qmap, hisi_hba->dev,CQ0_IRQ_INDEX , + hisi_hba_get_queue_affinity); }static const struct scsi_host_template sht_v2_hw = {
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +2 -2
@@ -3322,8 +3322,8 @@ static void hisi_sas_map_queues(struct Scsi_Host *shost)if (i ==HCTX_TYPE_POLL )blk_mq_map_queues (qmap);else -blk_mq_pci_map_queues (qmap, hisi_hba->pci_dev, -BASE_VECTORS_V3_HW ); +blk_mq_hctx_map_queues (qmap, &hisi_hba->pci_dev->dev, +BASE_VECTORS_V3_HW ,NULL ); qoff += qmap->nr_queues; } }
Signature · 1 line
2.47.0
PATCH v2 4/6 nvme: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues
In reply to Daniel WagnerFrom: Daniel Wagner <[email protected]>
Replace all users of blk_mq_pci_map_queues with the more generic blk_mq_hctx_map_queues. This in preparation to retire blk_mq_pci_map_queues.
--- drivers/nvme/host/fc.c | 1 - drivers/nvme/host/pci.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/nvme/host/fc.c +0 -1
@@ -16,7 +16,6 @@#include <linux/nvme-fc.h> #include "fc.h" #include <scsi/scsi_transport_fc.h> -#include <linux/blk-mq-pci.h> /* *************************** Data Structures/Defines ****************** */
drivers/nvme/host/pci.c +1 -2
@@ -8,7 +8,6 @@#include <linux/async.h> #include <linux/blkdev.h> #include <linux/blk-mq.h> -#include <linux/blk-mq-pci.h> #include <linux/blk-integrity.h> #include <linux/dmi.h> #include <linux/init.h>
@@ -457,7 +456,7 @@ static void nvme_pci_map_queues(struct blk_mq_tag_set *set)*/ map->queue_offset = qoff;if (i !=HCTX_TYPE_POLL && offset) -blk_mq_pci_map_queues (map,to_pci_dev (dev->dev), offset); +blk_mq_hctx_map_queues (map, dev->dev, offset,NULL );else blk_mq_map_queues (map); qoff += map->nr_queues;
Signature · 1 line
2.47.0
PATCH v2 5/6 virtio: blk/scsi: replace blk_mq_virtio_map_queues with blk_mq_hctx_map_queues
In reply to Daniel WagnerFrom: Daniel Wagner <[email protected]>
Replace all users of blk_mq_virtio_map_queues with the more generic blk_mq_hctx_map_queues. This in preparation to retire blk_mq_virtio_map_queues.
--- drivers/block/virtio_blk.c | 4 ++-- drivers/scsi/virtio_scsi.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/block/virtio_blk.c +2 -2
@@ -13,7 +13,6 @@#include <linux/string_helpers.h> #include <linux/idr.h> #include <linux/blk-mq.h> -#include <linux/blk-mq-virtio.h> #include <linux/numa.h> #include <linux/vmalloc.h> #include <uapi/linux/virtio_ring.h>
@@ -1186,7 +1185,8 @@ static void virtblk_map_queues(struct blk_mq_tag_set *set)if (i ==HCTX_TYPE_POLL )blk_mq_map_queues (&set->map[i]);else -blk_mq_virtio_map_queues (&set->map[i], vblk->vdev,0 ); +blk_mq_hctx_map_queues (&set->map[i], &vblk->vdev->dev, +0 ,NULL ); } }
drivers/scsi/virtio_scsi.c +1 -2
@@ -29,7 +29,6 @@#include <scsi/scsi_tcq.h> #include <scsi/scsi_devinfo.h> #include <linux/seqlock.h> -#include <linux/blk-mq-virtio.h> #include "sd.h"
@@ -746,7 +745,7 @@ static void virtscsi_map_queues(struct Scsi_Host *shost)if (i ==HCTX_TYPE_POLL )blk_mq_map_queues (map);else -blk_mq_virtio_map_queues (map, vscsi->vdev,2 ); +blk_mq_hctx_map_queues (map, &vscsi->vdev->dev,2 ,NULL ); } }
Signature · 1 line
2.47.0
Re: [PATCH v2 5/6] virtio: blk/scsi: replace blk_mq_virtio_map_queues with blk_mq_hctx_map_queues
Looks good:
PATCH v2 6/6 blk-mq: remove unused queue mapping helpers
In reply to Daniel WagnerThere are no users left of the pci and virtio queue mapping helpers. Thus remove them.
--- block/Makefile | 2 -- block/blk-mq-pci.c | 46 ------------------------------------------- block/blk-mq-virtio.c | 46 ------------------------------------------- include/linux/blk-mq-pci.h | 11 ----------- include/linux/blk-mq-virtio.h | 11 ----------- 5 files changed, 116 deletions(-)
block/Makefile +0 -2
@@ -27,8 +27,6 @@ bfq-y := bfq-iosched.o bfq-wf2q.o bfq-cgroup.o obj-$(CONFIG_IOSCHED_BFQ) += bfq.o obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o blk-integrity.o t10-pi.o -obj-$(CONFIG_BLK_MQ_PCI) += blk-mq-pci.o -obj-$(CONFIG_BLK_MQ_VIRTIO) += blk-mq-virtio.o obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o obj-$(CONFIG_BLK_WBT) += blk-wbt.o obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o
block/blk-mq-pci.c deleted +0 -46
46 lines not on this page · raw message
block/blk-mq-virtio.c deleted +0 -46
46 lines not on this page · raw message
include/linux/blk-mq-pci.h deleted +0 -11
@@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_BLK_MQ_PCI_H -#define _LINUX_BLK_MQ_PCI_H - -struct blk_mq_queue_map ; -struct pci_dev ; - -void blk_mq_pci_map_queues (struct blk_mq_queue_map *qmap,struct pci_dev *pdev, -int offset); - -#endif /* _LINUX_BLK_MQ_PCI_H */
include/linux/blk-mq-virtio.h deleted +0 -11
@@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_BLK_MQ_VIRTIO_H -#define _LINUX_BLK_MQ_VIRTIO_H - -struct blk_mq_queue_map ; -struct virtio_device ; - -void blk_mq_virtio_map_queues (struct blk_mq_queue_map *qmap, -struct virtio_device *vdev,int first_vec); - -#endif /* _LINUX_BLK_MQ_VIRTIO_H */
Signature · 1 line
2.47.0
Re: [PATCH v2 6/6] blk-mq: remove unused queue mapping helpers
Looks good: