All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert Lee <albertcc@tw.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	Linux IDE <linux-ide@vger.kernel.org>,
	Doug Maxey <dwm@maxeymade.com>, Tejun Heo <htejun@gmail.com>,
	Mark Lord <mlord@pobox.com>, Brett Russ <russb@emc.com>
Subject: [PATCH/RFC 4/4] irq-pio: add read/write multiple support
Date: Mon, 03 Oct 2005 21:19:50 +0800	[thread overview]
Message-ID: <43412FF6.5030006@tw.ibm.com> (raw)
In-Reply-To: <43411A1A.8050901@tw.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

Patch 4/4: add read/write multiple support

Changes:
    - add ATA_CMD_READ_MULTI, etc. to ata.h
    - add multi_count to ata_device and initialize it with device 
identify data
    - merge ata_prot_to_cmd() with ata_dev_set_protocol()
    - ata_pio_complete(): change the wait condition from (ATA_BUSY | 
ATA_DRQ) to ATA_BUSY
    - add ata_pio_sectors() to support r/w multiple commands
    - ata_pio_block(): add ata_altstatus(ap) to prevent reading device 
status before it is valid


For your review, thanks.

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


[-- Attachment #2: idpio4.diff --]
[-- Type: text/plain, Size: 6509 bytes --]

--- irq-pio/include/linux/ata.h	2005-09-30 10:00:30.000000000 +0800
+++ id8/include/linux/ata.h	2005-10-03 13:54:52.000000000 +0800
@@ -128,6 +128,10 @@ enum {
 	ATA_CMD_PIO_READ_EXT	= 0x24,
 	ATA_CMD_PIO_WRITE	= 0x30,
 	ATA_CMD_PIO_WRITE_EXT	= 0x34,
+	ATA_CMD_READ_MULTI	= 0xC4,
+	ATA_CMD_READ_MULTI_EXT	= 0x29,
+	ATA_CMD_WRITE_MULTI	= 0xC5,
+	ATA_CMD_WRITE_MULTI_EXT	= 0x39,
 	ATA_CMD_SET_FEATURES	= 0xEF,
 	ATA_CMD_PACKET		= 0xA0,
 	ATA_CMD_VERIFY		= 0x40,
@@ -270,6 +274,14 @@ static inline int is_atapi_taskfile(stru
 	       (tf->protocol == ATA_PROT_ATAPI_DMA);
 }
 
+static inline int is_multi_taskfile(struct ata_taskfile *tf)
+{
+	return (tf->command == ATA_CMD_READ_MULTI) ||
+	       (tf->command == ATA_CMD_WRITE_MULTI) ||
+	       (tf->command == ATA_CMD_READ_MULTI_EXT) ||
+	       (tf->command == ATA_CMD_WRITE_MULTI_EXT);
+}
+
 static inline int ata_ok(u8 status)
 {
 	return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR))
--- id6/include/linux/libata.h	2005-10-03 10:18:29.000000000 +0800
+++ id8/include/linux/libata.h	2005-10-03 13:56:29.000000000 +0800
@@ -285,6 +285,8 @@ struct ata_device {
 	u8			xfer_protocol;	/* taskfile xfer protocol */
 	u8			read_cmd;	/* opcode to use on read */
 	u8			write_cmd;	/* opcode to use on write */
+	unsigned int		multi_count;	/* sectors count for
+						   READ/WRITE MULTIPLE */
 };
 
 struct ata_port {
--- id7/drivers/scsi/libata-core.c	2005-10-03 12:39:03.000000000 +0800
+++ id8/drivers/scsi/libata-core.c	2005-10-03 18:33:26.000000000 +0800
@@ -616,49 +616,6 @@ void ata_tf_from_fis(u8 *fis, struct ata
 }
 
 /**
- *	ata_prot_to_cmd - determine which read/write opcodes to use
- *	@protocol: ATA_PROT_xxx taskfile protocol
- *	@lba48: true is lba48 is present
- *
- *	Given necessary input, determine which read/write commands
- *	to use to transfer data.
- *
- *	LOCKING:
- *	None.
- */
-static int ata_prot_to_cmd(int protocol, int lba48)
-{
-	int rcmd = 0, wcmd = 0;
-
-	switch (protocol) {
-	case ATA_PROT_PIO:
-		if (lba48) {
-			rcmd = ATA_CMD_PIO_READ_EXT;
-			wcmd = ATA_CMD_PIO_WRITE_EXT;
-		} else {
-			rcmd = ATA_CMD_PIO_READ;
-			wcmd = ATA_CMD_PIO_WRITE;
-		}
-		break;
-
-	case ATA_PROT_DMA:
-		if (lba48) {
-			rcmd = ATA_CMD_READ_EXT;
-			wcmd = ATA_CMD_WRITE_EXT;
-		} else {
-			rcmd = ATA_CMD_READ;
-			wcmd = ATA_CMD_WRITE;
-		}
-		break;
-
-	default:
-		return -1;
-	}
-
-	return rcmd | (wcmd << 8);
-}
-
-/**
  *	ata_dev_set_protocol - set taskfile protocol and r/w commands
  *	@dev: device to examine and configure
  *
@@ -675,19 +632,42 @@ static void ata_dev_set_protocol(struct 
 {
 	int pio = (dev->flags & ATA_DFLAG_PIO);
 	int lba48 = (dev->flags & ATA_DFLAG_LBA48);
-	int proto, cmd;
+	int rcmd, wcmd;
 
-	if (pio)
-		proto = dev->xfer_protocol = ATA_PROT_PIO;
-	else
-		proto = dev->xfer_protocol = ATA_PROT_DMA;
+	if (pio) {
+		dev->xfer_protocol = ATA_PROT_PIO;
 
-	cmd = ata_prot_to_cmd(proto, lba48);
-	if (cmd < 0)
-		BUG();
+		if (dev->multi_count) {
+			if (lba48) {
+				rcmd = ATA_CMD_READ_MULTI_EXT;
+				wcmd = ATA_CMD_WRITE_MULTI_EXT;
+			} else {
+				rcmd = ATA_CMD_READ_MULTI;
+				wcmd = ATA_CMD_WRITE_MULTI;
+			}
+		} else {
+			if (lba48) {
+				rcmd = ATA_CMD_PIO_READ_EXT;
+				wcmd = ATA_CMD_PIO_WRITE_EXT;
+			} else {
+				rcmd = ATA_CMD_PIO_READ;
+				wcmd = ATA_CMD_PIO_WRITE;
+			}
+		}
+	} else {
+		dev->xfer_protocol = ATA_PROT_DMA;
+
+		if (lba48) {
+			rcmd = ATA_CMD_READ_EXT;
+			wcmd = ATA_CMD_WRITE_EXT;
+		} else {
+			rcmd = ATA_CMD_READ;
+			wcmd = ATA_CMD_WRITE;
+		}
+	}
 
-	dev->read_cmd = cmd & 0xff;
-	dev->write_cmd = (cmd >> 8) & 0xff;
+	dev->read_cmd = rcmd;
+	dev->write_cmd = wcmd;
 }
 
 static const char * xfer_mode_str[] = {
@@ -1269,6 +1249,12 @@ retry:
 			dev->n_sectors = ata_id_u32(dev->id, 60);
 		}
 
+		if (dev->id[59] & 0x100) {
+			dev->multi_count = dev->id[59] & 0xff;
+			DPRINTK("ata%u: dev %u multi count %u\n",
+				ap->id, device, dev->multi_count);
+		}
+
 		ap->host->max_cmd_len = 16;
 
 		/* print device info to dmesg */
@@ -2483,13 +2469,13 @@ static int ata_pio_complete (struct ata_
 	 * we enter, BSY will be cleared in a chk-status or two.  If not,
 	 * the drive is probably seeking or something.  Snooze for a couple
 	 * msecs, then chk-status again.  If still busy, fall back to
-	 * HSM_ST_POLL state.
+	 * HSM_ST_LAST_POLL state.
 	 */
-	drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
-	if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
+	drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
+	if (drv_stat & ATA_BUSY) {
 		msleep(2);
-		drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
-		if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
+		drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
+		if (drv_stat & ATA_BUSY) {
 			ap->hsm_task_state = HSM_ST_LAST_POLL;
 			ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
 			return 1;
@@ -2697,6 +2683,32 @@ static void ata_pio_sector(struct ata_qu
 }
 
 /**
+ *	ata_pio_sectors - Transfer one or many 512-byte sectors.
+ *	@qc: Command on going
+ *
+ *	Transfer one or many ATA_SECT_SIZE of data from/to the 
+ *	ATA device for the DRQ request.
+ *
+ *	LOCKING:
+ *	Inherited from caller.
+ */
+
+static void ata_pio_sectors(struct ata_queued_cmd *qc)
+{
+	if (is_multi_taskfile(&qc->tf)) {
+		/* READ/WRITE MULTIPLE */
+		unsigned int nsect;
+
+		assert(qc->dev->multi_count);
+
+		nsect = min(qc->nsect - qc->cursect, qc->dev->multi_count);
+		while (nsect--)
+			ata_pio_sector(qc);
+	} else
+		ata_pio_sector(qc);
+}
+
+/**
  *	atapi_send_cdb - Write CDB bytes to hardware
  *	@ap: Port to which ATAPI device is attached.
  *	@qc: Taskfile currently active
@@ -2791,11 +2803,11 @@ static int ata_pio_first_block(struct at
 		 * send first data block.
 		 */
 
-		/* ata_pio_sector() might change the state to HSM_ST_LAST.
-		 * so, the state is changed here before ata_pio_sector().
+		/* ata_pio_sectors() might change the state to HSM_ST_LAST.
+		 * so, the state is changed here before ata_pio_sectors().
 		 */
 		ap->hsm_task_state = HSM_ST;
-		ata_pio_sector(qc);
+		ata_pio_sectors(qc);
 		ata_altstatus(ap); /* flush */
 	} else
 		/* send CDB */
@@ -2995,8 +3007,10 @@ static void ata_pio_block(struct ata_por
 			return;
 		}
 
-		ata_pio_sector(qc);
+		ata_pio_sectors(qc);
 	}
+
+	ata_altstatus(ap); /* flush */
 }
 
 static void ata_pio_error(struct ata_port *ap)
@@ -3932,7 +3946,7 @@ fsm_start:
 				goto fsm_start;
 			}
 
-			ata_pio_sector(qc);
+			ata_pio_sectors(qc);
 
 			if (ap->hsm_task_state == HSM_ST_LAST &&
 			    (!(qc->tf.flags & ATA_TFLAG_WRITE))) {

  parent reply	other threads:[~2005-10-03 13:20 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-09 16:14 [PATCH RFC] libata: interrupt driven pio Albert Lee
2005-09-09 17:35 ` Jeff Garzik
2005-09-09 18:14   ` Doug Maxey
2005-09-22  4:00   ` [PATCH/RFC 0/3] libata: interrupt driven pio (revised) Albert Lee
2005-09-22  4:09     ` [PATCH/RFC 1/3] libata: interrupt driven pio for libata-core Albert Lee
2005-09-23  9:25       ` Albert Lee
2005-09-22  4:11     ` [PATCH/RFC 2/3] libata: rename task states/variables Albert Lee
2005-09-23  9:34       ` Albert Lee
2005-09-22  4:14     ` [PATCH/RFC 3/3] libata: interrupt driven pio for LLD Albert Lee
2005-09-22 12:56       ` Mark Lord
2005-09-23  2:40         ` Albert Lee
2005-09-23  9:46     ` [PATCH/RFC 0/3] libata: interrupt driven pio (revised) Jeff Garzik
2005-09-27  9:31       ` [PATCH/RFC 0/4] libata: interrupt driven pio (revised 2) Albert Lee
2005-09-27  9:34         ` [PATCH/RFC 1/4] libata: indent and whitespace change Albert Lee
2005-09-27  9:36         ` [PATCH/RFC 2/4] libata: rename host states Albert Lee
2005-09-28 15:59           ` Jeff Garzik
2005-09-27  9:38         ` [PATCH/RFC 3/4] libata: interrupt driven pio for libata-core Albert Lee
2005-09-28 16:09           ` Jeff Garzik
2005-09-29 10:08           ` Bartlomiej Zolnierkiewicz
2005-09-30  8:02             ` Albert Lee
2005-09-30  9:28               ` Bartlomiej Zolnierkiewicz
2005-09-30 11:28                 ` Albert Lee
2005-09-30 12:00                   ` Bartlomiej Zolnierkiewicz
2005-09-30 11:04             ` [PATCH/RFC 0/4] libata: irq driven pio follow-up patches Albert Lee
2005-09-30 11:07               ` [PATCH/RFC 1/4] irq-pio: add comments and cleanup Albert Lee
2005-09-30 11:09               ` [PATCH/RFC 2/4] irq-pio: rename atapi_packet_task() and comments Albert Lee
2005-09-30 11:11               ` [PATCH/RFC 3/4] irq-pio: simplify if condition in ata_dataout_task() Albert Lee
2005-09-30 11:14               ` [PATCH/RFC 4/4] irq-pio: cleanup ata_qc_issue_prot() Albert Lee
2005-09-30 11:21               ` [PATCH/RFC 0/4] libata: irq driven pio follow-up patches Jeff Garzik
2005-10-03 11:46                 ` [PATCH/RFC 0/4] libata: more " Albert Lee
2005-10-03 13:00                   ` [PATCH/RFC 1/4] irq-pio: move functions Albert Lee
2005-10-03 13:02                   ` [PATCH/RFC 2/4] irq-pio: remove ap->dataout_task Albert Lee
2005-10-04 10:09                     ` Jeff Garzik
2005-10-04 11:54                       ` Albert Lee
2005-10-03 13:18                   ` [PATCH/RFC 3/4] irq-pio: integrate ata_pio_first_block() with ata_pio_task() Albert Lee
2005-10-04 10:10                     ` Jeff Garzik
2005-10-03 13:19                   ` Albert Lee [this message]
2005-10-03 13:35                     ` [PATCH/RFC 4/4] irq-pio: add read/write multiple support Mark Lord
2005-10-04  9:43                       ` Jeff Garzik
2005-10-04 12:00                         ` Albert Lee
2005-10-04 12:07                           ` Jeff Garzik
2005-10-04 12:22                             ` [PATCH/RFC 0/4] libata: CHS follow-up patches Albert Lee
2005-10-04 12:27                               ` [PATCH/RFC 1/4] CHS: white space beautification Albert Lee
2005-10-04 12:49                                 ` Jeff Garzik
2005-10-04 12:29                               ` [PATCH/RFC 2/4] CHS: tidy up SCSI lba and transfer length calculation Albert Lee
2005-10-04 12:30                               ` [PATCH/RFC 3/4] CHS: add CHS support to ata_scsi_start_stop_xlat() Albert Lee
2005-10-04 12:34                               ` [PATCH/RFC 4/4] CHS: calculate LBA28/LBA48 commands and protocol on the fly Albert Lee
2005-10-04 12:52                                 ` Jeff Garzik
2005-10-05 11:16                                   ` [PATCH/RFC 0/4] libata: more CHS follow-up patches Albert Lee
2005-10-05 11:20                                     ` [PATCH/RFC 1/4] CHS: move the initialization of taskfile LBA flags Albert Lee
2005-10-05 11:23                                     ` [PATCH/RFC 2/4] CHS: calculate read/write commands and protocol on the fly Albert Lee
2005-10-05 11:25                                     ` [PATCH/RFC 3/4] CHS: support overriding the ata_rwcmd_protocol() function Albert Lee
2005-10-05 11:27                                     ` [PATCH/RFC 4/4] CHS: optimize LBA28/LBA48 usage Albert Lee
2005-10-05 11:59                                     ` [PATCH/RFC 1/4] CHS: move the initialization of taskfile LBA flags (resend) Albert Lee
2005-10-05 12:02                                     ` [PATCH/RFC 2/4] CHS: calculate read/write commands and protocol on the fly (resend) Albert Lee
2005-10-05 12:03                                     ` [PATCH/RFC 3/4] CHS: support overriding the ata_rwcmd_protocol() function (resend) Albert Lee
2005-10-05 12:04                                     ` [PATCH/RFC 4/4] CHS: optimize LBA28/LBA48 usage (resend) Albert Lee
2005-10-06 11:26                                     ` [PATCH/RFC 0/4] libata: more CHS follow-up patches Jeff Garzik
2005-10-07  6:53                                       ` [PATCH 0/3] libata: CHS follow-up patches (resend #2) Albert Lee
2005-10-07  6:58                                         ` [PATCH 1/3] CHS: move the initialization of taskfile LBA flags Albert Lee
2005-10-07  7:01                                         ` [PATCH 2/3] CHS: calculate read/write commands and protocol on the fly Albert Lee
2005-10-07  7:04                                         ` [PATCH 3/3] CHS: LBA28/LBA48 optimization Albert Lee
2005-10-07  8:32                                         ` [PATCH 0/3] libata: CHS follow-up patches (resend #4) Albert Lee
2005-10-07  8:34                                           ` [PATCH 1/3] CHS: move the initialization of taskfile LBA flags " Albert Lee
2005-10-07  8:36                                           ` [PATCH 2/3] CHS: calculate read/write commands and protocol on the fly " Albert Lee
2005-10-07  8:37                                           ` [PATCH 3/3] CHS: LBA28/LBA48 optimization " Albert Lee
2005-10-09 13:41                                           ` [PATCH 0/3] libata: CHS follow-up patches " Jeff Garzik
2005-10-11 11:05                                             ` [PATCH 0/4] libata: CHS follow-up patches (resend #5) Albert Lee
2005-10-11 11:09                                               ` [PATCH 1/4] CHS: move the initialization of taskfile LBA flags " Albert Lee
2005-10-11 11:11                                               ` [PATCH 2/4] CHS: calculate read/write commands and protocol on the fly " Albert Lee
2005-10-11 11:21                                               ` [PATCH 4/4] CHS: LBA28/LBA48 optimization " Albert Lee
2005-10-11 13:09                                                 ` Mark Lord
2005-10-11 13:12                                                 ` Mark Lord
2005-10-12  5:05                                                   ` Albert Lee
2005-10-04 15:48                                 ` [PATCH/RFC 4/4] CHS: calculate LBA28/LBA48 commands and protocol on the fly Alan Cox
2005-10-04 10:19                     ` [PATCH/RFC 4/4] irq-pio: add read/write multiple support Jeff Garzik
2005-09-27  9:39         ` [PATCH/RFC 4/4] libata: interrupt driven pio for LLD Albert Lee
  -- strict thread matches above, loose matches on Subject: below --
2005-11-01 11:12 [PATCH/RFC 0/4] libata: more irq driven pio follow-up patches Albert Lee
2005-11-01 11:33 ` [PATCH/RFC 4/4] irq-pio: add read/write multiple support Albert Lee

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=43412FF6.5030006@tw.ibm.com \
    --to=albertcc@tw.ibm.com \
    --cc=bzolnier@gmail.com \
    --cc=dwm@maxeymade.com \
    --cc=htejun@gmail.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=mlord@pobox.com \
    --cc=russb@emc.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.