Re: [PATCH] ide-scsi highmem cleanup

From: Jeff Garzik
Date: Sun Oct 30 2005 - 22:49:42 EST


Linux Kernel Mailing List wrote:
tree c6016a8741a2527acac0ceb6e6ce431a798d6708
parent f1fc78a8c7f3a784b9fd1e07cc1438a0ea569555
author Andrew Morton <akpm@xxxxxxxx> Mon, 31 Oct 2005 07:00:13 -0800
committer Linus Torvalds <torvalds@xxxxxxxxxxx> Mon, 31 Oct 2005 09:37:17 -0800

[PATCH] ide-scsi highmem cleanup

It's not necessary to test PageHighmem in here - kmap_atomic() does the right
thing.

Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@xxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxx>

drivers/scsi/ide-scsi.c | 38 ++++++++++++--------------------------
1 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -180,19 +180,12 @@ static void idescsi_input_buffers (ide_d
return;
}
count = min(pc->sg->length - pc->b_count, bcount);
- if (PageHighMem(pc->sg->page)) {
- unsigned long flags;
-
- local_irq_save(flags);
- buf = kmap_atomic(pc->sg->page, KM_IRQ0) + pc->sg->offset;
- drive->hwif->atapi_input_bytes(drive, buf + pc->b_count, count);
- kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
- local_irq_restore(flags);
- } else {
- buf = page_address(pc->sg->page) + pc->sg->offset;
- drive->hwif->atapi_input_bytes(drive, buf + pc->b_count, count);
- }
- bcount -= count; pc->b_count += count;
+ buf = kmap_atomic(pc->sg->page, KM_IRQ0);
+ drive->hwif->atapi_input_bytes(drive,
+ buf + pc->b_count + pc->sg->offset, count);
+ kunmap_atomic(buf, KM_IRQ0);
+ bcount -= count;
+ pc->b_count += count;
if (pc->b_count == pc->sg->length) {
pc->sg++;
pc->b_count = 0;
@@ -212,19 +205,12 @@ static void idescsi_output_buffers (ide_
return;
}
count = min(pc->sg->length - pc->b_count, bcount);
- if (PageHighMem(pc->sg->page)) {
- unsigned long flags;
-
- local_irq_save(flags);
- buf = kmap_atomic(pc->sg->page, KM_IRQ0) + pc->sg->offset;
- drive->hwif->atapi_output_bytes(drive, buf + pc->b_count, count);
- kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
- local_irq_restore(flags);
- } else {
- buf = page_address(pc->sg->page) + pc->sg->offset;
- drive->hwif->atapi_output_bytes(drive, buf + pc->b_count, count);
- }
- bcount -= count; pc->b_count += count;
+ buf = kmap_atomic(pc->sg->page, KM_IRQ0);
+ drive->hwif->atapi_output_bytes(drive,
+ buf + pc->b_count + pc->sg->offset, count);
+ kunmap_atomic(buf, KM_IRQ0);
+ bcount -= count;
+ pc->b_count += count;

Unless I'm missing something, this patch looks very wrong.

kmap_atomic(..., KM_IRQx) needs to be inside local_irq_save().

As such, the PageHighMem() does have clear benefits.

Jeff


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/