From: Fenghua Yu <fenghua.yu@intel.com>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
David Woodhouse <dwmw2@infradead.org>,
Christopher Wright <chrisw@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Tony Luck <tony.luck@intel.com>
Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
linux-ia64@vger.kernel.org
Subject: [PATCH v2] IA64 Compilation Error Fix for Intel IOMMU Identity Mapping Support
Date: Wed, 24 Jun 2009 21:16:05 -0700 [thread overview]
Message-ID: <20090625041605.GA9330@linux-os.sc.intel.com> (raw)
In-Reply-To: <20090625095643F.fujita.tomonori@lab.ntt.co.jp>
IA64 compilation error fix for Intel IOMMU identity mapping
The Intel IOMMU identity mapping uses e820 to walk the memory map. This causes
compilation error on IA64 when IOMMU is configured:
drivers/pci/intel-iommu.c:42:22: error: asm/e820.h: No such file or directory
This patch fixes this compilation error on IA64. It defines architecture
dependent memory map walk functions on x86 and ia64 seperately to set up
identity mapping for all devices.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Acked-by: Tony Luck <tony.luck@intel.com>
---
This patch is against the latest upstream tree.
arch/ia64/kernel/pci-dma.c | 27 +++++++++++++++++++++++++++
arch/x86/kernel/pci-dma.c | 29 +++++++++++++++++++++++++++++
drivers/pci/intel-iommu.c | 38 ++++++++++++++++++++++----------------
include/linux/intel-iommu.h | 4 ++++
4 files changed, 82 insertions(+), 16 deletions(-)
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index 0569596..9cb3700 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -10,7 +10,9 @@
#include <linux/dmar.h>
#include <asm/iommu.h>
#include <asm/machvec.h>
+#include <linux/efi.h>
#include <linux/dma-mapping.h>
+#include <linux/intel-iommu.h>
#include <asm/system.h>
@@ -122,4 +124,29 @@ void __init pci_iommu_alloc(void)
#endif
}
+static int __initdata identity_mapped = 1;
+
+static int __init __iommu_prepare_identity_map(u64 start, u64 end, void *pdev)
+{
+ int ret;
+
+ ret = iommu_prepare_identity_map((struct pci_dev *)pdev, start, end);
+ if (ret) {
+ printk(KERN_INFO "1:1 mapping to one domain failed.\n");
+ identity_mapped = 0;
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+int __init iommu_setup_identity_map(struct pci_dev *pdev)
+{
+ efi_memmap_walk(__iommu_prepare_identity_map, pdev);
+ if (!identity_mapped)
+ return -EFAULT;
+
+ return 0;
+}
+
#endif
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 4763047..16dcc61 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -10,6 +10,7 @@
#include <asm/gart.h>
#include <asm/calgary.h>
#include <asm/amd_iommu.h>
+#include <linux/intel-iommu.h>
static int forbid_dac __read_mostly;
@@ -314,3 +315,31 @@ static __devinit void via_no_dac(struct pci_dev *dev)
}
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID, via_no_dac);
#endif
+
+#ifdef CONFIG_DMAR
+int iommu_setup_identity_map(struct pci_dev *pdev)
+{
+ int i;
+ int ret;
+
+ for (i = 0; i < e820.nr_map; i++) {
+ struct e820entry *ei = &e820.map[i];
+
+ if (ei->type == E820_RAM) {
+ ret = iommu_prepare_identity_map(pdev,
+ ei->addr, ei->addr + ei->size);
+ if (ret) {
+ printk(KERN_INFO "1:1 mapping to one domain failed.\n");
+ return -EFAULT;
+ }
+ }
+ }
+
+ return 0;
+}
+#else
+int iommu_setup_identity_map(struct pci_dev *pdev)
+{
+ return 0;
+}
+#endif
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index e53eacd..009a79a 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -39,7 +39,6 @@
#include <linux/sysdev.h>
#include <asm/cacheflush.h>
#include <asm/iommu.h>
-#include <asm/e820.h>
#include "pci.h"
#define ROOT_SIZE VTD_PAGE_SIZE
@@ -1845,9 +1844,8 @@ error:
static int iommu_identity_mapping;
-static int iommu_prepare_identity_map(struct pci_dev *pdev,
- unsigned long long start,
- unsigned long long end)
+int iommu_prepare_identity_map(struct pci_dev *pdev, unsigned long long start,
+ unsigned long long end)
{
struct dmar_domain *domain;
unsigned long size;
@@ -2081,8 +2079,8 @@ static int domain_add_dev_info(struct dmar_domain *domain,
static int iommu_prepare_static_identity_mapping(void)
{
- int i;
struct pci_dev *pdev = NULL;
+ int first_pdev = 1;
int ret;
ret = si_domain_init();
@@ -2091,17 +2089,25 @@ static int iommu_prepare_static_identity_mapping(void)
printk(KERN_INFO "IOMMU: Setting identity map:\n");
for_each_pci_dev(pdev) {
- for (i = 0; i < e820.nr_map; i++) {
- struct e820entry *ei = &e820.map[i];
-
- if (ei->type == E820_RAM) {
- ret = iommu_prepare_identity_map(pdev,
- ei->addr, ei->addr + ei->size);
- if (ret) {
- printk(KERN_INFO "1:1 mapping to one domain failed.\n");
- return -EFAULT;
- }
- }
+ if (first_pdev) {
+ /*
+ * first pdev sets up the whole page table for
+ * si_domain.
+ */
+ first_pdev = 0;
+ ret = iommu_setup_identity_map(pdev);
+ if (ret)
+ return ret;
+ } else {
+ /*
+ * following pdev's just use the page table.
+ */
+ printk(KERN_INFO "IOMMU: identity mapping for device %s\n",
+ pci_name(pdev));
+ ret = domain_context_mapping(si_domain, pdev,
+ CONTEXT_TT_MULTI_LEVEL);
+ if (ret)
+ return ret;
}
ret = domain_add_dev_info(si_domain, pdev);
if (ret)
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 482dc91..5d470cf 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -359,5 +359,9 @@ extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
u64 addr, unsigned mask);
extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu);
+extern int iommu_prepare_identity_map(struct pci_dev *pdev,
+ unsigned long long start,
+ unsigned long long end);
+extern int iommu_setup_identity_map(struct pci_dev *pdev);
#endif
next prev parent reply other threads:[~2009-06-25 4:16 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090327212241.234500000@intel.com>
2009-03-28 14:24 ` [patch 0/4] Intel IOMMU Supspend/Resume Support Andrew Lutomirski
2009-03-30 23:01 ` David Woodhouse
[not found] ` <20090327212321.520992000@intel.com>
2009-04-03 12:37 ` [patch 4/4] Intel IOMMU Suspend/Resume Support - Code Clean Up David Woodhouse
[not found] ` <20090327212321.070229000@intel.com>
2009-04-16 0:19 ` [PATCH] Intel IOMMU Pass Through Support Fenghua Yu
2009-04-16 2:13 ` Han, Weidong
2009-04-19 10:05 ` David Woodhouse
2009-04-20 17:27 ` Yu, Fenghua
2009-05-13 23:13 ` [PATCH] Fix Intel IOMMU Compilation Warnings on IA64 Fenghua Yu
2009-05-14 15:17 ` David Woodhouse
2009-05-14 15:31 ` Matthew Wilcox
2009-05-14 17:59 ` Fenghua Yu
2009-06-18 18:05 ` [PATCH 1/2] IOMMU Identity Mapping Support: iommu_identity_mapping definition Fenghua Yu
2009-06-18 18:08 ` Muli Ben-Yehuda
2009-06-18 18:13 ` Chris Wright
2009-06-18 18:14 ` Yu, Fenghua
2009-06-18 18:25 ` Muli Ben-Yehuda
2009-06-18 18:31 ` Chris Wright
2009-06-18 18:41 ` Muli Ben-Yehuda
2009-06-18 18:50 ` Yu, Fenghua
2009-06-18 18:51 ` Chris Wright
2009-06-18 19:09 ` Yu, Fenghua
2009-06-25 0:38 ` [PATCH] IA64 Compilation Error Fix for Intel IOMMU Identity Mapping Support Fenghua Yu
2009-06-25 1:00 ` FUJITA Tomonori
2009-06-25 4:16 ` Fenghua Yu [this message]
2009-06-25 4:48 ` [PATCH v2] " FUJITA Tomonori
2009-06-25 7:11 ` David Woodhouse
2009-06-25 21:52 ` David Woodhouse
2009-06-25 21:56 ` Yu, Fenghua
2009-06-26 18:21 ` David Woodhouse
2009-06-25 22:00 ` Linus Torvalds
2009-06-25 22:46 ` Tony Luck
2009-06-25 23:43 ` Chris Wright
2009-06-26 1:35 ` Linus Torvalds
2009-06-26 1:52 ` Chris Wright
2009-06-26 2:00 ` Linus Torvalds
2009-06-26 2:08 ` Chris Wright
2009-06-26 11:15 ` David Woodhouse
2009-06-27 0:03 ` Chris Wright
2009-06-27 11:44 ` David Woodhouse
2009-06-18 18:13 ` [PATCH 1/2] IOMMU Identity Mapping Support: iommu_identity_mapping definition Chris Wright
2009-06-18 18:28 ` Yu, Fenghua
2009-06-18 18:34 ` Chris Wright
2009-07-04 18:40 ` David Woodhouse
2009-05-20 17:42 ` [PATCH] Time out for possible dead loops during queued invalidation wait Fenghua Yu
2009-05-27 5:51 ` Andrew Morton
2009-05-27 22:40 ` Yu, Fenghua
2009-05-27 22:48 ` Andrew Morton
2009-05-27 23:25 ` Yu, Fenghua
2009-05-27 23:51 ` Andrew Morton
2009-05-28 0:47 ` Yu, Fenghua
2009-06-18 18:05 ` [PATCH 2/2] IOMMU Identity Mapping Support: Intel IOMMU implementation Fenghua Yu
2009-06-18 19:15 ` Chris Wright
2009-06-18 19:40 ` Yu, Fenghua
2009-06-18 20:02 ` Chris Wright
2009-06-19 20:47 ` [PATCH v2] IOMMU Identity Mapping Support (drivers/pci/intel_iommu.c) Fenghua Yu
2009-04-30 23:29 ` [PATCH] Intel IOMMU Pass Through Support Andrew Morton
2009-04-30 23:37 ` Randy Dunlap
2009-05-01 0:00 ` Andrew Morton
2009-05-01 0:57 ` Fenghua Yu
2009-05-01 0:05 ` Fenghua Yu
2009-05-01 0:14 ` Andrew Morton
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=20090625041605.GA9330@linux-os.sc.intel.com \
--to=fenghua.yu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=chrisw@redhat.com \
--cc=dwmw2@infradead.org \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.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