Commit af16cd63 authored by Mike Christie's avatar Mike Christie Committed by Martin K. Petersen

scsi: sd: Convert to scsi_execute_cmd()

scsi_execute*() is going to be removed. Convert sd_mod to use
scsi_execute_cmd().
Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c9ee828a
...@@ -664,6 +664,9 @@ static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, ...@@ -664,6 +664,9 @@ static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
struct scsi_disk *sdkp = data; struct scsi_disk *sdkp = data;
struct scsi_device *sdev = sdkp->device; struct scsi_device *sdev = sdkp->device;
u8 cdb[12] = { 0, }; u8 cdb[12] = { 0, };
const struct scsi_exec_args exec_args = {
.req_flags = BLK_MQ_REQ_PM,
};
int ret; int ret;
cdb[0] = send ? SECURITY_PROTOCOL_OUT : SECURITY_PROTOCOL_IN; cdb[0] = send ? SECURITY_PROTOCOL_OUT : SECURITY_PROTOCOL_IN;
...@@ -671,9 +674,9 @@ static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, ...@@ -671,9 +674,9 @@ static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
put_unaligned_be16(spsp, &cdb[2]); put_unaligned_be16(spsp, &cdb[2]);
put_unaligned_be32(len, &cdb[6]); put_unaligned_be32(len, &cdb[6]);
ret = scsi_execute(sdev, cdb, send ? DMA_TO_DEVICE : DMA_FROM_DEVICE, ret = scsi_execute_cmd(sdev, cdb, send ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
buffer, len, NULL, NULL, SD_TIMEOUT, sdkp->max_retries, 0, buffer, len, SD_TIMEOUT, sdkp->max_retries,
RQF_PM, NULL); &exec_args);
return ret <= 0 ? ret : -EIO; return ret <= 0 ? ret : -EIO;
} }
#endif /* CONFIG_BLK_SED_OPAL */ #endif /* CONFIG_BLK_SED_OPAL */
...@@ -1583,13 +1586,16 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) ...@@ -1583,13 +1586,16 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
const int timeout = sdp->request_queue->rq_timeout const int timeout = sdp->request_queue->rq_timeout
* SD_FLUSH_TIMEOUT_MULTIPLIER; * SD_FLUSH_TIMEOUT_MULTIPLIER;
struct scsi_sense_hdr my_sshdr; struct scsi_sense_hdr my_sshdr;
const struct scsi_exec_args exec_args = {
.req_flags = BLK_MQ_REQ_PM,
/* caller might not be interested in sense, but we need it */
.sshdr = sshdr ? : &my_sshdr,
};
if (!scsi_device_online(sdp)) if (!scsi_device_online(sdp))
return -ENODEV; return -ENODEV;
/* caller might not be interested in sense, but we need it */ sshdr = exec_args.sshdr;
if (!sshdr)
sshdr = &my_sshdr;
for (retries = 3; retries > 0; --retries) { for (retries = 3; retries > 0; --retries) {
unsigned char cmd[16] = { 0 }; unsigned char cmd[16] = { 0 };
...@@ -1602,8 +1608,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) ...@@ -1602,8 +1608,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
* Leave the rest of the command zero to indicate * Leave the rest of the command zero to indicate
* flush everything. * flush everything.
*/ */
res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, sshdr, res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0,
timeout, sdkp->max_retries, 0, RQF_PM, NULL); timeout, sdkp->max_retries, &exec_args);
if (res == 0) if (res == 0)
break; break;
} }
...@@ -1745,6 +1751,9 @@ static int sd_pr_command(struct block_device *bdev, u8 sa, ...@@ -1745,6 +1751,9 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk);
struct scsi_device *sdev = sdkp->device; struct scsi_device *sdev = sdkp->device;
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
};
int result; int result;
u8 cmd[16] = { 0, }; u8 cmd[16] = { 0, };
u8 data[24] = { 0, }; u8 data[24] = { 0, };
...@@ -1758,8 +1767,9 @@ static int sd_pr_command(struct block_device *bdev, u8 sa, ...@@ -1758,8 +1767,9 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
put_unaligned_be64(sa_key, &data[8]); put_unaligned_be64(sa_key, &data[8]);
data[20] = flags; data[20] = flags;
result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data), result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, &data,
&sshdr, SD_TIMEOUT, sdkp->max_retries, NULL); sizeof(data), SD_TIMEOUT, sdkp->max_retries,
&exec_args);
if (scsi_status_is_check_condition(result) && if (scsi_status_is_check_condition(result) &&
scsi_sense_valid(&sshdr)) { scsi_sense_valid(&sshdr)) {
...@@ -2088,6 +2098,9 @@ sd_spinup_disk(struct scsi_disk *sdkp) ...@@ -2088,6 +2098,9 @@ sd_spinup_disk(struct scsi_disk *sdkp)
int retries, spintime; int retries, spintime;
unsigned int the_result; unsigned int the_result;
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
};
int sense_valid = 0; int sense_valid = 0;
spintime = 0; spintime = 0;
...@@ -2103,10 +2116,11 @@ sd_spinup_disk(struct scsi_disk *sdkp) ...@@ -2103,10 +2116,11 @@ sd_spinup_disk(struct scsi_disk *sdkp)
cmd[0] = TEST_UNIT_READY; cmd[0] = TEST_UNIT_READY;
memset((void *) &cmd[1], 0, 9); memset((void *) &cmd[1], 0, 9);
the_result = scsi_execute_req(sdkp->device, cmd, the_result = scsi_execute_cmd(sdkp->device, cmd,
DMA_NONE, NULL, 0, REQ_OP_DRV_IN, NULL, 0,
&sshdr, SD_TIMEOUT, SD_TIMEOUT,
sdkp->max_retries, NULL); sdkp->max_retries,
&exec_args);
/* /*
* If the drive has indicated to us that it * If the drive has indicated to us that it
...@@ -2163,10 +2177,10 @@ sd_spinup_disk(struct scsi_disk *sdkp) ...@@ -2163,10 +2177,10 @@ sd_spinup_disk(struct scsi_disk *sdkp)
cmd[4] = 1; /* Start spin cycle */ cmd[4] = 1; /* Start spin cycle */
if (sdkp->device->start_stop_pwr_cond) if (sdkp->device->start_stop_pwr_cond)
cmd[4] |= 1 << 4; cmd[4] |= 1 << 4;
scsi_execute_req(sdkp->device, cmd, DMA_NONE, scsi_execute_cmd(sdkp->device, cmd,
NULL, 0, &sshdr, REQ_OP_DRV_IN, NULL, 0,
SD_TIMEOUT, sdkp->max_retries, SD_TIMEOUT, sdkp->max_retries,
NULL); &exec_args);
spintime_expire = jiffies + 100 * HZ; spintime_expire = jiffies + 100 * HZ;
spintime = 1; spintime = 1;
} }
...@@ -2296,6 +2310,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, ...@@ -2296,6 +2310,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
{ {
unsigned char cmd[16]; unsigned char cmd[16];
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
};
int sense_valid = 0; int sense_valid = 0;
int the_result; int the_result;
int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET; int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET;
...@@ -2313,9 +2330,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, ...@@ -2313,9 +2330,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
cmd[13] = RC16_LEN; cmd[13] = RC16_LEN;
memset(buffer, 0, RC16_LEN); memset(buffer, 0, RC16_LEN);
the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN,
buffer, RC16_LEN, &sshdr, buffer, RC16_LEN, SD_TIMEOUT,
SD_TIMEOUT, sdkp->max_retries, NULL); sdkp->max_retries, &exec_args);
if (media_not_present(sdkp, &sshdr)) if (media_not_present(sdkp, &sshdr))
return -ENODEV; return -ENODEV;
...@@ -2387,6 +2404,9 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, ...@@ -2387,6 +2404,9 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
{ {
unsigned char cmd[16]; unsigned char cmd[16];
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
};
int sense_valid = 0; int sense_valid = 0;
int the_result; int the_result;
int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET; int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET;
...@@ -2398,9 +2418,9 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, ...@@ -2398,9 +2418,9 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
memset(&cmd[1], 0, 9); memset(&cmd[1], 0, 9);
memset(buffer, 0, 8); memset(buffer, 0, 8);
the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer,
buffer, 8, &sshdr, 8, SD_TIMEOUT, sdkp->max_retries,
SD_TIMEOUT, sdkp->max_retries, NULL); &exec_args);
if (media_not_present(sdkp, &sshdr)) if (media_not_present(sdkp, &sshdr))
return -ENODEV; return -ENODEV;
...@@ -3637,6 +3657,10 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start) ...@@ -3637,6 +3657,10 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
{ {
unsigned char cmd[6] = { START_STOP }; /* START_VALID */ unsigned char cmd[6] = { START_STOP }; /* START_VALID */
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
.req_flags = BLK_MQ_REQ_PM,
};
struct scsi_device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
int res; int res;
...@@ -3649,8 +3673,8 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start) ...@@ -3649,8 +3673,8 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
if (!scsi_device_online(sdp)) if (!scsi_device_online(sdp))
return -ENODEV; return -ENODEV;
res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, SD_TIMEOUT,
SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL); sdkp->max_retries, &exec_args);
if (res) { if (res) {
sd_print_result(sdkp, "Start/Stop Unit failed", res); sd_print_result(sdkp, "Start/Stop Unit failed", res);
if (res > 0 && scsi_sense_valid(&sshdr)) { if (res > 0 && scsi_sense_valid(&sshdr)) {
...@@ -3790,10 +3814,13 @@ static int sd_resume_runtime(struct device *dev) ...@@ -3790,10 +3814,13 @@ static int sd_resume_runtime(struct device *dev)
if (sdp->ignore_media_change) { if (sdp->ignore_media_change) {
/* clear the device's sense data */ /* clear the device's sense data */
static const u8 cmd[10] = { REQUEST_SENSE }; static const u8 cmd[10] = { REQUEST_SENSE };
const struct scsi_exec_args exec_args = {
.req_flags = BLK_MQ_REQ_PM,
};
if (scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, if (scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0,
NULL, sdp->request_queue->rq_timeout, 1, 0, sdp->request_queue->rq_timeout, 1,
RQF_PM, NULL)) &exec_args))
sd_printk(KERN_NOTICE, sdkp, sd_printk(KERN_NOTICE, sdkp,
"Failed to clear sense data\n"); "Failed to clear sense data\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment