Skip to contentSkip to conversation

libata updates (mostly fixes)

PATCH In review Jeff Garzik 4 participants 8 messages Feb 15, 2007 – Feb 23, 2007

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

PATCH 1/1 libata updates (mostly fixes)

The pile that was waiting for post-conference, largely bug fixes.

As mentioned in the last push, were two other push points planned for 2.6.21:
1) merge libata support for ACPI
2) Remove ugly combined mode hacks in libata-sff and pci/quirks, now that old-IDE and libata have the necessary improvements.

Depending on timing and the devres bug count, I may push #2 back to 2.6.22. The sum of devres + ACPI + remove-combined-mode-quirks might be more change than should be in 2.6.21.

Both ACPI and remove-combined-quirks are ready to be pushed, it's just a matter of staging. Comments welcome.

Please pull from 'upstream-linus' branch of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream-linus

to receive the following updates:

 arch/ia64/Kconfig                 |    1 +
 drivers/ata/libata-core.c         |   11 ++++++-
 drivers/ata/pata_legacy.c         |   11 +++++-
 drivers/ata/pata_qdi.c            |    4 ++-
 drivers/ata/pata_sl82c105.c       |    3 ++
 drivers/ata/sata_nv.c             |    6 +++-
 drivers/ata/sata_promise.c        |   64 +++++++------------------------------
 drivers/ata/sata_vsc.c            |    8 +++-
 include/asm-ia64/libata-portmap.h |   12 +++++++
 include/linux/ata.h               |    2 +-
 include/linux/libata.h            |    1 +
 11 files changed, 63 insertions(+), 60 deletions(-)
 create mode 100644 include/asm-ia64/libata-portmap.h

Alan Cox (1):
libata: Add a host flag to indicate lack of IORDY capability

Mikael Pettersson (2):
sata_promise: fix missing PATA cable detection
sata_promise: new EH conversion for 20619 chips, take 2

Nate Dailey (1):
sata_vsc: use default cache line size if non-zero

Olaf Hering (1):
add delay around sl82c105_reset_engine calls

Robert Hancock (1):
sata_nv: handle SError status indication

Tejun Heo (2):
libata: fix drive side 80c cable check, take 3
libata: clear TF before IDENTIFYing

Zhang, Yanmin (1):
ATA convert GSI to irq on ia64

arch/ia64/Kconfig +1 -0
index db185f3..d51f0f1 100644
@@ -22,6 +22,7 @@ config IA64
 
 config 64BIT
 	bool
+	select ATA_NONSTANDARD if ATA
 	default y
 
 config ZONE_DMA
drivers/ata/libata-core.c +10 -1
index 25d8d3f..2cf8251 100644
@@ -1410,7 +1410,16 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
 	}
 
 	tf.protocol = ATA_PROT_PIO;
-	tf.flags |= ATA_TFLAG_POLLING; /* for polling presence detection */
+
+	/* Some devices choke if TF registers contain garbage.  Make
+	 * sure those are properly initialized.
+	 */
+	tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+
+	/* Device presence detection is unreliable on some
+	 * controllers.  Always poll IDENTIFY if available.
+	 */
+	tf.flags |= ATA_TFLAG_POLLING;
 
 	err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
 				     id, sizeof(id[0]) * ATA_ID_WORDS);
drivers/ata/pata_legacy.c +9 -2
index 4223e10..98c1fee 100644
@@ -89,9 +89,10 @@ static int probe_all;			/* Set to check all ISA port ranges */
 static int ht6560a;			/* HT 6560A on primary 1, secondary 2, both 3 */
 static int ht6560b;			/* HT 6560A on primary 1, secondary 2, both 3 */
 static int opti82c611a;			/* Opti82c611A on primary 1, secondary 2, both 3 */
-static int opti82c46x;		/* Opti 82c465MV present (pri/sec autodetect) */
+static int opti82c46x;			/* Opti 82c465MV present (pri/sec autodetect) */
 static int autospeed;			/* Chip present which snoops speed changes */
 static int pio_mask = 0x1F;		/* PIO range for autospeed devices */
