linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/15] Add struct to pass in optional args to scsi_execute
@ 2022-11-22  3:39 Mike Christie
  2022-11-22  3:39 ` [PATCH 01/15] scsi: Add struct for args to execution functions Mike Christie
                   ` (14 more replies)
  0 siblings, 15 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: bvanassche, mwilck, hch, martin.petersen, linux-scsi, james.bottomley

The following patches made over Martin's 6.1 scsi queue branch adds a
struct that contains optinal arguments to the scsi_execute* functions.
Right now, it's just a nice cleanup, but will be needed for the patches
that allow the scsi passthrough users to control retries. I separated
the 2 sets to make it easier to review and post.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/15] scsi: Add struct for args to execution functions
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  6:36   ` Christoph Hellwig
  2022-11-22  9:16   ` John Garry
  2022-11-22  3:39 ` [PATCH 02/15] scsi: libata: Convert to scsi_execute_cmd Mike Christie
                   ` (13 subsequent siblings)
  14 siblings, 2 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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 and adds a new helper
scsi_execute_cmd.

The next patches will convert scsi_execute and scsi_execute_req users to
scsi_execute_cmd then remove scsi_execute and scsi_execute_req.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/scsi_lib.c    | 50 ++++++++++++++-----------------
 include/scsi/scsi_device.h | 61 +++++++++++++++++++++++++++++---------
 2 files changed, 69 insertions(+), 42 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ec890865abae..327eb2df5583 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -185,39 +185,31 @@ 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)
 {
 	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);
+	req = scsi_alloc_request(sdev->request_queue, opf,
+				 args ? args->req_flags : 0);
 	if (IS_ERR(req))
 		return PTR_ERR(req);
 
@@ -232,8 +224,6 @@ 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;
 
 	/*
 	 * head injection *required* here otherwise quiesce won't work
@@ -249,20 +239,24 @@ 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)
-		scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len,
-				     sshdr);
+	if (args) {
+		if (args->resid)
+			*args->resid = scmd->resid_len;
+		if (args->sense && scmd->sense_len)
+			memcpy(args->sense, scmd->sense_buffer,
+			       SCSI_SENSE_BUFFERSIZE);
+		if (args->sshdr)
+			scsi_normalize_sense(scmd->sense_buffer,
+					     scmd->sense_len, 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 24bdbf7999ab..578f344e330d 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -454,28 +454,61 @@ 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_cmd(sdev, cmd, opf, buffer, bufflen, timeout,	\
+			 retries, args)					\
 ({									\
-	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);						\
+	BUILD_BUG_ON(args.sense &&					\
+		     args.sense_len != SCSI_SENSE_BUFFERSIZE);		\
+	__scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, timeout,	\
+			   retries, &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)						\
+({									\
+	BUILD_BUG_ON((_sense) != NULL &&				\
+		     sizeof(_sense) != SCSI_SENSE_BUFFERSIZE);		\
+	__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] 23+ messages in thread

* [PATCH 02/15] scsi: libata: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
  2022-11-22  3:39 ` [PATCH 01/15] scsi: Add struct for args to execution functions Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 03/15] hwmon: drivetemp: " Mike Christie
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: bvanassche, mwilck, hch, martin.petersen, linux-scsi, james.bottomley
  Cc: Mike Christie

scsi_execute_req is going to be removed. Convert libata to
scsi_execute_cmd.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/ata/libata-scsi.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 06a3d95ed8f9..b4f3a2ce9d0f 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -367,7 +367,6 @@ 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;
 	int cmd_result;
 
@@ -391,11 +390,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 +410,12 @@ 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,
+				      ((struct scsi_exec_args) {
+					.sense = sensebuf,
+					.sense_len = sizeof(sensebuf),
+					.sshdr = &sshdr, }));
 	if (cmd_result < 0) {
 		rc = cmd_result;
 		goto error;
@@ -497,9 +497,12 @@ 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,
+				      ((struct scsi_exec_args) {
+					.sense = sensebuf,
+					.sense_len = sizeof(sensebuf),
+					.sshdr = &sshdr }));
 	if (cmd_result < 0) {
 		rc = cmd_result;
 		goto error;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/15] hwmon: drivetemp: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
  2022-11-22  3:39 ` [PATCH 01/15] scsi: Add struct for args to execution functions Mike Christie
  2022-11-22  3:39 ` [PATCH 02/15] scsi: libata: Convert to scsi_execute_cmd Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 04/15] scsi: ch: " Mike Christie
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 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..015a16d6b007 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] 23+ messages in thread

* [PATCH 04/15] scsi: ch: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (2 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 03/15] hwmon: drivetemp: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 05/15] scsi: scsi_dh: " Mike Christie
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/scsi/ch.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 7ab29eaec6f3..dedfa84476cd 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -184,8 +184,7 @@ 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;
@@ -195,9 +194,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,
 
  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,
+				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
 	if (result < 0)
 		return result;
 	if (scsi_sense_valid(&sshdr)) {
@@ -254,7 +253,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 +283,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 +305,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 +433,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 +454,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 +480,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 +530,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 +798,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] 23+ messages in thread

* [PATCH 05/15] scsi: scsi_dh: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (3 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 04/15] scsi: ch: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 06/15] scsi: core: " Mike Christie
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/scsi/device_handler/scsi_dh_alua.c  | 22 +++++++++++----------
 drivers/scsi/device_handler/scsi_dh_emc.c   | 10 +++++-----
 drivers/scsi/device_handler/scsi_dh_hp_sw.c | 18 +++++++++--------
 drivers/scsi/device_handler/scsi_dh_rdac.c  | 12 ++++++-----
 4 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 693cd827e138..0a595275eea4 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -127,8 +127,8 @@ 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;
 
 	/* Prepare the command. */
 	memset(cdb, 0x0, MAX_COMMAND_SIZE);
