Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CCF3C433EF for ; Fri, 24 Dec 2021 09:51:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352345AbhLXJvt (ORCPT ); Fri, 24 Dec 2021 04:51:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343853AbhLXJvs (ORCPT ); Fri, 24 Dec 2021 04:51:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 805AAC061401 for ; Fri, 24 Dec 2021 01:51:48 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 06707B8227A for ; Fri, 24 Dec 2021 09:51:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4FD6C36AE8; Fri, 24 Dec 2021 09:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640339505; bh=5ZBLSnr8id7hvyy51ilunilPWg3IJnArfzyG5Z0ToRM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=M9nlL7aYoz1UvR7uNlasqQAQCKMM8h8ehKg2FwsjieQ4A/jFtcRbfyAmLEadTfqsr O+E3QTa1DX+Cyd+pBw+aabRjrM5peuwzEYc+eLE5kMR3PH5JRXjjTNuGIdHHypzrtq 1lf7LgENNQM7NVAnNDBLFkMWTwnGYV3kidNnkS+kgRzqOlhyryu0ZT/ytyPKmukMcU Ai2o8YC9b7QM0etodl3krzt/5uUshvnabj+PVM2dbk8SGvDspBzlxWINskGIo8NnC3 IfwTXP+mimSoUeqDgVSPOq4CvwXVESk5IF1rGGqO78sv6P/DlkBLb8oU+bAh4ZF/w7 1LStyqSJ/dqTA== Received: from 91-161-240-24.subs.proxad.net ([91.161.240.24] 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.94.2) (envelope-from ) id 1n0hEl-00E6SM-JJ; Fri, 24 Dec 2021 09:51:43 +0000 Date: Fri, 24 Dec 2021 09:51:44 +0000 Message-ID: <87wnjuz5xr.wl-maz@kernel.org> From: Marc Zyngier To: Huacai Chen Cc: Huacai Chen , Thomas Gleixner , LKML , Xuefeng Li , Jiaxun Yang Subject: Re: [PATCH V8 02/10] irqchip/loongson-pch-pic: Add ACPI init support In-Reply-To: References: <20211216125157.631992-1-chenhuacai@loongson.cn> <20211216125356.632067-1-chenhuacai@loongson.cn> <20211216125356.632067-2-chenhuacai@loongson.cn> <87pmpwwpw5.wl-maz@kernel.org> <87czlrwk2k.wl-maz@kernel.org> 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: 91.161.240.24 X-SA-Exim-Rcpt-To: chenhuacai@gmail.com, chenhuacai@loongson.cn, tglx@linutronix.de, linux-kernel@vger.kernel.org, lixuefeng@loongson.cn, 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 Fri, 24 Dec 2021 07:31:53 +0000, Huacai Chen wrote: > > Hi, Marc, > > On Mon, Dec 20, 2021 at 8:13 PM Marc Zyngier wrote: > > > > On Fri, 17 Dec 2021 04:45:24 +0000, > > Huacai Chen wrote: > > > > > > Hi, Marc, > > > > > > On Thu, Dec 16, 2021 at 11:06 PM Marc Zyngier wrote: > > > > > > > > On Thu, 16 Dec 2021 12:53:48 +0000, > > > > Huacai Chen wrote: > > > > > > > > > > We are preparing to add new Loongson (based on LoongArch, not compatible > > > > > with old MIPS-based Loongson) support. LoongArch use ACPI other than DT > > > > > as its boot protocol, so add ACPI init support. > > > > > > > > > > PCH-PIC/PCH-MSI stands for "Interrupt Controller" that described in > > > > > Section 5 of "Loongson 7A1000 Bridge User Manual". For more information > > > > > please refer Documentation/loongarch/irq-chip-model.rst. > > > > > > > > > > Signed-off-by: Huacai Chen > > > > > --- > > > > > drivers/irqchip/irq-loongson-pch-pic.c | 108 ++++++++++++++++++------- > > > > > 1 file changed, 81 insertions(+), 27 deletions(-) > > > > > > > > [...] > > > > > > > > > > > > > > +#ifdef CONFIG_ACPI > > > > > + > > > > > +struct irq_domain *pch_pic_acpi_init(struct irq_domain *parent, > > > > > + struct acpi_madt_bio_pic *acpi_pchpic) > > > > > > > > Who is calling this? This works the opposite way from what the arm64 > > > > irqchips are doing. Why? I have the ugly feeling that this is called > > > > from the arch code, bypassing the existing infrastructure... > > > Yes, this is called from the arch code and a bit ugly, but I can't > > > find a better way to do this. > > > > > > Is the "existing infrastructure" declare the irqchip init function > > > with IRQCHIP_ACPI_DECLARE and the arch code only need to call > > > irqchip_init()? Then we have a problem: our irqchips have a 4 level > > > hierachy and the parent should be initialized before its children. In > > > FDT world this is not a problem, because of_irq_init() will sort > > > irqchip drivers to ensure the right order. But in ACPI world, > > > acpi_probe_device_table just call init functions in the linking order. > > > If we want to control the order, it seems we can only sort the drivers > > > in drivers/irq/Makefile. But I don't think this is a good idea... > > > > > > If there are better solutions, please let me know. Thanks. > > > > We have the exact same thing on the arm64 side, and we don't need of > > this to be arch specific: > > > > - The MADT table describes the root interrupt controller, and it is > > probed via IRQCHIP_ACPI_DECLARE(). > > > > - Each children controller is declared in ACPI as a *device*, and is > > both an interrupt producer and an interrupt consumer. Normal probe > > deferral rules apply. See irq-mbigen.c for an example of how this is > > done. > Thank you for your suggestions, I have tried but failed. It seems > there are some differences between irq-mbigen.c and our irqchips. > Because our irqchips are mandatory while mbigen is optional. The fact that this is optional has nothing to do with it. On a system that requires mbigen to boot (both mass storage and networking are hanging off it), there is a guarantee that the probe order will respect the resource dependency. And if that's not enough, -EPROBE_DEFER is your friend, always. > If we declare our irqchips as devices, they are initialized in the > initcall phase, which is too late for pci devices. This suggests that your PCIe driver is either not enforcing the dependencies on the interrupt controller (bad), or that the core code is not made aware of the dependencies (equally bad). In any case, this needs sorting, because a new architecture should be able to boot without resorting to handcrafted dependencies that will inevitably result in a larger pile of hacks over time. It is much easier to solve it before day-1. M. -- Without deviation from the norm, progress is not possible.