Skip to contentSkip to conversation

libata ate one PATA channel

2.6.18-rc2-mm1 J.A. Magallón 5 participants 14 messages Jul 28, 2006 – Aug 1, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi...

I've been out for more than a week. Just went to try -rc2-mm1 and it ate one ide channel...

This was -rc1-mm2:
libata version 2.00 loaded.
ata_piix 0000:00:1f.1: version 2.00ac6
ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.1 to 64
ata1: PATA max UDMA/100 cmd 0x1F0 ctl 0x3F6 bmdma 0xF000 irq 14 scsi0 : ata_piix
ata1.00: ATAPI, max UDMA/33
ata1.01: ATAPI, max MWDMA0, CDB intr
ata1.00: configured for PIO3
ata1.01: configured for PIO3

  Vendor: HL-DT-ST  Model: DVDRAM GSA-4120B  Rev: A111
  Type:   CD-ROM                             ANSI SCSI revision: 05
  Vendor: IOMEGA    Model: ZIP 250           Rev: 51.G
  Type:   Direct-Access                      ANSI SCSI revision: 05

ata2: PATA max UDMA/100 cmd 0x170 ctl 0x376 bmdma 0xF008 irq 15 scsi1 : ata_piix
ata2.00: ATA-6, max UDMA/100, 234441648 sectors: LBA48 ata2.00: ata2: dev 0 multi count 16
ata2.01: ATAPI, max UDMA/33
ata2.00: configured for UDMA/33
ata2.01: configured for UDMA/33

  Vendor: ATA       Model: ST3120022A        Rev: 3.06
  Type:   Direct-Access                      ANSI SCSI revision: 05
  Vendor: TOSHIBA   Model: DVD-ROM SD-M1712  Rev: 1004
  Type:   CD-ROM                             ANSI SCSI revision: 05

ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ]
ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.2 to 64
ata3: SATA max UDMA/133 cmd 0xC000 ctl 0xC402 bmdma 0xD000 irq 16
ata4: SATA max UDMA/133 cmd 0xC800 ctl 0xCC02 bmdma 0xD008 irq 16

This is -rc2-mm1, a PATA channel is missing...

libata version 2.00 loaded.
ata_piix 0000:00:1f.1: version 2.00ac6
ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.1 to 64
ata1: PATA max UDMA/100 cmd 0x1F0 ctl 0x3F6 bmdma 0xF000 irq 14 scsi0 : ata_piix
ata1.00: ATAPI, max UDMA/33
ata1.01: ATAPI, max MWDMA0, CDB intr
ata1.00: configured for UDMA/33
ata1.01: configured for PIO3

  Vendor: HL-DT-ST  Model: DVDRAM GSA-4120B  Rev: A111 
  Type:   CD-ROM                             ANSI SCSI revision: 05
  Vendor: IOMEGA    Model: ZIP 250           Rev: 51.G 
  Type:   Direct-Access                      ANSI SCSI revision: 05

ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ]
ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.2 to 64
ata2: SATA max UDMA/133 cmd 0xC000 ctl 0xC402 bmdma 0xD000 irq 16
ata3: SATA max UDMA/133 cmd 0xC800 ctl 0xCC02 bmdma 0xD008 irq 16

Any idea ?
Any more info needed ?
TIA

--
J.A. Magallon <jamagallon()ono!com> \ Software is like sex:
\ It's better when it's free
Mandriva Linux release 2007.0 (Cooker) for i586
Linux 2.6.17-jam04 (gcc 4.1.1 20060518 (prerelease)) #2 SMP PREEMPT Mon

#1 lore raw
Quoted 53 lines · J.A. Magallón

Hi...

I've been out for more than a week. Just went to try -rc2-mm1 and it ate one ide channel...

This was -rc1-mm2:
libata version 2.00 loaded.
ata_piix 0000:00:1f.1: version 2.00ac6
ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.1 to 64
ata1: PATA max UDMA/100 cmd 0x1F0 ctl 0x3F6 bmdma 0xF000 irq 14 scsi0 : ata_piix
ata1.00: ATAPI, max UDMA/33
ata1.01: ATAPI, max MWDMA0, CDB intr
ata1.00: configured for PIO3
ata1.01: configured for PIO3

  Vendor: HL-DT-ST  Model: DVDRAM GSA-4120B  Rev: A111
  Type:   CD-ROM                             ANSI SCSI revision: 05
  Vendor: IOMEGA    Model: ZIP 250           Rev: 51.G
  Type:   Direct-Access                      ANSI SCSI revision: 05

ata2: PATA max UDMA/100 cmd 0x170 ctl 0x376 bmdma 0xF008 irq 15 scsi1 : ata_piix
ata2.00: ATA-6, max UDMA/100, 234441648 sectors: LBA48 ata2.00: ata2: dev 0 multi count 16
ata2.01: ATAPI, max UDMA/33
ata2.00: configured for UDMA/33
ata2.01: configured for UDMA/33

  Vendor: ATA       Model: ST3120022A        Rev: 3.06
  Type:   Direct-Access                      ANSI SCSI revision: 05
  Vendor: TOSHIBA   Model: DVD-ROM SD-M1712  Rev: 1004
  Type:   CD-ROM                             ANSI SCSI revision: 05

ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ]
ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.2 to 64
ata3: SATA max UDMA/133 cmd 0xC000 ctl 0xC402 bmdma 0xD000 irq 16
ata4: SATA max UDMA/133 cmd 0xC800 ctl 0xCC02 bmdma 0xD008 irq 16

This is -rc2-mm1, a PATA channel is missing...

libata version 2.00 loaded.
ata_piix 0000:00:1f.1: version 2.00ac6
ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.1 to 64
ata1: PATA max UDMA/100 cmd 0x1F0 ctl 0x3F6 bmdma 0xF000 irq 14 scsi0 : ata_piix
ata1.00: ATAPI, max UDMA/33 ata1.01: ATAPI, max MWDMA0, CDB intr ata1.00: configured for UDMA/33
ata1.01: configured for PIO3

  Vendor: HL-DT-ST  Model: DVDRAM GSA-4120B  Rev: A111 
  Type:   CD-ROM                             ANSI SCSI revision: 05
  Vendor: IOMEGA    Model: ZIP 250           Rev: 51.G 
  Type:   Direct-Access                      ANSI SCSI revision: 05
Quoted 7 lines

ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ] ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.2 to 64
ata2: SATA max UDMA/133 cmd 0xC000 ctl 0xC402 bmdma 0xD000 irq 16
ata3: SATA max UDMA/133 cmd 0xC800 ctl 0xCC02 bmdma 0xD008 irq 16

Any idea ?
Any more info needed ?

lspci -n please. Also, can you report what the kernel says with the attached patch applied?

Thanks.

Signature · 1 line
tejun
drivers/scsi/libata-bmdma.c +4 -0
index 9ce221f..9397f0b 100644
@@ -1070,6 +1070,10 @@ int ata_pci_init_one (struct pci_dev *pd
 		goto err_out_regions;
 	}
 
+	dev_printk(KERN_INFO, &pdev->dev,
+		   "XXX: legacy_mode=%x probe_ent=%p probe_ent2=%p\n",
+		   legacy_mode, probe_ent, probe_ent2);
+
 	pci_set_master(pdev);
 
 	/* FIXME: check ata_device_add return */
drivers/scsi/libata-core.c +8 -3
index 66feebd..9756ee6 100644
@@ -5401,8 +5401,11 @@ int ata_device_add(const struct ata_prob
 	/* alloc a container for our list of ATA ports (buses) */
 	host_set = kzalloc(sizeof(struct ata_host_set) +
 			   (ent->n_ports * sizeof(void *)), GFP_KERNEL);
-	if (!host_set)
+	if (!host_set) {
+		printk(KERN_ERR "ata_device_add() alloc failed, n_ports=%d\n",
+		       ent->n_ports);
 		return 0;
+	}
 	spin_lock_init(&host_set->lock);
 
 	host_set->dev = dev;
@@ -5419,8 +5422,10 @@ int ata_device_add(const struct ata_prob
 		unsigned long xfer_mode_mask;
 
 		ap = ata_host_add(ent, host_set, i);
-		if (!ap)
+		if (!ap) {
+			printk(KERN_ERR "ata_host_add() failed\n");
 			goto err_out;
+		}
 
 		host_set->ports[i] = ap;
 		xfer_mode_mask =(ap->udma_mask << ATA_SHIFT_UDMA) |
@@ -5537,7 +5542,7 @@ err_out:
 	}
 err_free_ret:
 	kfree(host_set);
-	VPRINTK("EXIT, returning 0\n");
+	printk(KERN_ERR "ata_device_add() ERROR, returning 0\n");
 	return 0;
 }
 
#2 lore raw
Quoted 61 lines · Tejun Heo
Quoted 60 lines · J.A. Magallón

Hi...

I've been out for more than a week. Just went to try -rc2-mm1 and it ate one ide channel...

This was -rc1-mm2:
libata version 2.00 loaded.
ata_piix 0000:00:1f.1: version 2.00ac6
ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.1 to 64
ata1: PATA max UDMA/100 cmd 0x1F0 ctl 0x3F6 bmdma 0xF000 irq 14 scsi0 : ata_piix
ata1.00: ATAPI, max UDMA/33
ata1.01: ATAPI, max MWDMA0, CDB intr
ata1.00: configured for PIO3
ata1.01: configured for PIO3

  Vendor: HL-DT-ST  Model: DVDRAM GSA-4120B  Rev: A111
  Type:   CD-ROM                             ANSI SCSI revision: 05
  Vendor: IOMEGA    Model: ZIP 250           Rev: 51.G
  Type:   Direct-Access                      ANSI SCSI revision: 05

ata2: PATA max UDMA/100 cmd 0x170 ctl 0x376 bmdma 0xF008 irq 15 scsi1 : ata_piix
ata2.00: ATA-6, max UDMA/100, 234441648 sectors: LBA48 ata2.00: ata2: dev 0 multi count 16
ata2.01: ATAPI, max UDMA/33
ata2.00: configured for UDMA/33
ata2.01: configured for UDMA/33

  Vendor: ATA       Model: ST3120022A        Rev: 3.06
  Type:   Direct-Access                      ANSI SCSI revision: 05
  Vendor: TOSHIBA   Model: DVD-ROM SD-M1712  Rev: 1004
  Type:   CD-ROM                             ANSI SCSI revision: 05

ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ]
ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.2 to 64
ata3: SATA max UDMA/133 cmd 0xC000 ctl 0xC402 bmdma 0xD000 irq 16
ata4: SATA max UDMA/133 cmd 0xC800 ctl 0xCC02 bmdma 0xD008 irq 16

This is -rc2-mm1, a PATA channel is missing...

libata version 2.00 loaded.
ata_piix 0000:00:1f.1: version 2.00ac6
ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.1 to 64
ata1: PATA max UDMA/100 cmd 0x1F0 ctl 0x3F6 bmdma 0xF000 irq 14 scsi0 : ata_piix
ata1.00: ATAPI, max UDMA/33
ata1.01: ATAPI, max MWDMA0, CDB intr
ata1.00: configured for UDMA/33
ata1.01: configured for PIO3

  Vendor: HL-DT-ST  Model: DVDRAM GSA-4120B  Rev: A111 
  Type:   CD-ROM                             ANSI SCSI revision: 05
  Vendor: IOMEGA    Model: ZIP 250           Rev: 51.G 
  Type:   Direct-Access                      ANSI SCSI revision: 05

ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ]
ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level, low) -> IRQ 16
PCI: Setting latency timer of device 0000:00:1f.2 to 64
ata2: SATA max UDMA/133 cmd 0xC000 ctl 0xC402 bmdma 0xD000 irq 16
ata3: SATA max UDMA/133 cmd 0xC800 ctl 0xCC02 bmdma 0xD008 irq 16

Quoted 4 lines
Quoted 2 lines

