Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932434AbcLAKdP (ORCPT ); Thu, 1 Dec 2016 05:33:15 -0500 Received: from 8bytes.org ([81.169.241.247]:52769 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932261AbcLAKdO (ORCPT ); Thu, 1 Dec 2016 05:33:14 -0500 Date: Thu, 1 Dec 2016 11:33:07 +0100 From: Joerg Roedel To: xlpang@redhat.com Cc: Baoquan He , Don Brace , Myron Stowe , kexec@lists.infradead.org, LKML , iommu@lists.linux-foundation.org, Myron Stowe , Dave Young , David Woodhouse Subject: Re: [PATCH] iommu/vt-d: Flush old iotlb for kdump when the device gets context mapped Message-ID: <20161201103307.GL2078@8bytes.org> References: <582C232F.6080205@redhat.com> <582D1A40.409@redhat.com> <20161129143547.GG2078@8bytes.org> <583E8A9B.7070906@redhat.com> <20161130090327.GA4192@x1> <20161130095334.GB4192@x1> <20161130102334.GC4192@x1> <20161130142642.GJ2078@8bytes.org> <583F87D1.6030402@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <583F87D1.6030402@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1433 Lines: 34 On Thu, Dec 01, 2016 at 10:15:45AM +0800, Xunlei Pang wrote: > index 3965e73..624eac9 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -2024,6 +2024,25 @@ static int domain_context_mapping_one(struct dmar_domain *domain, > if (context_present(context)) > goto out_unlock; > > + /* > + * For kdump cases, old valid entries may be cached due to the > + * in-flight DMA and copied pgtable, but there is no unmapping > + * behaviour for them, thus we need an explicit cache flush for > + * the newly-mapped device. For kdump, at this point, the device > + * is supposed to finish reset at its driver probe stage, so no > + * in-flight DMA will exist, and we don't need to worry anymore > + * hereafter. > + */ > + if (context_copied(context)) { > + u16 did_old = context_domain_id(context); > + > + if (did_old >= 0 && did_old < cap_ndoms(iommu->cap)) > + iommu->flush.flush_context(iommu, did_old, > + (((u16)bus) << 8) | devfn, > + DMA_CCMD_MASK_NOBIT, > + DMA_CCMD_DEVICE_INVL); > + } > + > pgd = domain->pgd; Yes, this looks better. Have you tested it the same way as the old patch? Joerg