diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2015-12-31 11:30:46 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-01-15 07:43:59 -0500 |
commit | 433cbd57d190a1cdd02f243df41c3d7f55ec4b94 (patch) | |
tree | 8fa629daec768b8ce02448b2d1eedff4df4d98d0 | |
parent | 8a580f70f6936ec095da217018cdeeb5835c0207 (diff) |
x86/irq: Reorganize the return path in assign_irq_vector
Use an explicit goto for the cases where we have success in the search/update
and return -ENOSPC if the search loop ends due to no space.
Preparatory patch for fixes. No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Borislav Petkov <bp@alien8.de>
Tested-by: Joe Lawrence <joe.lawrence@stratus.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Jeremiah Mahler <jmmahler@gmail.com>
Cc: andy.shevchenko@gmail.com
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org #4.3+
Link: http://lkml.kernel.org/r/20151231160106.403491024@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/kernel/apic/vector.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index 19082cf56616..613b1cd8eecb 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c | |||
@@ -118,13 +118,12 @@ static int __assign_irq_vector(int irq, struct apic_chip_data *d, | |||
118 | */ | 118 | */ |
119 | static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START; | 119 | static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START; |
120 | static int current_offset = VECTOR_OFFSET_START % 16; | 120 | static int current_offset = VECTOR_OFFSET_START % 16; |
121 | int cpu, err; | 121 | int cpu; |
122 | 122 | ||
123 | if (d->move_in_progress) | 123 | if (d->move_in_progress) |
124 | return -EBUSY; | 124 | return -EBUSY; |
125 | 125 | ||
126 | /* Only try and allocate irqs on cpus that are present */ | 126 | /* Only try and allocate irqs on cpus that are present */ |
127 | err = -ENOSPC; | ||
128 | cpumask_clear(d->old_domain); | 127 | cpumask_clear(d->old_domain); |
129 | cpumask_clear(searched_cpumask); | 128 | cpumask_clear(searched_cpumask); |
130 | cpu = cpumask_first_and(mask, cpu_online_mask); | 129 | cpu = cpumask_first_and(mask, cpu_online_mask); |
@@ -134,9 +133,8 @@ static int __assign_irq_vector(int irq, struct apic_chip_data *d, | |||
134 | apic->vector_allocation_domain(cpu, vector_cpumask, mask); | 133 | apic->vector_allocation_domain(cpu, vector_cpumask, mask); |
135 | 134 | ||
136 | if (cpumask_subset(vector_cpumask, d->domain)) { | 135 | if (cpumask_subset(vector_cpumask, d->domain)) { |
137 | err = 0; | ||
138 | if (cpumask_equal(vector_cpumask, d->domain)) | 136 | if (cpumask_equal(vector_cpumask, d->domain)) |
139 | break; | 137 | goto success; |
140 | /* | 138 | /* |
141 | * New cpumask using the vector is a proper subset of | 139 | * New cpumask using the vector is a proper subset of |
142 | * the current in use mask. So cleanup the vector | 140 | * the current in use mask. So cleanup the vector |
@@ -147,7 +145,7 @@ static int __assign_irq_vector(int irq, struct apic_chip_data *d, | |||
147 | d->move_in_progress = | 145 | d->move_in_progress = |
148 | cpumask_intersects(d->old_domain, cpu_online_mask); | 146 | cpumask_intersects(d->old_domain, cpu_online_mask); |
149 | cpumask_and(d->domain, d->domain, vector_cpumask); | 147 | cpumask_and(d->domain, d->domain, vector_cpumask); |
150 | break; | 148 | goto success; |
151 | } | 149 | } |
152 | 150 | ||
153 | vector = current_vector; | 151 | vector = current_vector; |
@@ -187,17 +185,13 @@ next: | |||
187 | per_cpu(vector_irq, new_cpu)[vector] = irq_to_desc(irq); | 185 | per_cpu(vector_irq, new_cpu)[vector] = irq_to_desc(irq); |
188 | d->cfg.vector = vector; | 186 | d->cfg.vector = vector; |
189 | cpumask_copy(d->domain, vector_cpumask); | 187 | cpumask_copy(d->domain, vector_cpumask); |
190 | err = 0; | 188 | goto success; |
191 | break; | ||
192 | } | 189 | } |
190 | return -ENOSPC; | ||
193 | 191 | ||
194 | if (!err) { | 192 | success: |
195 | /* cache destination APIC IDs into cfg->dest_apicid */ | 193 | /* cache destination APIC IDs into cfg->dest_apicid */ |
196 | err = apic->cpu_mask_to_apicid_and(mask, d->domain, | 194 | return apic->cpu_mask_to_apicid_and(mask, d->domain, &d->cfg.dest_apicid); |
197 | &d->cfg.dest_apicid); | ||
198 | } | ||
199 | |||
200 | return err; | ||
201 | } | 195 | } |
202 | 196 | ||
203 | static int assign_irq_vector(int irq, struct apic_chip_data *data, | 197 | static int assign_irq_vector(int irq, struct apic_chip_data *data, |