Received: by 10.213.65.68 with SMTP id h4csp696841imn; Tue, 27 Mar 2018 07:10:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELurxibTphmLsgxduVKkv89KnLgRZG5oMZZ+RokKVJqr2KlEbskyeUbwtqh9DuHO9HM1kKjt X-Received: by 2002:a17:902:ac96:: with SMTP id h22-v6mr44495173plr.93.1522159818452; Tue, 27 Mar 2018 07:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522159818; cv=none; d=google.com; s=arc-20160816; b=jDFbR4nZ8Y8olP62TnxoG5VoZWbeEZmNXSNLefNheXmUYJlOHcAxG55rebiqIeXaMt X6PHY/Ty5a/+YQoQ2G+4A/POBfXgJMFlY2d+naayAIr1e+eZhHHW3ZkG1QnqCuFVm3B+ a4uNZPZ8bRHf7nwbJccMCXuc9ZtovNuAiLLq49jhSVK9a6w85emB224BdnOcWRkWEhXp /74R4Xz8YQDf9TsG9hBAVdsEmMytZA3613ShIxMSL5qjn2jJlWQjRsNwTpDW5t1kMskB k4E1Qy6aeK/mVINCVZxEPCrfJJVWilG7Gb7kjbAEiQXWjiiQqSzVCvgm1Pz3CPL7gpCs h/OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=MZQL5xwT13e1EKTNaGjgSthrDWOsPeDwzmnaxrG0Ovk=; b=UXtjmRA7+vSeXIXc1F1KJOWaNe2Xq0poUh821m0X8zitcsybvqJn/UcGesHCr/u5DJ t8Zu/bsSZZmACLP2RLkqKKUqBi2aUwaaHXgyn8ciUPzL5M0JpHBfOSewvQypLMRC018w +UWtmlDYFjZVSGkTCgi6ziuw+aoIk5RY3+bwj7GRit+yrNgMhzXnI2LC7zd1VztRV43o 2ILZnX0M7oGul/MIxaagD9nbUhePyyF0ead0sfZO7/k5Bhr2MSYe4P/eN4sn4lzv4lxE 7zqWigJnbgdXnFG8YX9YV3Yohpw0wJa8oGGr2HcGZqwjVt9Dr2gph41HHczWkVP7wZex uTdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7-v6si1255240plr.293.2018.03.27.07.10.03; Tue, 27 Mar 2018 07:10:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752934AbeC0OEh (ORCPT + 99 others); Tue, 27 Mar 2018 10:04:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52520 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752865AbeC0OEd (ORCPT ); Tue, 27 Mar 2018 10:04:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0725F40201A4; Tue, 27 Mar 2018 14:04:33 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-135.ams2.redhat.com [10.36.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09A93215CDB5; Tue, 27 Mar 2018 14:04:30 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, cdall@kernel.org, peter.maydell@linaro.org Cc: andre.przywara@arm.com, drjones@redhat.com, wei@redhat.com Subject: [RFC v2 04/12] KVM: arm/arm64: Helper to locate free rdist index Date: Tue, 27 Mar 2018 16:04:08 +0200 Message-Id: <1522159456-10419-5-git-send-email-eric.auger@redhat.com> In-Reply-To: <1522159456-10419-1-git-send-email-eric.auger@redhat.com> References: <1522159456-10419-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 27 Mar 2018 14:04:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 27 Mar 2018 14:04:33 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We introduce vgic_v3_rdist_free_slot to help identifying where we can place a new 2x64KB redistributor. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 +-- virt/kvm/arm/vgic/vgic-v3.c | 17 +++++++++++++++++ virt/kvm/arm/vgic/vgic.h | 11 +++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index d1aab18..49ca176 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c @@ -593,8 +593,7 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu) * function for all VCPUs when the base address is set. Just return * without doing any work for now. */ - rdreg = list_first_entry(&vgic->rd_regions, - struct vgic_redist_region, list); + rdreg = vgic_v3_rdist_free_slot(&vgic->rd_regions); if (!rdreg) return 0; diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c index 7e696e6..6a7e4065 100644 --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c @@ -438,6 +438,23 @@ 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 regions + * + * If any, return this redist region handle, otherwise returns NULL. + */ +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; diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index f5b8519..d5e89b8 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h @@ -248,6 +248,17 @@ static inline int vgic_v3_max_apr_idx(struct kvm_vcpu *vcpu) } } +static inline bool +vgic_v3_redist_region_full(struct vgic_redist_region *region) +{ + if (!region->count) + return false; + + return (region->free_index >= region->count); +} + +struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rdregs); + int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its, u32 devid, u32 eventid, struct vgic_irq **irq); struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi); -- 2.5.5