Bug 10179 - pata_amd libata: Erroneous "limited to UDMA/33 due to 40-wire cable" from PX-130A
Summary: pata_amd libata: Erroneous "limited to UDMA/33 due to 40-wire cable" from PX-...
Status: CLOSED CODE_FIX
Alias: None
Product: IO/Storage
Classification: Unclassified
Component: Serial ATA (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Alan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-06 05:06 UTC by Manfred
Modified: 2008-06-18 03:28 UTC (History)
0 users

See Also:
Kernel Version: 2.6.24.3
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description Manfred 2008-03-06 05:06:23 UTC
Latest working kernel version: n.a.
Earliest failing kernel version: n.a.

Distribution: Gentoo

Hardware Environment:
- Motherboard:  ASUS M2N-SLI Deluxe
- - on-Board: nVidia nForce 570 SLI MCP
- - - Primary IDE - Master: PLEXTOR DVD-ROM PX-130A, Firmware 1.03
- - - Primary IDE - Slave : PLEXTOR DVDR   PX-760A,  Firmware 1.07

Software Environment: n.a.

Problem Description:
The DVD-ROM "detects" a 40-wire cable only;
thus the connection is reduced to UDMA33

Steps to reproduce:
boot - dmesg : 'limited to UDMA/33 due to 40-wire cable'

I.) First approach:  IDE

Kernel config:
A) device drivers -> ATA/... -> AMD and NVidia support :
-- CONFIG_BLK_DEV_AMD74XX=y

limits down to UDMA33 due to 40-wire - but works.


II.) Second approach: upgrade Firmware
from Firmware 1.01 to Firmware 1.03 : no diff. at all


III.) Third approach: change to PATA_AMD

Kernel config:
A) device drivers -> ATA/... -> AMD and NVidia support :
-- CONFIG_BLK_DEV_AMD74XX is not set
B) device drivers -> Serial ATA and Parallel ATA -> AMD/NVida PATA support :
-- CONFIG_PATA_AMD=y

still limits down to UDMA33 due to 40-wire - but works:

>>>  'limited to UDMA/33 due to 40-wire cable'  <<<

in /usr/src/linux/drivers/ata/libata-core.c :
static void ata_dev_xfermask(struct ata_device *dev)

calling
static int ata_is_40wire(struct ata_device *dev)

calling
/usr/src/linux/include/linux/ata.h :
static inline int ata_drive_40wire(const u16 *dev_id)
{ ...
        if ((dev_id[93] & 0xE000) == 0x6000)
                return 0;       /* 80 wire */
        return 1;
}

but [93] is 0x0000 - for _both_ devices !???!  
- c.f. hdparm-output below -

How the hell then does DVD-RW get it's UDMA66 ?!


- cf. below


I.)
I changed cables to different very short 80-wire ribbon cable:
no diff.

II.)
I soleyly attached DVD-RW to MASTER:
still detected as UDMA66.

III.)
I soleyly attached DVD-ROM to MASTER:
still reduced to UDMA33.

IV.)
Dirty override:
I commented the "downgrade" in ata_dev_xfermask():
/* xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); */
and added some DEBUG lines:

Still detects 
ata9.00: ___ MKN ___ : libata-core : ap->cbl == ATA_CBL_PATA80
ata9.00: ___ MKN ___ : libata-core : ata_is_40wire(dev)

but for for DVD-ROM only (!?)

it is just
ata9.01: ___ MKN ___ : libata-core : ap->cbl == ATA_CBL_PATA80
for the DVD-RW

Works perfectly in the resulting UDMA100+UDMA66 combination,
with short 80-wire ribbon cables, as well as 
even with a really long round 80-wire cable !

Test:
Copy a whole big DVD-ROM to SATA-disk && diff both trees: +identical+

### ### ### ### ### ### 
# 
# Some more information:
# 
### ### ### ### ### ### 

