提交 c4596114 编写于 作者: J Joerg Roedel

x86/amd-iommu: Add per IOMMU reference counting

This patch adds reference counting for protection domains
per IOMMU. This allows a smarter TLB flushing strategy.
Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
上级 bb52777e
......@@ -238,7 +238,9 @@ struct protection_domain {
unsigned long flags; /* flags to find out type of domain */
bool updated; /* complete domain flush required */
unsigned dev_cnt; /* devices assigned to this domain */
unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */
void *priv; /* private data */
};
/*
......
......@@ -1175,6 +1175,8 @@ static void __attach_device(struct amd_iommu *iommu,
/* update DTE entry */
set_dte_entry(devid, domain);
/* Do reference counting */
domain->dev_iommu[iommu->index] += 1;
domain->dev_cnt += 1;
/* ready */
......@@ -1209,6 +1211,9 @@ static void attach_device(struct amd_iommu *iommu,
*/
static void __detach_device(struct protection_domain *domain, u16 devid)
{
struct amd_iommu *iommu = amd_iommu_rlookup_table[devid];
BUG_ON(!iommu);
/* lock domain */
spin_lock(&domain->lock);
......@@ -1223,7 +1228,8 @@ static void __detach_device(struct protection_domain *domain, u16 devid)
amd_iommu_apply_erratum_63(devid);
/* decrease reference counter */
/* decrease reference counters */
domain->dev_iommu[iommu->index] -= 1;
domain->dev_cnt -= 1;
/* ready */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册