From 1244ad70a80a50faa43ed66313fae10ec011b455 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 (cherry picked from commit ce39549d9283e32cee6a476e4603e7b586957ecf) Signed-off-by: Mostafa Saleh --- 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 d72ea5602eaf..2cac6aea8c8c 100644 --- a/arch/arm64/kvm/hyp/nvhe/iommu.c +++ b/arch/arm64/kvm/hyp/nvhe/iommu.c @@ -545,4 +545,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); + } }