Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <nunodasneves@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Link: https://lore.kernel.org/r/1751582677-30930-5-git-send-email-nunodasneves@linux.microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <1751582677-30930-5-git-send-email-nunodasneves@linux.microsoft.com>

authored by

Nuno Das Neves and committed by
Wei Liu
faab52b5 bb169f80

+26 -39
+14 -18
arch/x86/hyperv/irqdomain.c
··· 47 47 if (nr_bank < 0) { 48 48 local_irq_restore(flags); 49 49 pr_err("%s: unable to generate VP set\n", __func__); 50 - return EINVAL; 50 + return -EINVAL; 51 51 } 52 52 intr_desc->target.flags = HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET; 53 53 ··· 67 67 if (!hv_result_success(status)) 68 68 hv_status_err(status, "\n"); 69 69 70 - return hv_result(status); 70 + return hv_result_to_errno(status); 71 71 } 72 72 73 73 static int hv_unmap_interrupt(u64 id, struct hv_interrupt_entry *old_entry) ··· 89 89 status = hv_do_hypercall(HVCALL_UNMAP_DEVICE_INTERRUPT, input, NULL); 90 90 local_irq_restore(flags); 91 91 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); 93 96 } 94 97 95 98 #ifdef CONFIG_PCI_MSI ··· 192 189 static int hv_unmap_msi_interrupt(struct pci_dev *dev, struct hv_interrupt_entry *old_entry); 193 190 static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) 194 191 { 195 - struct msi_desc *msidesc; 196 - struct pci_dev *dev; 197 192 struct hv_interrupt_entry out_entry, *stored_entry; 198 193 struct irq_cfg *cfg = irqd_cfg(data); 199 - int cpu; 200 - u64 status; 194 + struct msi_desc *msidesc; 195 + struct pci_dev *dev; 196 + int cpu, ret; 201 197 202 198 msidesc = irq_data_get_msi_desc(data); 203 199 dev = msi_desc_to_pci_dev(msidesc); ··· 220 218 stored_entry = data->chip_data; 221 219 data->chip_data = NULL; 222 220 223 - status = hv_unmap_msi_interrupt(dev, stored_entry); 221 + ret = hv_unmap_msi_interrupt(dev, stored_entry); 224 222 225 223 kfree(stored_entry); 226 224 227 - if (status != HV_STATUS_SUCCESS) { 228 - hv_status_debug(status, "failed to unmap\n"); 225 + if (ret) 229 226 return; 230 - } 231 227 } 232 228 233 229 stored_entry = kzalloc(sizeof(*stored_entry), GFP_ATOMIC); ··· 234 234 return; 235 235 } 236 236 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) { 239 239 kfree(stored_entry); 240 240 return; 241 241 } ··· 256 256 { 257 257 struct hv_interrupt_entry old_entry; 258 258 struct msi_msg msg; 259 - u64 status; 260 259 261 260 if (!irqd->chip_data) { 262 261 pr_debug("%s: no chip data\n!", __func__); ··· 268 269 kfree(irqd->chip_data); 269 270 irqd->chip_data = NULL; 270 271 271 - status = hv_unmap_msi_interrupt(dev, &old_entry); 272 - 273 - if (status != HV_STATUS_SUCCESS) 274 - hv_status_err(status, "\n"); 272 + (void)hv_unmap_msi_interrupt(dev, &old_entry); 275 273 } 276 274 277 275 static void hv_msi_free_irq(struct irq_domain *domain,
+12 -21
drivers/iommu/hyperv-iommu.c
··· 193 193 static void 194 194 hyperv_root_ir_compose_msi_msg(struct irq_data *irq_data, struct msi_msg *msg) 195 195 { 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; 203 196 struct hyperv_root_ir_data *data = irq_data->chip_data; 197 + struct hv_interrupt_entry entry; 198 + const struct cpumask *affinity; 204 199 struct IO_APIC_route_entry e; 200 + struct irq_cfg *cfg; 201 + int cpu, ioapic_id; 202 + u32 vector; 205 203 206 204 cfg = irqd_cfg(irq_data); 207 205 affinity = irq_data_get_effective_affinity_mask(irq_data); ··· 212 214 && data->entry.ioapic_rte.as_uint64) { 213 215 entry = data->entry; 214 216 215 - status = hv_unmap_ioapic_interrupt(ioapic_id, &entry); 216 - 217 - if (status != HV_STATUS_SUCCESS) 218 - hv_status_debug(status, "failed to unmap\n"); 217 + (void)hv_unmap_ioapic_interrupt(ioapic_id, &entry); 219 218 220 219 data->entry.ioapic_rte.as_uint64 = 0; 221 220 data->entry.source = 0; /* Invalid source */ 222 221 } 223 222 224 223 225 - status = hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu, 226 - vector, &entry); 227 - 228 - if (status != HV_STATUS_SUCCESS) { 229 - hv_status_err(status, "map failed\n"); 224 + if (hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu, 225 + vector, &entry)) 230 226 return; 231 - } 232 227 233 228 data->entry = entry; 234 229 ··· 313 322 data = irq_data->chip_data; 314 323 e = &data->entry; 315 324 316 - if (e->source == HV_DEVICE_TYPE_IOAPIC 317 - && e->ioapic_rte.as_uint64) 318 - hv_unmap_ioapic_interrupt(data->ioapic_id, 319 - &data->entry); 325 + if (e->source == HV_DEVICE_TYPE_IOAPIC && 326 + e->ioapic_rte.as_uint64) 327 + (void)hv_unmap_ioapic_interrupt(data->ioapic_id, 328 + &data->entry); 320 329 321 330 kfree(data); 322 331 }