ide: Fix IDE PIO size calculation
authorSteven J. Hill <sjhill@mips.com>
Thu, 20 Jun 2013 15:30:37 +0000 (10:30 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 Jul 2013 19:09:10 +0000 (12:09 -0700)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/ide/ide-taskfile.c

index 729428edeba26c4fca4ddfde7c9615f76a0c76b5..dabb88b1cbec69052d32eb5e84b7f647534a4599 100644 (file)
@@ -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);