From: Don Dutile <ddutile-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: chrisw-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org
Subject: Re: [PATCH] intel_iommu,dmar: reserve mmio of IOMMU registers
Date: Fri, 09 Mar 2012 11:10:27 -0500 [thread overview]
Message-ID: <4F5A2B73.9010103@redhat.com> (raw)
In-Reply-To: <1331250676-55926-1-git-send-email-ddutile-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
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<ddutile-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> 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;
prev parent reply other threads:[~2012-03-09 16:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-08 23:51 [PATCH] intel_iommu,dmar: reserve mmio of IOMMU registers Donald Dutile
[not found] ` <1331250676-55926-1-git-send-email-ddutile-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-03-09 16:10 ` Don Dutile [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F5A2B73.9010103@redhat.com \
--to=ddutile-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=chrisw-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.