Patchwork [2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write

login
register
mail settings
Submitter Bart Hartgers
Date Jan. 16, 2010, 11:56 p.m.
Message ID <20100116235851.884756038@gmail.com>
Download mbox | patch
Permalink /patch/43017/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Bart Hartgers - Jan. 16, 2010, 11:56 p.m.
When writing a disc on certain lite-on dvd-writers (also rebadged as
optiarc/LG/...) connected to a vt6420, the ATAPI CDB ends up in the
datastream and on the disc, causing silent corruption.  Delaying
between sending the CDB and starting DMA seems to prevent this.

I do not know if there are burners that do not suffer from this, but
the patch should be safe for those as well.

There are many reports of this issue, but AFAICT no solution was 
found before. For example:
http://lkml.indiana.edu/hypermail/linux/kernel/0802.3/0561.html

Signed-off-by: Bart Hartgers <bart.hartgers@gmail.com>
---
Tejun Heo - Jan. 20, 2010, 3:30 a.m.
Hello,

On 01/17/2010 08:56 AM, Bart Hartgers wrote:
> When writing a disc on certain lite-on dvd-writers (also rebadged as
> optiarc/LG/...) connected to a vt6420, the ATAPI CDB ends up in the
> datastream and on the disc, causing silent corruption.  Delaying
> between sending the CDB and starting DMA seems to prevent this.
> 
> I do not know if there are burners that do not suffer from this, but
> the patch should be safe for those as well.
> 
> There are many reports of this issue, but AFAICT no solution was 
> found before. For example:
> http://lkml.indiana.edu/hypermail/linux/kernel/0802.3/0561.html
> 
> Signed-off-by: Bart Hartgers <bart.hartgers@gmail.com>

Ah... you found solution for this?  That's great.  This is one of the
three problems that have been lingering for years - the other two
being pata_ali ATAPI DMA problem and sata_sil data corruption problem.
I'll be ecstatic if this fix works.  Just one thing, I don't think
we'll need a warning message there.  It's useful during development
but it doesn't really provide any useful information afterwards.

Digging up the mailing list and cc'ing people who have reported this
problem.  If you still have the affected systems, can you guys please
test the patch in the following message and see whether it fixes the
problem?

  http://article.gmane.org/gmane.linux.kernel/939112/raw

Thanks a lot.  :-)
Robert Hancock - Jan. 20, 2010, 4:53 a.m.
On 01/19/2010 09:30 PM, Tejun Heo wrote:
> Hello,
>
> On 01/17/2010 08:56 AM, Bart Hartgers wrote:
>> When writing a disc on certain lite-on dvd-writers (also rebadged as
>> optiarc/LG/...) connected to a vt6420, the ATAPI CDB ends up in the
>> datastream and on the disc, causing silent corruption.  Delaying
>> between sending the CDB and starting DMA seems to prevent this.
>>
>> I do not know if there are burners that do not suffer from this, but
>> the patch should be safe for those as well.
>>
>> There are many reports of this issue, but AFAICT no solution was
>> found before. For example:
>> http://lkml.indiana.edu/hypermail/linux/kernel/0802.3/0561.html
>>
>> Signed-off-by: Bart Hartgers<bart.hartgers@gmail.com>
>
> Ah... you found solution for this?  That's great.  This is one of the
> three problems that have been lingering for years - the other two
> being pata_ali ATAPI DMA problem and sata_sil data corruption problem.
> I'll be ecstatic if this fix works.  Just one thing, I don't think
> we'll need a warning message there.  It's useful during development
> but it doesn't really provide any useful information afterwards.

Another tiny nitpick about the patch, the unlikely() around the 
DMA_TO_DEVICE check probably shouldn't be there - unlikely() is for 
things that will always be either highly unlikely or a slow path, 
neither of which really apply.

>
> Digging up the mailing list and cc'ing people who have reported this
> problem.  If you still have the affected systems, can you guys please
> test the patch in the following message and see whether it fixes the
> problem?
>
>    http://article.gmane.org/gmane.linux.kernel/939112/raw
>
> Thanks a lot.  :-)
>

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bart Hartgers - Jan. 20, 2010, 6:33 a.m.
Hi,

