From nobody Fri Nov 14 00:48:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583854642; cv=none; d=zohomail.com; s=zohoarc; b=EyNTd8ql4BSyyjrUTuwREKFGNTImDnVx0ZlvaTWLCdIVHkYODIHiJOZUbVNAZ1OywB1hOiYDpEZrY4BLOR6JJ4Tui1iiK1qrKBrJUmJ0t/Z1QHsV/k8kQO7S1qLr/94+/41KVY/3KLo6j4Wxs2E0RUSH+ESzKbOty1Akbg+gTrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583854642; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dAVG56X+6csWDSwqTHTjLZjsQD1ORBj1oN7BRQ6tzIs=; b=VK0UhdUdkiwiL17SpZWjClmqMXXIz1L2wgU0EJT/sTe1mna/bULoh96jWfljX7ABYlRovMu7iIYSb11XLpGK1bfJsh0d7GG9q8bu0U99NQonSCm7n9KEX8cjYxu0h6r0YJhoXpC5D2CdRTAJHFlEXAt/u6UXVhrgI3zZRDwKw+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583854642448855.3419792509535; Tue, 10 Mar 2020 08:37:22 -0700 (PDT) Received: from localhost ([::1]:34900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBgL7-0004gS-P6 for importer@patchew.org; Tue, 10 Mar 2020 10:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34500) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBgHp-0007X1-Nx for qemu-devel@nongnu.org; Tue, 10 Mar 2020 10:55:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBgHo-0002oO-Dl for qemu-devel@nongnu.org; Tue, 10 Mar 2020 10:55:13 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:58714 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBgHo-0002mv-9k for qemu-devel@nongnu.org; Tue, 10 Mar 2020 10:55:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-ZZ7gt7pEPiG9NA2c8Qq4og-1; Tue, 10 Mar 2020 10:55:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E6D3800D50; Tue, 10 Mar 2020 14:55:05 +0000 (UTC) Received: from laptop.redhat.com (ovpn-117-85.ams2.redhat.com [10.36.117.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id A870F60BF3; Tue, 10 Mar 2020 14:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583852111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dAVG56X+6csWDSwqTHTjLZjsQD1ORBj1oN7BRQ6tzIs=; b=LNsZEnTxAIJVQFE8B5u9rufCvNUrigUK8U5iLTpNB6dweF6FGSZL5CoL31hsyEGH8JPDky cFq4c9LLBGXzPi3Kf6gYFasG3axdmEMojG6hf9lK4hBJfLFS0rZq/K80lAIWjoe1cRYP+T 1nmjXuiMU7G5z49NcsG/XsywMRD4Vqc= X-MC-Unique: ZZ7gt7pEPiG9NA2c8Qq4og-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, maz@kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Subject: [kvm-unit-tests PATCH v5 08/13] arm/arm64: ITS: Device and collection Initialization Date: Tue, 10 Mar 2020 15:54:05 +0100 Message-Id: <20200310145410.26308-9-eric.auger@redhat.com> In-Reply-To: <20200310145410.26308-1-eric.auger@redhat.com> References: <20200310145410.26308-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, andre.przywara@arm.com, thuth@redhat.com, yuzenghui@huawei.com, alexandru.elisei@arm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Introduce an helper functions to register - a new device, characterized by its device id and the max number of event IDs that dimension its ITT (Interrupt Translation Table). The function allocates the ITT. - a new collection, characterized by its ID and the target processing engine (PE). Signed-off-by: Eric Auger --- v3 -> v4: - remove unused its_baser variable from its_create_device() - use get_order() - device->itt becomes a GVA instead of GPA v2 -> v3: - s/report_abort/assert v1 -> v2: - s/nb_/nr_ --- lib/arm64/asm/gic-v3-its.h | 19 +++++++++++++++++++ lib/arm64/gic-v3-its.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/lib/arm64/asm/gic-v3-its.h b/lib/arm64/asm/gic-v3-its.h index 1e95977..3da548b 100644 --- a/lib/arm64/asm/gic-v3-its.h +++ b/lib/arm64/asm/gic-v3-its.h @@ -27,6 +27,19 @@ struct its_baser { }; =20 #define GITS_BASER_NR_REGS 8 +#define GITS_MAX_DEVICES 8 +#define GITS_MAX_COLLECTIONS 8 + +struct its_device { + u32 device_id; /* device ID */ + u32 nr_ites; /* Max Interrupt Translation Entries */ + void *itt; /* Interrupt Translation Table GVA */ +}; + +struct its_collection { + u64 target_address; + u16 col_id; +}; =20 struct its_data { void *base; @@ -35,6 +48,10 @@ struct its_data { struct its_baser coll_baser; struct its_cmd_block *cmd_base; struct its_cmd_block *cmd_write; + struct its_device devices[GITS_MAX_DEVICES]; + u32 nr_devices; /* Allocated Devices */ + struct its_collection collections[GITS_MAX_COLLECTIONS]; + u32 nr_collections; /* Allocated Collections */ }; =20 extern struct its_data its_data; @@ -89,5 +106,7 @@ extern void its_parse_typer(void); extern void its_init(void); extern int its_baser_lookup(int i, struct its_baser *baser); extern void its_enable_defaults(void); +extern struct its_device *its_create_device(u32 dev_id, int nr_ites); +extern struct its_collection *its_create_collection(u32 col_id, u32 target= _pe); =20 #endif /* _ASMARM64_GIC_V3_ITS_H_ */ diff --git a/lib/arm64/gic-v3-its.c b/lib/arm64/gic-v3-its.c index c431f31..442dcf0 100644 --- a/lib/arm64/gic-v3-its.c +++ b/lib/arm64/gic-v3-its.c @@ -110,3 +110,41 @@ void its_enable_defaults(void) =20 writel(GITS_CTLR_ENABLE, its_data.base + GITS_CTLR); } + +struct its_device *its_create_device(u32 device_id, int nr_ites) +{ + struct its_device *new; + unsigned long n; + + assert(its_data.nr_devices < GITS_MAX_DEVICES); + + new =3D &its_data.devices[its_data.nr_devices]; + + new->device_id =3D device_id; + new->nr_ites =3D nr_ites; + + n =3D (its_data.typer.ite_size * nr_ites) >> PAGE_SHIFT; + new->itt =3D alloc_pages(get_order(n)); + + its_data.nr_devices++; + return new; +} + +struct its_collection *its_create_collection(u32 col_id, u32 pe) +{ + struct its_collection *new; + + assert(its_data.nr_collections < GITS_MAX_COLLECTIONS); + + new =3D &its_data.collections[its_data.nr_collections]; + + new->col_id =3D col_id; + + if (its_data.typer.pta) + new->target_address =3D (u64)gicv3_data.redist_base[pe]; + else + new->target_address =3D pe << 16; + + its_data.nr_collections++; + return new; +} --=20 2.20.1