mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andries.Brouwer@cwi.nl
To: B.Zolnierkiewicz@elka.pw.edu.pl
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] correct - I hope - check for HPA and LBA48
Date: Thu, 7 Aug 2003 22:17:24 +0200 (MEST)	[thread overview]
Message-ID: <UTC200308072017.h77KHOl02587.aeb@smtp.cwi.nl> (raw)

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

diff -u --recursive --new-file -X /linux/dontdiff a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
--- a/drivers/ide/ide-disk.c	Thu Aug  7 22:08:22 2003
+++ b/drivers/ide/ide-disk.c	Thu Aug  7 22:42:27 2003
@@ -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

                 reply	other threads:[~2003-08-07 20:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=UTC200308072017.h77KHOl02587.aeb@smtp.cwi.nl \
    --to=andries.brouwer@cwi.nl \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®