Skip to contentSkip to conversation

blk: refactor queue affinity helpers

PATCH Superseded Daniel Wagner 7 participants 36 messages Nov 12, 2024 – Nov 13, 2024

Subsystems (16)
SCSI Block layer PCI Driver core +12 more subsystems

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover blk: refactor queue affinity helpers

As suggested by Christoph I've dropped the special case for hisi_sas v2, so the open coded loop will stay. That means for the isolcpus patches, I just need to open code that thing there as well. But overall, this should be okay and it avoids adding a wierd interface to blk-mq APIs.

Original cover letter:

These patches were part of 'honor isolcpus configuration' [1] series. To simplify the review process I decided to send this as separate series because I think it's a nice cleanup independent of the isolcpus feature.

---
Changes in v3:
- dropped the additinal argument in blk_mq_hctx_map_queues.
leave open coded version in hisi_sas_v2.
- splitted "blk-mp: introduce blk_mq_hctx_map_queues" patch into
three patches.
- dropped local variable in pci_device_irq_get_affinity
- Link to v2: https://lore.kernel.org/r/20241111-refactor-blk-affinity-helpers-v2-0-f360ddad231a@kernel.org

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
[1] https://lore.kernel.org/all/[email protected]

---
Daniel Wagner (8):
driver core: bus: add irq_get_affinity callback to bus_type
PCI: hookup irq_get_affinity callback
virtio: hookup irq_get_affinity callback
blk-mp: introduce blk_mq_hctx_map_queues
scsi: 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                     | 37 +++++++++++++++++++++++++
 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                  | 14 ++++++++++
 drivers/scsi/fnic/fnic_main.c             |  3 +-
 drivers/scsi/hisi_sas/hisi_sas.h          |  1 -
 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           |  2 +-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c      |  3 +-
 drivers/scsi/pm8001/pm8001_init.c         |  2 +-
 drivers/scsi/pm8001/pm8001_sas.h          |  1 -
 drivers/scsi/qla2xxx/qla_nvme.c           |  3 +-
 drivers/scsi/qla2xxx/qla_os.c             |  4 +--
 drivers/scsi/smartpqi/smartpqi_init.c     |  7 ++---
 drivers/scsi/virtio_scsi.c                |  3 +-
 drivers/virtio/virtio.c                   | 19 +++++++++++++
 include/linux/blk-mq-pci.h                | 11 --------
 include/linux/blk-mq-virtio.h             | 11 --------
 include/linux/blk-mq.h                    |  2 ++
 include/linux/device/bus.h                |  3 ++
 26 files changed, 92 insertions(+), 144 deletions(-)

---
base-commit: c9af98a7e8af266bae73e9d662b8341da1ec5824
change-id: 20240912-refactor-blk-affinity-helpers-7089b95b4b10

Best regards,

Signature · 1 line
Daniel Wagner <[email protected]>
#1 lore raw

PATCH v3 1/8 driver core: bus: add irq_get_affinity callback to bus_type

Introducing a callback in struct bus_type so that a subsystem can hook up the getters directly. This approach avoids exposing random getters in any subsystems APIs.

---
 include/linux/device/bus.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/device/bus.h +3 -0
index cdc4757217f9bb4b36b5c3b8a48bab45737e44c5..b18658bce2c3819fc1cbeb38fb98391d56ec3317 100644
@@ -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
Reviewed-by on v3 1/8
#3 lore raw

Re: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type

In reply to Daniel Wagner
Quoted 10 lines · Daniel Wagner

Introducing a callback in struct bus_type so that a subsystem can hook up the getters directly. This approach avoids exposing random getters in any subsystems APIs.

---
  include/linux/device/bus.h | 3 +++
  1 file changed, 3 insertions(+)

Cheers,

Han nes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#4 lore raw

Re: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type

In reply to Daniel Wagner
Quoted 15 lines · Daniel Wagner

Introducing a callback in struct bus_type so that a subsystem can hook up the getters directly. This approach avoids exposing random getters in any subsystems APIs.

---
  include/linux/device/bus.h | 3 +++
  1 file changed, 3 insertions(+)
include/linux/device/bus.h +0 -0
index cdc4757217f9bb4b36b5c3b8a48bab45737e44c5..b18658bce2c3819fc1cbeb38fb98391d56ec3317 100644

include/linux/device/bus.h struct fwnode_handle; · line 49

Quoted 2 lines
include/linux/device/bus.h +0 -0
@@ -48,6 +48,7 @@ struct fwnode_handle;
   *		will never get called until they do.
   * @remove:	Called when a device removed from this bus.

My impression is that this would be better suited to "struct device_driver", but I assume that there is a good reason to add to "struct bus_type".

#5 lore raw

Re: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type

Quoted 11 lines · John Garry
Quoted 10 lines · Daniel Wagner