+static int iordy_mask = 0xFFFFFFFF;	/* Use iordy if available */
 
 /**
  *	legacy_set_mode		-	mode setting
@@ -113,6 +114,7 @@ static int legacy_set_mode(struct ata_port *ap, struct ata_device **unused)
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
 		struct ata_device *dev = &ap->device[i];
 		if (ata_dev_enabled(dev)) {
+			ata_dev_printk(dev, KERN_INFO, "configured for PIO\n");
 			dev->pio_mode = XFER_PIO_0;
 			dev->xfer_mode = XFER_PIO_0;
 			dev->xfer_shift = ATA_SHIFT_PIO;
@@ -695,6 +697,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
 	void __iomem *io_addr, *ctrl_addr;
 	int pio_modes = pio_mask;
 	u32 mask = (1 << port);
+	u32 iordy = (iordy_mask & mask) ? 0: ATA_FLAG_NO_IORDY;
 	int ret;
 
 	pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0);
@@ -715,6 +718,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
 	if (ht6560a & mask) {
 		ops = &ht6560a_port_ops;
 		pio_modes = 0x07;
+		iordy = ATA_FLAG_NO_IORDY;
 	}
 	if (ht6560b & mask) {
 		ops = &ht6560b_port_ops;
@@ -750,6 +754,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
 			printk(KERN_INFO "PDC20230-C/20630 VLB ATA controller detected.\n");
 				pio_modes = 0x07;
 			ops = &pdc20230_port_ops;
+			iordy = ATA_FLAG_NO_IORDY;
 			udelay(100);
 			inb(0x1F5);
 		} else {
@@ -767,6 +772,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
 	/* Chip does mode setting by command snooping */
 	if (ops == &legacy_port_ops && (autospeed & mask))
 		ops = &simple_port_ops;
+
 	memset(&ae, 0, sizeof(struct ata_probe_ent));
 	INIT_LIST_HEAD(&ae.node);
 	ae.dev = &pdev->dev;
@@ -776,7 +782,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
 	ae.pio_mask = pio_modes;
 	ae.irq = irq;
 	ae.irq_flags = 0;
-	ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST;
+	ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST|iordy;
 	ae.port[0].cmd_addr = io_addr;
 	ae.port[0].altstatus_addr = ctrl_addr;
 	ae.port[0].ctl_addr = ctrl_addr;
@@ -945,6 +951,7 @@ module_param(ht6560b, int, 0);
 module_param(opti82c611a, int, 0);
 module_param(opti82c46x, int, 0);
 module_param(pio_mask, int, 0);
+module_param(iordy_mask, int, 0);
 
 module_init(legacy_init);
 module_exit(legacy_exit);
drivers/ata/pata_qdi.c +3 -1
index 1b3b4ed..4362141 100644
@@ -264,16 +264,18 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
 	if (type == 6580) {
 		ae.port_ops = &qdi6580_port_ops;
 		ae.pio_mask = 0x1F;
+		ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
 	} else {
 		ae.port_ops = &qdi6500_port_ops;
 		ae.pio_mask = 0x07;	/* Actually PIO3 !IORDY is possible */
+		ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST |
+				ATA_FLAG_NO_IORDY;
 	}
 
 	ae.sht = &qdi_sht;
 	ae.n_ports = 1;
 	ae.irq = irq;
 	ae.irq_flags = 0;
-	ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
 	ae.port[0].cmd_addr = io_addr;
 	ae.port[0].altstatus_addr = ctl_addr;
 	ae.port[0].ctl_addr = ctl_addr;
drivers/ata/pata_sl82c105.c +3 -0
index f2fa158..96e890f 100644
@@ -187,7 +187,9 @@ static void sl82c105_bmdma_start(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
 
+	udelay(100);
 	sl82c105_reset_engine(ap);
+	udelay(100);
 
 	/* Set the clocks for DMA */
 	sl82c105_configure_dmamode(ap, qc->dev);
@@ -216,6 +218,7 @@ static void sl82c105_bmdma_stop(struct ata_queued_cmd *qc)
 
 	ata_bmdma_stop(qc);
 	sl82c105_reset_engine(ap);
+	udelay(100);
 
 	/* This will redo the initial setup of the DMA device to matching
 	   PIO timings */
drivers/ata/sata_nv.c +5 -1
index 095ef1b..ab92f20 100644
@@ -827,7 +827,8 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
 			/* freeze if hotplugged or controller error */
 			if (unlikely(status & (NV_ADMA_STAT_HOTPLUG |
 					       NV_ADMA_STAT_HOTUNPLUG |
-					       NV_ADMA_STAT_TIMEOUT))) {
+					       NV_ADMA_STAT_TIMEOUT |
+					       NV_ADMA_STAT_SERROR))) {
 				struct ata_eh_info *ehi = &ap->eh_info;
 
 				ata_ehi_clear_desc(ehi);
@@ -841,6 +842,9 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
 				} else if (status & NV_ADMA_STAT_HOTUNPLUG) {
 					ata_ehi_hotplugged(ehi);
 					ata_ehi_push_desc(ehi, ": hot unplug");
+				} else if (status & NV_ADMA_STAT_SERROR) {
+					/* let libata analyze SError and figure out the cause */
+					ata_ehi_push_desc(ehi, ": SError");
 				}
 				ata_port_freeze(ap);
 				continue;
drivers/ata/sata_promise.c +12 -52

110 lines not on this page · raw message

drivers/ata/sata_vsc.c +6 -2
index 3d9daf2..2fd037b 100644
@@ -346,6 +346,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
 	struct ata_probe_ent *probe_ent;
 	void __iomem *mmio_base;
 	int rc;
+	u8 cls;
 
 	if (!printed_version++)
 		dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
@@ -383,9 +384,12 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
 	INIT_LIST_HEAD(&probe_ent->node);
 
 	/*
-	 * Due to a bug in the chip, the default cache line size can't be used
+	 * Due to a bug in the chip, the default cache line size can't be
+	 * used (unless the default is non-zero).
 	 */
-	pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80);
+	pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cls);
+	if (cls == 0x00)
+		pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80);
 
 	if (pci_enable_msi(pdev) == 0)
 		pci_intx(pdev, 0);
include/asm-ia64/libata-portmap.h new file +12 -0
new file mode 100644
index 0000000..0e00c9a
@@ -0,0 +1,12 @@
+#ifndef __ASM_IA64_LIBATA_PORTMAP_H
+#define __ASM_IA64_LIBATA_PORTMAP_H
+
+#define ATA_PRIMARY_CMD		0x1F0
+#define ATA_PRIMARY_CTL		0x3F6
+#define ATA_PRIMARY_IRQ(dev)	isa_irq_to_vector(14)
+
+#define ATA_SECONDARY_CMD	0x170
+#define ATA_SECONDARY_CTL	0x376
+#define ATA_SECONDARY_IRQ(dev)	isa_irq_to_vector(15)
+
+#endif
include/linux/ata.h +1 -1
index 18e401f..272736e 100644
@@ -352,7 +352,7 @@ static inline int ata_drive_40wire(const u16 *dev_id)
 {
 	if (ata_id_major_version(dev_id) >= 5 && ata_id_is_sata(dev_id))
 		return 0;	/* SATA */
-	if (dev_id[93] & 0x4000)
+	if ((dev_id[93] & 0xE000) == 0x6000)
 		return 0;	/* 80 wire */
 	return 1;
 }
include/linux/libata.h +1 -0
index 596e0c1..b870b20 100644
@@ -172,6 +172,7 @@ enum {
 	ATA_FLAG_DEBUGMSG	= (1 << 13),
 	ATA_FLAG_SETXFER_POLLING= (1 << 14), /* use polling for SETXFER */
 	ATA_FLAG_IGN_SIMPLEX	= (1 << 15), /* ignore SIMPLEX */
+	ATA_FLAG_NO_IORDY	= (1 << 16), /* controller lacks iordy */
 
 	/* The following flag belongs to ap->pflags but is kept in
 	 * ap->flags because it's referenced in many LLDs and will be
#1 lore raw

include/linux/ata.h static inline int ata_drive_40wire(const u16 *dev_id) · line 358

Quoted 11 lines · Jeff Garzik
include/linux/ata.h +1 -1
@@ -352,7 +352,7 @@ static inline int ata_drive_40wire(const u16 *dev_id)
 {
 	if (ata_id_major_version(dev_id) >= 5 && ata_id_is_sata(dev_id))
 		return 0;	/* SATA */
-	if (dev_id[93] & 0x4000)
+	if ((dev_id[93] & 0xE000) == 0x6000)
 		return 0;	/* 80 wire */
 	return 1;
 }

A thought: it seems to me that the major version check should be moved into ata_id_is_sata().

Jeff

#4 lore raw
In reply to Jeff Garzik

arch/ia64/Kconfig config IA64 · line 26

Quoted 11 lines · Jeff Garzik
arch/ia64/Kconfig +1 -0
index db185f3..d51f0f1 100644
@@ -22,6 +22,7 @@ config IA64
 
 config 64BIT
 	bool
