Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753259AbbHVN0T (ORCPT ); Sat, 22 Aug 2015 09:26:19 -0400 Received: from mail-bl2on0063.outbound.protection.outlook.com ([65.55.169.63]:13968 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751793AbbHVN0R (ORCPT ); Sat, 22 Aug 2015 09:26:17 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Robert.Richter@caviumnetworks.com; Date: Sat, 22 Aug 2015 15:10:50 +0200 From: Robert Richter To: Marc Zygnier , Will Deacon , Thomas Gleixner , Jason Cooper CC: Ganapatrao Kulkarni , Tirumalesh Chalamarla , Robert Richter , , Subject: [PATCH] irqchip, gicv3-its, numa: Workaround for Cavium ThunderX erratum 23144 Message-ID: <20150822131050.GK1820@rric.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [78.53.82.170] X-ClientProxiedBy: AM2PR03CA0025.eurprd03.prod.outlook.com (25.160.207.35) To BY1PR0701MB1611.namprd07.prod.outlook.com (25.162.110.152) X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1611;2:trcUHT4F4jipppccQunvAuXjUXGUbCQKvE5MAnd+4IjUMVA6XtwosI7YYCOZoMop41gPOjKHwnXz+WEQ1JqXna4SQtpnWZ6AeIVeqeAje2ZboonG7oJkg0gmNr0LxgM3HsHbjeeGJwjlpRY+3GV5ohS+IFAPdAzSYt7KJ7vqvjg=;3:clPP+0I178VLzXbBRXVyPZA1ZisUIXVyQFVpcNNhj2Suzgayt+WOHboQLqkzR9aC4c2/7LLFZgcYFkFZ7a+WEOX4+sCHCFigrWR6y4WnMnLh+p4ConpsTwVKy3LJvPEdhtPAUJMqLoY4YqnUty/2Wg==;25:TUToGyI5EaPyIQzsDGUr/stpHdFdgaladScOphpNZ5h15RbvL+9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1gvDC2Mh775vgUmjzLVFmU1VpMmQNzh9rrVoMKqmKG9wRA9/Jdo/8HvlM5JELFemjRV5vLxpQ+PehXhRK5RHmbOKxio6hug9Bgjc7xT7YLuhdm1c6TNa46hXIT739tFvfrriUwP/ExZbbwEYNE7B4FNYf7h8XIv7xgLtoCp6+4bTZX0O0S3UIyHIQOL+B2/d9uJgCxRwJy6o5H9u52YFR9vaIgcAyg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(8121501046)(5005006)(3002001);SRVR:BY1PR0701MB1611;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1611; X-Forefront-PRVS: 0676F530A9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(199003)(164054003)(189002)(5004730100002)(4001350100001)(83506001)(77096005)(77156002)(23726002)(5001830100001)(575784001)(40100003)(50986999)(46102003)(101416001)(19580395003)(19580405001)(54356999)(5001860100001)(64706001)(87976001)(33656002)(50466002)(92566002)(4001540100001)(189998001)(47776003)(5001960100002)(66066001)(122386002)(5001770100001)(68736005)(105586002)(229853001)(42186005)(46406003)(97736004)(81156007)(97756001)(86362001)(62966003)(5007970100001)(106356001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1611;H:rric.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1611;23:sS1gZjfJSL3RWvWyDr/fFv8a6915vrdbFtDSGov?= =?us-ascii?Q?NehkaBHZ3vsc4tN+N0n79DgscZcu0ZrCvkbOY1m+cgqRBAOM9KARoVLfWQnx?= =?us-ascii?Q?a3rrKXOM4g83o2SZVTaKV46bbo018rzgAoK9ntX/+oN0FVhPQhlbxyK/EU2c?= =?us-ascii?Q?XDKy/8TXqOrvDBOg9BQCk11e3bTQxAYe4ZyvwGcSTQYV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cDqVg4FWZ6Z23ZN8kzcrKx6Jxvn85XZP/2768TiCQZP7aKeh8SSnZ83MQ?= =?us-ascii?Q?RK6fr1qZnH+4Q9oMb0DhbyZE1qgaX2uj4nUrovRrA2aDQNJ7Upjsx4EE/mMx?= =?us-ascii?Q?KtePoxEbB1PghH8ZQRsHFNxKhf1ZBM0RSUnEX?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1611;5:vNu4uK3+tRbFstVBNez5zE5oxtL2yCnnU2IDClHWNggLhByF1VueDi6DSmCj8ecnHPpQnVmVYjbv6xR9kQKvItD4w7hyMRGb3pt+yY5cHtxtQaoyYhg/aXLv61zQo/p+GG+2d07Dq9q3TB7j7TQ+Tg==;24:aRlDnDXOLDkGCuJuVmq8ZJzW0lu7l+8lCvKRYJubivmgjJCcUZGrUVs3rKqHiPoy6fZiiQo+Qi28I5vqLsMRzdhJ3aE+p6rws++VPFGWE7o=;20:gtqxR+7H5qOUON7+eiMy/4fezLpkq2ykTOne2C4+5IPR5rOdG1sqMiDFHi4ifFCrJm9/N1j+KXYqzOTjpmuP4w== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2015 13:11:01.1142 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1611 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6442 Lines: 215 The patch below adds a workaround for gicv3 in a numa environment. It is on top of my recent gicv3 errata patch submission v4 and Ganapat's arm64 numa patches for devicetree v5. Please comment. Thanks, -Robert >From c432820451a46b8d1e299b8bfbfcdcb3b75340e7 Mon Sep 17 00:00:00 2001 From: Ganapatrao Kulkarni Date: Wed, 19 Aug 2015 23:40:05 +0530 Subject: [PATCH] irqchip, gicv3-its, numa: Workaround for Cavium ThunderX erratum 23144 This implements a workaround for gicv3-its erratum 23144 applicable for Cavium's ThunderX multinode systems. The erratum fixes the hang of ITS SYNC command by avoiding inter node io and collections/cpu mapping. This fix is only applicable for Cavium's ThunderX dual-socket platforms. Signed-off-by: Ganapatrao Kulkarni [ rric: Reworked errata code, added helper functions, updated commit message. ] Signed-off-by: Robert Richter --- arch/arm64/Kconfig | 14 +++++++++++ drivers/irqchip/irq-gic-common.c | 5 ++-- drivers/irqchip/irq-gic-v3-its.c | 54 ++++++++++++++++++++++++++++++++++------ 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 3809187ed653..b92b7b70b29b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -421,6 +421,20 @@ config ARM64_ERRATUM_845719 If unsure, say Y. +config CAVIUM_ERRATUM_22375 + bool "Cavium erratum 22375, 24313" + depends on NUMA + default y + help + Enable workaround for erratum 22375, 24313. + +config CAVIUM_ERRATUM_23144 + bool "Cavium erratum 23144" + depends on NUMA + default y + help + Enable workaround for erratum 23144. + config CAVIUM_ERRATUM_23154 bool "Cavium erratum 23154: Access to ICC_IAR1_EL1 is not sync'ed" depends on ARCH_THUNDER diff --git a/drivers/irqchip/irq-gic-common.c b/drivers/irqchip/irq-gic-common.c index ee789b07f2d1..1dfce64dbdac 100644 --- a/drivers/irqchip/irq-gic-common.c +++ b/drivers/irqchip/irq-gic-common.c @@ -24,11 +24,12 @@ void gic_check_capabilities(u32 iidr, const struct gic_capabilities *cap, void *data) { - for (; cap->desc; cap++) { + for (; cap->init; cap++) { if (cap->iidr != (cap->mask & iidr)) continue; cap->init(data); - pr_info("%s\n", cap->desc); + if (cap->desc) + pr_info("%s\n", cap->desc); } } diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 4bb135721e72..666be39f13a9 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -43,7 +43,8 @@ #include "irqchip.h" #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING (1ULL << 0) -#define ITS_FLAGS_CAVIUM_THUNDERX (1ULL << 1) +#define ITS_WORKAROUND_CAVIUM_22375 (1ULL << 1) +#define ITS_WORKAROUND_CAVIUM_23144 (1ULL << 2) #define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING (1 << 0) @@ -76,6 +77,7 @@ struct its_node { struct list_head its_device_list; u64 flags; u32 ite_size; + int numa_node; }; #define ITS_ITT_ALIGN SZ_256 @@ -609,11 +611,18 @@ static void its_eoi_irq(struct irq_data *d) static int its_set_affinity(struct irq_data *d, const struct cpumask *mask_val, bool force) { - unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask); + unsigned int cpu; struct its_device *its_dev = irq_data_get_irq_chip_data(d); struct its_collection *target_col; u32 id = its_get_event_id(d); + if (its_dev->its->flags & ITS_WORKAROUND_CAVIUM_23144) { + cpu = cpumask_any_and(mask_val, + cpumask_of_node(its_dev->its->numa_node)); + } else { + cpu = cpumask_any_and(mask_val, cpu_online_mask); + } + if (cpu >= nr_cpu_ids) return -EINVAL; @@ -845,7 +854,7 @@ static int its_alloc_tables(struct its_node *its) u64 typer; u32 ids; - if (its->flags & ITS_FLAGS_CAVIUM_THUNDERX) { + if (its->flags & ITS_WORKAROUND_CAVIUM_22375) { /* * erratum 22375: only alloc 8MB table size * erratum 24313: ignore memory access type @@ -1093,6 +1102,11 @@ static void its_cpu_init_lpis(void) dsb(sy); } +static inline int numa_node_id_early(void) +{ + return MPIDR_AFFINITY_LEVEL(read_cpuid_mpidr(), 2); +} + static void its_cpu_init_collection(void) { struct its_node *its; @@ -1104,6 +1118,11 @@ static void its_cpu_init_collection(void) list_for_each_entry(its, &its_nodes, entry) { u64 target; + /* avoid cross node core and its mapping */ + if ((its->flags & ITS_WORKAROUND_CAVIUM_23144) && + its->numa_node != numa_node_id_early()) + continue; + /* * We now have to bind each collection to its target * redistributor. @@ -1372,9 +1391,15 @@ static void its_irq_domain_activate(struct irq_domain *domain, { struct its_device *its_dev = irq_data_get_irq_chip_data(d); u32 event = its_get_event_id(d); + unsigned int cpu; + + if (its_dev->its->flags & ITS_WORKAROUND_CAVIUM_23144) + cpu = cpumask_first(cpumask_of_node(its_dev->its->numa_node)); + else + cpu = cpumask_first(cpu_online_mask); /* Bind the LPI to the first possible CPU */ - its_dev->event_map.col_map[event] = cpumask_first(cpu_online_mask); + its_dev->event_map.col_map[event] = cpu; /* Map the GIC IRQ and event to the device */ its_send_mapvi(its_dev, d->hwirq, event); @@ -1457,16 +1482,31 @@ static int its_force_quiescent(void __iomem *base) } } +static inline int its_get_node_thunderx(struct its_node *its) +{ + return (its->phys_base >> 44) & 0x3; +} + static void its_enable_cavium_thunderx(void *data) { - struct its_node *its = data; + struct its_node __maybe_unused *its = data; - its->flags |= ITS_FLAGS_CAVIUM_THUNDERX; +#ifdef CONFIG_CAVIUM_ERRATUM_22375 + its->flags |= ITS_WORKAROUND_CAVIUM_22375; + pr_info("ITS: Enabling workaround for 22375, 24313\n"); +#endif + +#ifdef CONFIG_CAVIUM_ERRATUM_23144 + if (num_possible_nodes() > 1) { + its->numa_node = its_get_node_thunderx(its); + its->flags |= ITS_WORKAROUND_CAVIUM_23144; + pr_info("ITS: Enabling workaround for 23144\n"); + } +#endif } static const struct gic_capabilities its_errata[] = { { - .desc = "ITS: Cavium errata 22375, 24313", .iidr = 0xa100034c, /* ThunderX pass 1.x */ .mask = 0xffff0fff, .init = its_enable_cavium_thunderx, -- 2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/