Introducing a callback in struct bus_type so that a subsystem can hook up the getters directly. This approach avoids exposing random getters in any subsystems APIs.

---
  include/linux/device/bus.h | 3 +++
  1 file changed, 3 insertions(+)
Quoted 10 lines

include/linux/device/bus.h struct fwnode_handle; · line 49

Quoted 7 lines
include/linux/device/bus.h +0 -0
index cdc4757217f9bb4b36b5c3b8a48bab45737e44c5..b18658bce2c3819fc1cbeb38fb98391d56ec3317 100644
@@ -48,6 +48,7 @@ struct fwnode_handle;
   *		will never get called until they do.
   * @remove:	Called when a device removed from this bus.

My impression is that this would be better suited to "struct device_driver", but I assume that there is a good reason to add to "struct bus_type".

I think the main reason to put it here is that most of the drivers are happy with the getter on bus level and don't need special treatment. We don't have to touch all the drivers to hookup a common getter, nor do we have to install a default handler when the driver doesn't specify one. Having the callback in struct bus_driver avoids this. Though Christoph suggested it, so I can only guess.

But you bring up a good point, if we had also an irq_get_affinity callback in struct device_driver it would be possible for the hisi_sas v2 driver to provide a getter and blk_mq_hctx_map_queues could do:

	for (queue = 0; queue < qmap->nr_queues; queue++) {
		if (dev->driver->irq_get_affinity)
			mask = dev->driver->irq_get_affinity;
		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;
	}

and with this in place the open coded version in hisi_sas v2 can also be replaced. If no one objects, I go ahead and add the callback to struct device_driver.

#6 lore raw

Re: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type

Quoted 29 lines · Daniel Wagner
Quoted 5 lines

Review struct fwnode_handle; · line 49

Quoted 3 lines
(quoted diff) +0 -0
@@ -48,6 +48,7 @@ struct fwnode_handle;
    *		will never get called until they do.
    * @remove:	Called when a device removed from this bus.

My impression is that this would be better suited to "struct device_driver", but I assume that there is a good reason to add to "struct bus_type".

I think the main reason to put it here is that most of the drivers are happy with the getter on bus level and don't need special treatment. We don't have to touch all the drivers to hookup a common getter, nor do we have to install a default handler when the driver doesn't specify one. Having the callback in struct bus_driver avoids this. Though Christoph suggested it, so I can only guess.

But you bring up a good point, if we had also an irq_get_affinity callback in struct device_driver it would be possible for the hisi_sas v2 driver to provide a getter and blk_mq_hctx_map_queues could do:

	for (queue = 0; queue < qmap->nr_queues; queue++) {
		if (dev->driver->irq_get_affinity)
			mask = dev->driver->irq_get_affinity;
		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;
	}
Quoted 2 lines

and with this in place the open coded version in hisi_sas v2 can also be replaced.

Yeah, I think that it could be plugged in like:

(quoted diff) +0 -0

b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 342d75f12051..5172af77a3f0 100644

drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1 -0
@@ -3636,6 +3636,7 @@ static struct platform_driver hisi_sas_v2_driver = {
               .name = DRV_NAME,
               .of_match_table = sas_v2_of_match,
               .acpi_match_table = ACPI_PTR(sas_v2_acpi_match),
+               .irq_get_affinity_mask = hisi_sas_v2_get_affinity_mask,
       },

};

Quoted 2 lines

If no one objects, I go ahead and add the callback to struct device_driver.

I'd wait for Christoph and Greg to both agree. I was just wondering why we use bus_type.

#7 lore raw

Re: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type

Quoted 49 lines · John Garry
Quoted 29 lines · Daniel Wagner
Quoted 5 lines

Review struct fwnode_handle; · line 49

Quoted 3 lines
(quoted diff) +0 -0
@@ -48,6 +48,7 @@ struct fwnode_handle;
    *		will never get called until they do.
    * @remove:	Called when a device removed from this bus.

My impression is that this would be better suited to "struct device_driver", but I assume that there is a good reason to add to "struct bus_type".

I think the main reason to put it here is that most of the drivers are happy with the getter on bus level and don't need special treatment. We don't have to touch all the drivers to hookup a common getter, nor do we have to install a default handler when the driver doesn't specify one. Having the callback in struct bus_driver avoids this. Though Christoph suggested it, so I can only guess.

But you bring up a good point, if we had also an irq_get_affinity callback in struct device_driver it would be possible for the hisi_sas v2 driver to provide a getter and blk_mq_hctx_map_queues could do:

	for (queue = 0; queue < qmap->nr_queues; queue++) {
		if (dev->driver->irq_get_affinity)
			mask = dev->driver->irq_get_affinity;
		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;
	}
Quoted 2 lines

and with this in place the open coded version in hisi_sas v2 can also be replaced.

Yeah, I think that it could be plugged in like:

drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1 -0
index 342d75f12051..5172af77a3f0 100644
@@ -3636,6 +3636,7 @@ static struct platform_driver hisi_sas_v2_driver = {
               .name = DRV_NAME,
               .of_match_table = sas_v2_of_match,
               .acpi_match_table = ACPI_PTR(sas_v2_acpi_match),
+               .irq_get_affinity_mask = hisi_sas_v2_get_affinity_mask,
       },
 };
 
Quoted 5 lines
Quoted 2 lines

If no one objects, I go ahead and add the callback to struct device_driver.

I'd wait for Christoph and Greg to both agree. I was just wondering why we use bus_type.

bus types are good to set it at a bus level so you don't have to explicitly set it at each-and-every-driver. Depends on what you want this to be, if it is a "all drivers of this bus type will have the same callback" then put it on the bus. otherwise if you are going to mix/match on a same bus, then put it in the driver structure.

hope this helps,

greg k-h

#8 lore raw

Re: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type

Quoted 16 lines · Greg Kroah-Hartman
Quoted 16 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1 -0
index 342d75f12051..5172af77a3f0 100644
@@ -3636,6 +3636,7 @@ static struct platform_driver hisi_sas_v2_driver = {
                .name = DRV_NAME,
                .of_match_table = sas_v2_of_match,
                .acpi_match_table = ACPI_PTR(sas_v2_acpi_match),
+               .irq_get_affinity_mask = hisi_sas_v2_get_affinity_mask,
        },
 };
 
Quoted 3 lines

If no one objects, I go ahead and add the callback to struct device_driver.

Quoted 7 lines
Quoted 2 lines

I'd wait for Christoph and Greg to both agree. I was just wondering why we use bus_type.

bus types are good to set it at a bus level so you don't have to explicitly set it at each-and-every-driver. Depends on what you want this to be, if it is a "all drivers of this bus type will have the same callback" then put it on the bus. otherwise if you are going to mix/match on a same bus, then put it in the driver structure.

Understood, I think all drivers on same bus will use the same callback.

FWIW, most drivers of interest are pci drivers, so I thought that it would simply be a change like this (for those drivers if we use struct device_driver):

@@ -1442,6 +1455,7 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner,

       drv->driver.mod_name = mod_name;
       drv->driver.groups = drv->groups;
       drv->driver.dev_groups = drv->dev_groups;

+ drv->driver.irq_get_affinity = pci_device_irq_get_affinity;

Thanks,
John

#9 lore raw

Re: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type

Quoted 32 lines · John Garry
Quoted 16 lines · Greg Kroah-Hartman
Quoted 16 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1 -0
index 342d75f12051..5172af77a3f0 100644
@@ -3636,6 +3636,7 @@ static struct platform_driver hisi_sas_v2_driver = {
                .name = DRV_NAME,
                .of_match_table = sas_v2_of_match,
                .acpi_match_table = ACPI_PTR(sas_v2_acpi_match),
+               .irq_get_affinity_mask = hisi_sas_v2_get_affinity_mask,
        },
 };
 
Quoted 3 lines

If no one objects, I go ahead and add the callback to struct device_driver.

Quoted 7 lines
Quoted 2 lines

I'd wait for Christoph and Greg to both agree. I was just wondering why we use bus_type.

bus types are good to set it at a bus level so you don't have to explicitly set it at each-and-every-driver. Depends on what you want this to be, if it is a "all drivers of this bus type will have the same callback" then put it on the bus. otherwise if you are going to mix/match on a same bus, then put it in the driver structure.

Understood, I think all drivers on same bus will use the same callback.

FWIW, most drivers of interest are pci drivers, so I thought that it would simply be a change like this (for those drivers if we use struct device_driver):

