mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luming Yu <luming.yu@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Subject: [RFC patch] return early if all dmar HW unit ignored
Date: Fri, 31 Jul 2009 16:29:01 +0800	[thread overview]
Message-ID: <3877989d0907310129p29dd5039p18563946b9be8099@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2519 bytes --]

Hello list,

When debugging an IOMMU problem, I noticed it should be much more safe
to return early than late if all remapping HW unit are ignored.
To figure out what device causes the iommu problem on my linux box:
hp-compaq dc7800, I tried to mark all dmar HW
unit ignored,but still got a lot of unxepcted dmar_fault. So I think
the proposed patch make sense. The next step is to
add a boot option to make dmar HW units selectable enable/disable individually.

Please review.

**The patch is enclosed in text attachment*
**Using web client to send the patch* *
**below is for review, please apply attached  patch*/

Thanks,
Luming


Signed-off-by: Yu Luming <luming.yu@intel.com>

 intel-iommu.c |   26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index ebc9b8d..713e206 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2994,9 +2994,10 @@ static void __init iommu_exit_mempool(void)

 }

-static void __init init_no_remapping_devices(void)
+static int __init init_no_remapping_devices(void)
 {
 	struct dmar_drhd_unit *drhd;
+	int drhd_total = 0,drhd_ignored = 0;

 	for_each_drhd_unit(drhd) {
 		if (!drhd->include_all) {
@@ -3008,32 +3009,34 @@ static void __init init_no_remapping_devices(void)
 			if (i == drhd->devices_cnt)
 				drhd->ignored = 1;
 		}
+		drhd_total++;
 	}
-
-	if (dmar_map_gfx)
-		return;
-
 	for_each_drhd_unit(drhd) {
 		int i;
-		if (drhd->ignored || drhd->include_all)
+		if (drhd->ignored)
+			drhd_ignored++;
+		if (drhd->ignored || drhd->include_all) {
+			continue;
+		}
+		if (dmar_map_gfx)
 			continue;
-
 		for (i = 0; i < drhd->devices_cnt; i++)
 			if (drhd->devices[i] &&
 				!IS_GFX_DEVICE(drhd->devices[i]))
 				break;
-
 		if (i < drhd->devices_cnt)
 			continue;

 		/* bypass IOMMU if it is just for gfx devices */
 		drhd->ignored = 1;
+		drhd_ignored++;
 		for (i = 0; i < drhd->devices_cnt; i++) {
 			if (!drhd->devices[i])
 				continue;
 			drhd->devices[i]->dev.archdata.iommu = DUMMY_DEVICE_DOMAIN_INFO;
 		}
 	}
+	return (drhd_total == drhd_ignored);
 }

 #ifdef CONFIG_SUSPEND
@@ -3200,7 +3203,12 @@ int __init intel_iommu_init(void)
 	iommu_init_mempool();
 	dmar_init_reserved_ranges();

-	init_no_remapping_devices();
+	if(init_no_remapping_devices()) {
+		printk(KERN_ERR "IOMMU: all dmar HW unit ignored\n");
+		put_iova_domain(&reserved_iova_list);
+		iommu_exit_mempool();
+		return ret;
+	}

 	ret = init_dmars();
 	if (ret) {

[-- Attachment #2: 0.patch --]
[-- Type: application/octet-stream, Size: 1743 bytes --]

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index ebc9b8d..713e206 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2994,9 +2994,10 @@ static void __init iommu_exit_mempool(void)
 
 }
 
-static void __init init_no_remapping_devices(void)
+static int __init init_no_remapping_devices(void)
 {
 	struct dmar_drhd_unit *drhd;
+	int drhd_total = 0,drhd_ignored = 0;
 
 	for_each_drhd_unit(drhd) {
 		if (!drhd->include_all) {
@@ -3008,32 +3009,34 @@ static void __init init_no_remapping_devices(void)
 			if (i == drhd->devices_cnt)
 				drhd->ignored = 1;
 		}
+		drhd_total++;
 	}
-
-	if (dmar_map_gfx)
-		return;
-
 	for_each_drhd_unit(drhd) {
 		int i;
-		if (drhd->ignored || drhd->include_all)
+		if (drhd->ignored)
+			drhd_ignored++;
+		if (drhd->ignored || drhd->include_all) {
+			continue;
+		}
+		if (dmar_map_gfx)
 			continue;
-
 		for (i = 0; i < drhd->devices_cnt; i++)
 			if (drhd->devices[i] &&
 				!IS_GFX_DEVICE(drhd->devices[i]))
 				break;
-
 		if (i < drhd->devices_cnt)
 			continue;
 
 		/* bypass IOMMU if it is just for gfx devices */
 		drhd->ignored = 1;
+		drhd_ignored++;
 		for (i = 0; i < drhd->devices_cnt; i++) {
 			if (!drhd->devices[i])
 				continue;
 			drhd->devices[i]->dev.archdata.iommu = DUMMY_DEVICE_DOMAIN_INFO;
 		}
 	}
+	return (drhd_total == drhd_ignored);
 }
 
 #ifdef CONFIG_SUSPEND
@@ -3200,7 +3203,12 @@ int __init intel_iommu_init(void)
 	iommu_init_mempool();
 	dmar_init_reserved_ranges();
 
-	init_no_remapping_devices();
+	if(init_no_remapping_devices()) {
+		printk(KERN_ERR "IOMMU: all dmar HW unit ignored\n");
+		put_iova_domain(&reserved_iova_list);
+		iommu_exit_mempool();
+		return ret;
+	}
 
 	ret = init_dmars();
 	if (ret) {

             reply	other threads:[~2009-07-31  8:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-31  8:29 Luming Yu [this message]
2009-08-04  7:09 ` David Woodhouse
2009-08-10  6:21   ` Luming Yu
2009-08-10  9:13     ` David Woodhouse
2009-08-10  9:19       ` Luming Yu
2009-08-10  9:22         ` Luming Yu
2009-08-11  2:47           ` Luming Yu

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=3877989d0907310129p29dd5039p18563946b9be8099@mail.gmail.com \
    --to=luming.yu@gmail.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®