aboutsummaryrefslogtreecommitdiffstats
path: root/arch/alpha/kernel
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-10-16 01:02:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:33 -0400
commiteb117d3e519f99567ddd2c86386a6e64c6e471cd (patch)
tree7e529e072134b265d4fbd0e40efa798dfe854cfe /arch/alpha/kernel
parent2994a3b2653a3ab04f7b1459ce2442baecb62961 (diff)
alpha: use iommu_num_pages function in IOMMU code
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Muli Ben-Yehuda <muli@il.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/alpha/kernel')
-rw-r--r--arch/alpha/kernel/pci_iommu.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 2179c602032a..b9094da05d7a 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -41,13 +41,6 @@ mk_iommu_pte(unsigned long paddr)
41 return (paddr >> (PAGE_SHIFT-1)) | 1; 41 return (paddr >> (PAGE_SHIFT-1)) | 1;
42} 42}
43 43
44static inline long
45calc_npages(long bytes)
46{
47 return (bytes + PAGE_SIZE - 1) >> PAGE_SHIFT;
48}
49
50
51/* Return the minimum of MAX or the first power of two larger 44/* Return the minimum of MAX or the first power of two larger
52 than main memory. */ 45 than main memory. */
53 46
@@ -287,7 +280,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size,
287 if (!arena || arena->dma_base + arena->size - 1 > max_dma) 280 if (!arena || arena->dma_base + arena->size - 1 > max_dma)
288 arena = hose->sg_isa; 281 arena = hose->sg_isa;
289 282
290 npages = calc_npages((paddr & ~PAGE_MASK) + size); 283 npages = iommu_num_pages(paddr, size, PAGE_SIZE);
291 284
292 /* Force allocation to 64KB boundary for ISA bridges. */ 285 /* Force allocation to 64KB boundary for ISA bridges. */
293 if (pdev && pdev == isa_bridge) 286 if (pdev && pdev == isa_bridge)
@@ -387,7 +380,7 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
387 BUG(); 380 BUG();
388 } 381 }
389 382
390 npages = calc_npages((dma_addr & ~PAGE_MASK) + size); 383 npages = iommu_num_pages(dma_addr, size, PAGE_SIZE);
391 384
392 spin_lock_irqsave(&arena->lock, flags); 385 spin_lock_irqsave(&arena->lock, flags);
393 386
@@ -580,7 +573,7 @@ sg_fill(struct device *dev, struct scatterlist *leader, struct scatterlist *end,
580 contiguous. */ 573 contiguous. */
581 574
582 paddr &= ~PAGE_MASK; 575 paddr &= ~PAGE_MASK;
583 npages = calc_npages(paddr + size); 576 npages = iommu_num_pages(paddr, size, PAGE_SIZE);
584 dma_ofs = iommu_arena_alloc(dev, arena, npages, 0); 577 dma_ofs = iommu_arena_alloc(dev, arena, npages, 0);
585 if (dma_ofs < 0) { 578 if (dma_ofs < 0) {
586 /* If we attempted a direct map above but failed, die. */ 579 /* If we attempted a direct map above but failed, die. */
@@ -616,7 +609,7 @@ sg_fill(struct device *dev, struct scatterlist *leader, struct scatterlist *end,
616 sg++; 609 sg++;
617 } 610 }
618 611
619 npages = calc_npages((paddr & ~PAGE_MASK) + size); 612 npages = iommu_num_pages(paddr, size, PAGE_SIZE);
620 613
621 paddr &= PAGE_MASK; 614 paddr &= PAGE_MASK;
622 for (i = 0; i < npages; ++i, paddr += PAGE_SIZE) 615 for (i = 0; i < npages; ++i, paddr += PAGE_SIZE)
@@ -775,7 +768,7 @@ pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
775 DBGA(" (%ld) sg [%lx,%lx]\n", 768 DBGA(" (%ld) sg [%lx,%lx]\n",
776 sg - end + nents, addr, size); 769 sg - end + nents, addr, size);
777 770
778 npages = calc_npages((addr & ~PAGE_MASK) + size); 771 npages = iommu_num_pages(addr, size, PAGE_SIZE);
779 ofs = (addr - arena->dma_base) >> PAGE_SHIFT; 772 ofs = (addr - arena->dma_base) >> PAGE_SHIFT;
780 iommu_arena_free(arena, ofs, npages); 773 iommu_arena_free(arena, ofs, npages);
781 774