Review int __pci_register_driver(struct pci_driver · line 1459

Quoted 5 lines
(quoted diff) +1 -0
@@ -1442,6 +1455,7 @@ int __pci_register_driver(struct pci_driver
 *drv, struct module *owner,
       drv->driver.mod_name = mod_name;
       drv->driver.groups = drv->groups;
       drv->driver.dev_groups = drv->dev_groups;
+       drv->driver.irq_get_affinity = pci_device_irq_get_affinity;

Yes, you can do that too. But now you have a pointer-per-driver instead of just one-per-bus. It's not a big deal, but again if this is always going to be the same for everything on a bus, make it a bus pointer please.

thanks,

greg k-h

#10 lore raw

Re: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type

In reply to Greg Kroah-Hartman
Quoted 5 lines · Greg Kroah-Hartman

bus types are good to set it at a bus level so you don't have to explicitly set it at each-and-every-driver. Depends on what you want this to be, if it is a "all drivers of this bus type will have the same callback" then put it on the bus. otherwise if you are going to mix/match on a same bus, then put it in the driver structure.

... and that is exactly the case here. The driver itself has no business being involved.

#11 lore raw

PATCH v3 2/8 PCI: hookup irq_get_affinity callback

In reply to Daniel Wagner

struct bus_type has a new callback for retrieving the IRQ affinity for a device. Hook this callback up for PCI based devices.

---
 drivers/pci/pci-driver.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/pci/pci-driver.c +14 -0
index 35270172c833186995aebdda6f95ab3ffd7c67a0..a9cb0e3ad2e6eca58c34683303b1242228e96909 100644
@@ -1670,6 +1670,19 @@ static void pci_dma_cleanup(struct device *dev)
 		iommu_device_unuse_default_domain(dev);
 }
 
+/**
+ * pci_device_irq_get_affinity - get IRQ affinity mask for device
+ * @dev: ptr to dev structure
+ * @irq_vec: interrupt vector number
+ *
+ * Return the CPU affinity mask for @dev and @irq_vec.
+ */
+static const struct cpumask *pci_device_irq_get_affinity(struct device *dev,
+					unsigned int irq_vec)
+{
+	return pci_irq_get_affinity(to_pci_dev(dev), irq_vec);
+}
+
 const struct bus_type pci_bus_type = {
 	.name		= "pci",
 	.match		= pci_bus_match,
@@ -1677,6 +1690,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,
Signature · 1 line
2.47.0
Reviewed-by on v3 2/8
#13 lore raw

Re: [PATCH v3 2/8] PCI: hookup irq_get_affinity callback

In reply to Daniel Wagner
Quoted 9 lines · Daniel Wagner

struct bus_type has a new callback for retrieving the IRQ affinity for a device. Hook this callback up for PCI based devices.

---
  drivers/pci/pci-driver.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#14 lore raw

PATCH v3 3/8 virtio: hookup irq_get_affinity callback

In reply to Daniel Wagner

struct bus_type has a new callback for retrieving the IRQ affinity for a device. Hook this callback up for virtio based devices.

---
 drivers/virtio/virtio.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/virtio/virtio.c +19 -0
index b9095751e43bb7db5fc991b0cc0979d2e86f7b9b..7774aecdfe52d4dce11eb77e43864981a2e2b2bb 100644
@@ -377,6 +377,24 @@ static void virtio_dev_remove(struct device *_d)
 	of_node_put(dev->dev.of_node);
 }
 
+/**
+ * virtio_irq_get_affinity - get IRQ affinity mask for device
+ * @_d: ptr to dev structure
+ * @irq_vec: interrupt vector number
+ *
+ * Return the CPU affinity mask for @_d and @irq_vec.
+ */
+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 +402,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)
Signature · 1 line
2.47.0
maintainer Reviewed-by on v3 3/8
#15 lore raw

Re: [PATCH v3 3/8] virtio: hookup irq_get_affinity callback

Quoted 2 lines · Daniel Wagner

struct bus_type has a new callback for retrieving the IRQ affinity for a device. Hook this callback up for virtio based devices.

Looks good:

#16 lore raw

Re: [PATCH v3 3/8] virtio: hookup irq_get_affinity callback

In reply to Daniel Wagner
kernel test robot noticed the following build warnings:

Hi Daniel,

kernel test robot noticed the following build warnings:

[auto build test WARNING on c9af98a7e8af266bae73e9d662b8341da1ec5824]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Wagner/driver-core-bus-add-irq_get_affinity-callback-to-bus_type/20241112-213257
base:   c9af98a7e8af266bae73e9d662b8341da1ec5824
patch link:    https://lore.kernel.org/r/20241112-refactor-blk-affinity-helpers-v3-3-573bfca0cbd8%40kernel.org
patch subject: [PATCH v3 3/8] virtio: hookup irq_get_affinity callback
config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20241113/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241113/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/virtio/virtio.c:389: warning: Function parameter or struct member 'irq_veq' not described in 'virtio_irq_get_affinity'
>> drivers/virtio/virtio.c:389: warning: Excess function parameter 'irq_vec' description in 'virtio_irq_get_affinity'

vim +389 drivers/virtio/virtio.c

379
380 /**
381 * virtio_irq_get_affinity - get IRQ affinity mask for device
382 * @_d: ptr to dev structure
383 * @irq_vec: interrupt vector number
384 *
385 * Return the CPU affinity mask for @_d and @irq_vec.
386 */
387 static const struct cpumask *virtio_irq_get_affinity(struct device *_d,
388 unsigned int irq_veq)

 > 389	{

390 struct virtio_device *dev = dev_to_virtio(_d);
391
392 if (!dev->config->get_vq_affinity)
393 return NULL;
394
395 return dev->config->get_vq_affinity(dev, irq_veq);
396 }
397

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Reviewed-by on v3 3/8
#17 lore raw

Re: [PATCH v3 3/8] virtio: hookup irq_get_affinity callback

