Skip to content

Commit

Permalink
scsi: provide a generic change_queue_type method
Browse files Browse the repository at this point in the history
Most drivers use exactly the same implementation, so provide it as a
library function.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
Reviewed-by: Mike Christie <[email protected]>
Reviewed-by: Martin K. Petersen <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
  • Loading branch information
Christoph Hellwig committed Nov 12, 2014
1 parent 1d52032 commit a62182f
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 228 deletions.
24 changes: 1 addition & 23 deletions drivers/infiniband/ulp/srp/ib_srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/bnx2fc/bnx2fc_fcoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion drivers/scsi/esas2r/esas2r.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
20 changes: 1 addition & 19 deletions drivers/scsi/esas2r/esas2r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/fcoe/fcoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/fnic/fnic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 1 addition & 24 deletions drivers/scsi/ibmvscsi/ibmvfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 3 additions & 17 deletions drivers/scsi/ipr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 0 additions & 20 deletions drivers/scsi/libfc/fc_fcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 2 additions & 22 deletions drivers/scsi/lpfc/lpfc_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 = {
Expand All @@ -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,
};
24 changes: 1 addition & 23 deletions drivers/scsi/mpt2sas/mpt2sas_scsih.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 1 addition & 24 deletions drivers/scsi/mpt3sas/mpt3sas_scsih.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 4 additions & 10 deletions drivers/scsi/pmcraid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 1 addition & 17 deletions drivers/scsi/qla2xxx/qla_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit a62182f

Please sign in to comment.