ia64/xen-unstable
changeset 18803:2604400f75e3
vtd: fix memory allocation from NUMA node for VT-d.
Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Tue Nov 18 10:52:42 2008 +0000 (2008-11-18) |
parents | 7dd722064128 |
children | ae891977a4d3 |
files | xen/drivers/passthrough/vtd/ia64/vtd.c xen/drivers/passthrough/vtd/intremap.c xen/drivers/passthrough/vtd/iommu.c xen/drivers/passthrough/vtd/qinval.c xen/drivers/passthrough/vtd/vtd.h xen/drivers/passthrough/vtd/x86/vtd.c |
line diff
1.1 --- a/xen/drivers/passthrough/vtd/ia64/vtd.c Mon Nov 17 15:55:56 2008 +0000 1.2 +++ b/xen/drivers/passthrough/vtd/ia64/vtd.c Tue Nov 18 10:52:42 2008 +0000 1.3 @@ -21,6 +21,7 @@ 1.4 #include <xen/sched.h> 1.5 #include <xen/domain_page.h> 1.6 #include <xen/iommu.h> 1.7 +#include <xen/numa.h> 1.8 #include <asm/xensystem.h> 1.9 #include <asm/sal.h> 1.10 #include "../iommu.h" 1.11 @@ -44,12 +45,12 @@ void unmap_vtd_domain_page(void *va) 1.12 } 1.13 1.14 /* Allocate page table, return its machine address */ 1.15 -u64 alloc_pgtable_maddr(void) 1.16 +u64 alloc_pgtable_maddr(struct domain *d) 1.17 { 1.18 struct page_info *pg; 1.19 u64 *vaddr; 1.20 1.21 - pg = alloc_domheap_page(NULL, 0); 1.22 + pg = alloc_domheap_page(NULL, d ? MEMF_node(domain_to_node(d)) : 0); 1.23 vaddr = map_domain_page(page_to_mfn(pg)); 1.24 if ( !vaddr ) 1.25 return 0;
2.1 --- a/xen/drivers/passthrough/vtd/intremap.c Mon Nov 17 15:55:56 2008 +0000 2.2 +++ b/xen/drivers/passthrough/vtd/intremap.c Tue Nov 18 10:52:42 2008 +0000 2.3 @@ -502,7 +502,7 @@ int intremap_setup(struct iommu *iommu) 2.4 ir_ctrl = iommu_ir_ctrl(iommu); 2.5 if ( ir_ctrl->iremap_maddr == 0 ) 2.6 { 2.7 - ir_ctrl->iremap_maddr = alloc_pgtable_maddr(); 2.8 + ir_ctrl->iremap_maddr = alloc_pgtable_maddr(NULL); 2.9 if ( ir_ctrl->iremap_maddr == 0 ) 2.10 { 2.11 dprintk(XENLOG_WARNING VTDPREFIX,
3.1 --- a/xen/drivers/passthrough/vtd/iommu.c Mon Nov 17 15:55:56 2008 +0000 3.2 +++ b/xen/drivers/passthrough/vtd/iommu.c Tue Nov 18 10:52:42 2008 +0000 3.3 @@ -148,7 +148,7 @@ static u64 bus_to_context_maddr(struct i 3.4 root = &root_entries[bus]; 3.5 if ( !root_present(*root) ) 3.6 { 3.7 - maddr = alloc_pgtable_maddr(); 3.8 + maddr = alloc_pgtable_maddr(NULL); 3.9 if ( maddr == 0 ) 3.10 { 3.11 unmap_vtd_domain_page(root_entries); 3.12 @@ -205,7 +205,7 @@ static u64 addr_to_dma_page_maddr(struct 3.13 addr &= (((u64)1) << addr_width) - 1; 3.14 spin_lock_irqsave(&hd->mapping_lock, flags); 3.15 if ( hd->pgd_maddr == 0 ) 3.16 - if ( !alloc || ((hd->pgd_maddr = alloc_pgtable_maddr()) == 0) ) 3.17 + if ( !alloc || ((hd->pgd_maddr = alloc_pgtable_maddr(domain)) == 0) ) 3.18 goto out; 3.19 3.20 parent = (struct dma_pte *)map_vtd_domain_page(hd->pgd_maddr); 3.21 @@ -218,7 +218,7 @@ static u64 addr_to_dma_page_maddr(struct 3.22 { 3.23 if ( !alloc ) 3.24 break; 3.25 - maddr = alloc_pgtable_maddr(); 3.26 + maddr = alloc_pgtable_maddr(domain); 3.27 if ( !maddr ) 3.28 break; 3.29 dma_set_pte_addr(*pte, maddr); 3.30 @@ -605,7 +605,7 @@ static int iommu_set_root_entry(struct i 3.31 spin_lock_irqsave(&iommu->register_lock, flags); 3.32 3.33 if ( iommu->root_maddr == 0 ) 3.34 - iommu->root_maddr = alloc_pgtable_maddr(); 3.35 + iommu->root_maddr = alloc_pgtable_maddr(NULL); 3.36 if ( iommu->root_maddr == 0 ) 3.37 { 3.38 spin_unlock_irqrestore(&iommu->register_lock, flags);
4.1 --- a/xen/drivers/passthrough/vtd/qinval.c Mon Nov 17 15:55:56 2008 +0000 4.2 +++ b/xen/drivers/passthrough/vtd/qinval.c Tue Nov 18 10:52:42 2008 +0000 4.3 @@ -426,7 +426,7 @@ int qinval_setup(struct iommu *iommu) 4.4 4.5 if ( qi_ctrl->qinval_maddr == 0 ) 4.6 { 4.7 - qi_ctrl->qinval_maddr = alloc_pgtable_maddr(); 4.8 + qi_ctrl->qinval_maddr = alloc_pgtable_maddr(NULL); 4.9 if ( qi_ctrl->qinval_maddr == 0 ) 4.10 { 4.11 dprintk(XENLOG_WARNING VTDPREFIX,
5.1 --- a/xen/drivers/passthrough/vtd/vtd.h Mon Nov 17 15:55:56 2008 +0000 5.2 +++ b/xen/drivers/passthrough/vtd/vtd.h Tue Nov 18 10:52:42 2008 +0000 5.3 @@ -101,7 +101,7 @@ unsigned int get_cache_line_size(void); 5.4 void cacheline_flush(char *); 5.5 void flush_all_cache(void); 5.6 void *map_to_nocache_virt(int nr_iommus, u64 maddr); 5.7 -u64 alloc_pgtable_maddr(void); 5.8 +u64 alloc_pgtable_maddr(struct domain *d); 5.9 void free_pgtable_maddr(u64 maddr); 5.10 void *map_vtd_domain_page(u64 maddr); 5.11 void unmap_vtd_domain_page(void *va);
6.1 --- a/xen/drivers/passthrough/vtd/x86/vtd.c Mon Nov 17 15:55:56 2008 +0000 6.2 +++ b/xen/drivers/passthrough/vtd/x86/vtd.c Tue Nov 18 10:52:42 2008 +0000 6.3 @@ -22,6 +22,7 @@ 6.4 #include <xen/domain_page.h> 6.5 #include <asm/paging.h> 6.6 #include <xen/iommu.h> 6.7 +#include <xen/numa.h> 6.8 #include "../iommu.h" 6.9 #include "../dmar.h" 6.10 #include "../vtd.h" 6.11 @@ -37,13 +38,13 @@ void unmap_vtd_domain_page(void *va) 6.12 } 6.13 6.14 /* Allocate page table, return its machine address */ 6.15 -u64 alloc_pgtable_maddr(void) 6.16 +u64 alloc_pgtable_maddr(struct domain *d) 6.17 { 6.18 struct page_info *pg; 6.19 u64 *vaddr; 6.20 unsigned long mfn; 6.21 6.22 - pg = alloc_domheap_page(NULL, 0); 6.23 + pg = alloc_domheap_page(NULL, d ? MEMF_node(domain_to_node(d)) : 0); 6.24 if ( !pg ) 6.25 return 0; 6.26 mfn = page_to_mfn(pg);