Message ID | 20231025202344.581132-7-sunilvl@ventanamicro.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp217788vqb; Wed, 25 Oct 2023 13:25:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqOVr1mZlnWUMaoZ7cX1Woif5zcJxtVBnrIj7neWux5Bv2h+BgaPHNYFBaYBiSZXrPdMtk X-Received: by 2002:a81:4c82:0:b0:5a7:fcad:e865 with SMTP id z124-20020a814c82000000b005a7fcade865mr1308989ywa.2.1698265515279; Wed, 25 Oct 2023 13:25:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698265515; cv=none; d=google.com; s=arc-20160816; b=ijgs0ondcTRs9Byx52FY4u329phZ5Q1pz7UgwW8s9rOojaC1bG9SJC3DIz+jyrlZuz 9pLDIUhIpbaNxqDZ9JANqfSqwQDZh0xL43XCOD6PUJ3xS9Pbxb0z7S/f277LYY5F2Cdi aUAC8O9NaDqDFqW2HnSziOiw0sGwv5vBUmL63su7qiIR5jzhEguX2OE86nYeQBHF2S5q y7MJ7UktySrQpei+NK7GgsjrfO/JBdCg8H7KeEdkKqtDMQSGW1Wk4fCEkKumX1flBhKi apP3BSxfWRehTRVfau7CBUJSPXTe1sVt5tUaO7TpbPY8YIH14lK/OjLrpOPKCSn4OhLF mF6g== 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; bh=GmA5kOKekb5h3Uw1k+e0LhCWijGnTH8utnJ5szxpch8=; fh=/fEAwM0ftwV2z3MN/iSYq1lv8IFPZ2fY8Kg8RoFcxjU=; b=bsGP4Y24rVmAB3L4yvYisvQwTdirnVRNqPvdMgEbOUAtl75y+jVbjRoWaZOwiNkMiQ ASnz198MofYr9bhQEvbWPLLh2mXU2AmfrjyLFK1PtUdaqIhAQTay/yZiyqZ4ln9RXiZc lYq5oyLKZvejQ2+QK0zpXnCeAVSWUxSehaGSr8y430PO2rgsu1ed5Lw0tY+5qgVKWoJu ecmz0icr2ViJSh3fSnEx1yBuDpz+3GBNC6AvGiD9mxheukI7U5Ph8LQyUODhXEzjMyqs bDiL7OrXjy8T2oBaWIgwwUTt/QnbiYuzXfeJ6Cdyk6l4HpOlGS3bFrPnzO3ergiaTJ+k o0OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="auVS/K/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id l15-20020a0de20f000000b005a1ed82af9asi12873186ywe.47.2023.10.25.13.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 13:25:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="auVS/K/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 35B82807C5C3; Wed, 25 Oct 2023 13:25:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234962AbjJYUZA (ORCPT <rfc822;a1648639935@gmail.com> + 25 others); Wed, 25 Oct 2023 16:25:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234693AbjJYUYs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 25 Oct 2023 16:24:48 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6834D4A for <linux-kernel@vger.kernel.org>; Wed, 25 Oct 2023 13:24:43 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-577fff1cae6so96832a12.1 for <linux-kernel@vger.kernel.org>; Wed, 25 Oct 2023 13:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698265483; x=1698870283; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GmA5kOKekb5h3Uw1k+e0LhCWijGnTH8utnJ5szxpch8=; b=auVS/K/Jk7vgky4MjvSPyw3256thHNswIFM0+CHRJfw8cZMbSsKDL7aCq9OiRUFHIn vhqWb1Ba0aPYiVgfisYHsfrxFFdjBfLbOs15MAzbLhPHxuRqT5s81JCMSPHp7u4BnRry 2ZPfCe8yqF4CGCh/KyUFfF2HFzYkNOEEm7i8nBl2N857thL2U0IW97wJcK88BIZUrGVV OYTNiUslB8+H3xiH1zs8mwP083VVwgO4yBf3eLBh2Fzc2+Waue+65NOTaD2v8RT8lmcd FXE3K1JffCz/cOrAvDcRniAps0d0N0MF3sseo29l7YXpoM1uetpW//TUo52Ge7kHw90C KoUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698265483; x=1698870283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GmA5kOKekb5h3Uw1k+e0LhCWijGnTH8utnJ5szxpch8=; b=cwsUJ8u2ud2so69Osh17GWsyDu6kpqlDiwv1/v8oJBweNBamMKFdO/BetxhXEzMtxs i3l2LJXseL8f6lE555Jr/mhkXGJCWr+2pIOi8qUe9swqEExov8DAvYUZTs7h9MbNPTY4 llN/ODRwkkLrAfJ1bT7LeWeHyYlX2QijlfFQyXgT2DkvSs2qrXtJiIgMhlVqgCNk5HXZ q3rsEVQifVeesoekcOne0DMKwQLwqeHPHorJdo4x+IdL7/T1Ds3r9v9b+qY8JL6jn7Ej Fi4ppm9DFrzQxTPRt+RbPAld0t59MnKGCMhdYLmBSnsTVVEZRm1DDdi8y6+1rbHmsJfT u4vA== X-Gm-Message-State: AOJu0Yxa2D5CnPV1isv2BzvZUccVQnAYBO3jioWd46Bixg1PYZhuGgnn tDZ+EIt6INmUrO/AfInKteaHFQ== X-Received: by 2002:a05:6a21:999c:b0:17a:f4b6:bf89 with SMTP id ve28-20020a056a21999c00b0017af4b6bf89mr713082pzb.31.1698265483317; Wed, 25 Oct 2023 13:24:43 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id y3-20020aa79423000000b006b84ed9371esm10079590pfo.177.2023.10.25.13.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 13:24:42 -0700 (PDT) From: Sunil V L <sunilvl@ventanamicro.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org Cc: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, "Rafael J . Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org>, Bjorn Helgaas <bhelgaas@google.com>, Anup Patel <anup@brainfault.org>, Thomas Gleixner <tglx@linutronix.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, Conor Dooley <conor.dooley@microchip.com>, Andrew Jones <ajones@ventanamicro.com>, Atish Kumar Patra <atishp@rivosinc.com>, Haibo Xu <haibo1.xu@intel.com>, Sunil V L <sunilvl@ventanamicro.com> Subject: [RFC PATCH v2 06/21] RISC-V: Kconfig: Select deferred GSI probe for ACPI systems Date: Thu, 26 Oct 2023 01:53:29 +0530 Message-Id: <20231025202344.581132-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231025202344.581132-1-sunilvl@ventanamicro.com> References: <20231025202344.581132-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 25 Oct 2023 13:25:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780760460739987256 X-GMAIL-MSGID: 1780760460739987256 |
Series |
RISC-V: ACPI: Add external interrupt controller support
|
|
Commit Message
Sunil V L
Oct. 25, 2023, 8:23 p.m. UTC
On RISC-V platforms, apart from root interrupt controllers (which
provide local interrupts and IPI), other interrupt controllers in the
hierarchy are probed late. Enable this select this CONFIG option for
RISC-V platforms so that device drivers which connect to deferred
interrupt controllers can take appropriate action.
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
arch/riscv/Kconfig | 1 +
1 file changed, 1 insertion(+)
Comments
On Thu, Oct 26, 2023 at 01:53:29AM +0530, Sunil V L wrote: > On RISC-V platforms, apart from root interrupt controllers (which > provide local interrupts and IPI), other interrupt controllers in the > hierarchy are probed late. Enable this select this CONFIG option for > RISC-V platforms so that device drivers which connect to deferred > interrupt controllers can take appropriate action. Quite a bit of this series seems related to the question of interrupt controllers being probed "late". I don't see anything specific about *how* late this might be, but from the use of -EPROBE_DEFER in individual drivers (8250_pnp explicitly, and acpi_register_gsi() and pnp_irq() and acpi_pci_irq_enable(), which are called from driver .probe() paths) it seems like interrupt controllers might be detected even after devices that use them. That seems like a fairly invasive change to the driver probe flow. If we really need to do that, I think it might merit a little more background as justification since we haven't had to do it for any other arch yet. Bjorn > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > --- > arch/riscv/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 8c105a151e12..b62441aefa6a 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -12,6 +12,7 @@ config 32BIT > > config RISCV > def_bool y > + select ARCH_ACPI_DEFERRED_GSI if ACPI > select ACPI_GENERIC_GSI if ACPI > select ACPI_MCFG if (ACPI && PCI) > select ACPI_REDUCED_HARDWARE_ONLY if ACPI > -- > 2.39.2 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Thu, Oct 26, 2023 at 12:04:08PM -0500, Bjorn Helgaas wrote: > On Thu, Oct 26, 2023 at 01:53:29AM +0530, Sunil V L wrote: > > On RISC-V platforms, apart from root interrupt controllers (which > > provide local interrupts and IPI), other interrupt controllers in the > > hierarchy are probed late. Enable this select this CONFIG option for > > RISC-V platforms so that device drivers which connect to deferred > > interrupt controllers can take appropriate action. > > Quite a bit of this series seems related to the question of interrupt > controllers being probed "late". > > I don't see anything specific about *how* late this might be, but from > the use of -EPROBE_DEFER in individual drivers (8250_pnp explicitly, > and acpi_register_gsi() and pnp_irq() and acpi_pci_irq_enable(), which > are called from driver .probe() paths) it seems like interrupt > controllers might be detected even after devices that use them. > > That seems like a fairly invasive change to the driver probe flow. > If we really need to do that, I think it might merit a little more > background as justification since we haven't had to do it for any > other arch yet. > Hi Bjorn, In RISC-V, the APLIC can be a converter from wired (GSI) to MSI interrupts. Hence, especially in this mode, it has to be a platform device to use device MSI domain. Also, according to Marc Zyngier there is no reason to probe interrupt controllers early apart from root controller. So, the device drivers which use wired interrupts need to be probed after APLIC. The PNP devices and PCI INTx GSI links use either acpi_dev_resource_interrupt() (PNP) or acpi_register_gsi() directly (PCI). The approach taken here is to follow the example of acpi_irq_get() which is enhanced to return EPROBE_DEFER and several platform device drivers which use platform_get_irq() seem to be handling this already. Using ResourceSource dependency (mbigen uses) in the namespace as part of Extended Interrupt Descriptor will not ensure the order since PNP/INTx GSI devices don't work with that. Is there any other better way to create dependency between IO devices and the interrupt controllers when interrupt controller itself is a platform device? While using core_initcall() for interrupt controllers seem to work which forces the interrupt controller to be probed first, Marc is not in favor of that approach since it is fragile. Thanks a lot for your help with review and feedback! Sunil
On Fri, Oct 27, 2023 at 06:25:03PM +0530, Sunil V L wrote: > On Thu, Oct 26, 2023 at 12:04:08PM -0500, Bjorn Helgaas wrote: > > On Thu, Oct 26, 2023 at 01:53:29AM +0530, Sunil V L wrote: > > > On RISC-V platforms, apart from root interrupt controllers (which > > > provide local interrupts and IPI), other interrupt controllers in the > > > hierarchy are probed late. Enable this select this CONFIG option for > > > RISC-V platforms so that device drivers which connect to deferred > > > interrupt controllers can take appropriate action. > > > > Quite a bit of this series seems related to the question of interrupt > > controllers being probed "late". > > > > I don't see anything specific about *how* late this might be, but from > > the use of -EPROBE_DEFER in individual drivers (8250_pnp explicitly, > > and acpi_register_gsi() and pnp_irq() and acpi_pci_irq_enable(), which > > are called from driver .probe() paths) it seems like interrupt > > controllers might be detected even after devices that use them. > > > > That seems like a fairly invasive change to the driver probe flow. > > If we really need to do that, I think it might merit a little more > > background as justification since we haven't had to do it for any > > other arch yet. > > In RISC-V, the APLIC can be a converter from wired (GSI) to MSI interrupts. > Hence, especially in this mode, it has to be a platform device to use > device MSI domain. Also, according to Marc Zyngier there is no reason to > probe interrupt controllers early apart from root controller. So, the > device drivers which use wired interrupts need to be probed after APLIC. > > The PNP devices and PCI INTx GSI links use either > acpi_dev_resource_interrupt() (PNP) or acpi_register_gsi() directly > (PCI). The approach taken here is to follow the example of > acpi_irq_get() which is enhanced to return EPROBE_DEFER and several > platform device drivers which use platform_get_irq() seem to be handling > this already. This series (patch 04/21 "ACPI: irq: Add support for deferred probe in acpi_register_gsi()" [1]) makes acpi_register_gsi() return -EPROBE_DEFER, which percolates up through pci_enable_device(). Maybe that's ok, but this affects *all* PCI drivers, and it's a new case that did not occur before. Many drivers emit warning or error messages for any pci_enable_device() failure, which you probably don't want in this case, since -EPROBE_DEFER is not really a "failure"; IIUC, it just means "probe again later." > Using ResourceSource dependency (mbigen uses) in the namespace as part of > Extended Interrupt Descriptor will not ensure the order since PNP/INTx > GSI devices don't work with that. Are these PNP/INTx GSI devices described in ACPI? In the namespace? Or in a static table? > Is there any other better way to create dependency between IO devices > and the interrupt controllers when interrupt controller itself is a > platform device? While using core_initcall() for interrupt controllers > seem to work which forces the interrupt controller to be probed first, > Marc is not in favor of that approach since it is fragile. I guess PCI interrupts from the PCI host bridges (PNP0A03 devices) feed into the APLIC? And APLIC is described via MADT? Based on this series, it looks like this: acpi_init + acpi_riscv_init + riscv_acpi_aplic_platform_init + acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, aplic_parse_madt, 0) acpi_scan_init acpi_pci_root_init acpi_pci_link_init acpi_bus_scan # add PCI host bridges, etc If that's the sequence, it looks like aplic_parse_madt() should be called before the PCI host bridges are added. Or maybe this isn't how the APLICs are enumerated? Bjorn [1] https://lore.kernel.org/r/20231025202344.581132-5-sunilvl@ventanamicro.com
Hi Bjorn, On Mon, Nov 06, 2023 at 04:16:06PM -0600, Bjorn Helgaas wrote: > On Fri, Oct 27, 2023 at 06:25:03PM +0530, Sunil V L wrote: > > On Thu, Oct 26, 2023 at 12:04:08PM -0500, Bjorn Helgaas wrote: > > > On Thu, Oct 26, 2023 at 01:53:29AM +0530, Sunil V L wrote: > > > > On RISC-V platforms, apart from root interrupt controllers (which > > > > provide local interrupts and IPI), other interrupt controllers in the > > > > hierarchy are probed late. Enable this select this CONFIG option for > > > > RISC-V platforms so that device drivers which connect to deferred > > > > interrupt controllers can take appropriate action. > > > > > > Quite a bit of this series seems related to the question of interrupt > > > controllers being probed "late". > > > > > > I don't see anything specific about *how* late this might be, but from > > > the use of -EPROBE_DEFER in individual drivers (8250_pnp explicitly, > > > and acpi_register_gsi() and pnp_irq() and acpi_pci_irq_enable(), which > > > are called from driver .probe() paths) it seems like interrupt > > > controllers might be detected even after devices that use them. > > > > > > That seems like a fairly invasive change to the driver probe flow. > > > If we really need to do that, I think it might merit a little more > > > background as justification since we haven't had to do it for any > > > other arch yet. > > > > In RISC-V, the APLIC can be a converter from wired (GSI) to MSI interrupts. > > Hence, especially in this mode, it has to be a platform device to use > > device MSI domain. Also, according to Marc Zyngier there is no reason to > > probe interrupt controllers early apart from root controller. So, the > > device drivers which use wired interrupts need to be probed after APLIC. > > > > The PNP devices and PCI INTx GSI links use either > > acpi_dev_resource_interrupt() (PNP) or acpi_register_gsi() directly > > (PCI). The approach taken here is to follow the example of > > acpi_irq_get() which is enhanced to return EPROBE_DEFER and several > > platform device drivers which use platform_get_irq() seem to be handling > > this already. > > This series (patch 04/21 "ACPI: irq: Add support for deferred probe in > acpi_register_gsi()" [1]) makes acpi_register_gsi() return > -EPROBE_DEFER, which percolates up through pci_enable_device(). > > Maybe that's ok, but this affects *all* PCI drivers, and it's a new > case that did not occur before. Many drivers emit warning or error > messages for any pci_enable_device() failure, which you probably don't > want in this case, since -EPROBE_DEFER is not really a "failure"; > IIUC, it just means "probe again later." > Yeah, I think all the drivers which need to be supported on RISC-V ACPI based systems will have to support deferred probe with this scheme. > > Using ResourceSource dependency (mbigen uses) in the namespace as part of > > Extended Interrupt Descriptor will not ensure the order since PNP/INTx > > GSI devices don't work with that. > > Are these PNP/INTx GSI devices described in ACPI? In the namespace? > Or in a static table? > Yes, these are standard devices in the namespace. For ex: PNP0501(16550) or PNP0C0F (PCI interrupt link devices) are in the namespace. > > Is there any other better way to create dependency between IO devices > > and the interrupt controllers when interrupt controller itself is a > > platform device? While using core_initcall() for interrupt controllers > > seem to work which forces the interrupt controller to be probed first, > > Marc is not in favor of that approach since it is fragile. > > I guess PCI interrupts from the PCI host bridges (PNP0A03 devices) > feed into the APLIC? And APLIC is described via MADT? Based on this > series, it looks like this: > > acpi_init > + acpi_riscv_init > + riscv_acpi_aplic_platform_init > + acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, aplic_parse_madt, 0) > acpi_scan_init > acpi_pci_root_init > acpi_pci_link_init > acpi_bus_scan # add PCI host bridges, etc > > If that's the sequence, it looks like aplic_parse_madt() should be > called before the PCI host bridges are added. > > Or maybe this isn't how the APLICs are enumerated? > That's partly correct. APLIC platform devices are created prior to PCI host bridges added. But the actual APLIC driver which creates the irqdomain will be probed as a regular platform driver for the APLIC device. The platform driver probe will happen using DD framework and devices don't have any dependency on APLIC which can cause device probe prior to APLIC driver probe. DT supports fw_devlink framework which makes it easier for IRQ devices to use regular platform drivers and produces-consumers are probed in the order without requiring drivers to do deferred probe. But I don't see that supported for ACPI framework. Also, the way PNP devices get added there is an assumption that interrupt controller is already setup fully. With this new use case in RISC-V, here are the alternatives I am aware of. 1) Use core_initcall() in the APLIC drivers which makes APLIC driver to be probed prior to PNP or PCI INTx devices. But this was ruled out in the context of DT from Marc. 2) Like the approach tried in this series, add support for deferred probe in drivers. This will be invasive change requiring many drivers to change like you pointed. I don't know which is less evil or if there is any other alternative which I am not aware of. Thomas/Marc, could you allow APLIC (and PLIC) irqchip drivers to use core_initcall() for ACPI? Thanks, Sunil
On Wed, 08 Nov 2023 09:53:14 +0000, Sunil V L <sunilvl@ventanamicro.com> wrote: > > That's partly correct. APLIC platform devices are created prior to PCI > host bridges added. But the actual APLIC driver which creates the > irqdomain will be probed as a regular platform driver for the APLIC > device. The platform driver probe will happen using DD framework and > devices don't have any dependency on APLIC which can cause device probe > prior to APLIC driver probe. > > DT supports fw_devlink framework which makes it easier for IRQ devices > to use regular platform drivers and produces-consumers are probed in the > order without requiring drivers to do deferred probe. But I don't see > that supported for ACPI framework. Also, the way PNP devices get added > there is an assumption that interrupt controller is already setup fully. > > With this new use case in RISC-V, here are the alternatives I am aware of. > > 1) Use core_initcall() in the APLIC drivers which makes APLIC driver to > be probed prior to PNP or PCI INTx devices. But this was ruled out in > the context of DT from Marc. > > 2) Like the approach tried in this series, add support for deferred > probe in drivers. This will be invasive change requiring many drivers to > change like you pointed. > > I don't know which is less evil or if there is any other alternative > which I am not aware of. > > Thomas/Marc, could you allow APLIC (and PLIC) irqchip drivers to use > core_initcall() for ACPI? I don't have a say about this anymore, so this is only a passing comment, which you are free to cast aside. My personal view is that if you need to rely on core_initcall() for a particular firmware interface, then your architecture will end-up being an unmaintainable ball of hacks, with conflicting requirements and increasingly diverging behaviours. Those who had the 'privilege' to deal with the 32bit ARM transition to DT will understand what I mean. Having to rely on initcalls can only mean two things: - you're missing crucial topology information that will eventually bite you where it hurts, and you're better off going back to the drawing board to fix it before any HW ships, - you're not making use of the kernel's dependency management infrastructure, which is pretty sad. Yes, it is DT specific for now, but nothing prevents you from improving it to make it grok another firmware interface. But as I said, I don't have much skin in that game anymore. M.
Hi Sunil! I'm trying to decipher this thread, so apologies in advance for the stupid questions! :-P Sunil V L <sunilvl@ventanamicro.com> writes: > Hi Bjorn, > > On Mon, Nov 06, 2023 at 04:16:06PM -0600, Bjorn Helgaas wrote: >> On Fri, Oct 27, 2023 at 06:25:03PM +0530, Sunil V L wrote: >> > On Thu, Oct 26, 2023 at 12:04:08PM -0500, Bjorn Helgaas wrote: >> > > On Thu, Oct 26, 2023 at 01:53:29AM +0530, Sunil V L wrote: >> > > > On RISC-V platforms, apart from root interrupt controllers (which >> > > > provide local interrupts and IPI), other interrupt controllers in the >> > > > hierarchy are probed late. Enable this select this CONFIG option for >> > > > RISC-V platforms so that device drivers which connect to deferred >> > > > interrupt controllers can take appropriate action. >> > > >> > > Quite a bit of this series seems related to the question of interrupt >> > > controllers being probed "late". >> > > >> > > I don't see anything specific about *how* late this might be, but from >> > > the use of -EPROBE_DEFER in individual drivers (8250_pnp explicitly, >> > > and acpi_register_gsi() and pnp_irq() and acpi_pci_irq_enable(), which >> > > are called from driver .probe() paths) it seems like interrupt >> > > controllers might be detected even after devices that use them. >> > > >> > > That seems like a fairly invasive change to the driver probe flow. >> > > If we really need to do that, I think it might merit a little more >> > > background as justification since we haven't had to do it for any >> > > other arch yet. >> > >> > In RISC-V, the APLIC can be a converter from wired (GSI) to MSI interrupts. >> > Hence, especially in this mode, it has to be a platform device to use >> > device MSI domain. Also, according to Marc Zyngier there is no reason to >> > probe interrupt controllers early apart from root controller. So, the >> > device drivers which use wired interrupts need to be probed after APLIC. >> > >> > The PNP devices and PCI INTx GSI links use either >> > acpi_dev_resource_interrupt() (PNP) or acpi_register_gsi() directly >> > (PCI). The approach taken here is to follow the example of >> > acpi_irq_get() which is enhanced to return EPROBE_DEFER and several >> > platform device drivers which use platform_get_irq() seem to be handling >> > this already. >> >> This series (patch 04/21 "ACPI: irq: Add support for deferred probe in >> acpi_register_gsi()" [1]) makes acpi_register_gsi() return >> -EPROBE_DEFER, which percolates up through pci_enable_device(). >> >> Maybe that's ok, but this affects *all* PCI drivers, and it's a new >> case that did not occur before. Many drivers emit warning or error >> messages for any pci_enable_device() failure, which you probably don't >> want in this case, since -EPROBE_DEFER is not really a "failure"; >> IIUC, it just means "probe again later." >> > Yeah, I think all the drivers which need to be supported on RISC-V > ACPI based systems will have to support deferred probe with this scheme. > >> > Using ResourceSource dependency (mbigen uses) in the namespace as part of >> > Extended Interrupt Descriptor will not ensure the order since PNP/INTx >> > GSI devices don't work with that. >> >> Are these PNP/INTx GSI devices described in ACPI? In the namespace? >> Or in a static table? >> > Yes, these are standard devices in the namespace. For ex: PNP0501(16550) > or PNP0C0F (PCI interrupt link devices) are in the namespace. > >> > Is there any other better way to create dependency between IO devices >> > and the interrupt controllers when interrupt controller itself is a >> > platform device? While using core_initcall() for interrupt controllers >> > seem to work which forces the interrupt controller to be probed first, >> > Marc is not in favor of that approach since it is fragile. >> >> I guess PCI interrupts from the PCI host bridges (PNP0A03 devices) >> feed into the APLIC? And APLIC is described via MADT? Based on this >> series, it looks like this: >> >> acpi_init >> + acpi_riscv_init >> + riscv_acpi_aplic_platform_init >> + acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, aplic_parse_madt, 0) >> acpi_scan_init >> acpi_pci_root_init >> acpi_pci_link_init >> acpi_bus_scan # add PCI host bridges, etc >> >> If that's the sequence, it looks like aplic_parse_madt() should be >> called before the PCI host bridges are added. >> >> Or maybe this isn't how the APLICs are enumerated? >> > That's partly correct. APLIC platform devices are created prior to PCI > host bridges added. But the actual APLIC driver which creates the > irqdomain will be probed as a regular platform driver for the APLIC > device. The platform driver probe will happen using DD framework and > devices don't have any dependency on APLIC which can cause device probe > prior to APLIC driver probe. > > DT supports fw_devlink framework which makes it easier for IRQ devices > to use regular platform drivers and produces-consumers are probed in the > order without requiring drivers to do deferred probe. But I don't see > that supported for ACPI framework. Also, the way PNP devices get added > there is an assumption that interrupt controller is already setup fully. AFAIU, the -EPROBE_DEFER changes are needed for GSIs (and the way the IMSIC/APLIC irqchip series is structured), right? There's a couple of separate pieces in play here: 1. IMSIC-IPI (MADT init) 2. IMSIC-MSI (MADT init, imsic_platform_acpi_probe() patch 14) 3. APLIC-wired (platform) 4. APLIC-MSI-bridge (platform) APLIC-MSI-bridge is pretty much a RISC-V mbigen. Some devices do not have ResourceSource parsing implemented yet. The PNP devices that cannot use ResourceSource (you mention PNP0501 (16550) and PNP0C0F (PCI interrupt link devices), do we really need to care about them for the RISC-V platforms using ACPI? If that would change, the kernel drivers can be adjusted (d44fa3d46079 ("ACPI: Add support for ResourceSource/IRQ domain mapping"))? I guess my question is we need to care about GSIs w/o explicit ResourceSource, so that APLIC-MSI-bridge can be used. GED works nicely with ResourceSource, and covers a lot of the GSI use-cases, no? And if we do care, then *both* 3 and 4 would need at MADT scan point/init, and not be a platform device (late init). From my, probably naive perspective, it's a bit weird *not* to create the irq domains at MADT scan time. > With this new use case in RISC-V, here are the alternatives I am aware of. > > 1) Use core_initcall() in the APLIC drivers which makes APLIC driver to > be probed prior to PNP or PCI INTx devices. But this was ruled out in > the context of DT from Marc. > > 2) Like the approach tried in this series, add support for deferred > probe in drivers. This will be invasive change requiring many drivers to > change like you pointed. Again is this only for GSIs? Patch 14 moves the IMSIC-MSI init to MADT for PCIe devices (which is different from DT), so it's not for PCIe devices. I wonder if it's a lot of churn for something that will not be used for RISC-V ACPI systems... A quick look at what Arm's GICv3 does, all irq domains are created at MADT init. Björn (no, not PCI-Bjorn ;-))
Hi Björn!, Apologies for the delay in response. Held up with something else. On Wed, Nov 22, 2023 at 01:22:56PM +0100, Björn Töpel wrote: > Hi Sunil! > > I'm trying to decipher this thread, so apologies in advance for the > stupid questions! :-P > Appreciate your help to review the patch and suggesting solutions. Thank you very much!. > Sunil V L <sunilvl@ventanamicro.com> writes: > > > Hi Bjorn, > > > > On Mon, Nov 06, 2023 at 04:16:06PM -0600, Bjorn Helgaas wrote: > >> On Fri, Oct 27, 2023 at 06:25:03PM +0530, Sunil V L wrote: > >> > On Thu, Oct 26, 2023 at 12:04:08PM -0500, Bjorn Helgaas wrote: > >> > > On Thu, Oct 26, 2023 at 01:53:29AM +0530, Sunil V L wrote: > >> > > > On RISC-V platforms, apart from root interrupt controllers (which > >> > > > provide local interrupts and IPI), other interrupt controllers in the > >> > > > hierarchy are probed late. Enable this select this CONFIG option for > >> > > > RISC-V platforms so that device drivers which connect to deferred > >> > > > interrupt controllers can take appropriate action. > >> > > > >> > > Quite a bit of this series seems related to the question of interrupt > >> > > controllers being probed "late". > >> > > > >> > > I don't see anything specific about *how* late this might be, but from > >> > > the use of -EPROBE_DEFER in individual drivers (8250_pnp explicitly, > >> > > and acpi_register_gsi() and pnp_irq() and acpi_pci_irq_enable(), which > >> > > are called from driver .probe() paths) it seems like interrupt > >> > > controllers might be detected even after devices that use them. > >> > > > >> > > That seems like a fairly invasive change to the driver probe flow. > >> > > If we really need to do that, I think it might merit a little more > >> > > background as justification since we haven't had to do it for any > >> > > other arch yet. > >> > > >> > In RISC-V, the APLIC can be a converter from wired (GSI) to MSI interrupts. > >> > Hence, especially in this mode, it has to be a platform device to use > >> > device MSI domain. Also, according to Marc Zyngier there is no reason to > >> > probe interrupt controllers early apart from root controller. So, the > >> > device drivers which use wired interrupts need to be probed after APLIC. > >> > > >> > The PNP devices and PCI INTx GSI links use either > >> > acpi_dev_resource_interrupt() (PNP) or acpi_register_gsi() directly > >> > (PCI). The approach taken here is to follow the example of > >> > acpi_irq_get() which is enhanced to return EPROBE_DEFER and several > >> > platform device drivers which use platform_get_irq() seem to be handling > >> > this already. > >> > >> This series (patch 04/21 "ACPI: irq: Add support for deferred probe in > >> acpi_register_gsi()" [1]) makes acpi_register_gsi() return > >> -EPROBE_DEFER, which percolates up through pci_enable_device(). > >> > >> Maybe that's ok, but this affects *all* PCI drivers, and it's a new > >> case that did not occur before. Many drivers emit warning or error > >> messages for any pci_enable_device() failure, which you probably don't > >> want in this case, since -EPROBE_DEFER is not really a "failure"; > >> IIUC, it just means "probe again later." > >> > > Yeah, I think all the drivers which need to be supported on RISC-V > > ACPI based systems will have to support deferred probe with this scheme. > > > >> > Using ResourceSource dependency (mbigen uses) in the namespace as part of > >> > Extended Interrupt Descriptor will not ensure the order since PNP/INTx > >> > GSI devices don't work with that. > >> > >> Are these PNP/INTx GSI devices described in ACPI? In the namespace? > >> Or in a static table? > >> > > Yes, these are standard devices in the namespace. For ex: PNP0501(16550) > > or PNP0C0F (PCI interrupt link devices) are in the namespace. > > > >> > Is there any other better way to create dependency between IO devices > >> > and the interrupt controllers when interrupt controller itself is a > >> > platform device? While using core_initcall() for interrupt controllers > >> > seem to work which forces the interrupt controller to be probed first, > >> > Marc is not in favor of that approach since it is fragile. > >> > >> I guess PCI interrupts from the PCI host bridges (PNP0A03 devices) > >> feed into the APLIC? And APLIC is described via MADT? Based on this > >> series, it looks like this: > >> > >> acpi_init > >> + acpi_riscv_init > >> + riscv_acpi_aplic_platform_init > >> + acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, aplic_parse_madt, 0) > >> acpi_scan_init > >> acpi_pci_root_init > >> acpi_pci_link_init > >> acpi_bus_scan # add PCI host bridges, etc > >> > >> If that's the sequence, it looks like aplic_parse_madt() should be > >> called before the PCI host bridges are added. > >> > >> Or maybe this isn't how the APLICs are enumerated? > >> > > That's partly correct. APLIC platform devices are created prior to PCI > > host bridges added. But the actual APLIC driver which creates the > > irqdomain will be probed as a regular platform driver for the APLIC > > device. The platform driver probe will happen using DD framework and > > devices don't have any dependency on APLIC which can cause device probe > > prior to APLIC driver probe. > > > > DT supports fw_devlink framework which makes it easier for IRQ devices > > to use regular platform drivers and produces-consumers are probed in the > > order without requiring drivers to do deferred probe. But I don't see > > that supported for ACPI framework. Also, the way PNP devices get added > > there is an assumption that interrupt controller is already setup fully. > > AFAIU, the -EPROBE_DEFER changes are needed for GSIs (and the way the > IMSIC/APLIC irqchip series is structured), right? > Yes, It is only for GSI's. > There's a couple of separate pieces in play here: > 1. IMSIC-IPI (MADT init) > 2. IMSIC-MSI (MADT init, imsic_platform_acpi_probe() patch 14) > 3. APLIC-wired (platform) > 4. APLIC-MSI-bridge (platform) > > APLIC-MSI-bridge is pretty much a RISC-V mbigen. > > Some devices do not have ResourceSource parsing implemented yet. The PNP > devices that cannot use ResourceSource (you mention PNP0501 (16550) and > PNP0C0F (PCI interrupt link devices), do we really need to care about > them for the RISC-V platforms using ACPI? If that would change, the > kernel drivers can be adjusted (d44fa3d46079 ("ACPI: Add support for > ResourceSource/IRQ domain mapping"))? > > I guess my question is we need to care about GSIs w/o explicit > ResourceSource, so that APLIC-MSI-bridge can be used. > > GED works nicely with ResourceSource, and covers a lot of the GSI > use-cases, no? > > And if we do care, then *both* 3 and 4 would need at MADT scan > point/init, and not be a platform device (late init). > I am not sure it is a good idea not to support PCI link devices. Not allowing them removes the flexibility in _PRT. Also, is there a standard 16550 UART apart from PNP0501? ACPI platform devices already support deferred probe as per the series you mentioned. IMO, PNP also should support it. So, I am not sure it is a good idea to prohibit all PnP devices on RISC-V platforms. Other OS's might be able to handle them. > From my, probably naive perspective, it's a bit weird *not* to create > the irq domains at MADT scan time. > > > With this new use case in RISC-V, here are the alternatives I am aware of. > > > > 1) Use core_initcall() in the APLIC drivers which makes APLIC driver to > > be probed prior to PNP or PCI INTx devices. But this was ruled out in > > the context of DT from Marc. > > > > 2) Like the approach tried in this series, add support for deferred > > probe in drivers. This will be invasive change requiring many drivers to > > change like you pointed. > > Again is this only for GSIs? Patch 14 moves the IMSIC-MSI init to MADT > for PCIe devices (which is different from DT), so it's not for PCIe > devices. I wonder if it's a lot of churn for something that will not be > used for RISC-V ACPI systems... > > A quick look at what Arm's GICv3 does, all irq domains are created at > MADT init. > The issue is primarily with APLIC-MSI. Since it needs MSI device domain, it has to be a platform device. I am investigating fw-devlink like Marc suggested atleast for IRQ dependencies. If that works, it would be the best solution. Thanks, Sunil
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 8c105a151e12..b62441aefa6a 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -12,6 +12,7 @@ config 32BIT config RISCV def_bool y + select ARCH_ACPI_DEFERRED_GSI if ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_MCFG if (ACPI && PCI) select ACPI_REDUCED_HARDWARE_ONLY if ACPI