Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755276AbbHYKuH (ORCPT ); Tue, 25 Aug 2015 06:50:07 -0400 Received: from mail-bl2on0061.outbound.protection.outlook.com ([65.55.169.61]:3897 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751763AbbHYKuE (ORCPT ); Tue, 25 Aug 2015 06:50:04 -0400 X-Greylist: delayed 1882 seconds by postgrey-1.27 at vger.kernel.org; Tue, 25 Aug 2015 06:50:04 EDT Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ganapatrao.Kulkarni@caviumnetworks.com; From: Ganapatrao Kulkarni To: , , , CC: , , , , , Subject: [PATCH v2] irqchip, gicv3-its, numa: Workaround for Cavium ThunderX erratum 23144 Date: Tue, 25 Aug 2015 15:48:05 +0530 Message-ID: <1440497885-24584-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: SINPR01CA0022.apcprd01.prod.exchangelabs.com (10.141.109.22) To BN3PR0701MB1687.namprd07.prod.outlook.com (25.163.39.153) X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1687;2:1/w+599PpKBVAXBooLY1Jrlv+rCPcB/cNalg7h1Q7DVNWZ3NQ0kl1Tg7m9+3u/xHWiE0EcJTCOrL51Jrstl0tqhv7Yybso9G79nURgexGuWwOFrwoO1kXOtRXtBjIdIM9lJ9F8frMScsF/0LxBmtsHpSLNUEuubjwgGh+NqcYjo=;3:cmqbBVBNDxfZbH+UU7fzIx+Jnr0vlCOIt2vEzbt4iar5ukLGgThMonFULudoBBzt8E7D9wFQFuIggdx/Zj8dplG3VLIWNrAHj5Ztxlxi54mBhsm/SR2LwZwyKaqIysGX0cKpaGiTB9505Y1MQsGpmw==;25:I2RFB070bWHAfqg9kVe0nIjhI4TZu5WMVzlYWWz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rDcznmrq5ilQ4mpiwn8AxsjXDRhYI4zKChL86elNnQaJQALOW4lVWT5VubPLXixUq82BtK/J6qIOjQIy7OWtvXp7ces8k6ZNMyjFY+jSBULFL4idPlmLuR14dTogWZnBwhaQrnaB/NQJTNA3pGDlMtO/aSwvjzsV6salFVQPAIvIaaBoTuC0vlDfDPf6P3gdowvZDWk 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:BN3PR0701MB1687;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1687; X-Forefront-PRVS: 06793E740F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(189002)(199003)(46102003)(189998001)(106356001)(19580405001)(64706001)(50986999)(229853001)(40100003)(2201001)(105586002)(5001830100001)(62966003)(77156002)(77096005)(47776003)(68736005)(5001860100001)(5003940100001)(19580395003)(50226001)(33646002)(5007970100001)(575784001)(66066001)(122386002)(92566002)(87976001)(50466002)(5001770100001)(97736004)(48376002)(101416001)(42186005)(36756003)(5004730100002)(4001540100001)(7099028);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0701MB1687;H:mypc.cavium.com.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0701MB1687;23:f1Mvz/BSKR87CGxXh+StdxBUX8g/iHiN4Qvkkpp?= =?us-ascii?Q?MydoFt4jrPm7jwwNKu0MEweoa3r1npRDkCzE9EGT/PTTOYpgzPOzF04qRgHz?= =?us-ascii?Q?Ocm7xydVBoQjz5hNnDLPVKy4qyIvLMpq2Pvcv9o/2UIA53IQ1AakHcxkINXr?= =?us-ascii?Q?dX0r4/Y2WBwyp0cd3n6Fyr98T4xY5N0+EjcbnUTIwPtYbDsLtz+qWSTZ3V4V?= =?us-ascii?Q?L9YfBe+piRmkDZju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oft-Exchange-Diagnostics: 1;BN3PR0701MB1687;5:PcbSzikrwNif47QxeiIqqnt4by00UGR92lDUI5nhTqupCu4RDFb5jFpn44utURCUQXzsTf2geKeWUDscF8wSejbUFyze6Rv7TUZpogNpml5g9J6GU3n8FhYWNrzxWBNmP4fxZsw1ZQeJLfEHocavYg==;24:8RYLn/+Ub0bU7xO+57XY9UByqz/PSJOIIUGT2RcBcXaGagDY0unMY55aHTfKdFrqW5pxFwIDLodWetxdXna/4/a5nPFntTWbjWHhBlGp0YU=;20:2dTFf3Mnalw1Cux/qcJqQ1ayxpm/jtet2x2JKqjGLacs74O4i+Y7CHuuLbzZghVOdc658qMxKzVfKzHVHtIaPQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2015 10:18:35.4176 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1687 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5094 Lines: 154 The patch below adds a workaround for gicv3 in a numa environment. It is on top of Robert's recent gicv3 errata patch submission v4 and my arm64 numa patches v5. 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. v2: updatated as per Marc Zyngier's review comments. Signed-off-by: Ganapatrao Kulkarni Signed-off-by: Robert Richter --- drivers/irqchip/irq-gic-v3-its.c | 53 +++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 614a367..d3fe0a4 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -40,7 +40,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) @@ -73,6 +74,7 @@ struct its_node { struct list_head its_device_list; u64 flags; u32 ite_size; + int numa_node; }; #define ITS_ITT_ALIGN SZ_256 @@ -607,11 +609,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; @@ -1338,9 +1349,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); @@ -1423,11 +1439,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[] = { @@ -1435,10 +1459,16 @@ 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, + }, + { + } }; static void its_enable_quirks(struct its_node *its) @@ -1456,6 +1486,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) { @@ -1463,6 +1494,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); @@ -1498,6 +1532,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/