self-nak. Found an iounmap() with a missing release_mem_region(); will post V2 shortly.
On 03/08/2012 06:51 PM, Donald Dutile wrote:
Intel-iommu initialization doesn't currently reserve the memory used for the IOMMU registers. This can allow the pci resource allocator to assign a device BAR to the same address as the IOMMU registers. This can cause some not so nice side affects when the driver ioremap's that region. Signed-off-by: Donald Dutile<[email protected]> --- drivers/iommu/dmar.c | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 35c1e17..1fcbd96 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c @@ -599,10 +599,16 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) iommu->seq_id = iommu_allocated++; sprintf (iommu->name, "dmar%d", iommu->seq_id); + map_size = VTD_PAGE_SIZE; + 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, VTD_PAGE_SIZE); if (!iommu->reg) { printk(KERN_ERR "IOMMU: can't map the region\n"); - goto error; + goto err_release; } iommu->cap = dmar_readq(iommu->reg + DMAR_CAP_REG); iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG); @@ -637,10 +643,16 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) map_size = VTD_PAGE_ALIGN(map_size); if (map_size> VTD_PAGE_SIZE) { iounmap(iommu->reg); + release_mem_region(drhd->reg_base_addr, VTD_PAGE_SIZE); + 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"); - goto error; + goto err_release; } } @@ -659,6 +671,8 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) err_unmap: iounmap(iommu->reg); + err_release: + release_mem_region(drhd->reg_base_addr, VTD_PAGE_SIZE); error: kfree(iommu); return -1;
_______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
