diff mbox

Reserve memory for IOMMU registers

Message ID 5B3AAEAF6B46EA4D955DF7AD46C2C485930A0C32@AUSX7MCPS303.AMER.DELL.COM (mailing list archive)
State New, archived
Headers show

Commit Message

Jordan_Hargrave@Dell.com July 28, 2011, 9:09 p.m. UTC
The DMAR driver currently doesn't reserve the memory used for the IOMMU
registers.  On one specific combination of cards on our system, the kernel
pci resource allocator was assigning a BAR to the same address as the IOMMU.
When the other driver did an ioremap, suddenly the IOMMU registers were no
longer valid.

Signed-off-by: Jordan Hargrave <Jordan_Hargrave@dell.com>
---
 drivers/pci/dmar.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 12e02bf..9650b9b 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -750,6 +750,10 @@  int alloc_iommu(struct dmar_drhd_unit *drhd)
        iommu->seq_id = iommu_allocated++;
        sprintf (iommu->name, "dmar%d", iommu->seq_id);

+       if (!request_mem_region(drhd->reg_base_addr, VTD_PAGE_SIZE, iommu->name)) {
+               printk(KERN_ERR "IOMMU: can't reserve memory\n");
+               goto error;
+       }
        iommu->reg = ioremap(drhd->reg_base_addr, VTD_PAGE_SIZE);
        if (!iommu->reg) {
                printk(KERN_ERR "IOMMU: can't map the region\n");
@@ -789,7 +793,12 @@  int alloc_iommu(struct dmar_drhd_unit *drhd)
                cap_max_fault_reg_offset(iommu->cap));
        map_size = VTD_PAGE_ALIGN(map_size);
        if (map_size > VTD_PAGE_SIZE) {
+               release_mem_region(drhd->reg_base_addr, VTD_PAGE_SIZE);
                iounmap(iommu->reg);
+               if (!request_mem_region(drhd->reg_base_addr, map_size, iommu->name)) {
+                       printk(KERN_ERR "IOMMU: can't reserve memory\n");
+                       goto error;
+               }
                iommu->reg = ioremap(drhd->reg_base_addr, map_size);
                if (!iommu->reg) {
                        printk(KERN_ERR "IOMMU: can't map the region\n");