Skip to contentSkip to conversation

libata: fix drive side 80c cable check

PATCH In review Tejun Heo 4 participants 10 messages Feb 5, 2007 – Jul 13, 2007 libata

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 libata: fix drive side 80c cable check

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix it.

---
Please consider for -stable. This bug has been copied from ide and it's just amazing how long this has gone unnoticed. Will post separate patch for ide.

 include/linux/ata.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ata.h +1 -1
Index: work/include/linux/ata.h
===================================================================
@@ -347,7 +347,7 @@ static inline int ata_drive_40wire(const
 {
 	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] & (1 << 13))
 		return 0;	/* 80 wire */
 	return 1;
 }
#1 lore raw
Quoted 4 lines · On Mon, 5 Feb 2007 16:45:35 +0900 Tejun Heo <[email protected]> wrote:

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix it.

NAK to the fix but not the report

We must check bits 15 and 14 to know if bit 13 is valid. The old code is wrong (follows the old IDE bits) but your change is probably no better as you remove the needed validity check.

	if ((dev_id[93] & 0xC000) == 0x4000) && (dev_id[93] & 0x2000))
		return 0;

Alan

author
#2 lore raw

PATCH 1/1 libata: fix drive side 80c cable check, take 2

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix the test and add word93 validity check.

---
Thanks for pointing out, fixed accordingly.

include/linux/ata.h +1 -1
index 1df9416..ea2d597 100644
@@ -347,7 +347,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] & 0xC000) == 0x4000 && (dev_id[93] & 0x2000))
 		return 0;	/* 80 wire */
 	return 1;
 }
Acked-by Alan Cox on v1 1/1
#3 lore raw

Re: [PATCH libata-dev#upstream-fixes] libata: fix drive side 80c cable check, take 2

Quoted 9 lines · On Mon, 5 Feb 2007 21:41:06 +0900 Tejun Heo <[email protected]> wrote:

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix the test and add word93 validity check.

---
Thanks for pointing out, fixed accordingly.

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

Quoted 4 lines
include/linux/ata.h +1 -1
-	if (dev_id[93] & 0x4000)
+	if ((dev_id[93] & 0xC000) == 0x4000 && (dev_id[93] & 0x2000))
 		return 0;	/* 80 wire */
 	return 1;

Can we do

	if ((dev_id[93] & 0xE000) == 0x6000)
author
#4 lore raw

PATCH 1/1 libata: fix drive side 80c cable check, take 3

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix the test and add word93 validity check.

---
Sure, updated as suggested.

include/linux/ata.h +1 -1
index 1df9416..939be94 100644
@@ -347,7 +347,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;
 }
Acked-by Alan Cox on v1 1/1
#5 lore raw

Re: [PATCH libata-dev#upstream-fixes] libata: fix drive side 80c cable check, take 3

Quoted 9 lines · On Mon, 5 Feb 2007 23:21:19 +0900 Tejun Heo <[email protected]> wrote:

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix the test and add word93 validity check.

---
Sure, updated as suggested.

Applied
#6 lore raw

Re: [PATCH libata-dev#upstream-fixes] libata: fix drive side 80c cable check, take 3

In reply to Tejun Heo
Quoted 15 lines · Tejun Heo

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix the test and add word93 validity check.

---
Sure, updated as suggested.

include/linux/ata.h +0 -0
index 1df9416..939be94 100644

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

Quoted 6 lines
include/linux/ata.h +1 -1
@@ -347,7 +347,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 */

applied

#7 lore raw

Re: [PATCH libata-dev#upstream-fixes] libata: fix drive side 80c cable check, take 3

In reply to Tejun Heo
Quoted 13 lines · Tejun Heo

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix the test and add word93 validity check.

include/linux/ata.h +0 -0
index 1df9416..939be94 100644

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

Quoted 8 lines
include/linux/ata.h +1 -1
@@ -347,7 +347,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;
 }

Wrong, wrong as well! The correct value to compare with would be 0x4000.

MBR, Sergei

#8 lore raw

Re: [PATCH libata-dev#upstream-fixes] libata: fix drive side 80c cable check, take 3

Quoted 8 lines · Hello, I wrote:
Quoted 7 lines

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is implemented. This increases the chance of incorrect wire detection especially because host side cable detection is often unreliable and we sometimes soley depend on drive side cable detection. Fix the test and add word93 validity check.

Quoted 15 lines

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

Quoted 13 lines
include/linux/ata.h +1 -1
index 1df9416..939be94 100644
@@ -347,7 +347,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;
 }

Wrong, wrong as well! The correct value to compare with would be 0x4000.

Sorry for the false alarm -- those opposite senses on CBLID- have really
confused me. :-<

MBR, Sergei

author
#9 lore raw

Re: [PATCH libata-dev#upstream-fixes] libata: fix drive side 80c cable check, take 3

Quoted 5 lines · Sergei Shtylyov
Quoted 2 lines

Wrong, wrong as well! The correct value to compare with would be
0x4000.

Sorry for the false alarm -- those opposite senses on CBLID- have
really confused me. :-<

Yeah, all those cable detection mess plays tricks on minds. PATA is really screwed up in that area.

Signature · 1 line
tejun