All of lore.kernel.org
 help / color / mirror / Atom feed
* amd-iommu: can't boot with amdgpu, AMD-Vi: Completion-Wait loop timed out
@ 2017-03-13 19:49 Daniel Drake
       [not found] ` <CAD8Lp457TE1CnJ-DHnB6NB2LWxgA5K5K57Q6L7XcSHeYNpvARQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 42+ messages in thread
From: Daniel Drake @ 2017-03-13 19:49 UTC (permalink / raw)
  To: joro-zLv9SwRftAIdnm+yROfE0A
  Cc: Chris Chiu, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Linux Upstreaming Team, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hi,

We are unable to boot Acer Aspire E5-553G (AMD FX-9800P RADEON R7) nor
Acer Aspire E5-523 with standard configurations because during boot
the screen is flooded with the following error message over and over:

  AMD-Vi: Completion-Wait loop timed out

We have left the system for quite a while but the message spam does
not stop and the system doesn't complete the boot sequence.

We have reproduced on Linux 4.8 and Linux 4.10.

To avoid this, we can boot with iommu=soft or just disable the amdgpu
display driver.

Looks like this may also affect HP 15-ba012no :
https://bugzilla.redhat.com/show_bug.cgi?id=1409201

Earlier during boot the iommu is detected as:

[    1.274518] AMD-Vi: Found IOMMU at 0000:00:00.2 cap 0x40
[    1.274519] AMD-Vi: Extended features (0x37ef22294ada):
[    1.274519]  PPR NX GT IA GA PC GA_vAPIC
[    1.274523] AMD-Vi: Interrupt remapping enabled
[    1.274523] AMD-Vi: virtual APIC enabled
[    1.275144] AMD-Vi: Lazy IO/TLB flushing enabled
[    1.276498] perf: AMD NB counters detected
[    1.278096] LVT offset 0 assigned for vector 0x400
[    1.278963] perf: AMD IBS detected (0x000007ff)
[    1.278977] perf: amd_iommu: Detected. (0 banks, 0 counters/bank)

Any suggestions for how we can fix this, or get more useful debug info?

Thanks
Daniel
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 42+ messages in thread
* [PATCH] iommu/amd: flush IOTLB for specific domains only (v3)
@ 2017-05-22  7:46 arindam.nath
  0 siblings, 0 replies; 42+ 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] 42+ messages in thread

end of thread, other threads:[~2017-09-12  9:02 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13 19:49 amd-iommu: can't boot with amdgpu, AMD-Vi: Completion-Wait loop timed out Daniel Drake
     [not found] ` <CAD8Lp457TE1CnJ-DHnB6NB2LWxgA5K5K57Q6L7XcSHeYNpvARQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-13 20:01   ` Deucher, Alexander
     [not found]     ` <CY4PR12MB16533C83151D6FCFC11ED457F7250-rpdhrqHFk06apTa93KjAaQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-03-14  6:16       ` Nath, Arindam
2017-03-17 12:15       ` Daniel Drake
     [not found]         ` <CAD8Lp47zjJvqxY3TMMAhjz3OnLR52CtsQh_PQFPmsEW-xHfDwg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-17 15:53           ` Alex Deucher
     [not found]             ` <CADnq5_Oyfm-BzU9YV_QLjm6HxtMwnJcFkfYtjmCWpuah35TFvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-21 15:57               ` joro-zLv9SwRftAIdnm+yROfE0A
     [not found]                 ` <20170321155725.GD29659-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-03-21 16:01                   ` Deucher, Alexander
     [not found]                     ` <BN6PR12MB16526DD4A3B60DB4E20B9907F73D0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-03-21 16:10                       ` 'joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org'
     [not found]                         ` <20170321161056.GE29659-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-03-21 16:14                           ` Nath, Arindam
2017-03-21 16:17                           ` Deucher, Alexander
     [not found]                             ` <BN6PR12MB16528AF8E5577E9ACB483212F73D0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-03-21 16:25                               ` 'joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org'
     [not found]                                 ` <20170321162532.GG29659-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-03-21 16:30                                   ` Deucher, Alexander
     [not found]                                     ` <BN6PR12MB165268CA4C460215950409D5F73D0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-03-22 11:22                                       ` 'joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org'
     [not found]                                         ` <20170322112242.GK29659-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-03-22 17:18                                           ` Tom St Denis
     [not found]                                             ` <afecf448-c9fe-c481-0d0e-6dec0f459eeb-5C7GfCeVMHo@public.gmane.org>
2017-03-22 17:26                                               ` Tom St Denis
2017-03-27  6:17                                           ` [PATCH] iommu/amd: flush IOTLB for specific domains only arindam.nath-5C7GfCeVMHo
     [not found]                                             ` <1490595427-11979-1-git-send-email-arindam.nath-5C7GfCeVMHo@public.gmane.org>
2017-03-27 12:25                                               ` Daniel Drake
     [not found]                                                 ` <CAD8Lp46RjsUJEvCR5qVY6p8za5H9iDGTAyJMDd1zO7gbgBvqfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-27 12:27                                                   ` Nath, Arindam
2017-03-30  6:23                                                 ` Nath, Arindam
     [not found]                                                   ` <MWHPR12MB15186B0A864F247BFBEF8EAD9C340-Gy0DoCVfaSXKu+HfpMNLNQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-03-30 13:45                                                     ` Daniel Drake
     [not found]                                                       ` <CAD8Lp47VQ0X0ydsGMrpTu-y4LAXfg9N7+Mzb0hDWDsKc2P-kQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-30 14:48                                                         ` Nath, Arindam
2017-04-05 15:01                                                         ` Nath, Arindam
     [not found]                                                           ` <MWHPR12MB15183AFF01D7D74109CC62FF9C0A0-Gy0DoCVfaSXKu+HfpMNLNQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-05-08 18:22                                                             ` Daniel Drake
2017-04-07 10:20                                               ` Joerg Roedel
     [not found]                                                 ` <20170407102039.GW7266-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-05-19  1:31                                                   ` Michel Dänzer
2017-05-19 10:02                                                   ` [PATCH] iommu/amd: flush IOTLB for specific domains only (v2) arindam.nath-5C7GfCeVMHo
     [not found]                                                     ` <1495188151-14358-1-git-send-email-arindam.nath-5C7GfCeVMHo@public.gmane.org>
2017-05-19 13:35                                                       ` Jan Vesely
     [not found]                                                         ` <1495200930.4360.6.camel-kgbqMDwikbSVc3sceRu5cw@public.gmane.org>
2017-05-21  7:25                                                           ` Nath, Arindam
2017-05-22  1:08                                                       ` Michel Dänzer
     [not found]                                                         ` <c03c7d65-52a7-b656-2278-0cfb24e8d07a-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-05-22  1:12                                                           ` Michel Dänzer
2017-05-22  7:48                                                   ` [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) arindam.nath-5C7GfCeVMHo
2017-05-22  7:48                                                     ` arindam.nath
     [not found]                                                     ` <1495439281-24005-1-git-send-email-arindam.nath-5C7GfCeVMHo@public.gmane.org>
2017-05-23 18:24                                                       ` Deucher, Alexander
2017-05-23 18:24                                                         ` Deucher, Alexander
2017-05-29 14:38                                                     ` Joerg Roedel
2017-05-30  7:38                                                       ` Nath, Arindam
     [not found]                                                         ` <MWHPR12MB1518926453E8BAF205F3492D9CF00-Gy0DoCVfaSXKu+HfpMNLNQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-09-12  6:49                                                           ` Daniel Drake
2017-09-12  6:49                                                             ` Daniel Drake
2017-09-12  9:02                                                             ` Nath, Arindam
2017-03-27 12:23                                           ` amd-iommu: can't boot with amdgpu, AMD-Vi: Completion-Wait loop timed out Daniel Drake
2017-03-21 17:22                                   ` Tom St Denis
  -- strict thread matches above, loose matches on Subject: below --
2017-05-22  7:46 [PATCH] iommu/amd: flush IOTLB for specific domains only (v3) arindam.nath

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.