Patchwork [v2] ide: Fix IDE PIO size calculation

login
register
mail settings
Submitter Steven J. Hill
Date June 20, 2013, 3:30 p.m.
Message ID <1371742237-9929-1-git-send-email-Steven.Hill@imgtec.com>
Download mbox | patch
Permalink /patch/253007/
State Accepted
Delegated to: David Miller
Headers show

Comments

Steven J. Hill - June 20, 2013, 3:30 p.m.
From: Steven J. Hill <sjhill@mips.com>

IDE PIO calculates the size wrong when passing the parameter
"ide-core.nodma=0.0" to the kernel.

Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Acked-by: Steven J. Hill <Steven.Hill@imgtec.com>

Signed-off-by: Steven J. Hill <sjhill@mips.com>
---
Changes in v2: Remove internal gerrit ID from commit message.

 drivers/ide/ide-taskfile.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
David Miller - July 10, 2013, 7:09 p.m.
From: "Steven J. Hill" <Steven.Hill@imgtec.com>
Date: Thu, 20 Jun 2013 10:30:37 -0500

> From: Steven J. Hill <sjhill@mips.com>
> 
> IDE PIO calculates the size wrong when passing the parameter
> "ide-core.nodma=0.0" to the kernel.
> 
> Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
> Acked-by: Steven J. Hill <Steven.Hill@imgtec.com>
> 
> Signed-off-by: Steven J. Hill <sjhill@mips.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 729428e..dabb88b 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -239,9 +239,6 @@  void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd,
 		unsigned nr_bytes = min(len, cursg->length - cmd->cursg_ofs);
 		int page_is_high;
 
-		if (nr_bytes > PAGE_SIZE)
-			nr_bytes = PAGE_SIZE;
-
 		page = sg_page(cursg);
 		offset = cursg->offset + cmd->cursg_ofs;
 
@@ -249,6 +246,8 @@  void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd,
 		page = nth_page(page, (offset >> PAGE_SHIFT));
 		offset %= PAGE_SIZE;
 
+		nr_bytes = min_t(unsigned, nr_bytes, (PAGE_SIZE - offset));
+
 		page_is_high = PageHighMem(page);
 		if (page_is_high)
 			local_irq_save(flags);