public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com,
	hch@lst.de, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org,
	james.bottomley@hansenpartnership.com
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH v2 08/15] scsi: sd: Convert to scsi_execute_args
Date: Fri,  9 Dec 2022 00:13:18 -0600	[thread overview]
Message-ID: <20221209061325.705999-9-michael.christie@oracle.com> (raw)
In-Reply-To: <20221209061325.705999-1-michael.christie@oracle.com>

scsi_execute* is going to be removed. Convert sd_mod to use
scsi_execute_args.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/sd.c | 80 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 54 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 47dafe6b8a66..4032db01cb63 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_args(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,6 +1586,9 @@ 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;
+	struct scsi_exec_args exec_args = {
+		.req_flags = BLK_MQ_REQ_PM,
+	};
 
 	if (!scsi_device_online(sdp))
 		return -ENODEV;
@@ -1590,6 +1596,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
 	/* caller might not be interested in sense, but we need it */
 	if (!sshdr)
 		sshdr = &my_sshdr;
+	exec_args.sshdr = sshdr;
 
 	for (retries = 3; retries > 0; --retries) {
 		unsigned char cmd[16] = { 0 };
@@ -1602,8 +1609,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_args(sdp, cmd, REQ_OP_DRV_IN, NULL, 0,
+					timeout, sdkp->max_retries, exec_args);
 		if (res == 0)
 			break;
 	}
@@ -1745,6 +1752,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 +1768,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_args(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 +2099,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 +2117,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_args(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 +2178,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,
-						 SD_TIMEOUT, sdkp->max_retries,
-						 NULL);
+				scsi_execute_args(sdkp->device, cmd,
+						  REQ_OP_DRV_IN, NULL, 0,
+						  SD_TIMEOUT, sdkp->max_retries,
+						  exec_args);
 				spintime_expire = jiffies + 100 * HZ;
 				spintime = 1;
 			}
@@ -2296,6 +2311,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 +2331,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_args(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 +2405,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 +2419,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_args(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 +3658,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 +3674,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_args(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 +3815,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_args(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


  parent reply	other threads:[~2022-12-09  6:14 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09  6:13 [PATCH v2 00/15] scsi: Add struct for args to execution functions Mike Christie
2022-12-09  6:13 ` [PATCH v2 01/15] " Mike Christie
2022-12-09 10:40   ` John Garry
2022-12-09 17:15     ` Mike Christie
2022-12-09 18:37       ` Mike Christie
2022-12-09 18:47         ` Bart Van Assche
2022-12-12 16:17           ` John Garry
2022-12-12 17:03             ` Mike Christie
2022-12-12 19:45   ` Bart Van Assche
2022-12-12 21:17     ` Mike Christie
2022-12-09  6:13 ` [PATCH v2 02/15] scsi: libata: Convert to scsi_execute_args Mike Christie
2022-12-09  9:55   ` John Garry
2022-12-12  5:11   ` Damien Le Moal
2022-12-09  6:13 ` [PATCH v2 03/15] hwmon: drivetemp: Convert to scsi_execute_cmd Mike Christie
2022-12-09  9:56   ` John Garry
2022-12-12 20:58   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 04/15] scsi: ch: Convert to scsi_execute_args Mike Christie
2022-12-09  9:57   ` John Garry
2022-12-09 17:20   ` kernel test robot
2022-12-12 19:46   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 05/15] scsi: scsi_dh: " Mike Christie
2022-12-09 10:03   ` John Garry
2022-12-09 18:21   ` kernel test robot
2022-12-09 19:11   ` kernel test robot
2022-12-12 21:00   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 06/15] scsi: core: Convert to scsi_execute_args/cmd Mike Christie
2022-12-09 10:05   ` John Garry
2022-12-12 21:04   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 07/15] scsi: spi: Convert to scsi_execute_args Mike Christie
2022-12-09 10:10   ` John Garry
2022-12-12 21:16     ` Bart Van Assche
2022-12-09  6:13 ` Mike Christie [this message]
2022-12-09 10:12   ` [PATCH v2 08/15] scsi: sd: " John Garry
2022-12-12 21:16     ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 09/15] scsi: zbc: " Mike Christie
2022-12-09 10:13   ` John Garry
2022-12-12 21:17   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 10/15] scsi: ses: " Mike Christie
2022-12-09 10:14   ` John Garry
2022-12-12 21:17   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 11/15] scsi: sr: Convert to scsi_execute_args/cmd Mike Christie
2022-12-09 10:20   ` John Garry
2022-12-12 21:18   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 12/15] scsi: virtio_scsi: Convert to scsi_execute_cmd Mike Christie
2022-12-09 10:21   ` John Garry
2022-12-12 21:29   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 13/15] scsi: target_core_pscsi: " Mike Christie
2022-12-09 10:22   ` John Garry
2022-12-12 21:30   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 14/15] scsi: cxlflash: Convert to scsi_execute_args/cmd Mike Christie
2022-12-09 10:23   ` John Garry
2022-12-12 21:30   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 15/15] scsi: Remove scsi_execute_req/scsi_execute functions Mike Christie
2022-12-09 10:23   ` John Garry
2022-12-12 21:31   ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221209061325.705999-9-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=john.g.garry@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mwilck@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox