Skip to contentSkip to conversation

libata: implement libata.force_cbl parameter

PATCH In review Tejun Heo 2 participants 7 messages Jan 8, 2008 – Jan 9, 2008 libata

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 libata: implement libata.force_cbl parameter

Implement libata.force_cbl parameter to work around incorrect PATA cable detection.

---
Sledgehammer for just-in-case. Feel free to include or ignore.

 drivers/ata/libata-core.c |    4 ++++
 drivers/ata/libata-eh.c   |   20 +++++++++++++++++++-
 drivers/ata/libata.h      |    1 +
 3 files changed, 24 insertions(+), 1 deletion(-)
drivers/ata/libata-core.c +4 -0
Index: linux-2.6.22-SL103_BRANCH/drivers/ata/libata-core.c
===================================================================
@@ -110,6 +110,10 @@ int libata_noacpi = 1;
 module_param_named(noacpi, libata_noacpi, int, 0444);
 MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set");
 
+int libata_force_cbl = 0;
+module_param_named(force_cbl, libata_force_cbl, int, 0644);
+MODULE_PARM_DESC(force_cbl, "force PATA cable type (0=keep, 40=40c, 80=80c)");
+
 MODULE_AUTHOR("Jeff Garzik");
 MODULE_DESCRIPTION("Library module for ATA devices");
 MODULE_LICENSE("GPL");
drivers/ata/libata-eh.c +19 -1
Index: linux-2.6.22-SL103_BRANCH/drivers/ata/libata-eh.c
===================================================================
@@ -2165,9 +2165,27 @@ static int ata_eh_revalidate_and_attach(
 
 	/* PDIAG- should have been released, ask cable type if post-reset */
 	if (ata_is_host_link(link) && ap->ops->cable_detect &&
-	    (ehc->i.flags & ATA_EHI_DID_RESET))
+	    (ehc->i.flags & ATA_EHI_DID_RESET)) {
 		ap->cbl = ap->ops->cable_detect(ap);
 
+		if (!(ap->flags & ATA_FLAG_SATA) && libata_force_cbl) {
+			switch (libata_force_cbl) {
+			case 40:
+				ata_port_printk(ap, KERN_INFO, "forcing 40c\n");
+				ap->cbl = ATA_CBL_PATA40;
+				break;
+			case 80:
+				ata_port_printk(ap, KERN_INFO, "forcing 80c\n");
+				ap->cbl = ATA_CBL_PATA80;
+				break;
+			default:
+				ata_port_printk(ap, KERN_WARNING,
+						"invalid force_cbl value %d\n",
+						libata_force_cbl);
+			}
+		}
+	}
+
 	/* Configure new devices forward such that user doesn't see
 	 * device detection messages backwards.
 	 */
drivers/ata/libata.h +1 -0
Index: linux-2.6.22-SL103_BRANCH/drivers/ata/libata.h
===================================================================
@@ -59,6 +59,7 @@ extern int atapi_dmadir;
 extern int atapi_passthru16;
 extern int libata_fua;
 extern int libata_noacpi;
+extern int libata_force_cbl;
 extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
 extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
 			   u64 block, u32 n_block, unsigned int tf_flags,
#1 lore raw
Quoted 2 lines · On Tue, 08 Jan 2008 22:19:38 +0900 Tejun Heo <[email protected]> wrote:

Implement libata.force_cbl parameter to work around incorrect PATA cable detection.

This seems to be a pretty hopeless hack as it assumes all your devices are on the same cable (most boxes now have SATA and PATA). If we are going to do this we need a way to specify which controller/device as we will do for geometry forcing and other stuff.

Alan

author
#2 lore raw
Quoted 10 lines · Alan Cox
Quoted 2 lines · On Tue, 08 Jan 2008 22:19:38 +0900 Tejun Heo <[email protected]> wrote:

Implement libata.force_cbl parameter to work around incorrect PATA cable detection.

This seems to be a pretty hopeless hack as it assumes all your devices are on the same cable (most boxes now have SATA and PATA). If we are going to do this we need a way to specify which controller/device as we will do for geometry forcing and other stuff.

This only forces PATA controllers to certain cable type. It's a last resort method for installation or live media - just enough to get things going.

Signature · 1 line
tejun
#3 lore raw
Quoted 3 lines

This only forces PATA controllers to certain cable type. It's a last resort method for installation or live media - just enough to get things going.

In which case we only need to be able to force UDMA33 or less ?

author
#4 lore raw
Quoted 5 lines · Alan Cox
Quoted 3 lines

This only forces PATA controllers to certain cable type. It's a last resort method for installation or live media - just enough to get things going.

In which case we only need to be able to force UDMA33 or less ?

Cable detection goes wrong and 40c is detected as 80c. However, we got (un)lucky and all PIO and short transfers succeed however when large UDMA transfer starts, the drive detects transmission error and unfortunately does the right thing - reports transmission error via check sense. libata EH currently doesn't analyze sense data and simplify passes it to sr. sr knows transmission failure occurred but there isn't much it can do.

Signature · 1 line
tejun
#5 lore raw
Quoted 3 lines
Quoted 1 line

In which case we only need to be able to force UDMA33 or less ?

Cable detection goes wrong and 40c is detected as 80c. However, we got

In which case we only (see first question). I don't see why we need to force anything but "max speed UDMA 33"

author
#6 lore raw
Quoted 5 lines · Alan Cox
Quoted 2 lines
Quoted 1 line

In which case we only need to be able to force UDMA33 or less ?

Cable detection goes wrong and 40c is detected as 80c. However, we got

In which case we only (see first question). I don't see why we need to force anything but "max speed UDMA 33"

Ah.. yeah, right. I somehow missed the negation in the question. There's no need to force 80c usually. The parameter might be as well force_40c and only force 40c limit.

Signature · 1 line
tejun