Skip to content

Commit 9452d5b

Browse files
committed
iommu/vt-d: Add access functions for iommu->domains
This makes it easier to change the layout of the data structure later. Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent c0e8a6c commit 9452d5b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,17 @@ __setup("intel_iommu=", intel_iommu_setup);
569569
static struct kmem_cache *iommu_domain_cache;
570570
static struct kmem_cache *iommu_devinfo_cache;
571571

572+
static struct dmar_domain* get_iommu_domain(struct intel_iommu *iommu, u16 did)
573+
{
574+
return iommu->domains[did];
575+
}
576+
577+
static void set_iommu_domain(struct intel_iommu *iommu, u16 did,
578+
struct dmar_domain *domain)
579+
{
580+
iommu->domains[did] = domain;
581+
}
582+
572583
static inline void *alloc_pgtable_page(int node)
573584
{
574585
struct page *page;
@@ -1463,7 +1474,8 @@ static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
14631474
* flush. However, device IOTLB doesn't need to be flushed in this case.
14641475
*/
14651476
if (!cap_caching_mode(iommu->cap) || !map)
1466-
iommu_flush_dev_iotlb(iommu->domains[did], addr, mask);
1477+
iommu_flush_dev_iotlb(get_iommu_domain(iommu, did),
1478+
addr, mask);
14671479
}
14681480

14691481
static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu)
@@ -1573,7 +1585,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
15731585
if (i == 0)
15741586
continue;
15751587

1576-
domain = iommu->domains[i];
1588+
domain = get_iommu_domain(iommu, i);
15771589
clear_bit(i, iommu->domain_ids);
15781590
if (domain_detach_iommu(domain, iommu) == 0 &&
15791591
!domain_type_is_vm(domain))
@@ -1631,7 +1643,7 @@ static int __iommu_attach_domain(struct dmar_domain *domain,
16311643
num = find_first_zero_bit(iommu->domain_ids, ndomains);
16321644
if (num < ndomains) {
16331645
set_bit(num, iommu->domain_ids);
1634-
iommu->domains[num] = domain;
1646+
set_iommu_domain(iommu, num, domain);
16351647
domain->iommu_did[iommu->seq_id] = num;
16361648
} else {
16371649
num = -ENOSPC;
@@ -1681,7 +1693,7 @@ static void iommu_detach_domain(struct dmar_domain *domain,
16811693
return;
16821694

16831695
clear_bit(num, iommu->domain_ids);
1684-
iommu->domains[num] = NULL;
1696+
set_iommu_domain(iommu, num, NULL);
16851697

16861698
spin_unlock_irqrestore(&iommu->lock, flags);
16871699
}
@@ -4852,7 +4864,7 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain,
48524864
*/
48534865
ndomains = cap_ndoms(iommu->cap);
48544866
for_each_set_bit(num, iommu->domain_ids, ndomains) {
4855-
if (iommu->domains[num] == dmar_domain)
4867+
if (get_iommu_domain(iommu, num) == dmar_domain)
48564868
iommu_flush_iotlb_psi(iommu, num, start_pfn,
48574869
npages, !freelist, 0);
48584870
}

0 commit comments

Comments
 (0)