Lines Matching refs:arena

67 	struct pci_iommu_arena *arena;  in iommu_arena_new_node()  local
82 (NULL == (arena = alloc_bootmem_node(NODE_DATA(nid), in iommu_arena_new_node()
83 sizeof(*arena))))) { in iommu_arena_new_node()
87 arena = alloc_bootmem(sizeof(*arena)); in iommu_arena_new_node()
91 (NULL == (arena->ptes = __alloc_bootmem_node(NODE_DATA(nid), in iommu_arena_new_node()
98 arena->ptes = __alloc_bootmem(mem_size, align, 0); in iommu_arena_new_node()
103 arena = alloc_bootmem(sizeof(*arena)); in iommu_arena_new_node()
104 arena->ptes = __alloc_bootmem(mem_size, align, 0); in iommu_arena_new_node()
108 spin_lock_init(&arena->lock); in iommu_arena_new_node()
109 arena->hose = hose; in iommu_arena_new_node()
110 arena->dma_base = base; in iommu_arena_new_node()
111 arena->size = window_size; in iommu_arena_new_node()
112 arena->next_entry = 0; in iommu_arena_new_node()
116 arena->align_entry = 1; in iommu_arena_new_node()
118 return arena; in iommu_arena_new_node()
130 iommu_arena_find_pages(struct pci_iommu_arena *arena, long n, long mask) in iommu_arena_find_pages() argument
136 ptes = arena->ptes; in iommu_arena_find_pages()
137 nent = arena->size >> PAGE_SHIFT; in iommu_arena_find_pages()
138 p = (arena->next_entry + mask) & ~mask; in iommu_arena_find_pages()
150 alpha_mv.mv_pci_tbi(arena->hose, 0, -1); in iommu_arena_find_pages()
170 iommu_arena_alloc(struct pci_iommu_arena *arena, long n, unsigned int align) in iommu_arena_alloc() argument
176 spin_lock_irqsave(&arena->lock, flags); in iommu_arena_alloc()
179 ptes = arena->ptes; in iommu_arena_alloc()
180 mask = max(align, arena->align_entry) - 1; in iommu_arena_alloc()
181 p = iommu_arena_find_pages(arena, n, mask); in iommu_arena_alloc()
183 spin_unlock_irqrestore(&arena->lock, flags); in iommu_arena_alloc()
194 arena->next_entry = p + n; in iommu_arena_alloc()
195 spin_unlock_irqrestore(&arena->lock, flags); in iommu_arena_alloc()
201 iommu_arena_free(struct pci_iommu_arena *arena, long ofs, long n) in iommu_arena_free() argument
206 p = arena->ptes + ofs; in iommu_arena_free()
222 struct pci_iommu_arena *arena; in pci_map_single_1() local
264 arena = hose->sg_pci; in pci_map_single_1()
265 if (!arena || arena->dma_base + arena->size - 1 > max_dma) in pci_map_single_1()
266 arena = hose->sg_isa; in pci_map_single_1()
270 dma_ofs = iommu_arena_alloc(arena, npages, pdev ? 0 : 8); in pci_map_single_1()
279 arena->ptes[i + dma_ofs] = mk_iommu_pte(paddr); in pci_map_single_1()
281 ret = arena->dma_base + dma_ofs * PAGE_SIZE; in pci_map_single_1()
328 struct pci_iommu_arena *arena; in pci_unmap_single() local
350 arena = hose->sg_pci; in pci_unmap_single()
351 if (!arena || dma_addr < arena->dma_base) in pci_unmap_single()
352 arena = hose->sg_isa; in pci_unmap_single()
354 dma_ofs = (dma_addr - arena->dma_base) >> PAGE_SHIFT; in pci_unmap_single()
355 if (dma_ofs * PAGE_SIZE >= arena->size) { in pci_unmap_single()
357 " base %lx size %x\n", dma_addr, arena->dma_base, in pci_unmap_single()
358 arena->size); in pci_unmap_single()
365 spin_lock_irqsave(&arena->lock, flags); in pci_unmap_single()
367 iommu_arena_free(arena, dma_ofs, npages); in pci_unmap_single()
372 if (dma_ofs >= arena->next_entry) in pci_unmap_single()
375 spin_unlock_irqrestore(&arena->lock, flags); in pci_unmap_single()
508 struct scatterlist *out, struct pci_iommu_arena *arena, in sg_fill() argument
549 dma_ofs = iommu_arena_alloc(arena, npages, 0); in sg_fill()
558 return sg_fill(leader, end, out, arena, max_dma, dac_allowed); in sg_fill()
561 out->dma_address = arena->dma_base + dma_ofs*PAGE_SIZE + paddr; in sg_fill()
569 ptes = &arena->ptes[dma_ofs]; in sg_fill()
611 struct pci_iommu_arena *arena; in pci_map_sg() local
639 arena = hose->sg_pci; in pci_map_sg()
640 if (!arena || arena->dma_base + arena->size - 1 > max_dma) in pci_map_sg()
641 arena = hose->sg_isa; in pci_map_sg()
644 arena = NULL; in pci_map_sg()
653 if (sg_fill(sg, end, out, arena, max_dma, dac_allowed) < 0) in pci_map_sg()
689 struct pci_iommu_arena *arena; in pci_unmap_sg() local
702 arena = hose->sg_pci; in pci_unmap_sg()
703 if (!arena || arena->dma_base + arena->size - 1 > max_dma) in pci_unmap_sg()
704 arena = hose->sg_isa; in pci_unmap_sg()
708 spin_lock_irqsave(&arena->lock, flags); in pci_unmap_sg()
740 ofs = (addr - arena->dma_base) >> PAGE_SHIFT; in pci_unmap_sg()
741 iommu_arena_free(arena, ofs, npages); in pci_unmap_sg()
751 if ((fend - arena->dma_base) >> PAGE_SHIFT >= arena->next_entry) in pci_unmap_sg()
754 spin_unlock_irqrestore(&arena->lock, flags); in pci_unmap_sg()
767 struct pci_iommu_arena *arena; in pci_dma_supported() local
779 arena = hose->sg_isa; in pci_dma_supported()
780 if (arena && arena->dma_base + arena->size - 1 <= mask) in pci_dma_supported()
782 arena = hose->sg_pci; in pci_dma_supported()
783 if (arena && arena->dma_base + arena->size - 1 <= mask) in pci_dma_supported()
798 iommu_reserve(struct pci_iommu_arena *arena, long pg_count, long align_mask) in iommu_reserve() argument
804 if (!arena) return -EINVAL; in iommu_reserve()
806 spin_lock_irqsave(&arena->lock, flags); in iommu_reserve()
809 ptes = arena->ptes; in iommu_reserve()
810 p = iommu_arena_find_pages(arena, pg_count, align_mask); in iommu_reserve()
812 spin_unlock_irqrestore(&arena->lock, flags); in iommu_reserve()
822 arena->next_entry = p + pg_count; in iommu_reserve()
823 spin_unlock_irqrestore(&arena->lock, flags); in iommu_reserve()
829 iommu_release(struct pci_iommu_arena *arena, long pg_start, long pg_count) in iommu_release() argument
834 if (!arena) return -EINVAL; in iommu_release()
836 ptes = arena->ptes; in iommu_release()
843 iommu_arena_free(arena, pg_start, pg_count); in iommu_release()
848 iommu_bind(struct pci_iommu_arena *arena, long pg_start, long pg_count, in iommu_bind() argument
855 if (!arena) return -EINVAL; in iommu_bind()
857 spin_lock_irqsave(&arena->lock, flags); in iommu_bind()
859 ptes = arena->ptes; in iommu_bind()
863 spin_unlock_irqrestore(&arena->lock, flags); in iommu_bind()
871 spin_unlock_irqrestore(&arena->lock, flags); in iommu_bind()
877 iommu_unbind(struct pci_iommu_arena *arena, long pg_start, long pg_count) in iommu_unbind() argument
882 if (!arena) return -EINVAL; in iommu_unbind()
884 p = arena->ptes + pg_start; in iommu_unbind()