Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1723471

Re: [PATCH] intel-iommu: Don't be too aggressive when clearing one context entry

From Jacob Pan <jacob.jun.pan@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH] intel-iommu: Don't be too aggressive when clearing one context entry
Date 2017-08-30 17:50 +0200
Message-ID <ukdpD-1Ib-5@gated-at.bofh.it> (permalink)
References <ujt3s-6CP-9@gated-at.bofh.it>
Organization OTC

Show all headers | View raw


On Mon, 28 Aug 2017 16:16:29 +0200
Filippo Sironi via iommu <iommu@lists.linux-foundation.org> wrote:

> Previously, we were invalidating context cache and IOTLB globally when
> clearing one context entry.  This is a tad too aggressive.
> Invalidate the context cache and IOTLB for the interested device only.
> 
> Signed-off-by: Filippo Sironi <sironi@amazon.de>
> Cc: David Woodhouse <dwmw@amazon.co.uk>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: iommu@lists.linux-foundation.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/iommu/intel-iommu.c | 25 ++++++++++++++++++++++---
>  1 file changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 3e8636f1220e..4bf3e59b0929 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -2351,13 +2351,32 @@ static inline int domain_pfn_mapping(struct
> dmar_domain *domain, unsigned long i 
>  static void domain_context_clear_one(struct intel_iommu *iommu, u8
> bus, u8 devfn) {
> +	unsigned long flags;
> +	struct context_entry *context;
> +	u16 did_old;
> +
>  	if (!iommu)
>  		return;
>  
> +	spin_lock_irqsave(&iommu->lock, flags);
> +	context = iommu_context_addr(iommu, bus, devfn, 0);
> +	if (!context) {
> +		spin_unlock_irqrestore(&iommu->lock, flags);
> +		return;
> +	}
perhaps check with device_context_mapped()?

> +	did_old = context_domain_id(context);
> +	spin_unlock_irqrestore(&iommu->lock, flags);
>  	clear_context_table(iommu, bus, devfn);
> -	iommu->flush.flush_context(iommu, 0, 0, 0,
> -					   DMA_CCMD_GLOBAL_INVL);
> -	iommu->flush.flush_iotlb(iommu, 0, 0, 0,
> DMA_TLB_GLOBAL_FLUSH);
> +	iommu->flush.flush_context(iommu,
> +				   did_old,
> +				   (((u16)bus) << 8) | devfn,
> +				   DMA_CCMD_MASK_NOBIT,
> +				   DMA_CCMD_DEVICE_INVL);
> +	iommu->flush.flush_iotlb(iommu,
> +				 did_old,
> +				 0,
> +				 0,
> +				 DMA_TLB_DSI_FLUSH);
>  }
>  
>  static inline void unlink_domain_info(struct device_domain_info
> *info)

[Jacob Pan]

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] intel-iommu: Don't be too aggressive when clearing one context entry Filippo Sironi <sironi@amazon.de> - 2017-08-28 16:20 +0200
  Re: [PATCH] intel-iommu: Don't be too aggressive when clearing one  context entry Joerg Roedel <joro@8bytes.org> - 2017-08-30 15:40 +0200
    Re: [PATCH] intel-iommu: Don't be too aggressive when clearing one  context entry "Sironi, Filippo" <sironi@amazon.de> - 2017-08-31 10:50 +0200
  Re: [PATCH] intel-iommu: Don't be too aggressive when clearing one  context entry Jacob Pan <jacob.jun.pan@linux.intel.com> - 2017-08-30 17:50 +0200
    Re: [PATCH] intel-iommu: Don't be too aggressive when clearing one  context entry "Sironi, Filippo" <sironi@amazon.de> - 2017-08-31 10:50 +0200
  [PATCH v2] iommu/vt-d: Don't be too aggressive when clearing one context entry Filippo Sironi <sironi@amazon.de> - 2017-08-31 11:10 +0200
    Re: [PATCH v2] iommu/vt-d: Don't be too aggressive when clearing one  context entry Joerg Roedel <joro@8bytes.org> - 2017-09-01 11:40 +0200

csiph-web