[PATCH V3 04/10] scsi: replace blk_mq_pci_map_queues with blk_mq_dev_map_queues
Ming Lei
ming.lei at redhat.com
Fri Jul 9 01:09:59 PDT 2021
Replace blk_mq_pci_map_queues with blk_mq_dev_map_queues which is more
generic from blk-mq viewpoint, so we can unify all map queue via
blk_mq_dev_map_queues().
Meantime we can pass 'use_manage_irq' info to blk-mq via
blk_mq_dev_map_queues(), this info needn't be 100% accurate, and what
we need is that true has to be passed in if the hba really uses managed
irq.
Signed-off-by: Ming Lei <ming.lei at redhat.com>
---
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 21 ++++++++++-----------
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 5 +++--
drivers/scsi/megaraid/megaraid_sas_base.c | 4 +++-
drivers/scsi/mpi3mr/mpi3mr_os.c | 9 +++++----
drivers/scsi/mpt3sas/mpt3sas_scsih.c | 6 ++++--
drivers/scsi/qla2xxx/qla_os.c | 4 +++-
drivers/scsi/scsi_priv.h | 9 +++++++++
drivers/scsi/smartpqi/smartpqi_init.c | 7 +++++--
8 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 49d2723ef34c..4d3a698e2e4c 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -3547,6 +3547,14 @@ static struct device_attribute *host_attrs_v2_hw[] = {
NULL
};
+static inline const struct cpumask *hisi_hba_get_queue_affinity(
+ void *dev_data, int offset, int idx)
+{
+ struct hisi_hba *hba = dev_data;
+
+ return irq_get_affinity_mask(hba->irq_map[offset + idx]);
+}
+
static int map_queues_v2_hw(struct Scsi_Host *shost)
{
struct hisi_hba *hisi_hba = shost_priv(shost);
@@ -3554,17 +3562,8 @@ static int map_queues_v2_hw(struct Scsi_Host *shost)
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;
- }
-
- return 0;
-
+ return blk_mq_dev_map_queues(qmap, hisi_hba, 96,
+ hisi_hba_get_queue_affinity, false, true);
}
static struct scsi_host_template sht_v2_hw = {
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 5c3b1dfcb37c..f4370c43ba05 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -3132,8 +3132,9 @@ static int hisi_sas_map_queues(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];
- return blk_mq_pci_map_queues(qmap, hisi_hba->pci_dev,
- BASE_VECTORS_V3_HW);
+ return blk_mq_dev_map_queues(qmap, hisi_hba->pci_dev,
+ BASE_VECTORS_V3_HW,
+ scsi_pci_get_queue_affinity, false, true);
}
static struct scsi_host_template sht_v3_hw = {
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index ec10b2497310..1bb3d522e305 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -47,6 +47,7 @@
#include <scsi/scsi_dbg.h>
#include "megaraid_sas_fusion.h"
#include "megaraid_sas.h"
+#include "../scsi_priv.h"
/*
* Number of sectors per IO command
@@ -3185,7 +3186,8 @@ static int 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_dev_map_queues(map, instance->pdev, offset,
+ scsi_pci_get_queue_affinity, false, true);
qoff += map->nr_queues;
offset += map->nr_queues;
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 40676155e62d..7eed125ec66b 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -2787,17 +2787,18 @@ static int mpi3mr_bios_param(struct scsi_device *sdev,
* mpi3mr_map_queues - Map queues callback handler
* @shost: SCSI host reference
*
- * Call the blk_mq_pci_map_queues with from which operational
+ * Call the blk_mq_dev_map_queues with from which operational
* queue the mapping has to be done
*
- * Return: return of blk_mq_pci_map_queues
+ * Return: return of blk_mq_dev_map_queues
*/
static int mpi3mr_map_queues(struct Scsi_Host *shost)
{
struct mpi3mr_ioc *mrioc = shost_priv(shost);
- return blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
- mrioc->pdev, mrioc->op_reply_q_offset);
+ return blk_mq_dev_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
+ mrioc->pdev, mrioc->op_reply_q_offset,
+ scsi_pci_get_queue_affinity, false, true);
}
/**
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 866d118f7931..dded3cfa1115 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -57,6 +57,7 @@
#include <linux/blk-mq-pci.h>
#include <asm/unaligned.h>
+#include "../scsi_priv.h"
#include "mpt3sas_base.h"
#define RAID_CHANNEL 1
@@ -11784,8 +11785,9 @@ static int scsih_map_queues(struct Scsi_Host *shost)
if (ioc->shost->nr_hw_queues == 1)
return 0;
- return blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
- ioc->pdev, ioc->high_iops_queues);
+ return blk_mq_dev_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
+ ioc->pdev, ioc->high_iops_queues, scsi_pci_get_queue_affinity,
+ false, true);
}
/* shost template for SAS 2.0 HBA devices */
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 4eab564ea6a0..dc8c27052382 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -21,6 +21,7 @@
#include <scsi/scsi_transport_fc.h>
#include "qla_target.h"
+#include "../scsi_priv.h"
/*
* Driver version
@@ -7696,7 +7697,8 @@ static int qla2xxx_map_queues(struct Scsi_Host *shost)
if (USER_CTRL_IRQ(vha->hw) || !vha->hw->mqiobase)
rc = blk_mq_map_queues(qmap);
else
- rc = blk_mq_pci_map_queues(qmap, vha->hw->pdev, vha->irq_offset);
+ rc = blk_mq_dev_map_queues(qmap, vha->hw->pdev, vha->irq_offset,
+ scsi_pci_get_queue_affinity, false, true);
return rc;
}
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 75d6f23e4fff..cc1bd9ce6e2c 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -6,6 +6,7 @@
#include <linux/async.h>
#include <scsi/scsi_device.h>
#include <linux/sbitmap.h>
+#include <linux/pci.h>
struct request_queue;
struct request;
@@ -190,4 +191,12 @@ extern int scsi_device_max_queue_depth(struct scsi_device *sdev);
#define SCSI_DEVICE_BLOCK_MAX_TIMEOUT 600 /* units in seconds */
+static inline const struct cpumask *scsi_pci_get_queue_affinity(
+ void *dev_data, int offset, int queue)
+{
+ struct pci_dev *pdev = dev_data;
+
+ return pci_irq_get_affinity(pdev, offset + queue);
+}
+
#endif /* _SCSI_PRIV_H */
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index dcc0b9618a64..fd66260061c1 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -26,6 +26,7 @@
#include <scsi/scsi_eh.h>
#include <scsi/scsi_transport_sas.h>
#include <asm/unaligned.h>
+#include "../scsi_priv.h"
#include "smartpqi.h"
#include "smartpqi_sis.h"
@@ -6104,8 +6105,10 @@ static int pqi_map_queues(struct Scsi_Host *shost)
{
struct pqi_ctrl_info *ctrl_info = shost_to_hba(shost);
- return blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
- ctrl_info->pci_dev, 0);
+ return blk_mq_dev_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
+ ctrl_info->pci_dev, 0,
+ scsi_pci_get_queue_affinity, false,
+ true);
}
static int pqi_slave_configure(struct scsi_device *sdev)
--
2.31.1
More information about the Linux-nvme
mailing list