Skip to content

Commit faab52b

Browse files
NunoDasNevesliuw
authored andcommitted
x86/hyperv: Clean up hv_map/unmap_interrupt() return values
Fix the return values of these hypercall helpers so they return a negated errno either directly or via hv_result_to_errno(). Update the callers to check for errno instead of using hv_status_success(), and remove redundant error printing. While at it, rearrange some variable declarations to adhere to style guidelines i.e. "reverse fir tree order". Signed-off-by: Nuno Das Neves <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/1751582677-30930-5-git-send-email-nunodasneves@linux.microsoft.com Signed-off-by: Wei Liu <[email protected]> Message-ID: <1751582677-30930-5-git-send-email-nunodasneves@linux.microsoft.com>
1 parent bb169f8 commit faab52b

File tree

2 files changed

+26
-39
lines changed

2 files changed

+26
-39
lines changed

arch/x86/hyperv/irqdomain.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int hv_map_interrupt(union hv_device_id device_id, bool level,
4747
if (nr_bank < 0) {
4848
local_irq_restore(flags);
4949
pr_err("%s: unable to generate VP set\n", __func__);
50-
return EINVAL;
50+
return -EINVAL;
5151
}
5252
intr_desc->target.flags = HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET;
5353

@@ -67,7 +67,7 @@ static int hv_map_interrupt(union hv_device_id device_id, bool level,
6767
if (!hv_result_success(status))
6868
hv_status_err(status, "\n");
6969

70-
return hv_result(status);
70+
return hv_result_to_errno(status);
7171
}
7272

7373
static int hv_unmap_interrupt(u64 id, struct hv_interrupt_entry *old_entry)
@@ -89,7 +89,10 @@ static int hv_unmap_interrupt(u64 id, struct hv_interrupt_entry *old_entry)
8989
status = hv_do_hypercall(HVCALL_UNMAP_DEVICE_INTERRUPT, input, NULL);
9090
local_irq_restore(flags);
9191

92-
return hv_result(status);
92+
if (!hv_result_success(status))
93+
hv_status_err(status, "\n");
94+
95+
return hv_result_to_errno(status);
9396
}
9497

9598
#ifdef CONFIG_PCI_MSI
@@ -189,12 +192,11 @@ static inline void entry_to_msi_msg(struct hv_interrupt_entry *entry, struct msi
189192
static int hv_unmap_msi_interrupt(struct pci_dev *dev, struct hv_interrupt_entry *old_entry);
190193
static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
191194
{
192-
struct msi_desc *msidesc;
193-
struct pci_dev *dev;
194195
struct hv_interrupt_entry out_entry, *stored_entry;
195196
struct irq_cfg *cfg = irqd_cfg(data);
196-
int cpu;
197-
u64 status;
197+
struct msi_desc *msidesc;
198+
struct pci_dev *dev;
199+
int cpu, ret;
198200

199201
msidesc = irq_data_get_msi_desc(data);
200202
dev = msi_desc_to_pci_dev(msidesc);
@@ -218,14 +220,12 @@ static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
218220
stored_entry = data->chip_data;
219221
data->chip_data = NULL;
220222

221-
status = hv_unmap_msi_interrupt(dev, stored_entry);
223+
ret = hv_unmap_msi_interrupt(dev, stored_entry);
222224

223225
kfree(stored_entry);
224226

225-
if (status != HV_STATUS_SUCCESS) {
226-
hv_status_debug(status, "failed to unmap\n");
227+
if (ret)
227228
return;
228-
}
229229
}
230230

231231
stored_entry = kzalloc(sizeof(*stored_entry), GFP_ATOMIC);
@@ -234,8 +234,8 @@ static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
234234
return;
235235
}
236236

237-
status = hv_map_msi_interrupt(dev, cpu, cfg->vector, &out_entry);
238-
if (status != HV_STATUS_SUCCESS) {
237+
ret = hv_map_msi_interrupt(dev, cpu, cfg->vector, &out_entry);
238+
if (ret) {
239239
kfree(stored_entry);
240240
return;
241241
}
@@ -256,7 +256,6 @@ static void hv_teardown_msi_irq(struct pci_dev *dev, struct irq_data *irqd)
256256
{
257257
struct hv_interrupt_entry old_entry;
258258
struct msi_msg msg;
259-
u64 status;
260259

261260
if (!irqd->chip_data) {
262261
pr_debug("%s: no chip data\n!", __func__);
@@ -269,10 +268,7 @@ static void hv_teardown_msi_irq(struct pci_dev *dev, struct irq_data *irqd)
269268
kfree(irqd->chip_data);
270269
irqd->chip_data = NULL;
271270

272-
status = hv_unmap_msi_interrupt(dev, &old_entry);
273-
274-
if (status != HV_STATUS_SUCCESS)
275-
hv_status_err(status, "\n");
271+
(void)hv_unmap_msi_interrupt(dev, &old_entry);
276272
}
277273

278274
static void hv_msi_free_irq(struct irq_domain *domain,

drivers/iommu/hyperv-iommu.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,13 @@ struct hyperv_root_ir_data {
193193
static void
194194
hyperv_root_ir_compose_msi_msg(struct irq_data *irq_data, struct msi_msg *msg)
195195
{
196-
u64 status;
197-
u32 vector;
198-
struct irq_cfg *cfg;
199-
int ioapic_id;
200-
const struct cpumask *affinity;
201-
int cpu;
202-
struct hv_interrupt_entry entry;
203196
struct hyperv_root_ir_data *data = irq_data->chip_data;
197+
struct hv_interrupt_entry entry;
198+
const struct cpumask *affinity;
204199
struct IO_APIC_route_entry e;
200+
struct irq_cfg *cfg;
201+
int cpu, ioapic_id;
202+
u32 vector;
205203

206204
cfg = irqd_cfg(irq_data);
207205
affinity = irq_data_get_effective_affinity_mask(irq_data);
@@ -214,23 +212,16 @@ hyperv_root_ir_compose_msi_msg(struct irq_data *irq_data, struct msi_msg *msg)
214212
&& data->entry.ioapic_rte.as_uint64) {
215213
entry = data->entry;
216214

217-
status = hv_unmap_ioapic_interrupt(ioapic_id, &entry);
218-
219-
if (status != HV_STATUS_SUCCESS)
220-
hv_status_debug(status, "failed to unmap\n");
215+
(void)hv_unmap_ioapic_interrupt(ioapic_id, &entry);
221216

222217
data->entry.ioapic_rte.as_uint64 = 0;
223218
data->entry.source = 0; /* Invalid source */
224219
}
225220

226221

227-
status = hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu,
228-
vector, &entry);
229-
230-
if (status != HV_STATUS_SUCCESS) {
231-
hv_status_err(status, "map failed\n");
222+
if (hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu,
223+
vector, &entry))
232224
return;
233-
}
234225

235226
data->entry = entry;
236227

@@ -322,10 +313,10 @@ static void hyperv_root_irq_remapping_free(struct irq_domain *domain,
322313
data = irq_data->chip_data;
323314
e = &data->entry;
324315

325-
if (e->source == HV_DEVICE_TYPE_IOAPIC
326-
&& e->ioapic_rte.as_uint64)
327-
hv_unmap_ioapic_interrupt(data->ioapic_id,
328-
&data->entry);
316+
if (e->source == HV_DEVICE_TYPE_IOAPIC &&
317+
e->ioapic_rte.as_uint64)
318+
(void)hv_unmap_ioapic_interrupt(data->ioapic_id,
319+
&data->entry);
329320

330321
kfree(data);
331322
}

0 commit comments

Comments
 (0)