From patchwork Thu Jul 28 21:13:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jordan hargrave X-Patchwork-Id: 1017982 X-Patchwork-Delegate: bhelgaas@google.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6SLN0hK030399 for ; Thu, 28 Jul 2011 21:23:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755923Ab1G1VW7 (ORCPT ); Thu, 28 Jul 2011 17:22:59 -0400 Received: from ausxippc101.us.dell.com ([143.166.85.207]:44365 "EHLO ausxippc101.us.dell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755849Ab1G1VW7 (ORCPT ); Thu, 28 Jul 2011 17:22:59 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Jul 2011 21:23:00 +0000 (UTC) X-Greylist: delayed 572 seconds by postgrey-1.27 at vger.kernel.org; Thu, 28 Jul 2011 17:22:59 EDT X-Loopcount0: from 10.9.160.253 From: jharg93@gmail.com To: jordan_hargarave@dell.com, linux-pci@vger.kernel.org, Jordan_Hargrave@dell.com, jharg93@gmail.com Subject: [PATCH] Reserve memory for IOMMU registers Date: Thu, 28 Jul 2011 16:13:13 -0500 Message-Id: <1311887593-3608-1-git-send-email-jharg93@gmail.com> X-Mailer: git-send-email 1.7.4.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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 --- drivers/pci/dmar.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) 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");