scsi: provide a generic change_queue_type method
authorChristoph Hellwig <hch@lst.de>
Thu, 2 Oct 2014 12:39:55 +0000 (14:39 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 12 Nov 2014 10:19:39 +0000 (11:19 +0100)
Most drivers use exactly the same implementation, so provide it as a
library function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
19 files changed:
drivers/infiniband/ulp/srp/ib_srp.c
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
drivers/scsi/esas2r/esas2r.h
drivers/scsi/esas2r/esas2r_main.c
drivers/scsi/fcoe/fcoe.c
drivers/scsi/fnic/fnic_main.c
drivers/scsi/ibmvscsi/ibmvfc.c
drivers/scsi/ipr.c
drivers/scsi/libfc/fc_fcp.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/mpt2sas/mpt2sas_scsih.c
drivers/scsi/mpt3sas/mpt3sas_scsih.c
drivers/scsi/pmcraid.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/scsi.c
drivers/scsi/scsi_debug.c
drivers/target/loopback/tcm_loop.c
include/scsi/libfc.h
include/scsi/scsi_tcq.h

index 62d2a18e1b419225b312326690ec624563f5aa7b..51670d75ab786d274ff00f4440af3ba56a7a9102 100644 (file)
@@ -2258,28 +2258,6 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
        return 0;
 }
 
-/**
- * srp_change_queue_type - changing device queue tag type
- * @sdev: scsi device struct
- * @tag_type: requested tag type
- *
- * Returns queue tag type.
- */
-static int
-srp_change_queue_type(struct scsi_device *sdev, int tag_type)
-{
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, tag_type);
-               if (tag_type)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               tag_type = 0;
-
-       return tag_type;
-}
-
 /**
  * srp_change_queue_depth - setting device queue depth
  * @sdev: scsi device struct
@@ -2600,7 +2578,7 @@ static struct scsi_host_template srp_template = {
        .info                           = srp_target_info,
        .queuecommand                   = srp_queuecommand,
        .change_queue_depth             = srp_change_queue_depth,
-       .change_queue_type              = srp_change_queue_type,
+       .change_queue_type              = scsi_change_queue_type,
        .eh_abort_handler               = srp_abort,
        .eh_device_reset_handler        = srp_reset_device,
        .eh_host_reset_handler          = srp_reset_host,
index 79e5c94107a9cc44fe8269f55ab72e8150005e0b..3c6dc8abc776980c491aae63e6b93d33c2abf3bf 100644 (file)
@@ -2784,7 +2784,7 @@ static struct scsi_host_template bnx2fc_shost_template = {
        .eh_host_reset_handler  = fc_eh_host_reset,
        .slave_alloc            = fc_slave_alloc,
        .change_queue_depth     = fc_change_queue_depth,
-       .change_queue_type      = fc_change_queue_type,
+       .change_queue_type      = scsi_change_queue_type,
        .this_id                = -1,
        .cmd_per_lun            = 3,
        .use_clustering         = ENABLE_CLUSTERING,
index 3fd305d6b67d893f77e299b49269e5e7035ca43f..20ab211983f29c89a1b9eae0598543cec1d4a288 100644 (file)
@@ -976,7 +976,6 @@ int esas2r_slave_alloc(struct scsi_device *dev);
 int esas2r_slave_configure(struct scsi_device *dev);
 void esas2r_slave_destroy(struct scsi_device *dev);
 int esas2r_change_queue_depth(struct scsi_device *dev, int depth, int reason);
-int esas2r_change_queue_type(struct scsi_device *dev, int type);
 long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
 
 /* SCSI error handler (eh) functions */
index 45aa684f8b74093c117b5aaa6e93c33e82d3a219..be09c628d03425c69e87e8d01aa93fefb75ee536 100644 (file)
@@ -258,7 +258,7 @@ static struct scsi_host_template driver_template = {
        .slave_alloc                    = esas2r_slave_alloc,
        .slave_destroy                  = esas2r_slave_destroy,
        .change_queue_depth             = esas2r_change_queue_depth,
-       .change_queue_type              = esas2r_change_queue_type,
+       .change_queue_type              = scsi_change_queue_type,
        .max_sectors                    = 0xFFFF,
 };
 
