NV SATA breakage: jgarzik/libata-dev#upstream etc
Hi,
The following commit in libata-dev breaks NV SATA init - I don't have a dump handy, but the problem is a NULL ptr dereference here:
libata-core.c
int ata_device_add(const struct ata_probe_ent *ent) {
...
/* register each port bound to this device */
for (i = 0; i < host->n_ports; i++) {
...
/* start port */
rc = ap->ops->port_start(ap);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^The problematic commit is fea63e38013ec628ab3f7fddc4c2148064b7910a:
"[PATCH] libata: fix non-uniform ports handling
Non-uniform ports handling got broken while updating libata to handle those in the same host. Only separate irq for the non-uniform secondary port was implemented while all other fields (host flags, transfer mode...) of the secondary port simply shared those of the first.
For ata_piix combined mode, which ATM is the only user of non-uniform ports, this causes the secondary port assume the wrong type. This can cause PATA port to use SATA ops, which results in bogus check on PCS and detection failure.
This patch adds ata_probe_ent->pinfo2 which points to optional port_info for the secondary port. For the time being, this seems to be the simplest solution. This workaround will be removed together with ata_probe_ent itself after init model is updated to allow more flexibility."
All details etc. are, as always, available on request.
00:05.0 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a2) (prog-if 85 [Master SecO PriO])
Subsystem: Micro-Star International Co., Ltd. Unknown device 7250
Flags: bus master, 66MHz, fast devsel, latency 0, IRQ 225
I/O ports at c800 [size=8]
I/O ports at c480 [size=4]
I/O ports at c400 [size=8]
I/O ports at c080 [size=4]
I/O ports at c000 [size=16]
Memory at feaf9000 (32-bit, non-prefetchable) [size=4K]Signature · 1 line
Krzysztof Halasa
Quoted 16 lines · Krzysztof Halasa
Hi,
The following commit in libata-dev breaks NV SATA init - I don't have a dump handy, but the problem is a NULL ptr dereference here:
libata-core.c
intata_device_add(const struct ata_probe_ent *ent){
.../* register each port bound to this device */ for (i = 0; i < host->n_ports; i++) { ... /* start port */ rc = ap->ops->port_start(ap); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 8 lines
The problematic commit is
fea63e38013ec628ab3f7fddc4c2148064b7910a:
"[PATCH] libata: fix non-uniform ports handlingNon-uniform ports handling got broken while updating libata to handle those in the same host. Only separate irq for the non-uniform secondary port was implemented while all other fields (host flags, transfer mode...) of the secondary port simply shared those of the first.
What's broken, and how does it affect NV sata?
That's the chipset on my main dev workstation, and there are no problems here...
Jeff
Quoted 18 lines · Jeff Garzik
Quoted 10 lines
libata-core.c
intata_device_add(const struct ata_probe_ent *ent){
.../* register each port bound to this device */ for (i = 0; i < host->n_ports; i++) { ... /* start port */ rc = ap->ops->port_start(ap); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Quoted 7 lines
The problematic commit is
fea63e38013ec628ab3f7fddc4c2148064b7910a:
"[PATCH] libata: fix non-uniform ports handling Non-uniform ports handling got broken while updating libata to handle those in the same host. Only separate irq for the non-uniform secondary port was implemented while all other fields (host flags, transfer mode...) of the secondary port simply shared those of the first.
Quoted 1 line
What's broken, and how does it affect NV sata?
NV SATA initialization fails with NULL pointer dereference in ata_device_add (= kernel panic).
Quoted 2 lines
That's the chipset on my main dev workstation, and there are no problems here...
I'm a bit surprised... I'm using x86_64 with only one SATA "controller" enabled (ports 0 and 1 only, ports 2-5 are disabled in BIOS). Only port 0 is in use. Gcc 4.1.1.
With a64f97f2c351410dfb3099c2369eacf7154b5532 (2.6.18-rc7+, "Merge branch 'tmp' into upstream", just before the commit in question) it works fine:
libata version 2.00 loaded.sata_nv 0000:00:05.0: version 2.0
ACPI: PCI Interrupt Link [LSA0] enabled at IRQ 23
GSI 16 sharing vector 0xE1 and IRQ 16
ACPI: PCI Interrupt 0000:00:05.0[A] -> Link [LSA0] -> GSI 23 (level, low) -> IRQ
225
PCI: Setting latency timer of device 0000:00:05.0 to 64
ata1: SATA max UDMA/133 cmd 0xC800 ctl 0xC482 bmdma 0xC000 irq 225
ata2: SATA max UDMA/133 cmd 0xC400 ctl 0xC082 bmdma 0xC008 irq 225 scsi0 : sata_nv
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
ata1.00: ATA-7, max UDMA/133, 488397168 sectors: LBA48 NCQ (depth 0/32) ata1.00: ata1: dev 0 multi count 16
ata1.00: configured for UDMA/133
scsi1 : sata_nv
ata2: SATA link down (SStatus 0 SControl 300)
ATA: abnormal status 0x7F on port 0xC407
Vendor: ATA Model: ST3250823AS Rev: 3.03
Type: Direct-Access ANSI SCSI revision: 05
Signature · 1 line
Krzysztof Halasa
Ok, rebooted it.
After that commit (fea63e38013ec628ab3f7fddc4c2148064b7910a), it does:
ata1: SATA max UDMA/133 cmd 0xC800 ctl 0xC482 bmdma 0xC000 irq 225
GPF: 0 [1]
RIP: ata_device_add+0x19a/0x530
RAX: 48000002d0b38d48
R14: ffff81003f7cc7e0
Call trace: nv_init_one+0x190/0x1f0
pci_match_devicepci_device_probedriver_probe_device__driver_attach__driver_attachbus_for_each_devdriver_register__pci_register_drivernv_init
etc.
ata_device_add:
...
193: 49 8b 46 08 mov 0x8(%r14),%rax <<<< ap->ops = invalid 197: 4c 89 f7 mov %r14,%rdi <<<< ap 19a: ff 90 f8 00 00 00 callq *0xf8(%rax) <<<< ap->ops->port_start
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
And it GPFs here (ap->ops->port_start(ap)).
Actually it seems the ap->ops = RAX is invalid but not exactly a NULL ptr.
Now, sata_nv.c: nv_init_one():
struct ata_port_info *ppi;
ppi = &nv_port_info[ent->driver_data];
probe_ent = ata_pci_init_native_mode(pdev, &ppi,
ATA_PORT_PRIMARY | ATA_ PORT_SECONDARY);while
/**
* ata_pci_init_native_mode - Initialize native-mode driver
* @pdev: pci device to be initialized
* @port: array[2] of pointers to port info structures.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Not sure... should the nv_init_one() just read:
struct ata_port_info *ppi[2];
ppi[0] = ppi[1] = &nv_port_info[ent->driver_data];
probe_ent = ata_pci_init_native_mode(pdev, ppi,
ATA_PORT_PRIMARY | ATA_ PORT_SECONDARY);or should
ppi[1] = NULL?
Signature · 1 line
Krzysztof Halasa
Quoted 1 line · Krzysztof Halasa
ppi[0] = ppi[1] = &nv_port_info[ent->driver_data];
That's probably the best solution.
Jeff
Quoted 4 lines · Jeff Garzik
Quoted 1 line · Krzysztof Halasa
ppi[0] = ppi[1] = &nv_port_info[ent->driver_data];That's probably the best solution.
It fixes the SATA NV problem (I'm not attaching the patch as you already posted similar one).
Signature · 1 line
Krzysztof Halasa
Quoted 8 lines · Krzysztof Halasa
Quoted 3 lines · Jeff Garzik
Quoted 1 line · Krzysztof Halasa
ppi[0] = ppi[1] = &nv_port_info[ent->driver_data];That's probably the best solution.
It fixes the SATA NV problem (I'm not attaching the patch as you already posted similar one).
The argument to ata_pci_init_native_mode() was also updated.
Just for sanity's sake, could you test linux-2.5.git + my patch?
Jeff
Quoted 3 lines · Jeff Garzik
The argument to
ata_pci_init_native_mode()was also updated.Just for sanity's sake, could you test linux-2.5.git + my patch?
I've already tested nearly identical patch against your latest tree (currently equal to Linus' - a6d967a485c67ec8a1276261f39d81ace6a3e308) and it works fine, so Acked-By: Krzysztof Halasa <[email protected]>
Signature · 1 line
Krzysztof Halasa
A message that is not in the archive (sent off-list or not yet received): [email protected]
Does the attached patch fix the SATA oops?
Jeff
drivers/ata/sata_nv.c +3 -3
@@ -484,7 +484,7 @@ static void nv_error_handler(struct ata_static int nv_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) {static int printed_version =0 ; -struct ata_port_info *ppi; +struct ata_port_info *ppi[2 ];struct ata_probe_ent *probe_ent;int pci_dev_busy =0 ;int rc;
@@ -520,8 +520,8 @@ static int nv_init_one (struct pci_dev * rc = -ENOMEM ; - ppi = &nv_port_info[ent->driver_data]; - probe_ent =ata_pci_init_native_mode (pdev, &ppi,ATA_PORT_PRIMARY |ATA_PORT_SECONDARY ); + ppi[0 ] = ppi[1 ] = &nv_port_info[ent->driver_data]; + probe_ent =ata_pci_init_native_mode (pdev, ppi,ATA_PORT_PRIMARY |ATA_PORT_SECONDARY );if (!probe_ent) goto err_out_regions;
drivers/ata/sata_sis.c +3 -3
@@ -240,7 +240,7 @@ static int sis_init_one (struct pci_devstruct ata_probe_ent *probe_ent =NULL ;int rc;u32 genctl; -struct ata_port_info *ppi; +struct ata_port_info *ppi[2 ];int pci_dev_busy =0 ;u8 pmr;u8 port2_start;
@@ -265,8 +265,8 @@ static int sis_init_one (struct pci_devif (rc) goto err_out_regions; - ppi = &sis_port_info; - probe_ent =ata_pci_init_native_mode (pdev, &ppi,ATA_PORT_PRIMARY |ATA_PORT_SECONDARY ); + ppi[0 ] = ppi[1 ] = &sis_port_info; + probe_ent =ata_pci_init_native_mode (pdev, ppi,ATA_PORT_PRIMARY |ATA_PORT_SECONDARY );if (!probe_ent) { rc = -ENOMEM ; goto err_out_regions;
drivers/ata/sata_uli.c +3 -3
@@ -185,7 +185,7 @@ static int uli_init_one (struct pci_dev {static int printed_version;struct ata_probe_ent *probe_ent; -struct ata_port_info *ppi; +struct ata_port_info *ppi[2 ];int rc;unsigned int board_idx = (unsigned int ) ent->driver_data;int pci_dev_busy =0 ;
@@ -211,8 +211,8 @@ static int uli_init_one (struct pci_devif (rc) goto err_out_regions; - ppi = &uli_port_info; - probe_ent =ata_pci_init_native_mode (pdev, &ppi,ATA_PORT_PRIMARY |ATA_PORT_SECONDARY ); + ppi[0 ] = ppi[1 ] = &uli_port_info; + probe_ent =ata_pci_init_native_mode (pdev, ppi,ATA_PORT_PRIMARY |ATA_PORT_SECONDARY );if (!probe_ent) { rc = -ENOMEM ; goto err_out_regions;
drivers/ata/sata_via.c +4 -3
@@ -318,9 +318,10 @@ static void vt6421_init_addrs(struct atastatic struct ata_probe_ent *vt6420_init_probe_ent (struct pci_dev *pdev) {struct ata_probe_ent *probe_ent; -struct ata_port_info *ppi = &vt6420_port_info; - - probe_ent =ata_pci_init_native_mode (pdev, &ppi,ATA_PORT_PRIMARY |ATA_PORT_SECONDARY ); +struct ata_port_info *ppi[2 ]; + + ppi[0 ] = ppi[1 ] = &vt6420_port_info; + probe_ent =ata_pci_init_native_mode (pdev, ppi,ATA_PORT_PRIMARY |ATA_PORT_SECONDARY );if (!probe_ent)return NULL ;