From: Quan Xu Subject: [Patch RFC 13/13] vt-d: Set the IF bit in Invalidation Wait Descriptor When submit Device-TLB Date: Wed, 16 Sep 2015 09:24:07 -0400 Message-ID: <1442409847-65383-14-git-send-email-quan.xu@intel.com> References: <1442409847-65383-1-git-send-email-quan.xu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1442409847-65383-1-git-send-email-quan.xu@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: andrew.cooper3@citrix.com, eddie.dong@intel.com, ian.campbell@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, jun.nakajima@intel.com, keir@xen.org, kevin.tian@intel.com, tim@xen.org, yang.z.zhang@intel.com, george.dunlap@eu.citrix.com Cc: Quan Xu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org invalidataion requests. If the IF bit is Set, the interrupt based mechanism will be used to track the Device-TLB invalidation requests. Do not do polling to detect whether hardware completes the Device-TLB invalidation during Device- TLB invalidation. Signed-off-by: Quan Xu --- xen/drivers/passthrough/vtd/qinval.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/vtd/qinval.c b/xen/drivers/passthrough/vtd/qinval.c index 0d85ce7..b330d02 100644 --- a/xen/drivers/passthrough/vtd/qinval.c +++ b/xen/drivers/passthrough/vtd/qinval.c @@ -176,7 +176,15 @@ static int queue_invalidate_wait(struct iommu *iommu, qinval_update_qtail(iommu, index); spin_unlock_irqrestore(&iommu->register_lock, flags); - /* Now we don't support interrupt method */ + /* + * If the iflag is Set, the interrupt based mechanism will be used to track + * the Device-TLB invalidation status. Do not do polling to detect whether + * hardware completes the Device-TLB invalidation during submitting Device-TLB + * invalidation requests. + */ + if ( iflag ) + return 0; + if ( sw ) { /* In case all wait descriptor writes to same addr with same data */ @@ -322,6 +330,15 @@ static int flush_context_qi( return ret; } +static int invalidate_async(struct iommu *iommu, u16 device_id) +{ + struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu); + + if ( qi_ctrl->qinval_maddr ) + return queue_invalidate_wait(iommu, 1, 1, 1, device_id); + return 0; +} + static int flush_iotlb_qi( void *_iommu, u16 did, u64 addr, unsigned int size_order, u64 type, @@ -360,8 +377,13 @@ static int flush_iotlb_qi( type >> DMA_TLB_FLUSH_GRANU_OFFSET, dr, dw, did, size_order, 0, addr); if ( flush_dev_iotlb ) + { ret = dev_invalidate_iotlb(iommu, did, addr, size_order, type); - rc = invalidate_sync(iommu); + rc = invalidate_async(iommu, did); + } else { + rc = invalidate_sync(iommu); + } + if ( !ret ) ret = rc; } -- 1.8.3.2