summaryrefslogtreecommitdiffstats
path: root/virt/kvm/arm/vgic/vgic-v3.c
diff options
context:
space:
mode:
authorEric Auger <eric.auger@redhat.com>2018-05-22 09:55:09 +0200
committerMarc Zyngier <marc.zyngier@arm.com>2018-05-25 12:29:26 +0100
commitdc524619369c320e057cb198bbca017f3a0bb69a (patch)
tree6094b7ecf66f4b91f4b5440a9af4634ba0891f29 /virt/kvm/arm/vgic/vgic-v3.c
parentdbd9733ab6742dfb7d4f6c49e7d412d4e792d8be (diff)
downloadlinux-dc524619369c320e057cb198bbca017f3a0bb69a.tar.gz
linux-dc524619369c320e057cb198bbca017f3a0bb69a.tar.bz2
linux-dc524619369c320e057cb198bbca017f3a0bb69a.zip
KVM: arm/arm64: Helper to locate free rdist index
We introduce vgic_v3_rdist_free_slot to help identifying where we can place a new 2x64KB redistributor. Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt/kvm/arm/vgic/vgic-v3.c')
-rw-r--r--virt/kvm/arm/vgic/vgic-v3.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 56e6e903d998..2a11fe89943a 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -453,6 +453,29 @@ bool vgic_v3_check_base(struct kvm *kvm)
return false;
}
+/**
+ * vgic_v3_rdist_free_slot - Look up registered rdist regions and identify one
+ * which has free space to put a new rdist region.
+ *
+ * @rd_regions: redistributor region list head
+ *
+ * A redistributor regions maps n redistributors, n = region size / (2 x 64kB).
+ * Stride between redistributors is 0 and regions are filled in the index order.
+ *
+ * Return: the redist region handle, if any, that has space to map a new rdist
+ * region.
+ */
+struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rd_regions)
+{
+ struct vgic_redist_region *rdreg;
+
+ list_for_each_entry(rdreg, rd_regions, list) {
+ if (!vgic_v3_redist_region_full(rdreg))
+ return rdreg;
+ }
+ return NULL;
+}
+
int vgic_v3_map_resources(struct kvm *kvm)
{
int ret = 0;