libata - error register patch.
It's entirely possible I'm missing something either very obvious, or very subtle, but I think the reading of the error register in libata et al is incorrect.
Current code only reads the error register when in LBA48 mode, and then stores it in tf->hob_feature. Attached patch always reads it and stores it in tf->feature.
Signature · 3 lines
[email protected] Andy Warner Voice: (612) 801-8549 Fax: (208) 575-5634
drivers/scsi/libata-core.c +2 -2
@@ -321,10 +321,10 @@ tf->lbam =inb (ioaddr->lbam_addr); tf->lbah =inb (ioaddr->lbah_addr); tf->device =inb (ioaddr->device_addr); + tf->feature =inb (ioaddr->error_addr);if (tf->flags &ATA_TFLAG_LBA48 ) {outb (tf->ctl |ATA_HOB , ioaddr->ctl_addr); - tf->hob_feature =inb (ioaddr->error_addr); tf->hob_nsect =inb (ioaddr->nsect_addr); tf->hob_lbal =inb (ioaddr->lbal_addr); tf->hob_lbam =inb (ioaddr->lbam_addr);
@@ -353,10 +353,10 @@ tf->lbam =readb ((void __iomem *)ioaddr->lbam_addr); tf->lbah =readb ((void __iomem *)ioaddr->lbah_addr); tf->device =readb ((void __iomem *)ioaddr->device_addr); + tf->feature =readb ((void __iomem *)ioaddr->error_addr);if (tf->flags &ATA_TFLAG_LBA48 ) {writeb (tf->ctl |ATA_HOB , (void __iomem *) ap->ioaddr.ctl_addr); - tf->hob_feature =readb ((void __iomem *)ioaddr->error_addr); tf->hob_nsect =readb ((void __iomem *)ioaddr->nsect_addr); tf->hob_lbal =readb ((void __iomem *)ioaddr->lbal_addr); tf->hob_lbam =readb ((void __iomem *)ioaddr->lbam_addr);
drivers/scsi/sata_svw.c +1 -1
@@ -138,9 +138,9 @@ lbam = tf->lbam =readw (ioaddr->lbam_addr); lbah = tf->lbah =readw (ioaddr->lbah_addr); tf->device =readw (ioaddr->device_addr); + tf->feature =readw (ioaddr->error_addr);if (tf->flags &ATA_TFLAG_LBA48 ) { - tf->hob_feature =readw (ioaddr->error_addr) >>8 ; tf->hob_nsect = nsect >>8 ; tf->hob_lbal = lbal >>8 ; tf->hob_lbam = lbam >>8 ;
drivers/scsi/sata_vsc.c +1 -1
@@ -139,9 +139,9 @@ lbam = tf->lbam =readw (ioaddr->lbam_addr); lbah = tf->lbah =readw (ioaddr->lbah_addr); tf->device =readw (ioaddr->device_addr); + tf->feature =readb (ioaddr->error_addr);if (tf->flags &ATA_TFLAG_LBA48 ) { - tf->hob_feature =readb (ioaddr->error_addr); tf->hob_nsect = nsect >>8 ; tf->hob_lbal = lbal >>8 ; tf->hob_lbam = lbam >>8 ;
Quoted 8 lines · Andy Warner
It's entirely possible I'm missing something either very obvious, or very subtle, but I think the reading of the error register in libata et al is incorrect.
Current code only reads the error register when in LBA48 mode, and then stores it in
tf->hob_feature. Attached patch always reads it and stores it intf->feature.
I'm still thinking about this one.
I need to check and see the behavior of this register, as we have a separate ata_chk_err() as well.
Jeff
Quoted 5 lines · Jeff Garzik
[...]
I'm still thinking about this one.I need to check and see the behavior of this register, as we have a separate
ata_chk_err()as well.
I think the existing behaviour is odd.
I can see a case for either removing any read of the error register in ata_tf_read_xxx() and relying solely on ata_chk_err() or going with my patch.
I can's see any case for leaving it as it is - I can find no code that uses tf->hob_feature after calling ata_tf_read_xxx().
Looks to me like a cut and paste error from way back that got mashed by LBA48 support.
Reads of the error register are not destructive (at least according to the specs.)
Signature · 3 lines
[email protected] Andy Warner Voice: (612) 801-8549 Fax: (208) 575-5634