All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Roger Pau Monne <roger.pau@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>
Subject: [PATCH v3 2/6] x86/vioapic: issue EOI to dpci when switching pin to edge trigger mode
Date: Tue, 26 Jan 2021 14:45:17 +0100	[thread overview]
Message-ID: <20210126134521.25784-3-roger.pau@citrix.com> (raw)
In-Reply-To: <20210126134521.25784-1-roger.pau@citrix.com>

When an IO-APIC pin is switched from level to edge trigger mode the
IRR bit is cleared, so it can be used as a way to EOI an interrupt at
the IO-APIC level.

Such EOI however does not get forwarded to the dpci code like it's
done for the local APIC initiated EOI. This change adds the code in
order to notify dpci of such EOI, so that dpci and the interrupt
controller are in sync.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v2:
 - Fix comment message missing 'edge'.
 - Add asserts that previous triggering mode was level and it's not a
   top word write.
---
 xen/arch/x86/hvm/vioapic.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
index e3ee747b7d..87370dd417 100644
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -219,6 +219,7 @@ static void vioapic_write_redirent(
     struct domain *d = vioapic_domain(vioapic);
     struct hvm_irq *hvm_irq = hvm_domain_irq(d);
     union vioapic_redir_entry *pent, ent;
+    bool prev_level;
     int unmasked = 0;
     unsigned int gsi;
 
@@ -234,6 +235,7 @@ static void vioapic_write_redirent(
 
     pent = &vioapic->redirtbl[idx];
     ent  = *pent;
+    prev_level = ent.fields.trig_mode == VIOAPIC_LEVEL_TRIG;
 
     if ( top_word )
     {
@@ -270,6 +272,21 @@ static void vioapic_write_redirent(
 
     spin_unlock(&d->arch.hvm.irq_lock);
 
+    if ( ent.fields.trig_mode == VIOAPIC_EDGE_TRIG &&
+         ent.fields.remote_irr && is_iommu_enabled(d) )
+    {
+            /*
+             * Since IRR has been cleared and further interrupts can be
+             * injected also attempt to deassert any virtual line of passed
+             * through devices using this pin. Switching a pin from level to
+             * edge trigger mode can be used as a way to EOI an interrupt at
+             * the IO-APIC level.
+             */
+            ASSERT(prev_level);
+            ASSERT(!top_word);
+            hvm_dpci_eoi(d, gsi);
+    }
+
     if ( is_hardware_domain(d) && unmasked )
     {
         /*
-- 
2.29.2



  parent reply	other threads:[~2021-01-26 13:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 13:45 [PATCH v3 0/6] x86/intr: HVM guest interrupt handling fixes/cleanup Roger Pau Monne
2021-01-26 13:45 ` [PATCH v3 1/6] x86/vioapic: top word redir entry writes don't trigger interrupts Roger Pau Monne
2021-01-26 15:24   ` Jan Beulich
2021-01-26 13:45 ` Roger Pau Monne [this message]
2021-01-26 15:25   ` [PATCH v3 2/6] x86/vioapic: issue EOI to dpci when switching pin to edge trigger mode Jan Beulich
2021-01-26 13:45 ` [PATCH v3 3/6] x86/vpic: force int output to low when in init mode Roger Pau Monne
2021-01-26 16:50   ` Jan Beulich
2021-01-26 13:45 ` [PATCH v3 4/6] x86/vpic: don't trigger unmask event until end of init Roger Pau Monne
2021-01-26 16:53   ` Jan Beulich
2021-01-26 13:45 ` [PATCH v3 5/6] x86/vpic: issue dpci EOI for cleared pins at ICW1 Roger Pau Monne
2021-01-26 16:57   ` Jan Beulich
2021-01-27  9:15     ` Roger Pau Monné
2021-01-27  9:30       ` Jan Beulich
2021-04-20  9:32     ` Jan Beulich
2021-01-26 13:45 ` [PATCH v3 6/6] x86/dpci: remove the dpci EOI timer Roger Pau Monne
2021-01-26 17:07 ` [PATCH v3 0/6] x86/intr: HVM guest interrupt handling fixes/cleanup Jan Beulich
2021-01-27  9:21   ` Roger Pau Monné

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=20210126134521.25784-3-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.