aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/pci-gart_64.c10
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