linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Borislav Petkov <petkovbb@gmail.com>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 01/20] ide: add support for arbitrary transfer lengths to ide_pio_bytes()
Date: Mon, 16 Feb 2009 01:13:16 +0100	[thread overview]
Message-ID: <20090216001316.27491.28672.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090216001309.27491.59759.sendpatchset@localhost.localdomain>

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: add support for arbitrary transfer lengths to ide_pio_bytes()

Add support for arbitrary transfer lengths to ide_pio_bytes()
and then inline ide_pio_multi() into ide_pio_datablock().

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-taskfile.c |   73 ++++++++++++++++++++++-----------------------
 1 file changed, 37 insertions(+), 36 deletions(-)

Index: b/drivers/ide/ide-taskfile.c
===================================================================
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -189,7 +189,7 @@ static u8 wait_drive_not_busy(ide_drive_
 }
 
 static void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd,
-			  unsigned int write, unsigned int nr_bytes)
+			  unsigned int write, unsigned int len)
 {
 	ide_hwif_t *hwif = drive->hwif;
 	struct scatterlist *sg = hwif->sg_table;
@@ -202,56 +202,55 @@ static void ide_pio_bytes(ide_drive_t *d
 	u8 *buf;
 
 	cursg = cmd->cursg;
-	if (!cursg) {
-		cursg = sg;
-		cmd->cursg = sg;
-	}
+	if (cursg == NULL)
+		cursg = cmd->cursg = sg;
+
+	while (len) {
+		unsigned nr_bytes = min(len, cursg->length - cmd->cursg_ofs);
+
+		if (nr_bytes > PAGE_SIZE)
+			nr_bytes = PAGE_SIZE;
 
-	page = sg_page(cursg);
-	offset = cursg->offset + cmd->cursg_ofs;
+		page = sg_page(cursg);
+		offset = cursg->offset + cmd->cursg_ofs;
 
-	/* get the current page and offset */
-	page = nth_page(page, (offset >> PAGE_SHIFT));
-	offset %= PAGE_SIZE;
+		/* get the current page and offset */
+		page = nth_page(page, (offset >> PAGE_SHIFT));
+		offset %= PAGE_SIZE;
 
 #ifdef CONFIG_HIGHMEM
-	local_irq_save(flags);
+		local_irq_save(flags);
 #endif
-	buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
+		buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
 
-	cmd->nleft -= nr_bytes;
-	cmd->cursg_ofs += nr_bytes;
+		cmd->nleft -= nr_bytes;
+		cmd->cursg_ofs += nr_bytes;
 
-	if (cmd->cursg_ofs == cursg->length) {
-		cmd->cursg = sg_next(cmd->cursg);
-		cmd->cursg_ofs = 0;
-	}
+		if (cmd->cursg_ofs == cursg->length) {
+			cursg = cmd->cursg = sg_next(cmd->cursg);
+			cmd->cursg_ofs = 0;
+		}
 
-	/* do the actual data transfer */
-	if (write)
-		hwif->tp_ops->output_data(drive, cmd, buf, nr_bytes);
-	else
-		hwif->tp_ops->input_data(drive, cmd, buf, nr_bytes);
+		/* do the actual data transfer */
+		if (write)
+			hwif->tp_ops->output_data(drive, cmd, buf, nr_bytes);
+		else
+			hwif->tp_ops->input_data(drive, cmd, buf, nr_bytes);
 
-	kunmap_atomic(buf, KM_BIO_SRC_IRQ);
+		kunmap_atomic(buf, KM_BIO_SRC_IRQ);
 #ifdef CONFIG_HIGHMEM
-	local_irq_restore(flags);
+		local_irq_restore(flags);
 #endif
-}
-
-static void ide_pio_multi(ide_drive_t *drive, struct ide_cmd *cmd,
-			  unsigned int write)
-{
-	unsigned int nsect;
 
-	nsect = min_t(unsigned int, cmd->nleft >> 9, drive->mult_count);
-	while (nsect--)
-		ide_pio_bytes(drive, cmd, write, SECTOR_SIZE);
+		len -= nr_bytes;
+	}
 }
 
 static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd,
 			      unsigned int write)
 {
+	unsigned int nr_bytes;
+
 	u8 saved_io_32bit = drive->io_32bit;
 
 	if (cmd->tf_flags & IDE_TFLAG_FS)
@@ -263,9 +262,11 @@ static void ide_pio_datablock(ide_drive_
 	touch_softlockup_watchdog();
 
 	if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO)
-		ide_pio_multi(drive, cmd, write);
+		nr_bytes = min_t(unsigned, cmd->nleft, drive->mult_count << 9);
 	else
-		ide_pio_bytes(drive, cmd, write, SECTOR_SIZE);
+		nr_bytes = SECTOR_SIZE;
+
+	ide_pio_bytes(drive, cmd, write, nr_bytes);
 
 	drive->io_32bit = saved_io_32bit;
 }

  reply	other threads:[~2009-02-16  0:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-16  0:13 [PATCH 00/20] ide-cd: use scatterlists also for PIO transfers Bartlomiej Zolnierkiewicz
2009-02-16  0:13 ` Bartlomiej Zolnierkiewicz [this message]
2009-02-16  0:13 ` [PATCH 02/20] ide: use PageHighMem() instead of ifdefs in ide_pio_bytes() Bartlomiej Zolnierkiewicz
2009-02-16  0:13 ` [PATCH 03/20] ide-cd: remove dead URLs Bartlomiej Zolnierkiewicz
2009-02-16  0:13 ` [PATCH 04/20] ide-cd: use ide_end_rq() also for failed non-fs requests Bartlomiej Zolnierkiewicz
2009-02-16  0:13 ` [PATCH 05/20] ide-cd: remove dead code from cdrom_decode_status() Bartlomiej Zolnierkiewicz
2009-02-16  0:13 ` [PATCH 06/20] ide: remove needless ide_dump_status_no_sense() wrapper Bartlomiej Zolnierkiewicz
2009-02-16  0:13 ` [PATCH 07/20] ide-cd: remove no longer needed 'ignore' module parameter Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 08/20] ide-cd: factor out failed request completion from cdrom_end_request() Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 09/20] ide-cd: unify ide_cd_do_request() exit paths Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 10/20] ide-cd: move setting REQ_FAILED flag out from 'end_request' exit path Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 11/20] ide-cd: unify cdrom_newpc_intr() exit paths Bartlomiej Zolnierkiewicz
2009-02-16  9:25   ` Borislav Petkov
2009-02-16 21:09     ` Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 12/20] ide-cd: remove cdrom_end_request() Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 13/20] ide-cd: kill whole failed request in ide_cd_do_request() Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 14/20] ide-cd: cleanup ide_cd_do_request() Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 15/20] ide-cd: use scatterlists for PIO transfers (fs requests) Bartlomiej Zolnierkiewicz
2009-02-16  0:14 ` [PATCH 16/20] ide-cd: fix non-SECTOR_SIZE-multiples PIO transfers for fs requests Bartlomiej Zolnierkiewicz
2009-02-16  0:15 ` [PATCH 17/20] ide-cd: merge ide_cd_prepare_rw_request() into cdrom_start_rw() Bartlomiej Zolnierkiewicz
2009-02-16  0:15 ` [PATCH 18/20] ide-cd: use scatterlists for PIO transfers (non-fs requests) Bartlomiej Zolnierkiewicz
2009-02-16  0:15 ` [PATCH 19/20] ide-cd: use common completion path for DMA requests in cdrom_newpc_intr() Bartlomiej Zolnierkiewicz
2009-02-16  0:15 ` [PATCH 20/20] ide-cd: unify transfer padding " Bartlomiej Zolnierkiewicz

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=20090216001316.27491.28672.sendpatchset@localhost.localdomain \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petkovbb@gmail.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 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).