@@ -139,9 +139,10 @@ 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,
+				((struct scsi_exec_args) { .sshdr = sshdr }));
 }
 
 /*
@@ -157,8 +158,8 @@ 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;
 
 	/* Prepare the data buffer */
 	memset(stpg_data, 0, stpg_len);
@@ -171,9 +172,10 @@ 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,
+				((struct scsi_exec_args) { .sshdr = sshdr }));
 }
 
 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..7da4c5ceab89 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -239,8 +239,8 @@ 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;
 
 	if (csdev->flags & CLARIION_SHORT_TRESPASS) {
 		page22 = short_trespass;
@@ -263,9 +263,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,
+			       ((struct scsi_exec_args) { .sshdr = &sshdr }));
 	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..cb2f01b600c2 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -83,12 +83,13 @@ 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;
 
 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,
+			       ((struct scsi_exec_args) { .sshdr = &sshdr }));
 	if (res) {
 		if (scsi_sense_valid(&sshdr))
 			ret = tur_done(sdev, h, &sshdr);
@@ -121,12 +122,13 @@ 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;
 
 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,
+			       ((struct scsi_exec_args) { .sshdr = &sshdr }));
 	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..08ad6a2282ba 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -536,8 +536,9 @@ 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;
+	int result;
 
 	spin_lock(&ctlr->ms_lock);
 	list_splice_init(&ctlr->ms_head, &list);
@@ -555,9 +556,10 @@ 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)) {
+	result = scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select,
+				  data_size, RDAC_TIMEOUT * HZ, RDAC_RETRIES,
+				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
+	if (result) {
 		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] 23+ messages in thread

* [PATCH 06/15] scsi: core: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (4 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 05/15] scsi: scsi_dh: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  6:38   ` Christoph Hellwig
  2022-11-22  3:39 ` [PATCH 07/15] scsi: spi: " Mike Christie
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/scsi/scsi.c       |  9 +++++----
 drivers/scsi/scsi_ioctl.c |  5 +++--
 drivers/scsi/scsi_lib.c   | 17 +++++++++++------
 drivers/scsi/scsi_scan.c  | 22 ++++++++++++++--------
 4 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1426b9b03612..fc65d64b7299 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;
 
@@ -531,8 +531,9 @@ 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,
+				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
 
 	if (result < 0)
 		return result;
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 8baff7edf7c3..6956849bd1f1 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -73,8 +73,9 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 	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,
+				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
 
 	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 327eb2df5583..403bcda8ef09 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2130,8 +2130,9 @@ 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,
+			       ((struct scsi_exec_args) { .sshdr = sshdr }));
 	kfree(real_buffer);
 	return ret;
 }