$ dmesg
...
pata_amd 0000:00:04.0: version 0.3.10
PCI: Setting latency timer of device 0000:00:04.0 to 64
scsi8 : pata_amd
scsi9 : pata_amd
ata9: PATA max UDMA/133 cmd 0x1f0 ctl 0x3f6 bmdma 0xf000 irq 14
ata10: PATA max UDMA/133 cmd 0x170 ctl 0x376 bmdma 0xf008 irq 15
ata9.00: ATAPI: PLEXTOR DVD-ROM PX-130A, 1.03, max UDMA/100
ata9.01: ATAPI: PLEXTOR DVDR   PX-760A, 1.07, max UDMA/66
ata9.00: ___ MKN ___ : libata-core : ap->cbl == ATA_CBL_PATA80
ata9.00: ___ MKN ___ : libata-core : ata_is_40wire(dev)
ata9.00: ___ MKN ___ : libata-core : dirty override _wrong_ 'limited to UDMA/33 due to 40-wire cable' 
ata9.01: ___ MKN ___ : libata-core : ap->cbl == ATA_CBL_PATA80
ata9.00: configured for UDMA/100
ata9.01: configured for UDMA/66
ata10: port disabled. ignoring.
scsi 8:0:0:0: CD-ROM            PLEXTOR  DVD-ROM PX-130A  1.03 PQ: 0 ANSI: 5
sr0: scsi3-mmc drive: 0x/50x cd/rw xa/form2 cdda tray
Uniform CD-ROM driver Revision: 3.20
sr 8:0:0:0: Attached scsi CD-ROM sr0
sr 8:0:0:0: Attached scsi generic sg4 type 5
scsi 8:0:1:0: CD-ROM            PLEXTOR  DVDR   PX-760A   1.07 PQ: 0 ANSI: 5
sr1: scsi3-mmc drive: 40x/40x writer cd/rw xa/form2 cdda tray
sr 8:0:1:0: Attached scsi CD-ROM sr1
sr 8:0:1:0: Attached scsi generic sg5 type 5
...


# hdparm -I /dev/sr0

/dev/sr0:

ATAPI CD-ROM, with removable media
        Model Number:       PLEXTOR DVD-ROM PX-130A
        Serial Number:
        Firmware Revision:  1.03
Standards:
        Likely used CD-ROM ATAPI-1
Configuration:
        DRQ response: 50us.
        Packet size: 12 bytes
Capabilities:
        LBA, IORDY(can be disabled)
        Buffer size: 64.0kB
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    Power Management feature set
           *    PACKET command feature set
           *    DEVICE_RESET command


# hdparm -I /dev/sr1

/dev/sr1:

ATAPI CD-ROM, with removable media
        Model Number:       PLEXTOR DVDR   PX-760A
        Serial Number:      245097
        Firmware Revision:  1.07
Standards:
        Likely used CD-ROM ATAPI-1
Configuration:
        DRQ response: 50us.
        Packet size: 12 bytes
Capabilities:
        LBA, IORDY(can be disabled)
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 *udma4
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=120ns  IORDY flow control=120ns
HW reset results:
        CBLID- above Vih
        Device num = 1 determined by the jumper


# hdparm --Istdout /dev/sr0

/dev/sr0:
85c0 0000 0000 0000 0000 0000 0000 0000
0000 0000 2020 2020 2020 2020 2020 2020
2020 2020 2020 2020 3453 0080 0000 312e
3033 2020 2020 504c 4558 544f 5220 4456
442d 524f 4d20 5058 2d31 3330 4120 2020
2020 2020 2020 2020 2020 2020 2020 0000
0000 0f00 0000 0200 0200 0006 0000 0000
0000 0000 0000 0000 0000 0000 0000 0007
0003 0078 0078 0078 0078 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 <---
0000 0000 0218 4000 4000 0218 0000 4000
203f 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000


# hdparm --Istdout /dev/sr1

/dev/sr1:
85c0 0000 0000 0000 0000 0000 0000 0000
0000 0000 2020 2020 2020 2020 2020 2020
2020 3234 3530 3937 0000 0000 0000 312e
3037 2020 2020 504c 4558 544f 5220 4456
4452 2020 2050 582d 3736 3041 2020 2020
2020 2020 2020 2020 2020 2020 2020 0000
0000 0f00 0000 0400 0200 0006 0000 0000
0000 0000 0000 0000 0000 0000 0000 0007
0003 0078 0078 0078 0078 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 <---
0078 0000 0000 0000 0000 0000 0000 0000
101f 0000 0000 0000 0000 6b00 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000

$ emerge --info
Portage 2.1.4.4 (default-linux/amd64/2007.0/desktop, gcc-4.2.3, glibc-2.6.1-r0, 2.6.24-gentoo-r3 x86_64)
=================================================================
System uname: 2.6.24-gentoo-r3 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5200+
Timestamp of tree: Thu, 06 Mar 2008 04:16:01 +0000
ccache version 2.4 [disabled]
app-shells/bash:     3.2_p17-r1
dev-java/java-config: 1.3.7, 2.1.4
dev-lang/python:     2.4.4-r9
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r1
sys-devel/automake:  1.4_p6, 1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.24
ACCEPT_KEYWORDS="amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -O2 -pipe -mno-tls-direct-seg-refs "
CHOST="x86_64-pc-linux-gnu"
...
CXXFLAGS="-march=athlon64 -O2 -pipe -mno-tls-direct-seg-refs "
...
Comment 1 Manfred 2008-03-06 05:23:02 UTC
Sorry, but the hints "<---" alonside hdparm --Istdout 
slipped - in both cases - ;

