From: Mark McLoughlin <markmc@redhat.com>
To: "Han, Weidong" <weidong.han@intel.com>
Cc: "'Avi Kivity'" <avi@redhat.com>,
"Woodhouse, David" <david.woodhouse@intel.com>,
"'Jesse Barnes'" <jbarnes@virtuousgeek.org>,
"Yu, Fenghua" <fenghua.yu@intel.com>,
"'iommu@lists.linux-foundation.org'"
<iommu@lists.linux-foundation.org>,
"'kvm@vger.kernel.org'" <kvm@vger.kernel.org>
Subject: Re: [PATCH 01/13] iommu bitmap insteads of iommu pointer in dmar_domain
Date: Thu, 04 Dec 2008 17:12:26 +0000 [thread overview]
Message-ID: <1228410746.3732.135.camel@blaa> (raw)
In-Reply-To: <715D42877B251141A38726ABF5CABF2C018BF05987@pdsmsx503.ccr.corp.intel.com>
Hi Weidong,
On Tue, 2008-12-02 at 22:22 +0800, Han, Weidong wrote:
> Support dmar_domain own multiple devices from different iommus, which
> are set in iommu bitmap. add function domain_get_iommu() to get the
> only one iommu of domain in native VT-d usage.
A bitmap seems quite awkward. Why not a list?
Also, I wasn't sure at first what you meant by "native VT-d" ... you
mean DMA-API VT-d usage as opposed to KVM device assignment usage,
right? Perhaps we need a better term for that distinction.
> Signed-off-by: Weidong Han <weidong.han@intel.com>
> ---
> drivers/pci/intel-iommu.c | 102 ++++++++++++++++++++++++++++------------
> include/linux/dma_remapping.h | 2 +-
> 2 files changed, 72 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
> index 5c8baa4..39c5e9d 100644
> --- a/drivers/pci/intel-iommu.c
> +++ b/drivers/pci/intel-iommu.c
> @@ -184,6 +185,21 @@ void free_iova_mem(struct iova *iova)
> kmem_cache_free(iommu_iova_cache, iova);
> }
>
> +/* in native case, each domain is related to only one iommu */
> +static struct intel_iommu *domain_get_iommu(struct dmar_domain *domain)
> +{
> + struct dmar_drhd_unit *drhd;
> +
> + for_each_drhd_unit(drhd) {
> + if (drhd->ignored)
> + continue;
> + if (test_bit(drhd->iommu->seq_id, &domain->iommu_bmp))
> + return drhd->iommu;
> + }
> +
> + return NULL;
> +}
So, basically, a lot of the code assumes that there is only one iommu
associated with a domain. That makes it seem like the abstractions here
could do with some re-working.
We should at least add:
ASSERT(!(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE));
in the patch which adds that flag.
> @@ -1925,16 +1952,19 @@ static void add_unmap(struct dmar_domain *dom, struct iova *iova)
> {
> unsigned long flags;
> int next, iommu_id;
> + struct intel_iommu *iommu;
>
> spin_lock_irqsave(&async_umap_flush_lock, flags);
> if (list_size == HIGH_WATER_MARK)
> flush_unmaps();
>
> - iommu_id = dom->iommu->seq_id;
> + iommu = domain_get_iommu(dom);
> + iommu_id = iommu->seq_id;
>
> next = deferred_flush[iommu_id].next;
> deferred_flush[iommu_id].domain[next] = dom;
> deferred_flush[iommu_id].iova[next] = iova;
> + deferred_flush[iommu_id].iommu = iommu;
> deferred_flush[iommu_id].next++;
This deferred_flush->iommu change should be in it's own patch, IMHO.
Also, it's not quite right - there is a fixed mapping between iommu_id
and the iommu, so it makes no sense to update that mapping each time we
add a new iova.
In fact, it makes me wonder why we don't have the flush list in the
struct intel_iommu and have a global list of iommus.
Cheers,
Mark.
next prev parent reply other threads:[~2008-12-04 17:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-02 14:22 [PATCH 01/13] iommu bitmap insteads of iommu pointer in dmar_domain Han, Weidong
2008-12-04 17:12 ` Mark McLoughlin [this message]
2008-12-05 0:52 ` Han, Weidong
2008-12-05 16:42 ` Avi Kivity
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=1228410746.3732.135.camel@blaa \
--to=markmc@redhat.com \
--cc=avi@redhat.com \
--cc=david.woodhouse@intel.com \
--cc=fenghua.yu@intel.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jbarnes@virtuousgeek.org \
--cc=kvm@vger.kernel.org \
--cc=weidong.han@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).