@@ -2195,8 +2196,9 @@ 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,
+				  ((struct scsi_exec_args) { .sshdr = sshdr }));
 	if (result < 0)
 		return result;
 
@@ -2280,8 +2282,11 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
 
 	/* 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,
+					  ((struct scsi_exec_args) {
+						.sshdr = sshdr
+					  }));
 		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 5d27f5196de6..1af75cff9489 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -210,8 +210,8 @@ 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_TIMEOUT, 3, NULL);
+	__scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, result, 0x2a,
+			   SCSI_TIMEOUT, 3, NULL);
 }
 
 static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,
@@ -674,10 +674,13 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 
 		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);
+					  ((struct scsi_exec_args) {
+						.sshdr = &sshdr,
+						.resid = &resid
+					  }));
 
 		SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
 				"scsi scan: INQUIRY %s with code 0x%x\n",
@@ -1477,9 +1480,12 @@ 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,
+					  ((struct scsi_exec_args) {
+						.sshdr = &sshdr
+					  }));
 
 		SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev,
 				"scsi scan: REPORT LUNS"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/15] scsi: spi: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (5 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 06/15] scsi: core: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 08/15] scsi: sd: " Mike Christie
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/scsi/scsi_transport_spi.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index f569cf0095c2..ea71135ab3b1 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -105,13 +105,13 @@ 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;
 
 	if (!sshdr)
 		sshdr = &sshdr_tmp;
@@ -121,12 +121,12 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
 		 * 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,
+					  ((struct scsi_exec_args) {
+						.sshdr = sshdr,
+						.req_flags = BLK_MQ_REQ_PM,
+					  }));
 		if (result < 0 || !scsi_sense_valid(sshdr) ||
 		    sshdr->sense_key != UNIT_ATTENTION)
 			break;
@@ -675,7 +675,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 +697,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 +722,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 +828,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 +841,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] 23+ messages in thread

* [PATCH 08/15] scsi: sd: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (6 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 07/15] scsi: spi: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 09/15] scsi: zbc: " Mike Christie
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/scsi/sd.c | 77 +++++++++++++++++++++++++++++++----------------
 1 file changed, 51 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index bc60ec91dc8f..678f2f5e7813 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -671,9 +671,11 @@ 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,
+			       ((struct scsi_exec_args) {
+					.req_flags = BLK_MQ_REQ_PM
+			       }));
 	return ret <= 0 ? ret : -EIO;
 }
 #endif /* CONFIG_BLK_SED_OPAL */
@@ -1594,8 +1596,12 @@ 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,
+				       ((struct scsi_exec_args) {
+						.sshdr = sshdr,
+						.req_flags = BLK_MQ_REQ_PM
+				       }));
 		if (res == 0)
 			break;
 	}
