Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1222845iog; Sat, 18 Jun 2022 04:06:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s/k1NePqhCV9soJYO4dVPJHEc9t3EXEXuPV1kJoV0aLiWqBNk/42ZYX+l4IFlk+bssCi5A X-Received: by 2002:a05:6402:5c8:b0:433:545f:a811 with SMTP id n8-20020a05640205c800b00433545fa811mr17684778edx.101.1655550384967; Sat, 18 Jun 2022 04:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655550384; cv=none; d=google.com; s=arc-20160816; b=zZNsDx2og6rDsC+moC0N0kbuFfq0hqgOkQIf6gcjO5TGjO0WsllbN6m2F1J1+9R/vp 3BkwQq/pcn786pDArz3ktv+yqCnB97nmWOWFp6wOL7kRE/e7Kkd8l7LLa5bYROyan/9k 8NallHmmFowZOtAJHXURzM3dfMmE3L+sve47EgCGH9NaCYz1Wv1PPya7Ps02K2LuDVz1 tw9P8HikdSEtnDc3jy1rJUe0lF0A86UAoWjqiKbpSNLO9M/n5JJY103PtdrJZRQdqyVN nPZ5E9cjjzHSKMVosUzP/ioW39ZpH7F3zZomi/HJ71wbI9wklPX/9D1woZ575+u2ingA E6Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=2IaUCZz830VlBc2OKp46CCRvBtdM1f4/rgPimTjCmX8=; b=xD7/bQ1fOiXjLsxXSpsC2kI4/DnUt8+/8CzJDy4EYu7+5SUAzxs7nwQy/j+f4DkAQt Eu0KnKnzerXiKDXjb3AokdriFX0/axmuS5Kd52QK/x5tPbbk4ezZUP/E2jW9CqLMVQh3 BsgdpmK+yzw4SOJlelSHA2ZUgR/URrzOFsPlYlkHgJRcuu+FoPj2C362Hd70k9mOh/NE R1utYKkoAsQnuiCV5PFPkQmOkGdZNgoq5TNtNsXTzUoLlk2pZIF8Do4SHB6C5a61lbd1 YGQ7moVf6RboClZhFueaTZkNAlHu4/bT2Z7v6Ob9fWwt+e6wkFs8DshUCwZ9D23UIkKI gtjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r3s8iTPi; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm14-20020a170907948e00b006f466911fdesi6071263ejc.285.2022.06.18.04.05.58; Sat, 18 Jun 2022 04:06:24 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=r3s8iTPi; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232992AbiFRK7s (ORCPT + 99 others); Sat, 18 Jun 2022 06:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233369AbiFRK7i (ORCPT ); Sat, 18 Jun 2022 06:59:38 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB1D01837E for ; Sat, 18 Jun 2022 03:59:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 263E3CE1795 for ; Sat, 18 Jun 2022 10:59:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 391A3C3411A; Sat, 18 Jun 2022 10:59:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655549973; bh=4uyqZyMJF1Bu5df4KwTP7qqSfBeHSjp9u8ETaVpF/ho=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=r3s8iTPibIJQW2Yr0EEsXan9i12jWGxR+D30WkoWyIJKx0CN0oVkYVqll4gTklOOd +DSLUAjYs4z6+Iewwqve/C6pvd6r3C/LO/2W9EZKHK9Ta7sKGyh+z49tD7+swlEpsP cjRCHlL/V7TVnZpOcPfA+oKEGl88V9Pi6wNFgERWpOK/gESCs8/egQLVma4B1elAri hL4QtgTdcjDLNW1xQ1f6YTVrSTGQ/fmNh1JRwIL+kz12yM2Ik/GbpxcU0HBForJU36 GQJuRhymYJpxTRAU60WD29nOD/zfMwaCosC9A+uAZNhaLIgOc+LQIGrflhIsHUC+sD B9tdvD824U3bQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1o2WAs-001SvI-Vo; Sat, 18 Jun 2022 11:59:31 +0100 Date: Sat, 18 Jun 2022 11:59:32 +0100 Message-ID: <87czf6p78r.wl-maz@kernel.org> From: Marc Zyngier To: Jianmin Lv Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, Hanjun Guo , Lorenzo Pieralisi , Jiaxun Yang , Huacai Chen Subject: Re: [PATCH V12 03/10] irqchip: Add LoongArch CPU interrupt controller support In-Reply-To: <1655273250-23495-4-git-send-email-lvjianmin@loongson.cn> References: <1655273250-23495-1-git-send-email-lvjianmin@loongson.cn> <1655273250-23495-4-git-send-email-lvjianmin@loongson.cn> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: lvjianmin@loongson.cn, tglx@linutronix.de, linux-kernel@vger.kernel.org, guohanjun@huawei.com, lorenzo.pieralisi@arm.com, jiaxun.yang@flygoat.com, chenhuacai@loongson.cn X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Wed, 15 Jun 2022 07:07:23 +0100, Jianmin Lv wrote: > > From: Huacai Chen > > LoongArch CPUINTC stands for CSR.ECFG/CSR.ESTAT and related interrupt > controller that described in Section 7.4 of "LoongArch Reference Manual, > Vol 1". For more information please refer Documentation/loongarch/irq- > chip-model.rst. > > LoongArch CPUINTC has 13 interrupt sources: SWI0~1, HWI0~7, IPI, TI > (Timer) and PCOV (PMC). IRQ mappings of HWI0~7 are configurable (can be > created from DT/ACPI), but IPI, TI (Timer) and PCOV (PMC) are hardcoded > bits, so we define get_xxx_irq() for them. > > Change-Id: I53fb0be768daeeecc90d0ccc0bb0becd3d4e6984 Please drop this Change-Id. The upstream kernel doesn't use Gerrit. > Co-developed-by: Jianmin Lv > Signed-off-by: Jianmin Lv > Signed-off-by: Huacai Chen > --- > drivers/acpi/bus.c | 3 + > drivers/irqchip/Kconfig | 10 +++ > drivers/irqchip/Makefile | 1 + > drivers/irqchip/irq-loongarch-cpu.c | 134 ++++++++++++++++++++++++++++++++++++ > include/linux/acpi.h | 1 + > 5 files changed, 149 insertions(+) > create mode 100644 drivers/irqchip/irq-loongarch-cpu.c > > diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c > index 86fa61a..63fbf00 100644 > --- a/drivers/acpi/bus.c > +++ b/drivers/acpi/bus.c > @@ -1145,6 +1145,9 @@ static int __init acpi_bus_init_irq(void) > case ACPI_IRQ_MODEL_PLATFORM: > message = "platform specific model"; > break; > + case ACPI_IRQ_MODEL_LPIC: > + message = "LPIC"; > + break; This should be part of the patch that deals with the ACPI-specific part of the architecture, which is the following patch. > default: > pr_info("Unknown interrupt routing model\n"); > return -ENODEV; > diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig > index 4ab1038..4126b1c 100644 > --- a/drivers/irqchip/Kconfig > +++ b/drivers/irqchip/Kconfig > @@ -546,6 +546,16 @@ config EXYNOS_IRQ_COMBINER > Say yes here to add support for the IRQ combiner devices embedded > in Samsung Exynos chips. > > +config IRQ_LOONGARCH_CPU > + bool > + select GENERIC_IRQ_CHIP > + select IRQ_DOMAIN > + select GENERIC_IRQ_EFFECTIVE_AFF_MASK > + help > + Support for the LoongArch CPU Interrupt Controller. For details of > + irq chip hierarchy on LoongArch platforms please read the document > + Documentation/loongarch/irq-chip-model.rst. > + > config LOONGSON_LIOINTC > bool "Loongson Local I/O Interrupt Controller" > depends on MACH_LOONGSON64 > diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile > index 5b67450..6894a13 100644 > --- a/drivers/irqchip/Makefile > +++ b/drivers/irqchip/Makefile > @@ -103,6 +103,7 @@ obj-$(CONFIG_LS1X_IRQ) += irq-ls1x.o > obj-$(CONFIG_TI_SCI_INTR_IRQCHIP) += irq-ti-sci-intr.o > obj-$(CONFIG_TI_SCI_INTA_IRQCHIP) += irq-ti-sci-inta.o > obj-$(CONFIG_TI_PRUSS_INTC) += irq-pruss-intc.o > +obj-$(CONFIG_IRQ_LOONGARCH_CPU) += irq-loongarch-cpu.o > obj-$(CONFIG_LOONGSON_LIOINTC) += irq-loongson-liointc.o > obj-$(CONFIG_LOONGSON_HTPIC) += irq-loongson-htpic.o > obj-$(CONFIG_LOONGSON_HTVEC) += irq-loongson-htvec.o > diff --git a/drivers/irqchip/irq-loongarch-cpu.c b/drivers/irqchip/irq-loongarch-cpu.c > new file mode 100644 > index 0000000..c382bd9 > --- /dev/null > +++ b/drivers/irqchip/irq-loongarch-cpu.c > @@ -0,0 +1,134 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include "irq-loongarch-pic-common.h" > + > +static struct irq_domain *irq_domain; > + > +static void mask_loongarch_irq(struct irq_data *d) > +{ > + clear_csr_ecfg(ECFGF(d->hwirq)); > +} > + > +static void unmask_loongarch_irq(struct irq_data *d) > +{ > + set_csr_ecfg(ECFGF(d->hwirq)); > +} > + > +static struct irq_chip cpu_irq_controller = { > + .name = "LoongArch", Why is it "LoongArch" and not "CPUINTC", which would make a lot more sense? > + .irq_mask = mask_loongarch_irq, > + .irq_unmask = unmask_loongarch_irq, > +}; > + > +static void handle_cpu_irq(struct pt_regs *regs) > +{ > + int hwirq; > + unsigned int estat = read_csr_estat() & CSR_ESTAT_IS; > + > + while ((hwirq = ffs(estat))) { > + estat &= ~BIT(hwirq - 1); > + generic_handle_domain_irq(irq_domain, hwirq - 1); > + } > +} > + > +int get_ipi_irq(void) > +{ > + return irq_create_mapping(irq_domain, EXCCODE_IPI - EXCCODE_INT_START); > +} > + > +int get_pmc_irq(void) > +{ > + return irq_create_mapping(irq_domain, EXCCODE_PMC - EXCCODE_INT_START); > +} > + > +int get_timer_irq(void) > +{ > + return irq_create_mapping(irq_domain, EXCCODE_TIMER - EXCCODE_INT_START); > +} > + > +static int loongarch_cpu_intc_map(struct irq_domain *d, unsigned int irq, > + irq_hw_number_t hwirq) > +{ > + irq_set_noprobe(irq); > + irq_set_chip_and_handler(irq, &cpu_irq_controller, handle_percpu_irq); > + > + return 0; > +} > + > +static const struct irq_domain_ops loongarch_cpu_intc_irq_domain_ops = { > + .map = loongarch_cpu_intc_map, > + .xlate = irq_domain_xlate_onecell, > +}; > + > +struct irq_domain * __init loongarch_cpu_irq_init(void) > +{ > + struct fwnode_handle *domain_handle; > + > + /* Mask interrupts. */ > + clear_csr_ecfg(ECFG0_IM); > + clear_csr_estat(ESTATF_IP); > + > + domain_handle = irq_domain_alloc_fwnode(NULL); Please don't use NULL here, as this is supposed to be a physical address. If you don't have any physical address at hand (because this driver isn't using MMIO), use irq_domain_alloc_named_fwnode() instead. > + irq_domain = irq_domain_create_linear(domain_handle, EXCCODE_INT_NUM, > + &loongarch_cpu_intc_irq_domain_ops, NULL); > + > + if (!irq_domain) > + panic("Failed to add irqdomain for LoongArch CPU"); > + > + set_handle_irq(&handle_cpu_irq); > + acpi_set_irq_model(ACPI_IRQ_MODEL_LPIC, lpic_get_gsi_domain_id); lpic_get_gsi_domain_id only gets defined in the following patch, so the series cannot be bisected. Please fix this (the series should compile every step of the way). > + > + return irq_domain; > +} > + > +static int __init > +liointc_parse_madt(union acpi_subtable_headers *header, > + const unsigned long end) > +{ > + struct acpi_madt_lio_pic *liointc_entry = (struct acpi_madt_lio_pic *)header; > + > + return liointc_acpi_init(irq_domain, liointc_entry); > +} > + > +static int __init > +eiointc_parse_madt(union acpi_subtable_headers *header, > + const unsigned long end) > +{ > + struct acpi_madt_eio_pic *eiointc_entry = (struct acpi_madt_eio_pic *)header; > + > + return eiointc_acpi_init(irq_domain, eiointc_entry); > +} > +static int __init acpi_cascade_irqdomain_init(void) > +{ > + acpi_table_parse_madt(ACPI_MADT_TYPE_LIO_PIC, > + liointc_parse_madt, 0); > + acpi_table_parse_madt(ACPI_MADT_TYPE_EIO_PIC, > + eiointc_parse_madt, 0); > + return 0; > +} > +static int __init coreintc_acpi_init_v1(union acpi_subtable_headers *header, > + const unsigned long end) > +{ > + if (irq_domain) > + return 0; > + > + init_vector_parent_group(); > + loongarch_cpu_irq_init(); > + acpi_cascade_irqdomain_init(); > + return 0; > +} > +IRQCHIP_ACPI_DECLARE(coreintc_v1, ACPI_MADT_TYPE_CORE_PIC, > + NULL, ACPI_MADT_CORE_PIC_VERSION_V1, > + coreintc_acpi_init_v1); > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 957e23f..d2f5108 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -105,6 +105,7 @@ enum acpi_irq_model_id { > ACPI_IRQ_MODEL_IOSAPIC, > ACPI_IRQ_MODEL_PLATFORM, > ACPI_IRQ_MODEL_GIC, > + ACPI_IRQ_MODEL_LPIC, This hunk should be moved to the patch that introduces lpic_get_gsi_domain_id. Thanks, M. -- Without deviation from the norm, progress is not possible.