From: "Jan Beulich" Subject: [PATCH 5/5] AMD IOMMU: widen NUMA nodes to be allocated from Date: Thu, 26 Feb 2015 13:56:28 +0000 Message-ID: <54EF341C020000780006416C@mail.emea.novell.com> References: <54EF315902000078000640FF@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE9DC5F1C.2__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQyvW-0005ye-8i for xen-devel@lists.xenproject.org; Thu, 26 Feb 2015 13:56:30 +0000 In-Reply-To: <54EF315902000078000640FF@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Dario Faggioli , Aravind Gopalakrishnan , suravee.suthikulpanit@amd.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartE9DC5F1C.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/amd/iommu_map.c +++ b/xen/drivers/passthrough/amd/iommu_map.c @@ -488,7 +488,7 @@ static int iommu_pde_from_gfn(struct dom mfn =3D next_table_mfn; =20 /* allocate lower level page table */ - table =3D alloc_amd_iommu_pgtable(); + table =3D alloc_amd_iommu_pgtable(d); if ( table =3D=3D NULL ) { AMD_IOMMU_DEBUG("Cannot allocate I/O page table\n"); @@ -516,7 +516,7 @@ static int iommu_pde_from_gfn(struct dom { if ( next_table_mfn =3D=3D 0 ) { - table =3D alloc_amd_iommu_pgtable(); + table =3D alloc_amd_iommu_pgtable(d); if ( table =3D=3D NULL ) { AMD_IOMMU_DEBUG("Cannot allocate I/O page table\n"); @@ -567,7 +567,7 @@ static int update_paging_mode(struct dom { /* Allocate and install a new root table. * Only upper I/O page table grows, no need to fix next level = bits */ - new_root =3D alloc_amd_iommu_pgtable(); + new_root =3D alloc_amd_iommu_pgtable(d); if ( new_root =3D=3D NULL ) { AMD_IOMMU_DEBUG("%s Cannot allocate I/O page table\n", --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -225,13 +225,15 @@ int __init amd_iov_detect(void) return scan_pci_devices(); } =20 -static int allocate_domain_resources(struct hvm_iommu *hd) +static int allocate_domain_resources(struct domain *d) { + struct hvm_iommu *hd =3D domain_hvm_iommu(d); + /* allocate root table */ spin_lock(&hd->arch.mapping_lock); if ( !hd->arch.root_table ) { - hd->arch.root_table =3D alloc_amd_iommu_pgtable(); + hd->arch.root_table =3D alloc_amd_iommu_pgtable(d); if ( !hd->arch.root_table ) { spin_unlock(&hd->arch.mapping_lock); @@ -263,7 +265,7 @@ static int amd_iommu_domain_init(struct=20 struct hvm_iommu *hd =3D domain_hvm_iommu(d); =20 /* allocate page directroy */ - if ( allocate_domain_resources(hd) !=3D 0 ) + if ( allocate_domain_resources(d) !=3D 0 ) { if ( hd->arch.root_table ) free_domheap_page(hd->arch.root_table); @@ -383,7 +385,7 @@ static int reassign_device(struct domain /* IO page tables might be destroyed after pci-detach the last device * In this case, we have to re-allocate root table for next pci-attach= .*/ if ( t->arch.root_table =3D=3D NULL ) - allocate_domain_resources(t); + allocate_domain_resources(target); =20 amd_iommu_setup_domain_device(target, iommu, devfn, pdev); AMD_IOMMU_DEBUG("Re-assign %04x:%02x:%02x.%u from dom%d to dom%d\n", --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h @@ -158,12 +158,12 @@ static inline unsigned long region_to_pa return (PAGE_ALIGN(addr + size) - (addr & PAGE_MASK)) >> PAGE_SHIFT; } =20 -static inline struct page_info* alloc_amd_iommu_pgtable(void) +static inline struct page_info *alloc_amd_iommu_pgtable(struct domain *d) { struct page_info *pg; void *vaddr; =20 - pg =3D alloc_domheap_page(NULL, 0); + pg =3D alloc_domheap_page(d, MEMF_no_owner); if ( pg =3D=3D NULL ) return 0; vaddr =3D __map_domain_page(pg); --=__PartE9DC5F1C.2__= Content-Type: text/plain; name="AMD-IOMMU-alloc-for-domain.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="AMD-IOMMU-alloc-for-domain.patch" AMD IOMMU: widen NUMA nodes to be allocated from=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/drivers/passthrough/amd/iommu_ma= p.c=0A+++ b/xen/drivers/passthrough/amd/iommu_map.c=0A@@ -488,7 +488,7 @@ = static int iommu_pde_from_gfn(struct dom=0A mfn =3D next_table_= mfn;=0A =0A /* allocate lower level page table */=0A- = table =3D alloc_amd_iommu_pgtable();=0A+ table =3D alloc_amd_i= ommu_pgtable(d);=0A if ( table =3D=3D NULL )=0A = {=0A AMD_IOMMU_DEBUG("Cannot allocate I/O page table\n");= =0A@@ -516,7 +516,7 @@ static int iommu_pde_from_gfn(struct dom=0A = {=0A if ( next_table_mfn =3D=3D 0 )=0A {=0A- = table =3D alloc_amd_iommu_pgtable();=0A+ table =3D = alloc_amd_iommu_pgtable(d);=0A if ( table =3D=3D NULL )=0A = {=0A AMD_IOMMU_DEBUG("Cannot allocate = I/O page table\n");=0A@@ -567,7 +567,7 @@ static int update_paging_mode(str= uct dom=0A {=0A /* Allocate and install a new root table.=0A = * Only upper I/O page table grows, no need to fix next level bits = */=0A- new_root =3D alloc_amd_iommu_pgtable();=0A+ new_root = =3D alloc_amd_iommu_pgtable(d);=0A if ( new_root =3D=3D NULL )=0A = {=0A AMD_IOMMU_DEBUG("%s Cannot allocate I/O page = table\n",=0A--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c=0A+++ = b/xen/drivers/passthrough/amd/pci_amd_iommu.c=0A@@ -225,13 +225,15 @@ int = __init amd_iov_detect(void)=0A return scan_pci_devices();=0A }=0A = =0A-static int allocate_domain_resources(struct hvm_iommu *hd)=0A+static = int allocate_domain_resources(struct domain *d)=0A {=0A+ struct = hvm_iommu *hd =3D domain_hvm_iommu(d);=0A+=0A /* allocate root table = */=0A spin_lock(&hd->arch.mapping_lock);=0A if ( !hd->arch.root_tab= le )=0A {=0A- hd->arch.root_table =3D alloc_amd_iommu_pgtable();= =0A+ hd->arch.root_table =3D alloc_amd_iommu_pgtable(d);=0A = if ( !hd->arch.root_table )=0A {=0A spin_unlock(&hd->ar= ch.mapping_lock);=0A@@ -263,7 +265,7 @@ static int amd_iommu_domain_init(st= ruct =0A struct hvm_iommu *hd =3D domain_hvm_iommu(d);=0A =0A /* = allocate page directroy */=0A- if ( allocate_domain_resources(hd) !=3D = 0 )=0A+ if ( allocate_domain_resources(d) !=3D 0 )=0A {=0A = if ( hd->arch.root_table )=0A free_domheap_page(hd->arch.root_t= able);=0A@@ -383,7 +385,7 @@ static int reassign_device(struct domain=0A = /* IO page tables might be destroyed after pci-detach the last device=0A = * In this case, we have to re-allocate root table for next pci-attach.= */=0A if ( t->arch.root_table =3D=3D NULL )=0A- allocate_domain_= resources(t);=0A+ allocate_domain_resources(target);=0A =0A = amd_iommu_setup_domain_device(target, iommu, devfn, pdev);=0A = AMD_IOMMU_DEBUG("Re-assign %04x:%02x:%02x.%u from dom%d to dom%d\n",=0A--- = a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h=0A+++ b/xen/include/asm-x86= /hvm/svm/amd-iommu-proto.h=0A@@ -158,12 +158,12 @@ static inline unsigned = long region_to_pa=0A return (PAGE_ALIGN(addr + size) - (addr & = PAGE_MASK)) >> PAGE_SHIFT;=0A }=0A =0A-static inline struct page_info* = alloc_amd_iommu_pgtable(void)=0A+static inline struct page_info *alloc_amd_= iommu_pgtable(struct domain *d)=0A {=0A struct page_info *pg;=0A = void *vaddr;=0A =0A- pg =3D alloc_domheap_page(NULL, 0);=0A+ pg =3D = alloc_domheap_page(d, MEMF_no_owner);=0A if ( pg =3D=3D NULL )=0A = return 0;=0A vaddr =3D __map_domain_page(pg);=0A --=__PartE9DC5F1C.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartE9DC5F1C.2__=--