Lines Matching refs:qc
62 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc);
756 struct ata_queued_cmd *qc; in ata_scsi_qc_new() local
758 qc = ata_qc_new_init(dev, cmd->request->tag); in ata_scsi_qc_new()
759 if (qc) { in ata_scsi_qc_new()
760 qc->scsicmd = cmd; in ata_scsi_qc_new()
761 qc->scsidone = cmd->scsi_done; in ata_scsi_qc_new()
763 qc->sg = scsi_sglist(cmd); in ata_scsi_qc_new()
764 qc->n_elem = scsi_sg_count(cmd); in ata_scsi_qc_new()
770 return qc; in ata_scsi_qc_new()
773 static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) in ata_qc_set_pc_nbytes() argument
775 struct scsi_cmnd *scmd = qc->scsicmd; in ata_qc_set_pc_nbytes()
777 qc->extrabytes = scmd->request->extra_len; in ata_qc_set_pc_nbytes()
778 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; in ata_qc_set_pc_nbytes()
976 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) in ata_gen_passthru_sense() argument
978 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_passthru_sense()
979 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_passthru_sense()
982 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_passthru_sense()
992 if (qc->err_mask || in ata_gen_passthru_sense()
994 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_passthru_sense()
1049 static void ata_gen_ata_sense(struct ata_queued_cmd *qc) in ata_gen_ata_sense() argument
1051 struct ata_device *dev = qc->dev; in ata_gen_ata_sense()
1052 struct scsi_cmnd *cmd = qc->scsicmd; in ata_gen_ata_sense()
1053 struct ata_taskfile *tf = &qc->result_tf; in ata_gen_ata_sense()
1056 int verbose = qc->ap->ops->error_handler == NULL; in ata_gen_ata_sense()
1069 if (qc->err_mask || in ata_gen_ata_sense()
1071 ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, in ata_gen_ata_sense()
1076 block = ata_tf_read_block(&qc->result_tf, dev); in ata_gen_ata_sense()
1341 static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) in ata_scsi_start_stop_xlat() argument
1343 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_start_stop_xlat()
1344 struct ata_taskfile *tf = &qc->tf; in ata_scsi_start_stop_xlat()
1363 if (qc->dev->flags & ATA_DFLAG_LBA) { in ata_scsi_start_stop_xlat()
1382 if ((qc->ap->flags & ATA_FLAG_NO_POWEROFF_SPINDOWN) && in ata_scsi_start_stop_xlat()
1386 if ((qc->ap->flags & ATA_FLAG_NO_HIBERNATE_SPINDOWN) && in ata_scsi_start_stop_xlat()
1426 static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) in ata_scsi_flush_xlat() argument
1428 struct ata_taskfile *tf = &qc->tf; in ata_scsi_flush_xlat()
1433 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT) in ata_scsi_flush_xlat()
1439 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_flush_xlat()
1547 static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc) in ata_scsi_verify_xlat() argument
1549 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_verify_xlat()
1550 struct ata_taskfile *tf = &qc->tf; in ata_scsi_verify_xlat()
1551 struct ata_device *dev = qc->dev; in ata_scsi_verify_xlat()
1552 u64 dev_sectors = qc->dev->n_sectors; in ata_scsi_verify_xlat()
1675 static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) in ata_scsi_rw_xlat() argument
1677 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_rw_xlat()
1733 qc->flags |= ATA_QCFLAG_IO; in ata_scsi_rw_xlat()
1734 qc->nbytes = n_block * scmd->device->sector_size; in ata_scsi_rw_xlat()
1736 rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, in ata_scsi_rw_xlat()
1737 qc->tag); in ata_scsi_rw_xlat()
1759 static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) in ata_scsi_qc_complete() argument
1761 struct ata_port *ap = qc->ap; in ata_scsi_qc_complete()
1762 struct scsi_cmnd *cmd = qc->scsicmd; in ata_scsi_qc_complete()
1764 int need_sense = (qc->err_mask != 0); in ata_scsi_qc_complete()
1777 ata_gen_passthru_sense(qc); in ata_scsi_qc_complete()
1788 ata_gen_ata_sense(qc); in ata_scsi_qc_complete()
1793 ata_dump_status(ap->print_id, &qc->result_tf); in ata_scsi_qc_complete()
1795 qc->scsidone(cmd); in ata_scsi_qc_complete()
1797 ata_qc_free(qc); in ata_scsi_qc_complete()
1830 struct ata_queued_cmd *qc; in ata_scsi_translate() local
1835 qc = ata_scsi_qc_new(dev, cmd); in ata_scsi_translate()
1836 if (!qc) in ata_scsi_translate()
1847 ata_sg_init(qc, scsi_sglist(cmd), scsi_sg_count(cmd)); in ata_scsi_translate()
1849 qc->dma_dir = cmd->sc_data_direction; in ata_scsi_translate()
1852 qc->complete_fn = ata_scsi_qc_complete; in ata_scsi_translate()
1854 if (xlat_func(qc)) in ata_scsi_translate()
1858 if ((rc = ap->ops->qc_defer(qc))) in ata_scsi_translate()
1863 ata_qc_issue(qc); in ata_scsi_translate()
1869 ata_qc_free(qc); in ata_scsi_translate()
1875 ata_qc_free(qc); in ata_scsi_translate()
1883 ata_qc_free(qc); in ata_scsi_translate()
2585 static void atapi_sense_complete(struct ata_queued_cmd *qc) in atapi_sense_complete() argument
2587 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { in atapi_sense_complete()
2593 ata_gen_passthru_sense(qc); in atapi_sense_complete()
2596 qc->scsidone(qc->scsicmd); in atapi_sense_complete()
2597 ata_qc_free(qc); in atapi_sense_complete()
2606 static void atapi_request_sense(struct ata_queued_cmd *qc) in atapi_request_sense() argument
2608 struct ata_port *ap = qc->ap; in atapi_request_sense()
2609 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_request_sense()
2617 ap->ops->sff_tf_read(ap, &qc->tf); in atapi_request_sense()
2622 cmd->sense_buffer[2] = qc->tf.feature >> 4; in atapi_request_sense()
2624 ata_qc_reinit(qc); in atapi_request_sense()
2627 sg_init_one(&qc->sgent, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); in atapi_request_sense()
2628 ata_sg_init(qc, &qc->sgent, 1); in atapi_request_sense()
2629 qc->dma_dir = DMA_FROM_DEVICE; in atapi_request_sense()
2631 memset(&qc->cdb, 0, qc->dev->cdb_len); in atapi_request_sense()
2632 qc->cdb[0] = REQUEST_SENSE; in atapi_request_sense()
2633 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2635 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_request_sense()
2636 qc->tf.command = ATA_CMD_PACKET; in atapi_request_sense()
2639 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_request_sense()
2640 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_request_sense()
2642 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_request_sense()
2643 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2644 qc->tf.lbah = 0; in atapi_request_sense()
2646 qc->nbytes = SCSI_SENSE_BUFFERSIZE; in atapi_request_sense()
2648 qc->complete_fn = atapi_sense_complete; in atapi_request_sense()
2650 ata_qc_issue(qc); in atapi_request_sense()
2655 static void atapi_qc_complete(struct ata_queued_cmd *qc) in atapi_qc_complete() argument
2657 struct scsi_cmnd *cmd = qc->scsicmd; in atapi_qc_complete()
2658 unsigned int err_mask = qc->err_mask; in atapi_qc_complete()
2663 if (unlikely(qc->ap->ops->error_handler && in atapi_qc_complete()
2664 (err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID))) { in atapi_qc_complete()
2666 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) { in atapi_qc_complete()
2672 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2688 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) in atapi_qc_complete()
2689 qc->dev->sdev->locked = 0; in atapi_qc_complete()
2691 qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; in atapi_qc_complete()
2692 qc->scsidone(cmd); in atapi_qc_complete()
2693 ata_qc_free(qc); in atapi_qc_complete()
2700 atapi_request_sense(qc); in atapi_qc_complete()
2708 ata_gen_passthru_sense(qc); in atapi_qc_complete()
2737 qc->scsidone(cmd); in atapi_qc_complete()
2738 ata_qc_free(qc); in atapi_qc_complete()
2750 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) in atapi_xlat() argument
2752 struct scsi_cmnd *scmd = qc->scsicmd; in atapi_xlat()
2753 struct ata_device *dev = qc->dev; in atapi_xlat()
2758 memset(qc->cdb, 0, dev->cdb_len); in atapi_xlat()
2759 memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len); in atapi_xlat()
2761 qc->complete_fn = atapi_qc_complete; in atapi_xlat()
2763 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in atapi_xlat()
2765 qc->tf.flags |= ATA_TFLAG_WRITE; in atapi_xlat()
2769 qc->tf.command = ATA_CMD_PACKET; in atapi_xlat()
2770 ata_qc_set_pc_nbytes(qc); in atapi_xlat()
2773 if (!nodata && !using_pio && atapi_check_dma(qc)) in atapi_xlat()
2781 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); in atapi_xlat()
2810 qc->tf.lbam = (nbytes & 0xFF); in atapi_xlat()
2811 qc->tf.lbah = (nbytes >> 8); in atapi_xlat()
2814 qc->tf.protocol = ATAPI_PROT_NODATA; in atapi_xlat()
2816 qc->tf.protocol = ATAPI_PROT_PIO; in atapi_xlat()
2819 qc->tf.protocol = ATAPI_PROT_DMA; in atapi_xlat()
2820 qc->tf.feature |= ATAPI_PKT_DMA; in atapi_xlat()
2825 qc->tf.feature |= ATAPI_DMADIR; in atapi_xlat()
2939 static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) in ata_scsi_pass_thru() argument
2941 struct ata_taskfile *tf = &(qc->tf); in ata_scsi_pass_thru()
2942 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_pass_thru()
2943 struct ata_device *dev = qc->dev; in ata_scsi_pass_thru()
3006 qc->sect_size = scsi_bufflen(scmd); in ata_scsi_pass_thru()
3040 qc->sect_size = scmd->device->sector_size; in ata_scsi_pass_thru()
3045 qc->sect_size = ATA_SECT_SIZE; in ata_scsi_pass_thru()
3057 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; in ata_scsi_pass_thru()
3065 ata_qc_set_pc_nbytes(qc); in ata_scsi_pass_thru()
3123 static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) in ata_scsi_write_same_xlat() argument
3125 struct ata_taskfile *tf = &qc->tf; in ata_scsi_write_same_xlat()
3126 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_write_same_xlat()
3127 struct ata_device *dev = qc->dev; in ata_scsi_write_same_xlat()
3161 tf->nsect = qc->tag << 3; in ata_scsi_write_same_xlat()
3178 ata_qc_set_pc_nbytes(qc); in ata_scsi_write_same_xlat()
3199 static int ata_mselect_caching(struct ata_queued_cmd *qc, in ata_mselect_caching() argument
3202 struct ata_taskfile *tf = &qc->tf; in ata_mselect_caching()
3203 struct ata_device *dev = qc->dev; in ata_mselect_caching()
3245 static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) in ata_scsi_mode_select_xlat() argument
3247 struct scsi_cmnd *scmd = qc->scsicmd; in ata_scsi_mode_select_xlat()
3333 if (ata_mselect_caching(qc, p, pg_len) < 0) in ata_scsi_mode_select_xlat()