+	select ATA_NONSTANDARD if ATA
 	default y

Ok, this is just _strange_.

Tying ATA_NONSTANDARD into ia64 by tying it to the 64BIT config variable may work (well, I _assume_ it does), but it's just psychedelic.

How about adding a separate config entry like

config IA64_ATA
bool
depends on ATA
select ATA_NONSTANDARD
default y

which kind of makes sense when you squint just the right way..

Linus

#5 lore raw
Quoted 2 lines · Linus Torvalds

Ok, this is just _strange_.

Btw, I did pull, but I still think we shouldn't do those kinds of strange Kconfig file games.

Linus

#6 lore raw
In reply to Linus Torvalds
Quoted 8 lines · Linus Torvalds
Quoted 6 lines · Jeff Garzik
arch/ia64/Kconfig +0 -0
index db185f3..d51f0f1 100644
@@ -22,6 +22,7 @@ config IA64
 
Quoted 6 lines

arch/ia64/Kconfig config IA64 · line 26

Quoted 4 lines
arch/ia64/Kconfig +1 -0
 config 64BIT
 	bool
+	select ATA_NONSTANDARD if ATA
 	default y

Ok, this is just _strange_.

Agreed.

Quoted 1 line

Tying ATA_NONSTANDARD into ia64 by tying it to the 64BIT config variable may work (well, I _assume_ it does), but it's just psychedelic.

AFAICT it's an attempt to do an unconditional 'select'. I'm /not/ disputing its psychedilic properties, certainly, just figured that was the way that IA64 arch folks did stuff like this.

Quoted 9 lines

How about adding a separate config entry like

config IA64_ATA
bool
depends on ATA
select ATA_NONSTANDARD
default y

which kind of makes sense when you squint just the right way..

Either way, that seems sane to me. I'd love to have some IA64 folks to comment though.

Jeff

#7 lore raw
In reply to Linus Torvalds
Quoted 22 lines · Linus Torvalds

arch/ia64/Kconfig config IA64 · line 26

Quoted 11 lines · Jeff Garzik
arch/ia64/Kconfig +1 -0
index db185f3..d51f0f1 100644
@@ -22,6 +22,7 @@ config IA64
 
 config 64BIT
 	bool
+	select ATA_NONSTANDARD if ATA
 	default y

Ok, this is just _strange_.

Tying ATA_NONSTANDARD into ia64 by tying it to the 64BIT config variable may work (well, I _assume_ it does), but it's just psychedelic.

How about adding a separate config entry like

Quoted 7 lines

config IA64_ATA
bool
depends on ATA
select ATA_NONSTANDARD
default y

which kind of makes sense when you squint just the right way..

What about simply providing asm/libata-portmap.h on all architectures instead of this ATA_NONSTANDARD trickery?

Quoted 1 line

Linus

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#2 lore raw

PATCH 1/1 libata: test major version in ata_id_is_sata()

In reply to Jeff Garzik

Test major version in ata_id_is_sata() not separately.

include/linux/ata.h +6 -2
index 272736e..c331da2 100644
@@ -282,7 +282,6 @@ struct ata_taskfile {
 };
 
 #define ata_id_is_ata(id)	(((id)[0] & (1 << 15)) == 0)
-#define ata_id_is_sata(id)	((id)[93] == 0)
 #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
 #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
 #define ata_id_hpa_enabled(id)	((id)[85] & (1 << 10))
@@ -324,6 +323,11 @@ static inline unsigned int ata_id_major_version(const u16 *id)
 	return mver;
 }
 
+static inline int ata_id_is_sata(const u16 *id)
+{
+	return ata_id_major_version(id) >= 5 && id[93] == 0;
+}
+
 static inline int ata_id_current_chs_valid(const u16 *id)
 {
 	/* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
@@ -350,7 +354,7 @@ static inline int ata_id_is_cfa(const u16 *id)
 
 static inline int ata_drive_40wire(const u16 *dev_id)
 {
-	if (ata_id_major_version(dev_id) >= 5 && ata_id_is_sata(dev_id))
+	if (ata_id_is_sata(dev_id))
 		return 0;	/* SATA */
 	if ((dev_id[93] & 0xE000) == 0x6000)
 		return 0;	/* 80 wire */
author Applied
#3 lore raw

Re: [PATCH] libata: test major version in ata_id_is_sata()

Quoted 3 lines · Tejun Heo

Test major version in ata_id_is_sata() not separately.

applied