Any idea ?
Any more info needed ?

lspci -n please

werewolf:~> lspci
00:00.0 Host bridge: Intel Corporation 82875P/E7210 Memory Controller Hub (rev 02)
00:01.0 PCI bridge: Intel Corporation 82875P Processor to AGP Controller (rev 02)
00:03.0 PCI bridge: Intel Corporation 82875P/E7210 Processor to PCI to CSA Bridge (rev 02) 00:1d.0 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #1 (rev 02) 00:1d.1 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #2 (rev 02) 00:1d.2 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #3 (rev 02) 00:1d.3 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #4 (rev 02) 00:1d.7 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB2 EHCI Controller (rev 02) 00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev c2)
00:1f.0 ISA bridge: Intel Corporation 82801EB/ER (ICH5/ICH5R) LPC Interface Bridge (rev 02) 00:1f.1 IDE interface: Intel Corporation 82801EB/ER (ICH5/ICH5R) IDE Controller (rev 02) 00:1f.2 IDE interface: Intel Corporation 82801EB (ICH5) SATA Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801EB/ER (ICH5/ICH5R) SMBus Controller (rev 02)
00:1f.5 Multimedia audio controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller (rev 02) 01:00.0 VGA compatible controller: nVidia Corporation NV43 [GeForce 6600/GeForce 6600 GT] (rev a2) 02:01.0 Ethernet controller: Intel Corporation 82547EI Gigabit Ethernet Controller (LOM) 03:03.0 FireWire (IEEE 1394): Texas Instruments TSB43AB22/A IEEE-1394a-2000 Controller (PHY/Link) 03:04.0 RAID bus controller: Promise Technology, Inc. PDC20378 (FastTrak 378/SATA 378) (rev 02) 03:0a.0 Multimedia audio controller: Creative Labs SB Live! EMU10k1 (rev 06)
03:0a.1 Input device controller: Creative Labs SB Live! Game Port (rev 06)
03:0b.0 Ethernet controller: 3Com Corporation 3c980-C 10/100baseTX NIC [Python-T] (rev 78) 03:0c.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11) 03:0c.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11) werewolf:~> lspci -n
00:00.0 0600: 8086:2578 (rev 02)
00:01.0 0604: 8086:2579 (rev 02)
00:03.0 0604: 8086:257b (rev 02)
00:1d.0 0c03: 8086:24d2 (rev 02)
00:1d.1 0c03: 8086:24d4 (rev 02)
00:1d.2 0c03: 8086:24d7 (rev 02)
00:1d.3 0c03: 8086:24de (rev 02)
00:1d.7 0c03: 8086:24dd (rev 02)
00:1e.0 0604: 8086:244e (rev c2)
00:1f.0 0601: 8086:24d0 (rev 02)
00:1f.1 0101: 8086:24db (rev 02)
00:1f.2 0101: 8086:24d1 (rev 02)
00:1f.3 0c05: 8086:24d3 (rev 02)
00:1f.5 0401: 8086:24d5 (rev 02)
01:00.0 0300: 10de:00f1 (rev a2)
02:01.0 0200: 8086:1019
03:03.0 0c00: 104c:8023
03:04.0 0104: 105a:3373 (rev 02)
03:0a.0 0401: 1102:0002 (rev 06)
03:0a.1 0980: 1102:7002 (rev 06)
03:0b.0 0200: 10b7:9805 (rev 78)
03:0c.0 0400: 109e:036e (rev 11)
03:0c.1 0480: 109e:0878 (rev 11)

Quoted 3 lines

Also, can you report what the kernel says with the attached patch applied?

I reworked it to look like this:

    if (legacy_mode) {
        probe_ent = ata_pci_init_legacy_port(pdev, port, legacy_mode);
        dev_printk(KERN_INFO, &pdev->dev,
           "XXX: legacy_mode probe_ent=%p\n", probe_ent);
    } else {
        if (n_ports == 2)
            probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
        else
            probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY);
        dev_printk(KERN_INFO, &pdev->dev,
           "XXX: non_legacy_mode n_ports=%d probe_ent=%p\n",n_ports,probe_ent);
    }

and got:

libata version 2.00 loaded.
ata_piix 0000:00:1f.1: version 2.00ac6
ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level, low) -> IRQ 16
ata_piix 0000:00:1f.1: XXX: legacy_mode probe_ent=f7935c00 <=====================
PCI: Setting latency timer of device 0000:00:1f.1 to 64
ata1: PATA max UDMA/100 cmd 0x1F0 ctl 0x3F6 bmdma 0xF000 irq 14 scsi0 : ata_piix
ata1.00: ATAPI, max UDMA/33
ata1.01: ATAPI, max MWDMA0, CDB intr
ata1.00: configured for UDMA/33
ata1.01: configured for PIO3

  Vendor: HL-DT-ST  Model: DVDRAM GSA-4120B  Rev: A111
  Type:   CD-ROM                             ANSI SCSI revision: 05
  Vendor: IOMEGA    Model: ZIP 250           Rev: 51.G
  Type:   Direct-Access                      ANSI SCSI revision: 05

ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ]
ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level, low) -> IRQ 16
ata_piix 0000:00:1f.2: XXX: non_legacy_mode n_ports=2 probe_ent=f7935c00 <====================
PCI: Setting latency timer of device 0000:00:1f.2 to 64
ata2: SATA max UDMA/133 cmd 0xC000 ctl 0xC402 bmdma 0xD000 irq 16
ata3: SATA max UDMA/133 cmd 0xC800 ctl 0xCC02 bmdma 0xD008 irq 16
scsi1 : ata_piix
ata2.00: ATA-6, max UDMA/133, 390721968 sectors: LBA48
ata2.00: ata2: dev 0 multi count 16
ata2.00: configured for UDMA/133
scsi2 : ata_piix
ata3: SATA port has no device.
ATA: abnormal status 0x7F on port 0xC807
Vendor: ATA Model: ST3200822AS Rev: 3.01
Type: Direct-Access ANSI SCSI revision: 05
sata_promise 0000:03:04.0: version 1.04
ACPI: PCI Interrupt 0000:03:04.0[A] -> GSI 23 (level, low) -> IRQ 17 sata_promise PATA port found
ata4: SATA max UDMA/133 cmd 0xF8804200 ctl 0xF8804238 bmdma 0x0 irq 17
ata5: SATA max UDMA/133 cmd 0xF8804280 ctl 0xF88042B8 bmdma 0x0 irq 17
ata6: PATA max UDMA/133 cmd 0xF8804300 ctl 0xF8804338 bmdma 0x0 irq 17

I checked the BIOS and ICH is in 'Enhanced' mode, so both pata and both sata channels are usable for a max of 6 drives.

Any ideas ?

TIA

--
J.A. Magallon <jamagallon()ono!com> \ Software is like sex:
\ It's better when it's free
Mandriva Linux release 2007.0 (Cooker) for i586
Linux 2.6.17-jam04 (gcc 4.1.1 20060724 (prerelease) (4.1.1-3mdk)) #1 SMP PREEMPT

#3 lore raw
Quoted 6 lines · J.A. Magallón

werewolf:~> lspci
00:1f.1 IDE interface: Intel Corporation 82801EB/ER (ICH5/ICH5R) IDE Controller (rev 02) 00:1f.2 IDE interface: Intel Corporation 82801EB (ICH5) SATA Controller (rev 02) werewolf:~> lspci -n
00:1f.1 0101: 8086:24db (rev 02)
00:1f.2 0101: 8086:24d1 (rev 02)

You compiled w/ ATA_ENABLE_PATA, right?

Quoted 9 lines
Quoted 2 lines

Also, can you report what the kernel says with the attached patch applied?

