linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Albert Lee <albertcc@tw.ibm.com>
To: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	Linux IDE <linux-ide@vger.kernel.org>,
	Doug Maxey <dwm@maxeymade.com>
Subject: Re: [PATCH 2/4] if condition fix for __atapi_pio_bytes()
Date: Thu, 09 Jun 2005 12:05:34 +0800	[thread overview]
Message-ID: <42A7C00E.3070600@tw.ibm.com> (raw)
In-Reply-To: <58cb370e05060806334c997daa@mail.gmail.com>

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



Bartlomiej Zolnierkiewicz wrote:

> 
> Another idea - move rounding just before ata_data_xfer() so 'count' will stay 
> rounded only for the duration of ata_data_xfer() ('count' is reset for
> every sg)
> and we won't have to worry about sg->length and 'bytes'.
> 
> Or just leave it as it is and reorder patches... :).
> 
> 

Hi Bart,

How about moving the odd length rounding up code to ata_mmio_data_xfer() and ata_pio_data_xfer()?
It seems this can make the code of patch #4 simplified.
Also we can change the rounding in the trailing data handling code
from 'words = (bytes + 1)>> 1 ' to 'words = bytes >> 1'.

Ex. If bytes is 52, and buffer length is 51,
     ata_data_xfer() will be called with 51.
     ata_data_xfer() will actually transfer 52 bytes.

     1 byte left for the trailing data handling. Since
we know ata_data_xfer() round up one more byte, so in the trailing data handling code,
we can safely round down one less byte by 'words = bytes >> 1'.


Attached please find the revised patch #3 and #4 for your review.


Albert

[-- Attachment #2: 04_odd_data.diff --]
[-- Type: text/plain, Size: 741 bytes --]

--- 13_atapi_pio_trailing_data_handling/drivers/scsi/libata-core.c	2005-06-09 11:05:10.000000000 +0800
+++ 14_atapi_pio_odd_handling/drivers/scsi/libata-core.c	2005-06-09 11:04:09.000000000 +0800
@@ -2491,7 +2491,7 @@
 			       unsigned int buflen, int write_data)
 {
 	unsigned int i;
-	unsigned int words = buflen >> 1;
+	unsigned int words = (buflen+1) >> 1;
 	u16 *buf16 = (u16 *) buf;
 	void __iomem *mmio = (void __iomem *)ap->ioaddr.data_addr;
 
@@ -2507,7 +2507,7 @@
 static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
 			      unsigned int buflen, int write_data)
 {
-	unsigned int dwords = buflen >> 1;
+	unsigned int dwords = (buflen+1) >> 1;
 
 	if (write_data)
 		outsw(ap->ioaddr.data_addr, buf, dwords);

[-- Attachment #3: 03_trailing_data.diff --]
[-- Type: text/plain, Size: 738 bytes --]

--- 12_atapi_pio_if_condition_fix/drivers/scsi/libata-core.c	2005-06-06 13:52:11.000000000 +0800
+++ 13_atapi_pio_trailing_data_handling/drivers/scsi/libata-core.c	2005-06-09 11:05:10.000000000 +0800
@@ -2575,6 +2575,23 @@
 		ap->pio_task_state = PIO_ST_LAST;
 
 next_sg:
+	/* check whether qc->sg is full */
+	if (unlikely(qc->cursg >= qc->n_elem)) {
+		unsigned char pad_buf[2];
+		unsigned int words = bytes >> 1;
+		unsigned int i;
+
+		DPRINTK("ata%u: padding %u bytes\n", ap->id, bytes);
+
+		memset(&pad_buf, 0, sizeof(pad_buf));
+		for (i = 0; i < words; i++) {
+			ata_data_xfer(ap, pad_buf, sizeof(pad_buf), do_write);
+		}
+
+		ap->pio_task_state = PIO_ST_LAST;
+		return;
+	}
+
 	sg = &qc->sg[qc->cursg];
 
 	page = sg->page;

  reply	other threads:[~2005-06-09  4:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-06  7:47 [PATCH 0/4] Resubmit ATAPI PIO mode fixes Albert Lee
2005-06-06  7:56 ` [PATCH 1/4] sg traverse fix for __atapi_pio_bytes() Albert Lee
2005-06-06  9:24   ` Bartlomiej Zolnierkiewicz
2005-06-06  7:58 ` [PATCH 2/4] if condition " Albert Lee
2005-06-06  9:32   ` Bartlomiej Zolnierkiewicz
2005-06-08  3:47     ` Albert Lee
2005-06-08  9:48       ` Bartlomiej Zolnierkiewicz
2005-06-08 11:58         ` Albert Lee
2005-06-08 13:33           ` Bartlomiej Zolnierkiewicz
2005-06-09  4:05             ` Albert Lee [this message]
2005-06-09  6:54               ` Bartlomiej Zolnierkiewicz
2005-06-08 13:39           ` Bartlomiej Zolnierkiewicz
2005-06-06  7:59 ` [PATCH 3/4] trailing data handling " Albert Lee
2005-06-06  9:37   ` Bartlomiej Zolnierkiewicz
2005-06-06  8:01 ` [PATCH 4/4] odd length data handling " Albert Lee
2005-06-06  9:39   ` Bartlomiej Zolnierkiewicz
     [not found] ` <42A7ED91.4090008@pobox.com>
2005-06-10  6:08   ` [PATCH 0/4] Resubmit ATAPI PIO mode fixes Albert Lee
2005-06-10  7:38   ` [PATCH 2/4] libata: if condition fix for __atapi_pio_bytes() Albert Lee
2005-06-10  7:56     ` Bartlomiej Zolnierkiewicz
2005-06-10  8:31       ` Albert Lee
2005-06-10  7:44   ` [PATCH 3/4] libata: trailing data handling " Albert Lee
2005-06-10  7:46   ` [PATCH 4/4] libata: odd length data handling " 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=42A7C00E.3070600@tw.ibm.com \
    --to=albertcc@tw.ibm.com \
    --cc=bzolnier@gmail.com \
    --cc=dwm@maxeymade.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).