Lines Matching refs:pool
8 static void cpu_put(struct mlx5_irq_pool *pool, int cpu) in cpu_put() argument
10 pool->irqs_per_cpu[cpu]--; in cpu_put()
13 static void cpu_get(struct mlx5_irq_pool *pool, int cpu) in cpu_get() argument
15 pool->irqs_per_cpu[cpu]++; in cpu_get()
19 static int cpu_get_least_loaded(struct mlx5_irq_pool *pool, in cpu_get_least_loaded() argument
27 if (!pool->irqs_per_cpu[cpu]) { in cpu_get_least_loaded()
33 if (pool->irqs_per_cpu[cpu] < pool->irqs_per_cpu[best_cpu]) in cpu_get_least_loaded()
38 mlx5_core_err(pool->dev, "NO online CPUs in req_mask (%*pbl)\n", in cpu_get_least_loaded()
42 pool->irqs_per_cpu[best_cpu]++; in cpu_get_least_loaded()
48 irq_pool_request_irq(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_desc) in irq_pool_request_irq() argument
55 err = xa_alloc(&pool->irqs, &irq_index, NULL, pool->xa_num_irqs, GFP_KERNEL); in irq_pool_request_irq()
58 if (pool->irqs_per_cpu) { in irq_pool_request_irq()
63 cpumask_set_cpu(cpu_get_least_loaded(pool, &af_desc->mask), in irq_pool_request_irq()
66 cpu_get(pool, cpumask_first(&af_desc->mask)); in irq_pool_request_irq()
68 irq = mlx5_irq_alloc(pool, irq_index, in irq_pool_request_irq()
72 xa_erase(&pool->irqs, irq_index); in irq_pool_request_irq()
86 irq_pool_find_least_loaded(struct mlx5_irq_pool *pool, const struct cpumask *req_mask) in irq_pool_find_least_loaded() argument
88 int start = pool->xa_num_irqs.min; in irq_pool_find_least_loaded()
89 int end = pool->xa_num_irqs.max; in irq_pool_find_least_loaded()
95 lockdep_assert_held(&pool->lock); in irq_pool_find_least_loaded()
96 xa_for_each_range(&pool->irqs, index, iter, start, end) { in irq_pool_find_least_loaded()
103 if (iter_refcount < pool->min_threshold) in irq_pool_find_least_loaded()
125 mlx5_irq_affinity_request(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_desc) in mlx5_irq_affinity_request() argument
129 mutex_lock(&pool->lock); in mlx5_irq_affinity_request()
130 least_loaded_irq = irq_pool_find_least_loaded(pool, &af_desc->mask); in mlx5_irq_affinity_request()
132 mlx5_irq_read_locked(least_loaded_irq) < pool->min_threshold) in mlx5_irq_affinity_request()
135 new_irq = irq_pool_request_irq(pool, af_desc); in mlx5_irq_affinity_request()
139 mlx5_core_err(pool->dev, "Didn't find a matching IRQ. err = %ld\n", in mlx5_irq_affinity_request()
141 mutex_unlock(&pool->lock); in mlx5_irq_affinity_request()
153 if (mlx5_irq_read_locked(least_loaded_irq) > pool->max_threshold) in mlx5_irq_affinity_request()
154 mlx5_core_dbg(pool->dev, "IRQ %u overloaded, pool_name: %s, %u EQs on this irq\n", in mlx5_irq_affinity_request()
155 pci_irq_vector(pool->dev->pdev, in mlx5_irq_affinity_request()
156 mlx5_irq_get_index(least_loaded_irq)), pool->name, in mlx5_irq_affinity_request()
159 mutex_unlock(&pool->lock); in mlx5_irq_affinity_request()
165 struct mlx5_irq_pool *pool = mlx5_irq_pool_get(dev); in mlx5_irq_affinity_irq_release() local
169 synchronize_irq(pci_irq_vector(pool->dev->pdev, in mlx5_irq_affinity_irq_release()
172 if (pool->irqs_per_cpu) in mlx5_irq_affinity_irq_release()
173 cpu_put(pool, cpu); in mlx5_irq_affinity_irq_release()