aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 13:11:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 13:11:38 -0500
commita79960e576ebca9dbf24489b562689f2be7e9ff0 (patch)
treeb0748839230c2bba1d49ccdd732608d7d1f334cb
parent661e338f728d101b4839b6b157d44cfcb80e3c5e (diff)
parentcd7bcf32d42b15891620b3f1387a00178b54291a (diff)
Merge git://git.infradead.org/iommu-2.6
* git://git.infradead.org/iommu-2.6: implement early_io{re,un}map for ia64 Revert "Intel IOMMU: Avoid memory allocation failures in dma map api calls" intel-iommu: ignore page table validation in pass through mode intel-iommu: Fix oops with intel_iommu=igfx_off intel-iommu: Check for an RMRR which ends before it starts. intel-iommu: Apply BIOS sanity checks for interrupt remapping too. intel-iommu: Detect DMAR in hyperspace at probe time. dmar: Fix build failure without NUMA, warn on bogus RHSA tables and don't abort iommu: Allocate dma-remapping structures using numa locality info intr_remap: Allocate intr-remapping table using numa locality info dmar: Allocate queued invalidation structure using numa locality info dmar: support for parsing Remapping Hardware Static Affinity structure
-rw-r--r--arch/ia64/include/asm/io.h2
-rw-r--r--arch/ia64/mm/ioremap.c11
-rw-r--r--drivers/pci/dmar.c110
-rw-r--r--drivers/pci/intel-iommu.c78
-rw-r--r--drivers/pci/intr_remapping.c3
-rw-r--r--include/linux/intel-iommu.h1
6 files changed, 154 insertions, 51 deletions
diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h
index 0d9d16e2d949..cc8335eb3110 100644
--- a/arch/ia64/include/asm/io.h
+++ b/arch/ia64/include/asm/io.h
@@ -424,6 +424,8 @@ __writeq (unsigned long val, volatile void __iomem *addr)
424extern void __iomem * ioremap(unsigned long offset, unsigned long size); 424extern void __iomem * ioremap(unsigned long offset, unsigned long size);
425extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); 425extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
426extern void iounmap (volatile void __iomem *addr); 426extern void iounmap (volatile void __iomem *addr);
427extern void __iomem * early_ioremap (unsigned long phys_addr, unsigned long size);
428extern void early_iounmap (volatile void __iomem *addr, unsigned long size);
427 429
428/* 430/*
429 * String version of IO memory access ops: 431 * String version of IO memory access ops:
diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c
index 2a140627dfd6..3dccdd8eb275 100644
--- a/arch/ia64/mm/ioremap.c
+++ b/arch/ia64/mm/ioremap.c
@@ -22,6 +22,12 @@ __ioremap (unsigned long phys_addr)
22} 22}
23 23
24void __iomem * 24void __iomem *
25early_ioremap (unsigned long phys_addr, unsigned long size)
26{
27 return __ioremap(phys_addr);
28}
29
30void __iomem *
25ioremap (unsigned long phys_addr, unsigned long size) 31ioremap (unsigned long phys_addr, unsigned long size)
26{ 32{
27 void __iomem *addr; 33 void __iomem *addr;
@@ -102,6 +108,11 @@ ioremap_nocache (unsigned long phys_addr, unsigned long size)
102EXPORT_SYMBOL(ioremap_nocache); 108EXPORT_SYMBOL(ioremap_nocache);
103 109
104void 110void
111early_iounmap (volatile void __iomem *addr, unsigned long size)
112{
113}
114
115void
105iounmap (volatile void __iomem *addr) 116iounmap (volatile void __iomem *addr)
106{ 117{
107 if (REGION_NUMBER(addr) == RGN_GATE) 118 if (REGION_NUMBER(addr) == RGN_GATE)
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 6cdc931f7c17..83aae4747594 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -339,6 +339,35 @@ found:
339} 339}
340#endif 340#endif
341 341
342#ifdef CONFIG_ACPI_NUMA
343static int __init
344dmar_parse_one_rhsa(struct acpi_dmar_header *header)
345{
346 struct acpi_dmar_rhsa *rhsa;
347 struct dmar_drhd_unit *drhd;
348
349 rhsa = (struct acpi_dmar_rhsa *)header;
350 for_each_drhd_unit(drhd) {
351 if (drhd->reg_base_addr == rhsa->base_address) {
352 int node = acpi_map_pxm_to_node(rhsa->proximity_domain);
353
354 if (!node_online(node))
355 node = -1;
356 drhd->iommu->node = node;
357 return 0;
358 }
359 }
360 WARN(1, "Your BIOS is broken; RHSA refers to non-existent DMAR unit at %llx\n"
361 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
362 drhd->reg_base_addr,
363 dmi_get_system_info(DMI_BIOS_VENDOR),
364 dmi_get_system_info(DMI_BIOS_VERSION),
365 dmi_get_system_info(DMI_PRODUCT_VERSION));
366
367 return 0;
368}
369#endif
370
342static void __init 371static void __init
343dmar_table_print_dmar_entry(struct acpi_dmar_header *header) 372dmar_table_print_dmar_entry(struct acpi_dmar_header *header)
344{ 373{
@@ -458,7 +487,9 @@ parse_dmar_table(void)
458#endif 487#endif
459 break; 488 break;
460 case ACPI_DMAR_HARDWARE_AFFINITY: 489 case ACPI_DMAR_HARDWARE_AFFINITY:
461 /* We don't do anything with RHSA (yet?) */ 490#ifdef CONFIG_ACPI_NUMA
491 ret = dmar_parse_one_rhsa(entry_header);
492#endif
462 break; 493 break;
463 default: 494 default:
464 printk(KERN_WARNING PREFIX 495 printk(KERN_WARNING PREFIX
@@ -582,6 +613,8 @@ int __init dmar_table_init(void)
582 return 0; 613 return 0;
583} 614}
584 615
616static int bios_warned;
617
585int __init check_zero_address(void) 618int __init check_zero_address(void)
586{ 619{
587 struct acpi_table_dmar *dmar; 620 struct acpi_table_dmar *dmar;
@@ -601,6 +634,9 @@ int __init check_zero_address(void)
601 } 634 }
602 635
603 if (entry_header->type == ACPI_DMAR_TYPE_HARDWARE_UNIT) { 636 if (entry_header->type == ACPI_DMAR_TYPE_HARDWARE_UNIT) {
637 void __iomem *addr;
638 u64 cap, ecap;
639
604 drhd = (void *)entry_header; 640 drhd = (void *)entry_header;
605 if (!drhd->address) { 641 if (!drhd->address) {
606 /* Promote an attitude of violence to a BIOS engineer today */ 642 /* Promote an attitude of violence to a BIOS engineer today */
@@ -609,17 +645,40 @@ int __init check_zero_address(void)
609 dmi_get_system_info(DMI_BIOS_VENDOR), 645 dmi_get_system_info(DMI_BIOS_VENDOR),
610 dmi_get_system_info(DMI_BIOS_VERSION), 646 dmi_get_system_info(DMI_BIOS_VERSION),
611 dmi_get_system_info(DMI_PRODUCT_VERSION)); 647 dmi_get_system_info(DMI_PRODUCT_VERSION));
612#ifdef CONFIG_DMAR 648 bios_warned = 1;
613 dmar_disabled = 1; 649 goto failed;
614#endif 650 }
615 return 0; 651
652 addr = early_ioremap(drhd->address, VTD_PAGE_SIZE);
653 if (!addr ) {
654 printk("IOMMU: can't validate: %llx\n", drhd->address);
655 goto failed;
656 }
657 cap = dmar_readq(addr + DMAR_CAP_REG);
658 ecap = dmar_readq(addr + DMAR_ECAP_REG);
659 early_iounmap(addr, VTD_PAGE_SIZE);
660 if (cap == (uint64_t)-1 && ecap == (uint64_t)-1) {
661 /* Promote an attitude of violence to a BIOS engineer today */
662 WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n"
663 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
664 drhd->address,
665 dmi_get_system_info(DMI_BIOS_VENDOR),
666 dmi_get_system_info(DMI_BIOS_VERSION),
667 dmi_get_system_info(DMI_PRODUCT_VERSION));
668 bios_warned = 1;
669 goto failed;
616 } 670 }
617 break;
618 } 671 }
619 672
620 entry_header = ((void *)entry_header + entry_header->length); 673 entry_header = ((void *)entry_header + entry_header->length);
621 } 674 }
622 return 1; 675 return 1;
676
677failed:
678#ifdef CONFIG_DMAR
679 dmar_disabled = 1;
680#endif
681 return 0;
623} 682}
624 683
625void __init detect_intel_iommu(void) 684void __init detect_intel_iommu(void)
@@ -670,6 +729,18 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
670 int agaw = 0; 729 int agaw = 0;
671 int msagaw = 0; 730 int msagaw = 0;
672 731
732 if (!drhd->reg_base_addr) {
733 if (!bios_warned) {
734 WARN(1, "Your BIOS is broken; DMAR reported at address zero!\n"
735 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
736 dmi_get_system_info(DMI_BIOS_VENDOR),
737 dmi_get_system_info(DMI_BIOS_VERSION),
738 dmi_get_system_info(DMI_PRODUCT_VERSION));
739 bios_warned = 1;
740 }
741 return -EINVAL;
742 }
743
673 iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); 744 iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
674 if (!iommu) 745 if (!iommu)
675 return -ENOMEM; 746 return -ENOMEM;
@@ -686,13 +757,16 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
686 iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG); 757 iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG);
687 758
688 if (iommu->cap == (uint64_t)-1 && iommu->ecap == (uint64_t)-1) { 759 if (iommu->cap == (uint64_t)-1 && iommu->ecap == (uint64_t)-1) {
689 /* Promote an attitude of violence to a BIOS engineer today */ 760 if (!bios_warned) {
690 WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n" 761 /* Promote an attitude of violence to a BIOS engineer today */
691 "BIOS vendor: %s; Ver: %s; Product Version: %s\n", 762 WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n"
692 drhd->reg_base_addr, 763 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
693 dmi_get_system_info(DMI_BIOS_VENDOR), 764 drhd->reg_base_addr,
694 dmi_get_system_info(DMI_BIOS_VERSION), 765 dmi_get_system_info(DMI_BIOS_VENDOR),
695 dmi_get_system_info(DMI_PRODUCT_VERSION)); 766 dmi_get_system_info(DMI_BIOS_VERSION),
767 dmi_get_system_info(DMI_PRODUCT_VERSION));
768 bios_warned = 1;
769 }
696 goto err_unmap; 770 goto err_unmap;
697 } 771 }
698 772
@@ -715,6 +789,8 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
715 iommu->agaw = agaw; 789 iommu->agaw = agaw;
716 iommu->msagaw = msagaw; 790 iommu->msagaw = msagaw;
717 791
792 iommu->node = -1;
793
718 /* the registers might be more than one page */ 794 /* the registers might be more than one page */
719 map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), 795 map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap),
720 cap_max_fault_reg_offset(iommu->cap)); 796 cap_max_fault_reg_offset(iommu->cap));
@@ -1056,6 +1132,7 @@ static void __dmar_enable_qi(struct intel_iommu *iommu)
1056int dmar_enable_qi(struct intel_iommu *iommu) 1132int dmar_enable_qi(struct intel_iommu *iommu)
1057{ 1133{
1058 struct q_inval *qi; 1134 struct q_inval *qi;
1135 struct page *desc_page;
1059 1136
1060 if (!ecap_qis(iommu->ecap)) 1137 if (!ecap_qis(iommu->ecap))
1061 return -ENOENT; 1138 return -ENOENT;
@@ -1072,13 +1149,16 @@ int dmar_enable_qi(struct intel_iommu *iommu)
1072 1149
1073 qi = iommu->qi; 1150 qi = iommu->qi;
1074 1151
1075 qi->desc = (void *)(get_zeroed_page(GFP_ATOMIC)); 1152
1076 if (!qi->desc) { 1153 desc_page = alloc_pages_node(iommu->node, GFP_ATOMIC | __GFP_ZERO, 0);
1154 if (!desc_page) {
1077 kfree(qi); 1155 kfree(qi);
1078 iommu->qi = 0; 1156 iommu->qi = 0;
1079 return -ENOMEM; 1157 return -ENOMEM;
1080 } 1158 }
1081 1159
1160 qi->desc = page_address(desc_page);
1161
1082 qi->desc_status = kmalloc(QI_LENGTH * sizeof(int), GFP_ATOMIC); 1162 qi->desc_status = kmalloc(QI_LENGTH * sizeof(int), GFP_ATOMIC);
1083 if (!qi->desc_status) { 1163 if (!qi->desc_status) {
1084 free_page((unsigned long) qi->desc); 1164 free_page((unsigned long) qi->desc);
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 8d6159426311..e56f9bed6f2b 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -277,6 +277,7 @@ static int hw_pass_through = 1;
277 277
278struct dmar_domain { 278struct dmar_domain {
279 int id; /* domain id */ 279 int id; /* domain id */
280 int nid; /* node id */
280 unsigned long iommu_bmp; /* bitmap of iommus this domain uses*/ 281 unsigned long iommu_bmp; /* bitmap of iommus this domain uses*/
281 282
282 struct list_head devices; /* all devices' list */ 283 struct list_head devices; /* all devices' list */
@@ -386,30 +387,14 @@ static struct kmem_cache *iommu_domain_cache;
386static struct kmem_cache *iommu_devinfo_cache; 387static struct kmem_cache *iommu_devinfo_cache;
387static struct kmem_cache *iommu_iova_cache; 388static struct kmem_cache *iommu_iova_cache;
388 389
389static inline void *iommu_kmem_cache_alloc(struct kmem_cache *cachep) 390static inline void *alloc_pgtable_page(int node)
390{ 391{
391 unsigned int flags; 392 struct page *page;
392 void *vaddr; 393 void *vaddr = NULL;
393
394 /* trying to avoid low memory issues */
395 flags = current->flags & PF_MEMALLOC;
396 current->flags |= PF_MEMALLOC;
397 vaddr = kmem_cache_alloc(cachep, GFP_ATOMIC);
398 current->flags &= (~PF_MEMALLOC | flags);
399 return vaddr;
400}
401
402 394
403static inline void *alloc_pgtable_page(void) 395 page = alloc_pages_node(node, GFP_ATOMIC | __GFP_ZERO, 0);
404{ 396 if (page)
405 unsigned int flags; 397 vaddr = page_address(page);
406 void *vaddr;
407
408 /* trying to avoid low memory issues */
409 flags = current->flags & PF_MEMALLOC;
410 current->flags |= PF_MEMALLOC;
411 vaddr = (void *)get_zeroed_page(GFP_ATOMIC);
412 current->flags &= (~PF_MEMALLOC | flags);
413 return vaddr; 398 return vaddr;
414} 399}
415 400
@@ -420,7 +405,7 @@ static inline void free_pgtable_page(void *vaddr)
420 405
421static inline void *alloc_domain_mem(void) 406static inline void *alloc_domain_mem(void)
422{ 407{
423 return iommu_kmem_cache_alloc(iommu_domain_cache); 408 return kmem_cache_alloc(iommu_domain_cache, GFP_ATOMIC);
424} 409}
425 410
426static void free_domain_mem(void *vaddr) 411static void free_domain_mem(void *vaddr)
@@ -430,7 +415,7 @@ static void free_domain_mem(void *vaddr)
430 415
431static inline void * alloc_devinfo_mem(void) 416static inline void * alloc_devinfo_mem(void)
432{ 417{
433 return iommu_kmem_cache_alloc(iommu_devinfo_cache); 418 return kmem_cache_alloc(iommu_devinfo_cache, GFP_ATOMIC);
434} 419}
435 420
436static inline void free_devinfo_mem(void *vaddr) 421static inline void free_devinfo_mem(void *vaddr)
@@ -440,7 +425,7 @@ static inline void free_devinfo_mem(void *vaddr)
440 425
441struct iova *alloc_iova_mem(void) 426struct iova *alloc_iova_mem(void)
442{ 427{
443 return iommu_kmem_cache_alloc(iommu_iova_cache); 428 return kmem_cache_alloc(iommu_iova_cache, GFP_ATOMIC);
444} 429}
445 430
446void free_iova_mem(struct iova *iova) 431void free_iova_mem(struct iova *iova)
@@ -589,7 +574,8 @@ static struct context_entry * device_to_context_entry(struct intel_iommu *iommu,
589 root = &iommu->root_entry[bus]; 574 root = &iommu->root_entry[bus];
590 context = get_context_addr_from_root(root); 575 context = get_context_addr_from_root(root);
591 if (!context) { 576 if (!context) {
592 context = (struct context_entry *)alloc_pgtable_page(); 577 context = (struct context_entry *)
578 alloc_pgtable_page(iommu->node);
593 if (!context) { 579 if (!context) {
594 spin_unlock_irqrestore(&iommu->lock, flags); 580 spin_unlock_irqrestore(&iommu->lock, flags);
595 return NULL; 581 return NULL;
@@ -732,7 +718,7 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
732 if (!dma_pte_present(pte)) { 718 if (!dma_pte_present(pte)) {
733 uint64_t pteval; 719 uint64_t pteval;
734 720
735 tmp_page = alloc_pgtable_page(); 721 tmp_page = alloc_pgtable_page(domain->nid);
736 722
737 if (!tmp_page) 723 if (!tmp_page)
738 return NULL; 724 return NULL;
@@ -868,7 +854,7 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu)
868 struct root_entry *root; 854 struct root_entry *root;
869 unsigned long flags; 855 unsigned long flags;
870 856
871 root = (struct root_entry *)alloc_pgtable_page(); 857 root = (struct root_entry *)alloc_pgtable_page(iommu->node);
872 if (!root) 858 if (!root)
873 return -ENOMEM; 859 return -ENOMEM;
874 860
@@ -1263,6 +1249,7 @@ static struct dmar_domain *alloc_domain(void)
1263 if (!domain) 1249 if (!domain)
1264 return NULL; 1250 return NULL;
1265 1251
1252 domain->nid = -1;
1266 memset(&domain->iommu_bmp, 0, sizeof(unsigned long)); 1253 memset(&domain->iommu_bmp, 0, sizeof(unsigned long));
1267 domain->flags = 0; 1254 domain->flags = 0;
1268 1255
@@ -1420,9 +1407,10 @@ static int domain_init(struct dmar_domain *domain, int guest_width)
1420 domain->iommu_snooping = 0; 1407 domain->iommu_snooping = 0;
1421 1408
1422 domain->iommu_count = 1; 1409 domain->iommu_count = 1;
1410 domain->nid = iommu->node;
1423 1411
1424 /* always allocate the top pgd */ 1412 /* always allocate the top pgd */
1425 domain->pgd = (struct dma_pte *)alloc_pgtable_page(); 1413 domain->pgd = (struct dma_pte *)alloc_pgtable_page(domain->nid);
1426 if (!domain->pgd) 1414 if (!domain->pgd)
1427 return -ENOMEM; 1415 return -ENOMEM;
1428 __iommu_flush_cache(iommu, domain->pgd, PAGE_SIZE); 1416 __iommu_flush_cache(iommu, domain->pgd, PAGE_SIZE);
@@ -1523,12 +1511,15 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
1523 1511
1524 /* Skip top levels of page tables for 1512 /* Skip top levels of page tables for
1525 * iommu which has less agaw than default. 1513 * iommu which has less agaw than default.
1514 * Unnecessary for PT mode.
1526 */ 1515 */
1527 for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) { 1516 if (translation != CONTEXT_TT_PASS_THROUGH) {
1528 pgd = phys_to_virt(dma_pte_addr(pgd)); 1517 for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) {
1529 if (!dma_pte_present(pgd)) { 1518 pgd = phys_to_virt(dma_pte_addr(pgd));
1530 spin_unlock_irqrestore(&iommu->lock, flags); 1519 if (!dma_pte_present(pgd)) {
1531 return -ENOMEM; 1520 spin_unlock_irqrestore(&iommu->lock, flags);
1521 return -ENOMEM;
1522 }
1532 } 1523 }
1533 } 1524 }
1534 } 1525 }
@@ -1577,6 +1568,8 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
1577 spin_lock_irqsave(&domain->iommu_lock, flags); 1568 spin_lock_irqsave(&domain->iommu_lock, flags);
1578 if (!test_and_set_bit(iommu->seq_id, &domain->iommu_bmp)) { 1569 if (!test_and_set_bit(iommu->seq_id, &domain->iommu_bmp)) {
1579 domain->iommu_count++; 1570 domain->iommu_count++;
1571 if (domain->iommu_count == 1)
1572 domain->nid = iommu->node;
1580 domain_update_iommu_cap(domain); 1573 domain_update_iommu_cap(domain);
1581 } 1574 }
1582 spin_unlock_irqrestore(&domain->iommu_lock, flags); 1575 spin_unlock_irqrestore(&domain->iommu_lock, flags);
@@ -1991,6 +1984,16 @@ static int iommu_prepare_identity_map(struct pci_dev *pdev,
1991 "IOMMU: Setting identity map for device %s [0x%Lx - 0x%Lx]\n", 1984 "IOMMU: Setting identity map for device %s [0x%Lx - 0x%Lx]\n",
1992 pci_name(pdev), start, end); 1985 pci_name(pdev), start, end);
1993 1986
1987 if (end < start) {
1988 WARN(1, "Your BIOS is broken; RMRR ends before it starts!\n"
1989 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
1990 dmi_get_system_info(DMI_BIOS_VENDOR),
1991 dmi_get_system_info(DMI_BIOS_VERSION),
1992 dmi_get_system_info(DMI_PRODUCT_VERSION));
1993 ret = -EIO;
1994 goto error;
1995 }
1996
1994 if (end >> agaw_to_width(domain->agaw)) { 1997 if (end >> agaw_to_width(domain->agaw)) {
1995 WARN(1, "Your BIOS is broken; RMRR exceeds permitted address width (%d bits)\n" 1998 WARN(1, "Your BIOS is broken; RMRR exceeds permitted address width (%d bits)\n"
1996 "BIOS vendor: %s; Ver: %s; Product Version: %s\n", 1999 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
@@ -3228,6 +3231,9 @@ static int device_notifier(struct notifier_block *nb,
3228 struct pci_dev *pdev = to_pci_dev(dev); 3231 struct pci_dev *pdev = to_pci_dev(dev);
3229 struct dmar_domain *domain; 3232 struct dmar_domain *domain;
3230 3233
3234 if (iommu_no_mapping(dev))
3235 return 0;
3236
3231 domain = find_domain(pdev); 3237 domain = find_domain(pdev);
3232 if (!domain) 3238 if (!domain)
3233 return 0; 3239 return 0;
@@ -3455,6 +3461,7 @@ static struct dmar_domain *iommu_alloc_vm_domain(void)
3455 return NULL; 3461 return NULL;
3456 3462
3457 domain->id = vm_domid++; 3463 domain->id = vm_domid++;
3464 domain->nid = -1;
3458 memset(&domain->iommu_bmp, 0, sizeof(unsigned long)); 3465 memset(&domain->iommu_bmp, 0, sizeof(unsigned long));
3459 domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE; 3466 domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE;
3460 3467
@@ -3481,9 +3488,10 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width)
3481 domain->iommu_coherency = 0; 3488 domain->iommu_coherency = 0;
3482 domain->iommu_snooping = 0; 3489 domain->iommu_snooping = 0;
3483 domain->max_addr = 0; 3490 domain->max_addr = 0;
3491 domain->nid = -1;
3484 3492
3485 /* always allocate the top pgd */ 3493 /* always allocate the top pgd */
3486 domain->pgd = (struct dma_pte *)alloc_pgtable_page(); 3494 domain->pgd = (struct dma_pte *)alloc_pgtable_page(domain->nid);
3487 if (!domain->pgd) 3495 if (!domain->pgd)
3488 return -ENOMEM; 3496 return -ENOMEM;
3489 domain_flush_cache(domain, domain->pgd, PAGE_SIZE); 3497 domain_flush_cache(domain, domain->pgd, PAGE_SIZE);
diff --git a/drivers/pci/intr_remapping.c b/drivers/pci/intr_remapping.c
index 1487bf2be863..8b65a489581b 100644
--- a/drivers/pci/intr_remapping.c
+++ b/drivers/pci/intr_remapping.c
@@ -590,7 +590,8 @@ static int setup_intr_remapping(struct intel_iommu *iommu, int mode)
590 if (!iommu->ir_table) 590 if (!iommu->ir_table)
591 return -ENOMEM; 591 return -ENOMEM;
592 592
593 pages = alloc_pages(GFP_ATOMIC | __GFP_ZERO, INTR_REMAP_PAGE_ORDER); 593 pages = alloc_pages_node(iommu->node, GFP_ATOMIC | __GFP_ZERO,
594 INTR_REMAP_PAGE_ORDER);
594 595
595 if (!pages) { 596 if (!pages) {
596 printk(KERN_ERR "failed to allocate pages of order %d\n", 597 printk(KERN_ERR "failed to allocate pages of order %d\n",
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 4f0a72a9740c..9310c699a37d 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -332,6 +332,7 @@ struct intel_iommu {
332#ifdef CONFIG_INTR_REMAP 332#ifdef CONFIG_INTR_REMAP
333 struct ir_table *ir_table; /* Interrupt remapping info */ 333 struct ir_table *ir_table; /* Interrupt remapping info */
334#endif 334#endif
335 int node;
335}; 336};
336 337
337static inline void __iommu_flush_cache( 338static inline void __iommu_flush_cache(