In reply to Daniel Wagner
Quoted 8 lines · Daniel Wagner

struct bus_type has a new callback for retrieving the IRQ affinity for a device. Hook this callback up for virtio based devices.

---
  drivers/virtio/virtio.c | 19 +++++++++++++++++++
  1 file changed, 19 insertions(+)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#18 lore raw

PATCH v3 4/8 blk-mp: introduce blk_mq_hctx_map_queues

In reply to Daniel Wagner

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.

Thus introduce provide a generic mapping function which uses the irq_get_affinity callback from bus_type.

Originally idea from Ming Lei <[email protected]>

---
 block/blk-mq-cpumap.c  | 37 +++++++++++++++++++++++++++++++++++++
 include/linux/blk-mq.h |  2 ++
 2 files changed, 39 insertions(+)
block/blk-mq-cpumap.c +37 -0
index 9638b25fd52124f0173e968ebdca5f1fe0b42ad9..db22a7d523a2762b76398fdd768f55efd1d6d669 100644
@@ -11,6 +11,7 @@
 #include <linux/smp.h>
 #include <linux/cpu.h>
 #include <linux/group_cpus.h>
+#include <linux/device/bus.h>
 
 #include "blk.h"
 #include "blk-mq.h"
@@ -54,3 +55,39 @@ 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.
+ *
+ * Create a CPU to hardware queue mapping in @qmap. The struct 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)
+
+{
+	const struct cpumask *mask;
+	unsigned int queue, cpu;
+
+	if (!dev->bus->irq_get_affinity)
+		goto fallback;
+
+	for (queue = 0; queue < qmap->nr_queues; queue++) {
+		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);
include/linux/blk-mq.h +2 -0
index 2035fad3131fb60781957095ce8a3a941dd104be..1a85fdcb443c154390cd29f2b1f2a807bf10bfe3 100644
@@ -923,6 +923,8 @@ void blk_mq_unfreeze_queue_non_owner(struct request_queue *q);
 void blk_freeze_queue_start_non_owner(struct request_queue *q);
 
 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);
 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);
Signature · 1 line
2.47.0
#19 lore raw

Re: [PATCH v3 4/8] blk-mp: introduce blk_mq_hctx_map_queues

Quoted 43 lines · Daniel Wagner

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.

Thus introduce provide a generic mapping function which uses the irq_get_affinity callback from bus_type.

Originally idea from Ming Lei <[email protected]>

---
 block/blk-mq-cpumap.c  | 37 +++++++++++++++++++++++++++++++++++++
 include/linux/blk-mq.h |  2 ++
 2 files changed, 39 insertions(+)
block/blk-mq-cpumap.c +10 -0
index 9638b25fd52124f0173e968ebdca5f1fe0b42ad9..db22a7d523a2762b76398fdd768f55efd1d6d669 100644
@@ -11,6 +11,7 @@
 #include <linux/smp.h>
 #include <linux/cpu.h>
 #include <linux/group_cpus.h>
+#include <linux/device/bus.h>
 
 #include "blk.h"
 #include "blk-mq.h"
@@ -54,3 +55,39 @@ 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.
+ *
+ * Create a CPU to hardware queue mapping in @qmap. The struct bus_type
+ * irq_get_affinity callback will be used to retrieve the affinity.

block/blk-mq-cpumap.c int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index) · line 76

Quoted 10 lines
block/blk-mq-cpumap.c +10 -0
+ */
+void blk_mq_hctx_map_queues(struct blk_mq_queue_map *qmap,
+			    struct device *dev, unsigned int offset)
+
+{
+	const struct cpumask *mask;
+	unsigned int queue, cpu;
+
+	if (!dev->bus->irq_get_affinity)
+		goto fallback;

I think this is better than hard-coding it, but are you sure that the bus will always be bound to the device here so that you have a valid bus-> pointer?

thanks,

greg k-h

#20 lore raw

Re: [PATCH v3 4/8] blk-mp: introduce blk_mq_hctx_map_queues

Quoted 5 lines · Greg Kroah-Hartman
Quoted 5 lines
block/blk-mq-cpumap.c +5 -0
+void blk_mq_hctx_map_queues(struct blk_mq_queue_map *qmap,
+			    struct device *dev, unsigned int offset)
+
+{
+	const struct cpumask *mask;
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 76

Quoted 4 lines
block/blk-mq-cpumap.c +4 -0
+	unsigned int queue, cpu;
+
+	if (!dev->bus->irq_get_affinity)
+		goto fallback;

I think this is better than hard-coding it, but are you sure that the bus will always be bound to the device here so that you have a valid bus-> pointer?

No, I just assumed the bus pointer is always valid. If it is possible to have a device without a bus, than I'll better extend the condition to

	if (!dev->bus || !dev->bus->irq_get_affinity)
        	goto fallback;
#21 lore raw

Re: [PATCH v3 4/8] blk-mp: introduce blk_mq_hctx_map_queues

Quoted 15 lines · Daniel Wagner
Quoted 5 lines · Greg Kroah-Hartman
Quoted 5 lines
block/blk-mq-cpumap.c +5 -0
+void blk_mq_hctx_map_queues(struct blk_mq_queue_map *qmap,
+			    struct device *dev, unsigned int offset)
+
+{
+	const struct cpumask *mask;
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 76

Quoted 4 lines
block/blk-mq-cpumap.c +4 -0
+	unsigned int queue, cpu;
+
+	if (!dev->bus->irq_get_affinity)
+		goto fallback;

I think this is better than hard-coding it, but are you sure that the bus will always be bound to the device here so that you have a valid bus-> pointer?

Quoted 5 lines

No, I just assumed the bus pointer is always valid. If it is possible to have a device without a bus, than I'll better extend the condition to

	if (!dev->bus || !dev->bus->irq_get_affinity)
        	goto fallback;

I don't know if it's possible as I don't know what codepaths are calling this, it was hard to unwind. But you should check "just to be safe" :)

thanks,

greg k-h

#22 lore raw

Re: [PATCH v3 4/8] blk-mp: introduce blk_mq_hctx_map_queues

Quoted 16 lines · Greg Kroah-Hartman
Quoted 15 lines · Daniel Wagner
Quoted 13 lines · Greg Kroah-Hartman

block/blk-mq-cpumap.c int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index) · line 76

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)
+
+{
+	const struct cpumask *mask;
+	unsigned int queue, cpu;
+
+	if (!dev->bus->irq_get_affinity)
+		goto fallback;

I think this is better than hard-coding it, but are you sure that the bus will always be bound to the device here so that you have a valid bus-> pointer?

Quoted 8 lines
Quoted 5 lines

No, I just assumed the bus pointer is always valid. If it is possible to have a device without a bus, than I'll better extend the condition to

	if (!dev->bus || !dev->bus->irq_get_affinity)
        	goto fallback;

I don't know if it's possible as I don't know what codepaths are calling this, it was hard to unwind. But you should check "just to be safe" :)

The main path to map_queues is via the probe functions. There are some more paths like when updating a tagset after the number of queues but that is all after the probe function.

nvme_probe
nvme_alloc_admin_tag_set

    blk_mq_alloc_tag_set
       blk_mq_update_queue_map
          set->ops->map_queues
	     blk_mq_htcx_map_queues
  nvme_alloc_io_tag_set
    blk_mq_alloc_tag_set
      blk_mq_update_queue_map
        set->ops->map_queues
          blk_mq_htcx_map_queues

virtscsi_probe, hisi_sas_v3_probe, ...
scsi_add_host

    scsi_add_host_with_dma
      scsi_mq_setup_tags
         blk_mq_alloc_tag_set
           blk_mq_update_queue_map
             set->ops->map_queues
               blk_mq_htcx_map_queues

virtblk_probe
blk_mq_alloc_tag_set

    blk_mq_update_queue_map
      set->ops->map_queues
        blk_mq_htcx_map_queues

Does this help?

#23 lore raw

Re: [PATCH v3 4/8] blk-mp: introduce blk_mq_hctx_map_queues

Quoted 51 lines · Daniel Wagner
Quoted 16 lines · Greg Kroah-Hartman
Quoted 15 lines · Daniel Wagner
Quoted 13 lines · Greg Kroah-Hartman

block/blk-mq-cpumap.c int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index) · line 76

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)
+
+{
+	const struct cpumask *mask;
+	unsigned int queue, cpu;
+
+	if (!dev->bus->irq_get_affinity)
+		goto fallback;

I think this is better than hard-coding it, but are you sure that the bus will always be bound to the device here so that you have a valid bus-> pointer?

Quoted 8 lines
Quoted 5 lines

No, I just assumed the bus pointer is always valid. If it is possible to have a device without a bus, than I'll better extend the condition to

	if (!dev->bus || !dev->bus->irq_get_affinity)
        	goto fallback;

I don't know if it's possible as I don't know what codepaths are calling this, it was hard to unwind. But you should check "just to be safe" :)

The main path to map_queues is via the probe functions. There are some more paths like when updating a tagset after the number of queues but that is all after the probe function.

nvme_probe
nvme_alloc_admin_tag_set

    blk_mq_alloc_tag_set
       blk_mq_update_queue_map
          set->ops->map_queues
	     blk_mq_htcx_map_queues
  nvme_alloc_io_tag_set
    blk_mq_alloc_tag_set
      blk_mq_update_queue_map
        set->ops->map_queues
          blk_mq_htcx_map_queues

virtscsi_probe, hisi_sas_v3_probe, ...
scsi_add_host

    scsi_add_host_with_dma
      scsi_mq_setup_tags
         blk_mq_alloc_tag_set
           blk_mq_update_queue_map
             set->ops->map_queues
               blk_mq_htcx_map_queues
Quoted 7 lines

virtblk_probe
blk_mq_alloc_tag_set

    blk_mq_update_queue_map
      set->ops->map_queues
        blk_mq_htcx_map_queues

Does this help?

Ok, that seems fine. Worst case, you crash and it's obvious that it needs to be checked in the future :)

thanks,

greg k-h

Reviewed-by on v3 4/8
#26 lore raw

Re: [PATCH v3 4/8] blk-mp: introduce blk_mq_hctx_map_queues

In reply to Daniel Wagner
Quoted 10 lines · Daniel Wagner

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.

Thus introduce provide a generic mapping function which uses the irq_get_affinity callback from bus_type.

Quoted 8 lines

Originally idea from Ming Lei <[email protected]>

---
  block/blk-mq-cpumap.c  | 37 +++++++++++++++++++++++++++++++++++++
  include/linux/blk-mq.h |  2 ++
  2 files changed, 39 insertions(+)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#27 lore raw

PATCH v3 5/8 scsi: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues

In reply to Daniel Wagner

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/hisi_sas/hisi_sas.h          | 1 -
 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           | 2 +-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c      | 3 +--
 drivers/scsi/pm8001/pm8001_init.c         | 2 +-
 drivers/scsi/pm8001/pm8001_sas.h          | 1 -
 drivers/scsi/qla2xxx/qla_nvme.c           | 3 +--
 drivers/scsi/qla2xxx/qla_os.c             | 4 ++--
 drivers/scsi/smartpqi/smartpqi_init.c     | 7 +++----
 12 files changed, 13 insertions(+), 21 deletions(-)
drivers/scsi/fnic/fnic_main.c +1 -2
index adec0df24bc475ea4d7d8089ea0f75fe96746956..74a782780cc4f8b298168bb14809973a8206095f 100644
@@ -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);
 }
 
 static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
drivers/scsi/hisi_sas/hisi_sas.h +0 -1
index d223f482488fc6cebc2838e92ae7ec70fb4e1437..010479a354eeeb47bbee24102e450aa3b7ea6197 100644
@@ -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_v3_hw.c +2 -2
index 4cd3a3eab6f1c47c962565a74cd7284dad1db12e..7858c807be5eacb70ded5ec9399c6531a4ef6116 100644
@@ -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);
 		qoff += qmap->nr_queues;
 	}
 }
drivers/scsi/megaraid/megaraid_sas_base.c +1 -2
index 8e75e2e279a40ae5fdc6b7b07a7aed15241a8d54..0180bb56de52bb57f15fae22df0d413cdd576ba3 100644
@@ -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);
 	qoff += map->nr_queues;
 	offset += map->nr_queues;
 
drivers/scsi/mpi3mr/mpi3mr.h +0 -1
index 81bb408ce56d8f9599e6f62276666bedce6d0d32..57ccea42ece1ecf1c471ee744213453b13db0ea1 100644
@@ -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 +1 -1
index 5f2f67acf8bf3194cb8ec78904096ffb4bdd7ff2..e898b476af6dc84eb150ec867e6be8dd1b2d4d8a 100644
@@ -4042,7 +4042,7 @@ 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);
 		else
 			blk_mq_map_queues(map);
 
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 -2
index f2a55aa5fe65036a3beabae5c0c6e9db835d2aab..efb95fcef7ed71fc5daea215508e04b602d31663 100644
@@ -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,7 @@ 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);
 		else
 			blk_mq_map_queues(map);
 
drivers/scsi/pm8001/pm8001_init.c +1 -1
index 33e1eba62ca12c2555419197ecdbebad817e4a6d..035e102979f0de34b637be81e0f64b588a3893c8 100644
@@ -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);
 		return;
 	}
 
drivers/scsi/pm8001/pm8001_sas.h +0 -1
index ced6721380a85345a74a87ebd2facdaa513f8768..c46470e0cf63b7b18b9572c8d6b4f4ddf489aa2b 100644
@@ -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 +1 -2
index 8f4cc136a9c9c46f5f2d5408f9b7688ef520a8a3..2b2eeec159880d0178eb07455a7eac0e63d66af4 100644
@@ -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,7 @@ 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);
 }
 
 static void qla_nvme_localport_delete(struct nvme_fc_local_port *lport)
drivers/scsi/qla2xxx/qla_os.c +2 -2
index 7f980e6141c28282d4c4a0123dda96e36e1f180e..acf26d09fa4563409d50fbba118f3b37732a7c8b 100644
@@ -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);
 }
 
 struct scsi_host_template qla2xxx_driver_template = {
drivers/scsi/smartpqi/smartpqi_init.c +3 -4
index 870f37b7054644426a2695e857c45a0a12aff051..501af16d872b1295071a99208248f1d83f072ab5 100644
@@ -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);
 	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
