From nobody Fri Nov 14 02:13:11 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=1583935201; cv=none; d=zohomail.com; s=zohoarc; b=K+blrMVhDGsFR97JORb+rkWl0R6w7YCqzejGgnwcbqD+s06qoHrt9yDMZ8SizAP8s91nMjZmLLTypjhkNmMVrXXYhAxOTsqui5iKaMrsZLQzSB0drH8UDF15pIHvtCl4JhM9lMbVIOEEi4RV0W/6yC9zO4Fo+v1TKY3TaPAZbzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583935201; 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=LThBuzxpBIGnDg2AAuFd9Pk7/QYWy2R/aXM3izuVepc=; b=EYBhioEu1qhPtyyqx+H6xOqDT9TfVMgjNb+T9v2zXCX1Gz2OjcQTW3zqMVTqErUr1iG1/6POt+733T45ihNhtGB8xSvi03sRswEHTRjCw+/AcQVP1oMLHaOzzeq6bxA0UyqQqMD2LIrV3CW6AC/YkwpY4tpcKHe15kzOgEzQfE8= 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 1583935201227954.0126468931389; Wed, 11 Mar 2020 07:00:01 -0700 (PDT) Received: from localhost ([::1]:52606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jC1tu-0003I7-Fw for importer@patchew.org; Wed, 11 Mar 2020 09:59:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35853) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jC1mQ-00038o-Tt for qemu-devel@nongnu.org; Wed, 11 Mar 2020 09:52:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jC1mK-0001mH-Kb for qemu-devel@nongnu.org; Wed, 11 Mar 2020 09:52:13 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26696 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 1jC1mK-0001lX-HG for qemu-devel@nongnu.org; Wed, 11 Mar 2020 09:52:08 -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-160-5TdW9Vt9PyOmE9Sbna0gyA-1; Wed, 11 Mar 2020 09:52:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E037E1005509; Wed, 11 Mar 2020 13:52:04 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.36.118.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id B98E55C13D; Wed, 11 Mar 2020 13:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583934728; 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=LThBuzxpBIGnDg2AAuFd9Pk7/QYWy2R/aXM3izuVepc=; b=NNWNybLnbm/Y/YBkarHlGcJ1zdApgre4r8LiKE7SZx6kShYQcDij1J7Pz2nBX11olpW3Vj yjT8D65FMAKLRN4vTJUyt/Gje8xau6puM1LF41y+hvTXfiuvQCDEfmtbKDfPYQxRkS48DL gfqIW1unuyhAG3YR7DTtHgSo1VV7GRE= X-MC-Unique: 5TdW9Vt9PyOmE9Sbna0gyA-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 v6 07/13] arm/arm64: ITS: its_enable_defaults Date: Wed, 11 Mar 2020 14:51:11 +0100 Message-Id: <20200311135117.9366-8-eric.auger@redhat.com> In-Reply-To: <20200311135117.9366-1-eric.auger@redhat.com> References: <20200311135117.9366-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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" its_enable_defaults() enable LPIs at redistributor level and ITS level. gicv3_enable_defaults must be called before. Signed-off-by: Eric Auger Reviewed-by: Zenghui Yu --- v5 -> v6: - gicv3_lpi_set/get_config introduced before this patch - dist/redist in commit msg - Added Zenghui's R-b v4 -> v5: - some reformattings moved to earlier patch - add assert(!gicv3_redist_base()) in alloc_lpi_tables() - revert the usage of for_each_present_cpu() v3 -> v4: - use GITS_BASER_INDIRECT & GITS_BASER_VALID in its_setup_baser() - don't parse BASERs again in its_enable_defaults - rename its_setup_baser into its_baser_alloc_table - All allocations moved to the init function - squashed "arm/arm64: gicv3: Enable/Disable LPIs at re-distributor level" into this patch - introduce gicv3_lpi_rdist_enable and gicv3_lpi_rdist_disable - pend and prop table bases stored as virt addresses - move some init functions from enable() to its_init - removed GICR_PROPBASER_IDBITS_MASK - introduced LPI_OFFSET - lpi_prop becomes u8 * - gicv3_lpi_set_config/get_config became macro - renamed gicv3_lpi_set_pending_table_bit into gicv3_lpi_set_clr_pending v2 -> v3: - introduce its_setup_baser in this patch - squash "arm/arm64: ITS: Init the command queue" in this patch. --- lib/arm/asm/gic-v3.h | 6 ++++++ lib/arm/gic-v3.c | 25 +++++++++++++++++++++++++ lib/arm64/asm/gic-v3-its.h | 1 + lib/arm64/gic-v3-its.c | 13 +++++++++++++ 4 files changed, 45 insertions(+) diff --git a/lib/arm/asm/gic-v3.h b/lib/arm/asm/gic-v3.h index fedffa8..cb72922 100644 --- a/lib/arm/asm/gic-v3.h +++ b/lib/arm/asm/gic-v3.h @@ -57,6 +57,10 @@ #define LPI_PROP_DEFAULT_PRIO 0xa0 #define LPI_PROP_DEFAULT (LPI_PROP_DEFAULT_PRIO | LPI_PROP_GROUP1 | LPI_P= ROP_ENABLED) =20 +#define LPI_ID_BASE 8192 +#define LPI(lpi) ((lpi) + LPI_ID_BASE) +#define LPI_OFFSET(intid) ((intid) - LPI_ID_BASE) + #include =20 #ifndef __ASSEMBLY__ @@ -93,6 +97,8 @@ extern void gicv3_ipi_send_mask(int irq, const cpumask_t = *dest); extern void gicv3_set_redist_base(size_t stride); extern void gicv3_lpi_set_clr_pending(int rdist, int n, bool set); extern void gicv3_lpi_alloc_tables(void); +extern void gicv3_lpi_rdist_enable(int redist); +extern void gicv3_lpi_rdist_disable(int redist); =20 static inline void gicv3_do_wait_for_rwp(void *base) { diff --git a/lib/arm/gic-v3.c b/lib/arm/gic-v3.c index 6cf1d1d..a7e2cb8 100644 --- a/lib/arm/gic-v3.c +++ b/lib/arm/gic-v3.c @@ -199,4 +199,29 @@ void gicv3_lpi_set_clr_pending(int rdist, int n, bool = set) byte &=3D ~mask; *ptr =3D byte; } + +static void gicv3_lpi_rdist_ctrl(u32 redist, bool set) +{ + void *ptr; + u64 val; + + assert(redist < nr_cpus); + + ptr =3D gicv3_data.redist_base[redist]; + val =3D readl(ptr + GICR_CTLR); + if (set) + val |=3D GICR_CTLR_ENABLE_LPIS; + else + val &=3D ~GICR_CTLR_ENABLE_LPIS; + writel(val, ptr + GICR_CTLR); +} + +void gicv3_lpi_rdist_enable(int redist) +{ + gicv3_lpi_rdist_ctrl(redist, true); +} +void gicv3_lpi_rdist_disable(int redist) +{ + gicv3_lpi_rdist_ctrl(redist, false); +} #endif /* __aarch64__ */ diff --git a/lib/arm64/asm/gic-v3-its.h b/lib/arm64/asm/gic-v3-its.h index d46669b..fec6767 100644 --- a/lib/arm64/asm/gic-v3-its.h +++ b/lib/arm64/asm/gic-v3-its.h @@ -88,5 +88,6 @@ extern struct its_data its_data; 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); =20 #endif /* _ASMARM64_GIC_V3_ITS_H_ */ diff --git a/lib/arm64/gic-v3-its.c b/lib/arm64/gic-v3-its.c index 4c9c0db..c431f31 100644 --- a/lib/arm64/gic-v3-its.c +++ b/lib/arm64/gic-v3-its.c @@ -97,3 +97,16 @@ void its_init(void) its_cmd_queue_init(); } =20 +/* must be called after gicv3_enable_defaults */ +void its_enable_defaults(void) +{ + int i; + + /* Allocate LPI config and pending tables */ + gicv3_lpi_alloc_tables(); + + for (i =3D 0; i < nr_cpus; i++) + gicv3_lpi_rdist_enable(i); + + writel(GITS_CTLR_ENABLE, its_data.base + GITS_CTLR); +} --=20 2.20.1