The single command helpers only log an error when the command queue is full or a command times out. The vSGI CLEAR, PROP_UPDATE_VSGI, and domain activate callbacks therefore return 0 even when the VSGI command or its trailing SYNC/VSYNC failed. Return the error from the single command helpers and propagate it through its_configure_sgi() to these three callbacks, so irq_domain_activate_irq() does not mark an IRQ activated after a failed configuration and KVM callers observe failures. Command posting behaviour and other callers are unchanged. An error only means completion could not be confirmed; a timed-out command may still execute later. Existing WARN_ON() and WARN_RATELIMIT() in the KVM vSGI MMIO handlers now trigger on ITS failures instead of only logging. Signed-off-by: Jia He --- drivers/irqchip/irq-gic-v3-its.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 282e4bafb084..b302d1ea446c 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1212,7 +1212,7 @@ static int its_wait_for_range_completion(struct its_node *its, /* Warning, macro hell follows */ #define BUILD_SINGLE_CMD_FUNC(name, buildtype, synctype, buildfn) \ -void name(struct its_node *its, \ +int name(struct its_node *its, \ buildtype builder, \ struct its_cmd_desc *desc) \ { \ @@ -1220,21 +1220,24 @@ void name(struct its_node *its, \ synctype *sync_obj; \ unsigned long flags; \ u64 rd_idx; \ + int ret = 0; \ \ raw_spin_lock_irqsave(&its->lock, flags); \ \ cmd = its_allocate_entry(its); \ if (!cmd) { /* We're soooooo screewed... */ \ raw_spin_unlock_irqrestore(&its->lock, flags); \ - return; \ + return -EBUSY; \ } \ sync_obj = builder(its, cmd, desc); \ its_flush_cmd(its, cmd); \ \ if (sync_obj) { \ sync_cmd = its_allocate_entry(its); \ - if (!sync_cmd) \ + if (!sync_cmd) { \ + ret = -EBUSY; \ goto post; \ + } \ \ buildfn(its, sync_cmd, sync_obj); \ its_flush_cmd(its, sync_cmd); \ @@ -1245,8 +1248,11 @@ post: \ next_cmd = its_post_commands(its); \ raw_spin_unlock_irqrestore(&its->lock, flags); \ \ - if (its_wait_for_range_completion(its, rd_idx, next_cmd)) \ + if (its_wait_for_range_completion(its, rd_idx, next_cmd)) { \ pr_err_ratelimited("ITS cmd %ps failed\n", builder); \ + ret = -ETIMEDOUT; \ + } \ + return ret; \ } static void its_build_sync_cmd(struct its_node *its, @@ -4333,7 +4339,7 @@ static struct irq_chip its_vpe_4_1_irq_chip = { .irq_set_vcpu_affinity = its_vpe_4_1_set_vcpu_affinity, }; -static void its_configure_sgi(struct irq_data *d, bool clear) +static int its_configure_sgi(struct irq_data *d, bool clear) { struct its_vpe *vpe = irq_data_get_irq_chip_data(d); struct its_cmd_desc desc; @@ -4350,7 +4356,7 @@ static void its_configure_sgi(struct irq_data *d, bool clear) * destination VPE is mapped there. Since we map them eagerly at * activation time, we're pretty sure the first GICv4.1 ITS will do. */ - its_send_single_vcommand(find_4_1_its(), its_build_vsgi_cmd, &desc); + return its_send_single_vcommand(find_4_1_its(), its_build_vsgi_cmd, &desc); } static void its_sgi_mask_irq(struct irq_data *d) @@ -4398,7 +4404,7 @@ static int its_sgi_set_irqchip_state(struct irq_data *d, val |= FIELD_PREP(GITS_SGIR_VINTID, d->hwirq); writeq_relaxed(val, its->sgir_base + GITS_SGIR - SZ_128K); } else { - its_configure_sgi(d, true); + return its_configure_sgi(d, true); } return 0; @@ -4466,8 +4472,7 @@ static int its_sgi_set_vcpu_affinity(struct irq_data *d, void *vcpu_info) case PROP_UPDATE_VSGI: vpe->sgi_config[d->hwirq].priority = info->priority; vpe->sgi_config[d->hwirq].group = info->group; - its_configure_sgi(d, false); - return 0; + return its_configure_sgi(d, false); default: return -EINVAL; @@ -4518,8 +4523,7 @@ static int its_sgi_irq_domain_activate(struct irq_domain *domain, struct irq_data *d, bool reserve) { /* Write out the initial SGI configuration */ - its_configure_sgi(d, false); - return 0; + return its_configure_sgi(d, false); } static void its_sgi_irq_domain_deactivate(struct irq_domain *domain, -- 2.34.1