From patchwork Sat Jul 22 03:54:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 108518 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1579395qge; Fri, 21 Jul 2017 21:01:25 -0700 (PDT) X-Received: by 10.99.23.100 with SMTP id 36mr9429738pgx.118.1500696085223; Fri, 21 Jul 2017 21:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500696085; cv=none; d=google.com; s=arc-20160816; b=JIGlkiRBakQqKvLKB+hxnFWsRHgL7/LOkp59x84Ylrb/+kWECokeZXKX7eOBJ5O7Dp i0YW07x/l/wE/+swENLuakRzbzY0EJbpAM8m3AVju97ji1VQycXLedgV3ZSiGfkbW2nN 8N2pGwmBx+XGG5/y6NK7YqaNZGgK1DdvnW730A4SKb9qPqgWtNFg5j45H7Uw4GjkhxeI GS/mtl+wNY1Es8QaZT0yF/kgasyq5CHvewqyzIbDnuaRiKNnpqh0haaQN7yBe8PUWk2A jg2KdagRbUlhadHE+35tDopTv88oqvpb0CHHzWl3vt8aCQ2pOxd9pVU1+9bxOlUdcf9H fKWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=vsZSuTGb0OOeY2n7y3SjPKpGwUpUJK6enz8A5l/1hr4=; b=UDwUNvWvxjZkn0DK+e5xPuB1W82GzW++xnv87N2O+fu+AEO+VeHNEU3ze7tK9t87AZ NoaIUfuFrK/4bhtKKAmkk9cRA64Qm+ofUP0uDG526eBudc3alo+gHqjjNEjhHMsrHGqL HQMzruOx7zvsJBt6e7cW/SSVFYRkXFNlWjN9NkZGq1q+o0CwQksjyvKv8vHL1yeOf5fV gpB/8ZZYHIuC+4xhVa+v0HtYnSWaPzgb0TCuMRFQdy0/5tZtP4r+WcVr7mEB3+ytubA9 9ZKzoZeskch4mSVruKeauDXCHSwl7nJ3Bu+7eylMmn4Ky3dIP/2jctc0XMY+hNH1PaFN ovUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i127si3949465pgc.591.2017.07.21.21.01.25; Fri, 21 Jul 2017 21:01:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750760AbdGVEBW (ORCPT + 8 others); Sat, 22 Jul 2017 00:01:22 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:10331 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750750AbdGVEBW (ORCPT ); Sat, 22 Jul 2017 00:01:22 -0400 Received: from 172.30.72.55 (EHLO dggeml406-hub.china.huawei.com) ([172.30.72.55]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ARO88493; Sat, 22 Jul 2017 12:00:53 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by dggeml406-hub.china.huawei.com (10.3.17.50) with Microsoft SMTP Server id 14.3.301.0; Sat, 22 Jul 2017 12:00:43 +0800 From: Hanjun Guo To: Thomas Gleixner , Marc Zyngier CC: , , , , Hanjun Guo , Ganapatrao Kulkarni , Lorenzo Pieralisi Subject: [PATCH v2] irqchip/gic-v3-its: Allow GIC ITS number more than MAX_NUMNODES Date: Sat, 22 Jul 2017 11:54:12 +0800 Message-ID: <1500695652-27025-1-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5972CDF7.0123, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 6d75e7845106f359e4ca82a9f6e9a4b7 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Hanjun Guo When running 4.13-rc1 on top of D05, I got the boot log: [ 0.000000] SRAT: PXM 0 -> ITS 0 -> Node 0 [ 0.000000] SRAT: PXM 0 -> ITS 1 -> Node 0 [ 0.000000] SRAT: PXM 0 -> ITS 2 -> Node 0 [ 0.000000] SRAT: PXM 1 -> ITS 3 -> Node 1 [ 0.000000] SRAT: ITS affinity exceeding max count[4] This is wrong on D05 as we have 8 ITSes with 4 NUMA nodes. So dynamically alloc the memory needed instead of using its_srat_maps[MAX_NUMNODES], which count the number of ITS entry(ies) in SRAT and alloc its_srat_maps as needed, then build the mapping of numa node to ITS ID. Of course, its_srat_maps will be freed after ITS probing because we don't need that after boot. After doing this, I got what I wanted: [ 0.000000] SRAT: PXM 0 -> ITS 0 -> Node 0 [ 0.000000] SRAT: PXM 0 -> ITS 1 -> Node 0 [ 0.000000] SRAT: PXM 0 -> ITS 2 -> Node 0 [ 0.000000] SRAT: PXM 1 -> ITS 3 -> Node 1 [ 0.000000] SRAT: PXM 2 -> ITS 4 -> Node 2 [ 0.000000] SRAT: PXM 2 -> ITS 5 -> Node 2 [ 0.000000] SRAT: PXM 2 -> ITS 6 -> Node 2 [ 0.000000] SRAT: PXM 3 -> ITS 7 -> Node 3 Fixes: dbd2b8267233 ("irqchip/gic-v3-its: Add ACPI NUMA node mapping") Signed-off-by: Hanjun Guo Cc: Ganapatrao Kulkarni Cc: Lorenzo Pieralisi Cc: Marc Zyngier --- v1->v2: - Add NULL check in acpi_get_its_numa_node() for no ITS affinity case; - Free the its_srat_maps after ITS probing. drivers/irqchip/irq-gic-v3-its.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 3ccdf76..1d692aa 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1847,13 +1847,16 @@ struct its_srat_map { u32 its_id; }; -static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata; +static struct its_srat_map *its_srat_maps __initdata; static int its_in_srat __initdata; static int __init acpi_get_its_numa_node(u32 its_id) { int i; + if (!its_srat_maps) + return NUMA_NO_NODE; + for (i = 0; i < its_in_srat; i++) { if (its_id == its_srat_maps[i].its_id) return its_srat_maps[i].numa_node; @@ -1861,6 +1864,12 @@ static int __init acpi_get_its_numa_node(u32 its_id) return NUMA_NO_NODE; } +static int __init gic_acpi_match_srat_its(struct acpi_subtable_header *header, + const unsigned long end) +{ + return 0; +} + static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, const unsigned long end) { @@ -1877,12 +1886,6 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, return -EINVAL; } - if (its_in_srat >= MAX_NUMNODES) { - pr_err("SRAT: ITS affinity exceeding max count[%d]\n", - MAX_NUMNODES); - return -EINVAL; - } - node = acpi_map_pxm_to_node(its_affinity->proximity_domain); if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) { @@ -1901,14 +1904,35 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, static void __init acpi_table_parse_srat_its(void) { + int count; + + count = acpi_table_parse_entries(ACPI_SIG_SRAT, + sizeof(struct acpi_table_srat), + ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, + gic_acpi_match_srat_its, 0); + if (count <= 0) + return; + + its_srat_maps = kmalloc(count * sizeof(struct its_srat_map), + GFP_KERNEL); + if (!its_srat_maps) + return; + acpi_table_parse_entries(ACPI_SIG_SRAT, sizeof(struct acpi_table_srat), ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, gic_acpi_parse_srat_its, 0); } + +/* free the its_srat_maps after ITS probing */ +static void __init acpi_its_srat_maps_free(void) +{ + kfree(its_srat_maps); +} #else static void __init acpi_table_parse_srat_its(void) { } static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; } +static void __init acpi_its_srat_maps_free(void) { } #endif static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header, @@ -1955,6 +1979,7 @@ static void __init its_acpi_probe(void) acpi_table_parse_srat_its(); acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, gic_acpi_parse_madt_its, 0); + acpi_its_srat_maps_free(); } #else static void __init its_acpi_probe(void) { }