Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp516968rwd; Wed, 7 Jun 2023 03:19:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4F7urWvg2HohIiGzESrixdm5QPjUr/JIbLElOjnxqBIWoK7gJNX/fQsrYOr+dQIkamVCyd X-Received: by 2002:a92:cd09:0:b0:33a:efd3:add3 with SMTP id z9-20020a92cd09000000b0033aefd3add3mr8028194iln.14.1686133194532; Wed, 07 Jun 2023 03:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686133194; cv=none; d=google.com; s=arc-20160816; b=jcib/BUON0rz09/vDOVQGG4LRzBz3PEd+R8QGzc0P0M/70eXD9mZiWsBltBB6ZSZ5+ USpjwzb8VChBt3/DIMFvqUwPSiAU74Zzm1S5q6W62JdCsyBS9Zh1ofFRudExXWAsKDm4 WqbYXMu72UqCgmlPEhumQwsAZWLVHqw9ABqO32efwvMVMwTAbMfp3PWEFTEtICR0iAlc 97f5j965NHtVoUN7r8dDl1JthZjuJWAe+pxO20ZvFFRt9WSlk7mWaZ7UV8r8U13uceur 66He2f8Xjr/liVt9R2RL9JvJSMaiwquBZkcdCN1CORQVAiJ25GVvUyFfo2C0ewSyKAJg fDLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=qlXdfFw/HiWJjUJY1UCzB01kRukhWkgvFBm2LS1hOTc=; b=WOPIg8UTnzOXgBCzxDakKNpJkJLoC1OA/1EZW3DD+P5eV4Y4WiZEBrKOhAQqnAduAn 8gKKAblq1uqiqqNbRop1szoxyPSiY7+TIhlpdAawXjv1cMYT/i7xLJjs8IlQaKo0CiK8 SeBnk1Qq0uxpk8XxZpWFbIbkCb4Gv0f2xaMHhcdnLv/9WAMHvA9BnLEzPS7rDCv2X6bk vQNATg3Ncl95kRRt28xyv0nL5gRte2bT+Ss7GyBVwKTCRT82f+bFcIZ9fFYD6Op+zBEj uC54OVbZ4YeKsAEnnVtoRbqALEEYqZqIDblwScfQ+L0IMvSWT0bkZtwItlXG9jZk53AG PiXA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020aa79ad2000000b0064f4ee1aa5bsi8585256pfp.223.2023.06.07.03.19.39; Wed, 07 Jun 2023 03:19:54 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239320AbjFGJuh (ORCPT + 99 others); Wed, 7 Jun 2023 05:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234384AbjFGJug (ORCPT ); Wed, 7 Jun 2023 05:50:36 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D49E47 for ; Wed, 7 Jun 2023 02:50:34 -0700 (PDT) Received: from dggpemm500003.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QbjBw5dV6zqTqN; Wed, 7 Jun 2023 17:45:44 +0800 (CST) Received: from localhost.localdomain (10.28.77.120) by dggpemm500003.china.huawei.com (7.185.36.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 7 Jun 2023 17:50:33 +0800 From: wangwudi To: CC: , wangwudi , Thomas Gleixner , Marc Zyngier Subject: [PATCH v2] irqchip: gic-v3: Extend collection table Date: Wed, 7 Jun 2023 17:45:13 +0800 Message-ID: <1686131113-3611-1-git-send-email-wangwudi@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.28.77.120] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500003.china.huawei.com (7.185.36.56) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 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; } 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; + } + + if (!its_alloc_collection_table(its, baser)) { + raw_spin_unlock(&its_lock); + return false; + } + its_cpu_init_collection(its); + } + raw_spin_unlock(&its_lock); + return true; +} + static bool its_alloc_device_table(struct its_node *its, u32 dev_id) { struct its_baser *baser; diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index 728691365464..35e83da8961f 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -400,6 +400,9 @@ #define GITS_TYPER_PTA (1UL << 19) #define GITS_TYPER_HCC_SHIFT 24 #define GITS_TYPER_HCC(r) (((r) >> GITS_TYPER_HCC_SHIFT) & 0xff) +#define GITS_TYPER_CIDBITS_SHIFT 32 +#define GITS_TYPER_CIDBITS GENMASK_ULL(35, 32) +#define GITS_TYPER_CIL (1ULL << 36) #define GITS_TYPER_VMOVP (1ULL << 37) #define GITS_TYPER_VMAPP (1ULL << 40) #define GITS_TYPER_SVPET GENMASK_ULL(42, 41) -- 2.7.4