AMD IOMMU: Fix up coding style issue in amd iommu files
PATCH 1/1 AMD IOMMU: Fix up coding style issue in amd iommu files
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
Signature · 12 lines
AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Geschäftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplementär: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Geschäftsführer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
xen/drivers/passthrough/amd/iommu_acpi.c +15 -14
@@ -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_seleu16 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_rangint 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(strucunsigned 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(strucstruct 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 londprintk (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 {
xen/drivers/passthrough/amd/iommu_detect.c +25 -14
@@ -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); }
xen/drivers/passthrough/amd/iommu_init.c +4 -2
@@ -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(structvoid __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 ; }
xen/drivers/passthrough/amd/iommu_map.c +5 -4
@@ -132,7 +132,8 @@ void flush_command_buffer(struct amd_iomsend_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);
xen/drivers/passthrough/amd/pci_amd_iommu.c +3 -3
@@ -168,7 +168,7 @@ int iommu_detect_callback(u8 bus, u8 devlist_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 domaiint 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,
xen/drivers/passthrough/iommu.c +5 -5
@@ -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 domainstruct 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);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
I made a number of extra cleanups when I checked the patch in (changeset 17256). You can refer to that to see what kind of stuff you missed. It was all pretty minor.
-- Keir
Quoted 9 lines · On 19/3/08 14:00, "Wei Wang2" <[email protected]> wrote:
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 <[email protected]>
Appreciate your help :)
- Wei
Quoted 26 lines · Keir Fraser
I made a number of extra cleanups when I checked the patch in (changeset
17256). You can refer to that to see what kind of stuff you missed. It was
all pretty minor.-- Keir
Quoted 2 lines · On 19/3/08 14:00, "Wei Wang2" <[email protected]> wrote:
Hi Mark,
Attached patch fix up remaining coding style issue in AMD IOMMUfiles.
Quoted 1 line
Please check if it has met the requirement and let me know if
anything
Quoted 6 lines
is still missing.
Thanks a lot!-Wei
Signed-off-by Wei Wang <[email protected]>