Skip to contentSkip to conversation

correct - I hope - check for HPA and LBA48

PATCH New [email protected] 1 participant 1 message Aug 7, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 correct - I hope - check for HPA and LBA48

I remember that it is necessary to check whether the words containing the HPA and LBA48 bits are valid before looking at these bits. This improves things for at least one disk. But there is much buggy hardware out there - this may also break some things. Not to be applied (yet) to stable kernels.

Andries

drivers/ide/ide-disk.c +7 -10
diff -u --recursive --new-file -X /linux/dontdiff a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
@@ -1080,24 +1080,21 @@
 	return (id->capability & 2);
 }
 
-/*
- * Bits 10 of command_set_1 and cfs_enable_1 must be equal,
- * so on non-buggy drives we need test only one.
- * However, we should also check whether these fields are valid.
- */
 static inline int
 idedisk_supports_host_protected_area(const struct hd_driveid *id)
 {
-	return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400);
+	return (id->command_set_2 & 0xc000) == 0x4000 /* words 82-83 valid */
+		&& (id->command_set_1 & 0x0400)	      /* HPA supported */
+		&& (id->csf_default & 0xc000) == 0x4000 /* wds 85-87 valid */
+		&& (id->cfs_enable_1 & 0x0400);       /* HPA enabled */
 }
 
-/*
- * The same here.
- */
 static inline int
 idedisk_supports_lba48(const struct hd_driveid *id)
 {
-	return (id->command_set_2 & 0x0400) && (id->cfs_enable_2 & 0x0400);
+	return (id->command_set_2 & 0xc400) == 0x4400 /* LBA48 supported */
+		&& (id->csf_default & 0xc000) == 0x4000 /* wds 85-87 valid */
+		&& (id->cfs_enable_2 & 0x0400);       /* LBA48 enabled */
 }
 
 static inline unsigned long long