From patchwork Wed Aug 31 03:56:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9306307 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 2889260865 for ; Wed, 31 Aug 2016 04:28:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 170F828C14 for ; Wed, 31 Aug 2016 04:28:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BA9F28E23; Wed, 31 Aug 2016 04:28:03 +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 4AA5328C14 for ; Wed, 31 Aug 2016 04:28:01 +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 1bex5h-00018T-GA; Wed, 31 Aug 2016 04:25:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bex5g-000178-Fe for xen-devel@lists.xen.org; Wed, 31 Aug 2016 04:25:32 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id EE/AD-05361-C3C56C75; Wed, 31 Aug 2016 04:25:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsXS1tYhomsdcyz c4MkvI4slHxezODB6HN39mymAMYo1My8pvyKBNePm8162gt9yFev/NjI3MD4W72Lk5BASqJR4 8qiFHcSWEOCVOLJsBiuE7SvRMuMfG0RNvcSjjZPAatgEFCUOXjwEViMiIC1x7fNlxi5GLg5mg QWMEo0XjzKDJIQFAiQ27trBAmKzCKhKfJ77gAnE5hVwkFi+4w4LxAI5iQ27/zOC2JwCjhI/jj 8EWsYBtMxBYsc94wmMvAsYGVYxqhenFpWlFula6iUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCY V6yXn525iBIYCAxDsYLy7KeAQoyQHk5Iob/jfo+FCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjt oo+FCwkWpaanVqRl5gCDEiYtwcGjJMIrAZLmLS5IzC3OTIdInWJUlBLnfRcFlBAASWSU5sG1w SLhEqOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5D4FM4cnMK4Gb/gpoMRPQ4oI7h0EWlyQipK QaGE20FVrkLqbe0T+UvDYotbdrX5xp1dbLYRUa/2/q+3HOvG/907fKJPP4uWTOQw83mmh5v12 889di57Z3RzZ/NXvZMOHR96WWIS+9t7130bD6aN72ca6PUQdjgXLFtG/rE05O3PIr6evTI2mX 7a7nc0uy8+bkBF29M8+zikv49QJHiT6fQ1MnLVdiKc5INNRiLipOBABWlnbSfwIAAA== X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1472617522!30750590!6 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31870 invoked from network); 31 Aug 2016 04:25:31 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-10.tower-21.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 31 Aug 2016 04:25:31 -0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP; 30 Aug 2016 21:25:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,260,1470726000"; d="scan'208";a="2931040" Received: from feng-bdw-de-pi.bj.intel.com ([10.238.154.74]) by fmsmga005.fm.intel.com with ESMTP; 30 Aug 2016 21:25:29 -0700 From: Feng Wu To: xen-devel@lists.xen.org Date: Wed, 31 Aug 2016 11:56:30 +0800 Message-Id: <1472615791-8664-6-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1472615791-8664-1-git-send-email-feng.wu@intel.com> References: <1472615791-8664-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 v3 5/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 --- xen/drivers/passthrough/vtd/intremap.c | 62 +++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index bfd468b..2083ee2 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -595,33 +595,36 @@ static int msi_msg_to_remap_entry( GET_IREMAP_ENTRY(ir_ctrl->iremap_maddr, index, iremap_entries, iremap_entry); - memcpy(&new_ire, iremap_entry, sizeof(struct iremap_entry)); + if ( !iremap_entry->remap.p || !iremap_entry->remap.im ) + { + 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; + /* 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 ( 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 */ + } /* 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->remap.p || !iremap_entry->remap.im ) + { + 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);