please, look for word [93] two lines below

(still = 0x0000).
Comment 2 Andrew Morton 2008-03-06 10:44:20 UTC
We don't seem to have a bugzilla category for PATA..
Comment 3 Manfred 2008-03-06 21:09:47 UTC
P.S.:

I had reported the corresponding IDE contoller output at

  http://bugzilla.kernel.org/show_bug.cgi?id=9048#c22

It is fired in drivers/ide/ide-dma.c
by ide_find_dma_mode()
calling ide_get_mode_mask(),
calling eighty_ninty_three() in drivers/ide/ide-iops.c.


Notabene:

A)
Probably this PX-130A could be a candidate for ivb_list[]
in /usr/src/linux/drivers/ide/ide-iops.c,
thus skipping word 93 validity check ?
I could not find a corresponding construction 
in /usr/src/linux/drivers/ata/pata_amd.c yet.

B)
There was a tricky issue in
/usr/src/linux/drivers/ide/ide-probe.c : probe_hwif()
about necessarily testing the SLAVE drive first,
before testing the MASTER drive.
I could not find a corresponding construction 
in /usr/src/linux/drivers/ata/pata_amd.c yet.

--- cite ---

$ dmesg :

Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
NFORCE-MCP55: IDE controller (0x10de:0x036e rev 0xa1) at  PCI slot 0000:00:04.0
NFORCE-MCP55: not 100% native mode: will probe irqs later
NFORCE-MCP55: BIOS didn't set cable bits correctly. Enabling workaround.
NFORCE-MCP55: 0000:00:04.0 (rev a1) UDMA133 controller
    ide0: BM-DMA at 0xf000-0xf007, BIOS settings: hda:DMA, hdb:DMA
NFORCE-MCP55: IDE port disabled
Probing IDE interface ide0...
hdb: PLEXTOR DVDR PX-760A, ATAPI CD/DVD-ROM drive
hda: PLEXTOR DVD-ROM PX-130A, ATAPI CD/DVD-ROM drive
hda: host max PIO5 wanted PIO255(auto-tune) selected PIO4
hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33 <<<
hda: UDMA/33 mode selected
hdb: host max PIO5 wanted PIO255(auto-tune) selected PIO4
hdb: UDMA/66 mode selected
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14

...

# lspci
00:01.0 ISA bridge: nVidia Corporation MCP55 LPC Bridge (rev a2)
00:04.0 IDE interface: nVidia Corporation MCP55 IDE (rev a1)

--- /cite ---
Comment 4 Manfred 2008-03-06 21:19:38 UTC
Proposal:

Kernel config:

A) device drivers -> ATA/... -> AMD and NVidia support :
-- CONFIG_BLK_DEV_AMD74XX

B) device drivers -> Serial ATA and Parallel ATA -> AMD/NVida PATA support :
-- CONFIG_PATA_AMD

Perhaps it could help some people if there were at least a hint in the HELP texts to use these CONFIG options mutually exclusive.

In the beginning of my move from IDE to PATA_AMD I was puzzled why the driver didn't take over responsibility; but clearly, if both are compiled, "first come, first serve" ;)
Comment 5 Manfred 2008-03-06 21:34:20 UTC
Another small observation:

Difference in the output of hdparm -i:

For the PLEXTOR DVDR   PX-760A,
it ends with the line
  "Drive conforms to: Unspecified:  ATA/ATAPI-3,4,5,6"

For the PLEXTOR DVD-ROM PX-130A,
the corresponding line is missing.
Comment 6 Manfred 2008-03-07 04:02:58 UTC
P.S.:

My changes in libata-core.c 
to test "UDMA100 / 80-wire cable"
instead of "UDMA33 / 40-wire cable":

  if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA))
  {
    /* UDMA/44 or higher would be available */

    if (ap->cbl == ATA_CBL_PATA80) ata_dev_printk(dev, KERN_WARNING,
                "___ MKN ___ : libata-core : ap->cbl == ATA_CBL_PATA80\n");
    if (ata_is_40wire(dev)) ata_dev_printk(dev, KERN_WARNING,
                "___ MKN ___ : libata-core : ata_is_40wire(dev)\n");

    if ((ap->cbl == ATA_CBL_PATA40) ||
    (ata_is_40wire(dev) &&
    (ap->cbl == ATA_CBL_PATA_UNK ||
     ap->cbl == ATA_CBL_PATA80))) {
        /* ata_dev_printk(dev, KERN_WARNING,                    */
        /*       "limited to UDMA/33 due to 40-wire cable\n");  */
           ata_dev_printk(dev, KERN_WARNING,
                "___ MKN ___ : libata-core : dirty override _wrong_ 'limited to UDMA/33 due to 40-wire cable' \n");
        /* xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);              */
    }
  }
Comment 7 Alan 2008-06-09 08:38:43 UTC
Word93 = 0 basically means SATA ie  - no cable rules.

The cable code has been reworked since then so please test 2.6.26 when it comes out
Comment 8 Tejun Heo 2008-06-09 19:13:22 UTC
2.6.25 should have this fixed w/ the new BIOS based mode filtering.  Can you please test it?
Comment 9 Manfred 2008-06-18 03:28:03 UTC
(In reply to comment #8)
> 2.6.25 should have this fixed w/ the new BIOS based mode filtering.
> Can you please test it?

Hi, Tejun,
yes, sure, it's my pleasure! Sorry for not responding immediately, but I had to finish a tight schedule project on that production machine first and could not risk a kernel change. Well, today I had a chance to upgrade to 2.6.25.7.

Result:
-> The Master PLEXTOR DVD-ROM PX-130A (capable up to udma5) gets UDMA/100,
-> the Slave PLEXTOR DVDR PX-760A (capable up to udma4) gets UDMA/66.

! Congratulations !

Detailed output lines from /var/log/messages are attached below.

As far as I am concerned, I'd feel happy to close this bug :)

Kind regards
Manfred


# - - - snip - - - #

Jun 18 13:09:14 mammut Uniform Multi-Platform E-IDE driver
Jun 18 13:09:14 mammut ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
Jun 18 13:09:14 mammut st: Version 20080221, fixed bufsize 32768, s/g segs 256
Jun 18 13:09:14 mammut Driver 'st' needs updating - please use bus_type methods
Jun 18 13:09:14 mammut Driver 'sd' needs updating - please use bus_type methods
Jun 18 13:09:14 mammut Driver 'sr' needs updating - please use bus_type methods
...
... . . . sata_amd . . . 
...
Jun 18 13:09:14 mammut pata_amd 0000:00:04.0: version 0.3.10
Jun 18 13:09:14 mammut PCI: Setting latency timer of device 0000:00:04.0 to 64
Jun 18 13:09:14 mammut scsi6 : pata_amd
Jun 18 13:09:14 mammut scsi7 : pata_amd
Jun 18 13:09:14 mammut ata7: PATA max UDMA/133 cmd 0x1f0 ctl 0x3f6 bmdma 0xf000 irq 14
Jun 18 13:09:14 mammut ata8: PATA max UDMA/133 cmd 0x170 ctl 0x376 bmdma 0xf008 irq 15
Jun 18 13:09:14 mammut ata7.00: ATAPI: PLEXTOR DVD-ROM PX-130A, 1.03, max UDMA/100
Jun 18 13:09:14 mammut ata7.01: ATAPI: PLEXTOR DVDR   PX-760A, 1.07, max UDMA/66
Jun 18 13:09:14 mammut ata7: nv_mode_filter: 0x3f39f&0x3f01f->0x3f01f, BIOS=0x3f000 (0xc6c50000) ACPI=0x3f01f (20:30:0x1f)
Jun 18 13:09:14 mammut ata7: nv_mode_filter: 0x1f39f&0x1f01f->0x1f01f, BIOS=0x1f000 (0xc6c50000) ACPI=0x1f01f (20:30:0x1f)
Jun 18 13:09:14 mammut ata7.00: configured for UDMA/100
Jun 18 13:09:14 mammut ata7.01: configured for UDMA/66
Jun 18 13:09:14 mammut ata8: port disabled. ignoring.
Jun 18 13:09:14 mammut scsi 6:0:0:0: CD-ROM            PLEXTOR  DVD-ROM PX-130A  1.03 PQ: 0 ANSI: 5
Jun 18 13:09:14 mammut sr0: scsi3-mmc drive: 0x/50x cd/rw xa/form2 cdda tray
Jun 18 13:09:14 mammut Uniform CD-ROM driver Revision: 3.20
Jun 18 13:09:14 mammut sr 6:0:0:0: Attached scsi CD-ROM sr0
Jun 18 13:09:14 mammut sr 6:0:0:0: Attached scsi generic sg4 type 5
Jun 18 13:09:14 mammut scsi 6:0:1:0: CD-ROM            PLEXTOR  DVDR   PX-760A   1.07 PQ: 0 ANSI: 5
Jun 18 13:09:14 mammut sr1: scsi3-mmc drive: 40x/40x writer cd/rw xa/form2 cdda tray
Jun 18 13:09:14 mammut sr 6:0:1:0: Attached scsi CD-ROM sr1
Jun 18 13:09:14 mammut sr 6:0:1:0: Attached scsi generic sg5 type 5

Note You need to log in before you can comment on or make changes to this bug.