@@ -1750,8 +1756,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,
+				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
 
 	if (scsi_status_is_check_condition(result) &&
 	    scsi_sense_valid(&sshdr)) {
@@ -2095,10 +2102,13 @@ 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,
+						      ((struct scsi_exec_args) {
+								.sshdr = &sshdr
+						      }));
 
 			/*
 			 * If the drive has indicated to us that it
@@ -2155,10 +2165,12 @@ 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);
+						 ((struct scsi_exec_args) {
+							.sshdr = &sshdr
+						 }));
 				spintime_expire = jiffies + 100 * HZ;
 				spintime = 1;
 			}
@@ -2305,9 +2317,12 @@ 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,
+					      ((struct scsi_exec_args) {
+							.sshdr = &sshdr
+					      }));
 
 		if (media_not_present(sdkp, &sshdr))
 			return -ENODEV;
@@ -2390,9 +2405,11 @@ 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,
+					      ((struct scsi_exec_args) {
+							.sshdr = &sshdr
+					      }));
 
 		if (media_not_present(sdkp, &sshdr))
 			return -ENODEV;
@@ -3641,8 +3658,12 @@ 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,
+			       ((struct scsi_exec_args) {
+					.sshdr = &sshdr,
+					.req_flags = BLK_MQ_REQ_PM
+			       }));
 	if (res) {
 		sd_print_result(sdkp, "Start/Stop Unit failed", res);
 		if (res > 0 && scsi_sense_valid(&sshdr)) {
@@ -3782,10 +3803,14 @@ 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 };
-
-		if (scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL,
-				 NULL, sdp->request_queue->rq_timeout, 1, 0,
-				 RQF_PM, NULL))
+		int result;
+
+		result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0,
+					  sdp->request_queue->rq_timeout, 1,
+					  ((struct scsi_exec_args) {
+						.req_flags = BLK_MQ_REQ_PM
+					  }));
+		if (result)
 			sd_printk(KERN_NOTICE, sdkp,
 				  "Failed to clear sense data\n");
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/15] scsi: zbc: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (7 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 08/15] scsi: sd: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 10/15] scsi: ses: " Mike Christie
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/scsi/sd_zbc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index bd15624c6322..e6bfb3a7cb94 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -157,9 +157,9 @@ 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,
+				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
 	if (result) {
 		sd_printk(KERN_ERR, sdkp,
 			  "REPORT ZONES start lba %llu failed\n", lba);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/15] scsi: ses: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (8 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 09/15] scsi: zbc: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 11/15] scsi: sr: " Mike Christie
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 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..fa9966331670 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -91,8 +91,11 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
 	struct scsi_sense_hdr 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,
+				       ((struct scsi_exec_args) {
+						.sshdr = &sshdr
+				       }));
 	} while (ret > 0 && --retries && scsi_sense_valid(&sshdr) &&
 		 (sshdr.sense_key == NOT_READY ||
 		  (sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29)));
@@ -132,8 +135,11 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code,
 	unsigned int retries = SES_RETRIES;
 
 	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,
+					  ((struct scsi_exec_args) {
+							.sshdr = &sshdr
+					  }));
 	} 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] 23+ messages in thread

* [PATCH 11/15] scsi: sr: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (9 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 10/15] scsi: ses: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 12/15] scsi: virtio_scsi: " Mike Christie
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/scsi/sr.c       | 11 ++++++-----
 drivers/scsi/sr_ioctl.c |  9 +++++----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index a278b739d0c5..093ff071bb3f 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -172,8 +172,9 @@ static unsigned int sr_get_events(struct scsi_device *sdev)
 	struct scsi_sense_hdr 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,
+				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
 	if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION)
 		return DISK_EVENT_MEDIA_CHANGE;
 
@@ -730,9 +731,9 @@ 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,
-					      SR_TIMEOUT, MAX_RETRIES, 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..4a2342888a4f 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -202,10 +202,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,
+				  ((struct scsi_exec_args) { .sshdr = sshdr }));
 	/* 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] 23+ messages in thread

* [PATCH 12/15] scsi: virtio_scsi: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (10 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 11/15] scsi: sr: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 13/15] scsi: target_core_pscsi: " Mike Christie
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/scsi/virtio_scsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index d07d24c06b54..87751287d506 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -347,9 +347,9 @@ 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,
-					  SD_TIMEOUT, SD_MAX_RETRIES, 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) {
 			/* PQ indicates the LUN is not attached */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 13/15] scsi: target_core_pscsi: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (11 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 12/15] scsi: virtio_scsi: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 14/15] scsi: cxlflash: " Mike Christie
  2022-11-22  3:39 ` [PATCH 15/15] scsi: Remove scsi_execute functions Mike Christie
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---
 drivers/target/target_core_pscsi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 69a4c9581e80..f0e4813627f5 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -144,8 +144,8 @@ 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 +195,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 +230,9 @@ 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] 23+ messages in thread

* [PATCH 14/15] scsi: cxlflash: Convert to scsi_execute_cmd
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (12 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 13/15] scsi: target_core_pscsi: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  2022-11-22  3:39 ` [PATCH 15/15] scsi: Remove scsi_execute functions Mike Christie
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: 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>
---

Note that I updated the comments to reflect the new function being used.
Because the new function name is longer it caused me to have to adjust the
entire chunk of comments. There should be no other changes in the comments
changes.


 drivers/scsi/cxlflash/superpipe.c | 32 +++++++++++++++----------------
 drivers/scsi/cxlflash/vlun.c      | 32 +++++++++++++++----------------
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index df0ebabbf387..49f23f3517cb 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.
@@ -357,9 +357,9 @@ 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,
+				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
 	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..262763810570 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] 23+ messages in thread

