Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2713456iog; Mon, 27 Jun 2022 00:58:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tABqjCXiP0cPlbsvQHAYRS0pGCrXE2qR+Fw3oODdTRvOm3s6/6i4nKun1E6CUNZvyue7Lk X-Received: by 2002:a05:6402:26d6:b0:435:ba41:dbb0 with SMTP id x22-20020a05640226d600b00435ba41dbb0mr14836512edd.242.1656316702490; Mon, 27 Jun 2022 00:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656316702; cv=none; d=google.com; s=arc-20160816; b=Alg0AA6s7DN6agDGJtnS93OgDqh3rS1SqOCYWkPoDWXrGL1jAhfUtZCuFx8/gN9s3/ CMB6UoK8Nm8DPQ+OE6EWTEmPwde/L+CAyIWqsZcSPLjksCj8qNg45AN3SECCkrmnWknL vmNi1wC8PrKeq21260QnhvG+SSN60rFSMcXF1SjNfLdY2NBNaccR9+4jnUL1dlwJ3DXF EMBYvRRXClfgSu3P6VBzjs2M7bwM71eJaTZgFbj32n8HfYzMpWMvBTi4F9XtlS1XnANn Fgi4ZSW9B/nKFFmtY0GRBNN0FSNdht9P63lh+y6erZzoFpfu79E+Bm3p2UtYZiZ47AlL EYLA== 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 :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=2d8fbE3wPuOrLPp/oJvlt0kAcZRJaePAj3Oy6YIv6BM=; b=KtHlsfN0RlbACh2srsh/rtFQukWxBW3/g/0Ug/AmO3jNrNgXN5pxJxZ8734fBOau65 kW0IqHAhnkbGrTVtACQhI0LsHskDZsVOUsgTC3dZ6ilPmN/NNGR+BOVCRY2jRzWm+ajt VuBMj5eSP9CnkXW7oJw9h1Y4hNOM2L+4gDHqz0s67DxhkWBE7k9L/sSrVsGCXDQcLQop IX1X9Wqa7oWPM7GGR4owLJvrm3rXeuHs6KVV3ZVj6mwtM6Zrtai2znPGTqx0owmnE2sL SLlsBTGJBMLxt19GwWWk7TBadf+1kUbeBvaIXfDeFRjBeM9QHUhEWgkfhcFLU9LcD3ek A2Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DWY05/sh"; 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 y29-20020a50ce1d000000b0042df81b3afasi5588316edi.411.2022.06.27.00.57.56; Mon, 27 Jun 2022 00:58:22 -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="DWY05/sh"; 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 S232935AbiF0HeU (ORCPT + 99 others); Mon, 27 Jun 2022 03:34:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231752AbiF0HeT (ORCPT ); Mon, 27 Jun 2022 03:34:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DB035F8A for ; Mon, 27 Jun 2022 00:34:18 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B32A961363 for ; Mon, 27 Jun 2022 07:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 188F8C341C8; Mon, 27 Jun 2022 07:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656315257; bh=iZJgRYWbpA+2qbH3u0kTnr7m5AHxYRsfdAzOjEiiypo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DWY05/shMkC0ExmZdyGzyJ0bh0Pj/D2HSzNgM4q1L8F+8oRTOTKWVqrCTkAKkpUjT F5cCC6XiIpAbC+ULiAPZIFARvLt+RtTW2faNoE4RO/uGhRcb4aEKIKdOSEP4n3UZ08 UaHRFQSfSR5lPvCoXWY0omjLmblpiHKl6mi7K7haY4Qd/PIfXMcV4978UdKzVIqVPs GsyY8upzluuPwEZw7Xf2FB49OyCQZTBJeDnXgK/kLUIZ0NEiGDdt5JGxP6hhe3Hmjf b7C0HosgUDJrvbM8+gfjGGthPcuUEjuQYl/hF/IllRfsBFcHuVcI21wmQW6hVyplio J5MdiTIjgzPBQ== 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.95) (envelope-from ) id 1o5jGB-003LO3-2X; Mon, 27 Jun 2022 08:34:15 +0100 Date: Mon, 27 Jun 2022 08:34:14 +0100 Message-ID: <87bkue36h5.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 04/10] irqchip: create library file for LoongArch irqchip driver In-Reply-To: <7fa780d5-406d-6112-e4b4-b56ad291353f@loongson.cn> References: <1655273250-23495-1-git-send-email-lvjianmin@loongson.cn> <1655273250-23495-5-git-send-email-lvjianmin@loongson.cn> <877d5dga4k.wl-maz@kernel.org> <7fa780d5-406d-6112-e4b4-b56ad291353f@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=UTF-8 Content-Transfer-Encoding: quoted-printable 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.5 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 Mon, 20 Jun 2022 04:12:10 +0100, Jianmin Lv wrote: >=20 >=20 >=20 > On 2022/6/19 =E4=B8=8A=E5=8D=881:22, Marc Zyngier wrote: > > On Wed, 15 Jun 2022 07:07:24 +0100, > > Jianmin Lv wrote: > >>=20 > >> The library file contains following content: > >> - Implement acpi_get_gsi_domain_id callback. > >> - Implement initialization of vector group entries and APIs > >> for building hierachy irqdomains. > >>=20 > >> Signed-off-by: Jianmin Lv > >> --- > >> drivers/irqchip/Makefile | 2 +- > >> drivers/irqchip/irq-loongarch-pic-common.c | 122 +++++++++++++++++++= ++++++++++ > >> drivers/irqchip/irq-loongarch-pic-common.h | 39 +++++++++ > >> 3 files changed, 162 insertions(+), 1 deletion(-) > >> create mode 100644 drivers/irqchip/irq-loongarch-pic-common.c > >> create mode 100644 drivers/irqchip/irq-loongarch-pic-common.h > >>=20 > >> diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile > >> index 6894a13..2d0d871 100644 > >> --- a/drivers/irqchip/Makefile > >> +++ b/drivers/irqchip/Makefile > >> @@ -103,7 +103,7 @@ obj-$(CONFIG_LS1X_IRQ) +=3D irq-ls1x.o > >> obj-$(CONFIG_TI_SCI_INTR_IRQCHIP) +=3D irq-ti-sci-intr.o > >> obj-$(CONFIG_TI_SCI_INTA_IRQCHIP) +=3D irq-ti-sci-inta.o > >> obj-$(CONFIG_TI_PRUSS_INTC) +=3D irq-pruss-intc.o > >> -obj-$(CONFIG_IRQ_LOONGARCH_CPU) +=3D irq-loongarch-cpu.o > >> +obj-$(CONFIG_IRQ_LOONGARCH_CPU) +=3D irq-loongarch-cpu.o irq-loongar= ch-pic-common.o > >> obj-$(CONFIG_LOONGSON_LIOINTC) +=3D irq-loongson-liointc.o > >> obj-$(CONFIG_LOONGSON_HTPIC) +=3D irq-loongson-htpic.o > >> obj-$(CONFIG_LOONGSON_HTVEC) +=3D irq-loongson-htvec.o > >> diff --git a/drivers/irqchip/irq-loongarch-pic-common.c b/drivers/irqc= hip/irq-loongarch-pic-common.c > >> new file mode 100644 > >> index 0000000..2f75362 > >> --- /dev/null > >> +++ b/drivers/irqchip/irq-loongarch-pic-common.c > >> @@ -0,0 +1,122 @@ > >> +// SPDX-License-Identifier: GPL-2.0-only > >> +/* > >> + * Copyright (C) 2022 Loongson Limited, All Rights Reserved. > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> +#include "irq-loongarch-pic-common.h" > >> + > >> +static struct acpi_vector_group vector_group[MAX_IO_PICS]; > >> + > >> +struct acpi_madt_bio_pic *acpi_pchpic[MAX_IO_PICS]; > >> + > >> +struct fwnode_handle *liointc_handle; > >> +struct fwnode_handle *pch_lpc_handle; > >> +struct fwnode_handle *pch_msi_handle[MAX_IO_PICS]; > >> +struct fwnode_handle *pch_pic_handle[MAX_IO_PICS]; > >=20 > > Why aren't these in individual drivers, and then have accessors to > > retrieve them? > >=20 >=20 > Ok, I'll try to put them in individual drivers. >=20 >=20 > >> + > >> +static int find_pch_pic(u32 gsi) > >> +{ > >> + int i, start, end; > >> + > >> + /* Find the PCH_PIC that manages this GSI. */ > >> + for (i =3D 0; i < MAX_IO_PICS; i++) { > >> + struct acpi_madt_bio_pic *irq_cfg =3D acpi_pchpic[i]; > >> + > >> + if (!irq_cfg) > >> + return -1; > >> + > >> + start =3D irq_cfg->gsi_base; > >> + end =3D irq_cfg->gsi_base + irq_cfg->size; > >> + if (gsi >=3D start && gsi < end) > >> + return i; > >> + } > >> + > >> + pr_err("ERROR: Unable to locate PCH_PIC for GSI %d\n", gsi); > >> + return -1; > >> +} > >=20 > > Same thing. This really should be in the PCH driver, and be called by > > lpic_get_gsi_domain(). > >=20 >=20 > Ok, I'll try to put them in PCH driver. >=20 >=20 > >> + > >> +struct fwnode_handle *lpic_get_gsi_domain_id(u32 gsi) > >> +{ > >> + int id; > >> + struct fwnode_handle *domain_handle =3D NULL; > >> + > >> + switch (gsi) { > >> + case GSI_MIN_CPU_IRQ ... GSI_MAX_CPU_IRQ: > >> + if (liointc_handle) > >> + domain_handle =3D liointc_handle; > >> + break; > >> + > >> + case GSI_MIN_LPC_IRQ ... GSI_MAX_LPC_IRQ: > >> + if (pch_lpc_handle) > >> + domain_handle =3D pch_lpc_handle; > >> + break; > >> + > >> + case GSI_MIN_PCH_IRQ ... GSI_MAX_PCH_IRQ: > >> + id =3D find_pch_pic(gsi); > >> + if (id >=3D 0 && pch_pic_handle[id]) > >> + domain_handle =3D pch_pic_handle[id]; > >> + > >> + break; > >> + } > >> + > >> + return domain_handle; > >> +} > >> + > >> +static int pci_mcfg_parse(struct acpi_table_header *header) > >> +{ > >> + struct acpi_table_mcfg *mcfg; > >> + struct acpi_mcfg_allocation *mptr; > >> + int i, n; > >> + > >> + if (header->length < sizeof(struct acpi_table_mcfg)) > >> + return -EINVAL; > >> + > >> + n =3D (header->length - sizeof(struct acpi_table_mcfg)) / > >> + sizeof(struct acpi_mcfg_allocation); > >> + mcfg =3D (struct acpi_table_mcfg *)header; > >> + mptr =3D (struct acpi_mcfg_allocation *) &mcfg[1]; > >> + > >> + for (i =3D 0; i < n; i++, mptr++) > >> + vector_group[mptr->pci_segment].node =3D (mptr->address >> 44) & 0x= f; > >> + > >> + return 0; > >> +} > >> + > >> +void __init init_vector_parent_group(void) > >> +{ > >> + acpi_table_parse(ACPI_SIG_MCFG, pci_mcfg_parse); > >> +} > >=20 > > I really don't think the PCI code should be anywhere near > > this. Frankly, this file looks like a dumping ground for totally > > unrelated stuff. > >=20 >=20 >=20 > For ARM, the msi domain of a pci device is matched by comparing PCI > segment of it and PCI segment of msi domain's parent domain(its > domain). > The PCI segment number here is as in MCFG and as returned by _SEG in > the namespace. >=20 > For LoongArch, a similar way is used, but we don't use > IORT-like table, rather, we directly used PCI segment and Base > address(node information is in bit44-47 of the address) in MCFG for > it, so we need to get them by early parsing MCFG before creating MSI > and PCH irqdomain(MSI and PCH irqdomain have the same node as their > parent > irqdomain). >=20 > If the related code is not suitable to be here, Maybe I should put > them in arch/loongarch/kernel/irq.c and call init_vector_parent_group > before irqchip_init(). That'd probably be better. This really is arch-specific stuff, and not interrupt-controller related. M. --=20 Without deviation from the norm, progress is not possible.