diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-09-11 10:08:48 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-14 10:43:58 -0400 |
commit | f6a32a36ab96016675cd414802904feb288d7899 (patch) | |
tree | 1782f3b01261ea952da18208c20f9d30370856ba /arch | |
parent | f10ac8a232496bf9271cfc67c6eea432891f04a6 (diff) |
x86: gart alloc_coherent does virtual mapppings only when necessary
gart alloc_coherent need to do virtual mapppings only when an
allocated buffer is not DMA-capable for a device.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/pci-gart_64.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c index 9972c42ac925..9739d5682093 100644 --- a/arch/x86/kernel/pci-gart_64.c +++ b/arch/x86/kernel/pci-gart_64.c | |||
@@ -505,15 +505,23 @@ gart_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_addr, | |||
505 | gfp_t flag) | 505 | gfp_t flag) |
506 | { | 506 | { |
507 | void *vaddr; | 507 | void *vaddr; |
508 | dma_addr_t paddr; | ||
508 | unsigned long align_mask; | 509 | unsigned long align_mask; |
510 | u64 dma_mask = dma_alloc_coherent_mask(dev, flag); | ||
509 | 511 | ||
510 | vaddr = (void *)__get_free_pages(flag | __GFP_ZERO, get_order(size)); | 512 | vaddr = (void *)__get_free_pages(flag | __GFP_ZERO, get_order(size)); |
511 | if (!vaddr) | 513 | if (!vaddr) |
512 | return NULL; | 514 | return NULL; |
513 | 515 | ||
516 | paddr = virt_to_phys(vaddr); | ||
517 | if (is_buffer_dma_capable(dma_mask, paddr, size)) { | ||
518 | *dma_addr = paddr; | ||
519 | return vaddr; | ||
520 | } | ||
521 | |||
514 | align_mask = (1UL << get_order(size)) - 1; | 522 | align_mask = (1UL << get_order(size)) - 1; |
515 | 523 | ||
516 | *dma_addr = dma_map_area(dev, __pa(vaddr), size, DMA_BIDIRECTIONAL, | 524 | *dma_addr = dma_map_area(dev, paddr, size, DMA_BIDIRECTIONAL, |
517 | align_mask, dma_mask); | 525 | align_mask, dma_mask); |
518 | flush_gart(); | 526 | flush_gart(); |
519 | 527 | ||