Skip to contentSkip to conversation

ide: Fix IDE PIO size calculation

PATCH Applied Steven J. Hill 2 participants 2 messages Jun 20, 2013 – Jul 10, 2013 libata

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ide: Fix IDE PIO size calculation

From: Steven J. Hill <[email protected]>

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

---
Changes in v2: Remove internal gerrit ID from commit message.

 drivers/ide/ide-taskfile.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/ide/ide-taskfile.c +2 -3
index 729428e..dabb88b 100644
@@ -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);
Signature · 1 line
1.7.2.5