iommu/rockchip: refactor shootdown_entire to simplify code

Change-Id: I87325ddd76b41940af50c756a3ecab65a90797cc
Signed-off-by: Simon Xue <xxm@rock-chips.com>
This commit is contained in:
Simon Xue
2022-12-15 11:12:36 +08:00
parent d9796b9fe5
commit a7d36d67ed

View File

@@ -894,6 +894,10 @@ static void rk_iommu_zap_iova(struct rk_iommu_domain *rk_domain,
struct list_head *pos;
unsigned long flags;
/* Do not zap tlb cache line if shootdown_entire set */
if (rk_domain->shootdown_entire)
return;
/* shootdown these iova from all iommus using this domain */
spin_lock_irqsave(&rk_domain->iommus_lock, flags);
list_for_each(pos, &rk_domain->iommus) {
@@ -1082,9 +1086,7 @@ static int rk_iommu_map_iova(struct rk_iommu_domain *rk_domain, u32 *pte_addr,
* We only zap the first and last iova, since only they could have
* dte or pte shared with an existing mapping.
*/
/* Do not zap tlb cache line if shootdown_entire set */
if (!rk_domain->shootdown_entire)
rk_iommu_zap_iova_first_last(rk_domain, iova, size);
rk_iommu_zap_iova_first_last(rk_domain, iova, size);
return 0;
unwind:
@@ -1132,9 +1134,7 @@ static int rk_iommu_map_iova_v2(struct rk_iommu_domain *rk_domain, u32 *pte_addr
* We only zap the first and last iova, since only they could have
* dte or pte shared with an existing mapping.
*/
/* Do not zap tlb cache line if shootdown_entire set */
if (!rk_domain->shootdown_entire)
rk_iommu_zap_iova_first_last(rk_domain, iova, size);
rk_iommu_zap_iova_first_last(rk_domain, iova, size);
return 0;
unwind:
@@ -1303,9 +1303,7 @@ static size_t rk_iommu_unmap_v2(struct iommu_domain *domain, unsigned long _iova
spin_unlock_irqrestore(&rk_domain->dt_lock, flags);
/* Shootdown iotlb entries for iova range that was just unmapped */
/* Do not zap tlb cache line if shootdown_entire set */
if (!rk_domain->shootdown_entire)
rk_iommu_zap_iova(rk_domain, iova, unmap_size);
rk_iommu_zap_iova(rk_domain, iova, unmap_size);
return unmap_size;
}