Reviewed-by on v3 5/8
#28 lore raw

Re: [PATCH v3 5/8] scsi: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues

Quoted 6 lines · Daniel Wagner

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.

Quoted 15 lines
---
  drivers/scsi/fnic/fnic_main.c             | 3 +--
  drivers/scsi/hisi_sas/hisi_sas.h          | 1 -
  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           | 2 +-
  drivers/scsi/mpt3sas/mpt3sas_scsih.c      | 3 +--
  drivers/scsi/pm8001/pm8001_init.c         | 2 +-
  drivers/scsi/pm8001/pm8001_sas.h          | 1 -
  drivers/scsi/qla2xxx/qla_nvme.c           | 3 +--
  drivers/scsi/qla2xxx/qla_os.c             | 4 ++--
  drivers/scsi/smartpqi/smartpqi_init.c     | 7 +++----
  12 files changed, 13 insertions(+), 21 deletions(-)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#29 lore raw

Re: [PATCH v3 5/8] scsi: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues

In reply to Daniel Wagner
Quoted 11 lines · Daniel Wagner
  #include <linux/acpi.h>
  #include <linux/blk-mq.h>
drivers/scsi/hisi_sas/hisi_sas.h +0 -1
-#include <linux/blk-mq-pci.h>
  #include <linux/clk.h>
  #include <linux/debugfs.h>
  #include <linux/dmapool.h>
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +0 -0
index 4cd3a3eab6f1c47c962565a74cd7284dad1db12e..7858c807be5eacb70ded5ec9399c6531a4ef6116 100644

drivers/scsi/hisi_sas/hisi_sas_v3_hw.c static void hisi_sas_map_queues(struct Scsi_Host *shost) · line 3325

Quoted 6 lines
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -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,

nit: hisi_hba->dev could be used directly

drivers/scsi/hisi_sas/hisi_sas_v3_hw.c static void hisi_sas_map_queues(struct Scsi_Host *shost) · line 3326

Quoted 1 line
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -0
+					       BASE_VECTORS_V3_HW);

looks ok apart from that

Quoted 2 lines
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +0 -0
  		qoff += qmap->nr_queues;
  	}
#30 lore raw

PATCH v3 6/8 nvme: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues

In reply to Daniel Wagner

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
index b81af7919e94c421387033bf8361a9cf8a867486..094be164ffdc0fb79050cfb92c32dfaee8d15622 100644
@@ -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
index 4b9fda0b1d9a33af4d7030b72532835b205e9cbb..cb8ca574594d7eb5f959cf9eb03be445223b2666 100644
@@ -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);
 		else
 			blk_mq_map_queues(map);
 		qoff += map->nr_queues;
Signature · 1 line
2.47.0
Reviewed-by on v3 6/8
#31 lore raw

Re: [PATCH v3 6/8] nvme: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues

Quoted 11 lines · Daniel Wagner

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(-)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#32 lore raw

PATCH v3 7/8 virtio: blk/scsi: replace blk_mq_virtio_map_queues with blk_mq_hctx_map_queues

In reply to Daniel Wagner

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
index 0e99a4714928478c1ba81777b8e98448eb5b992a..fd997e3381526eb3d7a21eda296b3a8a2998c696 100644
@@ -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);
 	}
 }
 
drivers/scsi/virtio_scsi.c +1 -2
index 8471f38b730e205eb57052305c154260864bee95..dcb83c15f90825bd7bdb3a5f541108b934a308f3 100644
@@ -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);
 	}
 }
 
Signature · 1 line
2.47.0
Reviewed-by on v3 7/8
#33 lore raw

Re: [PATCH v3 7/8] virtio: blk/scsi: replace blk_mq_virtio_map_queues with blk_mq_hctx_map_queues

Quoted 11 lines · Daniel Wagner

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(-)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#34 lore raw

PATCH v3 8/8 blk-mq: remove unused queue mapping helpers

In reply to Daniel Wagner

There 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
index ddfd21c1a9ffc9c4f49efca9875bd8a1cbf81e4d..33748123710b368a1a3a7b099bbd90d27b24c69b 100644
@@ -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
deleted file mode 100644
index ca544e1d3508f34ab6e198b0bb17efe88de4d14d..0000000000000000000000000000000000000000
@@ -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
deleted file mode 100644
index 13226e9b22dd53e4289d506d49c52671de036ee8..0000000000000000000000000000000000000000
@@ -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
Reviewed-by on v3 8/8
#35 lore raw

Re: [PATCH v3 8/8] blk-mq: remove unused queue mapping helpers

Quoted 5 lines · Daniel Wagner

There are no users left of the pci and virtio queue mapping helpers. Thus remove them.

Quoted 8 lines
---
  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(-)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich