Lines Matching refs:vm

30 get_vm_block(struct ct_vm *vm, unsigned int size, struct ct_atc *atc)  in get_vm_block()  argument
36 if (size > vm->size) { in get_vm_block()
42 mutex_lock(&vm->lock); in get_vm_block()
43 list_for_each(pos, &vm->unused) { in get_vm_block()
48 if (pos == &vm->unused) in get_vm_block()
53 list_move(&entry->list, &vm->used); in get_vm_block()
54 vm->size -= size; in get_vm_block()
65 list_add(&block->list, &vm->used); in get_vm_block()
68 vm->size -= size; in get_vm_block()
71 mutex_unlock(&vm->lock); in get_vm_block()
75 static void put_vm_block(struct ct_vm *vm, struct ct_vm_block *block) in put_vm_block() argument
82 mutex_lock(&vm->lock); in put_vm_block()
84 vm->size += block->size; in put_vm_block()
86 list_for_each(pos, &vm->unused) { in put_vm_block()
91 if (pos == &vm->unused) { in put_vm_block()
92 list_add_tail(&block->list, &vm->unused); in put_vm_block()
107 while (pre != &vm->unused) { in put_vm_block()
119 mutex_unlock(&vm->lock); in put_vm_block()
124 ct_vm_map(struct ct_vm *vm, struct snd_pcm_substream *substream, int size) in ct_vm_map() argument
132 block = get_vm_block(vm, size, atc); in ct_vm_map()
139 ptp = (unsigned long *)vm->ptp[0].area; in ct_vm_map()
152 static void ct_vm_unmap(struct ct_vm *vm, struct ct_vm_block *block) in ct_vm_unmap() argument
155 put_vm_block(vm, block); in ct_vm_unmap()
164 ct_get_ptp_phys(struct ct_vm *vm, int index) in ct_get_ptp_phys() argument
166 return (index >= CT_PTP_NUM) ? ~0UL : vm->ptp[index].addr; in ct_get_ptp_phys()
171 struct ct_vm *vm; in ct_vm_create() local
177 vm = kzalloc(sizeof(*vm), GFP_KERNEL); in ct_vm_create()
178 if (!vm) in ct_vm_create()
181 mutex_init(&vm->lock); in ct_vm_create()
187 PAGE_SIZE, &vm->ptp[i]); in ct_vm_create()
193 ct_vm_destroy(vm); in ct_vm_create()
196 vm->size = CT_ADDRS_PER_PAGE * i; in ct_vm_create()
197 vm->map = ct_vm_map; in ct_vm_create()
198 vm->unmap = ct_vm_unmap; in ct_vm_create()
199 vm->get_ptp_phys = ct_get_ptp_phys; in ct_vm_create()
200 INIT_LIST_HEAD(&vm->unused); in ct_vm_create()
201 INIT_LIST_HEAD(&vm->used); in ct_vm_create()
205 block->size = vm->size; in ct_vm_create()
206 list_add(&block->list, &vm->unused); in ct_vm_create()
209 *rvm = vm; in ct_vm_create()
215 void ct_vm_destroy(struct ct_vm *vm) in ct_vm_destroy() argument
222 while (!list_empty(&vm->used)) { in ct_vm_destroy()
223 pos = vm->used.next; in ct_vm_destroy()
228 while (!list_empty(&vm->unused)) { in ct_vm_destroy()
229 pos = vm->unused.next; in ct_vm_destroy()
237 snd_dma_free_pages(&vm->ptp[i]); in ct_vm_destroy()
239 vm->size = 0; in ct_vm_destroy()
241 kfree(vm); in ct_vm_destroy()