Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-29 Thread Mark Lord

Alan Cox wrote:

Why 512 words ?
Though I have queued Mark's patch to be applied, my gut feeling would 
lean towards a single DRQ block, rather than 512.


Why not just work from the old IDE code.



ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);

ap->ops->cleanup();

might be wiser
If someone needs that, they can override the error handler with their 
own.  No need for a new op.


PDC202xx needs


Alan, you're the expert there (my condolences!).
Can you generate a fix for the PDC202xx to go with this?

Cheers
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation (try#2)

2007-09-29 Thread Jeff Garzik

Mark Lord wrote:

I think this original patch still applies cleanly on at least 2.6.23-rc7.

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.

Signed-off-by: Mark Lord <[EMAIL PROTECTED]>
---

--- old/drivers/ata/libata-sff.c2007-09-28 09:29:22.0 -0400
+++ linux/drivers/ata/libata-sff.c2007-09-28 09:39:44.0 -0400
@@ -420,6 +420,28 @@
ap->ops->irq_on(ap);
}

+static void ata_drain_fifo(struct ata_port *ap, struct ata_queued_cmd *qc)
+{
+u8 stat = ata_chk_status(ap);
+/*
+ * Try to clear stuck DRQ if necessary,
+ * by reading/discarding up to two sectors worth of data.
+ */
+if ((stat & ATA_DRQ) && (!qc || qc->dma_dir != DMA_TO_DEVICE)) {
+unsigned int i;
+unsigned int limit = qc ? qc->sect_size : ATA_SECT_SIZE;
+
+printk(KERN_WARNING "Draining up to %u words from data FIFO.\n",
+limit);
+for (i = 0; i < limit ; ++i) {
+ioread16(ap->ioaddr.data_addr);
+if (!(ata_chk_status(ap) & ATA_DRQ))
+break;
+}
+printk(KERN_WARNING "Drained %u/%u words.\n", i, limit);
+}
+}
+
/**
 *ata_bmdma_drive_eh - Perform EH with given methods for BMDMA 
controller

 *@ap: port to handle error for
@@ -476,7 +498,7 @@
}

ata_altstatus(ap);
-ata_chk_status(ap);
+ata_drain_fifo(ap, qc);
ap->ops->irq_clear(ap);

spin_unlock_irqrestore(ap->lock, flags);


applied, after hand-editing out the top of the message, so that it would 
not be copied into the kernel changelog


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-29 Thread Alan Cox
> > Why 512 words ?
> 
> Though I have queued Mark's patch to be applied, my gut feeling would 
> lean towards a single DRQ block, rather than 512.

Why not just work from the old IDE code.
> 
> 
> >>ata_altstatus(ap);
> >> -  ata_chk_status(ap);
> >> +  ata_drain_fifo(ap, qc);
> > 
> > ap->ops->cleanup();
> > 
> > might be wiser
> 
> If someone needs that, they can override the error handler with their 
> own.  No need for a new op.

PDC202xx needs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-29 Thread Alan Cox
  Why 512 words ?
 
 Though I have queued Mark's patch to be applied, my gut feeling would 
 lean towards a single DRQ block, rather than 512.

Why not just work from the old IDE code.
 
 
 ata_altstatus(ap);
  -  ata_chk_status(ap);
  +  ata_drain_fifo(ap, qc);
  
  ap-ops-cleanup();
  
  might be wiser
 
 If someone needs that, they can override the error handler with their 
 own.  No need for a new op.

PDC202xx needs
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation (try#2)

2007-09-29 Thread Jeff Garzik

Mark Lord wrote:

I think this original patch still applies cleanly on at least 2.6.23-rc7.

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.

Signed-off-by: Mark Lord [EMAIL PROTECTED]
---

--- old/drivers/ata/libata-sff.c2007-09-28 09:29:22.0 -0400
+++ linux/drivers/ata/libata-sff.c2007-09-28 09:39:44.0 -0400
@@ -420,6 +420,28 @@
ap-ops-irq_on(ap);
}

+static void ata_drain_fifo(struct ata_port *ap, struct ata_queued_cmd *qc)
+{
+u8 stat = ata_chk_status(ap);
+/*
+ * Try to clear stuck DRQ if necessary,
+ * by reading/discarding up to two sectors worth of data.
+ */
+if ((stat  ATA_DRQ)  (!qc || qc-dma_dir != DMA_TO_DEVICE)) {
+unsigned int i;
+unsigned int limit = qc ? qc-sect_size : ATA_SECT_SIZE;
+
+printk(KERN_WARNING Draining up to %u words from data FIFO.\n,
+limit);
+for (i = 0; i  limit ; ++i) {
+ioread16(ap-ioaddr.data_addr);
+if (!(ata_chk_status(ap)  ATA_DRQ))
+break;
+}
+printk(KERN_WARNING Drained %u/%u words.\n, i, limit);
+}
+}
+
/**
 *ata_bmdma_drive_eh - Perform EH with given methods for BMDMA 
controller

 *@ap: port to handle error for
@@ -476,7 +498,7 @@
}

ata_altstatus(ap);
-ata_chk_status(ap);
+ata_drain_fifo(ap, qc);
ap-ops-irq_clear(ap);

spin_unlock_irqrestore(ap-lock, flags);


applied, after hand-editing out the top of the message, so that it would 
not be copied into the kernel changelog


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-29 Thread Mark Lord

Alan Cox wrote:

Why 512 words ?
Though I have queued Mark's patch to be applied, my gut feeling would 
lean towards a single DRQ block, rather than 512.


Why not just work from the old IDE code.



ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);

ap-ops-cleanup();

might be wiser
If someone needs that, they can override the error handler with their 
own.  No need for a new op.


PDC202xx needs


Alan, you're the expert there (my condolences!).
Can you generate a fix for the PDC202xx to go with this?

Cheers
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Jeff Garzik

Alan Cox wrote:

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.


Why 512 words ?


Though I have queued Mark's patch to be applied, my gut feeling would 
lean towards a single DRQ block, rather than 512.




ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);


ap->ops->cleanup();

might be wiser


If someone needs that, they can override the error handler with their 
own.  No need for a new op.


Jeff


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] libata drain fifo on stuck DRQ HSM violation (try#2)

2007-09-28 Thread Mark Lord

Alan Cox wrote:

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.


Why 512 words ?



ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);


ap->ops->cleanup();

might be wiser


Actually, I belileve we should base it on qc->sect_size instead.

Then, if somebody also would like to submit a patch introducing
a cleanup() method, then please do so!

As a separate patch, though (seems to be the "libata way").
* * * *

Tejun Heo wrote:

Jeff Garzik wrote:

Tejun Heo wrote:

Alan Cox wrote:

I think there have been enough cases where this draining was necessary.
 IIRC, ata_piix was involved in those cases, right?  If so, can you
please submit a patch which applies this only to affected controllers?
I don't feel too confident about applying this to all SFF controllers.

Old IDE does it on all controllers bar a couple. So we have a very good
knowledge of what does/doesn't work. The one that needs care in old ide
is an ordering issue where a state machine reset done first causes the
drain of the I/O to hang.

Hmmm... So, do we apply draining to all PATA?  Or is ata_piix SATA
affected too?

I would think all SFF controllers, since a lot of first gen SATA are
really bridged solutions.  If they are flagging DRQ, I say oblige them :)


Alright, then the posted patch should be good enough.  Mark, can you be
bothered to regenerate the patch and post it one more time (again)?  It
seems we all agree the update is needed.


I think this original patch still applies cleanly on at least 2.6.23-rc7.

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.

Signed-off-by: Mark Lord <[EMAIL PROTECTED]>
---

--- old/drivers/ata/libata-sff.c2007-09-28 09:29:22.0 -0400
+++ linux/drivers/ata/libata-sff.c  2007-09-28 09:39:44.0 -0400
@@ -420,6 +420,28 @@
ap->ops->irq_on(ap);
}

+static void ata_drain_fifo(struct ata_port *ap, struct ata_queued_cmd *qc)
+{
+   u8 stat = ata_chk_status(ap);
+   /*
+* Try to clear stuck DRQ if necessary,
+* by reading/discarding up to two sectors worth of data.
+*/
+   if ((stat & ATA_DRQ) && (!qc || qc->dma_dir != DMA_TO_DEVICE)) {
+   unsigned int i;
+   unsigned int limit = qc ? qc->sect_size : ATA_SECT_SIZE;
+
+   printk(KERN_WARNING "Draining up to %u words from data FIFO.\n",
+   limit);
+   for (i = 0; i < limit ; ++i) {
+   ioread16(ap->ioaddr.data_addr);
+   if (!(ata_chk_status(ap) & ATA_DRQ))
+   break;
+   }
+   printk(KERN_WARNING "Drained %u/%u words.\n", i, limit);
+   }
+}
+
/**
 *  ata_bmdma_drive_eh - Perform EH with given methods for BMDMA controller
 *  @ap: port to handle error for
@@ -476,7 +498,7 @@
}

ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);
ap->ops->irq_clear(ap);

spin_unlock_irqrestore(ap->lock, flags);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Alan Cox
> Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
> rather than just getting stuck there forever.

Why 512 words ?


>   ata_altstatus(ap);
> - ata_chk_status(ap);
> + ata_drain_fifo(ap, qc);

ap->ops->cleanup();

might be wiser
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Tejun Heo
> Nacked-by: scripts/checkpatch.pl

Mark, it seems you'll have to get ACK from this dude first.  :-)

-- 
tejun
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Andrew Morton
On Fri, 28 Sep 2007 02:48:28 -0700 Tejun Heo <[EMAIL PROTECTED]> wrote:

> Mark Lord wrote:
> > Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
> > rather than just getting stuck there forever.
> > 
> > Signed-Off-By:  Mark Lord <[EMAIL PROTECTED]>
> 
> Acked-by: Tejun Heo <[EMAIL PROTECTED]>
> 

Nacked-by: scripts/checkpatch.pl
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Tejun Heo
Mark Lord wrote:
> Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
> rather than just getting stuck there forever.
> 
> Signed-Off-By:  Mark Lord <[EMAIL PROTECTED]>

Acked-by: Tejun Heo <[EMAIL PROTECTED]>

-- 
tejun
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] libata drain fifo on stuck DRQ HSM violation (try#2)

2007-09-28 Thread Mark Lord

Alan Cox wrote:

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.


Why 512 words ?



ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);


ap-ops-cleanup();

might be wiser


Actually, I belileve we should base it on qc-sect_size instead.

Then, if somebody also would like to submit a patch introducing
a cleanup() method, then please do so!

As a separate patch, though (seems to be the libata way).
* * * *

Tejun Heo wrote:

Jeff Garzik wrote:

Tejun Heo wrote:

Alan Cox wrote:

I think there have been enough cases where this draining was necessary.
 IIRC, ata_piix was involved in those cases, right?  If so, can you
please submit a patch which applies this only to affected controllers?
I don't feel too confident about applying this to all SFF controllers.

Old IDE does it on all controllers bar a couple. So we have a very good
knowledge of what does/doesn't work. The one that needs care in old ide
is an ordering issue where a state machine reset done first causes the
drain of the I/O to hang.

Hmmm... So, do we apply draining to all PATA?  Or is ata_piix SATA
affected too?

I would think all SFF controllers, since a lot of first gen SATA are
really bridged solutions.  If they are flagging DRQ, I say oblige them :)


Alright, then the posted patch should be good enough.  Mark, can you be
bothered to regenerate the patch and post it one more time (again)?  It
seems we all agree the update is needed.


I think this original patch still applies cleanly on at least 2.6.23-rc7.

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.

Signed-off-by: Mark Lord [EMAIL PROTECTED]
---

--- old/drivers/ata/libata-sff.c2007-09-28 09:29:22.0 -0400
+++ linux/drivers/ata/libata-sff.c  2007-09-28 09:39:44.0 -0400
@@ -420,6 +420,28 @@
ap-ops-irq_on(ap);
}

+static void ata_drain_fifo(struct ata_port *ap, struct ata_queued_cmd *qc)
+{
+   u8 stat = ata_chk_status(ap);
+   /*
+* Try to clear stuck DRQ if necessary,
+* by reading/discarding up to two sectors worth of data.
+*/
+   if ((stat  ATA_DRQ)  (!qc || qc-dma_dir != DMA_TO_DEVICE)) {
+   unsigned int i;
+   unsigned int limit = qc ? qc-sect_size : ATA_SECT_SIZE;
+
+   printk(KERN_WARNING Draining up to %u words from data FIFO.\n,
+   limit);
+   for (i = 0; i  limit ; ++i) {
+   ioread16(ap-ioaddr.data_addr);
+   if (!(ata_chk_status(ap)  ATA_DRQ))
+   break;
+   }
+   printk(KERN_WARNING Drained %u/%u words.\n, i, limit);
+   }
+}
+
/**
 *  ata_bmdma_drive_eh - Perform EH with given methods for BMDMA controller
 *  @ap: port to handle error for
@@ -476,7 +498,7 @@
}

ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);
ap-ops-irq_clear(ap);

spin_unlock_irqrestore(ap-lock, flags);
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Alan Cox
 Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
 rather than just getting stuck there forever.

Why 512 words ?


   ata_altstatus(ap);
 - ata_chk_status(ap);
 + ata_drain_fifo(ap, qc);

ap-ops-cleanup();

might be wiser
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Tejun Heo
 Nacked-by: scripts/checkpatch.pl

Mark, it seems you'll have to get ACK from this dude first.  :-)

-- 
tejun
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Tejun Heo
Mark Lord wrote:
 Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
 rather than just getting stuck there forever.
 
 Signed-Off-By:  Mark Lord [EMAIL PROTECTED]

Acked-by: Tejun Heo [EMAIL PROTECTED]

-- 
tejun
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Andrew Morton
On Fri, 28 Sep 2007 02:48:28 -0700 Tejun Heo [EMAIL PROTECTED] wrote:

 Mark Lord wrote:
  Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
  rather than just getting stuck there forever.
  
  Signed-Off-By:  Mark Lord [EMAIL PROTECTED]
 
 Acked-by: Tejun Heo [EMAIL PROTECTED]
 

Nacked-by: scripts/checkpatch.pl
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-28 Thread Jeff Garzik

Alan Cox wrote:

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.


Why 512 words ?


Though I have queued Mark's patch to be applied, my gut feeling would 
lean towards a single DRQ block, rather than 512.




ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);


ap-ops-cleanup();

might be wiser


If someone needs that, they can override the error handler with their 
own.  No need for a new op.


Jeff


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-27 Thread Mark Lord

Tejun Heo wrote:

Jeff Garzik wrote:

Tejun Heo wrote:

Alan Cox wrote:

I think there have been enough cases where this draining was necessary.
 IIRC, ata_piix was involved in those cases, right?  If so, can you
please submit a patch which applies this only to affected controllers?
I don't feel too confident about applying this to all SFF controllers.

Old IDE does it on all controllers bar a couple. So we have a very good
knowledge of what does/doesn't work. The one that needs care in old ide
is an ordering issue where a state machine reset done first causes the
drain of the I/O to hang.

Hmmm... So, do we apply draining to all PATA?  Or is ata_piix SATA
affected too?

I would think all SFF controllers, since a lot of first gen SATA are
really bridged solutions.  If they are flagging DRQ, I say oblige them :)


Alright, then the posted patch should be good enough.  Mark, can you be
bothered to regenerate the patch and post it one more time (again)?  It
seems we all agree the update is needed.


I think this original patch still applies cleanly on at least 2.6.23-rc7.

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.

Signed-Off-By:  Mark Lord <[EMAIL PROTECTED]>
---

--- old/drivers/ata/libata-sff.c2007-04-26 12:02:46.0 -0400
+++ linux/drivers/ata/libata-sff.c  2007-04-29 08:29:27.0 -0400
@@ -413,6 +413,24 @@
ap->ops->irq_on(ap);
}

+static void ata_drain_fifo (struct ata_port *ap, struct ata_queued_cmd *qc)
+{
+   u8 stat = ata_chk_status(ap);
+   /*
+* Try to clear stuck DRQ if necessary.
+*/
+   if ((stat & ATA_DRQ) && (!qc || qc->dma_dir != DMA_TO_DEVICE)) {
+   unsigned int i, limit = 512;
+   printk("Draining up to %u words from data FIFO.\n", limit);
+   for (i = 0; i < limit ; ++i) {
+   ioread16(ap->ioaddr.data_addr);
+   if (!(ata_chk_status(ap) & ATA_DRQ))
+   break;
+   }
+   printk("Drained %u/%u words.\n", i, limit);
+   }
+}
+
/**
 *  ata_bmdma_drive_eh - Perform EH with given methods for BMDMA controller
 *  @ap: port to handle error for
@@ -469,7 +487,7 @@
}

ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);
ap->ops->irq_clear(ap);

spin_unlock_irqrestore(ap->lock, flags);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] libata drain fifo on stuck DRQ HSM violation

2007-09-27 Thread Mark Lord

Tejun Heo wrote:

Jeff Garzik wrote:

Tejun Heo wrote:

Alan Cox wrote:

I think there have been enough cases where this draining was necessary.
 IIRC, ata_piix was involved in those cases, right?  If so, can you
please submit a patch which applies this only to affected controllers?
I don't feel too confident about applying this to all SFF controllers.

Old IDE does it on all controllers bar a couple. So we have a very good
knowledge of what does/doesn't work. The one that needs care in old ide
is an ordering issue where a state machine reset done first causes the
drain of the I/O to hang.

Hmmm... So, do we apply draining to all PATA?  Or is ata_piix SATA
affected too?

I would think all SFF controllers, since a lot of first gen SATA are
really bridged solutions.  If they are flagging DRQ, I say oblige them :)


Alright, then the posted patch should be good enough.  Mark, can you be
bothered to regenerate the patch and post it one more time (again)?  It
seems we all agree the update is needed.


I think this original patch still applies cleanly on at least 2.6.23-rc7.

Drain up to 512 words from host/bridge FIFO on stuck DRQ HSM violation,
rather than just getting stuck there forever.

Signed-Off-By:  Mark Lord [EMAIL PROTECTED]
---

--- old/drivers/ata/libata-sff.c2007-04-26 12:02:46.0 -0400
+++ linux/drivers/ata/libata-sff.c  2007-04-29 08:29:27.0 -0400
@@ -413,6 +413,24 @@
ap-ops-irq_on(ap);
}

+static void ata_drain_fifo (struct ata_port *ap, struct ata_queued_cmd *qc)
+{
+   u8 stat = ata_chk_status(ap);
+   /*
+* Try to clear stuck DRQ if necessary.
+*/
+   if ((stat  ATA_DRQ)  (!qc || qc-dma_dir != DMA_TO_DEVICE)) {
+   unsigned int i, limit = 512;
+   printk(Draining up to %u words from data FIFO.\n, limit);
+   for (i = 0; i  limit ; ++i) {
+   ioread16(ap-ioaddr.data_addr);
+   if (!(ata_chk_status(ap)  ATA_DRQ))
+   break;
+   }
+   printk(Drained %u/%u words.\n, i, limit);
+   }
+}
+
/**
 *  ata_bmdma_drive_eh - Perform EH with given methods for BMDMA controller
 *  @ap: port to handle error for
@@ -469,7 +487,7 @@
}

ata_altstatus(ap);
-   ata_chk_status(ap);
+   ata_drain_fifo(ap, qc);
ap-ops-irq_clear(ap);

spin_unlock_irqrestore(ap-lock, flags);
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/