From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang2 Subject: [PATCH] AMD IOMMU: Fix up coding style issue in amd iommu files Date: Wed, 19 Mar 2008 15:00:07 +0100 Message-ID: <1205935207.27747.16.camel@gran.amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-S8KEFxP9fsOLsjGJEAQ8" 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: mark.williamson@cl.cam.ac.uk Cc: xen-devel@lists.xensource.com, keir.fraser@eu.citrix.com List-Id: xen-devel@lists.xenproject.org --=-S8KEFxP9fsOLsjGJEAQ8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Mark, Attached patch fix up remaining coding style issue in AMD IOMMU files. Please check if it has met the requirement and let me know if anything is still missing. Thanks a lot! -Wei Signed-off-by: Wei Wang --=20 AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Gesch=C3=A4ftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplement=C3=A4r: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Gesch=C3=A4ftsf=C3=BChrer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy=20 --=-S8KEFxP9fsOLsjGJEAQ8 Content-Disposition: attachment; filename=cleanup.patch Content-Type: text/x-patch; name=cleanup.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit diff -r 1efc81ab19cd xen/drivers/passthrough/amd/iommu_acpi.c --- a/xen/drivers/passthrough/amd/iommu_acpi.c Tue Mar 18 11:15:20 2008 +0000 +++ b/xen/drivers/passthrough/amd/iommu_acpi.c Wed Mar 19 14:42:03 2008 +0100 @@ -105,7 +105,7 @@ static int __init register_exclusion_ran iommu_top = max_page * PAGE_SIZE; if ( base < iommu_top ) { - if (range_top > iommu_top) + if ( range_top > iommu_top ) range_top = iommu_top; length = range_top - base; /* reserve r/w unity-mapped page entries for devices */ @@ -116,7 +116,7 @@ static int __init register_exclusion_ran base = iommu_top; } /* register IOMMU exclusion range settings */ - if (limit >= iommu_top) + if ( limit >= iommu_top ) { for_each_amd_iommu( iommu ) reserve_iommu_exclusion_range_all(iommu, base, limit); @@ -147,7 +147,7 @@ static int __init register_exclusion_ran iommu_top = max_page * PAGE_SIZE; if ( base < iommu_top ) { - if (range_top > iommu_top) + if ( range_top > iommu_top ) range_top = iommu_top; length = range_top - base; /* reserve unity-mapped page entries for device */ @@ -183,7 +183,7 @@ static int __init register_exclusion_ran iommu_top = max_page * PAGE_SIZE; if ( base < iommu_top ) { - if (range_top > iommu_top) + if ( range_top > iommu_top ) range_top = iommu_top; length = range_top - base; /* reserve r/w unity-mapped page entries for devices */ @@ -205,7 +205,7 @@ static int __init register_exclusion_ran } /* register IOMMU exclusion range settings */ - if (limit >= iommu_top) + if ( limit >= iommu_top ) reserve_iommu_exclusion_range_all(iommu, base, limit); return 0; } @@ -217,7 +217,7 @@ static int __init parse_ivmd_device_sele u16 bdf; bdf = ivmd_block->header.dev_id; - if (bdf >= ivrs_bdf_entries) + if ( bdf >= ivrs_bdf_entries ) { dprintk(XENLOG_ERR, "IVMD Error: Invalid Dev_Id 0x%x\n", bdf); return -ENODEV; @@ -234,7 +234,7 @@ static int __init parse_ivmd_device_rang int error; first_bdf = ivmd_block->header.dev_id; - if (first_bdf >= ivrs_bdf_entries) + if ( first_bdf >= ivrs_bdf_entries ) { dprintk(XENLOG_ERR, "IVMD Error: " "Invalid Range_First Dev_Id 0x%x\n", first_bdf); @@ -242,14 +242,14 @@ static int __init parse_ivmd_device_rang } last_bdf = ivmd_block->last_dev_id; - if (last_bdf >= ivrs_bdf_entries || last_bdf <= first_bdf) + if ( last_bdf >= ivrs_bdf_entries || last_bdf <= first_bdf ) { dprintk(XENLOG_ERR, "IVMD Error: " "Invalid Range_Last Dev_Id 0x%x\n", last_bdf); return -ENODEV; } - dprintk(XENLOG_ERR, " Dev_Id Range: 0x%x -> 0x%x\n", + dprintk(XENLOG_ERR, " Dev_Id Range: 0x%x -> 0x%x\n", first_bdf, last_bdf); for ( bdf = first_bdf, error = 0; @@ -288,8 +288,8 @@ static int __init parse_ivmd_block(struc unsigned long start_addr, mem_length, base, limit; u8 iw, ir; - if (ivmd_block->header.length < - sizeof(struct acpi_ivmd_block_header)) + if ( ivmd_block->header.length < + sizeof(struct acpi_ivmd_block_header) ) { dprintk(XENLOG_ERR, "IVMD Error: Invalid Block Length!\n"); return -ENODEV; @@ -399,7 +399,8 @@ static u16 __init parse_ivhd_device_rang } if ( ivhd_device->range.trailer.type != - AMD_IOMMU_ACPI_IVHD_DEV_RANGE_END) { + AMD_IOMMU_ACPI_IVHD_DEV_RANGE_END ) + { dprintk(XENLOG_ERR, "IVHD Error: " "Invalid Range: End_Type 0x%x\n", ivhd_device->range.trailer.type); @@ -759,7 +760,7 @@ static int __init parse_ivrs_block(struc struct acpi_ivhd_block_header *ivhd_block; struct acpi_ivmd_block_header *ivmd_block; - switch(ivrs_block->type) + switch( ivrs_block->type ) { case AMD_IOMMU_ACPI_IVHD_TYPE: ivhd_block = (struct acpi_ivhd_block_header *)ivrs_block; @@ -857,7 +858,7 @@ int __init parse_ivrs_table(unsigned lon dprintk(XENLOG_INFO, " Length 0x%x\n", ivrs_block->length); dprintk(XENLOG_INFO, " Dev_Id 0x%x\n", ivrs_block->dev_id); - if (table->length >= (length + ivrs_block->length)) + if ( table->length >= (length + ivrs_block->length) ) error = parse_ivrs_block(ivrs_block); else { diff -r 1efc81ab19cd xen/drivers/passthrough/amd/iommu_detect.c --- a/xen/drivers/passthrough/amd/iommu_detect.c Tue Mar 18 11:15:20 2008 +0000 +++ b/xen/drivers/passthrough/amd/iommu_detect.c Wed Mar 19 14:42:03 2008 +0100 @@ -49,9 +49,11 @@ int __init get_iommu_last_downstream_bus iommu->downstream_bus_present[bus] = 1; dev = PCI_SLOT(iommu->first_devfn); multi_func = PCI_FUNC(iommu->first_devfn) > 0; - for ( devfn = iommu->first_devfn; devfn <= iommu->last_devfn; ++devfn ) { + for ( devfn = iommu->first_devfn; devfn <= iommu->last_devfn; ++devfn ) + { /* skipping to next device#? */ - if ( dev != PCI_SLOT(devfn) ) { + if ( dev != PCI_SLOT(devfn) ) + { dev = PCI_SLOT(devfn); multi_func = 0; } @@ -67,9 +69,10 @@ int __init get_iommu_last_downstream_bus multi_func = IS_PCI_MULTI_FUNCTION(hdr_type); if ( (func == 0 || multi_func) && - IS_PCI_TYPE1_HEADER(hdr_type) ) { - if (!valid_bridge_bus_config(bus, dev, func, - &sec_bus, &sub_bus)) + IS_PCI_TYPE1_HEADER(hdr_type) ) + { + if ( !valid_bridge_bus_config(bus, dev, func, + &sec_bus, &sub_bus) ) return -ENODEV; if ( sub_bus > iommu->last_downstream_bus ) @@ -92,7 +95,7 @@ int __init get_iommu_capabilities(u8 bus mmio_bar = (u64)read_pci_config(bus, dev, func, cap_ptr + PCI_CAP_MMIO_BAR_HIGH_OFFSET) << 32; mmio_bar |= read_pci_config(bus, dev, func, - cap_ptr + PCI_CAP_MMIO_BAR_LOW_OFFSET); + cap_ptr + PCI_CAP_MMIO_BAR_LOW_OFFSET); iommu->mmio_base_phys = mmio_bar & (u64)~0x3FFF; if ( (mmio_bar & 0x1) == 0 || iommu->mmio_base_phys == 0 ) @@ -151,16 +154,19 @@ static int __init scan_caps_for_iommu(in cap_ptr = read_pci_config_byte(bus, dev, func, PCI_CAPABILITY_LIST); while ( cap_ptr >= PCI_MIN_CAP_OFFSET && - count < PCI_MAX_CAP_BLOCKS && !error ) { + count < PCI_MAX_CAP_BLOCKS && !error ) + { cap_ptr &= PCI_CAP_PTR_MASK; cap_header = read_pci_config(bus, dev, func, cap_ptr); cap_id = get_field_from_reg_u32(cap_header, PCI_CAP_ID_MASK, PCI_CAP_ID_SHIFT); - if ( cap_id == PCI_CAP_ID_SECURE_DEVICE ) { + if ( cap_id == PCI_CAP_ID_SECURE_DEVICE ) + { cap_type = get_field_from_reg_u32(cap_header, PCI_CAP_TYPE_MASK, PCI_CAP_TYPE_SHIFT); - if ( cap_type == PCI_CAP_TYPE_IOMMU ) { + if ( cap_type == PCI_CAP_TYPE_IOMMU ) + { error = iommu_detect_callback( bus, dev, func, cap_ptr); } @@ -168,7 +174,8 @@ static int __init scan_caps_for_iommu(in cap_ptr = get_field_from_reg_u32(cap_header, PCI_CAP_NEXT_PTR_MASK, PCI_CAP_NEXT_PTR_SHIFT); - ++count; } + ++count; + } return error; } @@ -182,7 +189,8 @@ static int __init scan_functions_for_iom func = 0; count = 1; while ( VALID_PCI_VENDOR_ID(read_pci_config_16(bus, dev, func, - PCI_VENDOR_ID)) && !error && func < count ) { + PCI_VENDOR_ID)) && !error && func < count ) + { hdr_type = read_pci_config_byte(bus, dev, func, PCI_HEADER_TYPE); @@ -190,7 +198,8 @@ static int __init scan_functions_for_iom count = PCI_MAX_FUNC_COUNT; if ( IS_PCI_TYPE0_HEADER(hdr_type) || - IS_PCI_TYPE1_HEADER(hdr_type) ) { + IS_PCI_TYPE1_HEADER(hdr_type) ) + { error = scan_caps_for_iommu(bus, dev, func, iommu_detect_callback); } @@ -205,8 +214,10 @@ int __init scan_for_iommu(iommu_detect_c { int bus, dev, error = 0; - for ( bus = 0; bus < PCI_MAX_BUS_COUNT && !error; ++bus ) { - for ( dev = 0; dev < PCI_MAX_DEV_COUNT && !error; ++dev ) { + for ( bus = 0; bus < PCI_MAX_BUS_COUNT && !error; ++bus ) + { + for ( dev = 0; dev < PCI_MAX_DEV_COUNT && !error; ++dev ) + { error = scan_functions_for_iommu(bus, dev, iommu_detect_callback); } diff -r 1efc81ab19cd xen/drivers/passthrough/amd/iommu_init.c --- a/xen/drivers/passthrough/amd/iommu_init.c Tue Mar 18 11:15:20 2008 +0000 +++ b/xen/drivers/passthrough/amd/iommu_init.c Wed Mar 19 14:42:03 2008 +0100 @@ -32,7 +32,8 @@ int __init map_iommu_mmio_region(struct { unsigned long mfn; - if ( nr_amd_iommus > MAX_AMD_IOMMUS ) { + if ( nr_amd_iommus > MAX_AMD_IOMMUS ) + { gdprintk(XENLOG_ERR, "IOMMU: nr_amd_iommus %d > MAX_IOMMUS\n", nr_amd_iommus); return -ENOMEM; @@ -51,7 +52,8 @@ int __init map_iommu_mmio_region(struct void __init unmap_iommu_mmio_region(struct amd_iommu *iommu) { - if ( iommu->mmio_base ) { + if ( iommu->mmio_base ) + { iounmap(iommu->mmio_base); iommu->mmio_base = NULL; } diff -r 1efc81ab19cd xen/drivers/passthrough/amd/iommu_map.c --- a/xen/drivers/passthrough/amd/iommu_map.c Tue Mar 18 11:15:20 2008 +0000 +++ b/xen/drivers/passthrough/amd/iommu_map.c Wed Mar 19 14:42:03 2008 +0100 @@ -132,7 +132,8 @@ void flush_command_buffer(struct amd_iom send_iommu_command(iommu, cmd); /* wait for 'ComWaitInt' to signal comp#endifletion? */ - if ( amd_iommu_poll_comp_wait ) { + if ( amd_iommu_poll_comp_wait ) + { loop_count = amd_iommu_poll_comp_wait; do { status = readl(iommu->mmio_base + @@ -397,7 +398,7 @@ int amd_iommu_map_page(struct domain *d, spin_lock_irqsave(&hd->mapping_lock, flags); pte = get_pte_from_page_tables(hd->root_table, hd->paging_mode, gfn); - if ( pte == 0 ) + if ( pte == NULL ) { dprintk(XENLOG_ERR, "AMD IOMMU: Invalid IO pagetable entry gfn = %lx\n", gfn); @@ -428,7 +429,7 @@ int amd_iommu_unmap_page(struct domain * spin_lock_irqsave(&hd->mapping_lock, flags); pte = get_pte_from_page_tables(hd->root_table, hd->paging_mode, gfn); - if ( pte == 0 ) + if ( pte == NULL ) { dprintk(XENLOG_ERR, "AMD IOMMU: Invalid IO pagetable entry gfn = %lx\n", gfn); @@ -468,7 +469,7 @@ int amd_iommu_reserve_domain_unity_map( { pte = get_pte_from_page_tables(hd->root_table, hd->paging_mode, phys_addr>>PAGE_SHIFT); - if ( pte == 0 ) + if ( pte == NULL ) { dprintk(XENLOG_ERR, "AMD IOMMU: Invalid IO pagetable entry phys_addr = %lx\n", phys_addr); diff -r 1efc81ab19cd xen/drivers/passthrough/amd/pci_amd_iommu.c --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Tue Mar 18 11:15:20 2008 +0000 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Mar 19 14:42:03 2008 +0100 @@ -168,7 +168,7 @@ int iommu_detect_callback(u8 bus, u8 dev list_add_tail(&iommu->list, &amd_iommu_head); /* allocate resources for this IOMMU */ - if (allocate_iommu_resources(iommu) != 0) + if ( allocate_iommu_resources(iommu) != 0 ) goto error_out; return 0; @@ -369,7 +369,7 @@ int amd_iommu_detect(void) /* note: the table has entries to accomodate all IOMMUs */ last_bus = 0; for_each_amd_iommu (iommu) - if (iommu->last_downstream_bus > last_bus) + if ( iommu->last_downstream_bus > last_bus ) last_bus = iommu->last_downstream_bus; ivrs_bdf_entries = (last_bus + 1) * @@ -557,7 +557,7 @@ int amd_iommu_assign_device(struct domai int req_id; req_id = ivrs_mappings[bdf].dte_requestor_id; - if (ivrs_mappings[req_id].unity_map_enable) + if ( ivrs_mappings[req_id].unity_map_enable ) { amd_iommu_reserve_domain_unity_map(d, ivrs_mappings[req_id].addr_range_start, diff -r 1efc81ab19cd xen/drivers/passthrough/iommu.c --- a/xen/drivers/passthrough/iommu.c Tue Mar 18 11:15:20 2008 +0000 +++ b/xen/drivers/passthrough/iommu.c Wed Mar 19 14:42:03 2008 +0100 @@ -50,7 +50,7 @@ int assign_device(struct domain *d, u8 b { struct hvm_iommu *hd = domain_hvm_iommu(d); - if ( !iommu_enabled || !hd->platform_ops) + if ( !iommu_enabled || !hd->platform_ops ) return 0; return hd->platform_ops->assign_device(d, bus, devfn); @@ -65,7 +65,7 @@ void iommu_domain_destroy(struct domain struct g2m_ioport *ioport; struct dev_intx_gsi_link *digl; - if ( !iommu_enabled || !hd->platform_ops) + if ( !iommu_enabled || !hd->platform_ops ) return; if ( hvm_irq_dpci != NULL ) @@ -109,7 +109,7 @@ int iommu_map_page(struct domain *d, uns { struct hvm_iommu *hd = domain_hvm_iommu(d); - if ( !iommu_enabled || !hd->platform_ops) + if ( !iommu_enabled || !hd->platform_ops ) return 0; return hd->platform_ops->map_page(d, gfn, mfn); @@ -119,7 +119,7 @@ int iommu_unmap_page(struct domain *d, u { struct hvm_iommu *hd = domain_hvm_iommu(d); - if ( !iommu_enabled || !hd->platform_ops) + if ( !iommu_enabled || !hd->platform_ops ) return 0; return hd->platform_ops->unmap_page(d, gfn); @@ -129,7 +129,7 @@ void deassign_device(struct domain *d, u { struct hvm_iommu *hd = domain_hvm_iommu(d); - if ( !iommu_enabled || !hd->platform_ops) + if ( !iommu_enabled || !hd->platform_ops ) return; return hd->platform_ops->reassign_device(d, dom0, bus, devfn); --=-S8KEFxP9fsOLsjGJEAQ8 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 --=-S8KEFxP9fsOLsjGJEAQ8--