Lines Matching refs:qc

538 unsigned int ata_sff_data_xfer(struct ata_queued_cmd *qc, unsigned char *buf,  in ata_sff_data_xfer()  argument
541 struct ata_port *ap = qc->dev->link->ap; in ata_sff_data_xfer()
593 unsigned int ata_sff_data_xfer32(struct ata_queued_cmd *qc, unsigned char *buf, in ata_sff_data_xfer32() argument
596 struct ata_device *dev = qc->dev; in ata_sff_data_xfer32()
603 return ata_sff_data_xfer(qc, buf, buflen, rw); in ata_sff_data_xfer32()
640 static void ata_pio_xfer(struct ata_queued_cmd *qc, struct page *page, in ata_pio_xfer() argument
643 bool do_write = (qc->tf.flags & ATA_TFLAG_WRITE); in ata_pio_xfer()
647 qc->ap->ops->sff_data_xfer(qc, buf + offset, xfer_size, do_write); in ata_pio_xfer()
663 static void ata_pio_sector(struct ata_queued_cmd *qc) in ata_pio_sector() argument
665 struct ata_port *ap = qc->ap; in ata_pio_sector()
669 if (!qc->cursg) { in ata_pio_sector()
670 qc->curbytes = qc->nbytes; in ata_pio_sector()
673 if (qc->curbytes == qc->nbytes - qc->sect_size) in ata_pio_sector()
676 page = sg_page(qc->cursg); in ata_pio_sector()
677 offset = qc->cursg->offset + qc->cursg_ofs; in ata_pio_sector()
683 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); in ata_pio_sector()
690 if (offset + qc->sect_size > PAGE_SIZE) { in ata_pio_sector()
693 ata_pio_xfer(qc, page, offset, split_len); in ata_pio_sector()
694 ata_pio_xfer(qc, nth_page(page, 1), 0, in ata_pio_sector()
695 qc->sect_size - split_len); in ata_pio_sector()
697 ata_pio_xfer(qc, page, offset, qc->sect_size); in ata_pio_sector()
700 qc->curbytes += qc->sect_size; in ata_pio_sector()
701 qc->cursg_ofs += qc->sect_size; in ata_pio_sector()
703 if (qc->cursg_ofs == qc->cursg->length) { in ata_pio_sector()
704 qc->cursg = sg_next(qc->cursg); in ata_pio_sector()
705 if (!qc->cursg) in ata_pio_sector()
707 qc->cursg_ofs = 0; in ata_pio_sector()
721 static void ata_pio_sectors(struct ata_queued_cmd *qc) in ata_pio_sectors() argument
723 if (is_multi_taskfile(&qc->tf)) { in ata_pio_sectors()
727 WARN_ON_ONCE(qc->dev->multi_count == 0); in ata_pio_sectors()
729 nsect = min((qc->nbytes - qc->curbytes) / qc->sect_size, in ata_pio_sectors()
730 qc->dev->multi_count); in ata_pio_sectors()
732 ata_pio_sector(qc); in ata_pio_sectors()
734 ata_pio_sector(qc); in ata_pio_sectors()
736 ata_sff_sync(qc->ap); /* flush */ in ata_pio_sectors()
750 static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) in atapi_send_cdb() argument
754 WARN_ON_ONCE(qc->dev->cdb_len < 12); in atapi_send_cdb()
756 ap->ops->sff_data_xfer(qc, qc->cdb, qc->dev->cdb_len, 1); in atapi_send_cdb()
760 switch (qc->tf.protocol) { in atapi_send_cdb()
771 ap->ops->bmdma_start(qc); in atapi_send_cdb()
790 static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) in __atapi_pio_bytes() argument
792 int rw = (qc->tf.flags & ATA_TFLAG_WRITE) ? WRITE : READ; in __atapi_pio_bytes()
793 struct ata_port *ap = qc->ap; in __atapi_pio_bytes()
794 struct ata_device *dev = qc->dev; in __atapi_pio_bytes()
802 sg = qc->cursg; in __atapi_pio_bytes()
806 qc->nbytes, qc->curbytes, bytes); in __atapi_pio_bytes()
811 offset = sg->offset + qc->cursg_ofs; in __atapi_pio_bytes()
818 count = min(sg->length - qc->cursg_ofs, bytes); in __atapi_pio_bytes()
823 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); in __atapi_pio_bytes()
827 consumed = ap->ops->sff_data_xfer(qc, buf + offset, count, rw); in __atapi_pio_bytes()
831 qc->curbytes += count; in __atapi_pio_bytes()
832 qc->cursg_ofs += count; in __atapi_pio_bytes()
834 if (qc->cursg_ofs == sg->length) { in __atapi_pio_bytes()
835 qc->cursg = sg_next(qc->cursg); in __atapi_pio_bytes()
836 qc->cursg_ofs = 0; in __atapi_pio_bytes()
859 static void atapi_pio_bytes(struct ata_queued_cmd *qc) in atapi_pio_bytes() argument
861 struct ata_port *ap = qc->ap; in atapi_pio_bytes()
862 struct ata_device *dev = qc->dev; in atapi_pio_bytes()
865 int i_write, do_write = (qc->tf.flags & ATA_TFLAG_WRITE) ? 1 : 0; in atapi_pio_bytes()
873 ap->ops->sff_tf_read(ap, &qc->result_tf); in atapi_pio_bytes()
874 ireason = qc->result_tf.nsect; in atapi_pio_bytes()
875 bc_lo = qc->result_tf.lbam; in atapi_pio_bytes()
876 bc_hi = qc->result_tf.lbah; in atapi_pio_bytes()
893 if (unlikely(__atapi_pio_bytes(qc, bytes))) in atapi_pio_bytes()
903 qc->err_mask |= AC_ERR_HSM; in atapi_pio_bytes()
916 struct ata_queued_cmd *qc) in ata_hsm_ok_in_wq() argument
918 if (qc->tf.flags & ATA_TFLAG_POLLING) in ata_hsm_ok_in_wq()
922 if (qc->tf.protocol == ATA_PROT_PIO && in ata_hsm_ok_in_wq()
923 (qc->tf.flags & ATA_TFLAG_WRITE)) in ata_hsm_ok_in_wq()
926 if (ata_is_atapi(qc->tf.protocol) && in ata_hsm_ok_in_wq()
927 !(qc->dev->flags & ATA_DFLAG_CDB_INTR)) in ata_hsm_ok_in_wq()
945 static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq) in ata_hsm_qc_complete() argument
947 struct ata_port *ap = qc->ap; in ata_hsm_qc_complete()
954 qc = ata_qc_from_tag(ap, qc->tag); in ata_hsm_qc_complete()
955 if (qc) { in ata_hsm_qc_complete()
956 if (likely(!(qc->err_mask & AC_ERR_HSM))) { in ata_hsm_qc_complete()
958 ata_qc_complete(qc); in ata_hsm_qc_complete()
963 if (likely(!(qc->err_mask & AC_ERR_HSM))) in ata_hsm_qc_complete()
964 ata_qc_complete(qc); in ata_hsm_qc_complete()
971 ata_qc_complete(qc); in ata_hsm_qc_complete()
973 ata_qc_complete(qc); in ata_hsm_qc_complete()
987 int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, in ata_sff_hsm_move() argument
990 struct ata_link *link = qc->dev->link; in ata_sff_hsm_move()
996 WARN_ON_ONCE((qc->flags & ATA_QCFLAG_ACTIVE) == 0); in ata_sff_hsm_move()
1002 WARN_ON_ONCE(in_wq != ata_hsm_ok_in_wq(ap, qc)); in ata_sff_hsm_move()
1006 ap->print_id, qc->tf.protocol, ap->hsm_task_state, status); in ata_sff_hsm_move()
1016 poll_next = (qc->tf.flags & ATA_TFLAG_POLLING); in ata_sff_hsm_move()
1023 qc->err_mask |= AC_ERR_DEV; in ata_sff_hsm_move()
1028 qc->err_mask |= AC_ERR_HSM; in ata_sff_hsm_move()
1047 if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) { in ata_sff_hsm_move()
1051 qc->err_mask |= AC_ERR_HSM; in ata_sff_hsm_move()
1057 if (qc->tf.protocol == ATA_PROT_PIO) { in ata_sff_hsm_move()
1067 ata_pio_sectors(qc); in ata_sff_hsm_move()
1070 atapi_send_cdb(ap, qc); in ata_sff_hsm_move()
1079 if (qc->tf.protocol == ATAPI_PROT_PIO) { in ata_sff_hsm_move()
1099 qc->err_mask |= AC_ERR_HSM; in ata_sff_hsm_move()
1104 atapi_pio_bytes(qc); in ata_sff_hsm_move()
1116 qc->err_mask |= AC_ERR_DEV; in ata_sff_hsm_move()
1122 if (qc->dev->horkage & in ata_sff_hsm_move()
1124 qc->err_mask |= in ata_sff_hsm_move()
1134 qc->err_mask |= AC_ERR_HSM | in ata_sff_hsm_move()
1154 qc->err_mask |= AC_ERR_DEV; in ata_sff_hsm_move()
1156 if (!(qc->tf.flags & ATA_TFLAG_WRITE)) { in ata_sff_hsm_move()
1157 ata_pio_sectors(qc); in ata_sff_hsm_move()
1165 qc->err_mask |= AC_ERR_HSM; in ata_sff_hsm_move()
1176 qc->err_mask |= AC_ERR_NODEV_HINT; in ata_sff_hsm_move()
1186 ata_pio_sectors(qc); in ata_sff_hsm_move()
1189 (!(qc->tf.flags & ATA_TFLAG_WRITE))) { in ata_sff_hsm_move()
1201 qc->err_mask |= __ac_err_mask(status); in ata_sff_hsm_move()
1208 ap->print_id, qc->dev->devno, status); in ata_sff_hsm_move()
1210 WARN_ON_ONCE(qc->err_mask & (AC_ERR_DEV | AC_ERR_HSM)); in ata_sff_hsm_move()
1215 ata_hsm_qc_complete(qc, in_wq); in ata_sff_hsm_move()
1224 ata_hsm_qc_complete(qc, in_wq); in ata_sff_hsm_move()
1292 struct ata_queued_cmd *qc; in ata_sff_pio_task() local
1300 qc = ata_qc_from_tag(ap, link->active_tag); in ata_sff_pio_task()
1301 if (!qc) { in ata_sff_pio_task()
1335 poll_next = ata_sff_hsm_move(ap, qc, status, 1); in ata_sff_pio_task()
1359 unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc) in ata_sff_qc_issue() argument
1361 struct ata_port *ap = qc->ap; in ata_sff_qc_issue()
1362 struct ata_link *link = qc->dev->link; in ata_sff_qc_issue()
1368 qc->tf.flags |= ATA_TFLAG_POLLING; in ata_sff_qc_issue()
1371 ata_dev_select(ap, qc->dev->devno, 1, 0); in ata_sff_qc_issue()
1374 switch (qc->tf.protocol) { in ata_sff_qc_issue()
1376 if (qc->tf.flags & ATA_TFLAG_POLLING) in ata_sff_qc_issue()
1377 ata_qc_set_polling(qc); in ata_sff_qc_issue()
1379 ata_tf_to_host(ap, &qc->tf); in ata_sff_qc_issue()
1382 if (qc->tf.flags & ATA_TFLAG_POLLING) in ata_sff_qc_issue()
1388 if (qc->tf.flags & ATA_TFLAG_POLLING) in ata_sff_qc_issue()
1389 ata_qc_set_polling(qc); in ata_sff_qc_issue()
1391 ata_tf_to_host(ap, &qc->tf); in ata_sff_qc_issue()
1393 if (qc->tf.flags & ATA_TFLAG_WRITE) { in ata_sff_qc_issue()
1405 if (qc->tf.flags & ATA_TFLAG_POLLING) in ata_sff_qc_issue()
1418 if (qc->tf.flags & ATA_TFLAG_POLLING) in ata_sff_qc_issue()
1419 ata_qc_set_polling(qc); in ata_sff_qc_issue()
1421 ata_tf_to_host(ap, &qc->tf); in ata_sff_qc_issue()
1426 if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) || in ata_sff_qc_issue()
1427 (qc->tf.flags & ATA_TFLAG_POLLING)) in ata_sff_qc_issue()
1452 bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc) in ata_sff_qc_fill_rtf() argument
1454 qc->ap->ops->sff_tf_read(qc->ap, &qc->result_tf); in ata_sff_qc_fill_rtf()
1476 struct ata_queued_cmd *qc, in __ata_sff_port_intr() argument
1482 ap->print_id, qc->tf.protocol, ap->hsm_task_state); in __ata_sff_port_intr()
1495 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) in __ata_sff_port_intr()
1509 qc->err_mask |= AC_ERR_HSM; in __ata_sff_port_intr()
1519 ata_sff_hsm_move(ap, qc, status, 0); in __ata_sff_port_intr()
1537 unsigned int ata_sff_port_intr(struct ata_port *ap, struct ata_queued_cmd *qc) in ata_sff_port_intr() argument
1539 return __ata_sff_port_intr(ap, qc, false); in ata_sff_port_intr()
1559 struct ata_queued_cmd *qc; in __ata_sff_interrupt() local
1561 qc = ata_qc_from_tag(ap, ap->link.active_tag); in __ata_sff_interrupt()
1562 if (qc) { in __ata_sff_interrupt()
1563 if (!(qc->tf.flags & ATA_TFLAG_POLLING)) in __ata_sff_interrupt()
1564 handled |= port_intr(ap, qc); in __ata_sff_interrupt()
1651 struct ata_queued_cmd *qc; in ata_sff_lost_interrupt() local
1654 qc = ata_qc_from_tag(ap, ap->link.active_tag); in ata_sff_lost_interrupt()
1656 if (!qc || qc->tf.flags & ATA_TFLAG_POLLING) in ata_sff_lost_interrupt()
1670 ata_sff_port_intr(ap, qc); in ata_sff_lost_interrupt()
2111 void ata_sff_drain_fifo(struct ata_queued_cmd *qc) in ata_sff_drain_fifo() argument
2117 if (qc == NULL || qc->dma_dir == DMA_TO_DEVICE) in ata_sff_drain_fifo()
2120 ap = qc->ap; in ata_sff_drain_fifo()
2149 struct ata_queued_cmd *qc; in ata_sff_error_handler() local
2152 qc = __ata_qc_from_tag(ap, ap->link.active_tag); in ata_sff_error_handler()
2153 if (qc && !(qc->flags & ATA_QCFLAG_FAILED)) in ata_sff_error_handler()
2154 qc = NULL; in ata_sff_error_handler()
2166 ap->ops->sff_drain_fifo(qc); in ata_sff_error_handler()
2590 static void ata_bmdma_fill_sg(struct ata_queued_cmd *qc) in ata_bmdma_fill_sg() argument
2592 struct ata_port *ap = qc->ap; in ata_bmdma_fill_sg()
2598 for_each_sg(qc->sg, sg, qc->n_elem, si) { in ata_bmdma_fill_sg()
2641 static void ata_bmdma_fill_sg_dumb(struct ata_queued_cmd *qc) in ata_bmdma_fill_sg_dumb() argument
2643 struct ata_port *ap = qc->ap; in ata_bmdma_fill_sg_dumb()
2649 for_each_sg(qc->sg, sg, qc->n_elem, si) { in ata_bmdma_fill_sg_dumb()
2697 enum ata_completion_errors ata_bmdma_qc_prep(struct ata_queued_cmd *qc) in ata_bmdma_qc_prep() argument
2699 if (!(qc->flags & ATA_QCFLAG_DMAMAP)) in ata_bmdma_qc_prep()
2702 ata_bmdma_fill_sg(qc); in ata_bmdma_qc_prep()
2717 enum ata_completion_errors ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc) in ata_bmdma_dumb_qc_prep() argument
2719 if (!(qc->flags & ATA_QCFLAG_DMAMAP)) in ata_bmdma_dumb_qc_prep()
2722 ata_bmdma_fill_sg_dumb(qc); in ata_bmdma_dumb_qc_prep()
2742 unsigned int ata_bmdma_qc_issue(struct ata_queued_cmd *qc) in ata_bmdma_qc_issue() argument
2744 struct ata_port *ap = qc->ap; in ata_bmdma_qc_issue()
2745 struct ata_link *link = qc->dev->link; in ata_bmdma_qc_issue()
2748 if (!ata_is_dma(qc->tf.protocol)) in ata_bmdma_qc_issue()
2749 return ata_sff_qc_issue(qc); in ata_bmdma_qc_issue()
2752 ata_dev_select(ap, qc->dev->devno, 1, 0); in ata_bmdma_qc_issue()
2755 switch (qc->tf.protocol) { in ata_bmdma_qc_issue()
2757 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING); in ata_bmdma_qc_issue()
2759 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ in ata_bmdma_qc_issue()
2760 ap->ops->bmdma_setup(qc); /* set up bmdma */ in ata_bmdma_qc_issue()
2761 ap->ops->bmdma_start(qc); /* initiate bmdma */ in ata_bmdma_qc_issue()
2766 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING); in ata_bmdma_qc_issue()
2768 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ in ata_bmdma_qc_issue()
2769 ap->ops->bmdma_setup(qc); /* set up bmdma */ in ata_bmdma_qc_issue()
2773 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) in ata_bmdma_qc_issue()
2799 unsigned int ata_bmdma_port_intr(struct ata_port *ap, struct ata_queued_cmd *qc) in ata_bmdma_port_intr() argument
2806 if (ap->hsm_task_state == HSM_ST_LAST && ata_is_dma(qc->tf.protocol)) { in ata_bmdma_port_intr()
2816 ap->ops->bmdma_stop(qc); in ata_bmdma_port_intr()
2821 qc->err_mask |= AC_ERR_HOST_BUS; in ata_bmdma_port_intr()
2826 handled = __ata_sff_port_intr(ap, qc, bmdma_stopped); in ata_bmdma_port_intr()
2828 if (unlikely(qc->err_mask) && ata_is_dma(qc->tf.protocol)) in ata_bmdma_port_intr()
2869 struct ata_queued_cmd *qc; in ata_bmdma_error_handler() local
2873 qc = __ata_qc_from_tag(ap, ap->link.active_tag); in ata_bmdma_error_handler()
2874 if (qc && !(qc->flags & ATA_QCFLAG_FAILED)) in ata_bmdma_error_handler()
2875 qc = NULL; in ata_bmdma_error_handler()
2880 if (qc && ata_is_dma(qc->tf.protocol)) { in ata_bmdma_error_handler()
2890 if (qc->err_mask == AC_ERR_TIMEOUT && (host_stat & ATA_DMA_ERR)) { in ata_bmdma_error_handler()
2891 qc->err_mask = AC_ERR_HOST_BUS; in ata_bmdma_error_handler()
2895 ap->ops->bmdma_stop(qc); in ata_bmdma_error_handler()
2921 void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc) in ata_bmdma_post_internal_cmd() argument
2923 struct ata_port *ap = qc->ap; in ata_bmdma_post_internal_cmd()
2926 if (ata_is_dma(qc->tf.protocol)) { in ata_bmdma_post_internal_cmd()
2928 ap->ops->bmdma_stop(qc); in ata_bmdma_post_internal_cmd()
2963 void ata_bmdma_setup(struct ata_queued_cmd *qc) in ata_bmdma_setup() argument
2965 struct ata_port *ap = qc->ap; in ata_bmdma_setup()
2966 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); in ata_bmdma_setup()
2981 ap->ops->sff_exec_command(ap, &qc->tf); in ata_bmdma_setup()
2992 void ata_bmdma_start(struct ata_queued_cmd *qc) in ata_bmdma_start() argument
2994 struct ata_port *ap = qc->ap; in ata_bmdma_start()
3029 void ata_bmdma_stop(struct ata_queued_cmd *qc) in ata_bmdma_stop() argument
3031 struct ata_port *ap = qc->ap; in ata_bmdma_stop()