* [PATCH v3 00/15] scsi: Add struct for args to execution functions
@ 2022-12-14 23:49 Mike Christie
2022-12-14 23:49 ` [PATCH v3 01/15] " Mike Christie
` (14 more replies)
0 siblings, 15 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
The following patches were made over Martin's scsi staging/next branch.
They add a struct that contains optinal arguments to the scsi_execute*
functions. This will be needed for the patches that allow the scsi
passthrough users to control retries because I'm adding a new optional
argument. I separated the 2 sets to make it easier to review and post.
v3:
- Init scsi_exec_args user's sshdr as "sshdr = sshdr ? : local".
- Use just one sense_len check and remove the scsi_execute_args wrapper.
- Just use one scsi_execute_cmd function and have it check if the args
is NULL else use a local one.
- Pass exec_args by pointer.
v2:
- Fix RQF_QUIET use.
- Use the more standard way of passing in a struct for passing in
the scsi_exec_args struct.
- Pass a struct scsi_exec_args instead of pointer and add another
macro for the case the caller doesn't want to pass in a scsi_exec_args
struct. Then remove the NULL args check in __scsi_execute.
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v3 01/15] scsi: Add struct for args to execution functions
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-15 1:13 ` Bart Van Assche
` (2 more replies)
2022-12-14 23:49 ` [PATCH v3 02/15] ata: libata-scsi: Convert to scsi_execute_cmd Mike Christie
` (13 subsequent siblings)
14 siblings, 3 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
This begins to move the SCSI execution functions to use a struct for
passing in optional args. This patch adds the new struct, temporarily
converts scsi_execute and scsi_execute_req ands a new helper,
scsi_execute_cmd, which takes the scsi_exec_args struct.
There should be no change in behavior. We no longer alilow users to pass
in any request->rq_flags valu, but they were only passing in RQF_QUIET
which we do support by allowing users to pass in the BLK_MQ_REQ flags used
by blk_mq_alloc_request.
The next patches will convert scsi_execute and scsi_execute_req users to
the new helpers then remove scsi_execute and scsi_execute_req.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
drivers/scsi/scsi_lib.c | 52 ++++++++++++++++++--------------------
include/scsi/scsi_device.h | 51 +++++++++++++++++++++++++++----------
2 files changed, 62 insertions(+), 41 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index a29d87e57430..7baad7ec8887 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -185,39 +185,37 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
__scsi_queue_insert(cmd, reason, true);
}
-
/**
- * __scsi_execute - insert request and wait for the result
- * @sdev: scsi device
+ * scsi_execute_cmd - insert request and wait for the result
+ * @sdev: scsi_device
* @cmd: scsi command
- * @data_direction: data direction
+ * @opf: block layer request cmd_flags
* @buffer: data buffer
* @bufflen: len of buffer
- * @sense: optional sense buffer
- * @sshdr: optional decoded sense header
* @timeout: request timeout in HZ
* @retries: number of times to retry request
- * @flags: flags for ->cmd_flags
- * @rq_flags: flags for ->rq_flags
- * @resid: optional residual length
+ * @args: Optional args. See struct definition for field descriptions
*
* Returns the scsi_cmnd result field if a command was executed, or a negative
* Linux error code if we didn't get that far.
*/
-int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
- int data_direction, void *buffer, unsigned bufflen,
- unsigned char *sense, struct scsi_sense_hdr *sshdr,
- int timeout, int retries, blk_opf_t flags,
- req_flags_t rq_flags, int *resid)
+int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd,
+ blk_opf_t opf, void *buffer, unsigned int bufflen,
+ int timeout, int retries,
+ const struct scsi_exec_args *args)
{
+ static const struct scsi_exec_args default_args;
struct request *req;
struct scsi_cmnd *scmd;
int ret;
- req = scsi_alloc_request(sdev->request_queue,
- data_direction == DMA_TO_DEVICE ?
- REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
- rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0);
+ if (!args)
+ args = &default_args;
+ else if (WARN_ON_ONCE(args->sense &&
+ args->sense_len != SCSI_SENSE_BUFFERSIZE))
+ return -EINVAL;
+
+ req = scsi_alloc_request(sdev->request_queue, opf, args->req_flags);
if (IS_ERR(req))
return PTR_ERR(req);
@@ -232,8 +230,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
memcpy(scmd->cmnd, cmd, scmd->cmd_len);
scmd->allowed = retries;
req->timeout = timeout;
- req->cmd_flags |= flags;
- req->rq_flags |= rq_flags | RQF_QUIET;
+ req->rq_flags |= RQF_QUIET;
/*
* head injection *required* here otherwise quiesce won't work
@@ -249,20 +246,21 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
if (unlikely(scmd->resid_len > 0 && scmd->resid_len <= bufflen))
memset(buffer + bufflen - scmd->resid_len, 0, scmd->resid_len);
- if (resid)
- *resid = scmd->resid_len;
- if (sense && scmd->sense_len)
- memcpy(sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
- if (sshdr)
+ if (args->resid)
+ *args->resid = scmd->resid_len;
+ if (args->sense)
+ memcpy(args->sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
+ if (args->sshdr)
scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len,
- sshdr);
+ args->sshdr);
+
ret = scmd->result;
out:
blk_mq_free_request(req);
return ret;
}
-EXPORT_SYMBOL(__scsi_execute);
+EXPORT_SYMBOL(scsi_execute_cmd);
/*
* Wake up the error handler if necessary. Avoid as follows that the error
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 3642b8e3928b..f6b33c6c1064 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -455,28 +455,51 @@ extern const char *scsi_device_state_name(enum scsi_device_state);
extern int scsi_is_sdev_device(const struct device *);
extern int scsi_is_target_device(const struct device *);
extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);
-extern int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
- int data_direction, void *buffer, unsigned bufflen,
- unsigned char *sense, struct scsi_sense_hdr *sshdr,
- int timeout, int retries, blk_opf_t flags,
- req_flags_t rq_flags, int *resid);
+
+/* Optional arguments to scsi_execute_cmd */
+struct scsi_exec_args {
+ unsigned char *sense; /* sense buffer */
+ unsigned int sense_len; /* sense buffer len */
+ struct scsi_sense_hdr *sshdr; /* decoded sense header */
+ blk_mq_req_flags_t req_flags; /* BLK_MQ_REQ flags */
+ int *resid; /* residual length */
+};
+
+int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd,
+ blk_opf_t opf, void *buffer, unsigned int bufflen,
+ int timeout, int retries,
+ const struct scsi_exec_args *args);
+
/* Make sure any sense buffer is the correct size. */
-#define scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \
- sshdr, timeout, retries, flags, rq_flags, resid) \
+#define scsi_execute(_sdev, _cmd, _data_dir, _buffer, _bufflen, _sense, \
+ _sshdr, _timeout, _retries, _flags, _rq_flags, \
+ _resid) \
({ \
- BUILD_BUG_ON((sense) != NULL && \
- sizeof(sense) != SCSI_SENSE_BUFFERSIZE); \
- __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, \
- sense, sshdr, timeout, retries, flags, rq_flags, \
- resid); \
+ scsi_execute_cmd(_sdev, _cmd, (_data_dir == DMA_TO_DEVICE ? \
+ REQ_OP_DRV_OUT : REQ_OP_DRV_IN) | _flags, \
+ _buffer, _bufflen, _timeout, _retries, \
+ &(struct scsi_exec_args) { \
+ .sense = _sense, \
+ .sshdr = _sshdr, \
+ .req_flags = _rq_flags & RQF_PM ? \
+ BLK_MQ_REQ_PM : 0, \
+ .resid = _resid, \
+ }); \
})
+
static inline int scsi_execute_req(struct scsi_device *sdev,
const unsigned char *cmd, int data_direction, void *buffer,
unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout,
int retries, int *resid)
{
- return scsi_execute(sdev, cmd, data_direction, buffer,
- bufflen, NULL, sshdr, timeout, retries, 0, 0, resid);
+ return scsi_execute_cmd(sdev, cmd,
+ data_direction == DMA_TO_DEVICE ?
+ REQ_OP_DRV_OUT : REQ_OP_DRV_IN, buffer,
+ bufflen, timeout, retries,
+ &(struct scsi_exec_args) {
+ .sshdr = sshdr,
+ .resid = resid,
+ });
}
extern void sdev_disable_disk_events(struct scsi_device *sdev);
extern void sdev_enable_disk_events(struct scsi_device *sdev);
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 02/15] ata: libata-scsi: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
2022-12-14 23:49 ` [PATCH v3 01/15] " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-14 23:49 ` [PATCH v3 03/15] hwmon: drivetemp: " Mike Christie
` (12 subsequent siblings)
14 siblings, 0 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie, Damien Le Moal
scsi_execute_req is going to be removed. Convert libata to
scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
drivers/ata/libata-scsi.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 06a3d95ed8f9..d143d80b1f03 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -367,8 +367,12 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
u8 scsi_cmd[MAX_COMMAND_SIZE];
u8 args[4], *argbuf = NULL;
int argsize = 0;
- enum dma_data_direction data_dir;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ .sense = sensebuf,
+ .sense_len = sizeof(sensebuf),
+ };
int cmd_result;
if (arg == NULL)
@@ -391,11 +395,9 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
scsi_cmd[1] = (4 << 1); /* PIO Data-in */
scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev,
block count in sector count field */
- data_dir = DMA_FROM_DEVICE;
} else {
scsi_cmd[1] = (3 << 1); /* Non-data */
scsi_cmd[2] = 0x20; /* cc but no off.line or data xfer */
- data_dir = DMA_NONE;
}
scsi_cmd[0] = ATA_16;
@@ -413,9 +415,8 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
/* Good values for timeout and retries? Values below
from scsi_ioctl_send_command() for default case... */
- cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
- sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);
-
+ cmd_result = scsi_execute_cmd(scsidev, scsi_cmd, REQ_OP_DRV_IN, argbuf,
+ argsize, 10 * HZ, 5, &exec_args);
if (cmd_result < 0) {
rc = cmd_result;
goto error;
@@ -475,6 +476,11 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
u8 args[7];
struct scsi_sense_hdr sshdr;
int cmd_result;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ .sense = sensebuf,
+ .sense_len = sizeof(sensebuf),
+ };
if (arg == NULL)
return -EINVAL;
@@ -497,9 +503,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
/* Good values for timeout and retries? Values below
from scsi_ioctl_send_command() for default case... */
- cmd_result = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0,
- sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);
-
+ cmd_result = scsi_execute_cmd(scsidev, scsi_cmd, REQ_OP_DRV_IN, NULL,
+ 0, 10 * HZ, 5, &exec_args);
if (cmd_result < 0) {
rc = cmd_result;
goto error;
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 03/15] hwmon: drivetemp: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
2022-12-14 23:49 ` [PATCH v3 01/15] " Mike Christie
2022-12-14 23:49 ` [PATCH v3 02/15] ata: libata-scsi: Convert to scsi_execute_cmd Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-14 23:49 ` [PATCH v3 04/15] scsi: ch: " Mike Christie
` (11 subsequent siblings)
14 siblings, 0 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute_req is going to be removed. Convert drivetemp to
scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/hwmon/drivetemp.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c
index 5bac2b0fc7bb..8e5759b42390 100644
--- a/drivers/hwmon/drivetemp.c
+++ b/drivers/hwmon/drivetemp.c
@@ -164,7 +164,7 @@ static int drivetemp_scsi_command(struct drivetemp_data *st,
u8 lba_low, u8 lba_mid, u8 lba_high)
{
u8 scsi_cmd[MAX_COMMAND_SIZE];
- int data_dir;
+ enum req_op op;
memset(scsi_cmd, 0, sizeof(scsi_cmd));
scsi_cmd[0] = ATA_16;
@@ -175,7 +175,7 @@ static int drivetemp_scsi_command(struct drivetemp_data *st,
* field.
*/
scsi_cmd[2] = 0x06;
- data_dir = DMA_TO_DEVICE;
+ op = REQ_OP_DRV_OUT;
} else {
scsi_cmd[1] = (4 << 1); /* PIO Data-in */
/*
@@ -183,7 +183,7 @@ static int drivetemp_scsi_command(struct drivetemp_data *st,
* field.
*/
scsi_cmd[2] = 0x0e;
- data_dir = DMA_FROM_DEVICE;
+ op = REQ_OP_DRV_IN;
}
scsi_cmd[4] = feature;
scsi_cmd[6] = 1; /* 1 sector */
@@ -192,9 +192,8 @@ static int drivetemp_scsi_command(struct drivetemp_data *st,
scsi_cmd[12] = lba_high;
scsi_cmd[14] = ata_command;
- return scsi_execute_req(st->sdev, scsi_cmd, data_dir,
- st->smartdata, ATA_SECT_SIZE, NULL, HZ, 5,
- NULL);
+ return scsi_execute_cmd(st->sdev, scsi_cmd, op, st->smartdata,
+ ATA_SECT_SIZE, HZ, 5, NULL);
}
static int drivetemp_ata_command(struct drivetemp_data *st, u8 feature,
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 04/15] scsi: ch: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (2 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 03/15] hwmon: drivetemp: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-14 23:49 ` [PATCH v3 05/15] scsi: scsi_dh: " Mike Christie
` (10 subsequent siblings)
14 siblings, 0 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute_req is going to be removed. Convert ch to scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/ch.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 7ab29eaec6f3..72fe6df78bc5 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -184,20 +184,21 @@ static int ch_find_errno(struct scsi_sense_hdr *sshdr)
static int
ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
- void *buffer, unsigned buflength,
- enum dma_data_direction direction)
+ void *buffer, unsigned int buflength, enum req_op op)
{
int errno, retries = 0, timeout, result;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
? timeout_init : timeout_move;
retry:
errno = 0;
- result = scsi_execute_req(ch->device, cmd, direction, buffer,
- buflength, &sshdr, timeout * HZ,
- MAX_RETRIES, NULL);
+ result = scsi_execute_cmd(ch->device, cmd, op, buffer, buflength,
+ timeout * HZ, MAX_RETRIES, &exec_args);
if (result < 0)
return result;
if (scsi_sense_valid(&sshdr)) {
@@ -254,7 +255,7 @@ ch_read_element_status(scsi_changer *ch, u_int elem, char *data)
cmd[5] = 1;
cmd[9] = 255;
if (0 == (result = ch_do_scsi(ch, cmd, 12,
- buffer, 256, DMA_FROM_DEVICE))) {
+ buffer, 256, REQ_OP_DRV_IN))) {
if (((buffer[16] << 8) | buffer[17]) != elem) {
DPRINTK("asked for element 0x%02x, got 0x%02x\n",
elem,(buffer[16] << 8) | buffer[17]);
@@ -284,7 +285,7 @@ ch_init_elem(scsi_changer *ch)
memset(cmd,0,sizeof(cmd));
cmd[0] = INITIALIZE_ELEMENT_STATUS;
cmd[1] = (ch->device->lun & 0x7) << 5;
- err = ch_do_scsi(ch, cmd, 6, NULL, 0, DMA_NONE);
+ err = ch_do_scsi(ch, cmd, 6, NULL, 0, REQ_OP_DRV_IN);
VPRINTK(KERN_INFO, "... finished\n");
return err;
}
@@ -306,10 +307,10 @@ ch_readconfig(scsi_changer *ch)
cmd[1] = (ch->device->lun & 0x7) << 5;
cmd[2] = 0x1d;
cmd[4] = 255;
- result = ch_do_scsi(ch, cmd, 10, buffer, 255, DMA_FROM_DEVICE);
+ result = ch_do_scsi(ch, cmd, 10, buffer, 255, REQ_OP_DRV_IN);
if (0 != result) {
cmd[1] |= (1<<3);
- result = ch_do_scsi(ch, cmd, 10, buffer, 255, DMA_FROM_DEVICE);
+ result = ch_do_scsi(ch, cmd, 10, buffer, 255, REQ_OP_DRV_IN);
}
if (0 == result) {
ch->firsts[CHET_MT] =
@@ -434,7 +435,7 @@ ch_position(scsi_changer *ch, u_int trans, u_int elem, int rotate)
cmd[4] = (elem >> 8) & 0xff;
cmd[5] = elem & 0xff;
cmd[8] = rotate ? 1 : 0;
- return ch_do_scsi(ch, cmd, 10, NULL, 0, DMA_NONE);
+ return ch_do_scsi(ch, cmd, 10, NULL, 0, REQ_OP_DRV_IN);
}
static int
@@ -455,7 +456,7 @@ ch_move(scsi_changer *ch, u_int trans, u_int src, u_int dest, int rotate)
cmd[6] = (dest >> 8) & 0xff;
cmd[7] = dest & 0xff;
cmd[10] = rotate ? 1 : 0;
- return ch_do_scsi(ch, cmd, 12, NULL,0, DMA_NONE);
+ return ch_do_scsi(ch, cmd, 12, NULL, 0, REQ_OP_DRV_IN);
}
static int
@@ -481,7 +482,7 @@ ch_exchange(scsi_changer *ch, u_int trans, u_int src,
cmd[9] = dest2 & 0xff;
cmd[10] = (rotate1 ? 1 : 0) | (rotate2 ? 2 : 0);
- return ch_do_scsi(ch, cmd, 12, NULL, 0, DMA_NONE);
+ return ch_do_scsi(ch, cmd, 12, NULL, 0, REQ_OP_DRV_IN);
}
static void
@@ -531,7 +532,7 @@ ch_set_voltag(scsi_changer *ch, u_int elem,
memcpy(buffer,tag,32);
ch_check_voltag(buffer);
- result = ch_do_scsi(ch, cmd, 12, buffer, 256, DMA_TO_DEVICE);
+ result = ch_do_scsi(ch, cmd, 12, buffer, 256, REQ_OP_DRV_OUT);
kfree(buffer);
return result;
}
@@ -799,8 +800,7 @@ static long ch_ioctl(struct file *file,
ch_cmd[5] = 1;
ch_cmd[9] = 255;
- result = ch_do_scsi(ch, ch_cmd, 12,
- buffer, 256, DMA_FROM_DEVICE);
+ result = ch_do_scsi(ch, ch_cmd, 12, buffer, 256, REQ_OP_DRV_IN);
if (!result) {
cge.cge_status = buffer[18];
cge.cge_flags = 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 05/15] scsi: scsi_dh: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (3 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 04/15] scsi: ch: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-14 23:49 ` [PATCH v3 06/15] scsi: core: " Mike Christie
` (9 subsequent siblings)
14 siblings, 0 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute is going to be removed. Convert the scsi_dh users to
scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/device_handler/scsi_dh_alua.c | 26 +++++++++++++--------
drivers/scsi/device_handler/scsi_dh_emc.c | 13 +++++++----
drivers/scsi/device_handler/scsi_dh_hp_sw.c | 22 ++++++++++-------
drivers/scsi/device_handler/scsi_dh_rdac.c | 12 ++++++----
4 files changed, 45 insertions(+), 28 deletions(-)
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 49cc18a87473..55a5073248f8 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -127,8 +127,11 @@ static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff,
int bufflen, struct scsi_sense_hdr *sshdr, int flags)
{
u8 cdb[MAX_COMMAND_SIZE];
- blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
- REQ_FAILFAST_DRIVER;
+ blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV |
+ REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = sshdr,
+ };
/* Prepare the command. */
memset(cdb, 0x0, MAX_COMMAND_SIZE);
@@ -139,9 +142,9 @@ static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff,
cdb[1] = MI_REPORT_TARGET_PGS;
put_unaligned_be32(bufflen, &cdb[6]);
- return scsi_execute(sdev, cdb, DMA_FROM_DEVICE, buff, bufflen, NULL,
- sshdr, ALUA_FAILOVER_TIMEOUT * HZ,
- ALUA_FAILOVER_RETRIES, req_flags, 0, NULL);
+ return scsi_execute_cmd(sdev, cdb, opf, buff, bufflen,
+ ALUA_FAILOVER_TIMEOUT * HZ,
+ ALUA_FAILOVER_RETRIES, &exec_args);
}
/*
@@ -157,8 +160,11 @@ static int submit_stpg(struct scsi_device *sdev, int group_id,
u8 cdb[MAX_COMMAND_SIZE];
unsigned char stpg_data[8];
int stpg_len = 8;
- blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
- REQ_FAILFAST_DRIVER;
+ blk_opf_t opf = REQ_OP_DRV_OUT | REQ_FAILFAST_DEV |
+ REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = sshdr,
+ };
/* Prepare the data buffer */
memset(stpg_data, 0, stpg_len);
@@ -171,9 +177,9 @@ static int submit_stpg(struct scsi_device *sdev, int group_id,
cdb[1] = MO_SET_TARGET_PGS;
put_unaligned_be32(stpg_len, &cdb[6]);
- return scsi_execute(sdev, cdb, DMA_TO_DEVICE, stpg_data, stpg_len, NULL,
- sshdr, ALUA_FAILOVER_TIMEOUT * HZ,
- ALUA_FAILOVER_RETRIES, req_flags, 0, NULL);
+ return scsi_execute_cmd(sdev, cdb, opf, stpg_data,
+ stpg_len, ALUA_FAILOVER_TIMEOUT * HZ,
+ ALUA_FAILOVER_RETRIES, &exec_args);
}
static struct alua_port_group *alua_find_get_pg(char *id_str, size_t id_size,
diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c
index 2e21ab447873..3cf88db2d5b2 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -239,8 +239,11 @@ static int send_trespass_cmd(struct scsi_device *sdev,
unsigned char cdb[MAX_COMMAND_SIZE];
int err, res = SCSI_DH_OK, len;
struct scsi_sense_hdr sshdr;
- blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
- REQ_FAILFAST_DRIVER;
+ blk_opf_t opf = REQ_OP_DRV_OUT | REQ_FAILFAST_DEV |
+ REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
if (csdev->flags & CLARIION_SHORT_TRESPASS) {
page22 = short_trespass;
@@ -263,9 +266,9 @@ static int send_trespass_cmd(struct scsi_device *sdev,
BUG_ON((len > CLARIION_BUFFER_SIZE));
memcpy(csdev->buffer, page22, len);
- err = scsi_execute(sdev, cdb, DMA_TO_DEVICE, csdev->buffer, len, NULL,
- &sshdr, CLARIION_TIMEOUT * HZ, CLARIION_RETRIES,
- req_flags, 0, NULL);
+ err = scsi_execute_cmd(sdev, cdb, opf, csdev->buffer, len,
+ CLARIION_TIMEOUT * HZ, CLARIION_RETRIES,
+ &exec_args);
if (err) {
if (scsi_sense_valid(&sshdr))
res = trespass_endio(sdev, &sshdr);
diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
index 0d2cfa60aa06..5f2f943d926c 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -83,12 +83,15 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
unsigned char cmd[6] = { TEST_UNIT_READY };
struct scsi_sense_hdr sshdr;
int ret = SCSI_DH_OK, res;
- blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
- REQ_FAILFAST_DRIVER;
+ blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV |
+ REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
retry:
- res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
- HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, NULL);
+ res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT,
+ HP_SW_RETRIES, &exec_args);
if (res) {
if (scsi_sense_valid(&sshdr))
ret = tur_done(sdev, h, &sshdr);
@@ -121,12 +124,15 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)
struct scsi_device *sdev = h->sdev;
int res, rc = SCSI_DH_OK;
int retry_cnt = HP_SW_RETRIES;
- blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
- REQ_FAILFAST_DRIVER;
+ blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV |
+ REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
retry:
- res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
- HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, NULL);
+ res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT,
+ HP_SW_RETRIES, &exec_args);
if (res) {
if (!scsi_sense_valid(&sshdr)) {
sdev_printk(KERN_WARNING, sdev,
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index bf8754741f85..c5538645057a 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -536,8 +536,11 @@ static void send_mode_select(struct work_struct *work)
unsigned char cdb[MAX_COMMAND_SIZE];
struct scsi_sense_hdr sshdr;
unsigned int data_size;
- blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
- REQ_FAILFAST_DRIVER;
+ blk_opf_t opf = REQ_OP_DRV_OUT | REQ_FAILFAST_DEV |
+ REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
spin_lock(&ctlr->ms_lock);
list_splice_init(&ctlr->ms_head, &list);
@@ -555,9 +558,8 @@ static void send_mode_select(struct work_struct *work)
(char *) h->ctlr->array_name, h->ctlr->index,
(retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying");
- if (scsi_execute(sdev, cdb, DMA_TO_DEVICE, &h->ctlr->mode_select,
- data_size, NULL, &sshdr, RDAC_TIMEOUT * HZ,
- RDAC_RETRIES, req_flags, 0, NULL)) {
+ if (scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size,
+ RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args)) {
err = mode_select_handle_sense(sdev, &sshdr);
if (err == SCSI_DH_RETRY && retry_cnt--)
goto retry;
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 06/15] scsi: core: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (4 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 05/15] scsi: scsi_dh: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-15 8:14 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 07/15] scsi: spi: " Mike Christie
` (8 subsequent siblings)
14 siblings, 1 reply; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute_req is going to be removed. Convert scsi-ml to
scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi.c | 12 +++++++-----
drivers/scsi/scsi_ioctl.c | 7 +++++--
drivers/scsi/scsi_lib.c | 26 +++++++++++++++++---------
drivers/scsi/scsi_scan.c | 26 ++++++++++++++++----------
4 files changed, 45 insertions(+), 26 deletions(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1426b9b03612..00ee47a04403 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -309,8 +309,8 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
* I'm not convinced we need to try quite this hard to get VPD, but
* all the existing users tried this hard.
*/
- result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
- len, NULL, 30 * HZ, 3, NULL);
+ result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer, len,
+ 30 * HZ, 3, NULL);
if (result)
return -EIO;
@@ -510,6 +510,9 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
unsigned char cmd[16];
struct scsi_sense_hdr sshdr;
int result, request_len;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
return -EINVAL;
@@ -531,9 +534,8 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
put_unaligned_be32(request_len, &cmd[6]);
memset(buffer, 0, len);
- result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
- request_len, &sshdr, 30 * HZ, 3, NULL);
-
+ result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer,
+ request_len, 30 * HZ, 3, &exec_args);
if (result < 0)
return result;
if (result && scsi_sense_valid(&sshdr) &&
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 1126a265d5ee..e3b31d32b6a9 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -69,12 +69,15 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
{
int result;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
SCSI_LOG_IOCTL(1, sdev_printk(KERN_INFO, sdev,
"Trying ioctl with scsi command %d\n", *cmd));
- result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
- &sshdr, timeout, retries, NULL);
+ result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, NULL, 0, timeout,
+ retries, &exec_args);
SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
"Ioctl returned 0x%x\n", result));
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7baad7ec8887..9a8ca20dd015 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2084,6 +2084,9 @@ int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
{
unsigned char cmd[10];
unsigned char *real_buffer;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = sshdr,
+ };
int ret;
memset(cmd, 0, sizeof(cmd));
@@ -2133,8 +2136,8 @@ int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
cmd[4] = len;
}
- ret = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, real_buffer, len,
- sshdr, timeout, retries, NULL);
+ ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, real_buffer, len,
+ timeout, retries, &exec_args);
kfree(real_buffer);
return ret;
}
@@ -2165,6 +2168,10 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
int header_length;
int result, retry_count = retries;
struct scsi_sense_hdr my_sshdr;
+ const struct scsi_exec_args exec_args = {
+ /* caller might not be interested in sense, but we need it */
+ .sshdr = sshdr ? : &my_sshdr,
+ };
memset(data, 0, sizeof(*data));
memset(&cmd[0], 0, 12);
@@ -2173,9 +2180,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
cmd[1] = dbd & 0x18; /* allows DBD and LLBA bits */
cmd[2] = modepage;
- /* caller might not be interested in sense, but we need it */
- if (!sshdr)
- sshdr = &my_sshdr;
+ sshdr = exec_args.sshdr;
retry:
use_10_for_ms = sdev->use_10_for_ms || len > 255;
@@ -2198,8 +2203,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
memset(buffer, 0, len);
- result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
- sshdr, timeout, retries, NULL);
+ result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer, len,
+ timeout, retries, &exec_args);
if (result < 0)
return result;
@@ -2279,12 +2284,15 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
char cmd[] = {
TEST_UNIT_READY, 0, 0, 0, 0, 0,
};
+ const struct scsi_exec_args exec_args = {
+ .sshdr = sshdr,
+ };
int result;
/* try to eat the UNIT_ATTENTION if there are enough retries */
do {
- result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr,
- timeout, 1, NULL);
+ result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, NULL, 0,
+ timeout, 1, &exec_args);
if (sdev->removable && scsi_sense_valid(sshdr) &&
sshdr->sense_key == UNIT_ATTENTION)
sdev->changed = 1;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 920b145f80b7..844b3cb556ab 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -210,7 +210,7 @@ static void scsi_unlock_floptical(struct scsi_device *sdev,
scsi_cmd[3] = 0;
scsi_cmd[4] = 0x2a; /* size */
scsi_cmd[5] = 0;
- scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, result, 0x2a, NULL,
+ scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, result, 0x2a,
SCSI_TIMEOUT, 3, NULL);
}
@@ -647,8 +647,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
unsigned char scsi_cmd[MAX_COMMAND_SIZE];
int first_inquiry_len, try_inquiry_len, next_inquiry_len;
int response_len = 0;
- int pass, count, result;
+ int pass, count, result, resid;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ .resid = &resid,
+ };
*bflags = 0;
@@ -666,18 +670,16 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
/* Each pass gets up to three chances to ignore Unit Attention */
for (count = 0; count < 3; ++count) {
- int resid;
-
memset(scsi_cmd, 0, 6);
scsi_cmd[0] = INQUIRY;
scsi_cmd[4] = (unsigned char) try_inquiry_len;
memset(inq_result, 0, try_inquiry_len);
- result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
- inq_result, try_inquiry_len, &sshdr,
+ result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN,
+ inq_result, try_inquiry_len,
HZ / 2 + HZ * scsi_inq_timeout, 3,
- &resid);
+ &exec_args);
SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
"scsi scan: INQUIRY %s with code 0x%x\n",
@@ -1403,6 +1405,9 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
struct scsi_sense_hdr sshdr;
struct scsi_device *sdev;
struct Scsi_Host *shost = dev_to_shost(&starget->dev);
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
int ret = 0;
/*
@@ -1477,9 +1482,10 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag
"scsi scan: Sending REPORT LUNS to (try %d)\n",
retries));
- result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
- lun_data, length, &sshdr,
- SCSI_REPORT_LUNS_TIMEOUT, 3, NULL);
+ result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN,
+ lun_data, length,
+ SCSI_REPORT_LUNS_TIMEOUT, 3,
+ &exec_args);
SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
"scsi scan: REPORT LUNS"
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 07/15] scsi: spi: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (5 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 06/15] scsi: core: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-14 23:49 ` [PATCH v3 08/15] scsi: sd: " Mike Christie
` (7 subsequent siblings)
14 siblings, 0 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute is going to be removed. Convert to the SPI class to
scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi_transport_spi.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index f569cf0095c2..2442d4d2e3f3 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -105,28 +105,27 @@ static int sprint_frac(char *dest, int value, int denom)
}
static int spi_execute(struct scsi_device *sdev, const void *cmd,
- enum dma_data_direction dir,
- void *buffer, unsigned bufflen,
+ enum req_op op, void *buffer, unsigned int bufflen,
struct scsi_sense_hdr *sshdr)
{
int i, result;
- unsigned char sense[SCSI_SENSE_BUFFERSIZE];
struct scsi_sense_hdr sshdr_tmp;
+ blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
+ REQ_FAILFAST_DRIVER;
+ const struct scsi_exec_args exec_args = {
+ .req_flags = BLK_MQ_REQ_PM,
+ .sshdr = sshdr ? : &sshdr_tmp,
+ };
- if (!sshdr)
- sshdr = &sshdr_tmp;
+ sshdr = exec_args.sshdr;
for(i = 0; i < DV_RETRIES; i++) {
/*
* The purpose of the RQF_PM flag below is to bypass the
* SDEV_QUIESCE state.
*/
- result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
- sshdr, DV_TIMEOUT, /* retries */ 1,
- REQ_FAILFAST_DEV |
- REQ_FAILFAST_TRANSPORT |
- REQ_FAILFAST_DRIVER,
- RQF_PM, NULL);
+ result = scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen,
+ DV_TIMEOUT, 1, &exec_args);
if (result < 0 || !scsi_sense_valid(sshdr) ||
sshdr->sense_key != UNIT_ATTENTION)
break;
@@ -675,7 +674,7 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,
}
for (r = 0; r < retries; r++) {
- result = spi_execute(sdev, spi_write_buffer, DMA_TO_DEVICE,
+ result = spi_execute(sdev, spi_write_buffer, REQ_OP_DRV_OUT,
buffer, len, &sshdr);
if(result || !scsi_device_online(sdev)) {
@@ -697,7 +696,7 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,
}
memset(ptr, 0, len);
- spi_execute(sdev, spi_read_buffer, DMA_FROM_DEVICE,
+ spi_execute(sdev, spi_read_buffer, REQ_OP_DRV_IN,
ptr, len, NULL);
scsi_device_set_state(sdev, SDEV_QUIESCE);
@@ -722,7 +721,7 @@ spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer,
for (r = 0; r < retries; r++) {
memset(ptr, 0, len);
- result = spi_execute(sdev, spi_inquiry, DMA_FROM_DEVICE,
+ result = spi_execute(sdev, spi_inquiry, REQ_OP_DRV_IN,
ptr, len, NULL);
if(result || !scsi_device_online(sdev)) {
@@ -828,7 +827,7 @@ spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer)
* (reservation conflict, device not ready, etc) just
* skip the write tests */
for (l = 0; ; l++) {
- result = spi_execute(sdev, spi_test_unit_ready, DMA_NONE,
+ result = spi_execute(sdev, spi_test_unit_ready, REQ_OP_DRV_IN,
NULL, 0, NULL);
if(result) {
@@ -841,7 +840,7 @@ spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer)
}
result = spi_execute(sdev, spi_read_buffer_descriptor,
- DMA_FROM_DEVICE, buffer, 4, NULL);
+ REQ_OP_DRV_IN, buffer, 4, NULL);
if (result)
/* Device has no echo buffer */
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 08/15] scsi: sd: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (6 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 07/15] scsi: spi: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-15 8:14 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 09/15] scsi: zbc: " Mike Christie
` (6 subsequent siblings)
14 siblings, 1 reply; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute* is going to be removed. Convert sd_mod to use
scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/sd.c | 83 +++++++++++++++++++++++++++++++----------------
1 file changed, 55 insertions(+), 28 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 47dafe6b8a66..2aa3b0393b96 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -664,6 +664,9 @@ static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
struct scsi_disk *sdkp = data;
struct scsi_device *sdev = sdkp->device;
u8 cdb[12] = { 0, };
+ const struct scsi_exec_args exec_args = {
+ .req_flags = BLK_MQ_REQ_PM,
+ };
int ret;
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,
put_unaligned_be16(spsp, &cdb[2]);
put_unaligned_be32(len, &cdb[6]);
- ret = scsi_execute(sdev, cdb, send ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
- buffer, len, NULL, NULL, SD_TIMEOUT, sdkp->max_retries, 0,
- RQF_PM, NULL);
+ ret = scsi_execute_cmd(sdev, cdb, send ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
+ buffer, len, SD_TIMEOUT, sdkp->max_retries,
+ &exec_args);
return ret <= 0 ? ret : -EIO;
}
#endif /* CONFIG_BLK_SED_OPAL */
@@ -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
* SD_FLUSH_TIMEOUT_MULTIPLIER;
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))
return -ENODEV;
- /* caller might not be interested in sense, but we need it */
- if (!sshdr)
- sshdr = &my_sshdr;
+ sshdr = exec_args.sshdr;
for (retries = 3; retries > 0; --retries) {
unsigned char cmd[16] = { 0 };
@@ -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
* flush everything.
*/
- res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, sshdr,
- timeout, sdkp->max_retries, 0, RQF_PM, NULL);
+ res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0,
+ timeout, sdkp->max_retries, &exec_args);
if (res == 0)
break;
}
@@ -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_device *sdev = sdkp->device;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
int result;
u8 cmd[16] = { 0, };
u8 data[24] = { 0, };
@@ -1758,8 +1767,9 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
put_unaligned_be64(sa_key, &data[8]);
data[20] = flags;
- result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
- &sshdr, SD_TIMEOUT, sdkp->max_retries, NULL);
+ result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, &data,
+ sizeof(data), SD_TIMEOUT, sdkp->max_retries,
+ &exec_args);
if (scsi_status_is_check_condition(result) &&
scsi_sense_valid(&sshdr)) {
@@ -2088,6 +2098,9 @@ sd_spinup_disk(struct scsi_disk *sdkp)
int retries, spintime;
unsigned int the_result;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
int sense_valid = 0;
spintime = 0;
@@ -2103,10 +2116,11 @@ sd_spinup_disk(struct scsi_disk *sdkp)
cmd[0] = TEST_UNIT_READY;
memset((void *) &cmd[1], 0, 9);
- the_result = scsi_execute_req(sdkp->device, cmd,
- DMA_NONE, NULL, 0,
- &sshdr, SD_TIMEOUT,
- sdkp->max_retries, NULL);
+ the_result = scsi_execute_cmd(sdkp->device, cmd,
+ REQ_OP_DRV_IN, NULL, 0,
+ SD_TIMEOUT,
+ sdkp->max_retries,
+ &exec_args);
/*
* If the drive has indicated to us that it
@@ -2163,10 +2177,10 @@ sd_spinup_disk(struct scsi_disk *sdkp)
cmd[4] = 1; /* Start spin cycle */
if (sdkp->device->start_stop_pwr_cond)
cmd[4] |= 1 << 4;
- scsi_execute_req(sdkp->device, cmd, DMA_NONE,
- NULL, 0, &sshdr,
+ scsi_execute_cmd(sdkp->device, cmd,
+ REQ_OP_DRV_IN, NULL, 0,
SD_TIMEOUT, sdkp->max_retries,
- NULL);
+ &exec_args);
spintime_expire = jiffies + 100 * HZ;
spintime = 1;
}
@@ -2296,6 +2310,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
{
unsigned char cmd[16];
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
int sense_valid = 0;
int the_result;
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,
cmd[13] = RC16_LEN;
memset(buffer, 0, RC16_LEN);
- the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
- buffer, RC16_LEN, &sshdr,
- SD_TIMEOUT, sdkp->max_retries, NULL);
+ the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN,
+ buffer, RC16_LEN, SD_TIMEOUT,
+ sdkp->max_retries, &exec_args);
if (media_not_present(sdkp, &sshdr))
return -ENODEV;
@@ -2387,6 +2404,9 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
{
unsigned char cmd[16];
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
int sense_valid = 0;
int the_result;
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,
memset(&cmd[1], 0, 9);
memset(buffer, 0, 8);
- the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
- buffer, 8, &sshdr,
- SD_TIMEOUT, sdkp->max_retries, NULL);
+ the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer,
+ 8, SD_TIMEOUT, sdkp->max_retries,
+ &exec_args);
if (media_not_present(sdkp, &sshdr))
return -ENODEV;
@@ -3637,6 +3657,10 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
{
unsigned char cmd[6] = { START_STOP }; /* START_VALID */
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;
int res;
@@ -3649,8 +3673,8 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
if (!scsi_device_online(sdp))
return -ENODEV;
- res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
- SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL);
+ res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, SD_TIMEOUT,
+ sdkp->max_retries, &exec_args);
if (res) {
sd_print_result(sdkp, "Start/Stop Unit failed", res);
if (res > 0 && scsi_sense_valid(&sshdr)) {
@@ -3790,10 +3814,13 @@ static int sd_resume_runtime(struct device *dev)
if (sdp->ignore_media_change) {
/* clear the device's sense data */
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,
- NULL, sdp->request_queue->rq_timeout, 1, 0,
- RQF_PM, NULL))
+ if (scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0,
+ sdp->request_queue->rq_timeout, 1,
+ &exec_args))
sd_printk(KERN_NOTICE, sdkp,
"Failed to clear sense data\n");
}
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 09/15] scsi: zbc: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (7 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 08/15] scsi: sd: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-15 8:14 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 10/15] scsi: ses: " Mike Christie
` (5 subsequent siblings)
14 siblings, 1 reply; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute_req is going to be removed. Conver zbc to scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/sd_zbc.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 62abebbaf2e7..6b3a02d4406c 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -148,6 +148,9 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf,
struct scsi_device *sdp = sdkp->device;
const int timeout = sdp->request_queue->rq_timeout;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
unsigned char cmd[16];
unsigned int rep_len;
int result;
@@ -160,9 +163,8 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf,
if (partial)
cmd[14] = ZBC_REPORT_ZONE_PARTIAL;
- result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
- buf, buflen, &sshdr,
- timeout, SD_MAX_RETRIES, NULL);
+ result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buf, buflen,
+ timeout, SD_MAX_RETRIES, &exec_args);
if (result) {
sd_printk(KERN_ERR, sdkp,
"REPORT ZONES start lba %llu failed\n", lba);
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 10/15] scsi: ses: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (8 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 09/15] scsi: zbc: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-14 23:49 ` [PATCH v3 11/15] scsi: sr: " Mike Christie
` (4 subsequent siblings)
14 siblings, 0 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute_req is going to be removed. Convert ses to scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/ses.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 0a1734f34587..869ca9c7f23f 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -89,10 +89,13 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
unsigned char recv_page_code;
unsigned int retries = SES_RETRIES;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
do {
- ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
- &sshdr, SES_TIMEOUT, 1, NULL);
+ ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, bufflen,
+ SES_TIMEOUT, 1, &exec_args);
} while (ret > 0 && --retries && scsi_sense_valid(&sshdr) &&
(sshdr.sense_key == NOT_READY ||
(sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29)));
@@ -130,10 +133,13 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code,
};
struct scsi_sense_hdr sshdr;
unsigned int retries = SES_RETRIES;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
do {
- result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, buf, bufflen,
- &sshdr, SES_TIMEOUT, 1, NULL);
+ result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, buf,
+ bufflen, SES_TIMEOUT, 1, &exec_args);
} while (result > 0 && --retries && scsi_sense_valid(&sshdr) &&
(sshdr.sense_key == NOT_READY ||
(sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29)));
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 11/15] scsi: sr: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (9 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 10/15] scsi: ses: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-15 8:14 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 12/15] scsi: virtio_scsi: " Mike Christie
` (3 subsequent siblings)
14 siblings, 1 reply; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute* is going to be removed. Convert sr to scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/sr.c | 11 +++++++----
drivers/scsi/sr_ioctl.c | 17 ++++++++++-------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index a278b739d0c5..9e51dcd30bfd 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -170,10 +170,13 @@ static unsigned int sr_get_events(struct scsi_device *sdev)
struct event_header *eh = (void *)buf;
struct media_event_desc *med = (void *)(buf + 4);
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
int result;
- result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, sizeof(buf),
- &sshdr, SR_TIMEOUT, MAX_RETRIES, NULL);
+ result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, sizeof(buf),
+ SR_TIMEOUT, MAX_RETRIES, &exec_args);
if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION)
return DISK_EVENT_MEDIA_CHANGE;
@@ -730,8 +733,8 @@ static void get_sectorsize(struct scsi_cd *cd)
memset(buffer, 0, sizeof(buffer));
/* Do the command and wait.. */
- the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
- buffer, sizeof(buffer), NULL,
+ the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN,
+ buffer, sizeof(buffer),
SR_TIMEOUT, MAX_RETRIES, NULL);
retries--;
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index fbdb5124d7f7..5b0b35e60e61 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -188,13 +188,15 @@ static int sr_play_trkind(struct cdrom_device_info *cdi,
int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
{
struct scsi_device *SDev;
- struct scsi_sense_hdr local_sshdr, *sshdr = &local_sshdr;
+ struct scsi_sense_hdr local_sshdr, *sshdr;
int result, err = 0, retries = 0;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = cgc->sshdr ? : &local_sshdr,
+ };
SDev = cd->device;
- if (cgc->sshdr)
- sshdr = cgc->sshdr;
+ sshdr = exec_args.sshdr;
retry:
if (!scsi_block_when_processing_errors(SDev)) {
@@ -202,10 +204,11 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
goto out;
}
- result = scsi_execute(SDev, cgc->cmd, cgc->data_direction,
- cgc->buffer, cgc->buflen, NULL, sshdr,
- cgc->timeout, IOCTL_RETRIES, 0, 0, NULL);
-
+ result = scsi_execute_cmd(SDev, cgc->cmd,
+ cgc->data_direction == DMA_TO_DEVICE ?
+ REQ_OP_DRV_OUT : REQ_OP_DRV_IN, cgc->buffer,
+ cgc->buflen, cgc->timeout, IOCTL_RETRIES,
+ &exec_args);
/* Minimal error checking. Ignore cases we know about, and report the rest. */
if (result < 0) {
err = result;
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 12/15] scsi: virtio_scsi: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (10 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 11/15] scsi: sr: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-15 8:15 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 13/15] scsi: target_core_pscsi: " Mike Christie
` (2 subsequent siblings)
14 siblings, 1 reply; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute_req is going to be removed. Convert virtio_scsi to
scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/virtio_scsi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index d07d24c06b54..b221c3c99320 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -347,8 +347,8 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
memset(inq_result, 0, inq_result_len);
- result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
- inq_result, inquiry_len, NULL,
+ result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN,
+ inq_result, inquiry_len,
SD_TIMEOUT, SD_MAX_RETRIES, NULL);
if (result == 0 && inq_result[0] >> 5) {
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 13/15] scsi: target_core_pscsi: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (11 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 12/15] scsi: virtio_scsi: " Mike Christie
@ 2022-12-14 23:49 ` Mike Christie
2022-12-14 23:50 ` [PATCH v3 14/15] scsi: cxlflash: " Mike Christie
2022-12-14 23:50 ` [PATCH v3 15/15] scsi: Remove scsi_execute_req/scsi_execute functions Mike Christie
14 siblings, 0 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:49 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute_req is going to be removed. Convert pscsi to
scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/target/target_core_pscsi.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 69a4c9581e80..e7425549e39c 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -144,8 +144,7 @@ static void pscsi_tape_read_blocksize(struct se_device *dev,
cdb[0] = MODE_SENSE;
cdb[4] = 0x0c; /* 12 bytes */
- ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf, 12, NULL,
- HZ, 1, NULL);
+ ret = scsi_execute_cmd(sdev, cdb, REQ_OP_DRV_IN, buf, 12, HZ, 1, NULL);
if (ret)
goto out_free;
@@ -195,8 +194,8 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn)
cdb[2] = 0x80; /* Unit Serial Number */
put_unaligned_be16(INQUIRY_VPD_SERIAL_LEN, &cdb[3]);
- ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf,
- INQUIRY_VPD_SERIAL_LEN, NULL, HZ, 1, NULL);
+ ret = scsi_execute_cmd(sdev, cdb, REQ_OP_DRV_IN, buf,
+ INQUIRY_VPD_SERIAL_LEN, HZ, 1, NULL);
if (ret)
goto out_free;
@@ -230,9 +229,8 @@ pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev,
cdb[2] = 0x83; /* Device Identifier */
put_unaligned_be16(INQUIRY_VPD_DEVICE_IDENTIFIER_LEN, &cdb[3]);
- ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf,
- INQUIRY_VPD_DEVICE_IDENTIFIER_LEN,
- NULL, HZ, 1, NULL);
+ ret = scsi_execute_cmd(sdev, cdb, REQ_OP_DRV_IN, buf,
+ INQUIRY_VPD_DEVICE_IDENTIFIER_LEN, HZ, 1, NULL);
if (ret)
goto out;
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 14/15] scsi: cxlflash: Convert to scsi_execute_cmd
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (12 preceding siblings ...)
2022-12-14 23:49 ` [PATCH v3 13/15] scsi: target_core_pscsi: " Mike Christie
@ 2022-12-14 23:50 ` Mike Christie
2022-12-14 23:50 ` [PATCH v3 15/15] scsi: Remove scsi_execute_req/scsi_execute functions Mike Christie
14 siblings, 0 replies; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:50 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute is going to be removed. Convert cxlflash to
use scsi_execute_cmd.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/cxlflash/superpipe.c | 34 ++++++++++++++++---------------
drivers/scsi/cxlflash/vlun.c | 32 ++++++++++++++---------------
2 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index df0ebabbf387..9935c47712dc 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -308,19 +308,19 @@ static int afu_attach(struct cxlflash_cfg *cfg, struct ctx_info *ctxi)
* @lli: LUN destined for capacity request.
*
* The READ_CAP16 can take quite a while to complete. Should an EEH occur while
- * in scsi_execute(), the EEH handler will attempt to recover. As part of the
- * recovery, the handler drains all currently running ioctls, waiting until they
- * have completed before proceeding with a reset. As this routine is used on the
- * ioctl path, this can create a condition where the EEH handler becomes stuck,
- * infinitely waiting for this ioctl thread. To avoid this behavior, temporarily
- * unmark this thread as an ioctl thread by releasing the ioctl read semaphore.
- * This will allow the EEH handler to proceed with a recovery while this thread
- * is still running. Once the scsi_execute() returns, reacquire the ioctl read
- * semaphore and check the adapter state in case it changed while inside of
- * scsi_execute(). The state check will wait if the adapter is still being
- * recovered or return a failure if the recovery failed. In the event that the
- * adapter reset failed, simply return the failure as the ioctl would be unable
- * to continue.
+ * in scsi_execute_cmd(), the EEH handler will attempt to recover. As part of
+ * the recovery, the handler drains all currently running ioctls, waiting until
+ * they have completed before proceeding with a reset. As this routine is used
+ * on the ioctl path, this can create a condition where the EEH handler becomes
+ * stuck, infinitely waiting for this ioctl thread. To avoid this behavior,
+ * temporarily unmark this thread as an ioctl thread by releasing the ioctl
+ * read semaphore. This will allow the EEH handler to proceed with a recovery
+ * while this thread is still running. Once the scsi_execute_cmd() returns,
+ * reacquire the ioctl read semaphore and check the adapter state in case it
+ * changed while inside of scsi_execute_cmd(). The state check will wait if the
+ * adapter is still being recovered or return a failure if the recovery failed.
+ * In the event that the adapter reset failed, simply return the failure as the
+ * ioctl would be unable to continue.
*
* Note that the above puts a requirement on this routine to only be called on
* an ioctl thread.
@@ -333,6 +333,9 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
struct device *dev = &cfg->dev->dev;
struct glun_info *gli = lli->parent;
struct scsi_sense_hdr sshdr;
+ const struct scsi_exec_args exec_args = {
+ .sshdr = &sshdr,
+ };
u8 *cmd_buf = NULL;
u8 *scsi_cmd = NULL;
int rc = 0;
@@ -357,9 +360,8 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
/* Drop the ioctl read semahpore across lengthy call */
up_read(&cfg->ioctl_rwsem);
- result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf,
- CMD_BUFSIZE, NULL, &sshdr, to, CMD_RETRIES,
- 0, 0, NULL);
+ result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, cmd_buf,
+ CMD_BUFSIZE, to, CMD_RETRIES, exec_args);
down_read(&cfg->ioctl_rwsem);
rc = check_state(cfg);
if (rc) {
diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c
index 5c74dc7c2288..9caabf550436 100644
--- a/drivers/scsi/cxlflash/vlun.c
+++ b/drivers/scsi/cxlflash/vlun.c
@@ -397,19 +397,19 @@ static int init_vlun(struct llun_info *lli)
* @nblks: Number of logical blocks to write same.
*
* The SCSI WRITE_SAME16 can take quite a while to complete. Should an EEH occur
- * while in scsi_execute(), the EEH handler will attempt to recover. As part of
- * the recovery, the handler drains all currently running ioctls, waiting until
- * they have completed before proceeding with a reset. As this routine is used
- * on the ioctl path, this can create a condition where the EEH handler becomes
- * stuck, infinitely waiting for this ioctl thread. To avoid this behavior,
- * temporarily unmark this thread as an ioctl thread by releasing the ioctl read
- * semaphore. This will allow the EEH handler to proceed with a recovery while
- * this thread is still running. Once the scsi_execute() returns, reacquire the
- * ioctl read semaphore and check the adapter state in case it changed while
- * inside of scsi_execute(). The state check will wait if the adapter is still
- * being recovered or return a failure if the recovery failed. In the event that
- * the adapter reset failed, simply return the failure as the ioctl would be
- * unable to continue.
+ * while in scsi_execute_cmd(), the EEH handler will attempt to recover. As
+ * part of the recovery, the handler drains all currently running ioctls,
+ * waiting until they have completed before proceeding with a reset. As this
+ * routine is used on the ioctl path, this can create a condition where the
+ * EEH handler becomes stuck, infinitely waiting for this ioctl thread. To
+ * avoid this behavior, temporarily unmark this thread as an ioctl thread by
+ * releasing the ioctl read semaphore. This will allow the EEH handler to
+ * proceed with a recovery while this thread is still running. Once the
+ * scsi_execute_cmd() returns, reacquire the ioctl read semaphore and check the
+ * adapter state in case it changed while inside of scsi_execute_cmd(). The
+ * state check will wait if the adapter is still being recovered or return a
+ * failure if the recovery failed. In the event that the adapter reset failed,
+ * simply return the failure as the ioctl would be unable to continue.
*
* Note that the above puts a requirement on this routine to only be called on
* an ioctl thread.
@@ -450,9 +450,9 @@ static int write_same16(struct scsi_device *sdev,
/* Drop the ioctl read semahpore across lengthy call */
up_read(&cfg->ioctl_rwsem);
- result = scsi_execute(sdev, scsi_cmd, DMA_TO_DEVICE, cmd_buf,
- CMD_BUFSIZE, NULL, NULL, to,
- CMD_RETRIES, 0, 0, NULL);
+ result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_OUT,
+ cmd_buf, CMD_BUFSIZE, to,
+ CMD_RETRIES, NULL);
down_read(&cfg->ioctl_rwsem);
rc = check_state(cfg);
if (rc) {
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 15/15] scsi: Remove scsi_execute_req/scsi_execute functions
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
` (13 preceding siblings ...)
2022-12-14 23:50 ` [PATCH v3 14/15] scsi: cxlflash: " Mike Christie
@ 2022-12-14 23:50 ` Mike Christie
2022-12-15 8:13 ` Christoph Hellwig
14 siblings, 1 reply; 28+ messages in thread
From: Mike Christie @ 2022-12-14 23:50 UTC (permalink / raw)
To: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Cc: Mike Christie
scsi_execute and scsi_execute_req are no longer used so remove them.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
include/scsi/scsi_device.h | 31 -------------------------------
1 file changed, 31 deletions(-)
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index f6b33c6c1064..7e95ec45138f 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -470,37 +470,6 @@ int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd,
int timeout, int retries,
const struct scsi_exec_args *args);
-/* Make sure any sense buffer is the correct size. */
-#define scsi_execute(_sdev, _cmd, _data_dir, _buffer, _bufflen, _sense, \
- _sshdr, _timeout, _retries, _flags, _rq_flags, \
- _resid) \
-({ \
- scsi_execute_cmd(_sdev, _cmd, (_data_dir == DMA_TO_DEVICE ? \
- REQ_OP_DRV_OUT : REQ_OP_DRV_IN) | _flags, \
- _buffer, _bufflen, _timeout, _retries, \
- &(struct scsi_exec_args) { \
- .sense = _sense, \
- .sshdr = _sshdr, \
- .req_flags = _rq_flags & RQF_PM ? \
- BLK_MQ_REQ_PM : 0, \
- .resid = _resid, \
- }); \
-})
-
-static inline int scsi_execute_req(struct scsi_device *sdev,
- const unsigned char *cmd, int data_direction, void *buffer,
- unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout,
- int retries, int *resid)
-{
- return scsi_execute_cmd(sdev, cmd,
- data_direction == DMA_TO_DEVICE ?
- REQ_OP_DRV_OUT : REQ_OP_DRV_IN, buffer,
- bufflen, timeout, retries,
- &(struct scsi_exec_args) {
- .sshdr = sshdr,
- .resid = resid,
- });
-}
extern void sdev_disable_disk_events(struct scsi_device *sdev);
extern void sdev_enable_disk_events(struct scsi_device *sdev);
extern int scsi_vpd_lun_id(struct scsi_device *, char *, size_t);
--
2.25.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH v3 01/15] scsi: Add struct for args to execution functions
2022-12-14 23:49 ` [PATCH v3 01/15] " Mike Christie
@ 2022-12-15 1:13 ` Bart Van Assche
2022-12-15 8:13 ` Christoph Hellwig
2022-12-15 9:59 ` John Garry
2 siblings, 0 replies; 28+ messages in thread
From: Bart Van Assche @ 2022-12-15 1:13 UTC (permalink / raw)
To: Mike Christie, john.g.garry, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
On 12/14/22 15:49, Mike Christie wrote:
> This begins to move the SCSI execution functions to use a struct for
> passing in optional args. This patch adds the new struct, temporarily
> converts scsi_execute and scsi_execute_req ands a new helper,
> scsi_execute_cmd, which takes the scsi_exec_args struct.
>
> There should be no change in behavior. We no longer alilow users to pass
^^^^^^
allow?
> in any request->rq_flags valu, but they were only passing in RQF_QUIET
^^^^ ^^^^^^^^^
value? RQF_PM?
> which we do support by allowing users to pass in the BLK_MQ_REQ flags used
> by blk_mq_alloc_request.
>
> The next patches will convert scsi_execute and scsi_execute_req users to
> the new helpers then remove scsi_execute and scsi_execute_req.
After the patch description has been updated, please add:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 01/15] scsi: Add struct for args to execution functions
2022-12-14 23:49 ` [PATCH v3 01/15] " Mike Christie
2022-12-15 1:13 ` Bart Van Assche
@ 2022-12-15 8:13 ` Christoph Hellwig
2022-12-15 9:59 ` John Garry
2 siblings, 0 replies; 28+ messages in thread
From: Christoph Hellwig @ 2022-12-15 8:13 UTC (permalink / raw)
To: Mike Christie
Cc: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 15/15] scsi: Remove scsi_execute_req/scsi_execute functions
2022-12-14 23:50 ` [PATCH v3 15/15] scsi: Remove scsi_execute_req/scsi_execute functions Mike Christie
@ 2022-12-15 8:13 ` Christoph Hellwig
0 siblings, 0 replies; 28+ messages in thread
From: Christoph Hellwig @ 2022-12-15 8:13 UTC (permalink / raw)
To: Mike Christie
Cc: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 06/15] scsi: core: Convert to scsi_execute_cmd
2022-12-14 23:49 ` [PATCH v3 06/15] scsi: core: " Mike Christie
@ 2022-12-15 8:14 ` Christoph Hellwig
0 siblings, 0 replies; 28+ messages in thread
From: Christoph Hellwig @ 2022-12-15 8:14 UTC (permalink / raw)
To: Mike Christie
Cc: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 08/15] scsi: sd: Convert to scsi_execute_cmd
2022-12-14 23:49 ` [PATCH v3 08/15] scsi: sd: " Mike Christie
@ 2022-12-15 8:14 ` Christoph Hellwig
0 siblings, 0 replies; 28+ messages in thread
From: Christoph Hellwig @ 2022-12-15 8:14 UTC (permalink / raw)
To: Mike Christie
Cc: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 09/15] scsi: zbc: Convert to scsi_execute_cmd
2022-12-14 23:49 ` [PATCH v3 09/15] scsi: zbc: " Mike Christie
@ 2022-12-15 8:14 ` Christoph Hellwig
0 siblings, 0 replies; 28+ messages in thread
From: Christoph Hellwig @ 2022-12-15 8:14 UTC (permalink / raw)
To: Mike Christie
Cc: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 11/15] scsi: sr: Convert to scsi_execute_cmd
2022-12-14 23:49 ` [PATCH v3 11/15] scsi: sr: " Mike Christie
@ 2022-12-15 8:14 ` Christoph Hellwig
0 siblings, 0 replies; 28+ messages in thread
From: Christoph Hellwig @ 2022-12-15 8:14 UTC (permalink / raw)
To: Mike Christie
Cc: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 12/15] scsi: virtio_scsi: Convert to scsi_execute_cmd
2022-12-14 23:49 ` [PATCH v3 12/15] scsi: virtio_scsi: " Mike Christie
@ 2022-12-15 8:15 ` Christoph Hellwig
2022-12-18 21:40 ` Mike Christie
0 siblings, 1 reply; 28+ messages in thread
From: Christoph Hellwig @ 2022-12-15 8:15 UTC (permalink / raw)
To: Mike Christie
Cc: john.g.garry, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
The conversion itself looks good, but how the f**k did we end up with
a LLDD calling unquiry below the SCSI midlayer?
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 01/15] scsi: Add struct for args to execution functions
2022-12-14 23:49 ` [PATCH v3 01/15] " Mike Christie
2022-12-15 1:13 ` Bart Van Assche
2022-12-15 8:13 ` Christoph Hellwig
@ 2022-12-15 9:59 ` John Garry
2 siblings, 0 replies; 28+ messages in thread
From: John Garry @ 2022-12-15 9:59 UTC (permalink / raw)
To: Mike Christie, bvanassche, mwilck, hch, martin.petersen,
linux-scsi, james.bottomley
On 14/12/2022 23:49, Mike Christie wrote:
> This begins to move the SCSI execution functions to use a struct for
> passing in optional args. This patch adds the new struct, temporarily
> converts scsi_execute and scsi_execute_req ands a new helper,
> scsi_execute_cmd, which takes the scsi_exec_args struct.
>
> There should be no change in behavior. We no longer alilow users to pass
> in any request->rq_flags valu, but they were only passing in RQF_QUIET
> which we do support by allowing users to pass in the BLK_MQ_REQ flags used
> by blk_mq_alloc_request.
>
> The next patches will convert scsi_execute and scsi_execute_req users to
> the new helpers then remove scsi_execute and scsi_execute_req.
>
> Signed-off-by: Mike Christie<michael.christie@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
> ---
> drivers/scsi/scsi_lib.c | 52 ++++++++++++++++++--------------------
> include/scsi/scsi_device.h | 51 +++++++++++++++++++++++++++----------
> 2 files changed, 62 insertions(+), 41 deletions(-)
...
>
> - req = scsi_alloc_request(sdev->request_queue,
> - data_direction == DMA_TO_DEVICE ?
> - REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
> - rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0);
> + if (!args)
> + args = &default_args;
> + else if (WARN_ON_ONCE(args->sense &&
> + args->sense_len != SCSI_SENSE_BUFFERSIZE))
As mentioned elsewhere, this size check is not fool proof as it does
rely on the caller to set sense_len to what really is the size of the
memory pointed to by args->sense. Better than nothing, I suppose.
> + return -EINVAL;
> +
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 12/15] scsi: virtio_scsi: Convert to scsi_execute_cmd
2022-12-15 8:15 ` Christoph Hellwig
@ 2022-12-18 21:40 ` Mike Christie
2022-12-23 15:57 ` Christoph Hellwig
0 siblings, 1 reply; 28+ messages in thread
From: Mike Christie @ 2022-12-18 21:40 UTC (permalink / raw)
To: Christoph Hellwig
Cc: john.g.garry, bvanassche, mwilck, martin.petersen, linux-scsi,
james.bottomley
On 12/15/22 2:15 AM, Christoph Hellwig wrote:
> The conversion itself looks good, but how the f**k did we end up with
> a LLDD calling unquiry below the SCSI midlayer?
I don't know how it happened.
It looks like a hack around scsi_scan_host not removing devices.
Going forward, it looks like we can remove the inquiry code by having
scsi_scan_host be able to remove devices that are no longer returned.
However, there's an extra catch because they have that DID_BAD_TARGET
case where qemu returns VIRTIO_SCSI_S_BAD_TARGET if there are no devices
on the host, but other drivers uses that error code for a bunch of
different reasons.
I was thinking to handle the DID_BAD_TARGET use case above and this type
of issue:
https://lore.kernel.org/linux-scsi/CA+PODjqrRzyJnOKoabMOV4EPByNnL1LgTi+QAKENP3NwUq5YCw@mail.gmail.com/
maybe we want to have a driver level BLIST like:
static struct {
char *driver;
blist_flags_t flags;
} scsi_static_driver_list[] __initdata = {
{"virtio_scsi", BLIST_REMOVE_ON_BAD_TARGET},
{"aacard", BLIST_SHOW_DEV_PQ1},
One other question, can I do this work after the patchset in this email, the
scsi_cmnd retry patches and the actual PR ones? I keep going off track on these
side adventures.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 12/15] scsi: virtio_scsi: Convert to scsi_execute_cmd
2022-12-18 21:40 ` Mike Christie
@ 2022-12-23 15:57 ` Christoph Hellwig
2022-12-23 18:43 ` michael.christie
0 siblings, 1 reply; 28+ messages in thread
From: Christoph Hellwig @ 2022-12-23 15:57 UTC (permalink / raw)
To: Mike Christie
Cc: Christoph Hellwig, john.g.garry, bvanassche, mwilck,
martin.petersen, linux-scsi, james.bottomley
On Sun, Dec 18, 2022 at 03:40:48PM -0600, Mike Christie wrote:
> It looks like a hack around scsi_scan_host not removing devices.
> Going forward, it looks like we can remove the inquiry code by having
> scsi_scan_host be able to remove devices that are no longer returned.
Yes, that's the place to do it. I can see arguments for and against
that, but doing it from and LLDD (and including sd.h in the LLDD
implementation!) just doesn't make sense.
> I was thinking to handle the DID_BAD_TARGET use case above and this type
> of issue:
>
> https://lore.kernel.org/linux-scsi/CA+PODjqrRzyJnOKoabMOV4EPByNnL1LgTi+QAKENP3NwUq5YCw@mail.gmail.com/
>
> maybe we want to have a driver level BLIST like:
Maybe instead of a blist we just need better way to communicate
this rather than abusing DID_BAD_TARGET?
> One other question, can I do this work after the patchset in this email, the
> scsi_cmnd retry patches and the actual PR ones? I keep going off track on these
> side adventures.
Yes, please. I think we need to finish this series first.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 12/15] scsi: virtio_scsi: Convert to scsi_execute_cmd
2022-12-23 15:57 ` Christoph Hellwig
@ 2022-12-23 18:43 ` michael.christie
0 siblings, 0 replies; 28+ messages in thread
From: michael.christie @ 2022-12-23 18:43 UTC (permalink / raw)
To: Christoph Hellwig
Cc: john.g.garry, bvanassche, mwilck, martin.petersen, linux-scsi,
james.bottomley
On 12/23/22 9:57 AM, Christoph Hellwig wrote:
> On Sun, Dec 18, 2022 at 03:40:48PM -0600, Mike Christie wrote:
>> It looks like a hack around scsi_scan_host not removing devices.
>> Going forward, it looks like we can remove the inquiry code by having
>> scsi_scan_host be able to remove devices that are no longer returned.
>
> Yes, that's the place to do it. I can see arguments for and against
> that, but doing it from and LLDD (and including sd.h in the LLDD
> implementation!) just doesn't make sense.
>
>> I was thinking to handle the DID_BAD_TARGET use case above and this type
>> of issue:
>>
>> https://lore.kernel.org/linux-scsi/CA+PODjqrRzyJnOKoabMOV4EPByNnL1LgTi+QAKENP3NwUq5YCw@mail.gmail.com/
>>
>> maybe we want to have a driver level BLIST like:
>
> Maybe instead of a blist we just need better way to communicate
> this rather than abusing DID_BAD_TARGET?
Yeah, after I sent the blist email I looked into qemu and the DID_BAD_TARGET uses
more and we can do more what you are thinking.
I'm going to do:
0. qemu only uses VIRTIO_SCSI_S_BAD_TARGET (this gets converted to DID_BAD_TARGET)
when the device does not exist, or if you are using a sg device and it returns
DID_BAD_TARGET.
1. Most driver uses of DID_BAD_TARGET are when the device is missing, disconnected,
timedout, or the bus:target_id:LUN value was not supported by the driver. So I was going
to rename DID_BAD_TARGET to DID_INVALID_DEVICE/DID_DEVICE_INACCESSIBLE for those cases.
2. Create a new DID_ error code for the other use cases where the driver meant that the
target did something incorrect/invalid like send a invalid response.
In the scan code then we know if we got a DID_INVALID_DEVICE the device is not there
anymore so we can remove it.
^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2022-12-23 18:43 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 23:49 [PATCH v3 00/15] scsi: Add struct for args to execution functions Mike Christie
2022-12-14 23:49 ` [PATCH v3 01/15] " Mike Christie
2022-12-15 1:13 ` Bart Van Assche
2022-12-15 8:13 ` Christoph Hellwig
2022-12-15 9:59 ` John Garry
2022-12-14 23:49 ` [PATCH v3 02/15] ata: libata-scsi: Convert to scsi_execute_cmd Mike Christie
2022-12-14 23:49 ` [PATCH v3 03/15] hwmon: drivetemp: " Mike Christie
2022-12-14 23:49 ` [PATCH v3 04/15] scsi: ch: " Mike Christie
2022-12-14 23:49 ` [PATCH v3 05/15] scsi: scsi_dh: " Mike Christie
2022-12-14 23:49 ` [PATCH v3 06/15] scsi: core: " Mike Christie
2022-12-15 8:14 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 07/15] scsi: spi: " Mike Christie
2022-12-14 23:49 ` [PATCH v3 08/15] scsi: sd: " Mike Christie
2022-12-15 8:14 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 09/15] scsi: zbc: " Mike Christie
2022-12-15 8:14 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 10/15] scsi: ses: " Mike Christie
2022-12-14 23:49 ` [PATCH v3 11/15] scsi: sr: " Mike Christie
2022-12-15 8:14 ` Christoph Hellwig
2022-12-14 23:49 ` [PATCH v3 12/15] scsi: virtio_scsi: " Mike Christie
2022-12-15 8:15 ` Christoph Hellwig
2022-12-18 21:40 ` Mike Christie
2022-12-23 15:57 ` Christoph Hellwig
2022-12-23 18:43 ` michael.christie
2022-12-14 23:49 ` [PATCH v3 13/15] scsi: target_core_pscsi: " Mike Christie
2022-12-14 23:50 ` [PATCH v3 14/15] scsi: cxlflash: " Mike Christie
2022-12-14 23:50 ` [PATCH v3 15/15] scsi: Remove scsi_execute_req/scsi_execute functions Mike Christie
2022-12-15 8:13 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.