From: "Jan Beulich" Subject: [PATCH] AMD-IOMMU: fix initialization order (after 23863:9e0259239822) Date: Fri, 23 Sep 2011 08:25:06 +0100 Message-ID: <4E7C507202000078000577D6@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part2C031342.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.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. --=__Part2C031342.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline That original patch caused alloc_ivrs_mappings() to be called too early, so things get moved back to where they were, just converting the single call there to a loop over all IOMMUs. Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/amd/iommu_detect.c +++ b/xen/drivers/passthrough/amd/iommu_detect.c @@ -121,10 +121,6 @@ int __init amd_iommu_detect_one_acpi(voi spin_lock_init(&iommu->lock); =20 iommu->seg =3D ivhd_block->pci_segment; - if (alloc_ivrs_mappings(ivhd_block->pci_segment)) { - xfree(iommu); - return -ENOMEM; - } iommu->bdf =3D ivhd_block->header.dev_id; iommu->cap_offset =3D ivhd_block->cap_offset; iommu->mmio_base_phys =3D ivhd_block->mmio_base; --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -769,7 +769,7 @@ int iterate_ivrs_entries(int (*handler)( return rc; } =20 -int __init alloc_ivrs_mappings(u16 seg) +static int __init alloc_ivrs_mappings(u16 seg) { struct ivrs_mappings *ivrs_mappings; int bdf; @@ -881,8 +881,9 @@ int __init amd_iommu_init(void) goto error_out; =20 radix_tree_init(&ivrs_maps); - if ( alloc_ivrs_mappings(0) !=3D 0 ) - goto error_out; + for_each_amd_iommu ( iommu ) + if ( alloc_ivrs_mappings(iommu->seg) !=3D 0 ) + goto error_out; =20 if ( amd_iommu_update_ivrs_mapping_acpi() !=3D 0 ) goto error_out; --- a/xen/include/asm-x86/amd-iommu.h +++ b/xen/include/asm-x86/amd-iommu.h @@ -103,7 +103,6 @@ struct ivrs_mappings { =20 extern unsigned short ivrs_bdf_entries; =20 -int alloc_ivrs_mappings(u16 seg); struct ivrs_mappings *get_ivrs_mappings(u16 seg); int iterate_ivrs_mappings(int (*)(u16 seg, struct ivrs_mappings *)); int iterate_ivrs_entries(int (*)(u16 seg, struct ivrs_mappings *)); --=__Part2C031342.0__= Content-Type: text/plain; name="pci-multi-seg-amd-iommu-fix.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pci-multi-seg-amd-iommu-fix.patch" That original patch caused alloc_ivrs_mappings() to be called too=0Aearly, = so things get moved back to where they were, just converting=0Athe single = call there to a loop over all IOMMUs.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/drivers/passthrough/amd/iommu_detect.c= =0A+++ b/xen/drivers/passthrough/amd/iommu_detect.c=0A@@ -121,10 +121,6 @@ = int __init amd_iommu_detect_one_acpi(voi=0A spin_lock_init(&iommu->lock= );=0A =0A iommu->seg =3D ivhd_block->pci_segment;=0A- if (alloc_ivrs= _mappings(ivhd_block->pci_segment)) {=0A- xfree(iommu);=0A- = return -ENOMEM;=0A- }=0A iommu->bdf =3D ivhd_block->header.dev_id;= =0A iommu->cap_offset =3D ivhd_block->cap_offset;=0A iommu->mmio_ba= se_phys =3D ivhd_block->mmio_base;=0A--- a/xen/drivers/passthrough/amd/iomm= u_init.c=0A+++ b/xen/drivers/passthrough/amd/iommu_init.c=0A@@ -769,7 = +769,7 @@ int iterate_ivrs_entries(int (*handler)(=0A return rc;=0A = }=0A =0A-int __init alloc_ivrs_mappings(u16 seg)=0A+static int __init = alloc_ivrs_mappings(u16 seg)=0A {=0A struct ivrs_mappings *ivrs_mapping= s;=0A int bdf;=0A@@ -881,8 +881,9 @@ int __init amd_iommu_init(void)=0A= goto error_out;=0A =0A radix_tree_init(&ivrs_maps);=0A- if = ( alloc_ivrs_mappings(0) !=3D 0 )=0A- goto error_out;=0A+ = for_each_amd_iommu ( iommu )=0A+ if ( alloc_ivrs_mappings(iommu->seg= ) !=3D 0 )=0A+ goto error_out;=0A =0A if ( amd_iommu_update_= ivrs_mapping_acpi() !=3D 0 )=0A goto error_out;=0A--- a/xen/include= /asm-x86/amd-iommu.h=0A+++ b/xen/include/asm-x86/amd-iommu.h=0A@@ -103,7 = +103,6 @@ struct ivrs_mappings {=0A =0A extern unsigned short ivrs_bdf_entr= ies;=0A =0A-int alloc_ivrs_mappings(u16 seg);=0A struct ivrs_mappings = *get_ivrs_mappings(u16 seg);=0A int iterate_ivrs_mappings(int (*)(u16 seg, = struct ivrs_mappings *));=0A int iterate_ivrs_entries(int (*)(u16 seg, = struct ivrs_mappings *));=0A --=__Part2C031342.0__= 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.xensource.com http://lists.xensource.com/xen-devel --=__Part2C031342.0__=--