aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-01-05 09:47:24 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-06 08:06:54 -0500
commit3991605c40b1059d0204d9fddfcf878429ab8948 (patch)
tree3b528ccea941f6afcc9384aa5dbc2043b7572486 /arch
parent052aedbfb6cd4fd1a73010735da88a9dcc224673 (diff)
x86, calgary: add map_page and unmap_page
This is a preparation of struct dma_mapping_ops unification. We use map_page and unmap_page instead of map_single and unmap_single. We will remove map_single and unmap_single hooks in the last patch in this patchset. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Muli Ben-Yehuda <muli@il.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/pci-calgary_64.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index d28bbdc35e4e..e33cfcf1af5b 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -445,10 +445,12 @@ error:
445 return 0; 445 return 0;
446} 446}
447 447
448static dma_addr_t calgary_map_single(struct device *dev, phys_addr_t paddr, 448static dma_addr_t calgary_map_page(struct device *dev, struct page *page,
449 size_t size, int direction) 449 unsigned long offset, size_t size,
450 enum dma_data_direction dir,
451 struct dma_attrs *attrs)
450{ 452{
451 void *vaddr = phys_to_virt(paddr); 453 void *vaddr = page_address(page) + offset;
452 unsigned long uaddr; 454 unsigned long uaddr;
453 unsigned int npages; 455 unsigned int npages;
454 struct iommu_table *tbl = find_iommu_table(dev); 456 struct iommu_table *tbl = find_iommu_table(dev);
@@ -456,17 +458,32 @@ static dma_addr_t calgary_map_single(struct device *dev, phys_addr_t paddr,
456 uaddr = (unsigned long)vaddr; 458 uaddr = (unsigned long)vaddr;
457 npages = iommu_num_pages(uaddr, size, PAGE_SIZE); 459 npages = iommu_num_pages(uaddr, size, PAGE_SIZE);
458 460
459 return iommu_alloc(dev, tbl, vaddr, npages, direction); 461 return iommu_alloc(dev, tbl, vaddr, npages, dir);
460} 462}
461 463
462static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle, 464static dma_addr_t calgary_map_single(struct device *dev, phys_addr_t paddr,
463 size_t size, int direction) 465 size_t size, int direction)
466{
467 return calgary_map_page(dev, pfn_to_page(paddr >> PAGE_SHIFT),
468 paddr & ~PAGE_MASK, size,
469 direction, NULL);
470}
471
472static void calgary_unmap_page(struct device *dev, dma_addr_t dma_addr,
473 size_t size, enum dma_data_direction dir,
474 struct dma_attrs *attrs)
464{ 475{
465 struct iommu_table *tbl = find_iommu_table(dev); 476 struct iommu_table *tbl = find_iommu_table(dev);
466 unsigned int npages; 477 unsigned int npages;
467 478
468 npages = iommu_num_pages(dma_handle, size, PAGE_SIZE); 479 npages = iommu_num_pages(dma_addr, size, PAGE_SIZE);
469 iommu_free(tbl, dma_handle, npages); 480 iommu_free(tbl, dma_addr, npages);
481}
482
483static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
484 size_t size, int direction)
485{
486 calgary_unmap_page(dev, dma_handle, size, direction, NULL);
470} 487}
471 488
472static void* calgary_alloc_coherent(struct device *dev, size_t size, 489static void* calgary_alloc_coherent(struct device *dev, size_t size,
@@ -522,6 +539,8 @@ static struct dma_mapping_ops calgary_dma_ops = {
522 .unmap_single = calgary_unmap_single, 539 .unmap_single = calgary_unmap_single,
523 .map_sg = calgary_map_sg, 540 .map_sg = calgary_map_sg,
524 .unmap_sg = calgary_unmap_sg, 541 .unmap_sg = calgary_unmap_sg,
542 .map_page = calgary_map_page,
543 .unmap_page = calgary_unmap_page,
525}; 544};
526 545
527static inline void __iomem * busno_to_bbar(unsigned char num) 546static inline void __iomem * busno_to_bbar(unsigned char num)