Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755151AbbHZFHu (ORCPT ); Wed, 26 Aug 2015 01:07:50 -0400 Received: from mail-by2on0071.outbound.protection.outlook.com ([207.46.100.71]:16064 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753195AbbHZFHb (ORCPT ); Wed, 26 Aug 2015 01:07:31 -0400 X-Greylist: delayed 857 seconds by postgrey-1.27 at vger.kernel.org; Wed, 26 Aug 2015 01:07:31 EDT Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ganapatrao.Kulkarni@caviumnetworks.com; From: Ganapatrao Kulkarni To: , , , CC: , , , , , Subject: [PATCH v2 RESEND] irqchip, gicv3-its, numa: Workaround for Cavium ThunderX erratum 23144 Date: Wed, 26 Aug 2015 10:22:39 +0530 Message-ID: <1440564759-3786-1-git-send-email-gkulkarni@caviumnetworks.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: HK2PR0201CA0011.apcprd02.prod.outlook.com (25.162.206.21) To BLUPR0701MB1682.namprd07.prod.outlook.com (25.163.84.28) X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1682;2:UFE7oHQJgkIj4Qya3H4N9jP+h9WjdyFLeV1lZhS4oIyLA+jzqldGXJC6u1ptBmzh69KF4VB24MjJTzPRI5aRpGyBhvm079LdMScaBqElkq3bFWQdr7hO5PjYtjMo5CzySUDQfq5x2BNKTqHB93ncGSwtDH2vUOqBu6Cq8xaVzcw=;3:weOnvnInaSHIJIaTBjVSlUBZxLLY1lMweKi4PiwFZPh+k/b9SQ4J+qFLj3wvBeW3DCd0xFc8sloO6XsJl5epOowhpr36dhGtIb0/H7wfiN3SI5omdk0IHK1M9ctRbZbaNIWcJRWBBWWOhMjUEVr6lA==;25:Hq/IDSC8L5pSzMUPpng3J9J87jmt6etRt81Re90fwul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ahHv6R3zZ7dldmwQfot00wnyziyKejBriQOCwQcG9ifOLMFVY3giZU7RKA5f5Qxe822JQnioNuiVgp6GUNzOQQRVZjA7IzvknFE3g0FhOyPS4x2vn3TyIqMHfqkNT8cG3PYn/2hBuAfA53m5+hphM0eQmFmcsd024xgOPSPm1c50fV5nq6qBLUvKEyywbCb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:BLUPR0701MB1682;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1682; X-Forefront-PRVS: 0680FADD48 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(189002)(199003)(48376002)(40100003)(189998001)(229853001)(77156002)(46102003)(62966003)(5003940100001)(105586002)(50466002)(5004730100002)(101416001)(92566002)(5001770100001)(5007970100001)(5001860100001)(36756003)(97736004)(50986999)(4001540100001)(5001830100001)(77096005)(68736005)(64706001)(47776003)(33646002)(66066001)(2201001)(106356001)(87976001)(575784001)(50226001)(42186005)(19580405001)(19580395003)(122386002)(7099028);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR0701MB1682;H:mypc.cavium.com.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0701MB1682;23:v7cayLmLt/3xH/ciaKTCC2B9wBSCxSw2DzH9mWg?= =?us-ascii?Q?jcP1YbOXh8dSgYLhB7QTEI0+dJzIIImIJnsOM+JCEsaPhb1Bd0ywgVwoo31u?= =?us-ascii?Q?dEw9f8bks9A7d8NtbVf/v0tc5KXjU/44XtWy6cIIX+NDY01chR587kHP8Bko?= =?us-ascii?Q?LUnlYw/+qzg3wxpnylsic+egHz1l+1erLrAeIRqO2cNP9EGOLeuZLSqj2jKV?= =?us-ascii?Q?j4KkBe26sg8yoR49Vzg/aYi4wjCG507ijxE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ange-Diagnostics: 1;BLUPR0701MB1682;5:VOXGQkWcRvgt6Qg+fjaA+T0+fCic/+43EsF3pmM4sibBtHToU2+0Knfn3Zk88E87oCU7+UvqIcYpkM8Z3UTUsB4CCTX9sanrsm7bcN/ErRKlbOQWSXcXkntQe7uhD1D6SqG2XiuIS0jlrkpjsE25LA==;24:VRzSKgBTrF6iigI9AE9snTv/LsBpZEqdiGBK1AH4aLyCiaue9tNlmAoBqPzdiNwfTgvmAO0fAX4gilKTRawrL7WdCUOyAkQp6yfydZlVo+M=;20:7UfcYQbuq7n+CqncVX/CDFXjclYWi+8xv2YFlXCkAJQnsI/hVXq4mON/uwRMTbVFFcHouw/gVAH0JpNhk/l6aA== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2015 04:53:05.0171 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1682 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5150 Lines: 157 This implements a workaround for gicv3-its erratum 23144 on Cavium's ThunderX dual-socket platforms, where LPI cannot be routed to a redistributors present on a foreign node. Signed-off-by: Ganapatrao Kulkarni Signed-off-by: Robert Richter --- The patch below is on top of Robert's recent gicv3 errata patch submission v4 and my arm64 numa patches v5. v2: updatated as per Marc Zyngier's review comments. drivers/irqchip/irq-gic-v3-its.c | 49 ++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index b83b132..47fded0 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -39,7 +39,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) @@ -72,6 +73,7 @@ struct its_node { struct list_head its_device_list; u64 flags; u32 ite_size; + int numa_node; }; #define ITS_ITT_ALIGN SZ_256 @@ -606,11 +608,20 @@ 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; + const struct cpumask *cpu_mask = cpu_online_mask; struct its_device *its_dev = irq_data_get_irq_chip_data(d); struct its_collection *target_col; u32 id = its_get_event_id(d); + /* lpi cannot be routed to a redistributor that is on a foreign node */ + if (its_dev->its->flags & ITS_WORKAROUND_CAVIUM_23144) { + cpu_mask = cpumask_of_node(its_dev->its->numa_node); + if (!cpumask_intersects(mask_val, cpu_mask)) + return -EINVAL; + } + + cpu = cpumask_any_and(mask_val, cpu_mask); if (cpu >= nr_cpu_ids) return -EINVAL; @@ -842,7 +853,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 @@ -1349,9 +1360,14 @@ 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); + const struct cpumask *cpu_mask = cpu_online_mask; + + /* get the cpu_mask of local node */ + if (IS_ENABLED(CONFIG_NUMA)) + cpu_mask = cpumask_of_node(its_dev->its->numa_node); /* 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] = cpumask_first(cpu_mask); /* Map the GIC IRQ and event to the device */ its_send_mapvi(its_dev, d->hwirq, event); @@ -1434,11 +1450,19 @@ static int its_force_quiescent(void __iomem *base) } } -static void its_enable_cavium_thunderx(void *data) +static void its_enable_cavium_thunderx_22375(void *data) { struct its_node *its = data; - its->flags |= ITS_FLAGS_CAVIUM_THUNDERX; + its->flags |= ITS_WORKAROUND_CAVIUM_22375; +} + +static void its_enable_cavium_thunderx_23144(void *data) +{ + struct its_node *its = data; + + if (num_possible_nodes() > 1) + its->flags |= ITS_WORKAROUND_CAVIUM_23144; } static const struct gic_capabilities its_errata[] = { @@ -1446,7 +1470,13 @@ 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, + .init = its_enable_cavium_thunderx_22375, + }, + { + .desc = "ITS: Cavium errata 23144", + .iidr = 0xa100034c, /* ThunderX pass 1.x */ + .mask = 0xffff0fff, + .init = its_enable_cavium_thunderx_23144, }, { } @@ -1465,6 +1495,7 @@ static int its_probe(struct device_node *node, struct irq_domain *parent) u32 val; u64 baser, tmp; int err; + int numa_node; err = of_address_to_resource(node, 0, &res); if (err) { @@ -1472,6 +1503,9 @@ static int its_probe(struct device_node *node, struct irq_domain *parent) return -ENXIO; } + /* get numa affinity of its node*/ + numa_node = of_node_to_nid(node); + its_base = ioremap(res.start, resource_size(&res)); if (!its_base) { pr_warn("%s: unable to map registers\n", node->full_name); @@ -1507,6 +1541,7 @@ static int its_probe(struct device_node *node, struct irq_domain *parent) its->phys_base = res.start; its->msi_chip.of_node = node; its->ite_size = ((readl_relaxed(its_base + GITS_TYPER) >> 4) & 0xf) + 1; + its->numa_node = numa_node; its->cmd_base = kzalloc(ITS_CMD_QUEUE_SZ, GFP_KERNEL); if (!its->cmd_base) { -- 1.8.1.4 -- 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/