[PATCH] block: disable block layer bouncing for most memory on 64bit systems

The low level PCI DMA mapping functions should handle it in most cases.

This should fix problems with depleting the DMA zone early. The old
code used precious GFP_DMA memory in many cases where it was not needed.

Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Andi Kleen and committed by Linus Torvalds 5ee1af9f f9262c12

+18 -13
+18 -13
block/ll_rw_blk.c
··· 625 625 * Different hardware can have different requirements as to what pages 626 626 * it can do I/O directly to. A low level driver can call 627 627 * blk_queue_bounce_limit to have lower memory pages allocated as bounce 628 - * buffers for doing I/O to pages residing above @page. By default 629 - * the block layer sets this to the highest numbered "low" memory page. 628 + * buffers for doing I/O to pages residing above @page. 630 629 **/ 631 630 void blk_queue_bounce_limit(request_queue_t *q, u64 dma_addr) 632 631 { 633 632 unsigned long bounce_pfn = dma_addr >> PAGE_SHIFT; 633 + int dma = 0; 634 634 635 - /* 636 - * set appropriate bounce gfp mask -- unfortunately we don't have a 637 - * full 4GB zone, so we have to resort to low memory for any bounces. 638 - * ISA has its own < 16MB zone. 639 - */ 640 - if (bounce_pfn < blk_max_low_pfn) { 641 - BUG_ON(dma_addr < BLK_BOUNCE_ISA); 635 + q->bounce_gfp = GFP_NOIO; 636 + #if BITS_PER_LONG == 64 637 + /* Assume anything <= 4GB can be handled by IOMMU. 638 + Actually some IOMMUs can handle everything, but I don't 639 + know of a way to test this here. */ 640 + if (bounce_pfn < (0xffffffff>>PAGE_SHIFT)) 641 + dma = 1; 642 + q->bounce_pfn = max_low_pfn; 643 + #else 644 + if (bounce_pfn < blk_max_low_pfn) 645 + dma = 1; 646 + q->bounce_pfn = bounce_pfn; 647 + #endif 648 + if (dma) { 642 649 init_emergency_isa_pool(); 643 650 q->bounce_gfp = GFP_NOIO | GFP_DMA; 644 - } else 645 - q->bounce_gfp = GFP_NOIO; 646 - 647 - q->bounce_pfn = bounce_pfn; 651 + q->bounce_pfn = bounce_pfn; 652 + } 648 653 } 649 654 650 655 EXPORT_SYMBOL(blk_queue_bounce_limit);