* [PATCH 15/15] scsi: Remove scsi_execute functions
  2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
                   ` (13 preceding siblings ...)
  2022-11-22  3:39 ` [PATCH 14/15] scsi: cxlflash: " Mike Christie
@ 2022-11-22  3:39 ` Mike Christie
  14 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22  3:39 UTC (permalink / raw)
  To: bvanassche, mwilck, hch, martin.petersen, linux-scsi, james.bottomley
  Cc: Mike Christie

The scsi_execute* functions are no longer used so remove them.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 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 578f344e330d..3de7cbe95bdc 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -479,37 +479,6 @@ int __scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd,
 			   retries, &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)						\
-({									\
-	BUILD_BUG_ON((_sense) != NULL &&				\
-		     sizeof(_sense) != SCSI_SENSE_BUFFERSIZE);		\
-	__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] 23+ messages in thread

* Re: [PATCH 01/15] scsi: Add struct for args to execution functions
  2022-11-22  3:39 ` [PATCH 01/15] scsi: Add struct for args to execution functions Mike Christie
@ 2022-11-22  6:36   ` Christoph Hellwig
  2022-11-22  9:16   ` John Garry
  1 sibling, 0 replies; 23+ messages in thread
From: Christoph Hellwig @ 2022-11-22  6:36 UTC (permalink / raw)
  To: Mike Christie
  Cc: bvanassche, mwilck, hch, martin.petersen, linux-scsi, james.bottomley

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 06/15] scsi: core: Convert to scsi_execute_cmd
  2022-11-22  3:39 ` [PATCH 06/15] scsi: core: " Mike Christie
@ 2022-11-22  6:38   ` Christoph Hellwig
  2022-11-22 16:13     ` Mike Christie
  0 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2022-11-22  6:38 UTC (permalink / raw)
  To: Mike Christie
  Cc: bvanassche, mwilck, hch, martin.petersen, linux-scsi, james.bottomley

On Mon, Nov 21, 2022 at 09:39:25PM -0600, Mike Christie wrote:
> +	result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer,
> +				  request_len, 30 * HZ, 3,
> +				  ((struct scsi_exec_args) { .sshdr = &sshdr }));

Maybe it's me, but I hate the syntax to declare structs inside argument
list.  But even when we go with it, splitting it into multiple lines
would be a lot more readable:
				  ((struct scsi_exec_args) {
				  	.sshdr = &sshdr,
				  }));


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 01/15] scsi: Add struct for args to execution functions
  2022-11-22  3:39 ` [PATCH 01/15] scsi: Add struct for args to execution functions Mike Christie
  2022-11-22  6:36   ` Christoph Hellwig
@ 2022-11-22  9:16   ` John Garry
  2022-11-22 15:44     ` Mike Christie
  1 sibling, 1 reply; 23+ messages in thread
From: John Garry @ 2022-11-22  9:16 UTC (permalink / raw)
  To: Mike Christie, bvanassche, mwilck, hch, martin.petersen,
	linux-scsi, james.bottomley

On 22/11/2022 03:39, 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 and adds a new helper
> scsi_execute_cmd.
> 
> The next patches will convert scsi_execute and scsi_execute_req users to
> scsi_execute_cmd then remove scsi_execute and scsi_execute_req.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>   drivers/scsi/scsi_lib.c    | 50 ++++++++++++++-----------------
>   include/scsi/scsi_device.h | 61 +++++++++++++++++++++++++++++---------
>   2 files changed, 69 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index ec890865abae..327eb2df5583 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -185,39 +185,31 @@ 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)

I suppose that you could alternatively continue to pass a struct instead 
of a struct pointer, so no need for the checks for args being NULL. As I 
see, all the direct callers of __scsi_execute_cmd() pass NULL anyway, so 
another macro in scsi_device.h could make it concise to implement.

>   {
>   	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);
> +	req = scsi_alloc_request(sdev->request_queue, opf,
> +				 args ? args->req_flags : 0);
>   	if (IS_ERR(req))
>   		return PTR_ERR(req);
>   
> @@ -232,8 +224,6 @@ 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;

Are we accidentally losing RQF_QUIET? Or does it matter?

The rest looks good, IMHO.

Thanks,
John

>   
>   	/*
>   	 * head injection *required* here otherwise quiesce won't work
> @@ -249,20 +239,24 @@ 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)
> -		scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len,
> -				     sshdr);
> +	if (args) {
> +		if (args->resid)
> +			*args->resid = scmd->resid_len;
> +		if (args->sense && scmd->sense_len)
> +			memcpy(args->sense, scmd->sense_buffer,
> +			       SCSI_SENSE_BUFFERSIZE);
> +		if (args->sshdr)
> +			scsi_normalize_sense(scmd->sense_buffer,
> +					     scmd->sense_len, 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 24bdbf7999ab..578f344e330d 100644
> --- a/include/scsi/scsi_device.h
> +++ b/include/scsi/scsi_device.h
> @@ -454,28 +454,61 @@ 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_cmd(sdev, cmd, opf, buffer, bufflen, timeout,	\
> +			 retries, args)					\
>   ({									\
> -	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);						\
> +	BUILD_BUG_ON(args.sense &&					\
> +		     args.sense_len != SCSI_SENSE_BUFFERSIZE);		\
> +	__scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, timeout,	\
> +			   retries, &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)						\
> +({									\
> +	BUILD_BUG_ON((_sense) != NULL &&				\
> +		     sizeof(_sense) != SCSI_SENSE_BUFFERSIZE);		\
> +	__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);


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 01/15] scsi: Add struct for args to execution functions
  2022-11-22  9:16   ` John Garry
@ 2022-11-22 15:44     ` Mike Christie
  0 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22 15:44 UTC (permalink / raw)
  To: John Garry, bvanassche, mwilck, hch, martin.petersen, linux-scsi,
	james.bottomley

On 11/22/22 3:16 AM, John Garry wrote:
>>
>> -    req->rq_flags |= rq_flags | RQF_QUIET;
> 
> Are we accidentally losing RQF_QUIET? Or does it matter?
> 

That was a mistake. Will fix.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 06/15] scsi: core: Convert to scsi_execute_cmd
  2022-11-22  6:38   ` Christoph Hellwig
@ 2022-11-22 16:13     ` Mike Christie
  2022-11-22 18:46       ` Bart Van Assche
  0 siblings, 1 reply; 23+ messages in thread
From: Mike Christie @ 2022-11-22 16:13 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: bvanassche, mwilck, martin.petersen, linux-scsi, james.bottomley

On 11/22/22 12:38 AM, Christoph Hellwig wrote:
> On Mon, Nov 21, 2022 at 09:39:25PM -0600, Mike Christie wrote:
>> +	result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer,
>> +				  request_len, 30 * HZ, 3,
>> +				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
> 
> Maybe it's me, but I hate the syntax to declare structs inside argument

I'll change it to setup the scsi_exec_args struct like normal. I've got this
comment several times now.

With the current design we know all the args when we declare the variables so
I can do it then like normal.

> list.  But even when we go with it, splitting it into multiple lines
> would be a lot more readable:
> 				  ((struct scsi_exec_args) {
> 				  	.sshdr = &sshdr,
> 				  }));
> 


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 06/15] scsi: core: Convert to scsi_execute_cmd
  2022-11-22 16:13     ` Mike Christie
@ 2022-11-22 18:46       ` Bart Van Assche
  2022-11-22 20:06         ` Mike Christie
  0 siblings, 1 reply; 23+ messages in thread
From: Bart Van Assche @ 2022-11-22 18:46 UTC (permalink / raw)
  To: Mike Christie, Christoph Hellwig
  Cc: mwilck, martin.petersen, linux-scsi, james.bottomley

On 11/22/22 08:13, Mike Christie wrote:
> On 11/22/22 12:38 AM, Christoph Hellwig wrote:
>> On Mon, Nov 21, 2022 at 09:39:25PM -0600, Mike Christie wrote:
>>> +	result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer,
>>> +				  request_len, 30 * HZ, 3,
>>> +				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
>>
>> Maybe it's me, but I hate the syntax to declare structs inside argument
> 
> I'll change it to setup the scsi_exec_args struct like normal. I've got this
> comment several times now.
> 
> With the current design we know all the args when we declare the variables so
> I can do it then like normal.

Will struct scsi_exec_args be retained? I'm asking this because I'd like 
to add another argument to the (already too large) argument list of 
scsi_execute().

Thanks,

Bart.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 06/15] scsi: core: Convert to scsi_execute_cmd
  2022-11-22 18:46       ` Bart Van Assche