2010/1/20 Robert Hancock <hancockrwd@gmail.com>:
> On 01/19/2010 09:30 PM, Tejun Heo wrote:
>>
>> Hello,
>>
>> On 01/17/2010 08:56 AM, Bart Hartgers wrote:
>>>
>>> When writing a disc on certain lite-on dvd-writers (also rebadged as
>>> optiarc/LG/...) connected to a vt6420, the ATAPI CDB ends up in the
>>> datastream and on the disc, causing silent corruption.  Delaying
>>> between sending the CDB and starting DMA seems to prevent this.
>>>
>>> I do not know if there are burners that do not suffer from this, but
>>> the patch should be safe for those as well.
>>>
>>> There are many reports of this issue, but AFAICT no solution was
>>> found before. For example:
>>> http://lkml.indiana.edu/hypermail/linux/kernel/0802.3/0561.html
>>>
>>> Signed-off-by: Bart Hartgers<bart.hartgers@gmail.com>
>>
>> Ah... you found solution for this?  That's great.  This is one of the
>> three problems that have been lingering for years - the other two
>> being pata_ali ATAPI DMA problem and sata_sil data corruption problem.
>> I'll be ecstatic if this fix works.  Just one thing, I don't think
>> we'll need a warning message there.  It's useful during development
>> but it doesn't really provide any useful information afterwards.
>
> Another tiny nitpick about the patch, the unlikely() around the
> DMA_TO_DEVICE check probably shouldn't be there - unlikely() is for things
> that will always be either highly unlikely or a slow path, neither of which
> really apply.
>

Well, the ata_sff_pause actually does a ndelay(400), and with today's
processors that would be a 'slow path', right?

Groeten,
Bart

>>
>> Digging up the mailing list and cc'ing people who have reported this
>> problem.  If you still have the affected systems, can you guys please
>> test the patch in the following message and see whether it fixes the
>> problem?
>>
>>   http://article.gmane.org/gmane.linux.kernel/939112/raw
>>
>> Thanks a lot.  :-)
>>
>
>
Bart Hartgers - Jan. 20, 2010, 6:44 a.m.
Hi,

2010/1/20 Tejun Heo <htejun@gmail.com>:
> Hello,
>
> On 01/17/2010 08:56 AM, Bart Hartgers wrote:
>> When writing a disc on certain lite-on dvd-writers (also rebadged as
>> optiarc/LG/...) connected to a vt6420, the ATAPI CDB ends up in the
>> datastream and on the disc, causing silent corruption.  Delaying
>> between sending the CDB and starting DMA seems to prevent this.
>>
>> I do not know if there are burners that do not suffer from this, but
>> the patch should be safe for those as well.
>>
>> There are many reports of this issue, but AFAICT no solution was
>> found before. For example:
>> http://lkml.indiana.edu/hypermail/linux/kernel/0802.3/0561.html
>>
>> Signed-off-by: Bart Hartgers <bart.hartgers@gmail.com>
>
> Ah... you found solution for this?  That's great.  This is one of the
> three problems that have been lingering for years - the other two
> being pata_ali ATAPI DMA problem and sata_sil data corruption problem.
> I'll be ecstatic if this fix works.  Just one thing, I don't think
> we'll need a warning message there.  It's useful during development
> but it doesn't really provide any useful information afterwards.
>

Yes, you're right. I'll drop the printk_once and send another patch
for inclusion. However, for testing I found it very useful to make
sure that I got the right module loaded. So I figured it could be
helpful for the interpretation of success/failure reports.

Assuming that this patch works for other people as well, what is
prefered: resending both patches or just to make a new #2/2 (the
vt6420 one)?

Groeten,
Bart

> Digging up the mailing list and cc'ing people who have reported this
> problem.  If you still have the affected systems, can you guys please
> test the patch in the following message and see whether it fixes the
> problem?
>
>  http://article.gmane.org/gmane.linux.kernel/939112/raw
>
> Thanks a lot.  :-)
>
> --
> tejun
>
Tejun Heo - Jan. 20, 2010, 6:54 a.m.
Hello,

On 01/20/2010 03:33 PM, Bart Hartgers wrote:
> Well, the ata_sff_pause actually does a ndelay(400), and with today's
> processors that would be a 'slow path', right?

unlikely() is used to mark very unlikely paths not the slow ones and I
don't really think DMA_TO_DEVICE would qualify as an unlikely path.

Thanks.
Tejun Heo - Jan. 20, 2010, 6:55 a.m.
Hello,

On 01/20/2010 03:44 PM, Bart Hartgers wrote:
> Yes, you're right. I'll drop the printk_once and send another patch
> for inclusion. However, for testing I found it very useful to make
> sure that I got the right module loaded. So I figured it could be
> helpful for the interpretation of success/failure reports.

Oh yeah, for testing, having it there is a good idea.

> Assuming that this patch works for other people as well, what is
> prefered: resending both patches or just to make a new #2/2 (the
> vt6420 one)?

I think just re-doing the second patch should be enough.

Thanks.
Bart Hartgers - Jan. 20, 2010, 10:43 a.m.
Hi,

