Lines Matching refs:qc
45 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
632 struct ata_queued_cmd *qc; in ata_scsi_qc_new() local
634 qc = ata_qc_new_init(dev, scsi_cmd_to_rq(cmd)->tag); in ata_scsi_qc_new()
635 if (qc) { in ata_scsi_qc_new()
636 qc->scsicmd = cmd; in ata_scsi_qc_new()
637 qc->scsidone = cmd->scsi_done; in ata_scsi_qc_new()
639 qc->sg = scsi_sglist(cmd); in ata_scsi_qc_new()
640 qc->n_elem = scsi_sg_count(cmd); in ata_scsi_qc_new()
643 qc->flags |= ATA_QCFLAG_QUIET; in ata_scsi_qc_new()
649 return qc; in ata_scsi_qc_new()
652 static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) in ata_qc_set_pc_nbytes() argument
654 struct scsi_cmnd *scmd = qc->scsicmd; in ata_qc_set_pc_nbytes()
656 qc->extrabytes = scmd->extra_len; in ata_qc_set_pc_nbytes()
657 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; in ata_qc_set_pc_nbytes()
854 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) in ata_gen_passthru_sense() argument
856 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_passthru_sense()
857 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_passthru_sense()
860 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_passthru_sense()
869 if (qc->err_mask || in ata_gen_passthru_sense()
871 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_passthru_sense()
873 ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); in ata_gen_passthru_sense()
949 static void ata_gen_ata_sense(struct ata_queued_cmd *qc) in ata_gen_ata_sense() argument
951 struct ata_device *dev = qc->dev; in ata_gen_ata_sense()
952 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_ata_sense()
953 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_ata_sense()
955 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_ata_sense()
970 if (qc->err_mask || in ata_gen_ata_sense()
972 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_ata_sense()
978 tf->command, qc->err_mask); in ata_gen_ata_sense()
983 block = ata_tf_read_block(&qc->result_tf, dev); in ata_gen_ata_sense()
1166 static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) in ata_scsi_start_stop_xlat() argument
1168 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_start_stop_xlat()
1169 struct ata_taskfile *tf = &qc->tf; in ata_scsi_start_stop_xlat()
1198 if (qc->dev->flags & ATA_DFLAG_LBA) { in ata_scsi_start_stop_xlat()
1217 if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) && in ata_scsi_start_stop_xlat()
1221 if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) && in ata_scsi_start_stop_xlat()
1239 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_start_stop_xlat()
1260 static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) in ata_scsi_flush_xlat() argument
1262 struct ata_taskfile *tf = &qc->tf; in ata_scsi_flush_xlat()
1267 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT) in ata_scsi_flush_xlat()
1273 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_flush_xlat()
1381 static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc) in ata_scsi_verify_xlat() argument
1383 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_verify_xlat()
1384 struct ata_taskfile *tf = &qc->tf; in ata_scsi_verify_xlat()
1385 struct ata_device *dev = qc->dev; in ata_scsi_verify_xlat()
1386 u64 dev_sectors = qc->dev->n_sectors; in ata_scsi_verify_xlat()
1484 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_verify_xlat()
1488 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_verify_xlat()
1530 static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) in ata_scsi_rw_xlat() argument
1532 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_rw_xlat()
1604 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_rw_xlat()
1605 qc->nbytes = n_block * scmd->device->sector_size; in ata_scsi_rw_xlat()
1607 rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, in ata_scsi_rw_xlat()
1608 qc->hw_tag, class); in ata_scsi_rw_xlat()
1617 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_rw_xlat()
1621 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x0); in ata_scsi_rw_xlat()
1630 static void ata_qc_done(struct ata_queued_cmd *qc) in ata_qc_done() argument
1632 struct scsi_cmnd *cmd = qc->scsicmd; in ata_qc_done()
1633 void (*done)(struct scsi_cmnd *) = qc->scsidone; in ata_qc_done()
1635 ata_qc_free(qc); in ata_qc_done()
1639 static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) in ata_scsi_qc_complete() argument
1641 struct ata_port *ap = qc->ap; in ata_scsi_qc_complete()
1642 struct scsi_cmnd *cmd = qc->scsicmd; in ata_scsi_qc_complete()
1644 int need_sense = (qc->err_mask != 0); in ata_scsi_qc_complete()
1657 ata_gen_passthru_sense(qc); in ata_scsi_qc_complete()
1658 else if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_scsi_qc_complete()
1661 ata_gen_ata_sense(qc); in ata_scsi_qc_complete()
1666 ata_dump_status(ap->print_id, &qc->result_tf); in ata_scsi_qc_complete()
1668 ata_qc_done(qc); in ata_scsi_qc_complete()
1701 struct ata_queued_cmd *qc; in ata_scsi_translate() local
1706 qc = ata_scsi_qc_new(dev, cmd); in ata_scsi_translate()
1707 if (!qc) in ata_scsi_translate()
1718 ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd)); in ata_scsi_translate()
1720 qc->dma_dir = cmd->sc_data_direction; in ata_scsi_translate()
1723 qc->complete_fn = ata_scsi_qc_complete; in ata_scsi_translate()
1725 if (xlat_func(qc)) in ata_scsi_translate()
1729 if ((rc = ap->ops->qc_defer(qc))) in ata_scsi_translate()
1734 ata_qc_issue(qc); in ata_scsi_translate()
1740 ata_qc_free(qc); in ata_scsi_translate()
1746 ata_qc_free(qc); in ata_scsi_translate()
1754 ata_qc_free(qc); in ata_scsi_translate()
2457 static void atapi_sense_complete(struct ata_queued_cmd *qc) in atapi_sense_complete() argument
2459 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { in atapi_sense_complete()
2465 ata_gen_passthru_sense(qc); in atapi_sense_complete()
2468 ata_qc_done(qc); in atapi_sense_complete()
2477 static void atapi_request_sense(struct ata_queued_cmd *qc) in atapi_request_sense() argument
2479 struct ata_port *ap = qc->ap; in atapi_request_sense()
2480 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_request_sense()
2488 ap->ops->sff_tf_read(ap, &qc->tf); in atapi_request_sense()
2493 cmd->sense_buffer[2] = qc->tf.feature >> 4; in atapi_request_sense()
2495 ata_qc_reinit(qc); in atapi_request_sense()
2498 sg_init_one(&qc->sgent, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); in atapi_request_sense()
2499 ata_sg_init(qc, &qc->sgent, 1); in atapi_request_sense()
2500 qc->dma_dir = DMA_FROM_DEVICE; in atapi_request_sense()
2502 memset(&qc->cdb, 0, qc->dev->cdb_len); in atapi_request_sense()
2503 qc->cdb[0] = REQUEST_SENSE; in atapi_request_sense()
2504 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2506 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_request_sense()
2507 qc->tf.command = ATA_CMD_PACKET; in atapi_request_sense()
2510 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_request_sense()
2511 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_request_sense()
2513 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_request_sense()
2514 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2515 qc->tf.lbah = 0; in atapi_request_sense()
2517 qc->nbytes = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2519 qc->complete_fn = atapi_sense_complete; in atapi_request_sense()
2521 ata_qc_issue(qc); in atapi_request_sense()
2546 static void atapi_qc_complete(struct ata_queued_cmd *qc) in atapi_qc_complete() argument
2548 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_qc_complete()
2549 unsigned int err_mask = qc->err_mask; in atapi_qc_complete()
2554 if (unlikely(qc->ap->ops->error_handler && in atapi_qc_complete()
2555 (err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID))) { in atapi_qc_complete()
2557 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2563 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2579 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) in atapi_qc_complete()
2580 qc->dev->sdev->locked = 0; in atapi_qc_complete()
2582 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; in atapi_qc_complete()
2583 ata_qc_done(qc); in atapi_qc_complete()
2590 atapi_request_sense(qc); in atapi_qc_complete()
2598 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2605 ata_qc_done(qc); in atapi_qc_complete()
2617 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) in atapi_xlat() argument
2619 struct scsi_cmnd *scmd = qc->scsicmd; in atapi_xlat()
2620 struct ata_device *dev = qc->dev; in atapi_xlat()
2625 memset(qc->cdb, 0, dev->cdb_len); in atapi_xlat()
2626 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len); in atapi_xlat()
2628 qc->complete_fn = atapi_qc_complete; in atapi_xlat()
2630 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_xlat()
2632 qc->tf.flags |= ATA_TFLAG_WRITE; in atapi_xlat()
2636 qc->tf.command = ATA_CMD_PACKET; in atapi_xlat()
2637 ata_qc_set_pc_nbytes(qc); in atapi_xlat()
2640 if (!nodata && !using_pio && atapi_check_dma(qc)) in atapi_xlat()
2648 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); in atapi_xlat()
2677 qc->tf.lbam = (nbytes & 0xFF); in atapi_xlat()
2678 qc->tf.lbah = (nbytes >> 8); in atapi_xlat()
2681 qc->tf.protocol = ATAPI_PROT_NODATA; in atapi_xlat()
2683 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_xlat()
2686 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_xlat()
2687 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_xlat()
2692 qc->tf.feature |= ATAPI_DMADIR; in atapi_xlat()
2810 static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) in ata_scsi_pass_thru() argument
2812 struct ata_taskfile *tf = &(qc->tf); in ata_scsi_pass_thru()
2813 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_pass_thru()
2814 struct ata_device *dev = qc->dev; in ata_scsi_pass_thru()
2906 tf->nsect = qc->hw_tag << 3; in ata_scsi_pass_thru()
2922 qc->sect_size = scsi_bufflen(scmd); in ata_scsi_pass_thru()
2956 qc->sect_size = scmd->device->sector_size; in ata_scsi_pass_thru()
2961 qc->sect_size = ATA_SECT_SIZE; in ata_scsi_pass_thru()
2973 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; in ata_scsi_pass_thru()
2981 ata_qc_set_pc_nbytes(qc); in ata_scsi_pass_thru()
3117 static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) in ata_scsi_write_same_xlat() argument
3119 struct ata_taskfile *tf = &qc->tf; in ata_scsi_write_same_xlat()
3120 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_write_same_xlat()
3123 struct ata_device *dev = qc->dev; in ata_scsi_write_same_xlat()
3186 tf->nsect = qc->hw_tag << 3; in ata_scsi_write_same_xlat()
3203 ata_qc_set_pc_nbytes(qc); in ata_scsi_write_same_xlat()
3299 static void ata_scsi_report_zones_complete(struct ata_queued_cmd *qc) in ata_scsi_report_zones_complete() argument
3301 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_report_zones_complete()
3359 ata_scsi_qc_complete(qc); in ata_scsi_report_zones_complete()
3362 static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_in_xlat() argument
3364 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_in_xlat()
3365 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_in_xlat()
3373 ata_dev_warn(qc->dev, "invalid cdb length %d\n", in ata_scsi_zbc_in_xlat()
3380 ata_dev_warn(qc->dev, "non-matching transfer count (%d/%d)\n", in ata_scsi_zbc_in_xlat()
3386 ata_dev_warn(qc->dev, "invalid service action %d\n", sa); in ata_scsi_zbc_in_xlat()
3395 ata_dev_warn(qc->dev, "invalid transfer count %d\n", n_block); in ata_scsi_zbc_in_xlat()
3401 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_in_xlat()
3402 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { in ata_scsi_zbc_in_xlat()
3406 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_in_xlat()
3427 qc->flags |= ATA_QCFLAG_RESULT_TF; in ata_scsi_zbc_in_xlat()
3429 ata_qc_set_pc_nbytes(qc); in ata_scsi_zbc_in_xlat()
3431 qc->complete_fn = ata_scsi_report_zones_complete; in ata_scsi_zbc_in_xlat()
3436 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_zbc_in_xlat()
3441 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_in_xlat()
3445 static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) in ata_scsi_zbc_out_xlat() argument
3447 struct ata_taskfile *tf = &qc->tf; in ata_scsi_zbc_out_xlat()
3448 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_zbc_out_xlat()
3449 struct ata_device *dev = qc->dev; in ata_scsi_zbc_out_xlat()
3490 if (ata_ncq_enabled(qc->dev) && in ata_scsi_zbc_out_xlat()
3491 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { in ata_scsi_zbc_out_xlat()
3495 tf->nsect = qc->hw_tag << 3; in ata_scsi_zbc_out_xlat()
3515 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); in ata_scsi_zbc_out_xlat()
3519 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_zbc_out_xlat()
3535 static int ata_mselect_caching(struct ata_queued_cmd *qc, in ata_mselect_caching() argument
3538 struct ata_taskfile *tf = &qc->tf; in ata_mselect_caching()
3539 struct ata_device *dev = qc->dev; in ata_mselect_caching()
3592 static int ata_mselect_control(struct ata_queued_cmd *qc, in ata_mselect_control() argument
3595 struct ata_device *dev = qc->dev; in ata_mselect_control()
3645 static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) in ata_scsi_mode_select_xlat() argument
3647 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_mode_select_xlat()
3751 if (ata_mselect_caching(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
3757 if (ata_mselect_control(qc, p, pg_len, &fp) < 0) { in ata_scsi_mode_select_xlat()
3779 ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp); in ata_scsi_mode_select_xlat()
3783 ata_scsi_set_invalid_parameter(qc->dev, scmd, fp); in ata_scsi_mode_select_xlat()
3788 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); in ata_scsi_mode_select_xlat()
3806 static unsigned int ata_scsi_security_inout_xlat(struct ata_queued_cmd *qc) in ata_scsi_security_inout_xlat() argument
3808 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_security_inout_xlat()
3810 struct ata_taskfile *tf = &qc->tf; in ata_scsi_security_inout_xlat()
3815 bool dma = !(qc->dev->flags & ATA_DFLAG_PIO); in ata_scsi_security_inout_xlat()
3821 ata_scsi_set_invalid_field(qc->dev, scmd, 1, 0); in ata_scsi_security_inout_xlat()
3827 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
3832 ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0); in ata_scsi_security_inout_xlat()
3857 ata_qc_set_pc_nbytes(qc); in ata_scsi_security_inout_xlat()
3872 static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) in ata_scsi_var_len_cdb_xlat() argument
3874 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_var_len_cdb_xlat()
3883 return ata_scsi_pass_thru(qc); in ata_scsi_var_len_cdb_xlat()