diff mbox series

[V3,04/10] scsi: replace blk_mq_pci_map_queues with blk_mq_dev_map_queues

Message ID 20210709081005.421340-5-ming.lei@redhat.com (mailing list archive)
State Changes Requested
Headers show
Series blk-mq: cleanup map queues & fix blk_mq_alloc_request_hctx | expand

Commit Message

Ming Lei July 9, 2021, 8:09 a.m. UTC
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@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(-)

Comments

kernel test robot July 9, 2021, 10:58 a.m. UTC | #1
Hi Ming,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on next-20210709]
[cannot apply to mkp-scsi/for-next scsi/for-next v5.13]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ming-Lei/blk-mq-cleanup-map-queues-fix-blk_mq_alloc_request_hctx/20210709-161333
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/68d3a74335a27dab42ec5f7b6c384ea7033e6864
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Ming-Lei/blk-mq-cleanup-map-queues-fix-blk_mq_alloc_request_hctx/20210709-161333
        git checkout 68d3a74335a27dab42ec5f7b6c384ea7033e6864
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/scsi/mpi3mr/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/scsi/mpi3mr/mpi3mr_os.c: In function 'mpi3mr_map_queues':
>> drivers/scsi/mpi3mr/mpi3mr_os.c:2801:6: error: 'scsi_pci_get_queue_affinity' undeclared (first use in this function)
    2801 |      scsi_pci_get_queue_affinity, false, true);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/scsi/mpi3mr/mpi3mr_os.c:2801:6: note: each undeclared identifier is reported only once for each function it appears in
   drivers/scsi/mpi3mr/mpi3mr_os.c:2802:1: error: control reaches end of non-void function [-Werror=return-type]
    2802 | }
         | ^
   cc1: some warnings being treated as errors


vim +/scsi_pci_get_queue_affinity +2801 drivers/scsi/mpi3mr/mpi3mr_os.c

  2785	
  2786	/**
  2787	 * mpi3mr_map_queues - Map queues callback handler
  2788	 * @shost: SCSI host reference
  2789	 *
  2790	 * Call the blk_mq_dev_map_queues with from which operational
  2791	 * queue the mapping has to be done
  2792	 *
  2793	 * Return: return of blk_mq_dev_map_queues
  2794	 */
  2795	static int mpi3mr_map_queues(struct Scsi_Host *shost)
  2796	{
  2797		struct mpi3mr_ioc *mrioc = shost_priv(shost);
  2798	
  2799		return blk_mq_dev_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
  2800		    mrioc->pdev, mrioc->op_reply_q_offset,
> 2801		    scsi_pci_get_queue_affinity, false, true);
  2802	}
  2803	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot July 9, 2021, 11:30 a.m. UTC | #2
Hi Ming,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on next-20210709]
[cannot apply to mkp-scsi/for-next scsi/for-next v5.13]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ming-Lei/blk-mq-cleanup-map-queues-fix-blk_mq_alloc_request_hctx/20210709-161333
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: riscv-randconfig-r022-20210709 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d69635ed9ecf36fd0ca85906bfde17949671cbe)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/68d3a74335a27dab42ec5f7b6c384ea7033e6864
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Ming-Lei/blk-mq-cleanup-map-queues-fix-blk_mq_alloc_request_hctx/20210709-161333
        git checkout 68d3a74335a27dab42ec5f7b6c384ea7033e6864
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from drivers/scsi/libsas/sas_scsi_host.c:27:
>> drivers/scsi/libsas/../scsi_priv.h:199:9: error: implicit declaration of function 'pci_irq_get_affinity' [-Werror,-Wimplicit-function-declaration]
           return pci_irq_get_affinity(pdev, offset + queue);
                  ^
   drivers/scsi/libsas/../scsi_priv.h:199:9: note: did you mean 'irq_set_affinity'?
   include/linux/interrupt.h:325:12: note: 'irq_set_affinity' declared here
   extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
              ^
   In file included from drivers/scsi/libsas/sas_scsi_host.c:27:
>> drivers/scsi/libsas/../scsi_priv.h:199:9: warning: incompatible integer to pointer conversion returning 'int' from a function with result type 'const struct cpumask *' [-Wint-conversion]
           return pci_irq_get_affinity(pdev, offset + queue);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 warning and 1 error generated.
--
   In file included from drivers/scsi/scsi.c:70:
>> drivers/scsi/scsi_priv.h:199:9: error: implicit declaration of function 'pci_irq_get_affinity' [-Werror,-Wimplicit-function-declaration]
           return pci_irq_get_affinity(pdev, offset + queue);
                  ^
   drivers/scsi/scsi_priv.h:199:9: note: did you mean 'irq_set_affinity'?
   include/linux/interrupt.h:325:12: note: 'irq_set_affinity' declared here
   extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
              ^
   In file included from drivers/scsi/scsi.c:70:
>> drivers/scsi/scsi_priv.h:199:9: warning: incompatible integer to pointer conversion returning 'int' from a function with result type 'const struct cpumask *' [-Wint-conversion]
           return pci_irq_get_affinity(pdev, offset + queue);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 warning and 1 error generated.


vim +/pci_irq_get_affinity +199 drivers/scsi/libsas/../scsi_priv.h

   193	
   194	static inline const struct cpumask *scsi_pci_get_queue_affinity(
   195			void *dev_data, int offset, int queue)
   196	{
   197		struct pci_dev *pdev = dev_data;
   198	
 > 199		return pci_irq_get_affinity(pdev, offset + queue);
   200	}
   201	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot July 9, 2021, 12:05 p.m. UTC | #3
Hi Ming,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on next-20210709]
[cannot apply to mkp-scsi/for-next scsi/for-next v5.13]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ming-Lei/blk-mq-cleanup-map-queues-fix-blk_mq_alloc_request_hctx/20210709-161333
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/68d3a74335a27dab42ec5f7b6c384ea7033e6864
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Ming-Lei/blk-mq-cleanup-map-queues-fix-blk_mq_alloc_request_hctx/20210709-161333
        git checkout 68d3a74335a27dab42ec5f7b6c384ea7033e6864
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/scsi/hisi_sas/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/scsi/hisi_sas/hisi_sas_v3_hw.c: In function 'hisi_sas_map_queues':
>> drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:3137:10: error: 'scsi_pci_get_queue_affinity' undeclared (first use in this function)
    3137 |          scsi_pci_get_queue_affinity, false, true);
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:3137:10: note: each undeclared identifier is reported only once for each function it appears in
   drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:3138:1: error: control reaches end of non-void function [-Werror=return-type]
    3138 | }
         | ^
   cc1: some warnings being treated as errors


vim +/scsi_pci_get_queue_affinity +3137 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

  3129	
  3130	static int hisi_sas_map_queues(struct Scsi_Host *shost)
  3131	{
  3132		struct hisi_hba *hisi_hba = shost_priv(shost);
  3133		struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT];
  3134	
  3135		return blk_mq_dev_map_queues(qmap, hisi_hba->pci_dev,
  3136					     BASE_VECTORS_V3_HW,
> 3137					     scsi_pci_get_queue_affinity, false, true);
  3138	}
  3139	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

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)