From patchwork Mon Nov 7 08:10:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9414491 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 5891E6022E for ; Mon, 7 Nov 2016 08:45:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49CDC28C79 for ; Mon, 7 Nov 2016 08:45:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EB0728CDA; Mon, 7 Nov 2016 08:45:24 +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 AC02628C79 for ; Mon, 7 Nov 2016 08:45:23 +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 1c3fWM-0006IO-8e; Mon, 07 Nov 2016 08:43:14 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3fWL-0006IG-Ta for xen-devel@lists.xen.org; Mon, 07 Nov 2016 08:43:14 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id A7/CE-30618-1AE30285; Mon, 07 Nov 2016 08:43:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRWlGSWpSXmKPExsVywNwkQneBnUK Ewf8vWhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b9o8sZC5bLV3z8rN/AuEiii5GDQ0igQqL9 gnUXIyeHhACvxJFlM1ghbB+JF4cmMHYxcgGV9DFK7Ombww6SYBNQlDh48RBYkYiAtMS1z5fBi pgFFjBKNF48ygySEBYIkFhxYyUjiM0ioCpx8tJfoDg7B6+Ao0Q/B8R8OYkNu/8zTmDkXsDIsI pRozi1qCy1SNfYSC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9CzDECwg/H0usB DjJIcTEqivJYWChFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHiv2wLlBItS01Mr0jJzgCEGk5bg 4FES4Z0LkuYtLkjMLc5Mh0idYlSUEuc9AZIQAElklObBtcHC+hKjrJQwLyPQIUI8BalFuZklq PKvGMU5GJWEeR1BpvBk5pXATX8FtJgJaLFbiAzI4pJEhJRUA2NjrS33MpPzNnW+cdZNRsdswx P27+HNtFLelLVm0YnkEywb5E0tau/43TGUXcf6ZLNTyUQvjTf1hw06lk99t9t/+vNfDhdfCoZ PEPk2d0LMFqMoz+t9L54EOPv4P+H8bvYvaa2THcONjhPtejtN5z8ui75i67zi1b6/CXMTExmW LVpWdMjc6qkSS3FGoqEWc1FxIgAVPN41ZgIAAA== X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1478508190!69840038!1 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 11817 invoked from network); 7 Nov 2016 08:43:12 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-12.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Nov 2016 08:43:12 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 07 Nov 2016 00:43:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,605,1473145200"; d="scan'208";a="518431" Received: from unknown (HELO feng-bdw-de-pi.bj.intel.com) ([10.238.154.57]) by orsmga002.jf.intel.com with ESMTP; 07 Nov 2016 00:43:07 -0800 From: Feng Wu To: xen-devel@lists.xen.org Date: Mon, 7 Nov 2016 16:10:42 +0800 Message-Id: <1478506242-14606-1-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 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 v7 4/6] 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 --- 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 | 54 +++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index bfd468b..3f8c109 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -597,31 +597,34 @@ static int msi_msg_to_remap_entry( memcpy(&new_ire, iremap_entry, sizeof(struct iremap_entry)); - /* 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; - if ( pdev ) set_msi_source_id(pdev, &new_ire); else set_hpet_source_id(msi_desc->hpet_id, &new_ire); - new_ire.remap.res_3 = 0; - new_ire.remap.res_4 = 0; - new_ire.remap.p = 1; /* finally, set present bit */ + + if ( !new_ire.remap.p || !new_ire.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 */ + } /* now construct new MSI/MSI-X rte entry */ remap_rte = (struct msi_msg_remap_entry *)msg; @@ -637,9 +640,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 ( iremap_entry->val != new_ire.val ) + { + 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);