sata_via: bugfixes for vt6420 and vt6421
cover sata_via: bugfixes for vt6420 and vt6421
Dear all,
The following patches fix two bugs I encountered in the sata_via driver.
- DMA/PIO timings for the pata slave drive on a vt6421 were not handled correctly.
- ATAPI DMA corruption on a vt6420. At least for some burners, the vt6420 needs a small delay between sending the CDB and starting DMA to prevent silent data corruption. I found this solution by experimentation and while it works great for me, it might not work for everyone. Reports of success or failure are appreciated.
Some more background is included in the individual patches.
Groeten,
Bart
PATCH 1/2 sata_via: Correctly setup PIO/DMA for pata slave on vt6421.
Before only the timings for master were set. Datasheet can be found
here: ftp://ftp.vtbridge.org/Docs/Storage/DS_VT6421A_100_CCPL.PDF Surprisingly, a slave drive works without this patch. According to the datasheet, the controller by default derives the DMA mode from the Set Features command issued to a drive. Not sure about the PIO timings, though. The real problem is that the timings for the master effectively are the ones tuned for the slave. If these support different UDMA-settings, there is trouble, especially when the slave supports a higher UDMA than the master.
Anyhow, using the same mechanism for both master and slave seems like a good idea.
---
drivers/ata/sata_via.c +5 -3
@@ -44,7 +44,7 @@#include <linux/libata.h> #define DRV_NAME "sata_via" -#define DRV_VERSION "2.4" +#define DRV_VERSION "2.5"/* * vt8251 is different from other sata controllers of VIA. It has two
@@ -392,14 +392,16 @@ static void vt6421_set_pio_mode(struct a {struct pci_dev *pdev =to_pci_dev (ap->host->dev);static const u8 pio_bits[] = {0xA8 ,0x65 ,0x65 ,0x31 ,0x20 }; -pci_write_config_byte (pdev,PATA_PIO_TIMING , pio_bits[adev->pio_mode -XFER_PIO_0 ]); +pci_write_config_byte (pdev,PATA_PIO_TIMING - adev->devno, + pio_bits[adev->pio_mode -XFER_PIO_0 ]); }static void vt6421_set_dma_mode (struct ata_port *ap,struct ata_device *adev) {struct pci_dev *pdev =to_pci_dev (ap->host->dev);static const u8 udma_bits[] = {0xEE ,0xE8 ,0xE6 ,0xE4 ,0xE2 ,0xE1 ,0xE0 ,0xE0 }; -pci_write_config_byte (pdev,PATA_UDMA_TIMING , udma_bits[adev->dma_mode -XFER_UDMA_0 ]); +pci_write_config_byte (pdev,PATA_UDMA_TIMING - adev->devno, + udma_bits[adev->dma_mode -XFER_UDMA_0 ]); }static const unsigned int svia_bar_sizes[] = {
Re: [patch 1/2] sata_via: Correctly setup PIO/DMA for pata slave on vt6421.
Quoted 10 lines · Bart Hartgers
Before only the timings for master were set. Datasheet can be found
here: ftp://ftp.vtbridge.org/Docs/Storage/DS_VT6421A_100_CCPL.PDF Surprisingly, a slave drive works without this patch. According to the datasheet, the controller by default derives the DMA mode from the Set Features command issued to a drive. Not sure about the PIO timings, though. The real problem is that the timings for the master effectively are the ones tuned for the slave. If these support different UDMA-settings, there is trouble, especially when the slave supports a higher UDMA than the master.
Quoted 4 lines
Anyhow, using the same mechanism for both master and slave seems like a good idea.
Signed-off-by Bart Hartgers <[email protected]>
Thanks.
Signature · 1 line
tejun
Jeff Garzik
AppliedRe: [patch 1/2] sata_via: Correctly setup PIO/DMA for pata slave on vt6421.
In reply to Bart HartgersQuoted 10 lines · Bart Hartgers
Before only the timings for master were set. Datasheet can be found
here: ftp://ftp.vtbridge.org/Docs/Storage/DS_VT6421A_100_CCPL.PDF Surprisingly, a slave drive works without this patch. According to the datasheet, the controller by default derives the DMA mode from the Set Features command issued to a drive. Not sure about the PIO timings, though. The real problem is that the timings for the master effectively are the ones tuned for the slave. If these support different UDMA-settings, there is trouble, especially when the slave supports a higher UDMA than the master.
Quoted 4 lines
Anyhow, using the same mechanism for both master and slave seems like a good idea.
Signed-off-by Bart Hartgers<[email protected]>
applied
PATCH 2/2 sata_via: Delay on vt6420 when starting ATAPI DMA write
In reply to Bart HartgersWhen 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
---
drivers/ata/sata_via.c +17 -0
@@ -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_lstatic 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_lireturn 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);
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
Hello,
Quoted 5 lines · Bart Hartgers
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.
Quoted 8 lines
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.htmlSigned-off-by Bart Hartgers <[email protected]>
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. :-)
Signature · 1 line
tejun
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
Quoted 15 lines · Tejun Heo
Hello,
Quoted 12 lines · Bart Hartgers
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
Quoted 8 lines
Quoted 1 line
Signed-off-by Bart Hartgers<[email protected]>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_aliATAPI DMA problem andsata_sildata 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.
Quoted 10 lines
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/rawThanks a lot. :-)
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
Hi,
2010/1/20 Robert Hancock <[email protected]>:
Quoted 27 lines · Tejun Heo
Quoted 17 lines
Hello,
Quoted 13 lines · Bart Hartgers
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.htmlQuoted 8 lines
Quoted 1 line
Signed-off-by Bart Hartgers<[email protected]>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_aliATAPI DMA problem andsata_sildata 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.
Quoted 5 lines
Another tiny nitpick about the patch, the
unlikely()around theDMA_TO_DEVICEcheck 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
Quoted 12 lines
Quoted 10 lines
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. :-)
Signature · 1 line
Bart Hartgers - New e-mail: [email protected]
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
Hello,
Quoted 2 lines · Bart Hartgers
Well, the
ata_sff_pauseactually 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.
Signature · 1 line
tejun
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
Hi,
2010/1/20 Tejun Heo <[email protected]>:
Quoted 9 lines
Hello,
Quoted 2 lines · Bart Hartgers
Well, the
ata_sff_pauseactually 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 thinkDMA_TO_DEVICEwould qualify as an unlikely path.
Ok, I am convinced; I'll drop the unlikely.
Groeten,
Bart
Quoted 5 lines
Thanks.
--
tejun
Signature · 1 line
Bart Hartgers - New e-mail: [email protected]
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
In reply to Tejun HeoHi,
2010/1/20 Tejun Heo <[email protected]>:
Quoted 15 lines
Hello,
Quoted 12 lines · Bart Hartgers
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
Quoted 9 lines
Quoted 1 line
Signed-off-by Bart Hartgers <[email protected]>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_aliATAPI DMA problem andsata_sildata 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
Quoted 12 lines
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
Signature · 1 line
Bart Hartgers - New e-mail: [email protected]
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
Hello,
Quoted 4 lines · Bart Hartgers
Yes, you're right. I'll drop the
printk_onceand 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.
Quoted 3 lines
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.
Signature · 1 line
tejun
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
Quoted 8 lines · Tejun Heo
Hello,
Quoted 4 lines · Bart Hartgers
Yes, you're right. I'll drop the
printk_onceand 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.
Quoted 7 lines
Oh yeah, for testing, having it there is a good idea.
Quoted 3 lines
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?
Re: [patch 2/2] sata_via: Delay on vt6420 when starting ATAPI DMA write
Quoted 11 lines · Jeff Garzik
Quoted 10 lines · Tejun Heo
Hello,
Quoted 4 lines · Bart Hartgers
Yes, you're right. I'll drop the
printk_onceand 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.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
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