From e1ea4666e1ec41ec05d4be81816b7d293535a4b4 Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Wed, 16 Nov 2022 17:54:51 +0000 Subject: [PATCH] ANDROID: KVM: arm64: iommu: Add host_stage2_idmap_complete Add a new callback to pkvm_iommu_ops called after host_stage2_idmap_apply on all IOMMU devices. This allows the drivers to complete operations like invalidation in two stages. Bug: 249161451 Signed-off-by: David Brazdil Change-Id: I9c077fd2b18ce54ad67eb34ef16bc94428797419 --- arch/arm64/kvm/hyp/include/nvhe/iommu.h | 6 ++++++ arch/arm64/kvm/hyp/nvhe/iommu.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/arch/arm64/kvm/hyp/include/nvhe/iommu.h b/arch/arm64/kvm/hyp/include/nvhe/iommu.h index 69bce1f01717..f9a75f49c499 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/iommu.h +++ b/arch/arm64/kvm/hyp/include/nvhe/iommu.h @@ -48,6 +48,12 @@ struct pkvm_iommu_ops { void (*host_stage2_idmap_apply)(struct pkvm_iommu *dev, phys_addr_t start, phys_addr_t end); + /* + * Callback to finish a host stage-2 mapping change at device level. + * Called after 'host_stage2_idmap_apply' with host lock held. + */ + void (*host_stage2_idmap_complete)(struct pkvm_iommu *dev); + /* Power management callbacks. Called with host lock held. */ int (*suspend)(struct pkvm_iommu *dev); int (*resume)(struct pkvm_iommu *dev); diff --git a/arch/arm64/kvm/hyp/nvhe/iommu.c b/arch/arm64/kvm/hyp/nvhe/iommu.c index 3fe47e542088..9327dd78af80 100644 --- a/arch/arm64/kvm/hyp/nvhe/iommu.c +++ b/arch/arm64/kvm/hyp/nvhe/iommu.c @@ -546,4 +546,9 @@ void pkvm_iommu_host_stage2_idmap(phys_addr_t start, phys_addr_t end, if (dev->powered && dev->ops->host_stage2_idmap_apply) dev->ops->host_stage2_idmap_apply(dev, start, end); } + + list_for_each_entry(dev, &iommu_list, list) { + if (dev->powered && dev->ops->host_stage2_idmap_complete) + dev->ops->host_stage2_idmap_complete(dev); + } }