|
@@ -260,11 +260,21 @@ void irq_matrix_remove_managed(struct irq_matrix *m, const struct cpumask *msk)
|
|
|
* @m: Matrix pointer
|
|
|
* @cpu: On which CPU the interrupt should be allocated
|
|
|
*/
|
|
|
-int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned int cpu)
|
|
|
+int irq_matrix_alloc_managed(struct irq_matrix *m, const struct cpumask *msk,
|
|
|
+ unsigned int *mapped_cpu)
|
|
|
{
|
|
|
- struct cpumap *cm = per_cpu_ptr(m->maps, cpu);
|
|
|
- unsigned int bit, end = m->alloc_end;
|
|
|
+ unsigned int bit, cpu, end = m->alloc_end;
|
|
|
+ struct cpumap *cm;
|
|
|
+
|
|
|
+ if (cpumask_empty(msk))
|
|
|
+ return -EINVAL;
|
|
|
|
|
|
+ cpu = matrix_find_best_cpu(m, msk);
|
|
|
+ if (cpu == UINT_MAX)
|
|
|
+ return -ENOSPC;
|
|
|
+
|
|
|
+ cm = per_cpu_ptr(m->maps, cpu);
|
|
|
+ end = m->alloc_end;
|
|
|
/* Get managed bit which are not allocated */
|
|
|
bitmap_andnot(m->scratch_map, cm->managed_map, cm->alloc_map, end);
|
|
|
bit = find_first_bit(m->scratch_map, end);
|
|
@@ -273,6 +283,7 @@ int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned int cpu)
|
|
|
set_bit(bit, cm->alloc_map);
|
|
|
cm->allocated++;
|
|
|
m->total_allocated++;
|
|
|
+ *mapped_cpu = cpu;
|
|
|
trace_irq_matrix_alloc_managed(bit, cpu, m, cm);
|
|
|
return bit;
|
|
|
}
|