2010/1/20 Tejun Heo <htejun@gmail.com>:
> Hello,
>
> On 01/20/2010 03:33 PM, Bart Hartgers wrote:
>> Well, the ata_sff_pause actually does a ndelay(400), and with today's
>> processors that would be a 'slow path', right?
>
> unlikely() is used to mark very unlikely paths not the slow ones and I
> don't really think DMA_TO_DEVICE would qualify as an unlikely path.
>

Ok, I am convinced; I'll drop the unlikely.

Groeten,
Bart

> Thanks.
>
> --
> tejun
>
Jeff Garzik - Feb. 13, 2010, 10:47 p.m.
On 01/20/2010 01:55 AM, Tejun Heo wrote:
> Hello,
>
> On 01/20/2010 03:44 PM, Bart Hartgers wrote:
>> Yes, you're right. I'll drop the printk_once and send another patch
>> for inclusion. However, for testing I found it very useful to make
>> sure that I got the right module loaded. So I figured it could be
>> helpful for the interpretation of success/failure reports.
>
> Oh yeah, for testing, having it there is a good idea.
>
>> Assuming that this patch works for other people as well, what is
>> prefered: resending both patches or just to make a new #2/2 (the
>> vt6420 one)?
>
> I think just re-doing the second patch should be enough.

Agreed...  ping, Bart?

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bart Hartgers - Feb. 14, 2010, 11:20 a.m.
Jeff Garzik wrote:
> On 01/20/2010 01:55 AM, Tejun Heo wrote:
>> Hello,
>>
>> On 01/20/2010 03:44 PM, Bart Hartgers wrote:
>>> Yes, you're right. I'll drop the printk_once and send another patch
>>> for inclusion. However, for testing I found it very useful to make
>>> sure that I got the right module loaded. So I figured it could be
>>> helpful for the interpretation of success/failure reports.
>>
>> Oh yeah, for testing, having it there is a good idea.
>>
>>> Assuming that this patch works for other people as well, what is
>>> prefered: resending both patches or just to make a new #2/2 (the
>>> vt6420 one)?
>>
>> I think just re-doing the second patch should be enough.
>
> Agreed...  ping, Bart?
>
Hi Jeff,

I was waiting for some feedback on whether this patch actually solves 
the problem for others as well. Unfortunately, I didn't get any response 
so far, that's why I didn't resend the patch yet. But I guess it doesn't 
make sense to wait any longer, so I'll redo the patch and send it in a 
separate mail in a few minutes.

(I also tried searching for people suffering from this bug in the past 3 
months, and couldn't find any. I _did_ see some recent posts on various 
bug-lists by Tejun asking to test my patch, but again no response.)

Groeten,
Bart
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

Index: linux-2.6.33-rc4/drivers/ata/sata_via.c
===================================================================
--- linux-2.6.33-rc4.orig/drivers/ata/sata_via.c	2010-01-16 22:29:30.000000000 +0100
+++ linux-2.6.33-rc4/drivers/ata/sata_via.c	2010-01-16 22:29:38.000000000 +0100
@@ -40,6 +40,8 @@ 
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 
@@ -80,6 +82,7 @@  static int vt8251_scr_write(struct ata_l
 static void svia_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
 static void svia_noop_freeze(struct ata_port *ap);
 static int vt6420_prereset(struct ata_link *link, unsigned long deadline);
+static void vt6420_bmdma_start(struct ata_queued_cmd *qc);
 static int vt6421_pata_cable_detect(struct ata_port *ap);
 static void vt6421_set_pio_mode(struct ata_port *ap, struct ata_device *adev);
 static void vt6421_set_dma_mode(struct ata_port *ap, struct ata_device *adev);
@@ -121,6 +124,7 @@  static struct ata_port_operations vt6420
 	.inherits		= &svia_base_ops,
 	.freeze			= svia_noop_freeze,
 	.prereset		= vt6420_prereset,
+	.bmdma_start		= vt6420_bmdma_start,
 };
 
 static struct ata_port_operations vt6421_pata_ops = {
@@ -377,6 +381,19 @@  static int vt6420_prereset(struct ata_li
 	return 0;
 }
 
+static void vt6420_bmdma_start(struct ata_queued_cmd *qc)
+{
+	struct ata_port *ap = qc->ap;
+	if ((qc->tf.command == ATA_CMD_PACKET) &&
+	    unlikely(qc->scsicmd->sc_data_direction == DMA_TO_DEVICE)) {
+		/* Prevents corruption on some ATAPI burners */
+		printk_once(KERN_WARNING DRV_NAME
+			    ": fixing DMA to device for ATAPI\n");
+		ata_sff_pause(ap);
+	}
+	ata_bmdma_start(qc);
+}
+
 static int vt6421_pata_cable_detect(struct ata_port *ap)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);