I reworked it to look like this:

    if (legacy_mode) {
        probe_ent = ata_pci_init_legacy_port(pdev, port, legacy_mode);
        dev_printk(KERN_INFO, &pdev->dev,
           "XXX: legacy_mode probe_ent=%p\n", probe_ent);

This is where the problem is. Ah.. I see. Alan's rework-legacy-handling patch got into mm.

=====
rework-legacy-handling-to-remove-much-of-the-cruft.patch

From: Alan Cox <[email protected]>

Kill host_set->next
Fix simplex support
Allow per platform setting of IDE legacy bases
Turn per device tuning on so that PATA timings are fully enabled

Some of this can be tidied further later on, in particular all the legacy port gunge belongs as a PCI quirk/PCI header decode to understand the special legacy IDE rules in the PCI spec.

Longer term Jeff also wants to move the request_irq/free_irq out of core which will make this even cleaner.
=====

These are patches #110-112. Andrew, can you drop those patches for the time being? I'm working on integrating those into libata #upstream now.
Also, please drop #113 libata_resume_fix.patch. This shouldn't be
necessary anymore.

Thanks.

Signature · 1 line
tejun
#4 lore raw

Ar Maw, 2006-08-01 am 01:00 +0900, ysgrifennodd Tejun Heo:

Quoted 2 lines

These are patches #110-112. Andrew, can you drop those patches for the time being? I'm working on integrating those into libata #upstream now.

If you drop the host_set and tuning patches please drop all the PATA stuff and my other patches out. I don't have time to field a second batch of hundreds of "why has my drive stopped working, why is the speed wrong" emails.

It'll be easier just to work outside the -mm tree with all this continued in/out random breakage if people are just going to say "drop xyz patch" rather than actually specifying *what is actually wrong* and getting me to fix the merge (Tejun that last one sentence is a hint ;))

Alan

#5 lore raw
Quoted 8 lines · Alan Cox

Ar Maw, 2006-08-01 am 01:00 +0900, ysgrifennodd Tejun Heo:

Quoted 2 lines

These are patches #110-112. Andrew, can you drop those patches for the time being? I'm working on integrating those into libata #upstream now.

If you drop the host_set and tuning patches please drop all the PATA stuff and my other patches out. I don't have time to field a second batch of hundreds of "why has my drive stopped working, why is the speed wrong" emails.

Didn't realize pata stuff relies on it.

Quoted 4 lines

It'll be easier just to work outside the -mm tree with all this continued in/out random breakage if people are just going to say "drop xyz patch" rather than actually specifying *what is actually wrong* and getting me to fix the merge (Tejun that last one sentence is a hint ;))

Okay, took the hint. Magallon, can you please try the following patch?

drivers/scsi/libata-bmdma.c +3 -4
Index: work/drivers/scsi/libata-bmdma.c
===================================================================
@@ -905,8 +905,6 @@ static struct ata_probe_ent *ata_pci_ini
 		return NULL;
 
 	probe_ent->legacy_mode = 1;
-	probe_ent->n_ports = 1;
-	probe_ent->hard_port_no = 0;
 	probe_ent->private_data = port[0]->private_data;
 
 	if (port_mask & ATA_PORT_PRIMARY) {
@@ -928,12 +926,10 @@ static struct ata_probe_ent *ata_pci_ini
 		else {
 			/* Secondary only. IRQ 15 only and "first" port is port 1 */
 			probe_ent->irq = 15;
-			probe_ent->hard_port_no = 1;
 		}
 		probe_ent->port[port_num].cmd_addr = ATA_SECONDARY_CMD;
 		probe_ent->port[port_num].altstatus_addr =
 		probe_ent->port[port_num].ctl_addr = ATA_SECONDARY_CTL;
-		port_num ++;
 		if (bmdma) {
 			probe_ent->port[port_num].bmdma_addr = bmdma + 8;
 			if (inb(bmdma + 10) & 0x80)
@@ -942,6 +938,9 @@ static struct ata_probe_ent *ata_pci_ini
 		ata_std_ports(&probe_ent->port[port_num]);
 		port_num ++;
 	}
+
+	probe_ent->n_ports = port_num;
+
 	return probe_ent;
 }
 
drivers/scsi/ata_jmicron.c +2 -2
Index: work/drivers/scsi/ata_jmicron.c
===================================================================
@@ -44,8 +44,8 @@ static int jmicron_pre_reset(struct ata_
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u32 control;
 	u32 control5;
-	int port_mask = 1<< (4 * ap->hard_port_no);
-	int port = ap->hard_port_no;
+	int port_mask = 1<< (4 * ap->port_no);
+	int port = ap->port_no;
 	port_type port_map[2];
 
 	/* Check if our port is enabled */
drivers/scsi/ata_piix.c +12 -12
Index: work/drivers/scsi/ata_piix.c
===================================================================
@@ -581,7 +581,7 @@ static void ich_pata_cbl_detect(struct a
 		goto cbl40;
 
 	/* check BIOS cable detect results */
-	mask = ap->hard_port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
+	mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
 	pci_read_config_byte(pdev, PIIX_IOCFG, &tmp);
 	if ((tmp & mask) == 0)
 		goto cbl40;
@@ -605,7 +605,7 @@ static int piix_pata_prereset(struct ata
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 
-	if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) {
 		ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
 		ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
 		return 0;
@@ -633,7 +633,7 @@ static int ich_pata_prereset(struct ata_
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 
-	if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) {
 		ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
 		ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
 		return 0;
@@ -670,7 +670,7 @@ static int piix_sata_prereset(struct ata
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	struct piix_host_priv *hpriv = ap->host_set->private_data;
 	const unsigned int *map = hpriv->map;
-	int base = 2 * ap->hard_port_no;
+	int base = 2 * ap->port_no;
 	unsigned int present = 0;
 	int port, i;
 	u16 pcs;
@@ -721,7 +721,7 @@ static void piix_set_piomode (struct ata
 	unsigned int pio	= adev->pio_mode - XFER_PIO_0;
 	struct pci_dev *dev	= to_pci_dev(ap->host_set->dev);
 	unsigned int is_slave	= (adev->devno != 0);
-	unsigned int master_port= ap->hard_port_no ? 0x42 : 0x40;
+	unsigned int master_port= ap->port_no ? 0x42 : 0x40;
 	unsigned int slave_port	= 0x44;
 	u16 master_data;
 	u8 slave_data;
@@ -756,9 +756,9 @@ static void piix_set_piomode (struct ata
 		/* enable PPE1, IE1 and TIME1 as needed */
 		master_data |= (control << 4);
 		pci_read_config_byte(dev, slave_port, &slave_data);
-		slave_data &= (ap->hard_port_no ? 0x0f : 0xf0);
+		slave_data &= (ap->port_no ? 0x0f : 0xf0);
 		/* Load the timing nibble for this slave */
-		slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->hard_port_no ? 4 : 0);
+		slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
 	} else {
 		/* Master keeps the bits in a different format */
 		master_data &= 0xccf8;
@@ -777,7 +777,7 @@ static void piix_set_piomode (struct ata
 	   
 	if (ap->udma_mask) {
 		pci_read_config_byte(dev, 0x48, &udma_enable);
-		udma_enable &= ~(1 << (2 * ap->hard_port_no + adev->devno));
+		udma_enable &= ~(1 << (2 * ap->port_no + adev->devno));
 		pci_write_config_byte(dev, 0x48, udma_enable);
 	}
 }
@@ -798,10 +798,10 @@ static void piix_set_piomode (struct ata
 static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, int isich)
 {
 	struct pci_dev *dev	= to_pci_dev(ap->host_set->dev);
-	u8 master_port		= ap->hard_port_no ? 0x42 : 0x40;
+	u8 master_port		= ap->port_no ? 0x42 : 0x40;
 	u16 master_data;
 	u8 speed		= adev->dma_mode;
-	int devid		= adev->devno + 2 * ap->hard_port_no;
+	int devid		= adev->devno + 2 * ap->port_no;
 	u8 udma_enable;
 	
 	static const	 /* ISP  RTC */
@@ -879,9 +879,9 @@ static void do_pata_set_dmamode (struct 
 			master_data &= 0xFF4F;  /* Mask out IORDY|TIME1|DMAONLY */
 			master_data |= control << 4;
 			pci_read_config_byte(dev, 0x44, &slave_data);
-			slave_data &= (0x0F + 0xE1 * ap->hard_port_no);
+			slave_data &= (0x0F + 0xE1 * ap->port_no);
 			/* Load the matching timing */
-			slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->hard_port_no ? 4 : 0);
+			slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
 			pci_write_config_byte(dev, 0x44, slave_data);
 		} else { 	/* Master */
 			master_data &= 0xCCF4;	/* Mask out IORDY|TIME1|DMAONLY 
drivers/scsi/libata-core.c +0 -2
Index: work/drivers/scsi/libata-core.c
===================================================================
@@ -5265,8 +5265,6 @@ static void ata_host_init(struct ata_por
 	ap->dev = ent->dev;
 	ap->port_no = port_no;
 
-	ap->hard_port_no =
-		ent->legacy_mode ? ent->hard_port_no : port_no;
 	ap->pio_mask = ent->pio_mask;
 	ap->mwdma_mask = ent->mwdma_mask;
 	ap->udma_mask = ent->udma_mask;
drivers/scsi/pata_ali.c +6 -6
Index: work/drivers/scsi/pata_ali.c
===================================================================
@@ -83,7 +83,7 @@ static int ali_c2_cable_detect(struct at
 	/* Host view cable detect 0x4A bit 0 primary bit 1 secondary
 	   Bit set for 40 pin */
 	pci_read_config_byte(pdev, 0x4A, &ata66);
-	if (ata66 & (1 << ap->hard_port_no))
+	if (ata66 & (1 << ap->port_no))
 		return ATA_CBL_PATA40;
 	else
 		return ATA_CBL_PATA80;
@@ -177,7 +177,7 @@ static unsigned long ali_20_filter(const
 static void ali_fifo_control(struct ata_port *ap, struct ata_device *adev, int on)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int pio_fifo = 0x54 + ap->hard_port_no;
+	int pio_fifo = 0x54 + ap->port_no;
 	u8 fifo;
 	int shift = 4 * adev->devno;
 
@@ -208,10 +208,10 @@ static void ali_fifo_control(struct ata_
 static void ali_program_modes(struct ata_port *ap, struct ata_device *adev, struct ata_timing *t, u8 ultra)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int cas = 0x58 + 4 * ap->hard_port_no;	/* Command timing */
-	int cbt = 0x59 + 4 * ap->hard_port_no;	/* Command timing */
-	int drwt = 0x5A + 4 * ap->hard_port_no + adev->devno; /* R/W timing */
-	int udmat = 0x56 + ap->hard_port_no;	/* UDMA timing */
+	int cas = 0x58 + 4 * ap->port_no;	/* Command timing */
+	int cbt = 0x59 + 4 * ap->port_no;	/* Command timing */
+	int drwt = 0x5A + 4 * ap->port_no + adev->devno; /* R/W timing */
+	int udmat = 0x56 + ap->port_no;	/* UDMA timing */
 	int shift = 4 * adev->devno;
 	u8 udma;
 
drivers/scsi/pata_amd.c +6 -6
Index: work/drivers/scsi/pata_amd.c
===================================================================
@@ -49,7 +49,7 @@ static void timing_setup(struct ata_port
 
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	struct ata_device *peer = ata_dev_pair(adev);
-	int dn = ap->hard_port_no * 2 + adev->devno;
+	int dn = ap->port_no * 2 + adev->devno;
 	struct ata_timing at, apeer;
 	int T, UT;
 	const int amd_clock = 33333;	/* KHz. */
@@ -137,14 +137,14 @@ static int amd_pre_reset(struct ata_port
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u8 ata66;
 	
-	if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
 	}
 
 	pci_read_config_byte(pdev, 0x42, &ata66);
-	if (ata66 & bitmask[ap->hard_port_no])
+	if (ata66 & bitmask[ap->port_no])
 		ap->cbl = ATA_CBL_PATA80;
 	else
 		ap->cbl = ATA_CBL_PATA40;
@@ -167,7 +167,7 @@ static int amd_early_pre_reset(struct at
 		{ 0x40, 1, 0x01, 0x01 }
 	};
 
-	if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -259,7 +259,7 @@ static int nv_pre_reset(struct ata_port 
 	u16 udma;
 
 	pci_read_config_byte(pdev, 0x52, &ata66);
-	if (ata66 & bitmask[ap->hard_port_no])
+	if (ata66 & bitmask[ap->port_no])
 		ap->cbl = ATA_CBL_PATA80;
 	else
 		ap->cbl = ATA_CBL_PATA40;
@@ -267,7 +267,7 @@ static int nv_pre_reset(struct ata_port 
 	/* We now have to double check because the Nvidia boxes BIOS
 	   doesn't always set the cable bits but does set mode bits */
 
-	pci_read_config_word(pdev, 0x62 - 2 * ap->hard_port_no, &udma);
+	pci_read_config_word(pdev, 0x62 - 2 * ap->port_no, &udma);
 	if ((udma & 0xC4) == 0xC4 || (udma & 0xC400) == 0xC400)
 		ap->cbl = ATA_CBL_PATA80;
 	return ata_std_prereset(ap);
drivers/scsi/pata_artop.c +11 -11
Index: work/drivers/scsi/pata_artop.c
===================================================================
@@ -47,7 +47,7 @@ static int artop6210_pre_reset(struct at
 		{ 0x4AU, 1U, 0x04UL, 0x04UL },	/* port 1 */
 	};
 
-	if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -90,13 +90,13 @@ static int artop6260_pre_reset(struct at
 	u8 tmp;
 
 	/* Odd numbered device ids are the units with enable bits (the -R cards) */
-	if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->hard_port_no])) {
+	if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
 	}
 	pci_read_config_byte(pdev, 0x49, &tmp);
-	if (tmp & (1 >> ap->hard_port_no))
+	if (tmp & (1 >> ap->port_no))
 		ap->cbl = ATA_CBL_PATA40;
 	else
 		ap->cbl = ATA_CBL_PATA80;
@@ -135,7 +135,7 @@ static void artop6260_error_handler(stru
 static void artop6210_load_piomode(struct ata_port *ap, struct ata_device *adev, unsigned int pio)
 {
 	struct pci_dev *pdev	= to_pci_dev(ap->host_set->dev);
-	int dn = adev->devno + 2 * ap->hard_port_no;
+	int dn = adev->devno + 2 * ap->port_no;
 	const u16 timing[2][5] = {
 		{ 0x0000, 0x000A, 0x0008, 0x0303, 0x0301 },
 		{ 0x0700, 0x070A, 0x0708, 0x0403, 0x0401 }
@@ -162,7 +162,7 @@ static void artop6210_load_piomode(struc
 static void artop6210_set_piomode(struct ata_port *ap, struct ata_device *adev)
 {
 	struct pci_dev *pdev	= to_pci_dev(ap->host_set->dev);
-	int dn = adev->devno + 2 * ap->hard_port_no;
+	int dn = adev->devno + 2 * ap->port_no;
 	u8 ultra;
 
 	artop6210_load_piomode(ap, adev, adev->pio_mode - XFER_PIO_0);
@@ -189,7 +189,7 @@ static void artop6210_set_piomode(struct
 static void artop6260_load_piomode (struct ata_port *ap, struct ata_device *adev, unsigned int pio)
 {
 	struct pci_dev *pdev	= to_pci_dev(ap->host_set->dev);
-	int dn = adev->devno + 2 * ap->hard_port_no;
+	int dn = adev->devno + 2 * ap->port_no;
 	const u8 timing[2][5] = {
 		{ 0x00, 0x0A, 0x08, 0x33, 0x31 },
 		{ 0x70, 0x7A, 0x78, 0x43, 0x41 }
@@ -221,9 +221,9 @@ static void artop6260_set_piomode(struct
 	artop6260_load_piomode(ap, adev, adev->pio_mode - XFER_PIO_0);
 
 	/* Clear the UDMA mode bits (set_dmamode will redo this if needed) */
-	pci_read_config_byte(pdev, 0x44 + ap->hard_port_no, &ultra);
+	pci_read_config_byte(pdev, 0x44 + ap->port_no, &ultra);
 	ultra &= ~(7 << (4  * adev->devno));	/* One nibble per drive */
-	pci_write_config_byte(pdev, 0x44 + ap->hard_port_no, ultra);
+	pci_write_config_byte(pdev, 0x44 + ap->port_no, ultra);
 }
 
 /**
@@ -241,7 +241,7 @@ static void artop6210_set_dmamode (struc
 {
 	unsigned int pio;
 	struct pci_dev *pdev	= to_pci_dev(ap->host_set->dev);
-	int dn = adev->devno + 2 * ap->hard_port_no;
+	int dn = adev->devno + 2 * ap->port_no;
 	u8 ultra;
 
 	if (adev->dma_mode == XFER_MW_DMA_0)
@@ -292,7 +292,7 @@ static void artop6260_set_dmamode (struc
 	artop6260_load_piomode(ap, adev, pio);
 
 	/* Add ultra DMA bits if in UDMA mode */
-	pci_read_config_byte(pdev, 0x44 + ap->hard_port_no, &ultra);
+	pci_read_config_byte(pdev, 0x44 + ap->port_no, &ultra);
 	ultra &= ~(7 << (4  * adev->devno));	/* One nibble per drive */
 	if (adev->dma_mode >= XFER_UDMA_0) {
 		u8 mode = adev->dma_mode - XFER_UDMA_0 + 1 - clock;
@@ -300,7 +300,7 @@ static void artop6260_set_dmamode (struc
 			mode = 1;
 		ultra |= (mode << (4 * adev->devno));
 	}
-	pci_write_config_byte(pdev, 0x44 + ap->hard_port_no, ultra);
+	pci_write_config_byte(pdev, 0x44 + ap->port_no, ultra);
 }
 
 static struct scsi_host_template artop_sht = {
drivers/scsi/pata_atiixp.c +7 -7
Index: work/drivers/scsi/pata_atiixp.c
===================================================================
@@ -41,7 +41,7 @@ static int atiixp_pre_reset(struct ata_p
 		{ 0x48, 1, 0x08, 0x00 }
 	};
 
-	if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -70,10 +70,10 @@ static void atiixp_set_pio_timing(struct
 	static u8 pio_timings[5] = { 0x5D, 0x47, 0x34, 0x22, 0x20 };
 
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int dn = 2 * ap->hard_port_no + adev->devno;
+	int dn = 2 * ap->port_no + adev->devno;
 
 	/* Check this is correct - the order is odd in both drivers */
-	int timing_shift = (16 * ap->hard_port_no) + 8 * (adev->devno ^ 1);
+	int timing_shift = (16 * ap->port_no) + 8 * (adev->devno ^ 1);
 	u16 pio_mode_data, pio_timing_data;
 
 	pci_read_config_word(pdev, ATIIXP_IDE_PIO_MODE, &pio_mode_data);
@@ -116,7 +116,7 @@ static void atiixp_set_dmamode(struct at
 
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	int dma = adev->dma_mode;
-	int dn = 2 * ap->hard_port_no + adev->devno;
+	int dn = 2 * ap->port_no + adev->devno;
 	int wanted_pio;
 
 	if (adev->dma_mode >= XFER_UDMA_0) {
@@ -131,7 +131,7 @@ static void atiixp_set_dmamode(struct at
 	} else {
 		u16 mwdma_timing_data;
 		/* Check this is correct - the order is odd in both drivers */
-		int timing_shift = (16 * ap->hard_port_no) + 8 * (adev->devno ^ 1);
+		int timing_shift = (16 * ap->port_no) + 8 * (adev->devno ^ 1);
 
 		dma -= XFER_MW_DMA_0;
 
@@ -170,7 +170,7 @@ static void atiixp_bmdma_start(struct at
 	struct ata_device *adev = qc->dev;
 
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int dn = (2 * ap->hard_port_no) + adev->devno;
+	int dn = (2 * ap->port_no) + adev->devno;
 	u16 tmp16;
 
 	pci_read_config_word(pdev, ATIIXP_IDE_UDMA_CONTROL, &tmp16);
@@ -194,7 +194,7 @@ static void atiixp_bmdma_stop(struct ata
 {
 	struct ata_port *ap = qc->ap;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int dn = (2 * ap->hard_port_no) + qc->dev->devno;
+	int dn = (2 * ap->port_no) + qc->dev->devno;
 	u16 tmp16;
 
 	pci_read_config_word(pdev, ATIIXP_IDE_UDMA_CONTROL, &tmp16);
drivers/scsi/pata_cmd64x.c +8 -8
Index: work/drivers/scsi/pata_cmd64x.c
===================================================================
@@ -88,7 +88,7 @@ static int cmd648_pre_reset(struct ata_p
 
 	/* Check cable detect bits */
 	pci_read_config_byte(pdev, BMIDECSR, &r);
-	if (r & (1 << ap->hard_port_no))
+	if (r & (1 << ap->port_no))
 		ap->cbl = ATA_CBL_PATA80;
 	else	
 		ap->cbl = ATA_CBL_PATA40;
@@ -133,15 +133,15 @@ static void cmd64x_set_piomode(struct at
 		{ DRWTIM2, DRWTIM3 }
 	};
 	
-	int arttim = arttim_port[ap->hard_port_no][adev->devno];
-	int drwtim = drwtim_port[ap->hard_port_no][adev->devno];
+	int arttim = arttim_port[ap->port_no][adev->devno];
+	int drwtim = drwtim_port[ap->port_no][adev->devno];
 	
 	
 	if (ata_timing_compute(adev, adev->pio_mode, &t, T, 0) < 0) {
 		printk(KERN_ERR DRV_NAME ": mode computation failed.\n");
 		return;
 	}
-	if (ap->hard_port_no) {
+	if (ap->port_no) {
 		/* Slave has shared address setup */
 		struct ata_device *pair = ata_dev_pair(adev);
 		
@@ -206,8 +206,8 @@ static void cmd64x_set_dmamode(struct at
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u8 regU, regD;
 
-	int pciU = UDIDETCR0 + 8 * ap->hard_port_no;
-	int pciD = BMIDESR0 + 8 * ap->hard_port_no;
+	int pciU = UDIDETCR0 + 8 * ap->port_no;
+	int pciD = BMIDESR0 + 8 * ap->port_no;
 	int shift = 2 * adev->devno;
 	
 	pci_read_config_byte(pdev, pciD, &regD);
@@ -239,8 +239,8 @@ static void cmd648_bmdma_stop(struct ata
 	struct ata_port *ap = qc->ap;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u8 dma_intr;
-	int dma_reg = ap->hard_port_no ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0;
-	int dma_mask = ap->hard_port_no ? ARTTIM2 : CFR;
+	int dma_reg = ap->port_no ? ARTTIM23_INTR_CH1 : CFR_INTR_CH0;
+	int dma_mask = ap->port_no ? ARTTIM2 : CFR;
 	
 	ata_bmdma_stop(qc);
 	
drivers/scsi/pata_cs5520.c +3 -4
Index: work/drivers/scsi/pata_cs5520.c
===================================================================
@@ -75,16 +75,16 @@ static void cs5520_set_timings(struct at
 	pio -= XFER_PIO_0;
 
 	/* Channel command timing */
-	pci_write_config_byte(pdev, 0x62 + ap->hard_port_no,
+	pci_write_config_byte(pdev, 0x62 + ap->port_no,
 				(cs5520_pio_clocks[pio].recovery << 4) |
 				(cs5520_pio_clocks[pio].assert));
 	/* FIXME: should these use address ? */
 	/* Read command timing */
-	pci_write_config_byte(pdev, 0x64 +  4*ap->hard_port_no + slave,
+	pci_write_config_byte(pdev, 0x64 +  4*ap->port_no + slave,
 				(cs5520_pio_clocks[pio].recovery << 4) |
 				(cs5520_pio_clocks[pio].assert));
 	/* Write command timing */
-	pci_write_config_byte(pdev, 0x66 +  4*ap->hard_port_no + slave,
+	pci_write_config_byte(pdev, 0x66 +  4*ap->port_no + slave,
 				(cs5520_pio_clocks[pio].recovery << 4) |
 				(cs5520_pio_clocks[pio].assert));
 }
@@ -261,7 +261,6 @@ static int __devinit cs5520_init_one(str
 	probe[1] = probe[0];
 	INIT_LIST_HEAD(&probe[1].node);
 	probe[1].irq = 15;
-	probe[1].hard_port_no = 1;
 	probe[1].port[0].cmd_addr = 0x170;
 	probe[1].port[0].ctl_addr = 0x376;
 	probe[1].port[0].altstatus_addr = 0x376;
drivers/scsi/pata_cs5530.c +2 -2
Index: work/drivers/scsi/pata_cs5530.c
===================================================================
@@ -52,7 +52,7 @@ static void cs5530_set_piomode(struct at
 		{0x00009172, 0x00012171, 0x00020080, 0x00032010, 0x00040010},
 		{0xd1329172, 0x71212171, 0x30200080, 0x20102010, 0x00100010}
 	};
-	unsigned long base = ( ap->ioaddr.bmdma_addr & ~0x0F) + 0x20 + 0x10 * ap->hard_port_no;
+	unsigned long base = ( ap->ioaddr.bmdma_addr & ~0x0F) + 0x20 + 0x10 * ap->port_no;
 	u32 tuning;
 	int format;
 
@@ -79,7 +79,7 @@ static void cs5530_set_piomode(struct at
 
 static void cs5530_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 {
-	unsigned long base = ( ap->ioaddr.bmdma_addr & ~0x0F) + 0x20 + 0x10 * ap->hard_port_no;
+	unsigned long base = ( ap->ioaddr.bmdma_addr & ~0x0F) + 0x20 + 0x10 * ap->port_no;
 	u32 tuning, timing = 0;
 	u8 reg;
 
drivers/scsi/pata_cypress.c +1 -1
Index: work/drivers/scsi/pata_cypress.c
===================================================================
@@ -109,7 +109,7 @@ static void cy82c693_set_piomode(struct 
  
 static void cy82c693_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 {
-	int reg = CY82_INDEX_CHANNEL0 + ap->hard_port_no;
+	int reg = CY82_INDEX_CHANNEL0 + ap->port_no;
 	
 	/* Be afraid, be very afraid. Magic registers  in low I/O space */
 	outb(reg, 0x22);
drivers/scsi/pata_efar.c +8 -8
Index: work/drivers/scsi/pata_efar.c
===================================================================
@@ -42,13 +42,13 @@ static int efar_pre_reset(struct ata_por
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u8 tmp;
 
-	if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
 	}
 	pci_read_config_byte(pdev, 0x47, &tmp);
-	if (tmp & (2 >> ap->hard_port_no))
+	if (tmp & (2 >> ap->port_no))
 		ap->cbl = ATA_CBL_PATA40;
 	else
 		ap->cbl = ATA_CBL_PATA80;
@@ -83,7 +83,7 @@ static void efar_set_piomode (struct ata
 {
 	unsigned int pio	= adev->pio_mode - XFER_PIO_0;
 	struct pci_dev *dev	= to_pci_dev(ap->host_set->dev);
-	unsigned int idetm_port= ap->hard_port_no ? 0x42 : 0x40;
+	unsigned int idetm_port= ap->port_no ? 0x42 : 0x40;
 	u16 idetm_data;
 	int control = 0;
 
@@ -117,7 +117,7 @@ static void efar_set_piomode (struct ata
 		idetm_data |= (timings[pio][0] << 12) |
 			(timings[pio][1] << 8);
 	} else {
-		int shift = 4 * ap->hard_port_no;
+		int shift = 4 * ap->port_no;
 		u8 slave_data;
 
 		idetm_data &= 0xCC0F;
@@ -148,10 +148,10 @@ static void efar_set_piomode (struct ata
 static void efar_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 {
 	struct pci_dev *dev	= to_pci_dev(ap->host_set->dev);
-	u8 master_port		= ap->hard_port_no ? 0x42 : 0x40;
+	u8 master_port		= ap->port_no ? 0x42 : 0x40;
 	u16 master_data;
 	u8 speed		= adev->dma_mode;
-	int devid		= adev->devno + 2 * ap->hard_port_no;
+	int devid		= adev->devno + 2 * ap->port_no;
 	u8 udma_enable;
 
 	static const	 /* ISP  RTC */
@@ -202,9 +202,9 @@ static void efar_set_dmamode (struct ata
 			master_data &= 0xFF4F;  /* Mask out IORDY|TIME1|DMAONLY */
 			master_data |= control << 4;
 			pci_read_config_byte(dev, 0x44, &slave_data);
-			slave_data &= (0x0F + 0xE1 * ap->hard_port_no);
+			slave_data &= (0x0F + 0xE1 * ap->port_no);
 			/* Load the matching timing */
-			slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->hard_port_no ? 4 : 0);
+			slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
 			pci_write_config_byte(dev, 0x44, slave_data);
 		} else { 	/* Master */
 			master_data &= 0xCCF4;	/* Mask out IORDY|TIME1|DMAONLY
drivers/scsi/pata_hpt366.c +5 -5
Index: work/drivers/scsi/pata_hpt366.c
===================================================================
@@ -226,7 +226,7 @@ static int hpt36x_pre_reset(struct ata_p
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	
 	pci_read_config_byte(pdev, 0x5A, &ata66);
-	if (ata66 & (1 << ap->hard_port_no))
+	if (ata66 & (1 << ap->port_no))
 		ap->cbl = ATA_CBL_PATA40;
 	else
 		ap->cbl = ATA_CBL_PATA80;
@@ -261,8 +261,8 @@ static void hpt366_set_piomode(struct at
 	u32 mode;
 	u8 fast;
 
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->hard_port_no);
-	addr2 = 0x51 + 4 * ap->hard_port_no;
+	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
+	addr2 = 0x51 + 4 * ap->port_no;
 	
 	/* Fast interrupt prediction disable, hold off interrupt disable */
 	pci_read_config_byte(pdev, addr2, &fast);
@@ -296,8 +296,8 @@ static void hpt366_set_dmamode(struct at
 	u32 mode;
 	u8 fast;
 
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->hard_port_no);
-	addr2 = 0x51 + 4 * ap->hard_port_no;
+	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
+	addr2 = 0x51 + 4 * ap->port_no;
 	
 	/* Fast interrupt prediction disable, hold off interrupt disable */
 	pci_read_config_byte(pdev, addr2, &fast);
drivers/scsi/pata_hpt37x.c +15 -15
Index: work/drivers/scsi/pata_hpt37x.c
===================================================================
@@ -461,7 +461,7 @@ static int hpt37x_pre_reset(struct ata_p
 	/* Restore state */
 	pci_write_config_byte(pdev, 0x5B, scr2);
 	
-	if (ata66 & (1 << ap->hard_port_no))
+	if (ata66 & (1 << ap->port_no))
 		ap->cbl = ATA_CBL_PATA40;
 	else
 		ap->cbl = ATA_CBL_PATA80;
@@ -505,7 +505,7 @@ static int hpt374_pre_reset(struct ata_p
 	pci_write_config_word(pdev, 0x52, mcr3);
 	pci_write_config_word(pdev, 0x56, mcr6);
 	
-	if (ata66 & (1 << ap->hard_port_no))
+	if (ata66 & (1 << ap->port_no))
 		ap->cbl = ATA_CBL_PATA40;
 	else
 		ap->cbl = ATA_CBL_PATA80;
@@ -553,8 +553,8 @@ static void hpt370_set_piomode(struct at
 	u32 mode;
 	u8 fast;
 
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->hard_port_no);
-	addr2 = 0x51 + 4 * ap->hard_port_no;
+	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
+	addr2 = 0x51 + 4 * ap->port_no;
 	
 	/* Fast interrupt prediction disable, hold off interrupt disable */
 	pci_read_config_byte(pdev, addr2, &fast);
@@ -587,8 +587,8 @@ static void hpt370_set_dmamode(struct at
 	u32 mode;
 	u8 fast;
 
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->hard_port_no);
-	addr2 = 0x51 + 4 * ap->hard_port_no;
+	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
+	addr2 = 0x51 + 4 * ap->port_no;
 	
 	/* Fast interrupt prediction disable, hold off interrupt disable */
 	pci_read_config_byte(pdev, addr2, &fast);
@@ -616,7 +616,7 @@ static void hpt370_bmdma_start(struct at
 {
 	struct ata_port *ap = qc->ap;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	pci_write_config_byte(pdev, 0x50 + 4 * ap->hard_port_no, 0x37);
+	pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
 	udelay(10);
 	ata_bmdma_start(qc);
 }
@@ -642,7 +642,7 @@ static void hpt370_bmdma_stop(struct ata
 	}
 	if (dma_stat & 0x01) {
 		/* Clear the engine */
-		pci_write_config_byte(pdev, 0x50 + 4 * ap->hard_port_no, 0x37);
+		pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
 		udelay(10);
 		/* Stop DMA */
 		dma_cmd = inb(bmdma );
@@ -651,7 +651,7 @@ static void hpt370_bmdma_stop(struct ata
 		dma_stat = inb(bmdma + 2);
 		outb(dma_stat | 0x06 , bmdma + 2);
 		/* Clear the engine */
-		pci_write_config_byte(pdev, 0x50 + 4 * ap->hard_port_no, 0x37);
+		pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
 		udelay(10);
 	}
 	ata_bmdma_stop(qc);
@@ -673,8 +673,8 @@ static void hpt372_set_piomode(struct at
 	u32 mode;
 	u8 fast;
 
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->hard_port_no);
-	addr2 = 0x51 + 4 * ap->hard_port_no;
+	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
+	addr2 = 0x51 + 4 * ap->port_no;
 	
 	/* Fast interrupt prediction disable, hold off interrupt disable */
 	pci_read_config_byte(pdev, addr2, &fast);
@@ -708,8 +708,8 @@ static void hpt372_set_dmamode(struct at
 	u32 mode;
 	u8 fast;
 
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->hard_port_no);
-	addr2 = 0x51 + 4 * ap->hard_port_no;
+	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
+	addr2 = 0x51 + 4 * ap->port_no;
 	
 	/* Fast interrupt prediction disable, hold off interrupt disable */
 	pci_read_config_byte(pdev, addr2, &fast);
@@ -736,12 +736,12 @@ static void hpt37x_bmdma_stop(struct ata
 {
 	struct ata_port *ap = qc->ap;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int mscreg = 0x50 + 2 * ap->hard_port_no;
+	int mscreg = 0x50 + 2 * ap->port_no;
 	u8 bwsr_stat, msc_stat;
 	
 	pci_read_config_byte(pdev, 0x6A, &bwsr_stat);
 	pci_read_config_byte(pdev, mscreg, &msc_stat);
-	if (bwsr_stat & (1 << ap->hard_port_no))
+	if (bwsr_stat & (1 << ap->port_no))
 		pci_write_config_byte(pdev, mscreg, msc_stat | 0x30);
 	ata_bmdma_stop(qc);
 }
drivers/scsi/pata_hpt3x2n.c +8 -8
Index: work/drivers/scsi/pata_hpt3x2n.c
===================================================================
@@ -134,7 +134,7 @@ static int hpt3xn_pre_reset(struct ata_p
 	/* Restore state */
 	pci_write_config_byte(pdev, 0x5B, scr2);
 	
-	if (ata66 & (1 << ap->hard_port_no))
+	if (ata66 & (1 << ap->port_no))
 		ap->cbl = ATA_CBL_PATA40;
 	else
 		ap->cbl = ATA_CBL_PATA80;
@@ -175,8 +175,8 @@ static void hpt3x2n_set_piomode(struct a
 	u32 mode;
 	u8 fast;
 
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->hard_port_no);
-	addr2 = 0x51 + 4 * ap->hard_port_no;
+	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
+	addr2 = 0x51 + 4 * ap->port_no;
 	
 	/* Fast interrupt prediction disable, hold off interrupt disable */
 	pci_read_config_byte(pdev, addr2, &fast);
@@ -208,8 +208,8 @@ static void hpt3x2n_set_dmamode(struct a
 	u32 mode;
 	u8 fast;
 
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->hard_port_no);
-	addr2 = 0x51 + 4 * ap->hard_port_no;
+	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
+	addr2 = 0x51 + 4 * ap->port_no;
 	
 	/* Fast interrupt prediction disable, hold off interrupt disable */
 	pci_read_config_byte(pdev, addr2, &fast);
@@ -235,12 +235,12 @@ static void hpt3x2n_bmdma_stop(struct at
 {
 	struct ata_port *ap = qc->ap;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int mscreg = 0x50 + 2 * ap->hard_port_no;
+	int mscreg = 0x50 + 2 * ap->port_no;
 	u8 bwsr_stat, msc_stat;
 	
 	pci_read_config_byte(pdev, 0x6A, &bwsr_stat);
 	pci_read_config_byte(pdev, mscreg, &msc_stat);
-	if (bwsr_stat & (1 << ap->hard_port_no))
+	if (bwsr_stat & (1 << ap->port_no))
 		pci_write_config_byte(pdev, mscreg, msc_stat | 0x30);
 	ata_bmdma_stop(qc);
 }
@@ -290,7 +290,7 @@ static void hpt3x2n_set_clock(struct ata
 static int hpt3x2n_pair_idle(struct ata_port *ap)
 {
 	struct ata_host_set *host = ap->host_set;
-	struct ata_port *pair = host->ports[ap->hard_port_no ^ 1];
+	struct ata_port *pair = host->ports[ap->port_no ^ 1];
 	
 	if (pair->hsm_task_state == HSM_ST_IDLE)
 		return 1;
drivers/scsi/pata_hpt3x3.c +2 -2
Index: work/drivers/scsi/pata_hpt3x3.c
===================================================================
@@ -58,7 +58,7 @@ static void hpt3x3_set_piomode(struct at
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u32 r1, r2;
-	int dn = 2 * ap->hard_port_no + adev->devno;
+	int dn = 2 * ap->port_no + adev->devno;
 
 	pci_read_config_dword(pdev, 0x44, &r1);
 	pci_read_config_dword(pdev, 0x48, &r2);
@@ -84,7 +84,7 @@ static void hpt3x3_set_dmamode(struct at
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u32 r1, r2;
-	int dn = 2 * ap->hard_port_no + adev->devno;
+	int dn = 2 * ap->port_no + adev->devno;
 	int mode_num = adev->dma_mode & 0x0F;
 
 	pci_read_config_dword(pdev, 0x44, &r1);
drivers/scsi/pata_it8172.c +2 -2
Index: work/drivers/scsi/pata_it8172.c
===================================================================
@@ -59,7 +59,7 @@ static int it8172_pre_reset(struct ata_p
 
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	
-	if (ap->hard_port_no && !pci_test_config_bits(pdev, &it8172_enable_bits[ap->hard_port_no])) {
+	if (ap->port_no && !pci_test_config_bits(pdev, &it8172_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -146,7 +146,7 @@ static void it8172_set_piomode(struct at
 static void it8172_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int dn = (2 * ap->hard_port_no) + adev->devno;
+	int dn = (2 * ap->port_no) + adev->devno;
 	u8 reg48, reg4a;
 	int pio;
 
drivers/scsi/pata_it821x.c +6 -6
Index: work/drivers/scsi/pata_it821x.c
===================================================================
@@ -152,7 +152,7 @@ static void it821x_program(struct ata_po
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	struct it821x_dev *itdev = ap->private_data;
-	int channel = ap->hard_port_no;
+	int channel = ap->port_no;
 	u8 conf;
 
 	/* Program PIO/MWDMA timing bits */
@@ -180,7 +180,7 @@ static void it821x_program_udma(struct a
 {
 	struct it821x_dev *itdev = ap->private_data;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int channel = ap->hard_port_no;
+	int channel = ap->port_no;
 	int unit = adev->devno;
 	u8 conf;
 
@@ -246,8 +246,8 @@ static void it821x_clock_strategy(struct
 		sel = 1;
 	}
 	pci_read_config_byte(pdev, 0x50, &v);
-	v &= ~(1 << (1 + ap->hard_port_no));
-	v |= sel << (1 + ap->hard_port_no);
+	v &= ~(1 << (1 + ap->port_no));
+	v |= sel << (1 + ap->port_no);
 	pci_write_config_byte(pdev, 0x50, v);
 
 	/*
@@ -316,7 +316,7 @@ static void it821x_passthru_set_dmamode(
 
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	struct it821x_dev *itdev = ap->private_data;
-	int channel = ap->hard_port_no;
+	int channel = ap->port_no;
 	int unit = adev->devno;
 	u8 conf;
 
@@ -624,7 +624,7 @@ static int it821x_port_start(struct ata_
 		/* No ATAPI DMA in this mode either */
 	}
 	/* Pull the current clocks from 0x50 */
-	if (conf & (1 << (1 + ap->hard_port_no)))
+	if (conf & (1 << (1 + ap->port_no)))
 		itdev->clock_mode = ATA_50;
 	else
 		itdev->clock_mode = ATA_66;
drivers/scsi/pata_mpiix.c +1 -3
Index: work/drivers/scsi/pata_mpiix.c
===================================================================
@@ -54,7 +54,7 @@ static int mpiix_pre_reset(struct ata_po
 		{ 0x6F, 1, 0x80, 0x80 }
 	};
 
-	if (!pci_test_config_bits(pdev, &mpiix_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &mpiix_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -233,7 +233,6 @@ static int mpiix_init_one(struct pci_dev
 	probe[0].irq_flags = SA_SHIRQ;
 	probe[0].host_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
 	probe[0].legacy_mode = 1;
-	probe[0].hard_port_no = 0;
 	probe[0].n_ports = 1;
 	probe[0].port[0].cmd_addr = 0x1F0;
 	probe[0].port[0].ctl_addr = 0x3F6;
@@ -245,7 +244,6 @@ static int mpiix_init_one(struct pci_dev
 	INIT_LIST_HEAD(&probe[1].node);
 	probe[1] = probe[0];
 	probe[1].irq = 15;
-	probe[1].hard_port_no = 1;
 	probe[1].port[0].cmd_addr = 0x170;
 	probe[1].port[0].ctl_addr = 0x376;
 	probe[1].port[0].altstatus_addr = 0x376;
drivers/scsi/pata_ns87410.c +2 -2
Index: work/drivers/scsi/pata_ns87410.c
===================================================================
@@ -45,7 +45,7 @@ static int ns87410_pre_reset(struct ata_
 		{ 0x47, 1, 0x08, 0x08 }
 	};
 
-	if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -80,7 +80,7 @@ static void ns87410_error_handler(struct
 static void ns87410_set_piomode(struct ata_port *ap, struct ata_device *adev)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int port = 0x40 + 4 * ap->hard_port_no;
+	int port = 0x40 + 4 * ap->port_no;
 	u8 idetcr, idefr;
 	struct ata_timing at;
 
drivers/scsi/pata_oldpiix.c +3 -3
Index: work/drivers/scsi/pata_oldpiix.c
===================================================================
@@ -42,7 +42,7 @@ static int oldpiix_pre_reset(struct ata_
 		{ 0x43U, 1U, 0x80UL, 0x80UL },	/* port 1 */
 	};
 
-	if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -80,7 +80,7 @@ static void oldpiix_set_piomode (struct 
 {
 	unsigned int pio	= adev->pio_mode - XFER_PIO_0;
 	struct pci_dev *dev	= to_pci_dev(ap->host_set->dev);
-	unsigned int idetm_port= ap->hard_port_no ? 0x42 : 0x40;
+	unsigned int idetm_port= ap->port_no ? 0x42 : 0x40;
 	u16 idetm_data;
 	int control = 0;
 
@@ -140,7 +140,7 @@ static void oldpiix_set_piomode (struct 
 static void oldpiix_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 {
 	struct pci_dev *dev	= to_pci_dev(ap->host_set->dev);
-	u8 idetm_port		= ap->hard_port_no ? 0x42 : 0x40;
+	u8 idetm_port		= ap->port_no ? 0x42 : 0x40;
 	u16 idetm_data;
 
 	static const	 /* ISP  RTC */
drivers/scsi/pata_opti.c +1 -1
Index: work/drivers/scsi/pata_opti.c
===================================================================
@@ -59,7 +59,7 @@ static int opti_pre_reset(struct ata_por
 		{ 0x40, 1, 0x08, 0x00 }
 	};
 
-	if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
drivers/scsi/pata_optidma.c +4 -4
Index: work/drivers/scsi/pata_optidma.c
===================================================================
@@ -59,7 +59,7 @@ static int optidma_pre_reset(struct ata_
 		0x40, 1, 0x08, 0x00
 	};
 
-	if (ap->hard_port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) {
+	if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -221,7 +221,7 @@ static void optiplus_set_mode(struct ata
 	u8 udcfg;
 	u8 udslave;
 	int dev2 = 2 * adev->devno;
-	int unit = 2 * ap->hard_port_no + adev->devno;
+	int unit = 2 * ap->port_no + adev->devno;
 	int udma = mode - XFER_UDMA_0;
 	
 	pci_read_config_byte(pdev, 0x44, &udcfg);
@@ -230,7 +230,7 @@ static void optiplus_set_mode(struct ata
 		optidma_set_mode(ap, adev, adev->dma_mode);
 	} else {
 		udcfg |=  (1 << unit);
-		if (ap->hard_port_no) {
+		if (ap->port_no) {
 			pci_read_config_byte(pdev, 0x45, &udslave);
 			udslave &= ~(0x03 << dev2);
 			udslave |= (udma << dev2);
@@ -334,7 +334,7 @@ static u8 optidma_make_bits43(struct ata
 static void optidma_post_set_mode(struct ata_port *ap)
 {
 	u8 r;
-	int nybble = 4 * ap->hard_port_no;
+	int nybble = 4 * ap->port_no;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	
 	pci_read_config_byte(pdev, 0x43, &r);
drivers/scsi/pata_pdc202xx_old.c +7 -7
Index: work/drivers/scsi/pata_pdc202xx_old.c
===================================================================
@@ -49,7 +49,7 @@ static int pdc2026x_pre_reset(struct ata
 	u16 cis;
 	
 	pci_read_config_word(pdev, 0x50, &cis);
-	if (cis & (1 << (10 + ap->hard_port_no)))
+	if (cis & (1 << (10 + ap->port_no)))
 		ap->cbl = ATA_CBL_PATA80;
 	else
 		ap->cbl = ATA_CBL_PATA40;
@@ -76,7 +76,7 @@ static void pdc2026x_error_handler(struc
 static void pdc_configure_piomode(struct ata_port *ap, struct ata_device *adev, int pio)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int port = 0x60 + 4 * ap->hard_port_no + 2 * adev->devno;
+	int port = 0x60 + 4 * ap->port_no + 2 * adev->devno;
 	static u16 pio_timing[5] = {
 		0x0913, 0x050C , 0x0308, 0x0206, 0x0104
 	};
@@ -123,7 +123,7 @@ static void pdc_set_piomode(struct ata_p
 static void pdc_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	int port = 0x60 + 4 * ap->hard_port_no + 2 * adev->devno;
+	int port = 0x60 + 4 * ap->port_no + 2 * adev->devno;
 	static u8 udma_timing[6][2] = {
 		{ 0x60, 0x03 },	/* 33 Mhz Clock */
 		{ 0x40, 0x02 },
@@ -168,11 +168,11 @@ static void pdc2026x_bmdma_start(struct 
 	struct ata_port *ap = qc->ap;
 	struct ata_device *adev = qc->dev;
 	struct ata_taskfile *tf = &qc->tf;
-	int sel66 = ap->hard_port_no ? 0x08: 0x02;
+	int sel66 = ap->port_no ? 0x08: 0x02;
 
 	unsigned long master = ap->host_set->ports[0]->ioaddr.bmdma_addr;
 	unsigned long clock = master + 0x11;
-	unsigned long atapi_reg = master + 0x20 + (4 * ap->hard_port_no);
+	unsigned long atapi_reg = master + 0x20 + (4 * ap->port_no);
 	
 	u32 len;
 	
@@ -220,11 +220,11 @@ static void pdc2026x_bmdma_stop(struct a
 	struct ata_device *adev = qc->dev;
 	struct ata_taskfile *tf = &qc->tf;
 	
-	int sel66 = ap->hard_port_no ? 0x08: 0x02;
+	int sel66 = ap->port_no ? 0x08: 0x02;
 	/* The clock bits are in the same register for both channels */
 	unsigned long master = ap->host_set->ports[0]->ioaddr.bmdma_addr;
 	unsigned long clock = master + 0x11;
-	unsigned long atapi_reg = master + 0x20 + (4 * ap->hard_port_no);
+	unsigned long atapi_reg = master + 0x20 + (4 * ap->port_no);
 	
 	/* Cases the state machine will not complete correctly */
 	if (tf->protocol == ATA_PROT_ATAPI_DMA || ( tf->flags & ATA_TFLAG_LBA48)) {
drivers/scsi/pata_sc1200.c +2 -2
Index: work/drivers/scsi/pata_sc1200.c
===================================================================
@@ -95,7 +95,7 @@ static void sc1200_set_piomode(struct at
 
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u32 format;
-	unsigned int reg = 0x40 + 0x10 * ap->hard_port_no;
+	unsigned int reg = 0x40 + 0x10 * ap->port_no;
 	int mode = adev->pio_mode - XFER_PIO_0;
 	
 	pci_read_config_dword(pdev, reg + 4, &format);
@@ -130,7 +130,7 @@ static void sc1200_set_dmamode(struct at
 	
 	int clock = sc1200_clock();
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-	unsigned int reg = 0x40 + 0x10 * ap->hard_port_no;
+	unsigned int reg = 0x40 + 0x10 * ap->port_no;
 	int mode = adev->dma_mode;
 	u32 format;
 
drivers/scsi/pata_serverworks.c +10 -10
Index: work/drivers/scsi/pata_serverworks.c
===================================================================
@@ -68,7 +68,7 @@ static const char *csb_bad_ata100[] = {
 static int dell_cable(struct ata_port *ap) {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	
-	if (pdev->subsystem_device & (1 << (ap->hard_port_no + 14)))
+	if (pdev->subsystem_device & (1 << (ap->port_no + 14)))
 		return ATA_CBL_PATA80;
 	return ATA_CBL_PATA40;
 }
@@ -85,7 +85,7 @@ static int dell_cable(struct ata_port *a
 static int sun_cable(struct ata_port *ap) {
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	
-	if (pdev->subsystem_device & (1 << (ap->hard_port_no + 14)))
+	if (pdev->subsystem_device & (1 << (ap->port_no + 14)))
 		return ATA_CBL_PATA80;
 	return ATA_CBL_PATA40;
 }
@@ -254,8 +254,8 @@ static unsigned long serverworks_csb_fil
 static void serverworks_set_piomode(struct ata_port *ap, struct ata_device *adev)
 {
 	static const u8 pio_mode[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
-	int offset = 1 + (2 * ap->hard_port_no) - adev->devno;
-	int devbits = (2 * ap->hard_port_no + adev->devno) * 4;
+	int offset = 1 + (2 * ap->port_no) - adev->devno;
+	int devbits = (2 * ap->port_no + adev->devno) * 4;
 	u16 csb5_pio;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	int pio = adev->pio_mode - XFER_PIO_0;
@@ -284,8 +284,8 @@ static void serverworks_set_piomode(stru
 static void serverworks_set_dmamode(struct ata_port *ap, struct ata_device *adev)
 {
 	static const u8 dma_mode[] = { 0x77, 0x21, 0x20 };
-	int offset = 1 + 2 * ap->hard_port_no - adev->devno;
-	int devbits = (2 * ap->hard_port_no + adev->devno);
+	int offset = 1 + 2 * ap->port_no - adev->devno;
+	int devbits = (2 * ap->port_no + adev->devno);
 	u8 ultra;
 	u8 ultra_cfg;
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
@@ -295,11 +295,11 @@ static void serverworks_set_dmamode(stru
 	if (adev->dma_mode >= XFER_UDMA_0) {
 		pci_write_config_byte(pdev, 0x44 + offset,  0x20);
 
-		pci_read_config_byte(pdev, 0x56 + ap->hard_port_no, &ultra);
-		ultra &= ~(0x0F << (ap->hard_port_no * 4));
+		pci_read_config_byte(pdev, 0x56 + ap->port_no, &ultra);
+		ultra &= ~(0x0F << (ap->port_no * 4));
 		ultra |= (adev->dma_mode - XFER_UDMA_0)
-					<< (ap->hard_port_no * 4);
-		pci_write_config_byte(pdev, 0x56 + ap->hard_port_no, ultra);
+					<< (ap->port_no * 4);
+		pci_write_config_byte(pdev, 0x56 + ap->port_no, ultra);
 
 		ultra_cfg |=  (1 << devbits);
 	} else {
drivers/scsi/pata_sil680.c +3 -3
Index: work/drivers/scsi/pata_sil680.c
===================================================================
@@ -49,7 +49,7 @@
 static unsigned long sil680_selreg(struct ata_port *ap, int r)
 {
 	unsigned long base = 0xA0 + r;
-	base += (ap->hard_port_no << 4);
+	base += (ap->port_no << 4);
 	return base;
 }
 
@@ -66,7 +66,7 @@ static unsigned long sil680_selreg(struc
 static unsigned long sil680_seldev(struct ata_port *ap, struct ata_device *adev, int r)
 {
 	unsigned long base = 0xA0 + r;
-	base += (ap->hard_port_no << 4);
+	base += (ap->port_no << 4);
 	base |= adev->devno ? 2 : 0;
 	return base;
 }
@@ -180,7 +180,7 @@ static void sil680_set_dmamode(struct at
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	unsigned long ma = sil680_seldev(ap, adev, 0x08);
 	unsigned long ua = sil680_seldev(ap, adev, 0x0C);
-	unsigned long addr_mask = 0x80 + 4 * ap->hard_port_no;
+	unsigned long addr_mask = 0x80 + 4 * ap->port_no;
 	int port_shift = adev->devno * 4;
 	u8 scsc, mode;
 	u16 multi, ultra;
drivers/scsi/pata_sis.c +9 -9
Index: work/drivers/scsi/pata_sis.c
===================================================================
@@ -53,7 +53,7 @@ struct sis_chipset {
 
 static int sis_port_base(struct ata_device *adev)
 {
-	return  0x40 + (4 * adev->ap->hard_port_no) +  (2 * adev->devno);
+	return  0x40 + (4 * adev->ap->port_no) +  (2 * adev->devno);
 }
 
 /**
@@ -74,13 +74,13 @@ static int sis_133_pre_reset(struct ata_
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u16 tmp;
 
-	if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
 	}
 	/* The top bit of this register is the cable detect bit */
-	pci_read_config_word(pdev, 0x50 + 2 * ap->hard_port_no, &tmp);
+	pci_read_config_word(pdev, 0x50 + 2 * ap->port_no, &tmp);
 	if (tmp & 0x8000)
 		ap->cbl = ATA_CBL_PATA40;
 	else
@@ -121,14 +121,14 @@ static int sis_66_pre_reset(struct ata_p
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u8 tmp;
 
-	if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
 	}
 	/* Older chips keep cable detect in bits 4/5 of reg 0x48 */
 	pci_read_config_byte(pdev, 0x48, &tmp);
-	tmp >>= ap->hard_port_no;
+	tmp >>= ap->port_no;
 	if (tmp & 0x10)
 		ap->cbl = ATA_CBL_PATA40;
 	else
@@ -167,7 +167,7 @@ static int sis_old_pre_reset(struct ata_
 	
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 
-	if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -206,7 +206,7 @@ static void sis_set_fifo(struct ata_port
 	u8 fifoctrl;
 	u8 mask = 0x11;
 
-	mask <<= (2 * ap->hard_port_no);
+	mask <<= (2 * ap->port_no);
 	mask <<= adev->devno;
 
 	/* This holds various bits including the FIFO control */
@@ -323,7 +323,7 @@ static void sis_133_set_piomode (struct 
 	pci_read_config_dword(pdev, 0x54, &reg54);
 	if (reg54 & 0x40000000)
 		port = 0x70;
-	port += 8 * ap->hard_port_no +  4 * adev->devno;
+	port += 8 * ap->port_no +  4 * adev->devno;
 
 	pci_read_config_dword(pdev, port, &t1);
 	t1 &= 0xC0C00FFF;	/* Mask out timing */
@@ -511,7 +511,7 @@ static void sis_133_set_dmamode (struct 
 	pci_read_config_dword(pdev, 0x54, &reg54);
 	if (reg54 & 0x40000000)
 		port = 0x70;
-	port += (8 * ap->hard_port_no) +  (4 * adev->devno);
+	port += (8 * ap->port_no) +  (4 * adev->devno);
 
 	pci_read_config_dword(pdev, port, &t1);
 
drivers/scsi/pata_sl82c105.c +3 -3
Index: work/drivers/scsi/pata_sl82c105.c
===================================================================
@@ -49,7 +49,7 @@ static int sl82c105_pre_reset(struct ata
 	};
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 
-	if (ap->hard_port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->hard_port_no])) {
+	if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		dev_printk(KERN_INFO, &pdev->dev, "port disabled. ignoring.\n");
 		return 0;
@@ -83,7 +83,7 @@ static void sl82c105_configure_piomode(s
 		0x50D, 0x407, 0x304, 0x242, 0x240
 	};
 	u16 dummy;
-	int timing = 0x44 + (8 * ap->hard_port_no) + (4 * adev->devno);
+	int timing = 0x44 + (8 * ap->port_no) + (4 * adev->devno);
 	
 	pci_write_config_word(pdev, timing, pio_timing[pio]);
 	/* Can we lose this oddity of the old driver */
@@ -120,7 +120,7 @@ static void sl82c105_configure_dmamode(s
 		0x707, 0x201, 0x200
 	};
 	u16 dummy;
-	int timing = 0x44 + (8 * ap->hard_port_no) + (4 * adev->devno);
+	int timing = 0x44 + (8 * ap->port_no) + (4 * adev->devno);
 	int dma = adev->dma_mode - XFER_MW_DMA_0;
 	
 	pci_write_config_word(pdev, timing, dma_timing[dma]);
drivers/scsi/pata_triflex.c +2 -2
Index: work/drivers/scsi/pata_triflex.c
===================================================================
@@ -61,7 +61,7 @@ static int triflex_probe_init(struct ata
 
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	
-	if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->hard_port_no])) {
+	if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no])) {
 		ata_port_disable(ap);
 		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 		return 0;
@@ -94,7 +94,7 @@ static void triflex_load_timing(struct a
 	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 	u32 timing = 0;
 	u32 triflex_timing, old_triflex_timing;
-	int channel_offset = ap->hard_port_no ? 0x74: 0x70;
+	int channel_offset = ap->port_no ? 0x74: 0x70;
 	unsigned int is_slave	= (adev->devno != 0);
 
 
drivers/scsi/pata_via.c +4 -4
Index: work/drivers/scsi/pata_via.c
===================================================================
@@ -137,7 +137,7 @@ static int via_cable_detect(struct ata_p
 	pci_read_config_dword(pdev, 0x50, &ata66);
 	/* Check both the drive cable reporting bits, we might not have
 	   two drives */
-	if (ata66 & (0x10100000 >> (16 * ap->hard_port_no)))
+	if (ata66 & (0x10100000 >> (16 * ap->port_no)))
 		return ATA_CBL_PATA80;
 	else
 		return ATA_CBL_PATA40;
@@ -155,7 +155,7 @@ static int via_pre_reset(struct ata_port
 
 		struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
 		
-		if (!pci_test_config_bits(pdev, &via_enable_bits[ap->hard_port_no])) {
+		if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no])) {
 			ata_port_disable(ap);
 			printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 			return 0;
@@ -207,7 +207,7 @@ static void via_do_set_mode(struct ata_p
 	unsigned long T =  1000000000 / via_clock;
 	unsigned long UT = T/tdiv;
 	int ut;
-	int offset = 3 - (2*ap->hard_port_no) - adev->devno;
+	int offset = 3 - (2*ap->port_no) - adev->devno;
 
 
 	/* Calculate the timing values we require */
@@ -233,7 +233,7 @@ static void via_do_set_mode(struct ata_p
 	}
 
 	/* Load the PIO mode bits */
-	pci_write_config_byte(pdev, 0x4F - ap->hard_port_no,
+	pci_write_config_byte(pdev, 0x4F - ap->port_no,
 		((FIT(t.act8b, 1, 16) - 1) << 4) | (FIT(t.rec8b, 1, 16) - 1));
 	pci_write_config_byte(pdev, 0x48 + offset,
 		((FIT(t.active, 1, 16) - 1) << 4) | (FIT(t.recover, 1, 16) - 1));
include/linux/libata.h +0 -2
Index: work/include/linux/libata.h
===================================================================
@@ -350,7 +350,6 @@ struct ata_probe_ent {
 	struct scsi_host_template *sht;
 	struct ata_ioports	port[ATA_MAX_PORTS];
 	unsigned int		n_ports;
-	unsigned int		hard_port_no;
 	unsigned int		pio_mask;
 	unsigned int		mwdma_mask;
 	unsigned int		udma_mask;
@@ -507,7 +506,6 @@ struct ata_port {
 	unsigned int		pflags; /* ATA_PFLAG_xxx */
 	unsigned int		id;	/* unique id req'd by scsi midlyr */
 	unsigned int		port_no; /* unique port #; from zero */
-	unsigned int		hard_port_no;	/* hardware port #; from zero */
 
 	struct ata_prd		*prd;	 /* our SG list */
 	dma_addr_t		prd_dma; /* and its DMA mapping */
#6 lore raw
Quoted 10 lines · Tejun Heo
Quoted 6 lines · Alan Cox

Ar Maw, 2006-08-01 am 01:00 +0900, ysgrifennodd Tejun Heo:

Quoted 1 line

These are patches #110-112. Andrew, can you drop those patches for the time being? I'm working on integrating those into libata #upstream now.

If you drop the host_set and tuning patches please drop all the PATA stuff and my other patches out. I don't have time to field a second batch of hundreds of "why has my drive stopped working, why is the speed wrong" emails.

Didn't realize pata stuff relies on it.

Quoted 7 lines
Quoted 4 lines

It'll be easier just to work outside the -mm tree with all this continued in/out random breakage if people are just going to say "drop xyz patch" rather than actually specifying *what is actually wrong* and getting me to fix the merge (Tejun that last one sentence is a hint ;))

Okay, took the hint. Magallon, can you please try the following patch?

Hit send a bit too fast.

Alan, the reason why the second port disappeared is a bug in init_legacy_mode(). probe_ent->n_ports is fxied to 1 and port_no gets incremented while initializing the second port ending up initializing part of the third port.

Another problem is that probe_ent/ap->hard_port_no are meaningless. hard_port_no is used to get port_no right on legacy cases where index of host_set->ports[] doesn't match the actual port_no. When there is only one host_set, port_no should always equal hard_port_no. For legacy hosts, the original code ended up assigning the wrong hard_port_no's.

I killed hard_port_no by s/ap->hard_port_no/ap->port_no/g without actually reviewing the usages (man, those are a LOT). If all pata drivers always relied on ap->hard_port_no representing the actual port index in the controller, there shouldn't be a problem. But, just in case, please review the change.

If this fixes Magallon's problem and you agree with the fix, I'll break it down to two patches and submit'em to you with proper heading and all.

Thanks. :)

Signature · 1 line
tejun
#10 lore raw
In reply to Tejun Heo

Ar Maw, 2006-08-01 am 01:50 +0900, ysgrifennodd Tejun Heo:

Quoted 1 line

Didn't realize pata stuff relies on it.

Lots of people have two drives, one junk on a cable so they get upset and all send me bug reports, lots and lots of them. The oher section of the problem is the Simplex mode part of that patch is depended upon by some of the drivers and if you don't do simplex right on some older controllers it *is* a corruptor so I care a lot about doing it right.

#7 lore raw
In reply to Tejun Heo

Ar Maw, 2006-08-01 am 02:03 +0900, ysgrifennodd Tejun Heo:

Quoted 4 lines

Alan, the reason why the second port disappeared is a bug in init_legacy_mode(). probe_ent->n_ports is fxied to 1 and port_no gets incremented while initializing the second port ending up initializing part of the third port.

Ouch yes.

Quoted 5 lines

Another problem is that probe_ent/ap->hard_port_no are meaningless. hard_port_no is used to get port_no right on legacy cases where index of host_set->ports[] doesn't match the actual port_no. When there is only one host_set, port_no should always equal hard_port_no. For legacy hosts, the original code ended up assigning the wrong hard_port_no's.

Agreed. I looked at that but it seemed that it isn't true that you can assume port_no == hard_port_no because you may have a device which has the primary port disabled and the secondary port set legacy. This also sort of comes up in mixed devices but we don't handle them and I think it comes out correctly once we do the pure legacy case right.

Quoted 5 lines

I killed hard_port_no by s/ap->hard_port_no/ap->port_no/g without actually reviewing the usages (man, those are a LOT). If all pata drivers always relied on ap->hard_port_no representing the actual port index in the controller, there shouldn't be a problem. But, just in case, please review the change.

Think about the following execution sequence

ati_pci_init_one
primary port already stolen by drivers/ide secondary port free

legacy_mode = ATA_PORT_SECONDARY
ata_pci_init_legacy_port

port_num = 0
hard_port_num = 1

*kerunnccchhhhhh*

Quoted 2 lines

If this fixes Magallon's problem and you agree with the fix, I'll break it down to two patches and submit'em to you with proper heading and all.

I agree with the theory and the diagnosis. I'm a bit worried about hard_port_no however and I don't think that bit is safe in the secondary only corner case. Registering both always and disabling one works for me as a cleanup.

If you do that then I'll audit all the drivers use of ->port_no against the patches.

Alan

#8 lore raw

Hello,

Alan Cox wrote:
[--snip--]

Quoted 8 lines
Quoted 1 line

I killed hard_port_no by s/ap->hard_port_no/ap->port_no/g without actually reviewing the usages (man, those are a LOT). If all pata drivers always relied on ap->hard_port_no representing the actual port index in the controller, there shouldn't be a problem. But, just in case, please review the change.

Think about the following execution sequence

ati_pci_init_one
primary port already stolen by drivers/ide secondary port free

Quoted 7 lines

legacy_mode = ATA_PORT_SECONDARY
ata_pci_init_legacy_port

port_num = 0
hard_port_num = 1

*kerunnccchhhhhh*

Ah... You're right. That will make port_no different from the hw port#.

Quoted 9 lines
Quoted 1 line

If this fixes Magallon's problem and you agree with the fix, I'll break it down to two patches and submit'em to you with proper heading and all.

I agree with the theory and the diagnosis. I'm a bit worried about hard_port_no however and I don't think that bit is safe in the secondary only corner case. Registering both always and disabling one works for me as a cleanup.

If you do that then I'll audit all the drivers use of ->port_no against the patches.

I like 'registering both always and disabling one' approach for partially stolen legacy devices. We can make ->hard_port_no do the job as before, but IMHO it's error-prone and only useful for very limited cases (first legacy port stolen).

Jeff, what do you think?

Signature · 1 line
tejun
#9 lore raw
Quoted 3 lines · Tejun Heo

I like 'registering both always and disabling one' approach for partially stolen legacy devices. We can make ->hard_port_no do the job as before, but IMHO it's error-prone and only useful for very limited cases (first legacy port stolen).

Jeff, what do you think?

The reason for hard_port_no's existence is the fact that is can sometimes differ from port_no, and we need to know the "real" port number, as opposed to the port number based on counting probed ports.

If you eliminate the need for hard_port_no, feel free to erase it.

Jeff

#11 lore raw
In reply to Tejun Heo
Quoted 12 lines · Tejun Heo
Quoted 8 lines · Alan Cox

Ar Maw, 2006-08-01 am 01:00 +0900, ysgrifennodd Tejun Heo:

Quoted 2 lines

These are patches #110-112. Andrew, can you drop those patches for the time being? I'm working on integrating those into libata #upstream now.

If you drop the host_set and tuning patches please drop all the PATA stuff and my other patches out. I don't have time to field a second batch of hundreds of "why has my drive stopped working, why is the speed wrong" emails.

Didn't realize pata stuff relies on it.

Quoted 8 lines
Quoted 4 lines

It'll be easier just to work outside the -mm tree with all this continued in/out random breakage if people are just going to say "drop xyz patch" rather than actually specifying *what is actually wrong* and getting me to fix the merge (Tejun that last one sentence is a hint ;))

Okay, took the hint. Magallon, can you please try the following patch?

Bingo!! My drives are back again:

libata version 2.00 loaded.
ata_piix 0000:00:1f.1: version 2.00ac6
ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 18 (level, low) -> IRQ 16 ata_piix 0000:00:1f.1: XXX: legacy_mode probe_ent=c2374800
PCI: Setting latency timer of device 0000:00:1f.1 to 64
ata1: PATA max UDMA/100 cmd 0x1F0 ctl 0x3F6 bmdma 0xF000 irq 14
ata2: PATA max UDMA/100 cmd 0x170 ctl 0x376 bmdma 0xF008 irq 14 scsi0 : ata_piix
ata1.00: ATAPI, max UDMA/33
ata1.01: ATAPI, max MWDMA0, CDB intr
ata1.00: configured for UDMA/33
ata1.01: configured for PIO3
scsi1 : ata_piix
ata2.00: ATA-6, max UDMA/100, 234441648 sectors: LBA48 ata2.00: ata2: dev 0 multi count 16
ata2.01: ATAPI, max UDMA/33
ata2.00: configured for UDMA/100
ata2.01: configured for UDMA/33

  Vendor: HL-DT-ST  Model: DVDRAM GSA-4120B  Rev: A111
  Type:   CD-ROM                             ANSI SCSI revision: 05
  Vendor: IOMEGA    Model: ZIP 250           Rev: 51.G
  Type:   Direct-Access                      ANSI SCSI revision: 05
  Vendor: ATA       Model: ST3120022A        Rev: 3.06
  Type:   Direct-Access                      ANSI SCSI revision: 05
  Vendor: TOSHIBA   Model: DVD-ROM SD-M1712  Rev: 1004
  Type:   CD-ROM                             ANSI SCSI revision: 05

ata_piix 0000:00:1f.2: MAP [ P0 -- P1 -- ]
ACPI: PCI Interrupt 0000:00:1f.2[A] -> GSI 18 (level, low) -> IRQ 16 ata_piix 0000:00:1f.2: XXX: non_legacy_mode n_ports=2 probe_ent=c2374800
PCI: Setting latency timer of device 0000:00:1f.2 to 64
ata3: SATA max UDMA/133 cmd 0xC000 ctl 0xC402 bmdma 0xD000 irq 16
ata4: SATA max UDMA/133 cmd 0xC800 ctl 0xCC02 bmdma 0xD008 irq 16 scsi2 : ata_piix
ata3.00: ATA-6, max UDMA/133, 390721968 sectors: LBA48 ata3.00: ata3: dev 0 multi count 16
ata3.00: configured for UDMA/133
scsi3 : ata_piix
ata4: SATA port has no device.
ATA: abnormal status 0x7F on port 0xC807
Vendor: ATA Model: ST3200822AS Rev: 3.01
Type: Direct-Access ANSI SCSI revision: 05
sata_promise 0000:03:04.0: version 1.04
ACPI: PCI Interrupt 0000:03:04.0[A] -> GSI 23 (level, low) -> IRQ 17 sata_promise PATA port found
ata5: SATA max UDMA/133 cmd 0xF8804200 ctl 0xF8804238 bmdma 0x0 irq 17
ata6: SATA max UDMA/133 cmd 0xF8804280 ctl 0xF88042B8 bmdma 0x0 irq 17
ata7: PATA max UDMA/133 cmd 0xF8804300 ctl 0xF8804338 bmdma 0x0 irq 17 scsi4 : sata_promise
ata5: SATA link down (SStatus 0 SControl 300)
scsi5 : sata_promise
ata6: SATA link down (SStatus 0 SControl 0)
scsi6 : sata_promise
ATA: abnormal status 0x7F on port 0xF880431C
ata7: disabling port

And CD burning works again at x40 on /dev/sr0 (the LG GSA-4120B drive). Thanks a lot, and a bug less !!

--
J.A. Magallon <jamagallon()ono!com> \ Software is like sex:
\ It's better when it's free
Mandriva Linux release 2007.0 (Cooker) for i586
Linux 2.6.17-jam05 (gcc 4.1.1 20060724 (prerelease) (4.1.1-3mdk)) #3 SMP PREEMPT

#12 lore raw
In reply to Tejun Heo
Quoted 7 lines · On Tue, 1 Aug 2006 01:50:11 +0900 Tejun Heo <[email protected]> wrote:
Quoted 4 lines

It'll be easier just to work outside the -mm tree with all this continued in/out random breakage if people are just going to say "drop xyz patch" rather than actually specifying *what is actually wrong* and getting me to fix the merge (Tejun that last one sentence is a hint ;))

Okay, took the hint. Magallon, can you please try the following patch?

Gee that's a big scary patch. Is it considered ready for -mm? (bearing in mind -mm's exacting quality standards (heh, I kill me)).

#13 lore raw
Quoted 7 lines · Andrew Morton
Quoted 4 lines · On Tue, 1 Aug 2006 01:50:11 +0900 Tejun Heo <[email protected]> wrote:
Quoted 4 lines

It'll be easier just to work outside the -mm tree with all this continued in/out random breakage if people are just going to say "drop xyz patch" rather than actually specifying *what is actually wrong* and getting me to fix the merge (Tejun that last one sentence is a hint ;))

Quoted 6 lines
Quoted 2 lines

Okay, took the hint. Magallon, can you please try the following patch?

Gee that's a big scary patch. Is it considered ready for -mm? (bearing in mind -mm's exacting quality standards (heh, I kill me)).

It's still a bit broken. I'll follow up with better patches later today (hopefully :)

Thanks.

Signature · 1 line
tejun