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 v6 5/7] VT-d: No need to set irq affinity for posted format IRTE
Date: Fri, 28 Oct 2016 10:37:37 +0800 [thread overview]
Message-ID: <1477622259-3476-6-git-send-email-feng.wu@intel.com> (raw)
In-Reply-To: <1477622259-3476-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>
---
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 | 61 ++++++++++++++++++++++++++++++++--
1 file changed, 58 insertions(+), 3 deletions(-)
diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c
index bfd468b..97e80a6 100644
--- a/xen/drivers/passthrough/vtd/intremap.c
+++ b/xen/drivers/passthrough/vtd/intremap.c
@@ -547,6 +547,54 @@ static int remap_entry_to_msi_msg(
return 0;
}
+static bool pi_can_suppress_irte_update(const struct iremap_entry *new,
+ const struct iremap_entry *old)
+{
+ ASSERT( old && new );
+
+ if ( !old->remap.p || !old->remap.im || !new->remap.p || new->remap.im )
+ return false;
+
+ /*
+ * We are updating posted IRTE to remapped one, check whether
+ * the common fields are going to be changed.
+ */
+ if ( ( new->remap.fpd != old->post.fpd ) ||
+ ( new->remap.sid != old->post.sid ) ||
+ ( new->remap.sq != old->post.sq ) ||
+ ( new->remap.svt != old->post.svt ) )
+ return false;
+
+ return true;
+}
+
+static void pi_get_new_irte(struct iremap_entry *new,
+ const struct iremap_entry *old)
+{
+ u16 fpd, sid, sq, svt;
+
+ ASSERT( old && new );
+
+ fpd = new->remap.fpd;
+ sid = new->remap.sid;
+ sq = new->remap.sq;
+ svt = new->remap.svt;
+
+ *new = *old;
+
+ if ( fpd != old->post.fpd )
+ new->post.fpd = fpd;
+
+ if ( sid != old->post.sid )
+ new->post.sid = sid;
+
+ if ( sq != old->post.sq )
+ new->post.sq = sq;
+
+ if ( svt != old->post.svt )
+ new->post.svt = svt;
+}
+
static int msi_msg_to_remap_entry(
struct iommu *iommu, struct pci_dev *pdev,
struct msi_desc *msi_desc, struct msi_msg *msg)
@@ -637,9 +685,16 @@ static int msi_msg_to_remap_entry(
remap_rte->address_hi = 0;
remap_rte->data = index - i;
- memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry));
- iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry));
- iommu_flush_iec_index(iommu, 0, index);
+ if ( !pi_can_suppress_irte_update(&new_ire, iremap_entry) )
+ {
+ if ( iremap_entry->remap.p && iremap_entry->remap.im &&
+ new_ire.remap.p && !new_ire.remap.im )
+ pi_get_new_irte(&new_ire, iremap_entry);
+
+ memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry));
+ 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-10-28 2:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-28 2:37 [PATCH v6 0/7] VMX: Properly handle pi descriptor and per-cpu blocking list Feng Wu
2016-10-28 2:37 ` [PATCH v6 1/7] VMX: Permanently assign PI hook vmx_pi_switch_to() Feng Wu
2016-10-28 13:04 ` Jan Beulich
2016-10-28 13:18 ` Jan Beulich
2016-10-31 1:11 ` Wu, Feng
2016-10-28 2:37 ` [PATCH v6 2/7] VMX: Properly handle pi when all the assigned devices are removed Feng Wu
2016-10-28 13:19 ` Jan Beulich
2016-11-03 7:45 ` Wu, Feng
2016-11-03 9:07 ` Jan Beulich
2016-11-03 9:10 ` Wu, Feng
2016-10-28 2:37 ` [PATCH v6 3/7] VMX: Cleanup PI per-cpu blocking list when vcpu is destroyed Feng Wu
2016-10-28 13:23 ` Jan Beulich
2016-10-28 2:37 ` [PATCH v6 4/7] VMX: Make sure PI is in proper state before install the hooks Feng Wu
2016-10-28 13:24 ` Jan Beulich
2016-10-28 2:37 ` Feng Wu [this message]
2016-10-31 14:57 ` [PATCH v6 5/7] VT-d: No need to set irq affinity for posted format IRTE Jan Beulich
2016-11-03 7:46 ` Wu, Feng
2016-11-03 9:15 ` Jan Beulich
2016-10-28 2:37 ` [PATCH v6 6/7] VT-d: Some cleanups Feng Wu
2016-10-31 15:00 ` Jan Beulich
2016-10-28 2:37 ` [PATCH v6 7/7] VMX: Fixup PI descriptor when cpu is offline Feng Wu
2016-10-31 15:50 ` Jan Beulich
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=1477622259-3476-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).