Lines Matching refs:cmd

888 static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd)  in sd_setup_unmap_cmnd()  argument
890 struct scsi_device *sdp = cmd->device; in sd_setup_unmap_cmnd()
891 struct request *rq = scsi_cmd_to_rq(cmd); in sd_setup_unmap_cmnd()
902 cmd->cmd_len = 10; in sd_setup_unmap_cmnd()
903 cmd->cmnd[0] = UNMAP; in sd_setup_unmap_cmnd()
904 cmd->cmnd[8] = 24; in sd_setup_unmap_cmnd()
911 cmd->allowed = sdkp->max_retries; in sd_setup_unmap_cmnd()
912 cmd->transfersize = data_len; in sd_setup_unmap_cmnd()
915 return scsi_alloc_sgtables(cmd); in sd_setup_unmap_cmnd()
918 static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, in sd_setup_write_same16_cmnd() argument
921 struct scsi_device *sdp = cmd->device; in sd_setup_write_same16_cmnd()
922 struct request *rq = scsi_cmd_to_rq(cmd); in sd_setup_write_same16_cmnd()
931 cmd->cmd_len = 16; in sd_setup_write_same16_cmnd()
932 cmd->cmnd[0] = WRITE_SAME_16; in sd_setup_write_same16_cmnd()
934 cmd->cmnd[1] = 0x8; /* UNMAP */ in sd_setup_write_same16_cmnd()
935 put_unaligned_be64(lba, &cmd->cmnd[2]); in sd_setup_write_same16_cmnd()
936 put_unaligned_be32(nr_blocks, &cmd->cmnd[10]); in sd_setup_write_same16_cmnd()
938 cmd->allowed = sdkp->max_retries; in sd_setup_write_same16_cmnd()
939 cmd->transfersize = data_len; in sd_setup_write_same16_cmnd()
942 return scsi_alloc_sgtables(cmd); in sd_setup_write_same16_cmnd()
945 static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, in sd_setup_write_same10_cmnd() argument
948 struct scsi_device *sdp = cmd->device; in sd_setup_write_same10_cmnd()
949 struct request *rq = scsi_cmd_to_rq(cmd); in sd_setup_write_same10_cmnd()
958 cmd->cmd_len = 10; in sd_setup_write_same10_cmnd()
959 cmd->cmnd[0] = WRITE_SAME; in sd_setup_write_same10_cmnd()
961 cmd->cmnd[1] = 0x8; /* UNMAP */ in sd_setup_write_same10_cmnd()
962 put_unaligned_be32(lba, &cmd->cmnd[2]); in sd_setup_write_same10_cmnd()
963 put_unaligned_be16(nr_blocks, &cmd->cmnd[7]); in sd_setup_write_same10_cmnd()
965 cmd->allowed = sdkp->max_retries; in sd_setup_write_same10_cmnd()
966 cmd->transfersize = data_len; in sd_setup_write_same10_cmnd()
969 return scsi_alloc_sgtables(cmd); in sd_setup_write_same10_cmnd()
972 static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd) in sd_setup_write_zeroes_cmnd() argument
974 struct request *rq = scsi_cmd_to_rq(cmd); in sd_setup_write_zeroes_cmnd()
975 struct scsi_device *sdp = cmd->device; in sd_setup_write_zeroes_cmnd()
983 return sd_setup_write_same16_cmnd(cmd, true); in sd_setup_write_zeroes_cmnd()
985 return sd_setup_write_same10_cmnd(cmd, true); in sd_setup_write_zeroes_cmnd()
995 return sd_setup_write_same16_cmnd(cmd, false); in sd_setup_write_zeroes_cmnd()
997 return sd_setup_write_same10_cmnd(cmd, false); in sd_setup_write_zeroes_cmnd()
1060 static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd) in sd_setup_flush_cmnd() argument
1062 struct request *rq = scsi_cmd_to_rq(cmd); in sd_setup_flush_cmnd()
1066 memset(&cmd->sdb, 0, sizeof(cmd->sdb)); in sd_setup_flush_cmnd()
1068 if (cmd->device->use_16_for_sync) { in sd_setup_flush_cmnd()
1069 cmd->cmnd[0] = SYNCHRONIZE_CACHE_16; in sd_setup_flush_cmnd()
1070 cmd->cmd_len = 16; in sd_setup_flush_cmnd()
1072 cmd->cmnd[0] = SYNCHRONIZE_CACHE; in sd_setup_flush_cmnd()
1073 cmd->cmd_len = 10; in sd_setup_flush_cmnd()
1075 cmd->transfersize = 0; in sd_setup_flush_cmnd()
1076 cmd->allowed = sdkp->max_retries; in sd_setup_flush_cmnd()
1082 static blk_status_t sd_setup_rw32_cmnd(struct scsi_cmnd *cmd, bool write, in sd_setup_rw32_cmnd() argument
1086 cmd->cmd_len = SD_EXT_CDB_SIZE; in sd_setup_rw32_cmnd()
1087 cmd->cmnd[0] = VARIABLE_LENGTH_CMD; in sd_setup_rw32_cmnd()
1088 cmd->cmnd[7] = 0x18; /* Additional CDB len */ in sd_setup_rw32_cmnd()
1089 cmd->cmnd[9] = write ? WRITE_32 : READ_32; in sd_setup_rw32_cmnd()
1090 cmd->cmnd[10] = flags; in sd_setup_rw32_cmnd()
1091 cmd->cmnd[11] = dld & 0x07; in sd_setup_rw32_cmnd()
1092 put_unaligned_be64(lba, &cmd->cmnd[12]); in sd_setup_rw32_cmnd()
1093 put_unaligned_be32(lba, &cmd->cmnd[20]); /* Expected Indirect LBA */ in sd_setup_rw32_cmnd()
1094 put_unaligned_be32(nr_blocks, &cmd->cmnd[28]); in sd_setup_rw32_cmnd()
1099 static blk_status_t sd_setup_rw16_cmnd(struct scsi_cmnd *cmd, bool write, in sd_setup_rw16_cmnd() argument
1103 cmd->cmd_len = 16; in sd_setup_rw16_cmnd()
1104 cmd->cmnd[0] = write ? WRITE_16 : READ_16; in sd_setup_rw16_cmnd()
1105 cmd->cmnd[1] = flags | ((dld >> 2) & 0x01); in sd_setup_rw16_cmnd()
1106 cmd->cmnd[14] = (dld & 0x03) << 6; in sd_setup_rw16_cmnd()
1107 cmd->cmnd[15] = 0; in sd_setup_rw16_cmnd()
1108 put_unaligned_be64(lba, &cmd->cmnd[2]); in sd_setup_rw16_cmnd()
1109 put_unaligned_be32(nr_blocks, &cmd->cmnd[10]); in sd_setup_rw16_cmnd()
1114 static blk_status_t sd_setup_rw10_cmnd(struct scsi_cmnd *cmd, bool write, in sd_setup_rw10_cmnd() argument
1118 cmd->cmd_len = 10; in sd_setup_rw10_cmnd()
1119 cmd->cmnd[0] = write ? WRITE_10 : READ_10; in sd_setup_rw10_cmnd()
1120 cmd->cmnd[1] = flags; in sd_setup_rw10_cmnd()
1121 cmd->cmnd[6] = 0; in sd_setup_rw10_cmnd()
1122 cmd->cmnd[9] = 0; in sd_setup_rw10_cmnd()
1123 put_unaligned_be32(lba, &cmd->cmnd[2]); in sd_setup_rw10_cmnd()
1124 put_unaligned_be16(nr_blocks, &cmd->cmnd[7]); in sd_setup_rw10_cmnd()
1129 static blk_status_t sd_setup_rw6_cmnd(struct scsi_cmnd *cmd, bool write, in sd_setup_rw6_cmnd() argument
1143 scmd_printk(KERN_ERR, cmd, "FUA write on READ/WRITE(6) drive\n"); in sd_setup_rw6_cmnd()
1147 cmd->cmd_len = 6; in sd_setup_rw6_cmnd()
1148 cmd->cmnd[0] = write ? WRITE_6 : READ_6; in sd_setup_rw6_cmnd()
1149 cmd->cmnd[1] = (lba >> 16) & 0x1f; in sd_setup_rw6_cmnd()
1150 cmd->cmnd[2] = (lba >> 8) & 0xff; in sd_setup_rw6_cmnd()
1151 cmd->cmnd[3] = lba & 0xff; in sd_setup_rw6_cmnd()
1152 cmd->cmnd[4] = nr_blocks; in sd_setup_rw6_cmnd()
1153 cmd->cmnd[5] = 0; in sd_setup_rw6_cmnd()
1183 static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) in sd_setup_read_write_cmnd() argument
1185 struct request *rq = scsi_cmd_to_rq(cmd); in sd_setup_read_write_cmnd()
1186 struct scsi_device *sdp = cmd->device; in sd_setup_read_write_cmnd()
1199 ret = scsi_alloc_sgtables(cmd); in sd_setup_read_write_cmnd()
1205 scmd_printk(KERN_ERR, cmd, "device offline or changed\n"); in sd_setup_read_write_cmnd()
1210 scmd_printk(KERN_ERR, cmd, "access beyond end of device\n"); in sd_setup_read_write_cmnd()
1215 scmd_printk(KERN_ERR, cmd, "request not aligned to the logical block size\n"); in sd_setup_read_write_cmnd()
1236 ret = sd_zbc_prepare_zone_append(cmd, &lba, nr_blocks); in sd_setup_read_write_cmnd()
1242 dix = scsi_prot_sg_count(cmd); in sd_setup_read_write_cmnd()
1243 dif = scsi_host_dif_capable(cmd->device->host, sdkp->protection_type); in sd_setup_read_write_cmnd()
1244 dld = sd_cdl_dld(sdkp, cmd); in sd_setup_read_write_cmnd()
1247 protect = sd_setup_protect_cmnd(cmd, dix, dif); in sd_setup_read_write_cmnd()
1252 ret = sd_setup_rw32_cmnd(cmd, write, lba, nr_blocks, in sd_setup_read_write_cmnd()
1255 ret = sd_setup_rw16_cmnd(cmd, write, lba, nr_blocks, in sd_setup_read_write_cmnd()
1259 ret = sd_setup_rw10_cmnd(cmd, write, lba, nr_blocks, in sd_setup_read_write_cmnd()
1262 ret = sd_setup_rw6_cmnd(cmd, write, lba, nr_blocks, in sd_setup_read_write_cmnd()
1274 cmd->transfersize = sdp->sector_size; in sd_setup_read_write_cmnd()
1275 cmd->underflow = nr_blocks << 9; in sd_setup_read_write_cmnd()
1276 cmd->allowed = sdkp->max_retries; in sd_setup_read_write_cmnd()
1277 cmd->sdb.length = nr_blocks * sdp->sector_size; in sd_setup_read_write_cmnd()
1280 scmd_printk(KERN_INFO, cmd, in sd_setup_read_write_cmnd()
1285 scmd_printk(KERN_INFO, cmd, in sd_setup_read_write_cmnd()
1295 scsi_free_sgtables(cmd); in sd_setup_read_write_cmnd()
1299 static blk_status_t sd_init_command(struct scsi_cmnd *cmd) in sd_init_command() argument
1301 struct request *rq = scsi_cmd_to_rq(cmd); in sd_init_command()
1307 return sd_setup_unmap_cmnd(cmd); in sd_init_command()
1309 return sd_setup_write_same16_cmnd(cmd, true); in sd_init_command()
1311 return sd_setup_write_same10_cmnd(cmd, true); in sd_init_command()
1313 return sd_setup_write_same10_cmnd(cmd, false); in sd_init_command()
1318 return sd_setup_write_zeroes_cmnd(cmd); in sd_init_command()
1320 return sd_setup_flush_cmnd(cmd); in sd_init_command()
1324 return sd_setup_read_write_cmnd(cmd); in sd_init_command()
1326 return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_RESET_WRITE_POINTER, in sd_init_command()
1329 return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_RESET_WRITE_POINTER, in sd_init_command()
1332 return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_OPEN_ZONE, false); in sd_init_command()
1334 return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_CLOSE_ZONE, false); in sd_init_command()
1336 return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_FINISH_ZONE, false); in sd_init_command()
1508 unsigned int cmd, unsigned long arg) in sd_ioctl() argument
1517 "cmd=0x%x\n", disk->disk_name, cmd)); in sd_ioctl()
1528 error = scsi_ioctl_block_when_processing_errors(sdp, cmd, in sd_ioctl()
1533 if (is_sed_ioctl(cmd)) in sd_ioctl()
1534 return sed_ioctl(sdkp->opal_dev, cmd, p); in sd_ioctl()
1535 return scsi_ioctl(sdp, mode & BLK_OPEN_WRITE, cmd, p); in sd_ioctl()
1661 unsigned char cmd[16] = { 0 }; in sd_sync_cache() local
1664 cmd[0] = SYNCHRONIZE_CACHE_16; in sd_sync_cache()
1666 cmd[0] = SYNCHRONIZE_CACHE; in sd_sync_cache()
1671 res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, in sd_sync_cache()
1804 u8 cmd[10] = { PERSISTENT_RESERVE_IN, sa }; in sd_pr_in_command() local
1810 put_unaligned_be16(data_len, &cmd[7]); in sd_pr_in_command()
1812 result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, data, data_len, in sd_pr_in_command()
1897 u8 cmd[16] = { 0, }; in sd_pr_out_command() local
1900 cmd[0] = PERSISTENT_RESERVE_OUT; in sd_pr_out_command()
1901 cmd[1] = sa; in sd_pr_out_command()
1902 cmd[2] = type; in sd_pr_out_command()
1903 put_unaligned_be32(sizeof(data), &cmd[5]); in sd_pr_out_command()
1909 result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, &data, in sd_pr_out_command()
2239 unsigned char cmd[10]; in sd_spinup_disk() local
2259 cmd[0] = TEST_UNIT_READY; in sd_spinup_disk()
2260 memset((void *) &cmd[1], 0, 9); in sd_spinup_disk()
2262 the_result = scsi_execute_cmd(sdkp->device, cmd, in sd_spinup_disk()
2317 cmd[0] = START_STOP; in sd_spinup_disk()
2318 cmd[1] = 1; /* Return immediately */ in sd_spinup_disk()
2319 memset((void *) &cmd[2], 0, 8); in sd_spinup_disk()
2320 cmd[4] = 1; /* Start spin cycle */ in sd_spinup_disk()
2322 cmd[4] |= 1 << 4; in sd_spinup_disk()
2323 scsi_execute_cmd(sdkp->device, cmd, in sd_spinup_disk()
2451 unsigned char cmd[16]; in read_capacity_16() local
2467 memset(cmd, 0, 16); in read_capacity_16()
2468 cmd[0] = SERVICE_ACTION_IN_16; in read_capacity_16()
2469 cmd[1] = SAI_READ_CAPACITY_16; in read_capacity_16()
2470 cmd[13] = RC16_LEN; in read_capacity_16()
2473 the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, in read_capacity_16()
2545 unsigned char cmd[16]; in read_capacity_10() local
2557 cmd[0] = READ_CAPACITY; in read_capacity_10()
2558 memset(&cmd[1], 0, 9); in read_capacity_10()
2561 the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer, in read_capacity_10()
3413 u8 *buffer, cmd[16] = { }; in sd_read_block_zero() local
3420 cmd[0] = READ_16; in sd_read_block_zero()
3421 put_unaligned_be64(0, &cmd[2]); /* Logical block address 0 */ in sd_read_block_zero()
3422 put_unaligned_be32(1, &cmd[10]);/* Transfer 1 logical block */ in sd_read_block_zero()
3424 cmd[0] = READ_10; in sd_read_block_zero()
3425 put_unaligned_be32(0, &cmd[2]); /* Logical block address 0 */ in sd_read_block_zero()
3426 put_unaligned_be16(1, &cmd[7]); /* Transfer 1 logical block */ in sd_read_block_zero()
3429 scsi_execute_cmd(sdkp->device, cmd, REQ_OP_DRV_IN, buffer, buf_len, in sd_read_block_zero()
3834 unsigned char cmd[6] = { START_STOP }; /* START_VALID */ in sd_start_stop_device() local
3844 cmd[4] |= 1; /* START */ in sd_start_stop_device()
3847 cmd[4] |= start ? 1 << 4 : 3 << 4; /* Active or Standby */ in sd_start_stop_device()
3852 res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, SD_TIMEOUT, in sd_start_stop_device()
4018 static const u8 cmd[10] = { REQUEST_SENSE }; in sd_resume_runtime() local
4023 if (scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, in sd_resume_runtime()