Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp542238pxb; Thu, 30 Sep 2021 11:24:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL5TviMG3whSHmHbOPqGyrPfkFCn0uKtFttwMY/+yS1qcxqyIPF5C3CAI/Z6ZSgwy+50jt X-Received: by 2002:a17:90a:a584:: with SMTP id b4mr8013709pjq.70.1633026262363; Thu, 30 Sep 2021 11:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633026262; cv=none; d=google.com; s=arc-20160816; b=ctc+cER2RprQYONQcbDYpbiCjsn8dF/kYqDuZJb/RsJCw95OxKqFM/Pw+l8vd6M1zJ B1RyeV9+HS2ZtT6HiNB3xZ2jvJ42ZHR24WP52lQ9cWx3X+4dtgPEOz02VXHpVeQUz+PD Z7iRKwOiZNQKRriMGiOA3RF0xk1Pcv5aq29SqeVYjuyG9+VTQTy56WI6Qy9GbCVW6+E7 pZkutaHmQlRLekK7CL3kO4ogiHPfOJp7w2830EKltJo79cPVUVLfHqT4c8a2tAuaAlDh kvLzlCC04Qi1HEJqmc7EEIWrH4fC2f1IJdCRSdJc/l5LlPOBZKA0vWW9jF/HEsh5LkT4 KdDQ== 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; bh=g9GpDE+cSFAXiKATd5HKD+4d5sfwGDc/vFRuG7ssjOo=; b=y8DlegHExtKSRGp6jfsc/0whjllEm3xiriCyTRYR9OEK0MfWNj07PgIqH/0e7DMDTc FGyvPTYOi+KUV4qODTeowOkQ50Vgcj4gUWnoYNz9MxaitgONEmcaMda+D+fU/9qgFbFW EpDb1jZwYzp60DA/06f0lmurRKPlX9j/EOBQzAxQmv/OnHxrNL0djyHGHqLXxqBxecQu sEk+hmO5S6j5Y2op6ypGO+irq9AZA94uCcFHMhmrU7rWUrBoQuOp2twfLD6de01maxwW sg3v/epDzBSQj9jF843W0lmG3NobnKJ0577TdJ5YYZ7/6XKCC7MZH4KYbG9Q38lXJKl9 DtgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si4335200pfj.165.2021.09.30.11.24.08; Thu, 30 Sep 2021 11:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1348401AbhI3O0G (ORCPT + 99 others); Thu, 30 Sep 2021 10:26:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:35098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245591AbhI3O0F (ORCPT ); Thu, 30 Sep 2021 10:26:05 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E10336126A; Thu, 30 Sep 2021 14:24:22 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mVwyz-00E0Ne-7L; Thu, 30 Sep 2021 15:24:21 +0100 Date: Thu, 30 Sep 2021 15:24:20 +0100 Message-ID: <87wnmyrvjf.wl-maz@kernel.org> From: Marc Zyngier To: Huacai Chen Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, Xuefeng Li , Huacai Chen , Jiaxun Yang Subject: Re: [PATCH V5 08/10] irqchip: Add LoongArch CPU interrupt controller support In-Reply-To: <20210916123138.3490474-9-chenhuacai@loongson.cn> References: <20210916123138.3490474-1-chenhuacai@loongson.cn> <20210916123138.3490474-9-chenhuacai@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: chenhuacai@loongson.cn, tglx@linutronix.de, linux-kernel@vger.kernel.org, lixuefeng@loongson.cn, chenhuacai@gmail.com, jiaxun.yang@flygoat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 16 Sep 2021 13:31:36 +0100, Huacai Chen wrote: > > We are preparing to add new Loongson (based on LoongArch, not compatible > with old MIPS-based Loongson) support. This patch add the LoongArch CPU > interrupt controller support. > > Signed-off-by: Huacai Chen > --- > drivers/irqchip/Kconfig | 10 ++++ > drivers/irqchip/Makefile | 1 + > drivers/irqchip/irq-loongarch-cpu.c | 89 +++++++++++++++++++++++++++++ > 3 files changed, 100 insertions(+) > create mode 100644 drivers/irqchip/irq-loongarch-cpu.c > > diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig > index 084bc4c2eebd..443c3a7a0cc1 100644 > --- a/drivers/irqchip/Kconfig > +++ b/drivers/irqchip/Kconfig > @@ -528,6 +528,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 f88cbf36a9d2..4e34eebe180b 100644 > --- a/drivers/irqchip/Makefile > +++ b/drivers/irqchip/Makefile > @@ -105,6 +105,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 000000000000..bc15e3cefbd8 > --- /dev/null > +++ b/drivers/irqchip/irq-loongarch-cpu.c > @@ -0,0 +1,89 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2020-2021 Loongson Technology Corporation Limited > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +static struct irq_domain *irq_domain; > + > +static void mask_loongarch_irq(struct irq_data *d) > +{ > + clear_csr_ecfg(ECFGF(d->hwirq)); Where is this function defined? > +} > + > +static void unmask_loongarch_irq(struct irq_data *d) > +{ > + set_csr_ecfg(ECFGF(d->hwirq)); > +} > + > +static struct irq_chip cpu_irq_controller = { > + .name = "LoongArch", > + .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); > + handle_domain_irq(irq_domain, hwirq - 1, regs); > + } > +} > + > +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); > +} How are these functions used? Why aren't the mappings created using the normal DT or ACPI flows? Where are these macros? > + > +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) > +{ > + /* Mask interrupts. */ > + clear_csr_ecfg(ECFG0_IM); > + clear_csr_estat(ESTATF_IP); > + > + irq_domain = irq_domain_add_simple(NULL, EXCCODE_INT_NUM, This needs to be attached to a firmware node of some sort. > + 0, &loongarch_cpu_intc_irq_domain_ops, NULL); > + > + if (!irq_domain) > + panic("Failed to add irqdomain for LoongArch CPU"); > + > + set_handle_irq(&handle_cpu_irq); > + > + return irq_domain; Who needs to know anything about this irq domain? > +} Given that this refers to all sort of symbols that are not included here and that there is no reference to another patch series containing the missing code, I'm not sure where you want to take this. M. -- Without deviation from the norm, progress is not possible.