Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2734980rwb; Fri, 20 Jan 2023 06:48:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXscAJTEyxx1WbvNMPuIgF3C4Uqs6+khw2IR2/dgUMLMevJN9ZJMww+jCOOAyeZI2xjulKX4 X-Received: by 2002:a17:907:7248:b0:872:b1d7:8028 with SMTP id ds8-20020a170907724800b00872b1d78028mr19325261ejc.3.1674226120157; Fri, 20 Jan 2023 06:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674226120; cv=none; d=google.com; s=arc-20160816; b=haTQCzmZxfyozKmOQL36ZcOJ8XlJoJim6nz6Y39CzHfxzlLWgsr7Y9azQbnqM5qRzi dASp11GDV5snu1BBcarNo69uW5eXAm2KKcch5HlxfotmJ2IyPND3xYofvRoew7/eYWW6 +FHX5AC7wa9HXPKWoIrinbtAmSltV2MoNULImDyqFyZhyVykx6qgroIhVHf77pVFyusr 8VhtUhPbqh0CKEnJN3QmZIc6Lm3ZJS+nwJCkCnK1p2NCiUu0wfk/tOkQw7v3f/fwKW93 swdUJt3dnu2x14DG263IpL2A3WSAOD1FmOtO0P7CmoVY2eHqbpSbUtWHU96mVYgJPaxA D46Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:secumail-id:dkim-signature; bh=d28u8Ds/UU1rB9dz4o/gDj3OY/L8bHsKH9sVYHPz23k=; b=mkZVk6rlYsqilfEGrIezURVtNm9Pj7ZDJ+bj1Ah9VXwxfixT+f5CaTq8vWyTw2pbi9 qrh1xyXCYhW96T7/rYBhNyBuES2Zn5NcjPp9kE/jzApNcTrLsl0xesIAMvFni+8TTU0v 8JogHz4Dam/+mQaBmbJkgHb1QjW9/vncFv0tLfMtP+y+CF0Es53yn+Uf69W8vSefF8d/ xzsVeKk+67tLLEJfGCrB4ExHugCNgBOAh6hN7MslAgwlMD0iaqZVYcs1V5PPi460DuB1 v073jTqO4OJxCZJKZO5my845+D76sIn/oikVZ353u7VpMd+l5gH50iE5KrEp0+fIakZx l87g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kalray.eu header.s=sec-sig-email header.b=4xRbut1w; dkim=neutral (body hash did not verify) header.i=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=PkDAJ2mb; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=kalray.eu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr11-20020a170906d54b00b00877a67bb40esi1247533ejc.803.2023.01.20.06.48.27; Fri, 20 Jan 2023 06:48:40 -0800 (PST) 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; dkim=pass header.i=@kalray.eu header.s=sec-sig-email header.b=4xRbut1w; dkim=neutral (body hash did not verify) header.i=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=PkDAJ2mb; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=kalray.eu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbjATOL6 (ORCPT + 49 others); Fri, 20 Jan 2023 09:11:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230391AbjATOLn (ORCPT ); Fri, 20 Jan 2023 09:11:43 -0500 Received: from fx405.security-mail.net (smtpout140.security-mail.net [85.31.212.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C8CBC638A for ; Fri, 20 Jan 2023 06:10:47 -0800 (PST) Received: from localhost (fx405.security-mail.net [127.0.0.1]) by fx405.security-mail.net (Postfix) with ESMTP id A3315335E76 for ; Fri, 20 Jan 2023 15:10:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1674223833; bh=YRX0Wr/1x7MjAvceUm2udvzUR1TOmF2eg1JprEHHvQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=4xRbut1w4zOpBXyHSq9C5pkhrGB2DjceQ+R2LOysvay+1gezw8L0D1oZzEGuT5eCO fL7HIubM9zERQDoUuV1TXhJGx3gwyRJEBYNLKPk82ghwq9y8tFs6yYB49igdxogouD ZxqEYzVf9YcTiIEp499NxozMFXug+0BI6pCW64rc= Received: from fx405 (fx405.security-mail.net [127.0.0.1]) by fx405.security-mail.net (Postfix) with ESMTP id 1288B335DF2; Fri, 20 Jan 2023 15:10:33 +0100 (CET) Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx405.security-mail.net (Postfix) with ESMTPS id EB02D335CEB; Fri, 20 Jan 2023 15:10:31 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id A49CE27E0442; Fri, 20 Jan 2023 15:10:31 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 8BB4A27E043D; Fri, 20 Jan 2023 15:10:31 +0100 (CET) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id U6itgih5Dbpw; Fri, 20 Jan 2023 15:10:31 +0100 (CET) Received: from junon.lin.mbt.kalray.eu (unknown [192.168.37.161]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 0F29627E0439; Fri, 20 Jan 2023 15:10:31 +0100 (CET) X-Virus-Scanned: E-securemail Secumail-id: <16482.63caa0d7.e71bf.0> DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 8BB4A27E043D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1674223831; bh=VOCUsPMJmFARQsqOvo9LjS/JXRlQuyQoyz0P2SXEDK0=; h=From:To:Date:Message-Id:MIME-Version; b=PkDAJ2mbH/dRIRz3Ev0E06+CjrkEGJWMzkHLNsc+7sKPjdsXswUAdfFC4Q8QwaCOa te2fWAMAQYkLOSuheX7j5IqaDoEo/DN8AdgKbTQ8vhcaN0lyuPH0UxU4CF3xo/U4JJ ZMNxpuEbibLGCxhjY+mfcXwuzTv0JEeR1KplNBpM= From: Yann Sionneau To: Arnd Bergmann , Jonathan Corbet , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Eric Biederman , Kees Cook , Oleg Nesterov , Ingo Molnar , Waiman Long , "Aneesh Kumar K.V" , Andrew Morton , Nick Piggin , Paul Moore , Eric Paris , Christian Brauner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jules Maselbas , Yann Sionneau , Guillaume Thouvenin , Clement Leger , Vincent Chardon , Marc =?utf-8?b?UG91bGhpw6hz?= , Julian Vetter , Samuel Jones , Ashley Lesdalons , Thomas Costis , Marius Gligor , Jonathan Borne , Julien Villette , Luc Michel , Louis Morhet , Julien Hascoet , Jean-Christophe Pince , Guillaume Missonnier , Alex Michon , Huacai Chen , WANG Xuerui , Shaokun Zhang , John Garry , Guangbin Huang , Bharat Bhushan , Bibo Mao , Atish Patra , "Jason A. Donenfeld" , Qi Liu , Jiaxun Yang , Catalin Marinas , Mark Brown , Janosch Frank , Alexey Dobriyan Cc: Benjamin Mugnier , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-audit@redhat.com, linux-riscv@lists.infradead.org, bpf@vger.kernel.org Subject: [RFC PATCH v2 15/31] irqchip: Add irq-kvx-apic-gic driver Date: Fri, 20 Jan 2023 15:09:46 +0100 Message-ID: <20230120141002.2442-16-ysionneau@kalray.eu> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230120141002.2442-1-ysionneau@kalray.eu> References: <20230120141002.2442-1-ysionneau@kalray.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 X-ALTERMIMEV2_out: done X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 Each Cluster of the Coolidge SoC includes an Advanced Programmable Interrupt Controller (APIC) and Generic Interrupt Controller (GIC). The APIC GIC acts as an intermediary interrupt controller, muxing/routing incoming interrupts to cores in the cluster. The 139 possible input interrupt lines are organized as follow: - 128 from the mailbox controller (one it per mailboxes) - 1 from the NoC router - 5 from IOMMUs - 1 from L2 cache DMA job FIFO - 1 from cluster watchdog - 2 for SECC, DECC - 1 from Data NoC The 72 possible output interrupt line: - 68 : 4 interrupts per cores (17 cores) - 1 for L2 cache controller - 3 extra that are for padding Co-developed-by: Clement Leger Signed-off-by: Clement Leger Co-developed-by: Julian Vetter Signed-off-by: Julian Vetter Co-developed-by: Vincent Chardon Signed-off-by: Vincent Chardon Signed-off-by: Jules Maselbas Signed-off-by: Yann Sionneau --- Notes: V1 -> V2: - removed irq-kvx-itgen driver (moved in its own patch) - removed irq-kvx-apic-mailbox driver (moved in its own patch) - removed irq-kvx-core-intc driver (moved in its own patch) - removed print on probe success drivers/irqchip/Kconfig | 6 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-kvx-apic-gic.c | 356 +++++++++++++++++++++++++++++ 3 files changed, 363 insertions(+) create mode 100644 drivers/irqchip/irq-kvx-apic-gic.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 7ef9f5e696d3..2433e4ba0759 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -334,6 +334,12 @@ config MIPS_GIC select IRQ_DOMAIN_HIERARCHY select MIPS_CM +config KVX_APIC_GIC + bool + depends on KVX + select IRQ_DOMAIN + select IRQ_DOMAIN_HIERARCHY + config INGENIC_IRQ bool depends on MACH_INGENIC diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 87b49a10962c..8ac1dd880420 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -69,6 +69,7 @@ obj-$(CONFIG_BCM7120_L2_IRQ) += irq-bcm7120-l2.o obj-$(CONFIG_BRCMSTB_L2_IRQ) += irq-brcmstb-l2.o obj-$(CONFIG_KEYSTONE_IRQ) += irq-keystone.o obj-$(CONFIG_MIPS_GIC) += irq-mips-gic.o +obj-$(CONFIG_KVX_APIC_GIC) += irq-kvx-apic-gic.o obj-$(CONFIG_ARCH_MEDIATEK) += irq-mtk-sysirq.o irq-mtk-cirq.o obj-$(CONFIG_ARCH_DIGICOLOR) += irq-digicolor.o obj-$(CONFIG_ARCH_SA1100) += irq-sa11x0.o diff --git a/drivers/irqchip/irq-kvx-apic-gic.c b/drivers/irqchip/irq-kvx-apic-gic.c new file mode 100644 index 000000000000..cc234a075473 --- /dev/null +++ b/drivers/irqchip/irq-kvx-apic-gic.c @@ -0,0 +1,356 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2017 - 2022 Kalray Inc. + * Author(s): Clement Leger + * Julian Vetter + */ + +#define pr_fmt(fmt) "kvx_apic_gic: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* APIC is organized in 18 groups of 4 output lines + * However, the two upper lines are for Secure RM and DMA engine + * Thus, we do not have to use them + */ +#define KVX_GIC_PER_CPU_IT_COUNT 4 +#define KVX_GIC_INPUT_IT_COUNT 0x9D +#define KVX_GIC_OUTPUT_IT_COUNT 0x10 + +/* GIC enable register definitions */ +#define KVX_GIC_ENABLE_OFFSET 0x0 +#define KVX_GIC_ENABLE_ELEM_SIZE 0x1 +#define KVX_GIC_ELEM_SIZE 0x400 + +/* GIC status lac register definitions */ +#define KVX_GIC_STATUS_LAC_OFFSET 0x120 +#define KVX_GIC_STATUS_LAC_ELEM_SIZE 0x8 +#define KVX_GIC_STATUS_LAC_ARRAY_SIZE 0x3 + +/** + * For each CPU, there is 4 output lines coming from the apic GIC. + * We only use 1 line and this structure represent this line. + * @base Output line base address + * @cpu CPU associated to this line + */ +struct gic_out_irq_line { + void __iomem *base; + unsigned int cpu; +}; + +/** + * Input irq line. + * This structure is used to store the status of the input line and the + * associated output line. + * @enabled Boolean for line status + * @cpu CPU currently receiving this interrupt + * @it_num Interrupt number + */ +struct gic_in_irq_line { + bool enabled; + struct gic_out_irq_line *out_line; + unsigned int it_num; +}; + +/** + * struct kvx_apic_gic - kvx apic gic + * @base: Base address of the controller + * @domain Domain for this controller + * @input_nr_irqs: maximum number of supported input interrupts + * @cpus: Per cpu interrupt configuration + * @output_irq: Array of output irq lines + * @input_irq: Array of input irq lines + */ +struct kvx_apic_gic { + raw_spinlock_t lock; + void __iomem *base; + struct irq_domain *domain; + uint32_t input_nr_irqs; + /* For each cpu, there is an output IT line */ + struct gic_out_irq_line output_irq[KVX_GIC_OUTPUT_IT_COUNT]; + /* Input interrupt status */ + struct gic_in_irq_line input_irq[KVX_GIC_INPUT_IT_COUNT]; +}; + +static int gic_parent_irq; + +/** + * Enable/Disable an output irq line + * This function is used by both mask/unmask to disable/enable the line. + */ +static void irq_line_set_enable(struct gic_out_irq_line *irq_line, + struct gic_in_irq_line *in_irq_line, + int enable) +{ + void __iomem *enable_line_addr = irq_line->base + + KVX_GIC_ENABLE_OFFSET + + in_irq_line->it_num * KVX_GIC_ENABLE_ELEM_SIZE; + + writeb((uint8_t) enable ? 1 : 0, enable_line_addr); + in_irq_line->enabled = enable; +} + +static void kvx_apic_gic_set_line(struct irq_data *data, int enable) +{ + struct kvx_apic_gic *gic = irq_data_get_irq_chip_data(data); + unsigned int in_irq = irqd_to_hwirq(data); + struct gic_in_irq_line *in_line = &gic->input_irq[in_irq]; + struct gic_out_irq_line *out_line = in_line->out_line; + + raw_spin_lock(&gic->lock); + /* Set line enable on currently assigned cpu */ + irq_line_set_enable(out_line, in_line, enable); + raw_spin_unlock(&gic->lock); +} + +static void kvx_apic_gic_mask(struct irq_data *data) +{ + kvx_apic_gic_set_line(data, 0); +} + +static void kvx_apic_gic_unmask(struct irq_data *data) +{ + kvx_apic_gic_set_line(data, 1); +} + +#ifdef CONFIG_SMP + +static int kvx_apic_gic_set_affinity(struct irq_data *d, + const struct cpumask *cpumask, + bool force) +{ + struct kvx_apic_gic *gic = irq_data_get_irq_chip_data(d); + unsigned int new_cpu; + unsigned int hw_irq = irqd_to_hwirq(d); + struct gic_in_irq_line *input_line = &gic->input_irq[hw_irq]; + struct gic_out_irq_line *new_out_line; + + /* We assume there is only one cpu in the mask */ + new_cpu = cpumask_first(cpumask); + new_out_line = &gic->output_irq[new_cpu]; + + raw_spin_lock(&gic->lock); + + /* Nothing to do, line is the same */ + if (new_out_line == input_line->out_line) + goto out; + + /* If old line was enabled, enable the new one before disabling + * the old one + */ + if (input_line->enabled) + irq_line_set_enable(new_out_line, input_line, 1); + + /* Disable it on old line */ + irq_line_set_enable(input_line->out_line, input_line, 0); + + /* Assign new output line to input IRQ */ + input_line->out_line = new_out_line; + +out: + raw_spin_unlock(&gic->lock); + + irq_data_update_effective_affinity(d, cpumask_of(new_cpu)); + + return IRQ_SET_MASK_OK; +} +#endif + +static struct irq_chip kvx_apic_gic_chip = { + .name = "kvx apic gic", + .irq_mask = kvx_apic_gic_mask, + .irq_unmask = kvx_apic_gic_unmask, +#ifdef CONFIG_SMP + .irq_set_affinity = kvx_apic_gic_set_affinity, +#endif +}; + +static int kvx_apic_gic_alloc(struct irq_domain *domain, unsigned int virq, + unsigned int nr_irqs, void *args) +{ + int i; + struct irq_fwspec *fwspec = args; + int hwirq = fwspec->param[0]; + + for (i = 0; i < nr_irqs; i++) { + irq_domain_set_info(domain, virq + i, hwirq + i, + &kvx_apic_gic_chip, + domain->host_data, handle_simple_irq, + NULL, NULL); + } + + return 0; +} + +static const struct irq_domain_ops kvx_apic_gic_domain_ops = { + .alloc = kvx_apic_gic_alloc, + .free = irq_domain_free_irqs_common, +}; + +static void irq_line_get_status_lac(struct gic_out_irq_line *out_irq_line, + uint64_t status[KVX_GIC_STATUS_LAC_ARRAY_SIZE]) +{ + int i; + + for (i = 0; i < KVX_GIC_STATUS_LAC_ARRAY_SIZE; i++) { + status[i] = readq(out_irq_line->base + + KVX_GIC_STATUS_LAC_OFFSET + + i * KVX_GIC_STATUS_LAC_ELEM_SIZE); + } +} + +static void kvx_apic_gic_handle_irq(struct irq_desc *desc) +{ + struct kvx_apic_gic *gic_data = irq_desc_get_handler_data(desc); + struct gic_out_irq_line *out_line; + uint64_t status[KVX_GIC_STATUS_LAC_ARRAY_SIZE]; + unsigned long irqn, cascade_irq; + unsigned long cpu = smp_processor_id(); + + out_line = &gic_data->output_irq[cpu]; + + irq_line_get_status_lac(out_line, status); + + for_each_set_bit(irqn, (unsigned long *) status, + KVX_GIC_STATUS_LAC_ARRAY_SIZE * BITS_PER_LONG) { + + cascade_irq = irq_find_mapping(gic_data->domain, irqn); + + generic_handle_irq(cascade_irq); + } +} + +static void __init apic_gic_init(struct kvx_apic_gic *gic) +{ + unsigned int cpu, line; + struct gic_in_irq_line *input_irq_line; + struct gic_out_irq_line *output_irq_line; + uint64_t status[KVX_GIC_STATUS_LAC_ARRAY_SIZE]; + + /* Initialize all input lines (device -> )*/ + for (line = 0; line < KVX_GIC_INPUT_IT_COUNT; line++) { + input_irq_line = &gic->input_irq[line]; + input_irq_line->enabled = false; + /* All input lines map on output 0 */ + input_irq_line->out_line = &gic->output_irq[0]; + input_irq_line->it_num = line; + } + + /* Clear all output lines (-> cpus) */ + for (cpu = 0; cpu < KVX_GIC_OUTPUT_IT_COUNT; cpu++) { + output_irq_line = &gic->output_irq[cpu]; + output_irq_line->cpu = cpu; + output_irq_line->base = gic->base + + cpu * (KVX_GIC_ELEM_SIZE * KVX_GIC_PER_CPU_IT_COUNT); + + /* Disable all external lines on this core */ + for (line = 0; line < KVX_GIC_INPUT_IT_COUNT; line++) + irq_line_set_enable(output_irq_line, + &gic->input_irq[line], 0x0); + + irq_line_get_status_lac(output_irq_line, status); + } +} + +static int kvx_gic_starting_cpu(unsigned int cpu) +{ + enable_percpu_irq(gic_parent_irq, IRQ_TYPE_NONE); + + return 0; +} + +static int kvx_gic_dying_cpu(unsigned int cpu) +{ + disable_percpu_irq(gic_parent_irq); + + return 0; +} + +static int __init kvx_init_apic_gic(struct device_node *node, + struct device_node *parent) +{ + struct kvx_apic_gic *gic; + int ret; + unsigned int irq; + + if (!parent) { + pr_err("kvx apic gic does not have parent\n"); + return -EINVAL; + } + + gic = kzalloc(sizeof(*gic), GFP_KERNEL); + if (!gic) + return -ENOMEM; + + if (of_property_read_u32(node, "kalray,intc-nr-irqs", + &gic->input_nr_irqs)) + gic->input_nr_irqs = KVX_GIC_INPUT_IT_COUNT; + + if (WARN_ON(gic->input_nr_irqs > KVX_GIC_INPUT_IT_COUNT)) { + ret = -EINVAL; + goto err_kfree; + } + + gic->base = of_io_request_and_map(node, 0, node->name); + if (!gic->base) { + ret = -EINVAL; + goto err_kfree; + } + + raw_spin_lock_init(&gic->lock); + apic_gic_init(gic); + + gic->domain = irq_domain_add_linear(node, + gic->input_nr_irqs, + &kvx_apic_gic_domain_ops, + gic); + if (!gic->domain) { + pr_err("Failed to add IRQ domain\n"); + ret = -EINVAL; + goto err_iounmap; + } + + irq = irq_of_parse_and_map(node, 0); + if (irq <= 0) { + pr_err("unable to parse irq\n"); + ret = -EINVAL; + goto err_irq_domain_remove; + } + + irq_set_chained_handler_and_data(irq, kvx_apic_gic_handle_irq, + gic); + + gic_parent_irq = irq; + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, + "kvx/gic:online", + kvx_gic_starting_cpu, + kvx_gic_dying_cpu); + if (ret < 0) { + pr_err("Failed to setup hotplug state"); + goto err_irq_unmap; + } + + return 0; + +err_irq_unmap: + irq_dispose_mapping(irq); +err_irq_domain_remove: + irq_domain_remove(gic->domain); +err_iounmap: + iounmap(gic->base); +err_kfree: + kfree(gic); + + return ret; +} + +IRQCHIP_DECLARE(kvx_apic_gic, "kalray,kvx-apic-gic", kvx_init_apic_gic); -- 2.37.2