@ 2022-11-22 20:06         ` Mike Christie
  0 siblings, 0 replies; 23+ messages in thread
From: Mike Christie @ 2022-11-22 20:06 UTC (permalink / raw)
  To: Bart Van Assche, Christoph Hellwig
  Cc: mwilck, martin.petersen, linux-scsi, james.bottomley

On 11/22/22 12:46 PM, Bart Van Assche wrote:
> On 11/22/22 08:13, Mike Christie wrote:
>> On 11/22/22 12:38 AM, Christoph Hellwig wrote:
>>> On Mon, Nov 21, 2022 at 09:39:25PM -0600, Mike Christie wrote:
>>>> +    result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer,
>>>> +                  request_len, 30 * HZ, 3,
>>>> +                  ((struct scsi_exec_args) { .sshdr = &sshdr }));
>>>
>>> Maybe it's me, but I hate the syntax to declare structs inside argument
>>
>> I'll change it to setup the scsi_exec_args struct like normal. I've got this
>> comment several times now.
>>
>> With the current design we know all the args when we declare the variables so
>> I can do it then like normal.
> 
> Will struct scsi_exec_args be retained? I'm asking this because I'd like to add another argument to the (already too large) argument list of scsi_execute().

Yes. I just meant for the above chunk I would move the struct setup like this:

@@ -509,6 +509,9 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
 {
 	unsigned char cmd[16];
 	struct scsi_sense_hdr sshdr;
+	struct scsi_exec_args exec_args = {
+		.sshdr = &sshdr,
+	};
 	int result, request_len;
 
 	if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
@@ -532,8 +535,7 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
 	memset(buffer, 0, len);
 
 	result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer,
-				  request_len, 30 * HZ, 3,
-				  ((struct scsi_exec_args) { .sshdr = &sshdr }));
+				  request_len, 30 * HZ, 3, exec_args);
 
 	if (result < 0)
 		return result;



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-11-22 20:07 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22  3:39 [PATCH 00/15] Add struct to pass in optional args to scsi_execute Mike Christie
2022-11-22  3:39 ` [PATCH 01/15] scsi: Add struct for args to execution functions Mike Christie
2022-11-22  6:36   ` Christoph Hellwig
2022-11-22  9:16   ` John Garry
2022-11-22 15:44     ` Mike Christie
2022-11-22  3:39 ` [PATCH 02/15] scsi: libata: Convert to scsi_execute_cmd Mike Christie
2022-11-22  3:39 ` [PATCH 03/15] hwmon: drivetemp: " Mike Christie
2022-11-22  3:39 ` [PATCH 04/15] scsi: ch: " Mike Christie
2022-11-22  3:39 ` [PATCH 05/15] scsi: scsi_dh: " Mike Christie
2022-11-22  3:39 ` [PATCH 06/15] scsi: core: " Mike Christie
2022-11-22  6:38   ` Christoph Hellwig
2022-11-22 16:13     ` Mike Christie
2022-11-22 18:46       ` Bart Van Assche
2022-11-22 20:06         ` Mike Christie
2022-11-22  3:39 ` [PATCH 07/15] scsi: spi: " Mike Christie
2022-11-22  3:39 ` [PATCH 08/15] scsi: sd: " Mike Christie
2022-11-22  3:39 ` [PATCH 09/15] scsi: zbc: " Mike Christie
2022-11-22  3:39 ` [PATCH 10/15] scsi: ses: " Mike Christie
2022-11-22  3:39 ` [PATCH 11/15] scsi: sr: " Mike Christie
2022-11-22  3:39 ` [PATCH 12/15] scsi: virtio_scsi: " Mike Christie
2022-11-22  3:39 ` [PATCH 13/15] scsi: target_core_pscsi: " Mike Christie
2022-11-22  3:39 ` [PATCH 14/15] scsi: cxlflash: " Mike Christie
2022-11-22  3:39 ` [PATCH 15/15] scsi: Remove scsi_execute functions Mike Christie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).