[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] vtd: cleanups
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1227697725 0 # Node ID 1975e33b79f18207454bf0366f90712123f14975 # Parent 4ccee1299bc7feab06a95495e2086d04d1b6e960 vtd: cleanups - potential issues in vtd_page_fault() handler - wrong print messages - existing ATS code in dmar.c. Signed-off-by: Allen Kay <allen.m.kay@xxxxxxxxx> --- xen/drivers/passthrough/vtd/dmar.c | 26 ++++++++++++++++++++++---- xen/drivers/passthrough/vtd/dmar.h | 1 + xen/drivers/passthrough/vtd/iommu.c | 20 +++++++++++--------- xen/drivers/passthrough/vtd/iommu.h | 4 ++++ xen/drivers/passthrough/vtd/qinval.c | 23 ++++++++++++----------- 5 files changed, 50 insertions(+), 24 deletions(-) diff -r 4ccee1299bc7 -r 1975e33b79f1 xen/drivers/passthrough/vtd/dmar.c --- a/xen/drivers/passthrough/vtd/dmar.c Wed Nov 26 11:07:44 2008 +0000 +++ b/xen/drivers/passthrough/vtd/dmar.c Wed Nov 26 11:08:45 2008 +0000 @@ -172,6 +172,28 @@ struct acpi_drhd_unit * acpi_find_matche return found ? found : include_all; } +struct acpi_atsr_unit * acpi_find_matched_atsr_unit(u8 bus, u8 devfn) +{ + struct acpi_atsr_unit *atsr; + struct acpi_atsr_unit *found = NULL, *include_all = NULL; + int i; + + list_for_each_entry ( atsr, &acpi_atsr_units, list ) + { + for (i = 0; i < atsr->scope.devices_cnt; i++) + if ( atsr->scope.devices[i] == PCI_BDF2(bus, devfn) ) + return atsr; + + if ( test_bit(bus, atsr->scope.buses) ) + found = atsr; + + if ( atsr->all_ports ) + include_all = atsr; + } + + return found ? found : include_all; +} + /* * Count number of devices in device scope. Do not include PCI sub * hierarchies. @@ -242,7 +264,6 @@ static int __init acpi_parse_dev_scope(v switch ( acpi_scope->dev_type ) { case ACPI_DEV_P2PBRIDGE: - { sec_bus = pci_conf_read8( bus, path->dev, path->fn, PCI_SECONDARY_BUS); sub_bus = pci_conf_read8( @@ -253,7 +274,6 @@ static int __init acpi_parse_dev_scope(v dmar_scope_add_buses(scope, sec_bus, sub_bus); break; - } case ACPI_DEV_MSI_HPET: dprintk(XENLOG_INFO VTDPREFIX, "found MSI HPET: bdf = %x:%x.%x\n", @@ -268,7 +288,6 @@ static int __init acpi_parse_dev_scope(v break; case ACPI_DEV_IOAPIC: - { dprintk(XENLOG_INFO VTDPREFIX, "found IOAPIC: bdf = %x:%x.%x\n", bus, path->dev, path->fn); @@ -288,7 +307,6 @@ static int __init acpi_parse_dev_scope(v scope->devices[didx++] = PCI_BDF(bus, path->dev, path->fn); break; } - } start += acpi_scope->length; } diff -r 4ccee1299bc7 -r 1975e33b79f1 xen/drivers/passthrough/vtd/dmar.h --- a/xen/drivers/passthrough/vtd/dmar.h Wed Nov 26 11:07:44 2008 +0000 +++ b/xen/drivers/passthrough/vtd/dmar.h Wed Nov 26 11:08:45 2008 +0000 @@ -80,6 +80,7 @@ struct acpi_atsr_unit { idx < rmrr->scope.devices_cnt; idx++) struct acpi_drhd_unit * acpi_find_matched_drhd_unit(u8 bus, u8 devfn); +struct acpi_atsr_unit * acpi_find_matched_atsr_unit(u8 bus, u8 devfn); void dmar_scope_add_buses(struct dmar_scope *scope, u16 sec, u16 sub); void dmar_scope_remove_buses(struct dmar_scope *scope, u16 sec, u16 sub); diff -r 4ccee1299bc7 -r 1975e33b79f1 xen/drivers/passthrough/vtd/iommu.c --- a/xen/drivers/passthrough/vtd/iommu.c Wed Nov 26 11:07:44 2008 +0000 +++ b/xen/drivers/passthrough/vtd/iommu.c Wed Nov 26 11:08:45 2008 +0000 @@ -714,22 +714,22 @@ static void iommu_fault_status(u32 fault if ( fault_status & DMA_FSTS_PFO ) dprintk(XENLOG_ERR VTDPREFIX, "iommu_fault_status: Fault Overflow\n"); - else if ( fault_status & DMA_FSTS_PPF ) + if ( fault_status & DMA_FSTS_PPF ) dprintk(XENLOG_ERR VTDPREFIX, "iommu_fault_status: Primary Pending Fault\n"); - else if ( fault_status & DMA_FSTS_AFO ) + if ( fault_status & DMA_FSTS_AFO ) dprintk(XENLOG_ERR VTDPREFIX, "iommu_fault_status: Advanced Fault Overflow\n"); - else if ( fault_status & DMA_FSTS_APF ) + if ( fault_status & DMA_FSTS_APF ) dprintk(XENLOG_ERR VTDPREFIX, "iommu_fault_status: Advanced Pending Fault\n"); - else if ( fault_status & DMA_FSTS_IQE ) + if ( fault_status & DMA_FSTS_IQE ) dprintk(XENLOG_ERR VTDPREFIX, "iommu_fault_status: Invalidation Queue Error\n"); - else if ( fault_status & DMA_FSTS_ICE ) + if ( fault_status & DMA_FSTS_ICE ) dprintk(XENLOG_ERR VTDPREFIX, "iommu_fault_status: Invalidation Completion Error\n"); - else if ( fault_status & DMA_FSTS_ITE ) + if ( fault_status & DMA_FSTS_ITE ) dprintk(XENLOG_ERR VTDPREFIX, "iommu_fault_status: Invalidation Time-out Error\n"); } @@ -754,10 +754,11 @@ static void iommu_page_fault(int vector, /* FIXME: ignore advanced fault log */ if ( !(fault_status & DMA_FSTS_PPF) ) - return; + goto clear_overflow; + fault_index = dma_fsts_fault_record_index(fault_status); reg = cap_fault_reg_offset(iommu->cap); - for ( ; ; ) + while (1) { u8 fault_reason; u16 source_id; @@ -797,8 +798,9 @@ static void iommu_page_fault(int vector, if ( fault_index > cap_num_fault_regs(iommu->cap) ) fault_index = 0; } - +clear_overflow: /* clear primary fault overflow */ + fault_status = readl(iommu->reg + DMAR_FSTS_REG); if ( fault_status & DMA_FSTS_PFO ) { spin_lock_irqsave(&iommu->register_lock, flags); diff -r 4ccee1299bc7 -r 1975e33b79f1 xen/drivers/passthrough/vtd/iommu.h --- a/xen/drivers/passthrough/vtd/iommu.h Wed Nov 26 11:07:44 2008 +0000 +++ b/xen/drivers/passthrough/vtd/iommu.h Wed Nov 26 11:08:45 2008 +0000 @@ -310,6 +310,10 @@ struct qinval_entry { struct qinval_entry { union { struct { + u64 lo; + u64 hi; + }val; + struct { struct { u64 type : 4, granu : 2, diff -r 4ccee1299bc7 -r 1975e33b79f1 xen/drivers/passthrough/vtd/qinval.c --- a/xen/drivers/passthrough/vtd/qinval.c Wed Nov 26 11:07:44 2008 +0000 +++ b/xen/drivers/passthrough/vtd/qinval.c Wed Nov 26 11:08:45 2008 +0000 @@ -34,13 +34,13 @@ static void print_qi_regs(struct iommu * u64 val; val = dmar_readq(iommu->reg, DMAR_IQA_REG); - printk("DMAR_IAQ_REG = %"PRIx64"\n", val); + printk("DMAR_IQA_REG = %"PRIx64"\n", val); val = dmar_readq(iommu->reg, DMAR_IQH_REG); - printk("DMAR_IAH_REG = %"PRIx64"\n", val); + printk("DMAR_IQH_REG = %"PRIx64"\n", val); val = dmar_readq(iommu->reg, DMAR_IQT_REG); - printk("DMAR_IAT_REG = %"PRIx64"\n", val); + printk("DMAR_IQT_REG = %"PRIx64"\n", val); } static int qinval_next_index(struct iommu *iommu) @@ -252,14 +252,15 @@ static int gen_dev_iotlb_inv_dsc(struct qinval_entry->q.dev_iotlb_inv_dsc.lo.res_3 = 0; qinval_entry->q.dev_iotlb_inv_dsc.hi.size = size; - qinval_entry->q.dev_iotlb_inv_dsc.hi.addr = addr; - - unmap_vtd_domain_page(qinval_entries); - spin_unlock_irqrestore(&qi_ctrl->qinval_lock, flags); - return 0; -} - -int queue_invalidate_device_iotlb(struct iommu *iommu, + qinval_entry->q.dev_iotlb_inv_dsc.hi.res_1 = 0; + qinval_entry->q.dev_iotlb_inv_dsc.hi.addr = addr >> PAGE_SHIFT_4K; + + unmap_vtd_domain_page(qinval_entries); + spin_unlock_irqrestore(&qi_ctrl->qinval_lock, flags); + return 0; +} + +int qinval_device_iotlb(struct iommu *iommu, u32 max_invs_pend, u16 sid, u16 size, u64 addr) { int ret = -1; _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |