|
@@ -1390,6 +1390,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
|
|
struct ata_queued_cmd *qc;
|
|
struct ata_queued_cmd *qc;
|
|
unsigned int tag, preempted_tag;
|
|
unsigned int tag, preempted_tag;
|
|
u32 preempted_sactive, preempted_qc_active;
|
|
u32 preempted_sactive, preempted_qc_active;
|
|
|
|
+ int preempted_nr_active_links;
|
|
DECLARE_COMPLETION_ONSTACK(wait);
|
|
DECLARE_COMPLETION_ONSTACK(wait);
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
unsigned int err_mask;
|
|
unsigned int err_mask;
|
|
@@ -1428,9 +1429,11 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
|
|
preempted_tag = link->active_tag;
|
|
preempted_tag = link->active_tag;
|
|
preempted_sactive = link->sactive;
|
|
preempted_sactive = link->sactive;
|
|
preempted_qc_active = ap->qc_active;
|
|
preempted_qc_active = ap->qc_active;
|
|
|
|
+ preempted_nr_active_links = ap->nr_active_links;
|
|
link->active_tag = ATA_TAG_POISON;
|
|
link->active_tag = ATA_TAG_POISON;
|
|
link->sactive = 0;
|
|
link->sactive = 0;
|
|
ap->qc_active = 0;
|
|
ap->qc_active = 0;
|
|
|
|
+ ap->nr_active_links = 0;
|
|
|
|
|
|
/* prepare & issue qc */
|
|
/* prepare & issue qc */
|
|
qc->tf = *tf;
|
|
qc->tf = *tf;
|
|
@@ -1509,6 +1512,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
|
|
link->active_tag = preempted_tag;
|
|
link->active_tag = preempted_tag;
|
|
link->sactive = preempted_sactive;
|
|
link->sactive = preempted_sactive;
|
|
ap->qc_active = preempted_qc_active;
|
|
ap->qc_active = preempted_qc_active;
|
|
|
|
+ ap->nr_active_links = preempted_nr_active_links;
|
|
|
|
|
|
/* XXX - Some LLDDs (sata_mv) disable port on command failure.
|
|
/* XXX - Some LLDDs (sata_mv) disable port on command failure.
|
|
* Until those drivers are fixed, we detect the condition
|
|
* Until those drivers are fixed, we detect the condition
|
|
@@ -5408,10 +5412,19 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
|
|
ata_sg_clean(qc);
|
|
ata_sg_clean(qc);
|
|
|
|
|
|
/* command should be marked inactive atomically with qc completion */
|
|
/* command should be marked inactive atomically with qc completion */
|
|
- if (qc->tf.protocol == ATA_PROT_NCQ)
|
|
|
|
|
|
+ if (qc->tf.protocol == ATA_PROT_NCQ) {
|
|
link->sactive &= ~(1 << qc->tag);
|
|
link->sactive &= ~(1 << qc->tag);
|
|
- else
|
|
|
|
|
|
+ if (!link->sactive)
|
|
|
|
+ ap->nr_active_links--;
|
|
|
|
+ } else {
|
|
link->active_tag = ATA_TAG_POISON;
|
|
link->active_tag = ATA_TAG_POISON;
|
|
|
|
+ ap->nr_active_links--;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* clear exclusive status */
|
|
|
|
+ if (unlikely(qc->flags & ATA_QCFLAG_CLEAR_EXCL &&
|
|
|
|
+ ap->excl_link == link))
|
|
|
|
+ ap->excl_link = NULL;
|
|
|
|
|
|
/* atapi: mark qc as inactive to prevent the interrupt handler
|
|
/* atapi: mark qc as inactive to prevent the interrupt handler
|
|
* from completing the command twice later, before the error handler
|
|
* from completing the command twice later, before the error handler
|
|
@@ -5590,9 +5603,14 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
|
|
|
|
|
|
if (qc->tf.protocol == ATA_PROT_NCQ) {
|
|
if (qc->tf.protocol == ATA_PROT_NCQ) {
|
|
WARN_ON(link->sactive & (1 << qc->tag));
|
|
WARN_ON(link->sactive & (1 << qc->tag));
|
|
|
|
+
|
|
|
|
+ if (!link->sactive)
|
|
|
|
+ ap->nr_active_links++;
|
|
link->sactive |= 1 << qc->tag;
|
|
link->sactive |= 1 << qc->tag;
|
|
} else {
|
|
} else {
|
|
WARN_ON(link->sactive);
|
|
WARN_ON(link->sactive);
|
|
|
|
+
|
|
|
|
+ ap->nr_active_links++;
|
|
link->active_tag = qc->tag;
|
|
link->active_tag = qc->tag;
|
|
}
|
|
}
|
|
|
|
|