From patchwork Tue Oct 11 00:57:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9370047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E595960487 for ; Tue, 11 Oct 2016 01:30:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DECB828CB3 for ; Tue, 11 Oct 2016 01:30:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D26A928CB1; Tue, 11 Oct 2016 01:30:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E11928CB1 for ; Tue, 11 Oct 2016 01:30:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btlsC-0005wm-AC; Tue, 11 Oct 2016 01:28:52 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btlsB-0005wO-Ce for xen-devel@lists.xen.org; Tue, 11 Oct 2016 01:28:51 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id B7/BA-13744-2504CF75; Tue, 11 Oct 2016 01:28:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsVywNxEWzfI4U+ 4wZ5b7BZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aUX3NZC+4JVhw5compgfE5bxcjJ4eQQKVE y8NbLCC2hACvxJFlM1ghbH+JO1e/s0LU1Etcvj4drIZNQFHi4MVDYHERAWmJa58vM3YxcnEwC yxglGi8eJQZJCEsECBxvn03I4jNIqAqsWzHLDCbV8BR4sXufewQC+QkNuz+DxbnFHCSmPx2Kl sXIwfQMkeJjv3sExh5FzAyrGJUL04tKkst0jXVSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCr WS87P3cQIDAUGINjBOP2y/yFGSQ4mJVHeIqM/4UJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkePXs gXKCRanpqRVpmTnAoIRJS3DwKInw5oOkeYsLEnOLM9MhUqcYFaXEeTlBEgIgiYzSPLg2WCRcY pSVEuZlBDpEiKcgtSg3swRV/hWjOAejkjCvCcgUnsy8Erjpr4AWMwEtZln8A2RxSSJCSqqBkV /Vr//Xt/t+cowLzlxvXTzD4YNOqx9L7Z7a09+ivq6TUrRWYty+fr5ZFpfIHamMvpxpKdPVjra I3jx1XtOUlZ3Jus4/2PRdblDc9TtzAyKnW+q9rhHjPHH64JaYMsPLCbsCIq8fPpl6ejlPRvv/ 9H/OuccEnxSs/bK9TtDRXfLHsqvSs7fsVWIpzkg01GIuKk4EAAPaHyl/AgAA X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1476149320!30791318!6 X-Originating-IP: [192.55.52.43] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54683 invoked from network); 11 Oct 2016 01:28:49 -0000 Received: from mga05.intel.com (HELO mga05.intel.com) (192.55.52.43) by server-10.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Oct 2016 01:28:49 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 10 Oct 2016 18:28:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,327,1473145200"; d="scan'208";a="178535731" Received: from feng-bdw-de-pi.bj.intel.com ([10.238.154.57]) by fmsmga004.fm.intel.com with ESMTP; 10 Oct 2016 18:28:48 -0700 From: Feng Wu To: xen-devel@lists.xen.org Date: Tue, 11 Oct 2016 08:57:51 +0800 Message-Id: <1476147473-30970-6-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1476147473-30970-1-git-send-email-feng.wu@intel.com> References: <1476147473-30970-1-git-send-email-feng.wu@intel.com> Cc: kevin.tian@intel.com, Feng Wu , george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v5 5/7] VT-d: No need to set irq affinity for posted format IRTE X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- v5: - Only suppress affinity related IRTE updates for PI xen/drivers/passthrough/vtd/intremap.c | 52 ++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index bfd468b..8dd0373 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -547,6 +547,49 @@ static int remap_entry_to_msi_msg( return 0; } +static bool_t pi_can_suppress_irte_update(struct iremap_entry *new, + const struct iremap_entry *old) +{ + bool_t ret = 1; + u16 fpd, sid, sq, svt; + + if ( !old->remap.p || !old->remap.im ) + return 0; + + fpd = new->post.fpd; + sid = new->post.sid; + sq = new->post.sq; + svt = new->post.svt; + + *new = *old; + + if ( fpd != old->post.fpd ) + { + new->post.fpd = fpd; + ret = 0; + } + + if ( sid != old->post.sid ) + { + new->post.sid = sid; + ret = 0; + } + + if ( sq != old->post.sq ) + { + new->post.sq = sq; + ret = 0; + } + + if ( svt != old->post.svt ) + { + new->post.svt = svt; + ret = 0; + } + + return ret; +} + 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 +680,12 @@ 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) ) + { + 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);