Lines Matching defs:task

45  * pm8001_find_tag - from sas task to find out  tag that belongs to this task
46 * @task: the task sent to the LLDD
47 * @tag: the found tag associated with the task
49 static int pm8001_find_tag(struct sas_task *task, u32 *tag)
51 if (task->lldd_task) {
53 ccb = task->lldd_task;
63 * @tag: the found tag associated with the task
72 * pm8001_tag_alloc - allocate a empty tag for task used.
294 * pm8001_task_prep_smp - the dispatcher function, prepare data for smp task
296 * @ccb: the ccb which attached to smp task
304 u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag)
306 struct ata_queued_cmd *qc = task->uldd_task;
321 * pm8001_task_prep_ata - the dispatcher function, prepare data for sata task
323 * @ccb: the ccb which attached to sata task
332 * pm8001_task_prep_ssp_tm - the dispatcher function, prepare task management data
335 * @tmf: the task management IU
344 * pm8001_task_prep_ssp - the dispatcher function,prepare ssp data for ssp task
346 * @ccb: the ccb which attached to ssp task
374 * pm8001_task_exec - queue the task(ssp, smp && ata) to the hardware.
375 * @task: the task to be execute.
377 * @is_tmf: if it is task management task.
378 * @tmf: the task management IU
380 static int pm8001_task_exec(struct sas_task *task,
383 struct domain_device *dev = task->dev;
387 struct sas_task *t = task;
401 pm8001_ha = pm8001_find_ha_by_dev(task->dev);
456 ccb->task = t;
512 * @task: the task to be execute.
515 int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags)
517 return pm8001_task_exec(task, gfp_flags, 0, NULL);
523 * @ccb: the ccb which attached to ssp task
524 * @task: the task to be free.
528 struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx)
530 if (!ccb->task)
532 if (!sas_protocol_ata(task->task_proto))
534 dma_unmap_sg(pm8001_ha->dev, task->scatter,
535 task->num_scatter, task->data_dir);
537 switch (task->task_proto) {
539 dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_resp, 1,
541 dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_req, 1,
552 task->lldd_task = NULL;
553 ccb->task = NULL;
685 void pm8001_task_done(struct sas_task *task)
687 del_timer(&task->slow_task->timer);
688 complete(&task->slow_task->completion);
694 struct sas_task *task = slow->task;
697 spin_lock_irqsave(&task->task_state_lock, flags);
698 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
699 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
700 complete(&task->slow_task->completion);
702 spin_unlock_irqrestore(&task->task_state_lock, flags);
707 * pm8001_exec_internal_tmf_task - execute some task management commands.
709 * @tmf: which task management wanted to be take.
711 * @parameter: ssp task parameter.
714 * abort the issued task which result in this execption, it is done by calling
715 * this function, note it is also with the task execute interface.
721 struct sas_task *task = NULL;
727 task = sas_alloc_slow_task(GFP_KERNEL);
728 if (!task)
731 task->dev = dev;
732 task->task_proto = dev->tproto;
733 memcpy(&task->ssp_task, parameter, para_len);
734 task->task_done = pm8001_task_done;
735 task->slow_task->timer.function = pm8001_tmf_timedout;
736 task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
737 add_timer(&task->slow_task->timer);
739 res = pm8001_task_exec(task, GFP_KERNEL, 1, tmf);
742 del_timer(&task->slow_task->timer);
743 pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n");
746 wait_for_completion(&task->slow_task->completion);
755 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
756 struct pm8001_ccb_info *ccb = task->lldd_task;
758 pm8001_dbg(pm8001_ha, FAIL, "TMF task[%x]timeout.\n",
762 ccb->task = NULL;
766 if (task->task_status.resp == SAS_TASK_COMPLETE &&
767 task->task_status.stat == SAS_SAM_STAT_GOOD) {
772 if (task->task_status.resp == SAS_TASK_COMPLETE &&
773 task->task_status.stat == SAS_DATA_UNDERRUN) {
776 res = task->task_status.residual;
780 if (task->task_status.resp == SAS_TASK_COMPLETE &&
781 task->task_status.stat == SAS_DATA_OVERRUN) {
782 pm8001_dbg(pm8001_ha, FAIL, "Blocked task error.\n");
789 task->task_status.resp,
790 task->task_status.stat);
791 sas_free_task(task);
792 task = NULL;
796 BUG_ON(retry == 3 && task != NULL);
797 sas_free_task(task);
809 struct sas_task *task = NULL;
812 task = sas_alloc_slow_task(GFP_KERNEL);
813 if (!task)
816 task->dev = dev;
817 task->task_proto = dev->tproto;
818 task->task_done = pm8001_task_done;
819 task->slow_task->timer.function = pm8001_tmf_timedout;
820 task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT * HZ;
821 add_timer(&task->slow_task->timer);
829 ccb->task = task;
835 del_timer(&task->slow_task->timer);
836 pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n");
840 wait_for_completion(&task->slow_task->completion);
843 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
844 pm8001_dbg(pm8001_ha, FAIL, "TMF task timeout.\n");
848 if (task->task_status.resp == SAS_TASK_COMPLETE &&
849 task->task_status.stat == SAS_SAM_STAT_GOOD) {
857 task->task_status.resp,
858 task->task_status.stat);
859 sas_free_task(task);
860 task = NULL;
864 BUG_ON(retry == 3 && task != NULL);
865 sas_free_task(task);
920 /* retry commands by ha, by task and/or by device */
935 struct sas_task *task;
956 task = ccb->task;
957 if (!task || !task->task_done)
959 if (task_to_close && (task != task_to_close))
961 ts = &task->task_status;
968 spin_lock_irqsave(&task->task_state_lock, flags1);
969 task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
970 task->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
971 task->task_state_flags |= SAS_TASK_STATE_DONE;
972 if (unlikely((task->task_state_flags
974 spin_unlock_irqrestore(&task->task_state_lock,
976 pm8001_ccb_task_free(pm8001_ha, task, ccb, tag);
978 spin_unlock_irqrestore(&task->task_state_lock,
980 pm8001_ccb_task_free(pm8001_ha, task, ccb, tag);
983 task->task_done(task);
1027 pm8001_dbg(pm8001_ha, EH, "task abort failed %x\n"
1105 /* mandatory SAM-3, the task reset the specified LUN*/
1134 int pm8001_query_task(struct sas_task *task)
1140 if (unlikely(!task || !task->lldd_task || !task->dev))
1143 if (task->task_proto & SAS_PROTOCOL_SSP) {
1144 struct scsi_cmnd *cmnd = task->uldd_task;
1145 struct domain_device *dev = task->dev;
1150 rc = pm8001_find_tag(task, &tag);
1161 /* The task is still in Lun, release it then */
1164 "The task is still in Lun\n");
1166 /* The task is not in Lun or failed, reset the phy */
1170 "The task is not in Lun or failed, reset the phy\n");
1178 /* mandatory SAM-3, still need free task/ccb info, abort the specified task */
1179 int pm8001_abort_task(struct sas_task *task)
1191 if (unlikely(!task || !task->lldd_task || !task->dev))
1193 dev = task->dev;
1197 ret = pm8001_find_tag(task, &tag);
1199 pm8001_printk("no tag for task:%p\n", task);
1202 spin_lock_irqsave(&task->task_state_lock, flags);
1203 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
1204 spin_unlock_irqrestore(&task->task_state_lock, flags);
1207 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
1208 if (task->slow_task == NULL) {
1210 task->slow_task = &slow_task;
1212 spin_unlock_irqrestore(&task->task_state_lock, flags);
1213 if (task->task_proto & SAS_PROTOCOL_SSP) {
1214 struct scsi_cmnd *cmnd = task->uldd_task;
1221 } else if (task->task_proto & SAS_PROTOCOL_SATA ||
1222 task->task_proto & SAS_PROTOCOL_STP) {
1253 * leaking the task in libsas or losing the race and
1284 * we wait for the task to be aborted so that the task
1286 * going to free the task.
1293 &task->slow_task->completion,
1309 } else if (task->task_proto & SAS_PROTOCOL_SMP) {
1316 spin_lock_irqsave(&task->task_state_lock, flags);
1317 if (task->slow_task == &slow_task)
1318 task->slow_task = NULL;
1319 spin_unlock_irqrestore(&task->task_state_lock, flags);
1347 pm8001_dbg(pm8001_ha, EH, "I_T_L_Q clear task set[%x]\n",