From: Feng Wu <feng.wu@intel.com>
To: xen-devel@lists.xen.org
Cc: kevin.tian@intel.com, Feng Wu <feng.wu@intel.com>,
george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
dario.faggioli@citrix.com, jbeulich@suse.com
Subject: [PATCH v8 5/7] VT-d: No need to set irq affinity for posted format IRTE
Date: Fri, 18 Nov 2016 09:57:22 +0800 [thread overview]
Message-ID: <1479434244-10223-6-git-send-email-feng.wu@intel.com> (raw)
In-Reply-To: <1479434244-10223-1-git-send-email-feng.wu@intel.com>
We don't set the affinity for posted format IRTE, since the
destination of these interrupts is vCPU and the vCPU affinity
is set during vCPU scheduling.
Signed-off-by: Feng Wu <feng.wu@intel.com>
---
v8:
- Changes based on [6/7]
v7:
- Compare all the field in IRTE to justify whether we can suppress the update
v6:
- Make pi_can_suppress_irte_update() a check-only function
- Introduce another function pi_get_new_irte() to update the 'new_ire' if needed
v5:
- Only suppress affinity related IRTE updates for PI
v4:
- Keep the construction of new_ire and only modify the hardware
IRTE when it is not in posted mode.
xen/drivers/passthrough/vtd/intremap.c | 87 ++++++++++++++++++++--------------
1 file changed, 52 insertions(+), 35 deletions(-)
diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c
index fd2a49a..0cb8c37 100644
--- a/xen/drivers/passthrough/vtd/intremap.c
+++ b/xen/drivers/passthrough/vtd/intremap.c
@@ -600,27 +600,41 @@ static int msi_msg_to_remap_entry(
if ( !pi_desc )
{
- /* Set interrupt remapping table entry */
- new_ire.remap.fpd = 0;
- new_ire.remap.dm = (msg->address_lo >> MSI_ADDR_DESTMODE_SHIFT) & 0x1;
- new_ire.remap.tm = (msg->data >> MSI_DATA_TRIGGER_SHIFT) & 0x1;
- new_ire.remap.dlm = (msg->data >> MSI_DATA_DELIVERY_MODE_SHIFT) & 0x1;
- /* Hardware require RH = 1 for LPR delivery mode */
- new_ire.remap.rh = (new_ire.remap.dlm == dest_LowestPrio);
- new_ire.remap.avail = 0;
- new_ire.remap.res_1 = 0;
- new_ire.remap.vector = (msg->data >> MSI_DATA_VECTOR_SHIFT) &
- MSI_DATA_VECTOR_MASK;
- new_ire.remap.res_2 = 0;
- if ( x2apic_enabled )
- new_ire.remap.dst = msg->dest32;
- else
- new_ire.remap.dst = ((msg->address_lo >> MSI_ADDR_DEST_ID_SHIFT)
- & 0xff) << 8;
+ /*
+ * We are here because we are trying to update the IRTE to remapped mode,
+ * we only need to update the remapped specific fields for the following
+ * two cases:
+ * 1. When we create a new IRTE. A new IRTE is created when we create a
+ * new irq, so a new IRTE is always initialized with remapped format.
+ * 2. When the old IRTE is present and in remapped mode. Since if the old
+ * IRTE is in posted mode, we cannot update it to remapped mode and
+ * this is what we need to suppress. So we don't update the remapped
+ * specific fields here, we only update the commom field.
+ */
+ if ( !iremap_entry->remap.p || !iremap_entry->remap.im )
+ {
+ /* Set interrupt remapping table entry */
+ new_ire.remap.fpd = 0;
+ new_ire.remap.dm = (msg->address_lo >> MSI_ADDR_DESTMODE_SHIFT) & 0x1;
+ new_ire.remap.tm = (msg->data >> MSI_DATA_TRIGGER_SHIFT) & 0x1;
+ new_ire.remap.dlm = (msg->data >> MSI_DATA_DELIVERY_MODE_SHIFT) & 0x1;
+ /* Hardware require RH = 1 for LPR delivery mode */
+ new_ire.remap.rh = (new_ire.remap.dlm == dest_LowestPrio);
+ new_ire.remap.avail = 0;
+ new_ire.remap.res_1 = 0;
+ new_ire.remap.vector = (msg->data >> MSI_DATA_VECTOR_SHIFT) &
+ MSI_DATA_VECTOR_MASK;
+ new_ire.remap.res_2 = 0;
+ if ( x2apic_enabled )
+ new_ire.remap.dst = msg->dest32;
+ else
+ new_ire.remap.dst = ((msg->address_lo >> MSI_ADDR_DEST_ID_SHIFT)
+ & 0xff) << 8;
- new_ire.remap.res_3 = 0;
- new_ire.remap.res_4 = 0;
- new_ire.remap.p = 1; /* finally, set present bit */
+ new_ire.remap.res_3 = 0;
+ new_ire.remap.res_4 = 0;
+ new_ire.remap.p = 1; /* finally, set present bit */
+ }
}
else
{
@@ -657,25 +671,28 @@ static int msi_msg_to_remap_entry(
remap_rte->address_hi = 0;
remap_rte->data = index - i;
- if ( !pi_desc )
- memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry));
- else
+ if ( iremap_entry->val != new_ire.val )
{
- __uint128_t ret;
+ if ( !pi_desc )
+ memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry));
+ else
+ {
+ __uint128_t ret;
- old_ire = *iremap_entry;
- ret = cmpxchg16b(iremap_entry, &old_ire, &new_ire);
+ old_ire = *iremap_entry;
+ ret = cmpxchg16b(iremap_entry, &old_ire, &new_ire);
- /*
- * In the above, we use cmpxchg16 to atomically update the 128-bit IRTE,
- * and the hardware cannot update the IRTE behind us, so the return value
- * of cmpxchg16 should be the same as old_ire. This ASSERT validate it.
- */
- ASSERT(ret == old_ire.val);
- }
+ /*
+ * In the above, we use cmpxchg16 to atomically update the 128-bit IRTE,
+ * and the hardware cannot update the IRTE behind us, so the return value
+ * of cmpxchg16 should be the same as old_ire. This ASSERT validate it.
+ */
+ ASSERT(ret == old_ire.val);
+ }
- iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry));
- iommu_flush_iec_index(iommu, 0, index);
+ iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry));
+ iommu_flush_iec_index(iommu, 0, index);
+ }
unmap_vtd_domain_page(iremap_entries);
spin_unlock_irqrestore(&ir_ctrl->iremap_lock, flags);
--
2.1.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-11-18 1:57 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-18 1:57 [PATCH v8 0/7] VMX: Properly handle pi descriptor and per-cpu blocking list Feng Wu
2016-11-18 1:57 ` [PATCH v8 1/7] VMX: Permanently assign PI hook vmx_pi_switch_to() Feng Wu
2016-11-18 3:14 ` Tian, Kevin
2016-11-18 4:23 ` Wu, Feng
2016-11-18 1:57 ` [PATCH v8 2/7] VMX: Properly handle pi when all the assigned devices are removed Feng Wu
2016-11-18 3:19 ` Tian, Kevin
2016-11-18 4:27 ` Wu, Feng
2016-11-18 4:58 ` Tian, Kevin
2016-11-18 5:22 ` Wu, Feng
2016-11-18 9:23 ` Jan Beulich
2016-11-18 1:57 ` [PATCH v8 3/7] VMX: Make sure PI is in proper state before install the hooks Feng Wu
2016-11-18 4:11 ` Tian, Kevin
2016-11-18 4:27 ` Wu, Feng
2016-11-18 1:57 ` [PATCH v8 4/7] VT-d: Use one function to update both remapped and posted IRTE Feng Wu
2016-11-18 4:31 ` Tian, Kevin
2016-11-22 4:31 ` Wu, Feng
2016-11-22 9:58 ` Jan Beulich
2017-02-22 1:53 ` Chao Gao
2017-02-22 9:10 ` Jan Beulich
2017-02-22 7:12 ` Chao Gao
2017-02-22 14:54 ` Jan Beulich
2016-11-18 1:57 ` Feng Wu [this message]
2016-11-18 1:57 ` [PATCH v8 6/7] VT-d: Some cleanups Feng Wu
2016-11-18 4:45 ` Tian, Kevin
2016-11-18 1:57 ` [PATCH v8 7/7] VMX: Fixup PI descriptor when cpu is offline Feng Wu
2016-11-18 4:55 ` Tian, Kevin
2016-11-18 3:02 ` [PATCH v8 0/7] VMX: Properly handle pi descriptor and per-cpu blocking list Tian, Kevin
2016-11-18 4:21 ` Wu, Feng
2017-02-21 21:30 ` Chao Gao
-- strict thread matches above, loose matches on Subject: below --
2016-11-18 1:58 [PATCH v8 5/7] VT-d: No need to set irq affinity for posted format IRTE Feng Wu
2016-11-18 4:44 ` Tian, Kevin
2016-11-22 4:31 ` Wu, Feng
2016-11-22 10:03 ` Jan Beulich
2017-02-22 7:24 ` Chao Gao
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=1479434244-10223-6-git-send-email-feng.wu@intel.com \
--to=feng.wu@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=dario.faggioli@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=kevin.tian@intel.com \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).