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>pull/1104/head^2^2
parent
bb169f80ed
commit
faab52b59b
|
|
@ -47,7 +47,7 @@ static int hv_map_interrupt(union hv_device_id device_id, bool level,
|
||||||
if (nr_bank < 0) {
|
if (nr_bank < 0) {
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
pr_err("%s: unable to generate VP set\n", __func__);
|
pr_err("%s: unable to generate VP set\n", __func__);
|
||||||
return EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
intr_desc->target.flags = HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET;
|
intr_desc->target.flags = HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET;
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ static int hv_map_interrupt(union hv_device_id device_id, bool level,
|
||||||
if (!hv_result_success(status))
|
if (!hv_result_success(status))
|
||||||
hv_status_err(status, "\n");
|
hv_status_err(status, "\n");
|
||||||
|
|
||||||
return hv_result(status);
|
return hv_result_to_errno(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hv_unmap_interrupt(u64 id, struct hv_interrupt_entry *old_entry)
|
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)
|
||||||
status = hv_do_hypercall(HVCALL_UNMAP_DEVICE_INTERRUPT, input, NULL);
|
status = hv_do_hypercall(HVCALL_UNMAP_DEVICE_INTERRUPT, input, NULL);
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
|
|
||||||
return hv_result(status);
|
if (!hv_result_success(status))
|
||||||
|
hv_status_err(status, "\n");
|
||||||
|
|
||||||
|
return hv_result_to_errno(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PCI_MSI
|
#ifdef CONFIG_PCI_MSI
|
||||||
|
|
@ -189,12 +192,11 @@ static inline void entry_to_msi_msg(struct hv_interrupt_entry *entry, struct msi
|
||||||
static int hv_unmap_msi_interrupt(struct pci_dev *dev, struct hv_interrupt_entry *old_entry);
|
static int hv_unmap_msi_interrupt(struct pci_dev *dev, struct hv_interrupt_entry *old_entry);
|
||||||
static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
|
static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
|
||||||
{
|
{
|
||||||
struct msi_desc *msidesc;
|
|
||||||
struct pci_dev *dev;
|
|
||||||
struct hv_interrupt_entry out_entry, *stored_entry;
|
struct hv_interrupt_entry out_entry, *stored_entry;
|
||||||
struct irq_cfg *cfg = irqd_cfg(data);
|
struct irq_cfg *cfg = irqd_cfg(data);
|
||||||
int cpu;
|
struct msi_desc *msidesc;
|
||||||
u64 status;
|
struct pci_dev *dev;
|
||||||
|
int cpu, ret;
|
||||||
|
|
||||||
msidesc = irq_data_get_msi_desc(data);
|
msidesc = irq_data_get_msi_desc(data);
|
||||||
dev = msi_desc_to_pci_dev(msidesc);
|
dev = msi_desc_to_pci_dev(msidesc);
|
||||||
|
|
@ -218,15 +220,13 @@ static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
|
||||||
stored_entry = data->chip_data;
|
stored_entry = data->chip_data;
|
||||||
data->chip_data = NULL;
|
data->chip_data = NULL;
|
||||||
|
|
||||||
status = hv_unmap_msi_interrupt(dev, stored_entry);
|
ret = hv_unmap_msi_interrupt(dev, stored_entry);
|
||||||
|
|
||||||
kfree(stored_entry);
|
kfree(stored_entry);
|
||||||
|
|
||||||
if (status != HV_STATUS_SUCCESS) {
|
if (ret)
|
||||||
hv_status_debug(status, "failed to unmap\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stored_entry = kzalloc(sizeof(*stored_entry), GFP_ATOMIC);
|
stored_entry = kzalloc(sizeof(*stored_entry), GFP_ATOMIC);
|
||||||
if (!stored_entry) {
|
if (!stored_entry) {
|
||||||
|
|
@ -234,8 +234,8 @@ static void hv_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = hv_map_msi_interrupt(dev, cpu, cfg->vector, &out_entry);
|
ret = hv_map_msi_interrupt(dev, cpu, cfg->vector, &out_entry);
|
||||||
if (status != HV_STATUS_SUCCESS) {
|
if (ret) {
|
||||||
kfree(stored_entry);
|
kfree(stored_entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -256,7 +256,6 @@ static void hv_teardown_msi_irq(struct pci_dev *dev, struct irq_data *irqd)
|
||||||
{
|
{
|
||||||
struct hv_interrupt_entry old_entry;
|
struct hv_interrupt_entry old_entry;
|
||||||
struct msi_msg msg;
|
struct msi_msg msg;
|
||||||
u64 status;
|
|
||||||
|
|
||||||
if (!irqd->chip_data) {
|
if (!irqd->chip_data) {
|
||||||
pr_debug("%s: no chip data\n!", __func__);
|
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)
|
||||||
kfree(irqd->chip_data);
|
kfree(irqd->chip_data);
|
||||||
irqd->chip_data = NULL;
|
irqd->chip_data = NULL;
|
||||||
|
|
||||||
status = hv_unmap_msi_interrupt(dev, &old_entry);
|
(void)hv_unmap_msi_interrupt(dev, &old_entry);
|
||||||
|
|
||||||
if (status != HV_STATUS_SUCCESS)
|
|
||||||
hv_status_err(status, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hv_msi_free_irq(struct irq_domain *domain,
|
static void hv_msi_free_irq(struct irq_domain *domain,
|
||||||
|
|
|
||||||
|
|
@ -193,15 +193,13 @@ struct hyperv_root_ir_data {
|
||||||
static void
|
static void
|
||||||
hyperv_root_ir_compose_msi_msg(struct irq_data *irq_data, struct msi_msg *msg)
|
hyperv_root_ir_compose_msi_msg(struct irq_data *irq_data, struct msi_msg *msg)
|
||||||
{
|
{
|
||||||
u64 status;
|
|
||||||
u32 vector;
|
|
||||||
struct irq_cfg *cfg;
|
|
||||||
int ioapic_id;
|
|
||||||
const struct cpumask *affinity;
|
|
||||||
int cpu;
|
|
||||||
struct hv_interrupt_entry entry;
|
|
||||||
struct hyperv_root_ir_data *data = irq_data->chip_data;
|
struct hyperv_root_ir_data *data = irq_data->chip_data;
|
||||||
|
struct hv_interrupt_entry entry;
|
||||||
|
const struct cpumask *affinity;
|
||||||
struct IO_APIC_route_entry e;
|
struct IO_APIC_route_entry e;
|
||||||
|
struct irq_cfg *cfg;
|
||||||
|
int cpu, ioapic_id;
|
||||||
|
u32 vector;
|
||||||
|
|
||||||
cfg = irqd_cfg(irq_data);
|
cfg = irqd_cfg(irq_data);
|
||||||
affinity = irq_data_get_effective_affinity_mask(irq_data);
|
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)
|
||||||
&& data->entry.ioapic_rte.as_uint64) {
|
&& data->entry.ioapic_rte.as_uint64) {
|
||||||
entry = data->entry;
|
entry = data->entry;
|
||||||
|
|
||||||
status = hv_unmap_ioapic_interrupt(ioapic_id, &entry);
|
(void)hv_unmap_ioapic_interrupt(ioapic_id, &entry);
|
||||||
|
|
||||||
if (status != HV_STATUS_SUCCESS)
|
|
||||||
hv_status_debug(status, "failed to unmap\n");
|
|
||||||
|
|
||||||
data->entry.ioapic_rte.as_uint64 = 0;
|
data->entry.ioapic_rte.as_uint64 = 0;
|
||||||
data->entry.source = 0; /* Invalid source */
|
data->entry.source = 0; /* Invalid source */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status = hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu,
|
if (hv_map_ioapic_interrupt(ioapic_id, data->is_level, cpu,
|
||||||
vector, &entry);
|
vector, &entry))
|
||||||
|
|
||||||
if (status != HV_STATUS_SUCCESS) {
|
|
||||||
hv_status_err(status, "map failed\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
data->entry = entry;
|
data->entry = entry;
|
||||||
|
|
||||||
|
|
@ -322,9 +313,9 @@ static void hyperv_root_irq_remapping_free(struct irq_domain *domain,
|
||||||
data = irq_data->chip_data;
|
data = irq_data->chip_data;
|
||||||
e = &data->entry;
|
e = &data->entry;
|
||||||
|
|
||||||
if (e->source == HV_DEVICE_TYPE_IOAPIC
|
if (e->source == HV_DEVICE_TYPE_IOAPIC &&
|
||||||
&& e->ioapic_rte.as_uint64)
|
e->ioapic_rte.as_uint64)
|
||||||
hv_unmap_ioapic_interrupt(data->ioapic_id,
|
(void)hv_unmap_ioapic_interrupt(data->ioapic_id,
|
||||||
&data->entry);
|
&data->entry);
|
||||||
|
|
||||||
kfree(data);
|
kfree(data);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue