Skip to contentSkip to conversation

ide-scsi highmem cleanup

PATCH Jeff Garzik 2 participants 2 messages Oct 31, 2005 1 message not in the archive libata

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 59 lines · Linux Kernel Mailing List

tree c6016a8741a2527acac0ceb6e6ce431a798d6708
parent f1fc78a8c7f3a784b9fd1e07cc1438a0ea569555
author Andrew Morton <[email protected]> Mon, 31 Oct 2005 07:00:13 -0800 committer Linus Torvalds <[email protected]> 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 <[email protected]>
 drivers/scsi/ide-scsi.c |   38 ++++++++++++--------------------------
 1 files changed, 12 insertions(+), 26 deletions(-)
drivers/scsi/ide-scsi.c +6 -22
@@ -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 {

drivers/scsi/ide-scsi.c static void idescsi_output_buffers (ide_ · line 213

Quoted 10 lines
drivers/scsi/ide-scsi.c +6 -4
-			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

#2 lore raw
Quoted 27 lines · Jeff Garzik
Quoted 14 lines
(quoted diff) +0 -9
@@ -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 {

Review static void idescsi_output_buffers (ide_ · line 213

Quoted 10 lines
(quoted diff) +6 -4
-			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.

Quoted 1 line

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

Yeah, shared interrupts.

Quoted 1 line

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

Yep, thanks. I'll fix that up.