@@ -1268,24 +1268,6 @@ int esas2r_change_queue_depth(struct scsi_device *dev, int depth, int reason)
        return dev->queue_depth;
 }
 
-int esas2r_change_queue_type(struct scsi_device *dev, int type)
-{
-       esas2r_log(ESAS2R_LOG_INFO, "change_queue_type %p, %d", dev, type);
-
-       if (dev->tagged_supported) {
-               scsi_set_tag_type(dev, type);
-
-               if (type)
-                       scsi_activate_tcq(dev, dev->queue_depth);
-               else
-                       scsi_deactivate_tcq(dev, dev->queue_depth);
-       } else {
-               type = 0;
-       }
-
-       return type;
-}
-
 int esas2r_slave_alloc(struct scsi_device *dev)
 {
        return 0;
index 4a8ac7d8c76b25467e5f51087f3f2ff6d6e2f5dd..86956cc3448eaf28f66270ff649f9910b562b970 100644 (file)
@@ -281,7 +281,7 @@ static struct scsi_host_template fcoe_shost_template = {
        .eh_host_reset_handler = fc_eh_host_reset,
        .slave_alloc = fc_slave_alloc,
        .change_queue_depth = fc_change_queue_depth,
-       .change_queue_type = fc_change_queue_type,
+       .change_queue_type = scsi_change_queue_type,
        .this_id = -1,
        .cmd_per_lun = 3,
        .can_queue = FCOE_MAX_OUTSTANDING_COMMANDS,
index 8c56fdc3a4560adf69a82332545a1ed768bde1e7..8581ce662cf0d32f82612ca81d9169cd9eda53ac 100644 (file)
@@ -113,7 +113,7 @@ static struct scsi_host_template fnic_host_template = {
        .eh_host_reset_handler = fnic_host_reset,
        .slave_alloc = fnic_slave_alloc,
        .change_queue_depth = fc_change_queue_depth,
-       .change_queue_type = fc_change_queue_type,
+       .change_queue_type = scsi_change_queue_type,
        .this_id = -1,
        .cmd_per_lun = 3,
        .can_queue = FNIC_DFLT_IO_REQ,
index 598c42cba5a86ab939f8a81ade1057dd8eb512f7..48d19a3256ceb2216e5bb1ddf0df4362ef8eb7c8 100644 (file)
@@ -2929,29 +2929,6 @@ static int ibmvfc_change_queue_depth(struct scsi_device *sdev, int qdepth,
        return sdev->queue_depth;
 }
 
-/**
- * ibmvfc_change_queue_type - Change the device's queue type
- * @sdev:              scsi device struct
- * @tag_type:  type of tags to use
- *
- * Return value:
- *     actual queue type set
- **/
-static int ibmvfc_change_queue_type(struct scsi_device *sdev, int tag_type)
-{
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, tag_type);
-
-               if (tag_type)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               tag_type = 0;
-
-       return tag_type;
-}
-
 static ssize_t ibmvfc_show_host_partition_name(struct device *dev,
                                                 struct device_attribute *attr, char *buf)
 {
@@ -3133,7 +3110,7 @@ static struct scsi_host_template driver_template = {
        .target_alloc = ibmvfc_target_alloc,
        .scan_finished = ibmvfc_scan_finished,
        .change_queue_depth = ibmvfc_change_queue_depth,
-       .change_queue_type = ibmvfc_change_queue_type,
+       .change_queue_type = scsi_change_queue_type,
        .cmd_per_lun = 16,
        .can_queue = IBMVFC_MAX_REQUESTS_DEFAULT,
        .this_id = -1,
index 2a9578c116b7a8f879b386a58c937bdf2b4d1fc1..3d689f6023e9343a2e58d3c6c03f40e1577bff97 100644 (file)
@@ -4364,24 +4364,10 @@ static int ipr_change_queue_type(struct scsi_device *sdev, int tag_type)
 
        spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
        res = (struct ipr_resource_entry *)sdev->hostdata;
-
-       if (res) {
-               if (ipr_is_gscsi(res) && sdev->tagged_supported) {
-                       /*
-                        * We don't bother quiescing the device here since the
-                        * adapter firmware does it for us.
-                        */
-                       scsi_set_tag_type(sdev, tag_type);
-
-                       if (tag_type)
-                               scsi_activate_tcq(sdev, sdev->queue_depth);
-                       else
-                               scsi_deactivate_tcq(sdev, sdev->queue_depth);
-               } else
-                       tag_type = 0;
-       } else
+       if (res && ipr_is_gscsi(res))
+               tag_type = scsi_change_queue_type(sdev, tag_type);
+       else
                tag_type = 0;
-
        spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
        return tag_type;
 }
index 1d7e76e8b447c7d8a6e42eb652a8f607277f070d..f3043ad1f35d07cebf64ae5eee852aeb6438dc2e 100644 (file)
@@ -2195,26 +2195,6 @@ int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
 }
 EXPORT_SYMBOL(fc_change_queue_depth);
 
-/**
- * fc_change_queue_type() - Change a device's queue type
- * @sdev:     The SCSI device whose queue depth is to change
- * @tag_type: Identifier for queue type
- */
-int fc_change_queue_type(struct scsi_device *sdev, int tag_type)
-{
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, tag_type);
-               if (tag_type)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               tag_type = 0;
-
-       return tag_type;
-}
-EXPORT_SYMBOL(fc_change_queue_type);
-
 /**
  * fc_fcp_destory() - Tear down the FCP layer for a given local port
  * @lport: The local port that no longer needs the FCP layer
index b99399fe25488095d82911e34e8dab82091cb0e6..2896e52ac6cd761005b5d3fd3a4267dbecf120f2 100644 (file)
@@ -344,26 +344,6 @@ lpfc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
        return sdev->queue_depth;
 }
 
-/**
- * lpfc_change_queue_type() - Change a device's scsi tag queuing type
- * @sdev: Pointer the scsi device whose queue depth is to change
- * @tag_type: Identifier for queue tag type
- */
-static int
-lpfc_change_queue_type(struct scsi_device *sdev, int tag_type)
-{
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, tag_type);
-               if (tag_type)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               tag_type = 0;
-
-       return tag_type;
-}
-
 /**
  * lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread
  * @phba: The Hba for which this call is being executed.
@@ -6019,7 +5999,7 @@ struct scsi_host_template lpfc_template = {
        .max_sectors            = 0xFFFF,
        .vendor_id              = LPFC_NL_VENDOR_ID,
        .change_queue_depth     = lpfc_change_queue_depth,
-       .change_queue_type      = lpfc_change_queue_type,
+       .change_queue_type      = scsi_change_queue_type,
 };
 
 struct scsi_host_template lpfc_vport_template = {
@@ -6042,5 +6022,5 @@ struct scsi_host_template lpfc_vport_template = {
        .shost_attrs            = lpfc_vport_attrs,
        .max_sectors            = 0xFFFF,
        .change_queue_depth     = lpfc_change_queue_depth,
-       .change_queue_type      = lpfc_change_queue_type,
+       .change_queue_type      = scsi_change_queue_type,
 };
index c80ed0482649c4ca92452c0ecd16fe6ccb89c48c..ec36b91c880f4ab609bd420949cf9c04c6f645a5 100644 (file)
@@ -1254,28 +1254,6 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
        return sdev->queue_depth;
 }
 
-/**
- * _scsih_change_queue_type - changing device queue tag type
- * @sdev: scsi device struct
- * @tag_type: requested tag type
- *
- * Returns queue tag type.
- */
-static int
-_scsih_change_queue_type(struct scsi_device *sdev, int tag_type)
-{
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, tag_type);
-               if (tag_type)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               tag_type = 0;
-
-       return tag_type;
-}
-
 /**
  * _scsih_target_alloc - target add routine
  * @starget: scsi target struct
@@ -7653,7 +7631,7 @@ static struct scsi_host_template scsih_driver_template = {
        .scan_finished                  = _scsih_scan_finished,
        .scan_start                     = _scsih_scan_start,
        .change_queue_depth             = _scsih_change_queue_depth,
-       .change_queue_type              = _scsih_change_queue_type,
+       .change_queue_type              = scsi_change_queue_type,
        .eh_abort_handler               = _scsih_abort,
        .eh_device_reset_handler        = _scsih_dev_reset,
        .eh_target_reset_handler        = _scsih_target_reset,
index 857276b8880f4b94e8578bdc237cc9683d180c29..52464ace282b1858b00c64ac8581ead60eb11c29 100644 (file)
@@ -1122,29 +1122,6 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
        return sdev->queue_depth;
 }
 
-/**
- * _scsih_change_queue_type - changing device queue tag type
- * @sdev: scsi device struct
- * @tag_type: requested tag type
- *
- * Returns queue tag type.
- */
-static int
-_scsih_change_queue_type(struct scsi_device *sdev, int tag_type)
-{
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, tag_type);
-               if (tag_type)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               tag_type = 0;
-
-       return tag_type;
-}
-
-
 /**
  * _scsih_target_alloc - target add routine
  * @starget: scsi target struct
@@ -7284,7 +7261,7 @@ static struct scsi_host_template scsih_driver_template = {
        .scan_finished                  = _scsih_scan_finished,
        .scan_start                     = _scsih_scan_start,
        .change_queue_depth             = _scsih_change_queue_depth,
-       .change_queue_type              = _scsih_change_queue_type,
+       .change_queue_type              = scsi_change_queue_type,
        .eh_abort_handler               = _scsih_abort,
        .eh_device_reset_handler        = _scsih_dev_reset,
        .eh_target_reset_handler        = _scsih_target_reset,
index bcb64eb1387f0565976449eb9a45941ec7186514..2233ed6b89e394f24a4db1559934ef0274d591e4 100644 (file)
@@ -321,16 +321,10 @@ static int pmcraid_change_queue_type(struct scsi_device *scsi_dev, int tag)
        struct pmcraid_resource_entry *res;
 
        res = (struct pmcraid_resource_entry *)scsi_dev->hostdata;
-
-       if ((res) && scsi_dev->tagged_supported &&
-           (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry))) {
-               scsi_set_tag_type(scsi_dev, tag);
-
-               if (tag)
-                       scsi_activate_tcq(scsi_dev, scsi_dev->queue_depth);
-               else
-                       scsi_deactivate_tcq(scsi_dev, scsi_dev->queue_depth);
-       } else
+       if (res && scsi_dev->tagged_supported &&
+           (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry)))
+               tag = scsi_change_queue_type(scsi_dev, tag);
+       else
                tag = 0;
 
        return tag;
index db3dbd999cb6b1aec722c7ead94769d8eebb91a4..5e755747e073188601a2194b7eb728b18ebb4303 100644 (file)
@@ -237,7 +237,6 @@ static int qla2xxx_eh_bus_reset(struct scsi_cmnd *);
 static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
 
 static int qla2x00_change_queue_depth(struct scsi_device *, int, int);
-static int qla2x00_change_queue_type(struct scsi_device *, int);
 static void qla2x00_clear_drv_active(struct qla_hw_data *);
 static void qla2x00_free_device(scsi_qla_host_t *);
 static void qla83xx_disable_laser(scsi_qla_host_t *vha);
@@ -260,7 +259,7 @@ struct scsi_host_template qla2xxx_driver_template = {
        .scan_finished          = qla2xxx_scan_finished,
        .scan_start             = qla2xxx_scan_start,
        .change_queue_depth     = qla2x00_change_queue_depth,
-       .change_queue_type      = qla2x00_change_queue_type,
+       .change_queue_type      = scsi_change_queue_type,
        .this_id                = -1,
        .cmd_per_lun            = 3,
        .use_clustering         = ENABLE_CLUSTERING,
@@ -1473,21 +1472,6 @@ qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
        return sdev->queue_depth;
 }
 
-static int
-qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type)
-{
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, tag_type);
-               if (tag_type)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               tag_type = 0;
-
-       return tag_type;
-}
-
 /**
  * qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
  * @ha: HA context
index bc52bbd973813c6cd73da0f7d7d5f3457d8d3715..9baeff03dd9b01e4bfa608688022f6ac2422762c 100644 (file)
@@ -866,6 +866,26 @@ int scsi_track_queue_full(struct scsi_device *sdev, int depth)
 }
 EXPORT_SYMBOL(scsi_track_queue_full);
 
+/**
+ * scsi_change_queue_type() - Change a device's queue type
+ * @sdev:     The SCSI device whose queue depth is to change
+ * @tag_type: Identifier for queue type
+ */
+int scsi_change_queue_type(struct scsi_device *sdev, int tag_type)
+{
+       if (sdev->tagged_supported) {
+               scsi_set_tag_type(sdev, tag_type);
+               if (tag_type)
+                       scsi_activate_tcq(sdev, sdev->queue_depth);
+               else
+                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
+       } else
+               tag_type = 0;
+
+       return tag_type;
+}
+EXPORT_SYMBOL(scsi_change_queue_type);
+
 /**
  * scsi_vpd_inquiry - Request a device provide us with a VPD page
  * @sdev: The device to ask
index 238e06f13b8a1c977146699d95f1783bbef571e7..7bcace2cdd53af18d8eaf92777cac1fa097696d9 100644 (file)
@@ -4532,14 +4532,7 @@ sdebug_change_qdepth(struct scsi_device *sdev, int qdepth, int reason)
 static int
 sdebug_change_qtype(struct scsi_device *sdev, int qtype)
 {
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, qtype);
-               if (qtype)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               qtype = 0;
+       qtype = scsi_change_queue_type(sdev, qtype);
        if (SCSI_DEBUG_OPT_Q_NOISE & scsi_debug_opts) {
                const char *cp;
 
index ab3ab27d49b7b0ef4114cf741eb5524c07564195..3b9c76835b4525cae1f0b3c138fff3ba835303f9 100644 (file)
@@ -135,21 +135,6 @@ static int tcm_loop_change_queue_depth(
        return sdev->queue_depth;
 }
 
-static int tcm_loop_change_queue_type(struct scsi_device *sdev, int tag)
-{
-       if (sdev->tagged_supported) {
-               scsi_set_tag_type(sdev, tag);
-
-               if (tag)
-                       scsi_activate_tcq(sdev, sdev->queue_depth);
-               else
-                       scsi_deactivate_tcq(sdev, sdev->queue_depth);
-       } else
-               tag = 0;
-
-       return tag;
-}
-
 /*
  * Locate the SAM Task Attr from struct scsi_cmnd *
  */
@@ -451,7 +436,7 @@ static struct scsi_host_template tcm_loop_driver_template = {
        .name                   = "TCM_Loopback",
        .queuecommand           = tcm_loop_queuecommand,
        .change_queue_depth     = tcm_loop_change_queue_depth,
-       .change_queue_type      = tcm_loop_change_queue_type,
+       .change_queue_type      = scsi_change_queue_type,
        .eh_abort_handler = tcm_loop_abort_task,
        .eh_device_reset_handler = tcm_loop_device_reset,
        .eh_target_reset_handler = tcm_loop_target_reset,
index 52beadf9a29be89592d41b6400c8e8d5d34e6036..2e0cf568a9c14e21463ba195e5b49f38c0e00951 100644 (file)
@@ -1106,7 +1106,6 @@ int fc_eh_device_reset(struct scsi_cmnd *);
 int fc_eh_host_reset(struct scsi_cmnd *);
 int fc_slave_alloc(struct scsi_device *);
 int fc_change_queue_depth(struct scsi_device *, int qdepth, int reason);
-int fc_change_queue_type(struct scsi_device *, int tag_type);
 
 /*
  * ELS/CT interface
index 7529c6acc231d81765ed82c06ef67c85988e12e7..1712dab6e00e4f05ef7f5f4149057abfbe56ce94 100644 (file)
@@ -16,6 +16,8 @@
 
 #ifdef CONFIG_BLOCK
 
+int scsi_change_queue_type(struct scsi_device *sdev, int tag_type);
+
 /**
  * scsi_get_tag_type - get the type of tag the device supports
  * @sdev:      the scsi device