From nobody Fri Nov 14 00:46:51 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=1583749681; cv=none; d=zohomail.com; s=zohoarc; b=YQqB7yXQPzY+MzxT6+4NIcd1ddl9r1xTtRAO0cRhf6IQwDyzddOXJ/E2WxKmRGoLpCLGI/HMr6Rcn4kcYY+rAXEfHbkIt5Wb5UR+QAIyeJiNWflKSaKcM9p+I+BiTq9uBAJFv52mb68ueSU+QAfpLYmNwHazmu3tKbBShPmF04s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583749681; 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=QN79AIMiRWnGkQVzN0tIppdKMS64inBORZvu36e4Zs4=; b=MeqGmaZKSLmynOfRFQA1sQuiN49+ZEsvGckYqMmrquTtu5ElOyImD0wwm3UV6UVIEyc2f/HQG0GTVwFZPviU4bUU6Pung8Wk2mlQHCLqvbXohCF4yc3ZcG7MDj6xtXjy5jt90M1YcDwU1PjtT/53+n0/3tN13YJcxsA76I/SEHc= 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 1583749681391191.80338546422308; Mon, 9 Mar 2020 03:28:01 -0700 (PDT) Received: from localhost ([::1]:40282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBFdg-0005R3-An for importer@patchew.org; Mon, 09 Mar 2020 06:28:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37937) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBFb0-0000On-Kc for qemu-devel@nongnu.org; Mon, 09 Mar 2020 06:25:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBFaz-0002Fq-9r for qemu-devel@nongnu.org; Mon, 09 Mar 2020 06:25:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:26709 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBFaz-0002Dw-4u for qemu-devel@nongnu.org; Mon, 09 Mar 2020 06:25:13 -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-61-LlcxDDTgOSmx89pOz96ZhQ-1; Mon, 09 Mar 2020 06:25:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8515107ACC4; Mon, 9 Mar 2020 10:25:09 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B6C991D87; Mon, 9 Mar 2020 10:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583749512; 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=QN79AIMiRWnGkQVzN0tIppdKMS64inBORZvu36e4Zs4=; b=SiWnH8xNqkMnhvo6LXoQbEY4/H8WBinE2KI1P/m3LkB/4c8nPsHOnieNKw/udUW6NUBPJc LqNTixMYuF58no1IQr+3DMTSAFfb7ytcBWA/rZUsKZxWKtZHRQk0A9AIBCN6rjOnAVEuze KL8Nio+nz1rmF6z04EsA0hWEN1Tw2ZY= X-MC-Unique: LlcxDDTgOSmx89pOz96ZhQ-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 v4 08/13] arm/arm64: ITS: Device and collection Initialization Date: Mon, 9 Mar 2020 11:24:15 +0100 Message-Id: <20200309102420.24498-9-eric.auger@redhat.com> In-Reply-To: <20200309102420.24498-1-eric.auger@redhat.com> References: <20200309102420.24498-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.120 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 2f480ae..fa84c00 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