Lines Matching refs:res_pool

37 	struct fsl_mc_resource_pool *res_pool;  in fsl_mc_resource_pool_add_device()  local
49 res_pool = &mc_bus->resource_pools[pool_type]; in fsl_mc_resource_pool_add_device()
50 if (res_pool->type != pool_type) in fsl_mc_resource_pool_add_device()
52 if (res_pool->mc_bus != mc_bus) in fsl_mc_resource_pool_add_device()
55 mutex_lock(&res_pool->mutex); in fsl_mc_resource_pool_add_device()
57 if (res_pool->max_count < 0) in fsl_mc_resource_pool_add_device()
59 if (res_pool->free_count < 0 || in fsl_mc_resource_pool_add_device()
60 res_pool->free_count > res_pool->max_count) in fsl_mc_resource_pool_add_device()
75 resource->parent_pool = res_pool; in fsl_mc_resource_pool_add_device()
77 list_add_tail(&resource->node, &res_pool->free_list); in fsl_mc_resource_pool_add_device()
79 res_pool->free_count++; in fsl_mc_resource_pool_add_device()
80 res_pool->max_count++; in fsl_mc_resource_pool_add_device()
83 mutex_unlock(&res_pool->mutex); in fsl_mc_resource_pool_add_device()
102 struct fsl_mc_resource_pool *res_pool; in fsl_mc_resource_pool_remove_device() local
115 res_pool = resource->parent_pool; in fsl_mc_resource_pool_remove_device()
116 if (res_pool != &mc_bus->resource_pools[resource->type]) in fsl_mc_resource_pool_remove_device()
119 mutex_lock(&res_pool->mutex); in fsl_mc_resource_pool_remove_device()
121 if (res_pool->max_count <= 0) in fsl_mc_resource_pool_remove_device()
123 if (res_pool->free_count <= 0 || in fsl_mc_resource_pool_remove_device()
124 res_pool->free_count > res_pool->max_count) in fsl_mc_resource_pool_remove_device()
140 res_pool->free_count--; in fsl_mc_resource_pool_remove_device()
141 res_pool->max_count--; in fsl_mc_resource_pool_remove_device()
147 mutex_unlock(&res_pool->mutex); in fsl_mc_resource_pool_remove_device()
179 struct fsl_mc_resource_pool *res_pool; in fsl_mc_resource_allocate() local
191 res_pool = &mc_bus->resource_pools[pool_type]; in fsl_mc_resource_allocate()
192 if (res_pool->mc_bus != mc_bus) in fsl_mc_resource_allocate()
195 mutex_lock(&res_pool->mutex); in fsl_mc_resource_allocate()
196 resource = list_first_entry_or_null(&res_pool->free_list, in fsl_mc_resource_allocate()
209 if (resource->parent_pool != res_pool) in fsl_mc_resource_allocate()
211 if (res_pool->free_count <= 0 || in fsl_mc_resource_allocate()
212 res_pool->free_count > res_pool->max_count) in fsl_mc_resource_allocate()
217 res_pool->free_count--; in fsl_mc_resource_allocate()
220 mutex_unlock(&res_pool->mutex); in fsl_mc_resource_allocate()
229 struct fsl_mc_resource_pool *res_pool; in fsl_mc_resource_free() local
231 res_pool = resource->parent_pool; in fsl_mc_resource_free()
232 if (resource->type != res_pool->type) in fsl_mc_resource_free()
235 mutex_lock(&res_pool->mutex); in fsl_mc_resource_free()
236 if (res_pool->free_count < 0 || in fsl_mc_resource_free()
237 res_pool->free_count >= res_pool->max_count) in fsl_mc_resource_free()
243 list_add_tail(&resource->node, &res_pool->free_list); in fsl_mc_resource_free()
244 res_pool->free_count++; in fsl_mc_resource_free()
246 mutex_unlock(&res_pool->mutex); in fsl_mc_resource_free()
357 struct fsl_mc_resource_pool *res_pool = in fsl_mc_populate_irq_pool() local
387 mc_dev_irq->resource.type = res_pool->type; in fsl_mc_populate_irq_pool()
389 mc_dev_irq->resource.parent_pool = res_pool; in fsl_mc_populate_irq_pool()
393 list_add_tail(&mc_dev_irq->resource.node, &res_pool->free_list); in fsl_mc_populate_irq_pool()
396 res_pool->max_count = irq_count; in fsl_mc_populate_irq_pool()
397 res_pool->free_count = irq_count; in fsl_mc_populate_irq_pool()
414 struct fsl_mc_resource_pool *res_pool = in fsl_mc_cleanup_irq_pool() local
420 if (res_pool->max_count == 0) in fsl_mc_cleanup_irq_pool()
423 if (res_pool->free_count != res_pool->max_count) in fsl_mc_cleanup_irq_pool()
426 INIT_LIST_HEAD(&res_pool->free_list); in fsl_mc_cleanup_irq_pool()
427 res_pool->max_count = 0; in fsl_mc_cleanup_irq_pool()
428 res_pool->free_count = 0; in fsl_mc_cleanup_irq_pool()
445 struct fsl_mc_resource_pool *res_pool; in fsl_mc_allocate_irqs() local
462 res_pool = &mc_bus->resource_pools[FSL_MC_POOL_IRQ]; in fsl_mc_allocate_irqs()
463 if (res_pool->free_count < irq_count) { in fsl_mc_allocate_irqs()
540 struct fsl_mc_resource_pool *res_pool = in fsl_mc_init_all_resource_pools() local
543 res_pool->type = pool_type; in fsl_mc_init_all_resource_pools()
544 res_pool->max_count = 0; in fsl_mc_init_all_resource_pools()
545 res_pool->free_count = 0; in fsl_mc_init_all_resource_pools()
546 res_pool->mc_bus = mc_bus; in fsl_mc_init_all_resource_pools()
547 INIT_LIST_HEAD(&res_pool->free_list); in fsl_mc_init_all_resource_pools()
548 mutex_init(&res_pool->mutex); in fsl_mc_init_all_resource_pools()
558 struct fsl_mc_resource_pool *res_pool = in fsl_mc_cleanup_resource_pool() local
562 list_for_each_entry_safe(resource, next, &res_pool->free_list, node) { in fsl_mc_cleanup_resource_pool()