int asd_I_T_nexus_reset(struct domain_device *dev)
{ int res, tmp_res, i; struct sas_phy *phy = sas_get_local_phy(dev); /* Standard mandates link reset for ATA (type 0) and
* hard reset for SSP (type 1) */ int reset_type = (dev->dev_type == SAS_SATA_DEV ||
(dev->tproto & SAS_PROTOCOL_STP)) ? 0 : 1;
asd_clear_nexus_I_T(dev, NEXUS_PHASE_PRE); /* send a hard reset */
ASD_DPRINTK("sending %s reset to %s\n",
reset_type ? "hard" : "soft", dev_name(&phy->dev));
res = sas_phy_reset(phy, reset_type); if (res == TMF_RESP_FUNC_COMPLETE || res == -ENODEV) { /* wait for the maximum settle time */
msleep(500); /* clear all outstanding commands (keep nexus suspended) */
asd_clear_nexus_I_T(dev, NEXUS_PHASE_POST);
} for (i = 0 ; i < 3; i++) {
tmp_res = asd_clear_nexus_I_T(dev, NEXUS_PHASE_RESUME); if (tmp_res == TC_RESUME) goto out;
msleep(500);
}
/* This is a bit of a problem: the sequencer is still suspended * and is refusing to resume. Hope it will resume on a bigger hammer
* or the disk is lost */
dev_printk(KERN_ERR, &phy->dev, "Failed to resume nexus after reset 0x%x\n", tmp_res);
res = TMF_RESP_FUNC_FAILED;
out:
sas_put_local_phy(phy); return res;
}
staticint asd_clear_nexus(struct sas_task *task)
{ int res = TMF_RESP_FUNC_FAILED; int leftover; struct asd_ascb *tascb = task->lldd_task;
DECLARE_COMPLETION_ONSTACK(completion); unsignedlong flags;
tascb->completion = &completion;
ASD_DPRINTK("task not done, clearing nexus\n"); if (tascb->tag_valid)
res = asd_clear_nexus_tag(task); else
res = asd_clear_nexus_index(task);
leftover = wait_for_completion_timeout(&completion,
AIC94XX_SCB_TIMEOUT);
tascb->completion = NULL;
ASD_DPRINTK("came back from clear nexus\n");
spin_lock_irqsave(&task->task_state_lock, flags); if (leftover < 1)
res = TMF_RESP_FUNC_FAILED; if (task->task_state_flags & SAS_TASK_STATE_DONE)
res = TMF_RESP_FUNC_COMPLETE;
spin_unlock_irqrestore(&task->task_state_lock, flags);
return res;
}
/** * asd_abort_task -- ABORT TASK TMF * @task: the task to be aborted * * Before calling ABORT TASK the task state flags should be ORed with * SAS_TASK_STATE_ABORTED (unless SAS_TASK_STATE_DONE is set) under * the task_state_lock IRQ spinlock, then ABORT TASK *must* be called. * * Implements the ABORT TASK TMF, I_T_L_Q nexus. * Returns: SAS TMF responses (see sas_task.h), * -ENOMEM, * -SAS_QUEUE_FULL. * * When ABORT TASK returns, the caller of ABORT TASK checks first the * task->task_state_flags, and then the return value of ABORT TASK. * * If the task has task state bit SAS_TASK_STATE_DONE set, then the * task was completed successfully prior to it being aborted. The * caller of ABORT TASK has responsibility to call task->task_done() * xor free the task, depending on their framework. The return code * is TMF_RESP_FUNC_FAILED in this case. * * Else the SAS_TASK_STATE_DONE bit is not set, * If the return code is TMF_RESP_FUNC_COMPLETE, then * the task was aborted successfully. The caller of * ABORT TASK has responsibility to call task->task_done() * to finish the task, xor free the task depending on their * framework. * else * the ABORT TASK returned some kind of error. The task * was _not_ cancelled. Nothing can be assumed. * The caller of ABORT TASK may wish to retry.
*/ int asd_abort_task(struct sas_task *task)
{ struct asd_ascb *tascb = task->lldd_task; struct asd_ha_struct *asd_ha = tascb->ha; int res = 1; unsignedlong flags; struct asd_ascb *ascb = NULL; struct scb *scb; int leftover;
DECLARE_TCS(tcs);
DECLARE_COMPLETION_ONSTACK(completion);
DECLARE_COMPLETION_ONSTACK(tascb_completion);
res = asd_enqueue_internal(ascb, asd_tmf_tasklet_complete,
asd_tmf_timedout); if (res) goto out_free;
wait_for_completion(&completion);
ASD_DPRINTK("tmf came back\n");
if (tcs.dl_opcode == TC_SSP_RESP) { /* The task to be aborted has been sent to the device.
* We got a Response IU for the ABORT TASK TMF. */ if (tcs.tmf_state == TMF_RESP_FUNC_COMPLETE)
res = asd_clear_nexus(task); else
res = tcs.tmf_state;
} elseif (tcs.dl_opcode == TC_NO_ERROR &&
tcs.tmf_state == TMF_RESP_FUNC_FAILED) { /* timeout */
res = TMF_RESP_FUNC_FAILED;
} else { /* In the following we assume that the managing layer * will _never_ make a mistake, when issuing ABORT * TASK.
*/ switch (tcs.dl_opcode) { default:
res = asd_clear_nexus(task);
fallthrough; case TC_NO_ERROR: break; /* The task hasn't been sent to the device xor * we never got a (sane) Response IU for the * ABORT TASK TMF.
*/ case TF_NAK_RECV:
res = TMF_RESP_INVALID_FRAME; break; case TF_TMF_TASK_DONE: /* done but not reported yet */
res = TMF_RESP_FUNC_FAILED;
leftover =
wait_for_completion_timeout(&tascb_completion,
AIC94XX_SCB_TIMEOUT);
spin_lock_irqsave(&task->task_state_lock, flags); if (leftover < 1)
res = TMF_RESP_FUNC_FAILED; if (task->task_state_flags & SAS_TASK_STATE_DONE)
res = TMF_RESP_FUNC_COMPLETE;
spin_unlock_irqrestore(&task->task_state_lock, flags); break; case TF_TMF_NO_TAG: case TF_TMF_TAG_FREE: /* the tag is in the free list */ case TF_TMF_NO_CONN_HANDLE: /* no such device */
res = TMF_RESP_FUNC_COMPLETE; break; case TF_TMF_NO_CTX: /* not in seq, or proto != SSP */
res = TMF_RESP_FUNC_ESUPP; break;
}
}
out_done:
tascb->completion = NULL; if (res == TMF_RESP_FUNC_COMPLETE) {
task->lldd_task = NULL;
mb();
asd_ascb_free(tascb);
}
ASD_DPRINTK("task 0x%p aborted, res: 0x%x\n", task, res); return res;
/** * asd_initiate_ssp_tmf -- send a TMF to an I_T_L or I_T_L_Q nexus * @dev: pointer to struct domain_device of interest * @lun: pointer to u8[8] which is the LUN * @tmf: the TMF to be performed (see sas_task.h or the SAS spec) * @index: the transaction context of the task to be queried if QT TMF * * This function is used to send ABORT TASK SET, CLEAR ACA, * CLEAR TASK SET, LU RESET and QUERY TASK TMFs. * * No SCBs should be queued to the I_T_L nexus when this SCB is * pending. * * Returns: TMF response code (see sas_task.h or the SAS spec)
*/ staticint asd_initiate_ssp_tmf(struct domain_device *dev, u8 *lun, int tmf, int index)
{ struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; struct asd_ascb *ascb; int res = 1; struct scb *scb;
DECLARE_COMPLETION_ONSTACK(completion);
DECLARE_TCS(tcs);
if (!(dev->tproto & SAS_PROTOCOL_SSP)) return TMF_RESP_FUNC_ESUPP;
ascb = asd_ascb_alloc_list(asd_ha, &res, GFP_KERNEL); if (!ascb) return -ENOMEM;
res = asd_enqueue_internal(ascb, asd_tmf_tasklet_complete,
asd_tmf_timedout); if (res) goto out_err;
wait_for_completion(&completion);
switch (tcs.dl_opcode) { case TC_NO_ERROR:
res = TMF_RESP_FUNC_COMPLETE; break; case TF_NAK_RECV:
res = TMF_RESP_INVALID_FRAME; break; case TF_TMF_TASK_DONE:
res = TMF_RESP_FUNC_FAILED; break; case TF_TMF_NO_TAG: case TF_TMF_TAG_FREE: /* the tag is in the free list */ case TF_TMF_NO_CONN_HANDLE: /* no such device */
res = TMF_RESP_FUNC_COMPLETE; break; case TF_TMF_NO_CTX: /* not in seq, or proto != SSP */
res = TMF_RESP_FUNC_ESUPP; break; default: /* Allow TMF response codes to propagate upwards */
res = tcs.dl_opcode; break;
} return res;
out_err:
asd_ascb_free(ascb); return res;
}
int asd_abort_task_set(struct domain_device *dev, u8 *lun)
{ int res = asd_initiate_ssp_tmf(dev, lun, TMF_ABORT_TASK_SET, 0);
if (res == TMF_RESP_FUNC_COMPLETE)
asd_clear_nexus_I_T_L(dev, lun); return res;
}
int asd_clear_task_set(struct domain_device *dev, u8 *lun)
{ int res = asd_initiate_ssp_tmf(dev, lun, TMF_CLEAR_TASK_SET, 0);
if (res == TMF_RESP_FUNC_COMPLETE)
asd_clear_nexus_I_T_L(dev, lun); return res;
}
int asd_lu_reset(struct domain_device *dev, u8 *lun)
{ int res = asd_initiate_ssp_tmf(dev, lun, TMF_LU_RESET, 0);
if (res == TMF_RESP_FUNC_COMPLETE)
asd_clear_nexus_I_T_L(dev, lun); return res;
}
/** * asd_query_task -- send a QUERY TASK TMF to an I_T_L_Q nexus * @task: pointer to sas_task struct of interest * * Returns: TMF_RESP_FUNC_COMPLETE if the task is not in the task set, * or TMF_RESP_FUNC_SUCC if the task is in the task set. * * Normally the management layer sets the task to aborted state, * and then calls query task and then abort task.
*/ int asd_query_task(struct sas_task *task)
{ struct asd_ascb *ascb = task->lldd_task; int index;
if (ascb) {
index = ascb->tc_index; return asd_initiate_ssp_tmf(task->dev, task->ssp_task.LUN,
TMF_QUERY_TASK, index);
} return TMF_RESP_FUNC_COMPLETE;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.