Lines Matching refs:task

12 static int mvs_find_tag(struct mvs_info *mvi, struct sas_task *task, u32 *tag)  in mvs_find_tag()  argument
14 if (task->lldd_task) { in mvs_find_tag()
16 slot = task->lldd_task; in mvs_find_tag()
302 struct sas_task *task = tei->task; in mvs_task_prep_smp() local
304 struct domain_device *dev = task->dev; in mvs_task_prep_smp()
320 sg_req = &task->smp_task.smp_req; in mvs_task_prep_smp()
326 sg_resp = &task->smp_task.smp_resp; in mvs_task_prep_smp()
395 MVS_CHIP_DISP->make_prd(task->scatter, tei->n_elem, buf_prd); in mvs_task_prep_smp()
400 dma_unmap_sg(mvi->dev, &tei->task->smp_task.smp_resp, 1, in mvs_task_prep_smp()
403 dma_unmap_sg(mvi->dev, &tei->task->smp_task.smp_req, 1, in mvs_task_prep_smp()
408 static u32 mvs_get_ncq_tag(struct sas_task *task, u32 *tag) in mvs_get_ncq_tag() argument
410 struct ata_queued_cmd *qc = task->uldd_task; in mvs_get_ncq_tag()
429 struct sas_task *task = tei->task; in mvs_task_prep_ata() local
430 struct domain_device *dev = task->dev; in mvs_task_prep_ata()
457 if (task->data_dir == DMA_FROM_DEVICE) in mvs_task_prep_ata()
462 if (task->ata_task.use_ncq) in mvs_task_prep_ata()
465 if (task->ata_task.fis.command != ATA_CMD_ID_ATAPI) in mvs_task_prep_ata()
471 if (task->ata_task.use_ncq && mvs_get_ncq_tag(task, &hdr_tag)) in mvs_task_prep_ata()
472 task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); in mvs_task_prep_ata()
478 hdr->data_len = cpu_to_le32(task->total_xfer_len); in mvs_task_prep_ata()
527 if (likely(!task->ata_task.device_control_reg_update)) in mvs_task_prep_ata()
528 task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */ in mvs_task_prep_ata()
530 memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); in mvs_task_prep_ata()
533 task->ata_task.atapi_packet, 16); in mvs_task_prep_ata()
543 MVS_CHIP_DISP->make_prd(task->scatter, tei->n_elem, buf_prd); in mvs_task_prep_ata()
545 if (task->data_dir == DMA_FROM_DEVICE) in mvs_task_prep_ata()
556 struct sas_task *task = tei->task; in mvs_task_prep_ssp() local
559 struct domain_device *dev = task->dev; in mvs_task_prep_ssp()
584 if (task->ssp_task.enable_first_burst) { in mvs_task_prep_ssp()
595 hdr->data_len = cpu_to_le32(task->total_xfer_len); in mvs_task_prep_ssp()
666 memcpy(buf_cmd, &task->ssp_task.LUN, 8); in mvs_task_prep_ssp()
669 buf_cmd[9] = fburst | task->ssp_task.task_attr | in mvs_task_prep_ssp()
670 (task->ssp_task.task_prio << 3); in mvs_task_prep_ssp()
671 memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd, in mvs_task_prep_ssp()
672 task->ssp_task.cmd->cmd_len); in mvs_task_prep_ssp()
688 MVS_CHIP_DISP->make_prd(task->scatter, tei->n_elem, buf_prd); in mvs_task_prep_ssp()
693 static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf, in mvs_task_prep() argument
696 struct domain_device *dev = task->dev; in mvs_task_prep()
704 struct task_status_struct *tsm = &task->task_status; in mvs_task_prep()
713 task->task_done(task); in mvs_task_prep()
730 if (sas_protocol_ata(task->task_proto)) { in mvs_task_prep()
731 struct task_status_struct *ts = &task->task_status; in mvs_task_prep()
737 task->task_done(task); in mvs_task_prep()
740 struct task_status_struct *ts = &task->task_status; in mvs_task_prep()
745 task->task_done(task); in mvs_task_prep()
750 if (!sas_protocol_ata(task->task_proto)) { in mvs_task_prep()
751 if (task->num_scatter) { in mvs_task_prep()
753 task->scatter, in mvs_task_prep()
754 task->num_scatter, in mvs_task_prep()
755 task->data_dir); in mvs_task_prep()
762 n_elem = task->num_scatter; in mvs_task_prep()
771 task->lldd_task = NULL; in mvs_task_prep()
781 tei.task = task; in mvs_task_prep()
785 switch (task->task_proto) { in mvs_task_prep()
800 task->task_proto); in mvs_task_prep()
809 slot->task = task; in mvs_task_prep()
811 task->lldd_task = slot; in mvs_task_prep()
813 spin_lock(&task->task_state_lock); in mvs_task_prep()
814 task->task_state_flags |= SAS_TASK_AT_INITIATOR; in mvs_task_prep()
815 spin_unlock(&task->task_state_lock); in mvs_task_prep()
830 if (!sas_protocol_ata(task->task_proto)) in mvs_task_prep()
832 dma_unmap_sg(mvi->dev, task->scatter, n_elem, in mvs_task_prep()
833 task->data_dir); in mvs_task_prep()
838 static int mvs_task_exec(struct sas_task *task, gfp_t gfp_flags, in mvs_task_exec() argument
847 mvi = ((struct mvs_device *)task->dev->lldd_dev)->mvi_info; in mvs_task_exec()
850 rc = mvs_task_prep(task, mvi, is_tmf, tmf, &pass); in mvs_task_exec()
862 int mvs_queue_command(struct sas_task *task, gfp_t gfp_flags) in mvs_queue_command() argument
864 return mvs_task_exec(task, gfp_flags, NULL, 0, NULL); in mvs_queue_command()
873 static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task, in mvs_slot_task_free() argument
878 if (!slot->task) in mvs_slot_task_free()
880 if (!sas_protocol_ata(task->task_proto)) in mvs_slot_task_free()
882 dma_unmap_sg(mvi->dev, task->scatter, in mvs_slot_task_free()
883 slot->n_elem, task->data_dir); in mvs_slot_task_free()
885 switch (task->task_proto) { in mvs_slot_task_free()
887 dma_unmap_sg(mvi->dev, &task->smp_task.smp_resp, 1, in mvs_slot_task_free()
889 dma_unmap_sg(mvi->dev, &task->smp_task.smp_req, 1, in mvs_slot_task_free()
906 task->lldd_task = NULL; in mvs_slot_task_free()
907 slot->task = NULL; in mvs_slot_task_free()
1260 static void mvs_task_done(struct sas_task *task) in mvs_task_done() argument
1262 if (!del_timer(&task->slow_task->timer)) in mvs_task_done()
1264 complete(&task->slow_task->completion); in mvs_task_done()
1270 struct sas_task *task = slow->task; in mvs_tmf_timedout() local
1272 task->task_state_flags |= SAS_TASK_STATE_ABORTED; in mvs_tmf_timedout()
1273 complete(&task->slow_task->completion); in mvs_tmf_timedout()
1281 struct sas_task *task = NULL; in mvs_exec_internal_tmf_task() local
1284 task = sas_alloc_slow_task(GFP_KERNEL); in mvs_exec_internal_tmf_task()
1285 if (!task) in mvs_exec_internal_tmf_task()
1288 task->dev = dev; in mvs_exec_internal_tmf_task()
1289 task->task_proto = dev->tproto; in mvs_exec_internal_tmf_task()
1291 memcpy(&task->ssp_task, parameter, para_len); in mvs_exec_internal_tmf_task()
1292 task->task_done = mvs_task_done; in mvs_exec_internal_tmf_task()
1294 task->slow_task->timer.function = mvs_tmf_timedout; in mvs_exec_internal_tmf_task()
1295 task->slow_task->timer.expires = jiffies + MVS_TASK_TIMEOUT*HZ; in mvs_exec_internal_tmf_task()
1296 add_timer(&task->slow_task->timer); in mvs_exec_internal_tmf_task()
1298 res = mvs_task_exec(task, GFP_KERNEL, NULL, 1, tmf); in mvs_exec_internal_tmf_task()
1301 del_timer(&task->slow_task->timer); in mvs_exec_internal_tmf_task()
1306 wait_for_completion(&task->slow_task->completion); in mvs_exec_internal_tmf_task()
1309 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { in mvs_exec_internal_tmf_task()
1310 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { in mvs_exec_internal_tmf_task()
1316 if (task->task_status.resp == SAS_TASK_COMPLETE && in mvs_exec_internal_tmf_task()
1317 task->task_status.stat == SAS_SAM_STAT_GOOD) { in mvs_exec_internal_tmf_task()
1322 if (task->task_status.resp == SAS_TASK_COMPLETE && in mvs_exec_internal_tmf_task()
1323 task->task_status.stat == SAS_DATA_UNDERRUN) { in mvs_exec_internal_tmf_task()
1326 res = task->task_status.residual; in mvs_exec_internal_tmf_task()
1330 if (task->task_status.resp == SAS_TASK_COMPLETE && in mvs_exec_internal_tmf_task()
1331 task->task_status.stat == SAS_DATA_OVERRUN) { in mvs_exec_internal_tmf_task()
1339 task->task_status.resp, in mvs_exec_internal_tmf_task()
1340 task->task_status.stat); in mvs_exec_internal_tmf_task()
1341 sas_free_task(task); in mvs_exec_internal_tmf_task()
1342 task = NULL; in mvs_exec_internal_tmf_task()
1347 BUG_ON(retry == 3 && task != NULL); in mvs_exec_internal_tmf_task()
1348 sas_free_task(task); in mvs_exec_internal_tmf_task()
1425 int mvs_query_task(struct sas_task *task) in mvs_query_task() argument
1432 if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) { in mvs_query_task()
1433 struct scsi_cmnd * cmnd = (struct scsi_cmnd *)task->uldd_task; in mvs_query_task()
1434 struct domain_device *dev = task->dev; in mvs_query_task()
1439 rc = mvs_find_tag(mvi, task, &tag); in mvs_query_task()
1463 int mvs_abort_task(struct sas_task *task) in mvs_abort_task() argument
1467 struct domain_device *dev = task->dev; in mvs_abort_task()
1481 spin_lock_irqsave(&task->task_state_lock, flags); in mvs_abort_task()
1482 if (task->task_state_flags & SAS_TASK_STATE_DONE) { in mvs_abort_task()
1483 spin_unlock_irqrestore(&task->task_state_lock, flags); in mvs_abort_task()
1487 spin_unlock_irqrestore(&task->task_state_lock, flags); in mvs_abort_task()
1489 if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) { in mvs_abort_task()
1490 struct scsi_cmnd * cmnd = (struct scsi_cmnd *)task->uldd_task; in mvs_abort_task()
1493 rc = mvs_find_tag(mvi, task, &tag); in mvs_abort_task()
1510 if (task->lldd_task) { in mvs_abort_task()
1511 slot = task->lldd_task; in mvs_abort_task()
1519 } else if (task->task_proto & SAS_PROTOCOL_SATA || in mvs_abort_task()
1520 task->task_proto & SAS_PROTOCOL_STP) { in mvs_abort_task()
1522 struct mvs_slot_info *slot = task->lldd_task; in mvs_abort_task()
1526 mvi, task, slot, slot_idx); in mvs_abort_task()
1527 task->task_state_flags |= SAS_TASK_STATE_ABORTED; in mvs_abort_task()
1528 mvs_slot_task_free(mvi, task, slot, slot_idx); in mvs_abort_task()
1573 static int mvs_sata_done(struct mvs_info *mvi, struct sas_task *task, in mvs_sata_done() argument
1576 struct mvs_device *mvi_dev = task->dev->lldd_dev; in mvs_sata_done()
1577 struct task_status_struct *tstat = &task->task_status; in mvs_sata_done()
1647 static int mvs_slot_err(struct mvs_info *mvi, struct sas_task *task, in mvs_slot_err() argument
1663 switch (task->task_proto) { in mvs_slot_err()
1671 sas_ssp_task_response(mvi->dev, task, iu); in mvs_slot_err()
1686 task->ata_task.use_ncq = 0; in mvs_slot_err()
1688 mvs_sata_done(mvi, task, slot_idx, err_dw0); in mvs_slot_err()
1702 struct sas_task *task = slot->task; in mvs_slot_complete() local
1711 if (unlikely(!task || !task->lldd_task || !task->dev)) in mvs_slot_complete()
1714 tstat = &task->task_status; in mvs_slot_complete()
1715 dev = task->dev; in mvs_slot_complete()
1718 spin_lock(&task->task_state_lock); in mvs_slot_complete()
1719 task->task_state_flags &= in mvs_slot_complete()
1721 task->task_state_flags |= SAS_TASK_STATE_DONE; in mvs_slot_complete()
1723 aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED; in mvs_slot_complete()
1724 spin_unlock(&task->task_state_lock); in mvs_slot_complete()
1733 if (sas_protocol_ata(task->task_proto)) in mvs_slot_complete()
1736 mvs_slot_task_free(mvi, task, slot, slot_idx); in mvs_slot_complete()
1758 tstat->stat = mvs_slot_err(mvi, task, slot_idx); in mvs_slot_complete()
1763 switch (task->task_proto) { in mvs_slot_complete()
1774 sas_ssp_task_response(mvi->dev, task, iu); in mvs_slot_complete()
1780 struct scatterlist *sg_resp = &task->smp_task.smp_resp; in mvs_slot_complete()
1793 tstat->stat = mvs_sata_done(mvi, task, slot_idx, 0); in mvs_slot_complete()
1810 if (sas_protocol_ata(task->task_proto) && !mvi_dev->running_req) in mvs_slot_complete()
1813 mvs_slot_task_free(mvi, task, slot, slot_idx); in mvs_slot_complete()
1817 if (task->task_done) in mvs_slot_complete()
1818 task->task_done(task); in mvs_slot_complete()
1843 struct sas_task *task; in mvs_do_release_task() local
1845 task = slot->task; in mvs_do_release_task()
1847 if (dev && task->dev != dev) in mvs_do_release_task()
1851 slot_idx, slot->slot_tag, task); in mvs_do_release_task()