linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Albert Lee <albertcc@tw.ibm.com>
Cc: Jeff Garzik <jgarzik@pobox.com>, Linux IDE <linux-ide@vger.kernel.org>
Subject: [PATCH 1/4] CHS: move the initialization of taskfile LBA flags (revise #6)
Date: Wed, 12 Oct 2005 15:04:18 +0800	[thread overview]
Message-ID: <434CB572.6060900@tw.ibm.com> (raw)
In-Reply-To: <434CAF8E.5040607@tw.ibm.com>

Patch 1/4:

   move the initialization of taskfile LBA flags
     "ATA_TFLAG_LBA" and "ATA_TFLAG_LBA48 flags"
   to the SCSI translation functions

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>

=============

--- upstream/drivers/scsi/libata-core.c	2005-10-11 11:40:03.000000000 +0800
+++ ch1/drivers/scsi/libata-core.c	2005-10-11 12:44:53.000000000 +0800
@@ -3195,13 +3195,6 @@ struct ata_queued_cmd *ata_qc_new_init(s
 		qc->nbytes = qc->curbytes = 0;
 
 		ata_tf_init(ap, &qc->tf, dev->devno);
-
-		if (dev->flags & ATA_DFLAG_LBA) {
-			qc->tf.flags |= ATA_TFLAG_LBA;
-
-			if (dev->flags & ATA_DFLAG_LBA48)
-				qc->tf.flags |= ATA_TFLAG_LBA48;
-		}
 	}
 
 	return qc;
--- upstream/drivers/scsi/libata-scsi.c	2005-10-11 11:40:03.000000000 +0800
+++ ch1/drivers/scsi/libata-scsi.c	2005-10-11 12:53:36.000000000 +0800
@@ -492,7 +492,7 @@ static unsigned int ata_scsi_flush_xlat(
 	tf->flags |= ATA_TFLAG_DEVICE;
 	tf->protocol = ATA_PROT_NODATA;
 
-	if ((tf->flags & ATA_TFLAG_LBA48) &&
+	if ((qc->dev->flags & ATA_DFLAG_LBA48) &&
 	    (ata_id_has_flush_ext(qc->dev->id)))
 		tf->command = ATA_CMD_FLUSH_EXT;
 	else
@@ -612,8 +612,6 @@ static unsigned int ata_scsi_verify_xlat
 {
 	struct ata_taskfile *tf = &qc->tf;
 	struct ata_device *dev = qc->dev;
-	unsigned int lba   = tf->flags & ATA_TFLAG_LBA;
-	unsigned int lba48 = tf->flags & ATA_TFLAG_LBA48;
 	u64 dev_sectors = qc->dev->n_sectors;
 	u64 block;
 	u32 n_block;
@@ -634,16 +632,16 @@ static unsigned int ata_scsi_verify_xlat
 		goto out_of_range;
 	if ((block + n_block) > dev_sectors)
 		goto out_of_range;
-	if (lba48) {
-		if (n_block > (64 * 1024))
-			goto invalid_fld;
-	} else {
-		if (n_block > 256)
-			goto invalid_fld;
-	}
 
-	if (lba) {
-		if (lba48) {
+	if (dev->flags & ATA_DFLAG_LBA) {
+		tf->flags |= ATA_TFLAG_LBA;
+
+		if (dev->flags & ATA_DFLAG_LBA48) {
+			if (n_block > (64 * 1024))
+				goto invalid_fld;
+
+			/* use LBA48 */
+			tf->flags |= ATA_TFLAG_LBA48;
 			tf->command = ATA_CMD_VERIFY_EXT;
 
 			tf->hob_nsect = (n_block >> 8) & 0xff;
@@ -652,6 +650,10 @@ static unsigned int ata_scsi_verify_xlat
 			tf->hob_lbam = (block >> 32) & 0xff;
 			tf->hob_lbal = (block >> 24) & 0xff;
 		} else {
+			if (n_block > 256)
+				goto invalid_fld;
+
+			/* use LBA28 */
 			tf->command = ATA_CMD_VERIFY;
 
 			tf->device |= (block >> 24) & 0xf;
@@ -668,6 +670,9 @@ static unsigned int ata_scsi_verify_xlat
 		/* CHS */
 		u32 sect, head, cyl, track;
 
+		if (n_block > 256)
+			goto invalid_fld;
+
 		/* Convert LBA to CHS */
 		track = (u32)block / dev->sectors;
 		cyl   = track / dev->heads;
@@ -733,8 +738,6 @@ static unsigned int ata_scsi_rw_xlat(str
 {
 	struct ata_taskfile *tf = &qc->tf;
 	struct ata_device *dev = qc->dev;
-	unsigned int lba   = tf->flags & ATA_TFLAG_LBA;
-	unsigned int lba48 = tf->flags & ATA_TFLAG_LBA48;
 	u64 block;
 	u32 n_block;
 
@@ -783,19 +786,24 @@ static unsigned int ata_scsi_rw_xlat(str
 		 */
 		goto nothing_to_do;
 
-	if (lba) {
-		if (lba48) {
+	if (dev->flags & ATA_DFLAG_LBA) {
+		tf->flags |= ATA_TFLAG_LBA;
+
+		if (dev->flags & ATA_DFLAG_LBA48) {
 			/* The request -may- be too large for LBA48. */
 			if ((block >> 48) || (n_block > 65536))
 				goto out_of_range;
 
+			/* use LBA48 */
+			tf->flags |= ATA_TFLAG_LBA48;
+
 			tf->hob_nsect = (n_block >> 8) & 0xff;
 
 			tf->hob_lbah = (block >> 40) & 0xff;
 			tf->hob_lbam = (block >> 32) & 0xff;
 			tf->hob_lbal = (block >> 24) & 0xff;
 		} else { 
-			/* LBA28 */
+			/* use LBA28 */
 
 			/* The request -may- be too large for LBA28. */
 			if ((block >> 28) || (n_block > 256))





  reply	other threads:[~2005-10-12  7:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-12  6:39 [PATCH 0/4] libata: CHS follow-up patches (revise #6) Albert Lee
2005-10-12  7:04 ` Albert Lee [this message]
2005-10-18 21:16   ` [PATCH 1/4] CHS: move the initialization of taskfile LBA flags " Jeff Garzik
2005-10-12  7:06 ` [PATCH 2/4] CHS: calculate read/write commands and protocol on the fly " Albert Lee
2005-10-12  7:12 ` [PATCH 4/4] CHS: LBA28/LBA48 optimization " Albert Lee
2005-10-18 21:19   ` Jeff Garzik

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=434CB572.6060900@tw.ibm.com \
    --to=albertcc@tw.ibm.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@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;
as well as URLs for NNTP newsgroup(s).