mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guanghui Feng <guanghuifeng@linux.alibaba.com>
To: joro@8bytes.org, vasant.hegde@amd.com,
	suravee.suthikulpanit@amd.com, will@kernel.org,
	robin.murphy@arm.com
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH] iommu/amd: Do not clear unobserved log overflow status bits
Date: Mon, 16 Nov 2026 11:39:02 +0800	[thread overview]
Message-ID: <20261116033902.3277875-1-guanghuifeng@linux.alibaba.com> (raw)

amd_iommu_handle_irq() clears the interrupt status with an unconditional
writel(mask, MMIO_STATUS_OFFSET), where mask is int_mask | overflow_mask.
The log overflow status bits (GALOverflow, EventOverflow, PprOverflow)
are RW1C and, per the AMD IOMMU spec, transitioning them from 0 to 1 does
not itself generate an interrupt; they can only be observed by an IRQ
round triggered by the corresponding log-interrupt bit.

If hardware sets an overflow bit after the status register is sampled at
the top of the loop but before the unconditional writel(), that write
clears the freshly-set bit while the stale sampled status does not
contain it, so overflow_handler() is skipped for an overflow that really
happened. For the GA log this is fatal: amd_iommu_restart_ga_log() is the
only recovery path, and per spec section 2.7.4 logging stays halted until
GALogEn is toggled. A bare W1C of GALOverflow is not part of the
documented recovery, so the GA log stays halted, no further entries are
written, GAInt never re-asserts and the GA log interrupt line goes
permanently silent, losing all AVIC non-running vCPU wakeups on that
IOMMU.

Clear only the bits actually observed this round by writing status & mask
instead of mask. An overflow bit set concurrently is then left asserted
and is picked up by the existing ERBT1312 status read-back at the bottom
of the loop, which re-enters the loop and runs overflow_handler().

Fixes: 2379f3485239 ("iommu/amd: Refactor IOMMU interrupt handling logic for Event, PPR, and GA logs")
Signed-off-by: Guanghui Feng <guanghuifeng@linux.alibaba.com>
---
 drivers/iommu/amd/iommu.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index d0d55c93a480..39254671b924 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -1168,8 +1168,17 @@ static void amd_iommu_handle_irq(void *data, const char *evt_type,
 	u32 mask = int_mask | overflow_mask;
 
 	while (status & mask) {
-		/* Enable interrupt sources again */
-		writel(mask, iommu->mmio_base + MMIO_STATUS_OFFSET);
+		/*
+		 * Clear only the status bits observed in this round.  The log
+		 * overflow bits (GALOverflow/EventOverflow/PprOverflow) are RW1C
+		 * and do not raise an interrupt on their own; clearing them
+		 * unconditionally here would drop an overflow that hardware set
+		 * between the readl() above and this write, without ever running
+		 * overflow_handler().  Leaving such a bit asserted lets the
+		 * existing ERBT1312 read-back below re-observe it and re-enter
+		 * the loop so overflow_handler() runs.
+		 */
+		writel(status & mask, iommu->mmio_base + MMIO_STATUS_OFFSET);
 
 		if (int_handler) {
 			pr_devel("Processing IOMMU (ivhd%d) %s Log\n",
-- 
2.43.7


                 reply	other threads:[~2026-11-16  3:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261116033902.3277875-1-guanghuifeng@linux.alibaba.com \
    --to=guanghuifeng@linux.alibaba.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=will@kernel.org \
    /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®