@@ -569,6 +569,17 @@ __setup("intel_iommu=", intel_iommu_setup);
569
569
static struct kmem_cache * iommu_domain_cache ;
570
570
static struct kmem_cache * iommu_devinfo_cache ;
571
571
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
+
572
583
static inline void * alloc_pgtable_page (int node )
573
584
{
574
585
struct page * page ;
@@ -1463,7 +1474,8 @@ static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
1463
1474
* flush. However, device IOTLB doesn't need to be flushed in this case.
1464
1475
*/
1465
1476
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 );
1467
1479
}
1468
1480
1469
1481
static void iommu_disable_protect_mem_regions (struct intel_iommu * iommu )
@@ -1573,7 +1585,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
1573
1585
if (i == 0 )
1574
1586
continue ;
1575
1587
1576
- domain = iommu -> domains [ i ] ;
1588
+ domain = get_iommu_domain ( iommu , i ) ;
1577
1589
clear_bit (i , iommu -> domain_ids );
1578
1590
if (domain_detach_iommu (domain , iommu ) == 0 &&
1579
1591
!domain_type_is_vm (domain ))
@@ -1631,7 +1643,7 @@ static int __iommu_attach_domain(struct dmar_domain *domain,
1631
1643
num = find_first_zero_bit (iommu -> domain_ids , ndomains );
1632
1644
if (num < ndomains ) {
1633
1645
set_bit (num , iommu -> domain_ids );
1634
- iommu -> domains [ num ] = domain ;
1646
+ set_iommu_domain ( iommu , num , domain ) ;
1635
1647
domain -> iommu_did [iommu -> seq_id ] = num ;
1636
1648
} else {
1637
1649
num = - ENOSPC ;
@@ -1681,7 +1693,7 @@ static void iommu_detach_domain(struct dmar_domain *domain,
1681
1693
return ;
1682
1694
1683
1695
clear_bit (num , iommu -> domain_ids );
1684
- iommu -> domains [ num ] = NULL ;
1696
+ set_iommu_domain ( iommu , num , NULL ) ;
1685
1697
1686
1698
spin_unlock_irqrestore (& iommu -> lock , flags );
1687
1699
}
@@ -4852,7 +4864,7 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain,
4852
4864
*/
4853
4865
ndomains = cap_ndoms (iommu -> cap );
4854
4866
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 )
4856
4868
iommu_flush_iotlb_psi (iommu , num , start_pfn ,
4857
4869
npages , !freelist , 0 );
4858
4870
}
0 commit comments