Lines Matching refs:slab

46 mm_slab_alloc(struct mm_slab *slab)  in mm_slab_alloc()  argument
50 if (slab->free == 0) in mm_slab_alloc()
53 for (i = 0; i < (slab->count + 31) / 32; ++i) { in mm_slab_alloc()
54 b = ffs(slab->bits[i]) - 1; in mm_slab_alloc()
57 assert(n < slab->count); in mm_slab_alloc()
58 slab->free--; in mm_slab_alloc()
59 slab->bits[i] &= ~(1 << b); in mm_slab_alloc()
67 mm_slab_free(struct mm_slab *slab, int i) in mm_slab_free() argument
69 assert(i < slab->count); in mm_slab_free()
70 slab->bits[i / 32] |= 1 << (i % 32); in mm_slab_free()
71 slab->free++; in mm_slab_free()
72 assert(slab->free <= slab->count); in mm_slab_free()
116 struct mm_slab *slab; in mm_slab_new() local
123 slab = MALLOC(sizeof(struct mm_slab) + words * 4); in mm_slab_new()
124 if (!slab) in mm_slab_new()
127 memset(&slab->bits[0], ~0, words * 4); in mm_slab_new()
129 slab->bo = NULL; in mm_slab_new()
132 &slab->bo); in mm_slab_new()
134 FREE(slab); in mm_slab_new()
138 LIST_INITHEAD(&slab->head); in mm_slab_new()
140 slab->cache = cache; in mm_slab_new()
141 slab->order = chunk_order; in mm_slab_new()
142 slab->count = slab->free = size >> chunk_order; in mm_slab_new()
144 LIST_ADD(&slab->head, &mm_bucket_by_order(cache, chunk_order)->free); in mm_slab_new()
161 struct mm_slab *slab; in nouveau_mm_allocate() local
178 slab = LIST_ENTRY(struct mm_slab, bucket->used.next, head); in nouveau_mm_allocate()
183 slab = LIST_ENTRY(struct mm_slab, bucket->free.next, head); in nouveau_mm_allocate()
185 LIST_DEL(&slab->head); in nouveau_mm_allocate()
186 LIST_ADD(&slab->head, &bucket->used); in nouveau_mm_allocate()
189 *offset = mm_slab_alloc(slab) << slab->order; in nouveau_mm_allocate()
195 nouveau_bo_ref(slab->bo, bo); in nouveau_mm_allocate()
197 if (slab->free == 0) { in nouveau_mm_allocate()
198 LIST_DEL(&slab->head); in nouveau_mm_allocate()
199 LIST_ADD(&slab->head, &bucket->full); in nouveau_mm_allocate()
204 alloc->priv = (void *)slab; in nouveau_mm_allocate()
212 struct mm_slab *slab = (struct mm_slab *)alloc->priv; in nouveau_mm_free() local
213 struct mm_bucket *bucket = mm_bucket_by_order(slab->cache, slab->order); in nouveau_mm_free()
215 mm_slab_free(slab, alloc->offset >> slab->order); in nouveau_mm_free()
217 if (slab->free == slab->count) { in nouveau_mm_free()
218 LIST_DEL(&slab->head); in nouveau_mm_free()
219 LIST_ADDTAIL(&slab->head, &bucket->free); in nouveau_mm_free()
221 if (slab->free == 1) { in nouveau_mm_free()
222 LIST_DEL(&slab->head); in nouveau_mm_free()
223 LIST_ADDTAIL(&slab->head, &bucket->used); in nouveau_mm_free()
262 struct mm_slab *slab, *next; in nouveau_mm_free_slabs() local
264 LIST_FOR_EACH_ENTRY_SAFE(slab, next, head, head) { in nouveau_mm_free_slabs()
265 LIST_DEL(&slab->head); in nouveau_mm_free_slabs()
266 nouveau_bo_ref(NULL, &slab->bo); in nouveau_mm_free_slabs()
267 FREE(slab); in nouveau_mm_free_slabs()