mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jia He <justin.he@arm.com>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>
Cc: nd@arm.com, Jia He <justin.he@arm.com>,
	Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Fuad Tabba <fuad.tabba@linux.dev>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Radu Rendec <radu@rendec.net>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Shuah Khan <shuah@kernel.org>,
	Ricardo Koller <ricarkol@google.com>,
	Andrew Jones <andrew.jones@linux.dev>,
	kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 02/10] irqchip/gic-v3-its: Propagate vSGI command queue failures
Date: Sun,  6 Dec 2026 13:53:46 +0000	[thread overview]
Message-ID: <20261206135354.1519499-3-justin.he@arm.com> (raw)
In-Reply-To: <20261206135354.1519499-1-justin.he@arm.com>

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 <justin.he@arm.com>
---
 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


  parent reply	other threads:[~2026-12-06 13:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06 13:53 [PATCH 00/10] KVM: arm64: GICv4.1 vSGI error handling and VGIC state fixes Jia He
2026-12-06 13:53 ` [PATCH 01/10] KVM: arm64: Preserve vSGI state when pending queries fail Jia He
2026-12-06 13:53 ` Jia He [this message]
2026-12-06 13:53 ` [PATCH 03/10] KVM: arm64: Stop vSGI enablement on state transfer errors Jia He
2026-12-06 13:53 ` [PATCH 04/10] KVM: arm64: Check clearing the pending state of vSGIs moved to SW Jia He
2026-12-06 13:53 ` [PATCH 05/10] KVM: arm64: vgic: Queue pending interrupts when the distributor is enabled Jia He
2026-12-06 13:53 ` [PATCH 06/10] KVM: arm64: vgic: Pass the enable state of HW SGIs to the ITS Jia He
2026-12-06 13:53 ` [PATCH 07/10] KVM: arm64: Synchronize vSGI state when restoring GICD_CTLR Jia He
2026-12-06 13:53 ` [PATCH 08/10] KVM: arm64: selftests: Avoid read-modify-write for GIC write-one registers Jia He
2026-12-06 13:53 ` [PATCH 09/10] KVM: arm64: selftests: Add vgic_dist_reenable test Jia He
2026-12-06 13:53 ` [PATCH 10/10] KVM: arm64: selftests: Check SGI delivery after VGIC restore Jia He
2026-12-06 16:51 ` [PATCH 00/10] KVM: arm64: GICv4.1 vSGI error handling and VGIC state fixes Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261206135354.1519499-3-justin.he@arm.com \
    --to=justin.he@arm.com \
    --cc=andrew.jones@linux.dev \
    --cc=fuad.tabba@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=nd@arm.com \
    --cc=oupton@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=radu@rendec.net \
    --cc=ricarkol@google.com \
    --cc=seanjc@google.com \
    --cc=seiden@linux.ibm.com \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=tglx@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®