Lines Matching refs:arena
63 struct pci_iommu_arena *arena; in iommu_arena_new_node() local
74 arena = memblock_alloc(sizeof(*arena), SMP_CACHE_BYTES); in iommu_arena_new_node()
75 if (!arena) in iommu_arena_new_node()
77 sizeof(*arena)); in iommu_arena_new_node()
78 arena->ptes = memblock_alloc(mem_size, align); in iommu_arena_new_node()
79 if (!arena->ptes) in iommu_arena_new_node()
83 spin_lock_init(&arena->lock); in iommu_arena_new_node()
84 arena->hose = hose; in iommu_arena_new_node()
85 arena->dma_base = base; in iommu_arena_new_node()
86 arena->size = window_size; in iommu_arena_new_node()
87 arena->next_entry = 0; in iommu_arena_new_node()
91 arena->align_entry = 1; in iommu_arena_new_node()
93 return arena; in iommu_arena_new_node()
105 iommu_arena_find_pages(struct device *dev, struct pci_iommu_arena *arena, in iommu_arena_find_pages() argument
114 base = arena->dma_base >> PAGE_SHIFT; in iommu_arena_find_pages()
118 ptes = arena->ptes; in iommu_arena_find_pages()
119 nent = arena->size >> PAGE_SHIFT; in iommu_arena_find_pages()
120 p = ALIGN(arena->next_entry, mask + 1); in iommu_arena_find_pages()
144 alpha_mv.mv_pci_tbi(arena->hose, 0, -1); in iommu_arena_find_pages()
160 iommu_arena_alloc(struct device *dev, struct pci_iommu_arena *arena, long n, in iommu_arena_alloc() argument
167 spin_lock_irqsave(&arena->lock, flags); in iommu_arena_alloc()
170 ptes = arena->ptes; in iommu_arena_alloc()
171 mask = max(align, arena->align_entry) - 1; in iommu_arena_alloc()
172 p = iommu_arena_find_pages(dev, arena, n, mask); in iommu_arena_alloc()
174 spin_unlock_irqrestore(&arena->lock, flags); in iommu_arena_alloc()
185 arena->next_entry = p + n; in iommu_arena_alloc()
186 spin_unlock_irqrestore(&arena->lock, flags); in iommu_arena_alloc()
192 iommu_arena_free(struct pci_iommu_arena *arena, long ofs, long n) in iommu_arena_free() argument
197 p = arena->ptes + ofs; in iommu_arena_free()
237 struct pci_iommu_arena *arena; in pci_map_single_1() local
277 arena = hose->sg_pci; in pci_map_single_1()
278 if (!arena || arena->dma_base + arena->size - 1 > max_dma) in pci_map_single_1()
279 arena = hose->sg_isa; in pci_map_single_1()
286 dma_ofs = iommu_arena_alloc(dev, arena, npages, align); in pci_map_single_1()
295 arena->ptes[i + dma_ofs] = mk_iommu_pte(paddr); in pci_map_single_1()
297 ret = arena->dma_base + dma_ofs * PAGE_SIZE; in pci_map_single_1()
358 struct pci_iommu_arena *arena; in alpha_pci_unmap_page() local
379 arena = hose->sg_pci; in alpha_pci_unmap_page()
380 if (!arena || dma_addr < arena->dma_base) in alpha_pci_unmap_page()
381 arena = hose->sg_isa; in alpha_pci_unmap_page()
383 dma_ofs = (dma_addr - arena->dma_base) >> PAGE_SHIFT; in alpha_pci_unmap_page()
384 if (dma_ofs * PAGE_SIZE >= arena->size) { in alpha_pci_unmap_page()
387 dma_addr, arena->dma_base, arena->size); in alpha_pci_unmap_page()
394 spin_lock_irqsave(&arena->lock, flags); in alpha_pci_unmap_page()
396 iommu_arena_free(arena, dma_ofs, npages); in alpha_pci_unmap_page()
401 if (dma_ofs >= arena->next_entry) in alpha_pci_unmap_page()
404 spin_unlock_irqrestore(&arena->lock, flags); in alpha_pci_unmap_page()
536 struct scatterlist *out, struct pci_iommu_arena *arena, in sg_fill() argument
577 dma_ofs = iommu_arena_alloc(dev, arena, npages, 0); in sg_fill()
586 return sg_fill(dev, leader, end, out, arena, max_dma, dac_allowed); in sg_fill()
589 out->dma_address = arena->dma_base + dma_ofs*PAGE_SIZE + paddr; in sg_fill()
597 ptes = &arena->ptes[dma_ofs]; in sg_fill()
640 struct pci_iommu_arena *arena; in alpha_pci_map_sg() local
669 arena = hose->sg_pci; in alpha_pci_map_sg()
670 if (!arena || arena->dma_base + arena->size - 1 > max_dma) in alpha_pci_map_sg()
671 arena = hose->sg_isa; in alpha_pci_map_sg()
674 arena = NULL; in alpha_pci_map_sg()
683 if (sg_fill(dev, sg, end, out, arena, max_dma, dac_allowed) < 0) in alpha_pci_map_sg()
722 struct pci_iommu_arena *arena; in alpha_pci_unmap_sg() local
734 arena = hose->sg_pci; in alpha_pci_unmap_sg()
735 if (!arena || arena->dma_base + arena->size - 1 > max_dma) in alpha_pci_unmap_sg()
736 arena = hose->sg_isa; in alpha_pci_unmap_sg()
740 spin_lock_irqsave(&arena->lock, flags); in alpha_pci_unmap_sg()
772 ofs = (addr - arena->dma_base) >> PAGE_SHIFT; in alpha_pci_unmap_sg()
773 iommu_arena_free(arena, ofs, npages); in alpha_pci_unmap_sg()
783 if ((fend - arena->dma_base) >> PAGE_SHIFT >= arena->next_entry) in alpha_pci_unmap_sg()
786 spin_unlock_irqrestore(&arena->lock, flags); in alpha_pci_unmap_sg()
798 struct pci_iommu_arena *arena; in alpha_pci_supported() local
810 arena = hose->sg_isa; in alpha_pci_supported()
811 if (arena && arena->dma_base + arena->size - 1 <= mask) in alpha_pci_supported()
813 arena = hose->sg_pci; in alpha_pci_supported()
814 if (arena && arena->dma_base + arena->size - 1 <= mask) in alpha_pci_supported()
829 iommu_reserve(struct pci_iommu_arena *arena, long pg_count, long align_mask) in iommu_reserve() argument
835 if (!arena) return -EINVAL; in iommu_reserve()
837 spin_lock_irqsave(&arena->lock, flags); in iommu_reserve()
840 ptes = arena->ptes; in iommu_reserve()
841 p = iommu_arena_find_pages(NULL, arena, pg_count, align_mask); in iommu_reserve()
843 spin_unlock_irqrestore(&arena->lock, flags); in iommu_reserve()
853 arena->next_entry = p + pg_count; in iommu_reserve()
854 spin_unlock_irqrestore(&arena->lock, flags); in iommu_reserve()
860 iommu_release(struct pci_iommu_arena *arena, long pg_start, long pg_count) in iommu_release() argument
865 if (!arena) return -EINVAL; in iommu_release()
867 ptes = arena->ptes; in iommu_release()
874 iommu_arena_free(arena, pg_start, pg_count); in iommu_release()
879 iommu_bind(struct pci_iommu_arena *arena, long pg_start, long pg_count, in iommu_bind() argument
886 if (!arena) return -EINVAL; in iommu_bind()
888 spin_lock_irqsave(&arena->lock, flags); in iommu_bind()
890 ptes = arena->ptes; in iommu_bind()
894 spin_unlock_irqrestore(&arena->lock, flags); in iommu_bind()
902 spin_unlock_irqrestore(&arena->lock, flags); in iommu_bind()
908 iommu_unbind(struct pci_iommu_arena *arena, long pg_start, long pg_count) in iommu_unbind() argument
913 if (!arena) return -EINVAL; in iommu_unbind()
915 p = arena->ptes + pg_start; in iommu_unbind()