Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp373977rwd; Thu, 8 Jun 2023 01:48:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QbVpWl7YOBASUiZpiYw8pl0YlGaAfVeCyVeV+gE3ZfRSJcQ5KNMmB2OXFTqVSdeTE4BTG X-Received: by 2002:a92:cc43:0:b0:331:55d1:92e with SMTP id t3-20020a92cc43000000b0033155d1092emr10605597ilq.17.1686214125229; Thu, 08 Jun 2023 01:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686214125; cv=none; d=google.com; s=arc-20160816; b=IyTD5rahIKNqzgVGU3Yqn7wuZkkVIdfE3bGKdTo3doWRB5abxXqixUCwS04Rdikasm c9K/vlwdfLsuu4p9A9EklvBQ5tQPqCgzxmB/VZ+Jg4haIFb1GCzrTZkrEiCUvSjzqJOO tpgsUXrGOJNHPtDvO0ni3w5vyvX91qsy0X4WE0vfo/rn1neL35yfkF/YYVdOchdFz0CY 81GD5Fz91pkRhEqxw2wf9CljADyInX3F96L2hdpAvyOpnupqlsfkNbIJlvLrbke6ndKr Yi9NtNZR1qWDXpReTzJK7B4aP2eLIH0lCeX9z/DaVIN3agDnspgMpe+sinUwFvS1lmnz m3/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=hI/Yqff4q7GZ8l1zu3Ks4u7uA4GCvWSUe8lO4bDxJMI=; b=NS18HzMWwW/ZXMhNQuNj9yT0XfMONwMLXHnwpJuKutsoRgINWW3AgU7JCtwEveLlNT A0D61ec/3aRKarMaSHQ98+QEV+6V+PD1wDyQV8ystpESBfaA5+N1tp8mxqK6PfDk3rOw qLyoYUS2ivzWnHVKHZBucwnZDlhPEmaJ1+lJ0w6GTNi2yhZUgh6U56hGc9Z5PXA9tr1w XZpfgqarJyJV3BRGqR5sFvEU5XB0Gi9iQ6HiD4IeDM2cBnICj9XDM1LifmlAbU2UOtux HF+Ic8eePHZtjHMmSjfJVM1Y/I3FSDOamIPXUpmcPakU0L8GNUaKezOtKg3n2tnWHQHE M6nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RFSAA9Hf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s188-20020a625ec5000000b0065cd02882d5si461960pfb.397.2023.06.08.01.48.33; Thu, 08 Jun 2023 01:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RFSAA9Hf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234451AbjFHIKe (ORCPT + 99 others); Thu, 8 Jun 2023 04:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234458AbjFHIKc (ORCPT ); Thu, 8 Jun 2023 04:10:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 471D226AE for ; Thu, 8 Jun 2023 01:10:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CDD8764A03 for ; Thu, 8 Jun 2023 08:10:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44BDFC433EF; Thu, 8 Jun 2023 08:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686211828; bh=8OIawGQRKkwbu/IyrxgY/eIFkFwYIqlXcO+jcYdoeJI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RFSAA9HfwxupfsLtXpeNkkBeiTM7Kcs78OER1NuZfai+Hsbb2WYkUIrHRF7Fc7s0p 5wwyMungR8F2tqHhUwzun8OmRXuvnZzcYUuwvWjNDUDpFx3A5zUzz672F5kQVr1Eb0 c0Of1oVXbPnnKqZSPZzMEgWXA5G0jorCz9E0AJxtPH23t+dUsmCX5nbW3SLjjS5Ori PMoXo9vRGuqgeFzZkKxcr5s9XCK26FCKBEpaQFHT8DRbYUcvh2Z12h4PvzDqVXyj7R Lq1XzxQLA+dQ45VMbziFMgEt16NbSyilnqdAtUTtd49lptgco1eqU1tcoPMluVS5t8 lCodTFWJ/684Q== Received: from 152.5.30.93.rev.sfr.net ([93.30.5.152] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q7Aiv-003jsk-E2; Thu, 08 Jun 2023 09:10:26 +0100 Date: Thu, 08 Jun 2023 09:10:24 +0100 Message-ID: <87cz26nzm7.wl-maz@kernel.org> From: Marc Zyngier To: wangwudi Cc: , , Thomas Gleixner Subject: Re: [PATCH v2] irqchip: gic-v3: Extend collection table In-Reply-To: <1686131113-3611-1-git-send-email-wangwudi@hisilicon.com> References: <1686131113-3611-1-git-send-email-wangwudi@hisilicon.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 93.30.5.152 X-SA-Exim-Rcpt-To: wangwudi@hisilicon.com, linux-kernel@vger.kernel.org, liaochang1@huawei.com, tglx@linutronix.de X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 07 Jun 2023 10:45:13 +0100, wangwudi wrote: > > Only single level table is supported to the collection table, and only > one page is allocated. > > Extend collection table to support more CPUs: > 1. Recalculate the page number of collection table based on the number of > CPUs. > 2. Add 2 level tables to collection table. > 3. Add GITS_TYPER_CIDBITS macros. > > It is noticed in an internal simulation research: > - the page_size of collection table is 4 KB > - the entry_size of collection table is 16 Byte > - with 512 CPUs > > Cc: Thomas Gleixner > Cc: Marc Zyngier > Signed-off-by: wangwudi > --- > > ChangeLog: > v1-->v2: > 1. Support 2 level table > 2. Rewrite the commit log > > drivers/irqchip/irq-gic-v3-its.c | 62 ++++++++++++++++++++++++++++++-------- > include/linux/irqchip/arm-gic-v3.h | 3 ++ > 2 files changed, 53 insertions(+), 12 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 0ec2b1e1df75..573ef26ad449 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -126,6 +126,7 @@ struct its_node { > #define is_v4(its) (!!((its)->typer & GITS_TYPER_VLPIS)) > #define is_v4_1(its) (!!((its)->typer & GITS_TYPER_VMAPP)) > #define device_ids(its) (FIELD_GET(GITS_TYPER_DEVBITS, (its)->typer) + 1) > +#define collection_ids(its) (FIELD_GET(GITS_TYPER_CIDBITS, (its)->typer) + 1) > > #define ITS_ITT_ALIGN SZ_256 > > @@ -2626,6 +2627,10 @@ static int its_alloc_tables(struct its_node *its) > indirect = its_parse_indirect_baser(its, baser, &order, > ITS_MAX_VPEID_BITS); > break; > + case GITS_BASER_TYPE_COLLECTION: > + indirect = its_parse_indirect_baser(its, baser, &order, > + order_base_2(num_possible_cpus())); > + break; Nice try, but no. See below. > } > > err = its_setup_baser(its, baser, cache, shr, order, indirect); > @@ -3230,18 +3235,6 @@ static void its_cpu_init_collection(struct its_node *its) > its_send_invall(its, &its->collections[cpu]); > } > > -static void its_cpu_init_collections(void) > -{ > - struct its_node *its; > - > - raw_spin_lock(&its_lock); > - > - list_for_each_entry(its, &its_nodes, entry) > - its_cpu_init_collection(its); > - > - raw_spin_unlock(&its_lock); > -} > - > static struct its_device *its_find_device(struct its_node *its, u32 dev_id) > { > struct its_device *its_dev = NULL, *tmp; > @@ -3316,6 +3309,51 @@ static bool its_alloc_table_entry(struct its_node *its, > return true; > } > > +static bool its_alloc_collection_table(struct its_node *its, struct its_baser *baser) > +{ > + int cpu = smp_processor_id(); > + int cpu_ids = 16; > + > + if (its->typer & GITS_TYPER_CIL) > + cpu_ids = collection_ids(its); > + > + if (!(ilog2(cpu) < cpu_ids)) { > + pr_warn("ITS: CPU%d out of Collection ID range for %dbits", cpu, cpu_ids); > + return false; > + } > + > + if (!its_alloc_table_entry(its, baser, cpu)) { > + pr_warn("ITS: CPU%d failed to allocate collection l2 table", cpu); > + return false; > + } > + > + return true; > +} > + > +static bool its_cpu_init_collections(void) > +{ > + struct its_node *its; > + struct its_baser *baser; > + > + raw_spin_lock(&its_lock); > + > + list_for_each_entry(its, &its_nodes, entry) { > + baser = its_get_baser(its, GITS_BASER_TYPE_COLLECTION); > + if (!baser) { > + raw_spin_unlock(&its_lock); > + return false; > + } This looks wrong. ITSs that have a non-zero HCC field may not need memory to back their collections at all, such as GIC500. There may not even be a BASERn register holding the memory. So this patch more or less *guarantees* to break most implementation that are more than 5 year old. M. -- Without deviation from the norm, progress is not possible.