public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Kevin Mitchell via iommu <iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: [PATCH 2/3] iommu/amd: move gart fallback to amd_iommu_init
Date: Thu, 18 Apr 2019 10:57:47 -0700	[thread overview]
Message-ID: <20190418175744.6229-3-kevmitch@arista.com> (raw)
In-Reply-To: <20190418175744.6229-1-kevmitch-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org>

The fallback to the GART driver in the case amd_iommu doesn't work was
executed in a function called free_iommu_resources, which didn't really
make sense. This was even being called twice if amd_iommu=off was
specified on the command line.

The only complication is that it needs to be verified that amd_iommu has
fully relinquished control by calling free_iommu_resources and emptying
the amd_iommu_list.

Signed-off-by: Kevin Mitchell <kevmitch-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org>
---
 drivers/iommu/amd_iommu_init.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 3798d7303c99..5f3df5ae6ba8 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -2345,15 +2345,6 @@ static void __init free_iommu_resources(void)
 	amd_iommu_dev_table = NULL;
 
 	free_iommu_all();
-
-#ifdef CONFIG_GART_IOMMU
-	/*
-	 * We failed to initialize the AMD IOMMU - try fallback to GART
-	 * if possible.
-	 */
-	gart_iommu_init();
-
-#endif
 }
 
 /* SB IOAPIC is always on this device in AMD systems */
@@ -2774,6 +2765,16 @@ static int __init amd_iommu_init(void)
 		}
 	}
 
+#ifdef CONFIG_GART_IOMMU
+	if (ret && list_empty(&amd_iommu_list)) {
+		/*
+		 * We failed to initialize the AMD IOMMU - try fallback
+		 * to GART if possible.
+		 */
+		gart_iommu_init();
+	}
+#endif
+
 	for_each_iommu(iommu)
 		amd_iommu_debugfs_setup(iommu);
 
-- 
2.20.1

WARNING: multiple messages have this Message-ID (diff)
From: Kevin Mitchell via iommu <iommu@lists.linux-foundation.org>
To: iommu@lists.linux-foundation.org
Subject: [PATCH 2/3] iommu/amd: move gart fallback to amd_iommu_init
Date: Thu, 18 Apr 2019 10:57:47 -0700	[thread overview]
Message-ID: <20190418175744.6229-3-kevmitch@arista.com> (raw)
Message-ID: <20190418175747.f3p0yLFeMKPGvhmbuqeE7PV6DOfk8vEnv08lVv_EbSc@z> (raw)
In-Reply-To: <20190418175744.6229-1-kevmitch@arista.com>

The fallback to the GART driver in the case amd_iommu doesn't work was
executed in a function called free_iommu_resources, which didn't really
make sense. This was even being called twice if amd_iommu=off was
specified on the command line.

The only complication is that it needs to be verified that amd_iommu has
fully relinquished control by calling free_iommu_resources and emptying
the amd_iommu_list.

Signed-off-by: Kevin Mitchell <kevmitch@arista.com>
---
 drivers/iommu/amd_iommu_init.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 3798d7303c99..5f3df5ae6ba8 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -2345,15 +2345,6 @@ static void __init free_iommu_resources(void)
 	amd_iommu_dev_table = NULL;
 
 	free_iommu_all();
-
-#ifdef CONFIG_GART_IOMMU
-	/*
-	 * We failed to initialize the AMD IOMMU - try fallback to GART
-	 * if possible.
-	 */
-	gart_iommu_init();
-
-#endif
 }
 
 /* SB IOAPIC is always on this device in AMD systems */
@@ -2774,6 +2765,16 @@ static int __init amd_iommu_init(void)
 		}
 	}
 
+#ifdef CONFIG_GART_IOMMU
+	if (ret && list_empty(&amd_iommu_list)) {
+		/*
+		 * We failed to initialize the AMD IOMMU - try fallback
+		 * to GART if possible.
+		 */
+		gart_iommu_init();
+	}
+#endif
+
 	for_each_iommu(iommu)
 		amd_iommu_debugfs_setup(iommu);
 
-- 
2.20.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  parent reply	other threads:[~2019-04-18 17:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18 17:57 [PATCH 0/3] handle init errors more gracefully in amd_iommu Kevin Mitchell via iommu
2019-04-18 17:57 ` Kevin Mitchell via iommu
     [not found] ` <20190418175744.6229-1-kevmitch-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org>
2019-04-18 17:57   ` [PATCH 1/3] iommu/amd: make iommu_disable safer Kevin Mitchell via iommu
2019-04-18 17:57     ` Kevin Mitchell via iommu
2019-04-18 17:57   ` Kevin Mitchell via iommu [this message]
2019-04-18 17:57     ` [PATCH 2/3] iommu/amd: move gart fallback to amd_iommu_init Kevin Mitchell via iommu
2019-04-18 17:57   ` [PATCH 3/3] iommu/amd: only free resources once on init error Kevin Mitchell via iommu
2019-04-18 17:57     ` Kevin Mitchell via iommu
2019-05-07 18:05 ` [PATCH 0/3] handle init errors more gracefully in amd_iommu Kevin Mitchell via iommu
  -- strict thread matches above, loose matches on Subject: below --
2019-05-17  0:52 Kevin Mitchell via iommu
2019-05-17  0:52 ` [PATCH 2/3] iommu/amd: move gart fallback to amd_iommu_init Kevin Mitchell via iommu
2019-05-28 18:29 [PATCH 0/3] handle init errors more gracefully in amd_iommu Kevin Mitchell via iommu
2019-05-28 18:29 ` [PATCH 2/3] iommu/amd: move gart fallback to amd_iommu_init Kevin Mitchell via iommu
2019-06-12 21:52 [PATCH 0/3] handle init errors more gracefully in amd_iommu Kevin Mitchell via iommu
2019-06-12 21:52 ` [PATCH 2/3] iommu/amd: move gart fallback to amd_iommu_init Kevin Mitchell via iommu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190418175744.6229-3-kevmitch@arista.com \
    --to=iommu-cuntk1mwbs9qetfly7kem3xjstq8ys+chz5vsktnxna@public.gmane.org \
    --cc=kevmitch-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox