From patchwork Fri Oct 28 02:37:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9400989 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 EBB38605EE for ; Fri, 28 Oct 2016 03:11:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBAE328D40 for ; Fri, 28 Oct 2016 03:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D02E72A4B1; Fri, 28 Oct 2016 03:11:55 +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 4E81A28D40 for ; Fri, 28 Oct 2016 03:11:55 +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 1bzxXq-0006MJ-88; Fri, 28 Oct 2016 03:09:26 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bzxXp-0006Lh-7n for xen-devel@lists.xen.org; Fri, 28 Oct 2016 03:09:25 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 2D/2B-09407-461C2185; Fri, 28 Oct 2016 03:09:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsVywNwkQjfloFC EQftORoslHxezODB6HN39mymAMYo1My8pvyKBNePchavMBXMlKnpOfmdqYJwu3MXIySEkUCnx bOEkVhBbQoBX4siyGVB2gMTvT03sXYxcQDV9jBIfN21lBkmwCShKHLx4CKxIREBa4trny4wgR cwCCxglGi8eBSsSBureu6aJBcRmEVCVmLXoAxuIzSvgIPH1aC8jxAY5iQ27/4PZnAKOEj8P3W GEuMhBYs6OV6wTGHkXMDKsYlQvTi0qSy3StdBLKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZ Lzs/dxAgMBwYg2MF4sNn5EKMkB5OSKO+FyUIRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4ow4A 5QSLUtNTK9Iyc4CBCZOW4OBREuHdvg8ozVtckJhbnJkOkTrFqCglzqsB0icAksgozYNrg0XDJ UZZKWFeRqBDhHgKUotyM0tQ5V8xinMwKgnzmoJM4cnMK4Gb/gpoMRPQ4unpAiCLSxIRUlINjK rOn2w+9P39ePvRQW0m9/P8ecG6qjM8bxTezywM+NapnLU5yias2aGswWe7MPu/6QeX8Cx8lrI wPJPdY/6foEP3DYzqnVf1Nh3d1x5smey6u1/oksqDiJnTLpzh/P7j/a3Js3bJnN7whVljQ86q rQ9mTGpWvfOOvc0ssIs3Ql+OM3V6TFvtHSWW4oxEQy3mouJEAIWZmrWBAgAA X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1477624160!63641240!2 X-Originating-IP: [192.55.52.88] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjg4ID0+IDM3NDcyNQ==\n X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21671 invoked from network); 28 Oct 2016 03:09:23 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-3.tower-206.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 28 Oct 2016 03:09:23 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 27 Oct 2016 20:09:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,407,1473145200"; d="scan'208"; a="1077010858" Received: from unknown (HELO feng-bdw-de-pi.bj.intel.com) ([10.238.154.53]) by fmsmga002.fm.intel.com with ESMTP; 27 Oct 2016 20:09:20 -0700 From: Feng Wu To: xen-devel@lists.xen.org Date: Fri, 28 Oct 2016 10:37:37 +0800 Message-Id: <1477622259-3476-6-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1477622259-3476-1-git-send-email-feng.wu@intel.com> References: <1477622259-3476-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 v6 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 --- 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);