AMD IOMMU: clean up debug information
PATCH 1/1 AMD IOMMU: clean up debug information
Keir,
This patch cleans up debug messages in amd iommu files. By this patch, we'd also like to announce a new name, "AMD IOV", for amd iommu. Here, AMD IOV stands for AMD I/O Virtualization. The booting option to switch on amd iommu functionality is also turned into "enable_amd_iov". Thanks!
Wei
Signed-off-by Wei Wang <[email protected]>
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/arch/x86/setup.c +1 -1
@@ -1021,7 +1021,7 @@ void __init __start_xen(unsigned long mbiommu_setup (); -amd_iommu_detect (); +amd_iov_detect ();/* * We're going to setup domain0 using the module(s) that we stashed safely
xen/drivers/passthrough/amd/iommu_acpi.c +95 -119
469 lines not on this page · raw message
xen/drivers/passthrough/amd/iommu_detect.c +2 -3
@@ -117,7 +117,7 @@ static int __init get_iommu_msi_capabiliif ( !iommu->msi_cap )return -ENODEV ; -dprintk (XENLOG_INFO ,"AMD IOMMU: Found MSI capability block \n" ); +amd_iov_info ("Found MSI capability block \n" ); control =pci_conf_read16 (bus, dev, func, iommu->msi_cap +PCI_MSI_FLAGS ); iommu->maskbit = control &PCI_MSI_FLAGS_MASKBIT ;
@@ -138,8 +138,7 @@ int __init get_iommu_capabilities(u8 busif ( ((mmio_bar &0x1 ) ==0 ) || (iommu->mmio_base_phys ==0 ) ) { -dprintk (XENLOG_ERR , -"AMD IOMMU: Invalid MMIO_BAR = 0x%" PRIx64"\n" , mmio_bar); +amd_iov_error ("Invalid MMIO_BAR = 0x%" PRIx64"\n" , mmio_bar);return -ENODEV ; }
xen/drivers/passthrough/amd/iommu_init.c +8 -9
@@ -35,8 +35,7 @@ int __init map_iommu_mmio_region(structif ( nr_amd_iommus >MAX_AMD_IOMMUS ) { -gdprintk (XENLOG_ERR , -"IOMMU: nr_amd_iommus %d > MAX_IOMMUS\n" , nr_amd_iommus); +amd_iov_error ("nr_amd_iommus %d > MAX_IOMMUS\n" , nr_amd_iommus);return -ENOMEM ; }
@@ -395,7 +394,7 @@ static void parse_event_log_entry(u32 enif ( (code >IOMMU_EVENT_INVALID_DEV_REQUEST ) || (code <IOMMU_EVENT_ILLEGAL_DEV_TABLE_ENTRY ) ) { -dprintk (XENLOG_ERR ,"Invalid event log entry!\n" ); +amd_iov_error ("Invalid event log entry!\n" );return ; }
@@ -408,8 +407,8 @@ static void parse_event_log_entry(u32 enIOMMU_EVENT_DOMAIN_ID_MASK , IOMMU_EVENT_DOMAIN_ID_SHIFT); addr= (u64 *) (entry +2 ); -dprintk (XENLOG_ERR , -"%s: domain = %d, device id = 0x%x, fault address = 0x%" PRIx64"\n" , +printk (XENLOG_ERR "AMD_IOV: " +"%s: domain:%d, device id:0x%x, fault address:0x%" PRIx64"\n" , event_str[code-1 ], domain_id, device_id, *addr); } }
@@ -445,7 +444,7 @@ static int set_iommu_interrupt_handler(sif ( !vector ) { -gdprintk (XENLOG_ERR ,"AMD IOMMU: no vectors\n" ); +amd_iov_error ("no vectors\n" );return 0 ; }
@@ -453,7 +452,7 @@ static int set_iommu_interrupt_handler(s ret =request_irq (vector, amd_iommu_page_fault,0 ,"dmar" , iommu);if ( ret ) { -gdprintk (XENLOG_ERR ,"AMD IOMMU: can't request irq\n" ); +amd_iov_error ("can't request irq\n" );return 0 ; }
@@ -483,5 +482,5 @@ void __init enable_iommu(struct amd_iommspin_unlock_irqrestore (&iommu->lock, flags); -printk ("AMD IOMMU %d: Enabled\n" , nr_amd_iommus); -} +printk ("AMD_IOV: IOMMU %d Enabled.\n" , nr_amd_iommus); +}
xen/drivers/passthrough/amd/iommu_map.c +8 -13
@@ -154,8 +154,7 @@ void flush_command_buffer(struct amd_iom }else { -dprintk (XENLOG_WARNING ,"AMD IOMMU: Warning:" -" ComWaitInt bit did not assert!\n" ); +amd_iov_warning ("Warning: ComWaitInt bit did not assert!\n" ); } } }
@@ -402,10 +401,9 @@ int amd_iommu_map_page(struct domain *d, pte =get_pte_from_page_tables (hd->root_table, hd->paging_mode, gfn);if ( pte ==NULL ) { -dprintk (XENLOG_ERR , -"AMD IOMMU: Invalid IO pagetable entry gfn = %lx\n" , gfn); +amd_iov_error ("Invalid IO pagetable entry gfn = %lx\n" , gfn);spin_unlock_irqrestore (&hd->mapping_lock, flags); -return -EIO ; +return -EFAULT ; }set_page_table_entry_present ((u32 *)pte, maddr, iw, ir);
@@ -439,10 +437,9 @@ int amd_iommu_unmap_page(struct domain * pte =get_pte_from_page_tables (hd->root_table, hd->paging_mode, gfn);if ( pte ==NULL ) { -dprintk (XENLOG_ERR , -"AMD IOMMU: Invalid IO pagetable entry gfn = %lx\n" , gfn); +amd_iov_error ("Invalid IO pagetable entry gfn = %lx\n" , gfn);spin_unlock_irqrestore (&hd->mapping_lock, flags); -return -EIO ; +return -EFAULT ; }/* mark PTE as 'page not present' */
@@ -479,9 +476,8 @@ int amd_iommu_reserve_domain_unity_map( hd->root_table, hd->paging_mode, phys_addr >> PAGE_SHIFT);if ( pte ==NULL ) { -dprintk (XENLOG_ERR , -"AMD IOMMU: Invalid IO pagetable entry " -"phys_addr = %lx\n" , phys_addr); +amd_iov_error ( +"Invalid IO pagetable entry phys_addr = %lx\n" , phys_addr);spin_unlock_irqrestore (&hd->mapping_lock, flags);return -EFAULT ; }
@@ -528,8 +524,7 @@ int amd_iommu_sync_p2m(struct domain *d) pte =get_pte_from_page_tables (hd->root_table, hd->paging_mode, gfn);if ( pte ==NULL ) { -dprintk (XENLOG_ERR , -"AMD IOMMU: Invalid IO pagetable entry gfn = %lx\n" , gfn); +amd_iov_error ("Invalid IO pagetable entry gfn = %lx\n" , gfn);spin_unlock_irqrestore (&hd->mapping_lock, flags);return -EFAULT ; }
xen/drivers/passthrough/amd/pci_amd_iommu.c +18 -20
@@ -39,7 +39,7 @@ int amd_iommu_enabled = 0;int amd_iommu_enabled =0 ;static int enable_amd_iommu =0 ; -boolean_param ("enable_amd_iommu" , enable_amd_iommu); +boolean_param ("enable_amd_iov" , enable_amd_iommu);static void deallocate_domain_page_tables (struct hvm_iommu *hd) {
@@ -104,7 +104,7 @@ static int __init allocate_iommu_table_sif ( !table->buffer ) { -dprintk (XENLOG_ERR ,"AMD IOMMU: Error allocating %s\n" , name); +amd_iov_error ("Error allocating %s\n" , name);return -ENOMEM ; }
@@ -169,7 +169,7 @@ int iommu_detect_callback(u8 bus, u8 dev iommu = (struct amd_iommu *) xmalloc(struct amd_iommu);if ( !iommu ) { -dprintk (XENLOG_ERR ,"AMD IOMMU: Error allocating amd_iommu\n" ); +amd_iov_error ("Error allocating amd_iommu\n" );return -ENOMEM ; }memset (iommu,0 ,sizeof (struct amd_iommu ));
@@ -237,7 +237,7 @@ static int __init amd_iommu_init(void) }if (acpi_table_parse (ACPI_IVRS , parse_ivrs_table) !=0 ) -dprintk (XENLOG_INFO ,"AMD IOMMU: Did not find IVRS table!\n" ); +amd_iov_error ("Did not find IVRS table!\n" );for_each_amd_iommu ( iommu ) {
@@ -308,7 +308,7 @@ void amd_iommu_setup_domain_device(invalidate_dev_table_entry (iommu, req_id);flush_command_buffer (iommu); -dprintk (XENLOG_INFO ,"AMD IOMMU: Set DTE req_id:%x, " +amd_iov_info ("Enable DTE:0x%x, " "root_ptr:%" PRIx64", domain_id:%d, paging_mode:%d\n" , req_id, root_ptr, hd->domain_id, hd->paging_mode);
@@ -354,15 +354,18 @@ void __init amd_iommu_setup_dom0_devices } } -int amd_iommu_detect (void ) +int amd_iov_detect (void ) {unsigned long i;int last_bus;struct amd_iommu *iommu; +if ( boot_cpu_data.x86_vendor !=X86_VENDOR_AMD ) +return 0 ; +if ( !enable_amd_iommu ) { -printk ("AMD IOMMU: Disabled\n" ); +printk ("AMD_IOV: Disabled.\n" );return 0 ; }
@@ -370,13 +373,13 @@ int amd_iommu_detect(void)if (scan_for_iommu (iommu_detect_callback) !=0 ) { -dprintk (XENLOG_ERR ,"AMD IOMMU: Error detection\n" ); +amd_iov_error ("Error detection\n" ); goto error_out; }if ( !iommu_found () ) { -printk ("AMD IOMMU: Not found!\n" ); +printk ("AMD_IOV: IOMMU not found!\n" );return 0 ; }else
@@ -394,8 +397,7 @@ int amd_iommu_detect(void)if ( !ivrs_mappings ) { -dprintk (XENLOG_ERR ,"AMD IOMMU:" -" Error allocating IVRS DevMappings table\n" ); +amd_iov_error ("Error allocating IVRS DevMappings table\n" ); goto error_out; } memset(ivrs_mappings, 0,
@@ -404,7 +406,7 @@ int amd_iommu_detect(void)if (amd_iommu_init () !=0 ) { -dprintk (XENLOG_ERR ,"AMD IOMMU: Error initialization\n" ); +amd_iov_error ("Error initialization\n" ); goto error_out; }
@@ -462,8 +464,6 @@ static int get_paging_mode(unsigned longreturn -ENOMEM ; } -dprintk (XENLOG_INFO ,"AMD IOMMU: paging mode = %d\n" , level); -return level; }
@@ -505,7 +505,7 @@ static void amd_iommu_disable_domain_devmemset (dte,0 ,IOMMU_DEV_TABLE_ENTRY_SIZE );invalidate_dev_table_entry (iommu, req_id);flush_command_buffer (iommu); -dprintk (XENLOG_INFO ,"AMD IOMMU: disable DTE 0x%x," +amd_iov_info ("Disable DTE:0x%x," " domain_id:%d, paging_mode:%d\n" , req_id,domain_hvm_iommu (domain)->domain_id,domain_hvm_iommu (domain)->paging_mode);
@@ -540,7 +540,7 @@ static int reassign_device( struct domaiif ( !iommu ) { -gdprintk (XENLOG_ERR ,"AMD IOMMU: fail to find iommu." +amd_iov_error ("Fail to find iommu." " %x:%x.%x cannot be assigned to domain %d\n" , bus,PCI_SLOT (devfn),PCI_FUNC (devfn), target->domain_id);return -ENODEV ;
@@ -555,8 +555,7 @@ static int reassign_device( struct domaispin_unlock_irqrestore (&source_hd->iommu_list_lock, flags);amd_iommu_setup_domain_device (target, iommu, bdf); -gdprintk (XENLOG_INFO , -"AMD IOMMU: reassign %x:%x.%x domain %d -> domain %d\n" , +amd_iov_info ("reassign %x:%x.%x domain %d -> domain %d\n" , bus,PCI_SLOT (devfn),PCI_FUNC (devfn), source->domain_id, target->domain_id);
@@ -595,8 +594,7 @@ static void release_domain_devices(struc { pdev =list_entry (hd->pdev_list.next,typeof (*pdev), list);pdev_flr (pdev->bus, pdev->devfn); -gdprintk (XENLOG_INFO , -"AMD IOMMU: release devices %x:%x.%x\n" , +amd_iov_info ("release domain %d devices %x:%x.%x\n" , d->domain_id, pdev->bus,PCI_SLOT (pdev->devfn),PCI_FUNC (pdev->devfn));reassign_device (d, dom0, pdev->bus, pdev->devfn); }
xen/include/asm-x86/amd-iommu.h +1 -1
@@ -31,7 +31,7 @@ extern int amd_iommu_enabled;extern int amd_iommu_enabled;extern struct list_head amd_iommu_head; -extern int __init amd_iommu_detect (void ); +extern int __init amd_iov_detect (void );struct table_struct {void *buffer;
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +13 -0
@@ -34,6 +34,19 @@#define DMA_32BIT_MASK 0x00000000ffffffffULL#define PAGE_ALIGN (addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) + +#ifdef AMD_IOV_DEBUG +#define amd_iov_info(fmt, args...) \ + printk(XENLOG_INFO "AMD_IOV: " fmt, ## args) +#define amd_iov_warning(fmt, args...) \ + printk(XENLOG_WARNING "AMD_IOV: " fmt, ## args) +#define amd_iov_error(fmt, args...) \ + printk(XENLOG_ERR "AMD_IOV: %s:%d: " fmt, __FILE__ , __LINE__ , ## args) +#else +#define amd_iov_info(fmt, args...) +#define amd_iov_warning(fmt, args...) +#define amd_iov_error(fmt, args...) +#endif typedef int (*iommu_detect_callback_ptr_t )(u8 bus,u8 dev,u8 func,u8 cap_ptr);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel