* [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) [not found] <20170407102039.GW7266@8bytes.org> @ 2017-05-22 7:48 ` arindam.nath 2017-05-23 18:24 ` Deucher, Alexander 2017-05-29 14:38 ` Joerg Roedel 0 siblings, 2 replies; 7+ messages in thread From: arindam.nath @ 2017-05-22 7:48 UTC (permalink / raw) To: iommu Cc: amd-gfx, Joerg Roedel, Alexander.Deucher, John.Bridgman, drake, Suravee.Suthikulpanit, linux, Craig Stein, michel, Felix.Kuehling, stable, Arindam Nath From: Arindam Nath <arindam.nath@amd.com> Change History -------------- v3: - add Fixes and CC tags - add link to Bugzilla v2: changes suggested by Joerg - add flush flag to improve efficiency of flush operation v1: - The idea behind flush queues is to defer the IOTLB flushing for domains for which the mappings are no longer valid. We add such domains in queue_add(), and when the queue size reaches FLUSH_QUEUE_SIZE, we perform __queue_flush(). Since we have already taken lock before __queue_flush() is called, we need to make sure the IOTLB flushing is performed as quickly as possible. In the current implementation, we perform IOTLB flushing for all domains irrespective of which ones were actually added in the flush queue initially. This can be quite expensive especially for domains for which unmapping is not required at this point of time. This patch makes use of domain information in 'struct flush_queue_entry' to make sure we only flush IOTLBs for domains who need it, skipping others. Bugzilla: https://bugs.freedesktop.org/101029 Fixes: b1516a14657a ("iommu/amd: Implement flush queue") Cc: stable@vger.kernel.org Suggested-by: Joerg Roedel <joro@8bytes.org> Signed-off-by: Arindam Nath <arindam.nath@amd.com> --- drivers/iommu/amd_iommu.c | 27 ++++++++++++++++++++------- drivers/iommu/amd_iommu_types.h | 2 ++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 63cacf5..1edeebec 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2227,15 +2227,26 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev) static void __queue_flush(struct flush_queue *queue) { - struct protection_domain *domain; - unsigned long flags; int idx; - /* First flush TLB of all known domains */ - spin_lock_irqsave(&amd_iommu_pd_lock, flags); - list_for_each_entry(domain, &amd_iommu_pd_list, list) - domain_flush_tlb(domain); - spin_unlock_irqrestore(&amd_iommu_pd_lock, flags); + /* First flush TLB of all domains which were added to flush queue */ + for (idx = 0; idx < queue->next; ++idx) { + struct flush_queue_entry *entry; + + entry = queue->entries + idx; + + /* + * There might be cases where multiple IOVA entries for the + * same domain are queued in the flush queue. To avoid + * flushing the same domain again, we check whether the + * flag is set or not. This improves the efficiency of + * flush operation. + */ + if (!entry->dma_dom->domain.already_flushed) { + entry->dma_dom->domain.already_flushed = true; + domain_flush_tlb(&entry->dma_dom->domain); + } + } /* Wait until flushes have completed */ domain_flush_complete(NULL); @@ -2289,6 +2300,8 @@ static void queue_add(struct dma_ops_domain *dma_dom, pages = __roundup_pow_of_two(pages); address >>= PAGE_SHIFT; + dma_dom->domain.already_flushed = false; + queue = get_cpu_ptr(&flush_queue); spin_lock_irqsave(&queue->lock, flags); diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 4de8f41..4f5519d 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -454,6 +454,8 @@ struct protection_domain { bool updated; /* complete domain flush required */ unsigned dev_cnt; /* devices assigned to this domain */ unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */ + bool already_flushed; /* flag to avoid flushing the same domain again + in a single invocation of __queue_flush() */ }; /* -- 2.7.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) 2017-05-22 7:48 ` [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) arindam.nath @ 2017-05-23 18:24 ` Deucher, Alexander 2017-05-29 14:38 ` Joerg Roedel 1 sibling, 0 replies; 7+ messages in thread From: Deucher, Alexander @ 2017-05-23 18:24 UTC (permalink / raw) To: Nath, Arindam, iommu@lists.linux-foundation.org Cc: amd-gfx@lists.freedesktop.org, Joerg Roedel, Bridgman, John, drake@endlessm.com, Suthikulpanit, Suravee, linux@endlessm.com, Craig Stein, michel@daenzer.net, Kuehling, Felix, stable@vger.kernel.org, Nath, Arindam > -----Original Message----- > From: Arindam Nath [mailto:anath.amd@gmail.com] On Behalf Of > arindam.nath@amd.com > Sent: Monday, May 22, 2017 3:48 AM > To: iommu@lists.linux-foundation.org > Cc: amd-gfx@lists.freedesktop.org; Joerg Roedel; Deucher, Alexander; > Bridgman, John; drake@endlessm.com; Suthikulpanit, Suravee; > linux@endlessm.com; Craig Stein; michel@daenzer.net; Kuehling, Felix; > stable@vger.kernel.org; Nath, Arindam > Subject: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) > > From: Arindam Nath <arindam.nath@amd.com> > > Change History > -------------- > > v3: > - add Fixes and CC tags > - add link to Bugzilla > > v2: changes suggested by Joerg > - add flush flag to improve efficiency of flush operation > > v1: > - The idea behind flush queues is to defer the IOTLB flushing > for domains for which the mappings are no longer valid. We > add such domains in queue_add(), and when the queue size > reaches FLUSH_QUEUE_SIZE, we perform __queue_flush(). > > Since we have already taken lock before __queue_flush() > is called, we need to make sure the IOTLB flushing is > performed as quickly as possible. > > In the current implementation, we perform IOTLB flushing > for all domains irrespective of which ones were actually > added in the flush queue initially. This can be quite > expensive especially for domains for which unmapping is > not required at this point of time. > > This patch makes use of domain information in > 'struct flush_queue_entry' to make sure we only flush > IOTLBs for domains who need it, skipping others. > > Bugzilla: https://bugs.freedesktop.org/101029 > Fixes: b1516a14657a ("iommu/amd: Implement flush queue") > Cc: stable@vger.kernel.org > Suggested-by: Joerg Roedel <joro@8bytes.org> > Signed-off-by: Arindam Nath <arindam.nath@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> > --- > drivers/iommu/amd_iommu.c | 27 ++++++++++++++++++++------- > drivers/iommu/amd_iommu_types.h | 2 ++ > 2 files changed, 22 insertions(+), 7 deletions(-) > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > index 63cacf5..1edeebec 100644 > --- a/drivers/iommu/amd_iommu.c > +++ b/drivers/iommu/amd_iommu.c > @@ -2227,15 +2227,26 @@ static struct iommu_group > *amd_iommu_device_group(struct device *dev) > > static void __queue_flush(struct flush_queue *queue) > { > - struct protection_domain *domain; > - unsigned long flags; > int idx; > > - /* First flush TLB of all known domains */ > - spin_lock_irqsave(&amd_iommu_pd_lock, flags); > - list_for_each_entry(domain, &amd_iommu_pd_list, list) > - domain_flush_tlb(domain); > - spin_unlock_irqrestore(&amd_iommu_pd_lock, flags); > + /* First flush TLB of all domains which were added to flush queue */ > + for (idx = 0; idx < queue->next; ++idx) { > + struct flush_queue_entry *entry; > + > + entry = queue->entries + idx; > + > + /* > + * There might be cases where multiple IOVA entries for the > + * same domain are queued in the flush queue. To avoid > + * flushing the same domain again, we check whether the > + * flag is set or not. This improves the efficiency of > + * flush operation. > + */ > + if (!entry->dma_dom->domain.already_flushed) { > + entry->dma_dom->domain.already_flushed = true; > + domain_flush_tlb(&entry->dma_dom->domain); > + } > + } > > /* Wait until flushes have completed */ > domain_flush_complete(NULL); > @@ -2289,6 +2300,8 @@ static void queue_add(struct dma_ops_domain > *dma_dom, > pages = __roundup_pow_of_two(pages); > address >>= PAGE_SHIFT; > > + dma_dom->domain.already_flushed = false; > + > queue = get_cpu_ptr(&flush_queue); > spin_lock_irqsave(&queue->lock, flags); > > diff --git a/drivers/iommu/amd_iommu_types.h > b/drivers/iommu/amd_iommu_types.h > index 4de8f41..4f5519d 100644 > --- a/drivers/iommu/amd_iommu_types.h > +++ b/drivers/iommu/amd_iommu_types.h > @@ -454,6 +454,8 @@ struct protection_domain { > bool updated; /* complete domain flush required */ > unsigned dev_cnt; /* devices assigned to this domain */ > unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference > count */ > + bool already_flushed; /* flag to avoid flushing the same domain > again > + in a single invocation of __queue_flush() */ > }; > > /* > -- > 2.7.4 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) 2017-05-22 7:48 ` [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) arindam.nath 2017-05-23 18:24 ` Deucher, Alexander @ 2017-05-29 14:38 ` Joerg Roedel 2017-05-30 7:38 ` Nath, Arindam 1 sibling, 1 reply; 7+ messages in thread From: Joerg Roedel @ 2017-05-29 14:38 UTC (permalink / raw) To: arindam.nath, Tom Lendacky Cc: iommu, amd-gfx, Alexander.Deucher, John.Bridgman, drake, Suravee.Suthikulpanit, linux, Craig Stein, michel, Felix.Kuehling, stable Hi Arindam, I met Tom Lendacky last week in Nuremberg last week and he told me he is working on the same area of the code that this patch is for. His reason for touching this code was to solve some locking problems. Maybe you two can work together on a joint approach to improve this? On Mon, May 22, 2017 at 01:18:01PM +0530, arindam.nath@amd.com wrote: > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > index 63cacf5..1edeebec 100644 > --- a/drivers/iommu/amd_iommu.c > +++ b/drivers/iommu/amd_iommu.c > @@ -2227,15 +2227,26 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev) > > static void __queue_flush(struct flush_queue *queue) > { > - struct protection_domain *domain; > - unsigned long flags; > int idx; > > - /* First flush TLB of all known domains */ > - spin_lock_irqsave(&amd_iommu_pd_lock, flags); > - list_for_each_entry(domain, &amd_iommu_pd_list, list) > - domain_flush_tlb(domain); > - spin_unlock_irqrestore(&amd_iommu_pd_lock, flags); > + /* First flush TLB of all domains which were added to flush queue */ > + for (idx = 0; idx < queue->next; ++idx) { > + struct flush_queue_entry *entry; > + > + entry = queue->entries + idx; > + > + /* > + * There might be cases where multiple IOVA entries for the > + * same domain are queued in the flush queue. To avoid > + * flushing the same domain again, we check whether the > + * flag is set or not. This improves the efficiency of > + * flush operation. > + */ > + if (!entry->dma_dom->domain.already_flushed) { > + entry->dma_dom->domain.already_flushed = true; > + domain_flush_tlb(&entry->dma_dom->domain); > + } > + } There is also a race condition here I have to look into. It is not introduced by your patch, but needs fixing anyway. I'll look into this too. Regards, Joerg ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) 2017-05-29 14:38 ` Joerg Roedel @ 2017-05-30 7:38 ` Nath, Arindam 2017-09-12 6:49 ` Daniel Drake 0 siblings, 1 reply; 7+ messages in thread From: Nath, Arindam @ 2017-05-30 7:38 UTC (permalink / raw) To: Joerg Roedel, Lendacky, Thomas Cc: iommu@lists.linux-foundation.org, amd-gfx@lists.freedesktop.org, Deucher, Alexander, Bridgman, John, drake@endlessm.com, Suthikulpanit, Suravee, linux@endlessm.com, Craig Stein, michel@daenzer.net, Kuehling, Felix, stable@vger.kernel.org >-----Original Message----- >From: Joerg Roedel [mailto:joro@8bytes.org] >Sent: Monday, May 29, 2017 8:09 PM >To: Nath, Arindam <Arindam.Nath@amd.com>; Lendacky, Thomas ><Thomas.Lendacky@amd.com> >Cc: iommu@lists.linux-foundation.org; amd-gfx@lists.freedesktop.org; >Deucher, Alexander <Alexander.Deucher@amd.com>; Bridgman, John ><John.Bridgman@amd.com>; drake@endlessm.com; Suthikulpanit, Suravee ><Suravee.Suthikulpanit@amd.com>; linux@endlessm.com; Craig Stein ><stein12c@gmail.com>; michel@daenzer.net; Kuehling, Felix ><Felix.Kuehling@amd.com>; stable@vger.kernel.org >Subject: Re: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) > >Hi Arindam, > >I met Tom Lendacky last week in Nuremberg last week and he told me he is >working on the same area of the code that this patch is for. His reason >for touching this code was to solve some locking problems. Maybe you two >can work together on a joint approach to improve this? Sure Joerg, I will work with Tom. Thanks. > >On Mon, May 22, 2017 at 01:18:01PM +0530, arindam.nath@amd.com wrote: >> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c >> index 63cacf5..1edeebec 100644 >> --- a/drivers/iommu/amd_iommu.c >> +++ b/drivers/iommu/amd_iommu.c >> @@ -2227,15 +2227,26 @@ static struct iommu_group >*amd_iommu_device_group(struct device *dev) >> >> static void __queue_flush(struct flush_queue *queue) >> { >> - struct protection_domain *domain; >> - unsigned long flags; >> int idx; >> >> - /* First flush TLB of all known domains */ >> - spin_lock_irqsave(&amd_iommu_pd_lock, flags); >> - list_for_each_entry(domain, &amd_iommu_pd_list, list) >> - domain_flush_tlb(domain); >> - spin_unlock_irqrestore(&amd_iommu_pd_lock, flags); >> + /* First flush TLB of all domains which were added to flush queue */ >> + for (idx = 0; idx < queue->next; ++idx) { >> + struct flush_queue_entry *entry; >> + >> + entry = queue->entries + idx; >> + >> + /* >> + * There might be cases where multiple IOVA entries for the >> + * same domain are queued in the flush queue. To avoid >> + * flushing the same domain again, we check whether the >> + * flag is set or not. This improves the efficiency of >> + * flush operation. >> + */ >> + if (!entry->dma_dom->domain.already_flushed) { >> + entry->dma_dom->domain.already_flushed = true; >> + domain_flush_tlb(&entry->dma_dom->domain); >> + } >> + } > >There is also a race condition here I have to look into. It is not >introduced by your patch, but needs fixing anyway. I'll look into this >too. > > >Regards, > > Joerg ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) 2017-05-30 7:38 ` Nath, Arindam @ 2017-09-12 6:49 ` Daniel Drake 2017-09-12 9:02 ` Nath, Arindam 0 siblings, 1 reply; 7+ messages in thread From: Daniel Drake @ 2017-09-12 6:49 UTC (permalink / raw) To: Nath, Arindam Cc: Joerg Roedel, Lendacky, Thomas, iommu@lists.linux-foundation.org, amd-gfx@lists.freedesktop.org, Deucher, Alexander, Bridgman, John, Suthikulpanit, Suravee, linux@endlessm.com, Craig Stein, michel@daenzer.net, Kuehling, Felix, stable@vger.kernel.org Hi, On Tue, May 30, 2017 at 3:38 PM, Nath, Arindam <Arindam.Nath@amd.com> wrote: >>-----Original Message----- >>From: Joerg Roedel [mailto:joro@8bytes.org] >>Sent: Monday, May 29, 2017 8:09 PM >>To: Nath, Arindam <Arindam.Nath@amd.com>; Lendacky, Thomas >><Thomas.Lendacky@amd.com> >>Cc: iommu@lists.linux-foundation.org; amd-gfx@lists.freedesktop.org; >>Deucher, Alexander <Alexander.Deucher@amd.com>; Bridgman, John >><John.Bridgman@amd.com>; drake@endlessm.com; Suthikulpanit, Suravee >><Suravee.Suthikulpanit@amd.com>; linux@endlessm.com; Craig Stein >><stein12c@gmail.com>; michel@daenzer.net; Kuehling, Felix >><Felix.Kuehling@amd.com>; stable@vger.kernel.org >>Subject: Re: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) >> >>Hi Arindam, >> >>I met Tom Lendacky last week in Nuremberg last week and he told me he is >>working on the same area of the code that this patch is for. His reason >>for touching this code was to solve some locking problems. Maybe you two >>can work together on a joint approach to improve this? > > Sure Joerg, I will work with Tom. What was the end result here? I see that the code has been reworked in 4.13 so your original patch no longer applies. Is the reworked version also expected to solve the original issue? Thanks Daniel ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) 2017-09-12 6:49 ` Daniel Drake @ 2017-09-12 9:02 ` Nath, Arindam 0 siblings, 0 replies; 7+ messages in thread From: Nath, Arindam @ 2017-09-12 9:02 UTC (permalink / raw) To: Daniel Drake Cc: Joerg Roedel, Lendacky, Thomas, iommu@lists.linux-foundation.org, amd-gfx@lists.freedesktop.org, Deucher, Alexander, Bridgman, John, Suthikulpanit, Suravee, linux@endlessm.com, Craig Stein, michel@daenzer.net, Kuehling, Felix, stable@vger.kernel.org Hi Daniel, >-----Original Message----- >From: Daniel Drake [mailto:drake@endlessm.com] >Sent: Tuesday, September 12, 2017 12:20 PM >To: Nath, Arindam <Arindam.Nath@amd.com> >Cc: Joerg Roedel <joro@8bytes.org>; Lendacky, Thomas ><Thomas.Lendacky@amd.com>; iommu@lists.linux-foundation.org; amd- >gfx@lists.freedesktop.org; Deucher, Alexander ><Alexander.Deucher@amd.com>; Bridgman, John ><John.Bridgman@amd.com>; Suthikulpanit, Suravee ><Suravee.Suthikulpanit@amd.com>; linux@endlessm.com; Craig Stein ><stein12c@gmail.com>; michel@daenzer.net; Kuehling, Felix ><Felix.Kuehling@amd.com>; stable@vger.kernel.org >Subject: Re: [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) > >Hi, > >On Tue, May 30, 2017 at 3:38 PM, Nath, Arindam <Arindam.Nath@amd.com> >wrote: >>>-----Original Message----- >>>From: Joerg Roedel [mailto:joro@8bytes.org] >>>Sent: Monday, May 29, 2017 8:09 PM >>>To: Nath, Arindam <Arindam.Nath@amd.com>; Lendacky, Thomas >>><Thomas.Lendacky@amd.com> >>>Cc: iommu@lists.linux-foundation.org; amd-gfx@lists.freedesktop.org; >>>Deucher, Alexander <Alexander.Deucher@amd.com>; Bridgman, John >>><John.Bridgman@amd.com>; drake@endlessm.com; Suthikulpanit, >Suravee >>><Suravee.Suthikulpanit@amd.com>; linux@endlessm.com; Craig Stein >>><stein12c@gmail.com>; michel@daenzer.net; Kuehling, Felix >>><Felix.Kuehling@amd.com>; stable@vger.kernel.org >>>Subject: Re: [PATCH] iommu/amd: flush IOTLB for specific domains only >(v3) >>> >>>Hi Arindam, >>> >>>I met Tom Lendacky last week in Nuremberg last week and he told me he is >>>working on the same area of the code that this patch is for. His reason >>>for touching this code was to solve some locking problems. Maybe you two >>>can work together on a joint approach to improve this? >> >> Sure Joerg, I will work with Tom. > >What was the end result here? I see that the code has been reworked in >4.13 so your original patch no longer applies. Is the reworked version >also expected to solve the original issue? Yes, if the reworked patch resolves the issue, my patch won't be required anymore. Thanks, Arindam > >Thanks >Daniel ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] iommu/amd: flush IOTLB for specific domains only (v3)
@ 2017-05-22 7:46 arindam.nath
0 siblings, 0 replies; 7+ messages in thread
From: arindam.nath @ 2017-05-22 7:46 UTC (permalink / raw)
To: arindam.nath; +Cc: stable
From: Arindam Nath <arindam.nath@amd.com>
Change History
--------------
v3:
- add Fixes and CC tags
- add link to Bugzilla
v2: changes suggested by Joerg
- add flush flag to improve efficiency of flush operation
v1:
- The idea behind flush queues is to defer the IOTLB flushing
for domains for which the mappings are no longer valid. We
add such domains in queue_add(), and when the queue size
reaches FLUSH_QUEUE_SIZE, we perform __queue_flush().
Since we have already taken lock before __queue_flush()
is called, we need to make sure the IOTLB flushing is
performed as quickly as possible.
In the current implementation, we perform IOTLB flushing
for all domains irrespective of which ones were actually
added in the flush queue initially. This can be quite
expensive especially for domains for which unmapping is
not required at this point of time.
This patch makes use of domain information in
'struct flush_queue_entry' to make sure we only flush
IOTLBs for domains who need it, skipping others.
Bugzilla: https://bugs.freedesktop.org/101029
Fixes: b1516a14657a ("iommu/amd: Implement flush queue")
Cc: stable@vger.kernel.org
Suggested-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Arindam Nath <arindam.nath@amd.com>
---
drivers/iommu/amd_iommu.c | 27 ++++++++++++++++++++-------
drivers/iommu/amd_iommu_types.h | 2 ++
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 63cacf5..1edeebec 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2227,15 +2227,26 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev)
static void __queue_flush(struct flush_queue *queue)
{
- struct protection_domain *domain;
- unsigned long flags;
int idx;
- /* First flush TLB of all known domains */
- spin_lock_irqsave(&amd_iommu_pd_lock, flags);
- list_for_each_entry(domain, &amd_iommu_pd_list, list)
- domain_flush_tlb(domain);
- spin_unlock_irqrestore(&amd_iommu_pd_lock, flags);
+ /* First flush TLB of all domains which were added to flush queue */
+ for (idx = 0; idx < queue->next; ++idx) {
+ struct flush_queue_entry *entry;
+
+ entry = queue->entries + idx;
+
+ /*
+ * There might be cases where multiple IOVA entries for the
+ * same domain are queued in the flush queue. To avoid
+ * flushing the same domain again, we check whether the
+ * flag is set or not. This improves the efficiency of
+ * flush operation.
+ */
+ if (!entry->dma_dom->domain.already_flushed) {
+ entry->dma_dom->domain.already_flushed = true;
+ domain_flush_tlb(&entry->dma_dom->domain);
+ }
+ }
/* Wait until flushes have completed */
domain_flush_complete(NULL);
@@ -2289,6 +2300,8 @@ static void queue_add(struct dma_ops_domain *dma_dom,
pages = __roundup_pow_of_two(pages);
address >>= PAGE_SHIFT;
+ dma_dom->domain.already_flushed = false;
+
queue = get_cpu_ptr(&flush_queue);
spin_lock_irqsave(&queue->lock, flags);
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index 4de8f41..4f5519d 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -454,6 +454,8 @@ struct protection_domain {
bool updated; /* complete domain flush required */
unsigned dev_cnt; /* devices assigned to this domain */
unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */
+ bool already_flushed; /* flag to avoid flushing the same domain again
+ in a single invocation of __queue_flush() */
};
/*
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in threadend of thread, other threads:[~2017-09-12 9:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20170407102039.GW7266@8bytes.org>
2017-05-22 7:48 ` [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) arindam.nath
2017-05-23 18:24 ` Deucher, Alexander
2017-05-29 14:38 ` Joerg Roedel
2017-05-30 7:38 ` Nath, Arindam
2017-09-12 6:49 ` Daniel Drake
2017-09-12 9:02 ` Nath, Arindam
2017-05-22 7:46 arindam.nath
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox