From patchwork Mon Apr 15 17:00:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630388 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E788C4345F for ; Mon, 15 Apr 2024 17:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nZnnPlQ3X/NWO3SMcCevOoV1Sl+kZOvMWUrCs1XurSo=; b=1m5DqDBW+VAZ9E RtY3l8czo1vahbHefrdvbfpSRjQr+qqWgsX51tEN18pIrXvH2nADMPM1BoicLs2CZupe6SMDL/YhD xmAukAQrZ9AkuDl0NvqxQt3CB4CVppkaMR2RBT+hD0W2lQmhcaWeuFz13I4Dps/FyTFjMGM4XI7MO 9sNmWHdyaZfYclYMGBl791PkiRz1yVpiiCCdpgdgiMtpCnP1JaPpKmddjZ0zcVT+p2EY40B9pjUPp bB09YJ5147r9gEpmQ6GIuKaCrIK+y0ssePQXmYiDvBKsTJHXwy0y6TemOFmopxuD8YQa6p0havpyq xgx1BQ9CZaiqQKAHuIrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPi4-00000009BLu-0MP4; Mon, 15 Apr 2024 17:01:36 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPhy-00000009BKL-2UXw for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:01:35 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6ed691fb83eso2822589b3a.1 for ; Mon, 15 Apr 2024 10:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200490; x=1713805290; darn=lists.infradead.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=TBFCNaiZG8SDhd9Avy2NjVgbIzDcy1byPrgimW8Jnrg=; b=Wv6ifgB0ZwZa/Swhsm2+3ktLVnkp4SgXM8/YeGRHcrQT0X+F+rgMdGcL4mOS7VXDjA gUoX24ZT/OmE4YoDT2Qhov3jTNNq/EchkOtH0YSTcCTtWpnDVgZOGP/YrFBgGJvDefGm 2qjlGvR4IwjRQgs02UKz0ke/sxdBSg3zVpGoibzzP8+Cr96eoiLp6fKXMjc4faQuxhXm JEfMyN57nH0MfIz1W8m6pt9xovQY/6EhpY11Bp4ni3pOdF1pAVypBMIb42Ze3wDs0oJj KAArA3LTXcfhjgmjHHadPn3iXxIZhEt2MkQ4BVM69pp9F1QT07NDrpCbuR0cULhzhfzf SjTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200490; x=1713805290; 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=TBFCNaiZG8SDhd9Avy2NjVgbIzDcy1byPrgimW8Jnrg=; b=V5HZ6ylPkqEGl9CWEeYFhZP39Jf/onGU7QUqofIIbEI+J53fvA3VIsT8RVlqhn8Hu5 L9Bd17fox15oKsL1aUJTD2dhJyfJz/sJtEumnA/S2SF1lM7FJTo/SuYQCIe7P7CIaiPI 2utq0RcfSqH52Ie7z/23o51ZNhDyLnGrKaSVRfgt+6qfANWD1aPwufnZbQeq/6B5myTR LLuQ5MOzW+oo/GXkdWjq3H9/JeEZdAKQEs8ivH4T2yJnYAFNwPztExWOKG0SZ/J3vSa/ pyn081TQhfz6PFiXePMIlGyZS8dB+hnWw0m5KuCNESe5A5Nw+u1BERR9oR37HdlMTJ9b EXbw== X-Forwarded-Encrypted: i=1; AJvYcCWoOeY5vNtf4pSIHdR2MNXjCLIS3TfDzNrR0/WBqOYXYmJvoQ0aILwi4OzDpil2Ligt1rk19i9bmd5FOgnmdTC/u9isw85/k5FNSeAOZH8T X-Gm-Message-State: AOJu0Yws2tkEylgpLwaRtriyKhdhnYV3GfBIbkP+DKPLcg7fKU9BGoTj 8pQEHmy+sMg9Y8x3M3RZWSM0YqNw8zmqLYLYO0k7GzhUkUnef5kmdZiU6zhuxqk= X-Google-Smtp-Source: AGHT+IEzt8khZRTAtvH8V3F5ny5WPuVjUU5oxNy7bzJAesNzMJQ033mielfe1XpkBmNZ7d1UwBv2dw== X-Received: by 2002:a05:6a00:1798:b0:6ea:bdbc:6a4 with SMTP id s24-20020a056a00179800b006eabdbc06a4mr9926776pfg.13.1713200489901; Mon, 15 Apr 2024 10:01:29 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:01:29 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 01/20] arm64: PCI: Migrate ACPI related functions to pci-acpi.c Date: Mon, 15 Apr 2024 22:30:54 +0530 Message-Id: <20240415170113.662318-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100130_750376_55F6ED7D X-CRM114-Status: GOOD ( 21.48 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The functions defined in arm64 for ACPI support are required for RISC-V also. To avoid duplication, move these functions to common location. Signed-off-by: Sunil V L Acked-by: Bjorn Helgaas --- arch/arm64/kernel/pci.c | 191 ---------------------------------------- drivers/pci/pci-acpi.c | 182 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+), 191 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index f872c57e9909..fd9a7bed83ce 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -6,28 +6,7 @@ * Copyright (C) 2014 ARM Ltd. */ -#include -#include -#include -#include -#include #include -#include -#include -#include - -#ifdef CONFIG_ACPI -/* - * Try to assign the IRQ number when probing a new device - */ -int pcibios_alloc_irq(struct pci_dev *dev) -{ - if (!acpi_disabled) - acpi_pci_irq_enable(dev); - - return 0; -} -#endif /* * raw_pci_read/write - Platform-specific PCI config space access. @@ -61,173 +40,3 @@ int pcibus_to_node(struct pci_bus *bus) EXPORT_SYMBOL(pcibus_to_node); #endif - -#ifdef CONFIG_ACPI - -struct acpi_pci_generic_root_info { - struct acpi_pci_root_info common; - struct pci_config_window *cfg; /* config space mapping */ -}; - -int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) -{ - struct pci_config_window *cfg = bus->sysdata; - struct acpi_device *adev = to_acpi_device(cfg->parent); - struct acpi_pci_root *root = acpi_driver_data(adev); - - return root->segment; -} - -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) -{ - struct pci_config_window *cfg; - struct acpi_device *adev; - struct device *bus_dev; - - if (acpi_disabled) - return 0; - - cfg = bridge->bus->sysdata; - - /* - * On Hyper-V there is no corresponding ACPI device for a root bridge, - * therefore ->parent is set as NULL by the driver. And set 'adev' as - * NULL in this case because there is no proper ACPI device. - */ - if (!cfg->parent) - adev = NULL; - else - adev = to_acpi_device(cfg->parent); - - bus_dev = &bridge->bus->dev; - - ACPI_COMPANION_SET(&bridge->dev, adev); - set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev))); - - return 0; -} - -static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) -{ - struct resource_entry *entry, *tmp; - int status; - - status = acpi_pci_probe_root_resources(ci); - resource_list_for_each_entry_safe(entry, tmp, &ci->resources) { - if (!(entry->res->flags & IORESOURCE_WINDOW)) - resource_list_destroy_entry(entry); - } - return status; -} - -/* - * Lookup the bus range for the domain in MCFG, and set up config space - * mapping. - */ -static struct pci_config_window * -pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root) -{ - struct device *dev = &root->device->dev; - struct resource *bus_res = &root->secondary; - u16 seg = root->segment; - const struct pci_ecam_ops *ecam_ops; - struct resource cfgres; - struct acpi_device *adev; - struct pci_config_window *cfg; - int ret; - - ret = pci_mcfg_lookup(root, &cfgres, &ecam_ops); - if (ret) { - dev_err(dev, "%04x:%pR ECAM region not found\n", seg, bus_res); - return NULL; - } - - adev = acpi_resource_consumer(&cfgres); - if (adev) - dev_info(dev, "ECAM area %pR reserved by %s\n", &cfgres, - dev_name(&adev->dev)); - else - dev_warn(dev, FW_BUG "ECAM area %pR not reserved in ACPI namespace\n", - &cfgres); - - cfg = pci_ecam_create(dev, &cfgres, bus_res, ecam_ops); - if (IS_ERR(cfg)) { - dev_err(dev, "%04x:%pR error %ld mapping ECAM\n", seg, bus_res, - PTR_ERR(cfg)); - return NULL; - } - - return cfg; -} - -/* release_info: free resources allocated by init_info */ -static void pci_acpi_generic_release_info(struct acpi_pci_root_info *ci) -{ - struct acpi_pci_generic_root_info *ri; - - ri = container_of(ci, struct acpi_pci_generic_root_info, common); - pci_ecam_free(ri->cfg); - kfree(ci->ops); - kfree(ri); -} - -/* Interface called from ACPI code to setup PCI host controller */ -struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) -{ - struct acpi_pci_generic_root_info *ri; - struct pci_bus *bus, *child; - struct acpi_pci_root_ops *root_ops; - struct pci_host_bridge *host; - - ri = kzalloc(sizeof(*ri), GFP_KERNEL); - if (!ri) - return NULL; - - root_ops = kzalloc(sizeof(*root_ops), GFP_KERNEL); - if (!root_ops) { - kfree(ri); - return NULL; - } - - ri->cfg = pci_acpi_setup_ecam_mapping(root); - if (!ri->cfg) { - kfree(ri); - kfree(root_ops); - return NULL; - } - - root_ops->release_info = pci_acpi_generic_release_info; - root_ops->prepare_resources = pci_acpi_root_prepare_resources; - root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops; - bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg); - if (!bus) - return NULL; - - /* If we must preserve the resource configuration, claim now */ - host = pci_find_host_bridge(bus); - if (host->preserve_config) - pci_bus_claim_resources(bus); - - /* - * Assign whatever was left unassigned. If we didn't claim above, - * this will reassign everything. - */ - pci_assign_unassigned_root_bus_resources(bus); - - list_for_each_entry(child, &bus->children, node) - pcie_bus_configure_settings(child); - - return bus; -} - -void pcibios_add_bus(struct pci_bus *bus) -{ - acpi_pci_add_bus(bus); -} - -void pcibios_remove_bus(struct pci_bus *bus) -{ - acpi_pci_remove_bus(bus); -} - -#endif diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 004575091596..e8d84fa435da 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1519,3 +1520,184 @@ static int __init acpi_pci_init(void) return 0; } arch_initcall(acpi_pci_init); + +#if defined(CONFIG_ARM64) + +/* + * Try to assign the IRQ number when probing a new device + */ +int pcibios_alloc_irq(struct pci_dev *dev) +{ + if (!acpi_disabled) + acpi_pci_irq_enable(dev); + + return 0; +} + +struct acpi_pci_generic_root_info { + struct acpi_pci_root_info common; + struct pci_config_window *cfg; /* config space mapping */ +}; + +int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +{ + struct pci_config_window *cfg = bus->sysdata; + struct acpi_device *adev = to_acpi_device(cfg->parent); + struct acpi_pci_root *root = acpi_driver_data(adev); + + return root->segment; +} + +int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) +{ + struct pci_config_window *cfg; + struct acpi_device *adev; + struct device *bus_dev; + + if (acpi_disabled) + return 0; + + cfg = bridge->bus->sysdata; + + /* + * On Hyper-V there is no corresponding ACPI device for a root bridge, + * therefore ->parent is set as NULL by the driver. And set 'adev' as + * NULL in this case because there is no proper ACPI device. + */ + if (!cfg->parent) + adev = NULL; + else + adev = to_acpi_device(cfg->parent); + + bus_dev = &bridge->bus->dev; + + ACPI_COMPANION_SET(&bridge->dev, adev); + set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev))); + + return 0; +} + +static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) +{ + struct resource_entry *entry, *tmp; + int status; + + status = acpi_pci_probe_root_resources(ci); + resource_list_for_each_entry_safe(entry, tmp, &ci->resources) { + if (!(entry->res->flags & IORESOURCE_WINDOW)) + resource_list_destroy_entry(entry); + } + return status; +} + +/* + * Lookup the bus range for the domain in MCFG, and set up config space + * mapping. + */ +static struct pci_config_window * +pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root) +{ + struct device *dev = &root->device->dev; + struct resource *bus_res = &root->secondary; + u16 seg = root->segment; + const struct pci_ecam_ops *ecam_ops; + struct resource cfgres; + struct acpi_device *adev; + struct pci_config_window *cfg; + int ret; + + ret = pci_mcfg_lookup(root, &cfgres, &ecam_ops); + if (ret) { + dev_err(dev, "%04x:%pR ECAM region not found\n", seg, bus_res); + return NULL; + } + + adev = acpi_resource_consumer(&cfgres); + if (adev) + dev_info(dev, "ECAM area %pR reserved by %s\n", &cfgres, + dev_name(&adev->dev)); + else + dev_warn(dev, FW_BUG "ECAM area %pR not reserved in ACPI namespace\n", + &cfgres); + + cfg = pci_ecam_create(dev, &cfgres, bus_res, ecam_ops); + if (IS_ERR(cfg)) { + dev_err(dev, "%04x:%pR error %ld mapping ECAM\n", seg, bus_res, + PTR_ERR(cfg)); + return NULL; + } + + return cfg; +} + +/* release_info: free resources allocated by init_info */ +static void pci_acpi_generic_release_info(struct acpi_pci_root_info *ci) +{ + struct acpi_pci_generic_root_info *ri; + + ri = container_of(ci, struct acpi_pci_generic_root_info, common); + pci_ecam_free(ri->cfg); + kfree(ci->ops); + kfree(ri); +} + +/* Interface called from ACPI code to setup PCI host controller */ +struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) +{ + struct acpi_pci_generic_root_info *ri; + struct pci_bus *bus, *child; + struct acpi_pci_root_ops *root_ops; + struct pci_host_bridge *host; + + ri = kzalloc(sizeof(*ri), GFP_KERNEL); + if (!ri) + return NULL; + + root_ops = kzalloc(sizeof(*root_ops), GFP_KERNEL); + if (!root_ops) { + kfree(ri); + return NULL; + } + + ri->cfg = pci_acpi_setup_ecam_mapping(root); + if (!ri->cfg) { + kfree(ri); + kfree(root_ops); + return NULL; + } + + root_ops->release_info = pci_acpi_generic_release_info; + root_ops->prepare_resources = pci_acpi_root_prepare_resources; + root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops; + bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg); + if (!bus) + return NULL; + + /* If we must preserve the resource configuration, claim now */ + host = pci_find_host_bridge(bus); + if (host->preserve_config) + pci_bus_claim_resources(bus); + + /* + * Assign whatever was left unassigned. If we didn't claim above, + * this will reassign everything. + */ + pci_assign_unassigned_root_bus_resources(bus); + + list_for_each_entry(child, &bus->children, node) + pcie_bus_configure_settings(child); + + return bus; +} + +void pcibios_add_bus(struct pci_bus *bus) +{ + acpi_pci_add_bus(bus); +} + +void pcibios_remove_bus(struct pci_bus *bus) +{ + acpi_pci_remove_bus(bus); +} + +#endif From patchwork Mon Apr 15 17:00:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630389 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2910BC04FFF for ; Mon, 15 Apr 2024 17:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fNq0Odz+5AwTnScVY60dPvA79WdreL1ZVBKVVtTUbtg=; b=CdT29aXZZy+3LL ty+VNRVfsW2h4YCeG8GDuZxk89+kBwLKPqLy25qdRjySTFigeiKkcg8kd8R+Pvr2W6rUDtOKPY3ou kfQy0jRvw+NGQNI7P3yurqd/ZXKjCY5ZSHn4JzR+gal4h0dcJ69YlvNlWLV+h/ZG+N29gaUAeq/Qd 3eTuavblaSOyYRvEW/vdnG2DhKd7Cbb+EHth0GhtzGXIVG4H1hbavcRHH7J8liJVYlLLj6x4TKnzw 8lJLITPLgEHs3gxGqYpQX0aZpNv49AyVqO2FdrY5SktXusoHjgu7RArlWGBIv9BYiq71JkZ8plQq2 yYmvTCnDX6vob6QTxyJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPiB-00000009BQm-2SKh; Mon, 15 Apr 2024 17:01:43 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPi6-00000009BML-1TWN for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:01:42 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6ecf1bb7f38so3169608b3a.0 for ; Mon, 15 Apr 2024 10:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200497; x=1713805297; darn=lists.infradead.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=SFAtcNyUPfmOo+WuzK4Rac+GFz0TbHOwinmWYmcFrxc=; b=Kl0KCs+fMaGJrjSTDgArtfSeubx0ZNL3zWYC1kbexJWTtaq5jaOMrOXDXW2fmA3fIi 8D8vfmprCvwEP/ZAu+Qq+WDvjUEiBq5dC6h6AsfFfLv5OWGwR8rvZ9t0vDH/VlWuh/ao jFWhyd17JDdQpJ/gEf7ivsoo3LbVlDLY/mCBFiv9RjlifU6mdmLHV841YLhiucWDrF6j yhy5zM2JS9n6fy5OAH6v9kGliID4u+/jXx0r39yFfO8hSqDYRi+zhUpGPxgvWoOYEn1B aA4dKAXxhElWxIWPBLItUKYh4uW2vpmxQyUboF8j2roeSUbd9k7l8+9O55dL+z4I110J 19aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200497; x=1713805297; 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=SFAtcNyUPfmOo+WuzK4Rac+GFz0TbHOwinmWYmcFrxc=; b=Mp3ABcw3HL2iJJx+mK7qw/1vQsDcyWAdTMyWsFZLUtB44NQ5Hy4FiN61bvhP0jh0qM reqTOTpKEwMriRPQaL7bTXWJOHmQ7UitaUg+gbxrgnSJFf++ap6AzkF5LLUHlI+F7Ww8 qVZaOkEUTond9dxlKW9mSAAfRdJoaC2PcHauV+4PkUPG5A/DEoW3SKuQtk1HsupMlUu7 Ph2I/09l0elgIG87/njTf8khNkVSEV+qV+HV5ND6lz5loObu12sdScolCIE8lBTkyuOm X5xiB6iSLCw1PdUiU3AxVspCqUyFRjmFlnRigWDAGOVX0ljGrr9u1eBprO62ATyty4ld yttQ== X-Forwarded-Encrypted: i=1; AJvYcCUvKttL8GodXso69jONlArmPt1lvLfwmQaz86xRh6nmMF48Fjwcpe2+kDX8utcTY6W7BMH76dgotG45c638cu1xEMXvY7h9bUfX7CVBHaZL X-Gm-Message-State: AOJu0YxiYAdqystTp89HRBNIMyYNZ5UJes62Uj6bIZRR/MON6r8PM2Kh t4eIveGNYc33KCNQpjzqC2TwAqwN3fnGF0yin4fVidlDv/bDzOoEemCbDgXC87w= X-Google-Smtp-Source: AGHT+IGqYjIa76YfWohzDrF4RGeNhNZq2I7mTi99zpcmd5VEKjXE94y5JlYL9p7qJRGZUYYL3web8A== X-Received: by 2002:a05:6a00:22cf:b0:6eb:2b:43b4 with SMTP id f15-20020a056a0022cf00b006eb002b43b4mr11021959pfj.27.1713200496609; Mon, 15 Apr 2024 10:01:36 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:01:36 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 02/20] RISC-V: ACPI: Implement PCI related functionality Date: Mon, 15 Apr 2024 22:30:55 +0530 Message-Id: <20240415170113.662318-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100138_461703_5DFD3F6F X-CRM114-Status: GOOD ( 13.73 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Replace the dummy implementation for PCI related functions with actual implementation. This needs ECAM and MCFG CONFIG options to be enabled for RISC-V. Signed-off-by: Sunil V L --- arch/riscv/Kconfig | 2 ++ arch/riscv/kernel/acpi.c | 31 ++++++++++++++----------------- drivers/pci/pci-acpi.c | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 6d64888134ba..69cc0509a19a 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -13,6 +13,7 @@ config 32BIT config RISCV def_bool y select ACPI_GENERIC_GSI if ACPI + select ACPI_MCFG if (ACPI && PCI) select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ARCH_DMA_DEFAULT_COHERENT select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION @@ -173,6 +174,7 @@ config RISCV select OF_EARLY_FLATTREE select OF_IRQ select PCI_DOMAINS_GENERIC if PCI + select PCI_ECAM if (ACPI && PCI) select PCI_MSI if PCI select RISCV_ALTERNATIVE if !XIP_KERNEL select RISCV_APLIC diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c index e619edc8b0cc..41aa77c8484b 100644 --- a/arch/riscv/kernel/acpi.c +++ b/arch/riscv/kernel/acpi.c @@ -306,29 +306,26 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) #ifdef CONFIG_PCI /* - * These interfaces are defined just to enable building ACPI core. - * TODO: Update it with actual implementation when external interrupt - * controller support is added in RISC-V ACPI. + * raw_pci_read/write - Platform-specific PCI config space access. */ -int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, - int reg, int len, u32 *val) +int raw_pci_read(unsigned int domain, unsigned int bus, + unsigned int devfn, int reg, int len, u32 *val) { - return PCIBIOS_DEVICE_NOT_FOUND; -} + struct pci_bus *b = pci_find_bus(domain, bus); -int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, - int reg, int len, u32 val) -{ - return PCIBIOS_DEVICE_NOT_FOUND; + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->read(b, devfn, reg, len, val); } -int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +int raw_pci_write(unsigned int domain, unsigned int bus, + unsigned int devfn, int reg, int len, u32 val) { - return -1; -} + struct pci_bus *b = pci_find_bus(domain, bus); -struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) -{ - return NULL; + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->write(b, devfn, reg, len, val); } + #endif /* CONFIG_PCI */ diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index e8d84fa435da..b5892d0fa68c 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1521,7 +1521,7 @@ static int __init acpi_pci_init(void) } arch_initcall(acpi_pci_init); -#if defined(CONFIG_ARM64) +#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) /* * Try to assign the IRQ number when probing a new device From patchwork Mon Apr 15 17:00:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630390 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39EFCC00A94 for ; Mon, 15 Apr 2024 17:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rEKboOnm/bv0UxP1K5Nb7U4gdNf7ZtKrh8WH2fS/Cnw=; b=XFNFjuM7pvRWto cI7/e4HNDIWx/iU8G4KFiFEvfEmG8W6txUoV8wPhhzmYovXjwB03O8qZpoyDn1nwnYmYBYzVD2WRC eMS/WcFjlGY+BzMTCcnKUYcEKglKgiYoyykMBksf6314HmLWoN3CNZbhnhZsRK3+DKsvJN1XIeH2P 9gqOGmiwD1okdITvLe41vJ6hhECDe1IhHwnwRILLYKLZtAhjGuRH8zNdGfoHyyvskmpByUHIIP7iU G1CwUJ7gRjU9MfbZXiHJ6TPjkXVZIr+OehaRniaHvDpPwMMXyw+zikY/k5XCWgG6R+YZSmEKb0O9L zT7dUMDj44mcnzsUmORA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPj6-00000009BxH-2MsO; Mon, 15 Apr 2024 17:02:40 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPiE-00000009BR8-1HT0 for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:01:56 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6ed627829e6so3791303b3a.1 for ; Mon, 15 Apr 2024 10:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200503; x=1713805303; darn=lists.infradead.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=VoHprznTatfd3jPIiDLel21Ov4h1fvX4qo25ti25gdk=; b=NkD/6adJbx2WWaW9g0LNJguAANigcw3RghTTUvkhYp2ODNntWwnFTRNv89+1V7elsy HLEFYKn2zidm9CwRndZJUsO8uWN1FVwgWc6fvW0N5GwKon0NmyS/zN5qiKSoN/ImVV52 3ZkC3XnIR2DYUnTCvGF3Ya8F+Vl4Amft6CYNtnhy5EyAAqvym6CREOaTayfuDrKQWinD w1ZsdWcDKM5d/qCCq1FTtd2wJR0xHkn3A/BHDpO1dR5o4y226h9IphcXU1snon8x2F16 mgVwyVgpFALI8dKetjU8IJOXEc/JKPDm7hgafXV7K6X40W+YrYI5hSn2iiQvGSO1R8Dl P4dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200503; x=1713805303; 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=VoHprznTatfd3jPIiDLel21Ov4h1fvX4qo25ti25gdk=; b=W+766zYQ0zEgW4C4EbEAiZ9zjGszpEy9b4BYDlIsWfnXJDYXQIWVf6TbFW9YW39x6Q ATcIAXqXzj6V5P0p6NvFyVu5rk80ID99mKGmaRdJRulMViqameHpk+i+T5IthzzeZnl2 P//o6+Dv5EcTTAnBYJLVRG72TouDDgTuZ4CEKbii/SpL4IyMhOWry6zV8TMemxNlwIvm j9Cmlg0jW8NuHr0b7k2rckn9ET+he9KiorER1ZD8GWUp+Czhw7pi9FQ+3OBHczsWyCJI zO7RfwhWCmNgdSXjarJTYKxIXw9/yMJ2uqSioyS3/u25Niincp/48ER3QhPyT2morzH3 JL0A== X-Forwarded-Encrypted: i=1; AJvYcCW4xBprO8vOgyMF3W6OkAKryj6gZ3hN2MV5AodhAIwxQYc3oyzu658jdnHSmJg3fCAImPVc8HAM9+SUkWMGjtgKCVSmn5Rc5wUa/RPPAlQq X-Gm-Message-State: AOJu0YyjXXcj6D4A2qv2SYMBow1oqifO+4DglDeRNahp5G8ItfuytmFE tv/+faFwc1nMiIOXg4KVM+Zjiw3Fs0zCiSyihXgknC1HC5jomYVQiNVuKQZSbjg= X-Google-Smtp-Source: AGHT+IEZTBakzY6PKzMTgs/zcMBONEtbNskqJbnRsI44xNlUKHaklyMLmZlZj49QTc7g7/a+/pPcjw== X-Received: by 2002:a05:6a21:3381:b0:1a7:58ca:cdf3 with SMTP id yy1-20020a056a21338100b001a758cacdf3mr14872194pzb.8.1713200503358; Mon, 15 Apr 2024 10:01:43 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:01:42 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 03/20] PCI: Make pci_create_root_bus() declare its reliance on MSI domains Date: Mon, 15 Apr 2024 22:30:56 +0530 Message-Id: <20240415170113.662318-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100146_539139_A75C9D3C X-CRM114-Status: UNSURE ( 9.18 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Similar to commit 9ec37efb8783 ("PCI/MSI: Make pci_host_common_probe() declare its reliance on MSI domains"), declare this dependency for PCI probe in ACPI based flow. This is required especially for RISC-V platforms where MSI controller can be absent. However, setting this for all architectures seem to cause issues on non RISC-V architectures [1]. Hence, enabled this only for RISC-V. [1] - https://lore.kernel.org/oe-lkp/202403041047.791cb18e-oliver.sang@intel.com Signed-off-by: Sunil V L --- drivers/pci/probe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 1325fbae2f28..e09915bee2ee 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3048,6 +3048,9 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, bridge->sysdata = sysdata; bridge->busnr = bus; bridge->ops = ops; +#ifdef CONFIG_RISCV + bridge->msi_domain = true; +#endif error = pci_register_host_bridge(bridge); if (error < 0) From patchwork Mon Apr 15 17:00:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630391 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2240C4345F for ; Mon, 15 Apr 2024 17:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tjTpr+7zHKOo6Y3p8agFRCNoG/prNKVv89Wi0vTc1q4=; b=nsLHIFNGvkTOmn jyAeoU3jej4+8V3jHaBx4Qv0zdYIwoJIG/bdwZBf5Yi75Ka35cqlLbVizdjvsfZHHzi1JOf02pO2V tBYUus5yE1UDK+4rFOb0ReO8Y4gUmQTbvVey7bLiDtJVgJxWX91HCsbrtfShYqk9jPlCGcU7DBpz1 xVuR3gltKRESUG5xf8eA2sE2uwlGk8OhWv2HUVw2hLdrghqfy1iQApjn2F4IwZ2wZpWLhXK6qJmWq 8k8qFvjXpS7WefGlzQdMEaegNtBRaB6wrP7R8C8y0t9kvsNIy3TyKEXE/DE4qs+w1Ygi2bk5JSsjx cESVciLGfUC3VY73bITg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPj8-00000009Bz5-3R5S; Mon, 15 Apr 2024 17:02:42 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPiI-00000009BVw-3gr9 for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:00 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6ed04c91c46so3648733b3a.0 for ; Mon, 15 Apr 2024 10:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200510; x=1713805310; darn=lists.infradead.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=NV0OeA3LqOjcEQwVzmEUb3l+O0qMWG2Q7MAVkkjj25w=; b=X8Br2pRkM/7jqPlK5wz6N9SDWMNdd8oWsepSZbNWp4FWFlRNs/a4OW1Np/na3hzZo5 m0md+724GDlPTtnH1pDDL+wX9iVLymjriz5qzTs108gaVHtxtQS0L0ccXaBS7H4Z+2sV GVzStudlaxDUnC71IuICiwwIp8O7LFcDcm/PhoyGxxn+1l/cnQ188744lX+cFQTdb6qh OEv9MgIV2zg7u6uZJAiPTOq3YYsd84FxW2AiSJp6St0oK9uPW/6uw+gh/YF9eMh45SSK euYSom/EHajNo7Ss9aOrJ6yBePRQbgEOrEYw5HwxrxGFhmT1K8k1SkTTTA+b26nvFL/i 8+/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200510; x=1713805310; 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=NV0OeA3LqOjcEQwVzmEUb3l+O0qMWG2Q7MAVkkjj25w=; b=qUsUQPE4fGSozM+w0LZjQxIc6iF5QrXZ2bLKVuS34PPeogWVGu91y6k7NIyXN/99cJ yiMM4NsXoifvYjQz/bSx7HVa8Bq6BANRWynqgpMkhIpk4Z0t3ff4w9vYHmgo3dAs6CoP AKIMuJFL4JL8muTJIhhHj0rZdusGdIuiAGjwoAWVyFg2yQPBg1VGz/MPU/wJ2baTZtOX B2wt1lhS9UJhpITzf1dhMXK3FkrLLPANb8y62hsvIojKDrHFgifozdb8zfOYXv8YRdHK 1p+3pBBbIVkl6m3sxKdLxodWXEIFVCiz3ayfi4pUnlUcxfR+7OzaPiAikxsmsH1zlECT a8hg== X-Forwarded-Encrypted: i=1; AJvYcCWFgIFdbCFYK6NAkL9iOsic4HJ/N33znU9RX07yUsI8AgvhGUY/TRmkh0HSTNpZF8LyWIDjcaLJ8R6ABF2WZaJN8jx1+xbzXpQdyX0bldNE X-Gm-Message-State: AOJu0Yx2/vkbng/XljfcslcPxp2kTojY6qeesuedLN/i6epMTpw7Va/t UB+EYCa8KLChPH3r21Xunh7rqExlhQmSacHlajiQaeACnCtqHdHmHSSJxVkVZiU= X-Google-Smtp-Source: AGHT+IGvmjYeaJvV6Cs9b+D8sHsU8MJVs6hR0ePtYiL5D9g9wvurdSLwMSWttPbHZlSkX+z1czGUNQ== X-Received: by 2002:a05:6a00:21d0:b0:6ed:de6f:d738 with SMTP id t16-20020a056a0021d000b006edde6fd738mr13801645pfj.9.1713200510295; Mon, 15 Apr 2024 10:01:50 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:01:49 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 04/20] ACPI: scan.c: Add weak arch specific function to reorder the IRQCHIP probe Date: Mon, 15 Apr 2024 22:30:57 +0530 Message-Id: <20240415170113.662318-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100150_972904_188964F0 X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Unlike OF framework, the irqchip probe using IRQCHIP_ACPI_DECLARE has no order defined. Depending on the driver Makefile is not a good idea. So, usually it is worked around by mandating only root interrupt controller probed using IRQCHIP_ACPI_DECLARE and other interrupt controllers are probed via cascade mechanism. However, this is also not a clean solution because if there are multiple root controllers (ex: RINTC in RISC-V which is per CPU) which need to be probed first, then the cascade will happen for every root controller. So, introduce a architecture specific weak function to order the probing of the interrupt controllers which can be implemented by different architectures as per their interrupt controller hierarchy. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 3 +++ include/linux/acpi.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 68f101323f53..de30a0af7a2f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2749,6 +2749,8 @@ static int __init acpi_match_madt(union acpi_subtable_headers *header, return 0; } +void __weak arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) { } + int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr) { int count = 0; @@ -2757,6 +2759,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr) return 0; mutex_lock(&acpi_probe_mutex); + arch_sort_irqchip_probe(ap_head, nr); for (ape = ap_head; nr; ape++, nr--) { if (ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) { acpi_probe_count = 0; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 168201e4c782..914ecd22ba64 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1337,6 +1337,8 @@ struct acpi_probe_entry { kernel_ulong_t driver_data; }; +void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr); + #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, \ valid, data, fn) \ static const struct acpi_probe_entry __acpi_probe_##name \ From patchwork Mon Apr 15 17:00:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630392 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A8C5C4345F for ; Mon, 15 Apr 2024 17:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=x83hadpOiMabDPax6E+FMFiO1ftfgvZmpzOPpSuubH4=; b=isA0KAzWO6S6Hc CeB35+VH85IyZGYL/nwgz/wALwvU+lDOfFQlgbAHs9oZIKulKGm+2UmlODQbAfY5TE4K23IxtolWL AFUSH9b78HTcarJsjm1X3Y9xrCUJu8n7nhYegsI6aPtBtei4+Se24Ajtjv5COJHH8VnIoT06B8f9o gNXQ0YqNwC3SDtl7xwwsVHx8iXeGxRiE1LTn4ZGzEJPQ5yCEYr1elpfa/B7CTvdPPAZWKkw53WzIg 89SrDP9gvLK3pBVFRueosayFHpA8GQp2zppiv3Nw7UosY4eCMhbTEr1Kb9799zYzfyIUJmI1I4eSO bX68kWkWbIbf/egnf7hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjT-00000009CFy-2XyQ; Mon, 15 Apr 2024 17:03:03 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPiQ-00000009Bb1-0OIg for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:05 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6ee13f19e7eso2452339b3a.1 for ; Mon, 15 Apr 2024 10:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200517; x=1713805317; darn=lists.infradead.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=Z52/1ZZYR1CvGL0V5chwJsk+UfCztWDiXCAoT+2GZNk=; b=JKJS5AgnWFe703jJXTr2O+uxXy2QdAGmV+WQ86Upv08fjr/M3ZaAJT7M3WYiaUhBwV zCZcyzl327z5er5d+FADKulnZVAXr+9pOFedaq8jJJ+pEYdS1oC4tRlYTBukGx366mhQ pWzTFsi/+3GiscbDxekUTfQDFnm69J4urLkw+yIzC/m/ehL6J6GaTGVKmt23RseEmQ9j luxsZDrmMPdqFuXvyUt3O74a4g5Ca36qrvrd5LT+MwoPO5SbZVk98+P0HF16yIBvFiGt oVpIoW/0yeXCZH5AXMyercEbcTmL+e7qMJ+dpyo3NDEFpyEP65FBswGF5DTUqEuvX8yg gQSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200517; x=1713805317; 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=Z52/1ZZYR1CvGL0V5chwJsk+UfCztWDiXCAoT+2GZNk=; b=u03N1EWiLM6ISZAPXePg3Z9A9CvkLw4qHOH4tAw99cmOtNdxqqVIu76SUpAFzJrJ4i gyyThGHMDn2DpJumfB7s7NauwbAshZV7i38CGlfrpvA3+gyQ+XAvGUf5PKB+BpgGPpoM 1W8NJbWdQ8DvindUCGYz81/E9kunlvv/p0uY9utR4seTLl2A4r773a8i32y9QtsqwAz8 dWdw2ySH0r8TZyCtvMY+8hUF9Y7KHRhd01ZbbGrH8VljdsdlmXrwxAwoopQxZIQrVMDQ z1/9U8AJv71HSTNiaYu73gpZbLJ/tJ8q/uVag0X3EDqJAFaYl/SldaEGvUW7LqKnKJsx HBaw== X-Forwarded-Encrypted: i=1; AJvYcCWTkfGfxiXKebdftnJnwo6RItW9wLL86n/tsDYpUBKjwGJgZh12GXk8nmOayyvZPPM1Rz7N7yGuzn5k22Ey7i+nbcJFW6I2kUQyhhKivECX X-Gm-Message-State: AOJu0YwqTNJ+AJMiiUOWeGj7cCoqGoRBuPcFm0A6ibS6cs4Ka7gya7zb 03fmKX55Jse19FIMF1o2iKRkF+xQFwHumwWxZ1vVNsECxZeomnpD7dg0AMrmAx8= X-Google-Smtp-Source: AGHT+IF3pZ5kgHd0L+s0ETBbrzTu2eQzZocJwTnnUWv3+XrCVjsqR27b/As/nt3u7TcsRgOfwdwSGQ== X-Received: by 2002:a05:6a00:986:b0:6ed:1c7:8c6b with SMTP id u6-20020a056a00098600b006ed01c78c6bmr10123074pfg.1.1713200516899; Mon, 15 Apr 2024 10:01:56 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:01:56 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 05/20] ACPI: RISC-V: Implement arch function to reorder irqchip probe entries Date: Mon, 15 Apr 2024 22:30:58 +0530 Message-Id: <20240415170113.662318-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100158_249871_2FC5BA46 X-CRM114-Status: GOOD ( 15.94 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org ACPI MADT entries for interrupt controllers don't have a way to describe the hierarchy. However, the hierarchy is known to the architecture and on RISC-V platforms, the MADT sub table types are ordered in the incremental order from the root controller which is RINTC. So, add architecture function for RISC-V to reorder the interrupt controller probing as per the hierarchy as below. Signed-off-by: Sunil V L --- drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/irq.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/irq.c diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 86b0925f612d..dceec808cfab 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y += rhct.o +obj-y += rhct.o irq.o obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc.o diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c new file mode 100644 index 000000000000..36e0525b3235 --- /dev/null +++ b/drivers/acpi/riscv/irq.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023, Ventana Micro Systems Inc + * Author: Sunil V L + * + */ + +#include +#include + +static int irqchip_cmp_func(const void *in0, const void *in1) +{ + struct acpi_probe_entry *elem0 = (struct acpi_probe_entry *)in0; + struct acpi_probe_entry *elem1 = (struct acpi_probe_entry *)in1; + + return (elem0->type > elem1->type) - (elem0->type < elem1->type); +} + +/* + * RISC-V irqchips in MADT of ACPI spec are defined in the same order how + * they should be probed. Since IRQCHIP_ACPI_DECLARE doesn't define any + * order, this arch function will reorder the probe functions as per the + * required order for the architecture. + */ +void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) +{ + struct acpi_probe_entry *ape = ap_head; + + if (nr == 1 || !ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) + return; + sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); +} From patchwork Mon Apr 15 17:00:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630393 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4BA46C4345F for ; Mon, 15 Apr 2024 17:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=INCAuSZmdz01BdowwBvJJj/K19yVp/nBcORK8pj6svU=; b=Leu9FQjAnMTudt K27M1Vj/FUVG7RSlwJtSnuSjak6lswtHkZGrCmlQXnE+nhjG1OUoK339lrs8xLxv7mp6d1ZeWyGHI jCKj1ytbFoAK6j2+n1siUCluS+2qd6dgUvcKquscpjeFJQQVT1zzvOtYQGbKhDX12Pgv+bT6YhRti P1w5tGeHFxySL0KEngVOggSWp5xDYikSAjkPyDmYqrSlI5Y9fMONdtp5AQ3aJ/Mx3HG/P0RpFLKnS mCDDtBIBxlXARVnoGF9/TwOAweOuA+XEXWqktmFmUQdrsNLK7q9BzqhhiGkGvZePB6Xcn0aVAopa8 MMmUq067gi4Nq/T74R5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjl-00000009CUt-2iCb; Mon, 15 Apr 2024 17:03:21 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPiY-00000009Bfm-1Mpk for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:18 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6ed11782727so2926957b3a.1 for ; Mon, 15 Apr 2024 10:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200523; x=1713805323; darn=lists.infradead.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=teU93TtwDbXbcibIb7AXZv+o/BW+BbmtaOdYSVoKyTI=; b=m8N6nuJl4IJO/5kvRUFw/h08UjATT7PJd6pkzq+vV8QPwhXlyfJgQDfVmK7TJH7f/8 fBjsdBbu0v1Y+bTPWv8riIYo/JQmkttXXVTHDs5EsDE/rXfXKfqnqSg8beH/km6IO6i7 nTHWqZQrev6lXtHZHonWM+w3Y/SkWXVhxOYXW3uNkBQrVxEW1X3TEoxG2Ii6Cs65kyta hFwF1BZc5Dz3fm3QnXudssPDm2cazdQoAOlEYGs21YFcLuxDa1zcFSd+MVEOk5niX1BG QrNbwbtXTr8XiJZaWmr560L0zkPH5B3RiDjorfQ4rQ6jazBqMCQybDpro23vRDO6yhuj buAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200524; x=1713805324; 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=teU93TtwDbXbcibIb7AXZv+o/BW+BbmtaOdYSVoKyTI=; b=agrvldBnw3GORxtHiDh34xgnljPk57KgWBMnJ6IZAQqiC/FO13sAndFTZ6EMvWd3I+ A15pEkS2ZHW0P7vhUqfyBGQxvw9jsDAcFjXxbmtIkaOPI3N2mgukFEwmtuyK/OxmKIeO 5RNKvTZClmpdWb117e53CITjAUeR59hFA50+CBPY0QlxMbtcUh8O0PDbVrXN6FgnpqEo lg5Gev2lZicV+tckofskqak1ufMvdj19tRRLPT1cIbZuqKE7cgt3QfmcgvRUejTVr3fk OyQxWo6YaSwyDVOGI2uQZty16gIpWc/IoY68+VqTRUQ9Mm1FQMeF5mGJAfkeE/qZVaRk +f/A== X-Forwarded-Encrypted: i=1; AJvYcCUbaqEu4nZqmcRXau/mXqHBgKO/crLv2HXrvj7fftPZevnMq01n7m8Rgy1JMOES4s/jlxWkpqtjG1VgjJsj7ZEj2B5hDmNlxx5ga4jQ1leC X-Gm-Message-State: AOJu0YzVE7NkJxZqmZS+0qcQUA4HekyXKEo//v/zyt5tzfwoS4RHxhny I+UdvBqjdwG6sKGzfns/ZB8qiiQnMsxtvP/SSCbVLfsNjUk7SmaxQDlsPkW/N6E= X-Google-Smtp-Source: AGHT+IHIdjpEtA26gjeeDnuLKQpBt+rlByzg0zdHDQS2GYQedk9D3DuzAQNVqthcjh2+Xm9tW86rPQ== X-Received: by 2002:a05:6a00:3985:b0:6ea:e31e:dc75 with SMTP id fi5-20020a056a00398500b006eae31edc75mr12713019pfb.5.1713200523442; Mon, 15 Apr 2024 10:02:03 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:03 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 06/20] ACPI: bus: Add acpi_riscv_init function Date: Mon, 15 Apr 2024 22:30:59 +0530 Message-Id: <20240415170113.662318-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100206_645864_C7A7D688 X-CRM114-Status: GOOD ( 15.81 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add a new function for RISC-V to do any architecture specific initialization. This function will be used to create platform devices like APLIC, PLIC, RISC-V IOMMU etc. This is similar to acpi_arm_init(). Signed-off-by: Sunil V L --- drivers/acpi/bus.c | 1 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 12 ++++++++++++ include/linux/acpi.h | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/init.c diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 844c46447914..17ee483c3bf4 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1446,6 +1446,7 @@ static int __init acpi_init(void) acpi_hest_init(); acpi_ghes_init(); acpi_arm_init(); + acpi_riscv_init(); acpi_scan_init(); acpi_ec_init(); acpi_debugfs_init(); diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index dceec808cfab..42d351859aeb 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y += rhct.o irq.o +obj-y += rhct.o irq.o init.o obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc.o diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c new file mode 100644 index 000000000000..b5807bbdb171 --- /dev/null +++ b/drivers/acpi/riscv/init.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023, Ventana Micro Systems Inc + * Author: Sunil V L + * + */ + +#include + +void __init acpi_riscv_init(void) +{ +} diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 914ecd22ba64..f8f92aaf97ad 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1525,6 +1525,12 @@ void acpi_arm_init(void); static inline void acpi_arm_init(void) { } #endif +#ifdef CONFIG_RISCV +void acpi_riscv_init(void); +#else +static inline void acpi_riscv_init(void) { } +#endif + #ifdef CONFIG_ACPI_PCC void acpi_init_pcc(void); #else From patchwork Mon Apr 15 17:01:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630395 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E098C4345F for ; Mon, 15 Apr 2024 17:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iPfkGiRzoHaVbOWeOiwcZbnx4nus9vwIZRKu2Q/K4qA=; b=Cyq7nXeW/ZQGv4 LjCP+NVyXsIZUe5FN/wlToP3WH5WnGNWckslY3aHu9ixwSvFOCGPcTgmO8B1ARSpfUHOjtV3xpO7V C0ThNtw+mlikgAr7vmSYTnJRQb/hXx3wHz4b/I73kXRCjinkYfuFfTc1dBVOroIGbq08s2n6D5K3O 8tAGAUOfY08cjsvVVzRk92xqYzgumZ1YaR//UX9dLJvgrLVwb5H+qorx5thT/GPgQu6uNnCzU5vU+ nBxAcDfgb0D7dONGwp0e7qBliPDWITogj0skZA0fLAtTA2U/CKIXP7WLtPr9yc3IHSNhZjyng/g9K +4TE+b5ZLcQC+MOQm7xA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPkE-00000009Cq9-3k7X; Mon, 15 Apr 2024 17:03:50 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPio-00000009Bpx-3rnn for linux-riscv@bombadil.infradead.org; Mon, 15 Apr 2024 17:02:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=wivOzLRmXtJHidm0Hubd14abZ9qXDzBQHr2qytLzYnU=; b=rLi0ZFoFp4WYP36jCawa8JD0Ms 9PeaQlMCo63xB3mY66nmnxeAGenOIpfr7bcevxA9GxA3E8tKGudz69vrH57/87IF6SqN4E0zSE8g2 4krKu+rW8I4np8gfa15DCqjoDb+qHpIgDQBgYnZSYO3Yp8aIdsZdI32bpjEgmwxt2Wyk2VBM3bfXW 98S6C6sb+1Ps/lwJddFXEpy4rzHbhxLPjLgxgs2oRUxpQ5m9UmTn5PfxomG7khI9o17BW1RJz3r+d 10rq3sWKIFhVIyhe3gQnkp5Iu9uhwAM4iKSGSJoUwPO9d+9oFE0gCW7W/djKgIphSmKgNsLILk31u /5XwiRhg==; Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPig-0000000AfSK-3eet for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:20 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6ecf05fd12fso3342964b3a.2 for ; Mon, 15 Apr 2024 10:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200530; x=1713805330; darn=lists.infradead.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=wivOzLRmXtJHidm0Hubd14abZ9qXDzBQHr2qytLzYnU=; b=SU5DSj0IIdowiK2MQCHn3tz8S428NnAr6l0y6YOh18g6ZT38bcE0gr2gxZxKPgstnm 18MUfJO76dS6zBuzlvgihKVsQdlQOOatoUoh4XTJBmWz1bcE1Ggr0dIDbuHdcZGnQoT/ YamL5STFXVeEPauF178qMnWkJdfP60BflwWa6oIqNj2VD8ED5TUmIb3TiYdYrX2shOEI V2TQOxAwpS76I7HFmdn7L8IoCn+I3pEWGaNIGFawLWEQiea5uwgWOu4ZtdBbWAPI7N6c aRw+fPgOuKDNf4T0g7xyOuuWGDvi62uk2vaPm5Zl7iFUuGVGhNaJwgMXZCGCCmCUI0t6 OLuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200530; x=1713805330; 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=wivOzLRmXtJHidm0Hubd14abZ9qXDzBQHr2qytLzYnU=; b=hFqRDF+vx+W9tYjeBf3X91IBEnTTXy2ThpiXQEsleWpD2AvBLxJ0jMYsEK9279CqC0 wt1BgaWcyzM44OSVn09BzMrTbyPc90Gy7gJWpXDsglkuAdXmmX1oRJvvjpK0Du6XnZam nsGPL1HBPPbSIAAs/bI6l6qTo2S5RULeNgK0GfFu3M/FdNhKMeilsRyXNu2CE1x/OzAk RgkaROsnAD/j/PTdZTHEHpiXDLRTG/M7iKgmIcOiixcpo6XZs4S2fpoWd7VCAC/VH28J y9q0FlxW93dQa29MzVR3+Nv4ZVWIJShg+A2/IZpeHWXv1JzSBY3aRR/GlUQSoyRjpc9u mDJA== X-Forwarded-Encrypted: i=1; AJvYcCVn+WOADcf2EMiSfQHSuGlxTKfmN+nBZastRjP7jLqrwUe7m3YXIXtS2qaUM+ACct86A8Q6Ob77wY9AD3nCN8rsl+HWdNmA41h0E1QG2dAe X-Gm-Message-State: AOJu0Yw/azNsEpann33P7QRblQrQr4uD4Xy1m6S6kcn9I3jQKmnaYG1f 3vDINCeWXgYCB2vJjBwVFM76gwh9CCE9X0nxNgRwV9FwzVLSEd8ZdLY4CFCebJA= X-Google-Smtp-Source: AGHT+IFQgj91jSGw2lUkZcvmJ8fK2VsBYSBL2HSqDtP8zaw7fuUgNF2lymwMr71eYZkL80x3yGmBkw== X-Received: by 2002:a05:6a00:4f94:b0:6e6:8df5:f77a with SMTP id ld20-20020a056a004f9400b006e68df5f77amr12893462pfb.31.1713200530140; Mon, 15 Apr 2024 10:02:10 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:09 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 07/20] RISC-V: Kconfig: Select deferred GSI probe for ACPI systems Date: Mon, 15 Apr 2024 22:31:00 +0530 Message-Id: <20240415170113.662318-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_180215_168956_D87D5443 X-CRM114-Status: UNSURE ( 9.19 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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 CONFIG option for RISC-V ACPI based platforms. Signed-off-by: Sunil V L --- arch/riscv/Kconfig | 1 + drivers/acpi/Kconfig | 3 +++ 2 files changed, 4 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 69cc0509a19a..d8cdb3535e44 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -15,6 +15,7 @@ config RISCV select ACPI_GENERIC_GSI if ACPI select ACPI_MCFG if (ACPI && PCI) select ACPI_REDUCED_HARDWARE_ONLY if ACPI + select ARCH_ACPI_DEFERRED_GSI if ACPI select ARCH_DMA_DEFAULT_COHERENT select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index e3a7c2aedd5f..ebec1707f662 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -587,6 +587,9 @@ config ACPI_PRMT substantially increase computational overhead related to the initialization of some server systems. +config ARCH_ACPI_DEFERRED_GSI + bool + endif # ACPI config X86_PM_TIMER From patchwork Mon Apr 15 17:01:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630394 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06F39C4345F for ; Mon, 15 Apr 2024 17:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q7Phr3+Yous8fGrUAUgA9ng6dgu/Uhu1ShcFhnwGDTc=; b=vCvn8SUw1qtKy5 tkdJ/JumVJcT5CnAWtWBfNDFIn6vljU9S2zg9CIGVKSV0jQ+niOB3vMUaucghmsbRTd9ysA7RLoHB IMkmxtxWIG0/SOTdl8MpuCSXNS0+l3wEIPcOZhaOHoOhNCez2jfJ+GOo95/kr2ud7izpWvOl7SxDi u0Y7f/WZae0M5k2CSAWRgfNoiJbTqjkPcasmOTETjLfuRcVDwLA+9jut6rpQUSqLvGyKUs8ETMlWf b6Oooj7K9YwG/6D0AYU0Z8nq0fiQHBVO7dMd6ZAYvVg89KfZealIiKSVdyhMJe5cVvJLEoQb0spaR vpKviVSfQg8srYMHPuZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjw-00000009Cd1-2ujJ; Mon, 15 Apr 2024 17:03:32 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPik-00000009BmT-3LgI for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:32 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ecf3943040so2743239b3a.0 for ; Mon, 15 Apr 2024 10:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200537; x=1713805337; darn=lists.infradead.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=wQjMcgzCCX1zvyyhnfJhjMc7UuQWOWfTm7mVOWGolO4=; b=iblOVtaB6DvGr+T0YQLc8/R21Naebi/mb7QCntIJm8rbj7niD4uVcxhmHSEMZIYd6n yTCPPZZ7uutZ8iA4hu1cVoa2QLjaiYu3O8RNn1Y+BCQpv44ztAevgE58ROh5c9fDI8mg gWjHoHoX+jWc6ubz63Co900IV8yiHjlUXq5mZzET7bn1fXexI70u7buGT+IJWhUU5p6H eE4RkpoW3Evg+3vyEKSto78X030qSKmBIaBlSgf7FhyDEdKEJYWOgA6qTThj17G8MLL/ DeL35AiGEV8PrHLg2cUnaVARAPqC2eoHLf7tRjtMFX6vEjw1tLy42juZhjVt9yUln+iv E0tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200537; x=1713805337; 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=wQjMcgzCCX1zvyyhnfJhjMc7UuQWOWfTm7mVOWGolO4=; b=OAUd9Y/MKmZBr0uOdoEpgnAMaT1o8ue0ZxozrPmzR9wbZfc9Z/dpC3H3kqIC3sbr6p o9S2crW6TZsgQIhsTIvL08Pt7Hs+5kHELqnftSplzHKyMOdFMf05pJMt4BYoqppZkR47 6ZkGyKldPEa0Ol4jw7Inp98wdfmgI09Xw4OqSPgnB21XJ+0YX0Yn9oRBtHs5/TglPpBv ldGLkAyqTLewc6NhVQaRmWdtZaO5WtztlgV5TV5IwDdT6CD1UNZ7NVqNjT5cX2xfwRIH f53sHuIL3LzvAHrzzFFgYmPz0XqciZX+5dzIKqzxd0CHTOTA6D7BwIhFCnieWVBbrfOe YThA== X-Forwarded-Encrypted: i=1; AJvYcCVMv+UtdzK7ICKjDgxHoRgoChLbet7D8BcSpU62q9lpxqjnLWT94D+CfSWzQlkXljF/Rm6lXLR7TDKW/2olYOZvF4SXuKiDxR+N4X6XPpHC X-Gm-Message-State: AOJu0Yzsis4hzC4r5XFwYPWm7XBrinK96hQNDKieCQR5HdsKHsza2n9V sG6lJx6oHU/qlbG+rj+kUMmLC2F3t7xgRksgAOUQr5qhl3uS3N0YJaygz137NUI= X-Google-Smtp-Source: AGHT+IEOKdv2GIoPVzAfszA+Mczkslu8VP2JvMat3iDp2rWUvNRo9ufo+FIpILZ6uWBafbyo9KluZw== X-Received: by 2002:a05:6a00:2314:b0:6ec:cec1:8fe3 with SMTP id h20-20020a056a00231400b006eccec18fe3mr10562037pfh.11.1713200536823; Mon, 15 Apr 2024 10:02:16 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:16 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 08/20] ACPI: scan: Refactor dependency creation Date: Mon, 15 Apr 2024 22:31:01 +0530 Message-Id: <20240415170113.662318-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100219_090705_B08FCCE5 X-CRM114-Status: GOOD ( 15.86 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Some architectures like RISC-V will use implicit dependencies like GSI map to create dependencies between interrupt controller and devices. To support doing that, the function which creates the dependency, is refactored bit and made public so that dependency can be added from outside of scan.c as well. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 48 ++++++++++++++++++++++++----------------- include/acpi/acpi_bus.h | 1 + 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index de30a0af7a2f..c8f40d81b6cb 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2028,33 +2028,18 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) } } -static u32 acpi_scan_check_dep(acpi_handle handle) +int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices) { - struct acpi_handle_list dep_devices; u32 count; int i; - /* - * Check for _HID here to avoid deferring the enumeration of: - * 1. PCI devices. - * 2. ACPI nodes describing USB ports. - * Still, checking for _HID catches more then just these cases ... - */ - if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID")) - return 0; - - if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) { - acpi_handle_debug(handle, "Failed to evaluate _DEP.\n"); - return 0; - } - - for (count = 0, i = 0; i < dep_devices.count; i++) { + for (count = 0, i = 0; i < dep_devices->count; i++) { struct acpi_device_info *info; struct acpi_dep_data *dep; bool skip, honor_dep; acpi_status status; - status = acpi_get_object_info(dep_devices.handles[i], &info); + status = acpi_get_object_info(dep_devices->handles[i], &info); if (ACPI_FAILURE(status)) { acpi_handle_debug(handle, "Error reading _DEP device info\n"); continue; @@ -2073,7 +2058,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle) count++; - dep->supplier = dep_devices.handles[i]; + dep->supplier = dep_devices->handles[i]; dep->consumer = handle; dep->honor_dep = honor_dep; @@ -2082,7 +2067,30 @@ static u32 acpi_scan_check_dep(acpi_handle handle) mutex_unlock(&acpi_dep_list_lock); } - acpi_handle_list_free(&dep_devices); + acpi_handle_list_free(dep_devices); + return count; +} + +static u32 acpi_scan_check_dep(acpi_handle handle) +{ + struct acpi_handle_list dep_devices; + u32 count = 0; + + /* + * Check for _HID here to avoid deferring the enumeration of: + * 1. PCI devices. + * 2. ACPI nodes describing USB ports. + * Still, checking for _HID catches more then just these cases ... + */ + if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID")) + return count; + + if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) { + acpi_handle_debug(handle, "Failed to evaluate _DEP.\n"); + return count; + } + + count += acpi_scan_add_dep(handle, &dep_devices); return count; } diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 1a4dfd7a1c4a..28a9b87c23fa 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -993,6 +993,7 @@ static inline void acpi_put_acpi_dev(struct acpi_device *adev) int acpi_wait_for_acpi_ipmi(void); +int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices); #else /* CONFIG_ACPI */ static inline int register_acpi_bus_type(void *bus) { return 0; } From patchwork Mon Apr 15 17:01:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630396 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0771C04FF9 for ; Mon, 15 Apr 2024 17:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=APdHGKF1VdkcDVjvSvH/QVtmbiqE/WMoLuDlgoi5Lpk=; b=Psg7LoX57lSguy Qa0toRqZ+u++sQdfM1WXs2AOK7yRzN5jS1BSqOsNUNwGaJ8K8JQai5LRv1CEhqsSYg5mnsnz7omSS DKmDzI7PZwYZ0oMIzgZUpun/VrJQfhOHo85sH6lk8KhzAcf3Wrx04F7MkpUHL64414wkBMB96LTc3 cJ+wfQPMg2NdgvEFhWsqgDJSIuzIuxGZFso9IoU1Ii1FMjzW6AcP2dWtsxZwSPvEZ43r4RRypL6Ns kryLOw6QK5cyOdH9v2KlMxunlGpUElc++RFs3Orpvr0rC5Zmswj1wPZoDcFsb73rqcyrzRwfjt/Ko 2CrPDqTb6tQOmiff9RFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPkH-00000009Crt-1WoD; Mon, 15 Apr 2024 17:03:53 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPiy-00000009BrA-1kwM for linux-riscv@bombadil.infradead.org; Mon, 15 Apr 2024 17:02:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=W2LHe0TiKeYFnNPgLCeAe5BF4w5DQy6QPlu5Fs7U6q4=; b=l43QAGDrETEL3JFf/KwPFPI9HI 7AU43Y76RqW4yDznuudY7Uo1dj54snCYY3P1f64EPD0yexfKsj406Eo79cLR9LM0wCTnu0jmnO/xj 0iYSANugqrDXvVGddWbOIznPCR/gxfH8sycfOaKjxpayw+wWIAcOLAHogoGZqGHdr85RwuXd4rhOl +H/2zp5GAFITHR7drvgx75P0MXB8H35Cx3+bwMOp5WuyJSlw+rDF1p+DIJt+PYFHbEdHpM+61uk46 PYsNc8qA7P77A4IvTtYUlyqy/Q5gwZiFmj+ugKG+lf/e4xrLM9G5XsXYzK39ny1Xz7536He8Z1kkr DkOrSbBA==; Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPir-0000000AfTv-3cS2 for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:31 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6e46dcd8feaso1422547b3a.2 for ; Mon, 15 Apr 2024 10:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200543; x=1713805343; darn=lists.infradead.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=W2LHe0TiKeYFnNPgLCeAe5BF4w5DQy6QPlu5Fs7U6q4=; b=BBIpJL47RAMUntJXJPedO+QjFl+CnSzbfWh+A/gyJ22vc9ubcVu78OUu1DGQ+XwRoL OGHcRRCySXOKKY6T0PnkVvLBME4tct5dY18dFsykklchtZN8xfVdxbCx1aDDt/VSsuJB O76ASnA31ebeNJHUews2YbVGhPZ1q/eO2Q2R6ZZrTM4coipUpdU4ENkEhLXK2mrl1NgS YyeBSQ3c/9CYeYYzYP2SpFe73fQiHs6m7aO5wBFGaH72sHBIjjd9BPmwYate77jsH5W3 0VrfMslxuUjmdn2Ci5nRt2+D0FiuLiw98ivjXbG5uAWa3CXXSeSRyevPVKPKORz5q0kt iDlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200543; x=1713805343; 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=W2LHe0TiKeYFnNPgLCeAe5BF4w5DQy6QPlu5Fs7U6q4=; b=HgEH6wYPRa+GtXk+9NMmMoIlCuxpQRUXUteYFNgMfzfKjEJm4G8BNr9gs7dUWmOhdv P8e9TND796RggUGavFoID5GGkPZvtQmin5t4pdy7j6jsVuU0htDuZssAQmsyi0Mpo59z t6cTgrGx5B+R7CEw+PLR1klqpQKmKtN23RmEXjAKrexwxP9crg9ST+LexwEAsTgtMy/k 9UhWH8Pawok347AC13U9PLrOkje+jzh4LOhjIENsUIVLRFs5yxUWwrbplWb3m8jVZjMo FDqwBHjhmjsNTxmUB2ff3CGnPqV7tNjt7ootaCU4wAhMCaqCxP0jHNpMmZJqPvUSg5cL Z5Yw== X-Forwarded-Encrypted: i=1; AJvYcCXMKY+iGFF0z1mesaauBq9jGRGu4vHd8uVrrtGz7NlMonWiWOJe2skQhI3YN9ZdZgU67e6ul9NqouYqonDjEuGDyPfASKAh26yNo9FMACvt X-Gm-Message-State: AOJu0Yw+u7Awlae4piMpm3dfKFYGhMJJB98dUA41rDv8GqV4jxBvltnO 1XFTPNs4k+KQrcSJuK2Ij8JzBjGk0PE8gaQtjhCfGUyy1JNOzbhBxYA5s3KutFQ= X-Google-Smtp-Source: AGHT+IHZPG6wbKkbl+YL/8OPMELdPpFA9RlWoys/7cQw/AgmouLy6gSngELWynfeqJUNk2wi6bZfdA== X-Received: by 2002:a05:6a00:3d0f:b0:6ed:41f3:431d with SMTP id lo15-20020a056a003d0f00b006ed41f3431dmr11412835pfb.0.1713200543335; Mon, 15 Apr 2024 10:02:23 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:22 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 09/20] drivers/acpi/scan.c: Update _DEP honor list Date: Mon, 15 Apr 2024 22:31:02 +0530 Message-Id: <20240415170113.662318-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_180226_144673_A31DC8E5 X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org RISC-V PLIC and APLIC will have _DEP from devices using GSI. So, add these devices into the honor list. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index c8f40d81b6cb..07e91616b7d4 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -832,6 +832,8 @@ static const char * const acpi_honor_dep_ids[] = { "INTC1095", /* IVSC (ADL) driver must be loaded to allow i2c access to camera sensors */ "INTC100A", /* IVSC (RPL) driver must be loaded to allow i2c access to camera sensors */ "INTC10CF", /* IVSC (MTL) driver must be loaded to allow i2c access to camera sensors */ + "RSCV0001", /* RISC-V PLIC */ + "RSCV0002", /* RISC-V APLIC */ NULL }; From patchwork Mon Apr 15 17:01:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630397 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C26FC00A94 for ; Mon, 15 Apr 2024 17:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+9KzKdPF1Hl/pLjf2DqPckQmapDu5As6S1W1VSQ1z9g=; b=CA2TdfOKcEd9QA hbJpOT3UKOz+FPS9XHleGAXM5qrhdx2507F+7E6FE3suTOao79KUhUVl+8WOHeSbsgA9/1tdIG7gH sRH8JmB7G+Oiu9WJncTXRCkjZEsC1A8WXyOoZzI4wIc/SPNJ1V6ljQbKYGoJzl1QAsUV3mEgICFMK gum4Jzo6FQBj0NrliyzYtHQPMzPx4jRZmmeDGoEmC4FwuhHdFkLAsEB0jH4nI3KBVTAvX5oXFkV2z PAJ6cS4J1uEyIHZ8PyqSO6256Ww3KxAYE2xKTao0N9St8FZM4t3IWvISMXDy2SFrzNpAWkC1innb5 aQlposUR+7lb0wQM67UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPkR-00000009Cyl-0sTq; Mon, 15 Apr 2024 17:04:03 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPj5-00000009BvV-3gB6 for linux-riscv@bombadil.infradead.org; Mon, 15 Apr 2024 17:02:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=qa8aPZaBb5SHnjDhwNe5AO6s82EyT//Q/0nqKZneQ7s=; b=YzAEF/2OIfULkXa8veXw9nKJN8 rfeitZUcQVDna7dHbzlx4sqtwyynrNTCXu0L8ZkOJwGosobz5quRjRg2TBQPt9OMwHH/iNVC2YepH kJfMMUJuFEBdlsNcDL/QmwPFxizkN86QlcnlkCQq/WqUB5m1nwM9tA59xIofLH+jbhVzUW7JXaOz1 OM4Tum6o/9dDPcmzPBKXyZ0rR1I8+weh98M0k9VxBki9H1jeQCNvQyH7md9NMTY5zBHstEH1e1xed hM9O9E09ht9zMa9KgCJBi2LGZkefkzAVZG66jdfaie72BXjc3zx3wc61YoSivYLxWBpNvXhFoV3y9 Q3frZKQA==; Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPiy-0000000AfVr-0KWv for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:38 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ee12766586so2243921b3a.0 for ; Mon, 15 Apr 2024 10:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200551; x=1713805351; darn=lists.infradead.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=qa8aPZaBb5SHnjDhwNe5AO6s82EyT//Q/0nqKZneQ7s=; b=B4CpJZdIqgAT1EweGtJUFNDeOLQlb1q3b8qX8GTq6KQ1//u1uQo1WldFZ1K1B9roL8 0A3rMnmCreUcRet0abEWVb0rciS7NgEXlhV6cUMkIvbi3reJzDyKDLGpDnT+WE5JT/Dp i7q8ZPxgB2uaPkOd7l1CAilwIHAa6yN49PYaPChmY1chdhL0swRPvHFawSjIiWB/sSrj iqKEsSfMbcvzq1VjCjmnV7OmHsmwkUEcQLHARVfX/CuKl6DChEt4le50sod+BWP5CZ3n IiLONH/NaRtQGrNPZc4vcODHVnKepxRAV1QG2uDMRxyWQA7KYqIeci/4/7CygfeeHnEX kXEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200551; x=1713805351; 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=qa8aPZaBb5SHnjDhwNe5AO6s82EyT//Q/0nqKZneQ7s=; b=wlAQQREi2bcyjf/NMJXfD74gTwZR97x0JDAlg1lZbVeg7XQa7d2eFB1WNNFPDmIiIs dNjK/Ltnq39LtCAUmCLZnewEMFlCLsATHmrT0LpXdf/1+UUmnGm9MgxLsD/5FGAQrpSC 6f8al3u4QDUn6dasmZwAY4uMSRxb0U8cBHd4v1PMzi2kGhshllQ0krAWN3+GVQMa5i/t ISh3vifXudUgAlfweSBnIsptWrlO+IBzEEcFWFRWRme6wvn8fxXjYV1TbN1u25CbpeFB i+Awb+sn8C7JDbuHnjEjjGCZCkTFYMatyOPi/ERtSUTdCljp8IruQy7J5YIKbRy9mFZy lATQ== X-Forwarded-Encrypted: i=1; AJvYcCVcRfDgvxc4skiaaGl1z4t1Swu5DUXvgq6y7od2HbIENEtxhCEUEfvs8HqmimMAm3c4gePSy7khFE8LA2XilWAvuGpPUdLcqTEF2tgPaQys X-Gm-Message-State: AOJu0YxyiDRS/HKWHgaWNpEiz8x2nyMzS4iROULKbo+EMRUXufac1HK1 OLaugQME2O4+H7ZhWvQNOVNUWP/NfYq9LXJ6bSewp43PDVhpUvHoiIKaKW+03Mw= X-Google-Smtp-Source: AGHT+IGeXHiOC0F13RXgbWt688j7t9WtlnZZWw2iOK4tJHmoNhJ03Rmp2MstRb1M8cWB8bLvffMYEA== X-Received: by 2002:a05:6a00:c88:b0:6ec:e21b:24f with SMTP id a8-20020a056a000c8800b006ece21b024fmr288145pfv.10.1713200550215; Mon, 15 Apr 2024 10:02:30 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:29 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 10/20] RISC-V: ACPI: Initialize GSI mapping structures Date: Mon, 15 Apr 2024 22:31:03 +0530 Message-Id: <20240415170113.662318-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_180232_232177_A47C2AF5 X-CRM114-Status: GOOD ( 19.42 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org RISC-V has PLIC and APLIC in MADT as well as namespace devices. Initialize the list of those structures using MADT and namespace devices to create mapping between the ACPI handle and the GSI ranges. This is will be used later to add dependencies. Signed-off-by: Sunil V L --- arch/riscv/include/asm/irq.h | 22 +++++ drivers/acpi/riscv/init.c | 2 + drivers/acpi/riscv/init.h | 4 + drivers/acpi/riscv/irq.c | 159 +++++++++++++++++++++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 drivers/acpi/riscv/init.h diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 8e10a94430a2..44a0b128c602 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -16,4 +16,26 @@ void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void)); struct fwnode_handle *riscv_get_intc_hwnode(void); +#ifdef CONFIG_ACPI + +enum riscv_irqchip_type { + ACPI_RISCV_IRQCHIP_INTC = 0x00, + ACPI_RISCV_IRQCHIP_IMSIC = 0x01, + ACPI_RISCV_IRQCHIP_PLIC = 0x02, + ACPI_RISCV_IRQCHIP_APLIC = 0x03, +}; + +int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, + u32 *id, u32 *nr_irqs, u32 *nr_idcs); +struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 gsi); + +#else +static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, + u32 *id, u32 *nr_irqs, u32 *nr_idcs) +{ + return 0; +} + +#endif /* CONFIG_ACPI */ + #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c index b5807bbdb171..56780af6ceb3 100644 --- a/drivers/acpi/riscv/init.c +++ b/drivers/acpi/riscv/init.c @@ -6,7 +6,9 @@ */ #include +#include "init.h" void __init acpi_riscv_init(void) { + riscv_acpi_init_gsi_mapping(); } diff --git a/drivers/acpi/riscv/init.h b/drivers/acpi/riscv/init.h new file mode 100644 index 000000000000..2a488ec684b9 --- /dev/null +++ b/drivers/acpi/riscv/init.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include + +int __init riscv_acpi_init_gsi_mapping(void); diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 36e0525b3235..de0f1ba92068 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -7,6 +7,21 @@ #include #include +#include + +#include "init.h" + +struct riscv_ext_intc_list { + acpi_handle handle; + u32 gsi_base; + u32 nr_irqs; + u32 nr_idcs; + u32 id; + u32 type; + struct list_head list; +}; + +LIST_HEAD(ext_intc_list); static int irqchip_cmp_func(const void *in0, const void *in1) { @@ -30,3 +45,147 @@ void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) return; sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); } + +static int riscv_acpi_update_gsi_handle(u32 gsi_base, acpi_handle handle) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i, *tmp; + + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element = list_entry(i, struct riscv_ext_intc_list, list); + if (gsi_base == ext_intc_element->gsi_base) { + ext_intc_element->handle = handle; + return 0; + } + } + + return -1; +} + +static acpi_handle riscv_acpi_get_gsi_handle(u32 gsi) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i, *tmp; + + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element = list_entry(i, struct riscv_ext_intc_list, list); + if (gsi >= ext_intc_element->gsi_base && + gsi < (ext_intc_element->gsi_base + ext_intc_element->nr_irqs)) + return ext_intc_element->handle; + } + + return NULL; +} + +int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, + u32 *id, u32 *nr_irqs, u32 *nr_idcs) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i, *tmp; + + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element = list_entry(i, struct riscv_ext_intc_list, list); + if (ext_intc_element->handle == ACPI_HANDLE_FWNODE(fwnode)) { + *gsi_base = ext_intc_element->gsi_base; + *id = ext_intc_element->id; + *nr_irqs = ext_intc_element->nr_irqs; + if (nr_idcs) + *nr_idcs = ext_intc_element->nr_idcs; + return 0; + } + } + + return -ENODEV; +} + +struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 gsi) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct acpi_device *adev; + struct list_head *i, *tmp; + + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element = list_entry(i, struct riscv_ext_intc_list, list); + if (gsi >= ext_intc_element->gsi_base && + gsi < (ext_intc_element->gsi_base + ext_intc_element->nr_irqs)) { + adev = acpi_fetch_acpi_dev(ext_intc_element->handle); + if (!adev) + return NULL; + + return acpi_fwnode_handle(adev); + } + } + + return NULL; +} + +static int __init riscv_acpi_register_ext_intc(u32 gsi_base, u32 nr_irqs, u32 nr_idcs, + u32 id, u32 type) +{ + struct riscv_ext_intc_list *ext_intc_element; + + ext_intc_element = kzalloc(sizeof(*ext_intc_element), GFP_KERNEL); + if (!ext_intc_element) + return -1; + + ext_intc_element->gsi_base = gsi_base; + ext_intc_element->nr_irqs = nr_irqs; + ext_intc_element->nr_idcs = nr_idcs; + ext_intc_element->id = id; + list_add_tail(&ext_intc_element->list, &ext_intc_list); + return 0; +} + +static acpi_status __init riscv_acpi_create_gsi_map(acpi_handle handle, u32 level, + void *context, void **return_value) +{ + acpi_status status; + u64 gbase; + + if (!acpi_has_method(handle, "_GSB")) + return AE_OK; + + status = acpi_evaluate_integer(handle, "_GSB", NULL, &gbase); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to evaluate _GSB method\n"); + return AE_OK; + } + + riscv_acpi_update_gsi_handle((u32)gbase, handle); + return AE_OK; +} + +static int __init riscv_acpi_aplic_parse_madt(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_madt_aplic *aplic = (struct acpi_madt_aplic *)header; + + riscv_acpi_register_ext_intc(aplic->gsi_base, aplic->num_sources, + aplic->num_idcs, aplic->id, ACPI_RISCV_IRQCHIP_APLIC); + return 0; +} + +static int __init riscv_acpi_plic_parse_madt(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_madt_plic *plic = (struct acpi_madt_plic *)header; + + riscv_acpi_register_ext_intc(plic->gsi_base, plic->num_irqs, 0, + plic->id, ACPI_RISCV_IRQCHIP_PLIC); + return 0; +} + +int __init riscv_acpi_init_gsi_mapping(void) +{ + int count = 0; + + count = acpi_table_parse_madt(ACPI_MADT_TYPE_PLIC, riscv_acpi_plic_parse_madt, 0); + if (count <= 0) { + acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, riscv_acpi_aplic_parse_madt, 0); + acpi_get_devices("RSCV0002", riscv_acpi_create_gsi_map, NULL, NULL); + return 0; + } + + acpi_get_devices("RSCV0001", riscv_acpi_create_gsi_map, NULL, NULL); + return 0; +} From patchwork Mon Apr 15 17:01:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630398 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42283C04FF9 for ; Mon, 15 Apr 2024 17:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OUEaS01YSO4Ss2b5TjPbS8aP5SQQpgaf+eEzC7K1D5s=; b=TVHOtKOy4caIl3 gKuyMyvTuowmofuTPEcMGtOki2XUlQcRDcwf0AqqchpYsBbbij4ravwI2Z7zNWwAP0/nmSJ3AugWP 5ea/t1Nq9DlB/7BAY0ouq/97aPr/LsVKlOA54siAt4uZG6D2IDD3f3JdJwnnHDyYUctpqkKY8EJ6n 50UIgb5J/9HUimT4JsRVoXAMrFKh492wK5NcUW7Fqo21yquzDvn04GCp8J8rIoNh9jUNFn6+yd73F wy1vEJdF7Q0FPZKWtr3+dpHzDeMNXRuqGVRHP6etVBaOnb13eVAbchLHTJLiB3RaaCEeOl1gdamKM 2ENFBf9UcBICceWsZwnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPkU-00000009D2d-2NeC; Mon, 15 Apr 2024 17:04:06 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPj4-00000009BvE-3o4Q for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:43 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6ed627829e6so3793131b3a.1 for ; Mon, 15 Apr 2024 10:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200558; x=1713805358; darn=lists.infradead.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=c1X7evQ35uoewh1RNAGJwcs/iaU3rzDK4qB90vlKVhs=; b=TVAvIrfMtQduvk8zQ40e/OYjUGhMHJKGQ2zUVoNQVPGbvqTUBCTa+WQAv3nXzOMqtj Af7MQ0ElKh/vJfTdwMo6ppGoVSJ5bFFU+s6bOA7ym+MYLgDJEjk4vGMHQxvroSWeQQAj aufJUtspWr/lYWGgYuzEY1go+yUG/UNG6S6dgn76rNFEME49K7kbSxUC2aXLFF+hYhkw uQtBy/yBRPMk8/nNjF81v+HbkPa1Y3GFKs5+ijF7meQtD8duDHL+S5dXEWVwmB7QUlSx b0kcXnxZ4jK/PDajEyE8FKzJu18Hrb2Tif9sMrioNOdPjUQCsTi06uPz0r8Q2bd0BuCb dWCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200558; x=1713805358; 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=c1X7evQ35uoewh1RNAGJwcs/iaU3rzDK4qB90vlKVhs=; b=PRgN3YwQOWXCOfhVvv2hVB1EWCeXXXb4U7UW4h9PBppYgteJ3Nw6uNEP4v4W6fwWEq qwnrgPFzkSoPejiSG4cRbo/eMuwo3isbOhpV7WYyWzbHpGoQoJb9o6Z50sHUd4kpZt8N aDNZtbFQAHmwTc3GMCSDY0kY8Oxlv687d9KwNJniKTIVSk1kpLABaEddA+2vaXeamhKy 5vTFWT3jvmtDOvKlNdujxLmqnHKMOX/uAZL3/aausK33jeEJaSTLc7z3oGPlnvb8Gv8J dpfChzfTFCfN2vv/EzLMv+1luFawowx6MWUz1+g98U4pYu0/MAOeReHafFow8dW/MNRa 69jw== X-Forwarded-Encrypted: i=1; AJvYcCUxZaaX5HA8iY1ZDj8LQS9Q4V5Ewh/LpGedmOA201scFeSBZVdKky/dTmVe6WZaFncmq6ErhqTQIA6L52tBFbXSQSWBx5b7jgYYgDy/9BTi X-Gm-Message-State: AOJu0YzsUQAZxB3CoOxdDe7UQd3rRSNsk7pQq9oikQ2hgFYqGPp695/b 2MNFisKy74zBohzpWlub4MapmCzdVJqpMwVyCuWYzOwme4EzBqBtKmhGpiQj1Uw= X-Google-Smtp-Source: AGHT+IHP5Rv0C3YxWinnwyj54lMdddb7BaD0yQpP0Yg8Qswii7cMjohW9Wcp53K9v1it+Ov4jHo51g== X-Received: by 2002:a05:6a00:181d:b0:6ec:fe26:4ec1 with SMTP id y29-20020a056a00181d00b006ecfe264ec1mr12412388pfa.22.1713200558011; Mon, 15 Apr 2024 10:02:38 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:36 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 11/20] ACPI: scan.c: Define weak function to populate dependencies Date: Mon, 15 Apr 2024 22:31:04 +0530 Message-Id: <20240415170113.662318-12-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100239_219065_B0E9BEDD X-CRM114-Status: GOOD ( 12.90 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Some architectures like RISC-V need to add dependencies without explicit _DEP. Define a weak function which can be implemented by the architecture. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 11 +++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 07e91616b7d4..8e23b9508716 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2073,11 +2073,22 @@ int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices) return count; } +u32 __weak arch_acpi_add_auto_dep(acpi_handle handle) { return 0; } + static u32 acpi_scan_check_dep(acpi_handle handle) { struct acpi_handle_list dep_devices; u32 count = 0; + /* + * Some architectures like RISC-V need to add dependencies for + * all devices which use GSI to the interrupt controller so that + * interrupt controller is probed before any of those devices. + * Instead of mandating _DEP on all the devices, detect the + * dependency and add automatically. + */ + count += arch_acpi_add_auto_dep(handle); + /* * Check for _HID here to avoid deferring the enumeration of: * 1. PCI devices. diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 28a9b87c23fa..5fba4075d764 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -994,6 +994,7 @@ static inline void acpi_put_acpi_dev(struct acpi_device *adev) int acpi_wait_for_acpi_ipmi(void); int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices); +u32 arch_acpi_add_auto_dep(acpi_handle handle); #else /* CONFIG_ACPI */ static inline int register_acpi_bus_type(void *bus) { return 0; } From patchwork Mon Apr 15 17:01:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630406 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84E61C4345F for ; Mon, 15 Apr 2024 17:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=21TDMqV/sekptJo1BBdgWQxV5cqHzfiTuBRug/QjEys=; b=ljeerre4StdbNa a3biy3+F5wAz5/GDShstqDZcX2GW0Knc+HLt4JUWLt7yfSCKgcb6Pc8njdF5LyYRVrBwyGYCUkw5d hJF2ub76WV8kcL8+tdinFJBAYuck68I0bZEQZzw53f54D1amNwpFK6gws0BcOvarZHquHfV+yUOBy 6kG/9VCrkNr9ytgcry7Zq6LQfKpY+11zFAsca8TBlIXSSB4rlfMUcQWY6X30YinAZ/Sas2zbzfhvh fkf7+6LN0bc/xx7v1o7rCfMz0U1kzscG1MAPntyBEfqReLERz6uBv/M0fjdXHoKzJa+bUhaK0d0OB j3NcrhM3SqLgVlN1wKSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPmW-00000009EeS-134w; Mon, 15 Apr 2024 17:06:12 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjB-00000009C0j-1o6r for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:02:50 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6eff9dc1821so1050134b3a.3 for ; Mon, 15 Apr 2024 10:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200564; x=1713805364; darn=lists.infradead.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=YAAOkQmqhfZx+8yFnraUuWf5SW+MXW6uPQvUnDzGd+Y=; b=LTJ3uXKi8pkofTRMKpcn1xNJqX5Lh9diuM9Ar1kH5aIRkWzEkNd4Zlvv7eKvWFYxif k9WGBI9PoZJ9rWEfo076c0dAicyDePg9zv6yu97UZIen/7yaVJJwCE1Gg16rVHRK36u2 Tww29VdBGX3GDzuaHo5yEm2ZCyyPb78gJfzwAf5Tb3zzTCYiUbhdsWr+N21FaX3tDOpI KcaqIlY5G2ST3pDh36418A/vnqIfqwkPEKP/oq1dae8KfF1XK8D0gE1IW0plxV0sHFvp NcP2qcf3pn1kEr8x8gF961emn2odUEqjenXeZa6vDKIBmDKKDzmOUkcbwB1qwTN34t9n TH3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200564; x=1713805364; 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=YAAOkQmqhfZx+8yFnraUuWf5SW+MXW6uPQvUnDzGd+Y=; b=p+rqiEBQ5rQ8NpXRsp8U/fOdV3Jlgz+E75F5ZxlkcVy72egHMG7D4soeDmMn8ERJKx r1lqvr8DFrJJUu5tXbOJbVyfFDq54kE1LApTgqiDjG1AvJncyepVbyOM2j462kp7JKk9 uv63bNo9irnr5Tpcqh9hQqQkEL23zr135UyV5zR/yMUcexTNX9ZQyvxfnPm5AXzixUZj ltf3YuJuj/AXHY/PO4QQ284/97duGtU9J+udu60WLMREMuCStQgN5zKth7yE/NREBZSc Cc2VPdKn+VPQTBlFPbtPMkQg3NjabbSp8yREGP2+JF/POr1/3I0k+e7IYLfbvvcvDT65 U5dg== X-Forwarded-Encrypted: i=1; AJvYcCUHOKX2yjdJtAxCX2p9XMzJgxuiLeCA8qfjzsiddYZzFU40iTH0u6FQJ3A95WKWJmwSvVmK1JhE+Zg2yWo91gQEw/629bGWlr0Leh4opaqR X-Gm-Message-State: AOJu0Yz8JyLwNS6ppB2uL9wW2cK0O85A+8hT4n5g+AovG/fuTX+G3fc8 AK1rfKk+Owv5IX/PSgI/IkPrqyTUkWBG5euIznevjB4sadszNNQAzmfZolj81oM= X-Google-Smtp-Source: AGHT+IG8/n77ZcwDo0dpINsAseTYN5DCCn1UfCXRDczymjXSK0MA9f3AzxnPM1y3GqoYLRAp+ADrkw== X-Received: by 2002:a05:6a00:4686:b0:6ee:1b6e:662a with SMTP id de6-20020a056a00468600b006ee1b6e662amr7890055pfb.32.1713200564540; Mon, 15 Apr 2024 10:02:44 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:44 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 12/20] RISC-V: ACPI: Implement function to add implicit dependencies Date: Mon, 15 Apr 2024 22:31:05 +0530 Message-Id: <20240415170113.662318-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100245_849220_0566BF0D X-CRM114-Status: GOOD ( 18.84 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org RISC-V interrupt controllers for wired interrupts are platform devices and hence their driver will be probed late. Also, APLIC which is one such interrupt controller can not be probed early since it needs MSI services. This needs a probing order between the interrupt controller driver and the device drivers. _DEP is typically used to indicate such dependencies. However, the dependency may be already available like GSI mapping. Hence, instead of an explicit _DEP, architecture can find the implicit dependencies and add to the dependency list. For RISC-V, add the dependencies for below use cases. 1) For devices which has IRQ resource, find out the interrupt controller using GSI number map and add the dependency. 2) For PCI host bridges: a) If _PRT indicate PCI link devices, add dependency on the link device. b) If _PRT indicates GSI, find out the interrupt controller using GSI number map and add the dependency. Signed-off-by: Sunil V L --- drivers/acpi/riscv/irq.c | 132 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index de0f1ba92068..f98645461bbe 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -21,6 +21,12 @@ struct riscv_ext_intc_list { struct list_head list; }; +struct acpi_irq_dep_ctx { + int rc; + unsigned int index; + acpi_handle handle; +}; + LIST_HEAD(ext_intc_list); static int irqchip_cmp_func(const void *in0, const void *in1) @@ -189,3 +195,129 @@ int __init riscv_acpi_init_gsi_mapping(void) acpi_get_devices("RSCV0001", riscv_acpi_create_gsi_map, NULL, NULL); return 0; } + +static acpi_status riscv_acpi_irq_get_parent(struct acpi_resource *ares, void *context) +{ + struct acpi_irq_dep_ctx *ctx = context; + struct acpi_resource_irq *irq; + struct acpi_resource_extended_irq *eirq; + + switch (ares->type) { + case ACPI_RESOURCE_TYPE_IRQ: + irq = &ares->data.irq; + if (ctx->index >= irq->interrupt_count) { + ctx->index -= irq->interrupt_count; + return AE_OK; + } + ctx->handle = riscv_acpi_get_gsi_handle(irq->interrupts[ctx->index]); + return AE_CTRL_TERMINATE; + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + eirq = &ares->data.extended_irq; + if (eirq->producer_consumer == ACPI_PRODUCER) + return AE_OK; + + if (ctx->index >= eirq->interrupt_count) { + ctx->index -= eirq->interrupt_count; + return AE_OK; + } + + /* Not supported */ + if (eirq->resource_source.string_length) + return AE_OK; + + ctx->handle = riscv_acpi_get_gsi_handle(eirq->interrupts[ctx->index]); + return AE_CTRL_TERMINATE; + } + + return AE_OK; +} + +static int riscv_acpi_irq_get_dep(acpi_handle handle, unsigned int index, acpi_handle *gsi_handle) +{ + struct acpi_irq_dep_ctx ctx; + + ctx.rc = -EINVAL; + ctx.index = index; + acpi_walk_resources(handle, METHOD_NAME__CRS, riscv_acpi_irq_get_parent, &ctx); + *gsi_handle = ctx.handle; + if (*gsi_handle) + return 1; + + return 0; +} + +static u32 riscv_acpi_add_prt_dep(acpi_handle handle) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_pci_routing_table *entry; + struct acpi_handle_list dep_devices; + acpi_handle gsi_handle; + acpi_handle link_handle; + acpi_status status; + u32 count = 0; + + status = acpi_get_irq_routing_table(handle, &buffer); + if (ACPI_FAILURE(status)) { + kfree(buffer.pointer); + return 0; + } + + entry = buffer.pointer; + while (entry && (entry->length > 0)) { + if (entry->source[0]) { + acpi_get_handle(handle, entry->source, &link_handle); + dep_devices.count = 1; + dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL); + if (!dep_devices.handles) + continue; + + dep_devices.handles[0] = link_handle; + count += acpi_scan_add_dep(handle, &dep_devices); + } else { + gsi_handle = riscv_acpi_get_gsi_handle(entry->source_index); + dep_devices.count = 1; + dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL); + if (!dep_devices.handles) + continue; + + dep_devices.handles[0] = gsi_handle; + count += acpi_scan_add_dep(handle, &dep_devices); + } + + entry = (struct acpi_pci_routing_table *) + ((unsigned long)entry + entry->length); + } + + kfree(buffer.pointer); + return count; +} + +static u32 riscv_acpi_add_irq_dep(acpi_handle handle) +{ + struct acpi_handle_list dep_devices; + acpi_handle gsi_handle; + u32 count = 0; + int i; + + for (i = 0; + riscv_acpi_irq_get_dep(handle, i, &gsi_handle); + i++) { + dep_devices.count = 1; + dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL); + if (!dep_devices.handles) + continue; + + dep_devices.handles[0] = gsi_handle; + count += acpi_scan_add_dep(handle, &dep_devices); + } + + return count; +} + +u32 arch_acpi_add_auto_dep(acpi_handle handle) +{ + if (acpi_has_method(handle, "_PRT")) + return riscv_acpi_add_prt_dep(handle); + + return riscv_acpi_add_irq_dep(handle); +} From patchwork Mon Apr 15 17:01:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630399 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF812C4345F for ; Mon, 15 Apr 2024 17:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pdNDWxrFzkJu8KWPcxswXg1aabAMEPy5ZafrzYQ4V6o=; b=koQt9/ow9qmrw6 6vgrSTvOytKs8kEYMGksy9ukkrcfqnylYfwVtEVPjywyyXfJLfZ/E3X/QyWtZiwgt9hScV9t62lLQ QEZmhwGTNDYqu6LranHl++AN+nkUJk6BL3n1iDcu/okuEmnVXmPUWsNJKWpBS0FQwdS1R2j/iv8o4 W52eufXnSrBmq4/QQpsApnqCRPTu5NM2Jf1ukfa7wgJFbTIx3pIYG7Z+T+gelDHD8UuXKjCmj97Nk ghHiAVEI4Lm5VqnPm5QirvvnBcaHeItRh5eLb0E1A5LyGNllQG3ho/N/dqbMhpfRPa76hyGB0Zv83 SH+6IhuqOxzTridzeVNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPl8-00000009DbN-22t9; Mon, 15 Apr 2024 17:04:46 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjH-00000009C6O-3zI1 for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:03:00 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6ecf8ebff50so2273311b3a.1 for ; Mon, 15 Apr 2024 10:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200571; x=1713805371; darn=lists.infradead.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=nLDuZBMdOA5LsIhe/7seDXRfkc825n/BCOMnccmbKZw=; b=oVTZluoQhpSCtITp5M7ZyOsomESZOM+jbma6hl+Md4TYixgbHTXQFe2N4Dj2jO54Wx OTlxYEiTQktkx3Ba5uqQqgzcgwSa6uFdekYAUA44DUdYINyus8kmXbPUqyFVmh8QQokG l49hBeJgKQcOpGJ/UyTFswiHqoD+FJgwZZTe+BcMVwzrM3/iZpGOMy3RlThp1CudxnSg 06gwCk+QdfrgKvV+wwHoKZm6ZTbIH7e8snRCrfCUU6pu6fU/JlMbxlVtFcg6zBGbDuod 5o3Jesj1itNvuf1VG+n/AzQFAkBngMQD9MwcEvlhulIUGxuN4pIl1uTloCexYfTgNT9A WnDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200571; x=1713805371; 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=nLDuZBMdOA5LsIhe/7seDXRfkc825n/BCOMnccmbKZw=; b=cASU+WeLeC3ohdjQifsVtEEbmT9EvJKTLEtK1stXce+wo3NPP86mS/63SZLz/4PKWi fMB6aXMvgibQYgpqW2luBfYYp0I8vV351wyq4FUy2dJJXJOxO5TjjUHNfUObexbz4gVx 77YCc6kwHm7Yrk6fuIHPUGklfgYWYu8jzP8+Uk0ydIYmObeGHcaZmYsZ80fOmUDnm/4v h7S/mtBP6A7S3FLKk9y3z99FRLOdaNGpQserNNuEOmltVyJXfIUVu0zDiYOEMYAI+x7S aRLPVH/psJSDfOO+0Z4sml1LXxppndo900XTb8deRzBbvB2+0e0lFclM9aEjvISFx5Zw OOog== X-Forwarded-Encrypted: i=1; AJvYcCVFeiVFzaspVkQJfA8HYnN4LO7NYc0ujavefUnSqLcs4sVESyQW5RHpAVFRHmx6i7I8uwjFCN+H+mbIzKRy6jMFa3dVjjZJvfnxTiaAiQ3M X-Gm-Message-State: AOJu0YwAZ2m5cSj+/c39sKppJSwZzSa1GbHN75b55kgHVXt/bAeeGoM+ wekmfcbzbW1pdAYaf/siXYuYNPks1J77JpRMkztddbd3zDInksFtaZXm9eKN94c= X-Google-Smtp-Source: AGHT+IE0Br/sfLtBzDZxNra+WQQQj8UhdqDe5qbQkKbjYH9VavooVHUHBefLx4JOZPgJS4SQ5vD0ww== X-Received: by 2002:a05:6a00:190e:b0:6ec:fa34:34ab with SMTP id y14-20020a056a00190e00b006ecfa3434abmr279743pfi.9.1713200571057; Mon, 15 Apr 2024 10:02:51 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:50 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 13/20] ACPI/PNP: Initialize PNP devices skipped due to _DEP Date: Mon, 15 Apr 2024 22:31:06 +0530 Message-Id: <20240415170113.662318-14-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100252_392533_50729C96 X-CRM114-Status: GOOD ( 18.45 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org When PNP devices have _DEP, they will not be enumerated in pnpacpi_init() unless the dependency is met. Hence, when such PNP device's supplier device is probed, the PNP device need to be added to the PNP data structures. So, introduce pnpacpi_init_2() for doing this which gets called as part of clearing the dependency. This is currently required for RISC-V. Hence, restricted the code with a CONFIG option enabled for RISC-V. Since pnpacpi_add_device() can be called now even after boot, __init attribute is removed from pnpacpi_add_device() and its dependent functions. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 4 +++ drivers/pnp/pnpacpi/core.c | 24 ++++++++++--- drivers/pnp/pnpacpi/rsparser.c | 63 +++++++++++++++++----------------- include/linux/pnp.h | 7 ++++ 4 files changed, 62 insertions(+), 36 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 8e23b9508716..086ae040a5ad 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -2370,6 +2371,9 @@ static void acpi_scan_clear_dep_fn(struct work_struct *work) acpi_bus_attach(cdw->adev, (void *)true); acpi_scan_lock_release(); + if (IS_ENABLED(CONFIG_ARCH_ACPI_DEFERRED_GSI) && IS_ENABLED(CONFIG_PNPACPI)) + pnpacpi_init_2(cdw->adev); + acpi_dev_put(cdw->adev); kfree(cdw); } diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index a0927081a003..c81893fc1fb2 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -26,7 +26,7 @@ static int num; #define TEST_ALPHA(c) \ if (!('A' <= (c) && (c) <= 'Z')) \ return 0 -static int __init ispnpidacpi(const char *id) +static int ispnpidacpi(const char *id) { TEST_ALPHA(id[0]); TEST_ALPHA(id[1]); @@ -194,7 +194,7 @@ struct pnp_protocol pnpacpi_protocol = { }; EXPORT_SYMBOL(pnpacpi_protocol); -static const char *__init pnpacpi_get_id(struct acpi_device *device) +static const char *pnpacpi_get_id(struct acpi_device *device) { struct acpi_hardware_id *id; @@ -206,7 +206,7 @@ static const char *__init pnpacpi_get_id(struct acpi_device *device) return NULL; } -static int __init pnpacpi_add_device(struct acpi_device *device) +static int pnpacpi_add_device(struct acpi_device *device) { struct pnp_dev *dev; const char *pnpid; @@ -283,6 +283,23 @@ static int __init pnpacpi_add_device(struct acpi_device *device) return 0; } +int pnpacpi_disabled; + +#ifdef CONFIG_ARCH_ACPI_DEFERRED_GSI +void pnpacpi_init_2(struct acpi_device *adev) +{ + if (acpi_disabled || pnpacpi_disabled) + return; + + if (!adev) + return; + + if (acpi_is_pnp_device(adev) && acpi_dev_ready_for_enumeration(adev)) + pnpacpi_add_device(adev); +} + +#endif + static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, u32 lvl, void *context, void **rv) @@ -296,7 +313,6 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, return AE_OK; } -int pnpacpi_disabled __initdata; static int __init pnpacpi_init(void) { if (acpi_disabled || pnpacpi_disabled) { diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index c02ce0834c2c..1008599901a2 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -289,9 +289,9 @@ int pnpacpi_parse_allocated_resource(struct pnp_dev *dev) return 0; } -static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource_dma *p) +static void pnpacpi_parse_dma_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource_dma *p) { int i; unsigned char map = 0, flags; @@ -303,9 +303,9 @@ static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, pnp_register_dma_resource(dev, option_flags, map, flags); } -static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource_irq *p) +static void pnpacpi_parse_irq_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource_irq *p) { int i; pnp_irq_mask_t map; @@ -320,9 +320,9 @@ static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, pnp_register_irq_resource(dev, option_flags, &map, flags); } -static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource_extended_irq *p) +static void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource_extended_irq *p) { int i; pnp_irq_mask_t map; @@ -344,9 +344,9 @@ static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, pnp_register_irq_resource(dev, option_flags, &map, flags); } -static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource_io *io) +static void pnpacpi_parse_port_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource_io *io) { unsigned char flags = 0; @@ -357,16 +357,16 @@ static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, } static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource_fixed_io *io) + unsigned int option_flags, + struct acpi_resource_fixed_io *io) { pnp_register_port_resource(dev, option_flags, io->address, io->address, 0, io->address_length, IORESOURCE_IO_FIXED); } -static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource_memory24 *p) +static void pnpacpi_parse_mem24_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource_memory24 *p) { unsigned char flags = 0; @@ -376,9 +376,9 @@ static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, p->alignment, p->address_length, flags); } -static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource_memory32 *p) +static void pnpacpi_parse_mem32_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource_memory32 *p) { unsigned char flags = 0; @@ -388,9 +388,9 @@ static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, p->alignment, p->address_length, flags); } -static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource_fixed_memory32 *p) +static void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource_fixed_memory32 *p) { unsigned char flags = 0; @@ -400,9 +400,9 @@ static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, 0, p->address_length, flags); } -static __init void pnpacpi_parse_address_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource *r) +static void pnpacpi_parse_address_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource *r) { struct acpi_resource_address64 addr, *p = &addr; acpi_status status; @@ -427,9 +427,9 @@ static __init void pnpacpi_parse_address_option(struct pnp_dev *dev, IORESOURCE_IO_FIXED); } -static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, - unsigned int option_flags, - struct acpi_resource *r) +static void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, + unsigned int option_flags, + struct acpi_resource *r) { struct acpi_resource_extended_address64 *p = &r->data.ext_address64; unsigned char flags = 0; @@ -451,8 +451,7 @@ struct acpipnp_parse_option_s { unsigned int option_flags; }; -static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, - void *data) +static acpi_status pnpacpi_option_resource(struct acpi_resource *res, void *data) { int priority; struct acpipnp_parse_option_s *parse_data = data; @@ -547,7 +546,7 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, return AE_OK; } -int __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev) +int pnpacpi_parse_resource_option_data(struct pnp_dev *dev) { struct acpi_device *acpi_dev = dev->data; acpi_handle handle = acpi_dev->handle; diff --git a/include/linux/pnp.h b/include/linux/pnp.h index ddbe7c3ca4ce..440f8c268a29 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -347,6 +347,7 @@ static inline struct acpi_device *pnp_acpi_device(struct pnp_dev *dev) return dev->data; return NULL; } + #else #define pnp_acpi_device(dev) 0 #endif @@ -514,4 +515,10 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { } module_driver(__pnp_driver, pnp_register_driver, \ pnp_unregister_driver) +#ifdef CONFIG_ARCH_ACPI_DEFERRED_GSI +void pnpacpi_init_2(struct acpi_device *adev); +#else +static inline void pnpacpi_init_2(struct acpi_device *adev) { } +#endif + #endif /* _LINUX_PNP_H */ From patchwork Mon Apr 15 17:01:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630400 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CC36C4345F for ; Mon, 15 Apr 2024 17:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uM0ChmbZN1wH63ytYjoDEapJt2JIWZOYHByrG0nmauQ=; b=wcnqB7PGVQyqdw oHwYELqmxLrO3ZgQWVWRzblG2B8ezcOhsz69Fe/T0sFtWwWAOGnqXs5uNRTa55KnzbOZ5L5UMD/Bh pp54Xs+C0T03kxcAUiac0X2Oi8tO15hPellbthuWgSeKDpQ+pJ3tturvPs4uHTPRFY6fbCOfaAn3V KcqbJcQQqC1ZX4u4ngbzWSb/AU/MFgvaimJxDyhTX6hqUmhaAHahLEKXk/yeBHJ+O5rTwVCbzCPNR 0BQructlBJQ0Bets2l/fEyml9PdVRn1KWx1BYx/tdZzS/K70bWjZkpbMUvAQqoBgpjWj+tu8dr8Jm jEDNzN5TAh9eyhZfrQdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPlG-00000009Dhu-2Itk; Mon, 15 Apr 2024 17:04:54 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjW-00000009CHK-1fc0 for linux-riscv@bombadil.infradead.org; Mon, 15 Apr 2024 17:03:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=tESHp1nipL9G+lPho1WiqoKvdd8aCfbVHrPrMY3qcLM=; b=dyXka9/c7X6mfJV2/7jdY9gR3g lrQ5RbgHc3HB6ZvTyCcb2bhDnfHjlfPofZGpQtBNzMCOXTJDZ7cChFvHCzrDqCWNNnrB6QDNiYDEY DhFCljG6vbLZRpjpGvHxsdxdqelBnNBdeJNamyKnvoVAY5+f3FDLEcSQ8NJvb7EykAAHoCSAlY8tk TzognwIKzzRX/81yZ4WYoJAv1ruXcbCRY2OHdMFspUoi8AKS6VMwyLjYgQYlwEXGAK9qA1WogP+kG Vso64AyNTlIybgwzI/aG0QYkBBtrnMaA8I52oQIKUOoK9x6p/c4mUMnMGlBA3W7U+cwcv6Rtb7841 01kW6KdA==; Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjQ-0000000AfY7-12dt for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:03:05 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6ecf8ebff50so2273439b3a.1 for ; Mon, 15 Apr 2024 10:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200577; x=1713805377; darn=lists.infradead.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=tESHp1nipL9G+lPho1WiqoKvdd8aCfbVHrPrMY3qcLM=; b=gS/GQ1+i6WuWWNYneimHlx9Y8do+AkuKAvtLpoK82JEhDdnBv82pMqypvX0peyKQai HYFJKGYUZWpsMNYUBTod2kA9rVRsb6Uu/QquHCpMvE6fntwOgp2jftXfYdZcqvYKvH/x LfT08Ts24IEV5/9LK6gPPOHb4VaMkA7+VfcslL5cxjtx8zTSHZq9rCpFZq6kBj5UmjMz ocHNgZ4JuRA/Go8HDrGpOlPrdekcvNtDOPLtmAfr28scSUs4PI3QEZ78GNDLwlTdgwks SifaCQaFrQJmF3EsMhvERC4MSz+6VGloBAIckHgfY+v6RPwfPQxbm2dYQ0IsrLuTS5Nk kETQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200577; x=1713805377; 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=tESHp1nipL9G+lPho1WiqoKvdd8aCfbVHrPrMY3qcLM=; b=YFI0W0ONdeI/p4iLVXB9DxZjaLxOffIxcqO37pfy1odLXfl4hPaNRCMU+LBTk2Lu38 rFPZUHn0Cy8r9u7U9aSad7iode0JophuqyK4Jt2UwJgzyn6iRdzek2WUxu09Zhdp+8jP QDN4hcUTpO/qiBqmg69WG6yxeMwQUVlAMZh7Sl/BCwLV/xpHfjWT2UyRbbslrkPsJfWs bUrhqBj7svZNyX7iWIBR0WTMS1ny7JY8hiBSPT3+6P/yzJZTUeuT0oRs8wTwp7ceDsJZ c+YhVmMR8eTv3Tcysj5OdVt85GKR4w11r4qYv9Ck3HZh4zuxzuH7Vi//hguIwSE3O3KW 7XlA== X-Forwarded-Encrypted: i=1; AJvYcCVgPPcO7SfH/sIrlsG5A4PA5pYm7mUL9e6S0aKrUf0KzDhCI069LJVxaPSpm0OJvZ9iEox27CqFWGR2Srt1KpFEL4NpGMgALQGUs6MGzJGv X-Gm-Message-State: AOJu0Yx1qQTPqWn54ATzFCxc2+Q8HAGLeQ26MqykbJkmaJhINaS1/SeX H9XNo0Dx7WU7iFVEEpzDfuGQ4S1jxKM4UfQ6T4wuf7xX8ku3igaVJG9lxgsp/5s= X-Google-Smtp-Source: AGHT+IGv/kllMgrVV78cn82AbUpzbO7/wD1E9hz7AVE67lzYg6zXQKt3/FnejYjVAq0dkP07wI6buA== X-Received: by 2002:a05:6a00:4611:b0:6ea:f3fb:26fe with SMTP id ko17-20020a056a00461100b006eaf3fb26femr305695pfb.12.1713200577636; Mon, 15 Apr 2024 10:02:57 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:02:57 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 14/20] irqchip: riscv-intc: Add ACPI support for AIA Date: Mon, 15 Apr 2024 22:31:07 +0530 Message-Id: <20240415170113.662318-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_180300_445911_32E7C41E X-CRM114-Status: GOOD ( 17.76 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The RINTC subtype structure in MADT also has information about other interrupt controllers. Save this information and provide interfaces to retrieve them when required by corresponding drivers. Signed-off-by: Sunil V L --- arch/riscv/include/asm/irq.h | 35 ++++++++++++ drivers/irqchip/irq-riscv-intc.c | 97 +++++++++++++++++++++++++++++++- 2 files changed, 130 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 44a0b128c602..6bd578b1ffc9 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -25,9 +25,22 @@ enum riscv_irqchip_type { ACPI_RISCV_IRQCHIP_APLIC = 0x03, }; +/* + * The ext_intc_id format is as follows: + * Bits [31:24] APLIC/PLIC ID + * Bits [15:0] APLIC IDC ID / PLIC S-Mode Context ID for this hart + */ +#define APLIC_PLIC_ID(x) ((x) >> 24) +#define IDC_CONTEXT_ID(x) ((x) & 0x0000ffff) + int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, u32 *id, u32 *nr_irqs, u32 *nr_idcs); struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 gsi); +int __init acpi_get_intc_index_hartid(u32 index, unsigned long *hartid); +int acpi_get_ext_intc_parent_hartid(u8 id, u32 idx, unsigned long *hartid); +void acpi_get_plic_nr_contexts(u8 id, int *nr_contexts); +int acpi_get_plic_context(u8 id, u32 idx, int *context_id); +int __init acpi_get_imsic_mmio_info(u32 index, struct resource *res); #else static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, @@ -36,6 +49,28 @@ static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi return 0; } +static inline int __init acpi_get_intc_index_hartid(u32 index, unsigned long *hartid) +{ + return -EINVAL; +} + +static inline int acpi_get_ext_intc_parent_hartid(u8 id, u32 idx, unsigned long *hartid) +{ + return -EINVAL; +} + +static inline void acpi_get_plic_nr_contexts(u8 id, int *nr_contexts) { } + +static inline int acpi_get_plic_context(u8 id, u32 idx, int *context_id) +{ + return -EINVAL; +} + +static inline int __init acpi_get_imsic_mmio_info(u32 index, struct resource *res) +{ + return 0; +} + #endif /* CONFIG_ACPI */ #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 9e71c4428814..b20272151aed 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -249,14 +249,101 @@ IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init); IRQCHIP_DECLARE(andes, "andestech,cpu-intc", riscv_intc_init); #ifdef CONFIG_ACPI +struct rintc_data { + u32 ext_intc_id; + unsigned long hart_id; + u64 imsic_addr; + u32 imsic_size; +}; + +static u32 nr_rintc; +static struct rintc_data *rintc_acpi_data[NR_CPUS]; + +int acpi_get_intc_index_hartid(u32 index, unsigned long *hartid) +{ + if (index >= nr_rintc) + return -1; + + *hartid = rintc_acpi_data[index]->hart_id; + return 0; +} + +int acpi_get_ext_intc_parent_hartid(u8 id, u32 idx, unsigned long *hartid) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) { + if (idx == j) { + *hartid = rintc_acpi_data[i]->hart_id; + return 0; + } + j++; + } + } + + return -1; +} + +void acpi_get_plic_nr_contexts(u8 id, int *nr_contexts) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) + j++; + } + + *nr_contexts = j; +} + +int acpi_get_plic_context(u8 id, u32 idx, int *context_id) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) { + if (idx == j) { + *context_id = IDC_CONTEXT_ID(rintc_acpi_data[i]->ext_intc_id); + return 0; + } + + j++; + } + } + + return -1; +} + +int acpi_get_imsic_mmio_info(u32 index, struct resource *res) +{ + if (index >= nr_rintc) + return -1; + + res->start = rintc_acpi_data[index]->imsic_addr; + res->end = res->start + rintc_acpi_data[index]->imsic_size - 1; + res->flags = IORESOURCE_MEM; + return 0; +} + static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, const unsigned long end) { - struct fwnode_handle *fn; struct acpi_madt_rintc *rintc; + struct fwnode_handle *fn; + int rc; rintc = (struct acpi_madt_rintc *)header; + rintc_acpi_data[nr_rintc] = kzalloc(sizeof(*rintc_acpi_data[0]), GFP_KERNEL); + if (!rintc_acpi_data[nr_rintc]) + return -ENOMEM; + + rintc_acpi_data[nr_rintc]->ext_intc_id = rintc->ext_intc_id; + rintc_acpi_data[nr_rintc]->hart_id = rintc->hart_id; + rintc_acpi_data[nr_rintc]->imsic_addr = rintc->imsic_addr; + rintc_acpi_data[nr_rintc]->imsic_size = rintc->imsic_size; + nr_rintc++; /* * The ACPI MADT will have one INTC for each CPU (or HART) @@ -273,7 +360,13 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, return -ENOMEM; } - return riscv_intc_init_common(fn, &riscv_intc_chip); + rc = riscv_intc_init_common(fn, &riscv_intc_chip); + if (rc) { + irq_domain_free_fwnode(fn); + return rc; + } + + return 0; } IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL, From patchwork Mon Apr 15 17:01:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630401 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 588DBC4345F for ; Mon, 15 Apr 2024 17:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DtbW6viHc5MQttZM1fvUbhUbppbE1yi0sUu0RV5F7Sg=; b=omXiYsItplLmOx 3u8QSqTNRBARZErj02yFUQ6Od49LALohO8xwyp7zcpRRMgPO2PFWAugsCHP1sC6lCM75wxoDehQjv Q1FeX0XjGMvEOZhrFYAktjstvc10bBdQYcN4P+B4uXHkxN2ceRIdjB26yPiwbV9YPzJJEvmUB1i66 Alist+NFWTMvrjQEOebdx3BAmYcXAzjC8bM3klFZ0gkl7KS6AdQL0VF85tUcXwbTjWaL3LKYbl2tq ZztSxb+KsbM7yAx/2bEGEWUgd3dSgrN9wrTyIsDZrBiCQLem+Wd09H1FD2U+UeYlm+O82WdbYOIT+ EPexNmPTD1EekTetdChw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPlN-00000009Doe-3b8H; Mon, 15 Apr 2024 17:05:01 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjV-00000009CH4-2SOr for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:03:16 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6ecf8ebff50so2273555b3a.1 for ; Mon, 15 Apr 2024 10:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200585; x=1713805385; darn=lists.infradead.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=8smg3owWHWW9PU5G6t7mt+Tcv3LUpwWLhoyg8/upQCQ=; b=mDYsDYvF/8DODQObKXvXLBtsYIVm0gzGNWmGbCTeq5evlBNAveKlt1cx9MwTXSr8Su 3KvoCUd7SNvvN+iA8k4eutVh05aZkAXpv7QUq9RAECfPWYgNDF6eaQF53VXM1snBOz88 7PfwEcKeTlFVP1nlL/qg7ClPf96oj0K0fc+05zTo3Il/pR8Bq7pLi6ElmzwAASrgOvGD 6yaceco+73/uWLqrDIv1x9ZXx8VXRem7QkIFBYhUhgozBQQYPolXYfhYjFcgaotIAS/L 1U8gjoXL2DMNTcazBt6o5CSsVtSakrtodZFmO6q9PtBL2EvUKpnOp8CnZJ1CLZGpC7kw vytA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200585; x=1713805385; 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=8smg3owWHWW9PU5G6t7mt+Tcv3LUpwWLhoyg8/upQCQ=; b=cebLSCnKgegglPaAfiT07xdUeOY3EN58RBFdZ7AvVOx1wer/0dQcc7akT81Ga8P8t1 +nrZRgdMv/YHSeovhNU2PFvuuUsbg/HAQ+cp+lkrRomcO58v/wisjWG6SQsiCZnUuke4 FOVpHVi+IsrrGdRE4LlCkhrSgWfJOJLzR6VW2KLSmyiIlT8/vnyz9AySbtEf4p0ITru0 fjK4R5195psAjWMKWsGXrBorceg6TQDcoQhcC1+09JPrGlsq+kYIHpbl0MhSECkETzuH Nz97RlXCX9qAMztAbt4t7ye9wgK2Kspetu+7Olj8oV9RaMi1+07a8kqhEAZ0et4/VwF5 ND+w== X-Forwarded-Encrypted: i=1; AJvYcCXmQ87ZOjCz4LE+d0zCBgKsaf3JoBQ9QfYdWY4AEE8Mqg9uTT+Ftpg2KKcYQKg6Gf+o4VXs2Q/FoDdfILlltACoBPR2p1QP8xZpTbfbrHBk X-Gm-Message-State: AOJu0YygOnWSsxRCswhRaOl3rLRn3IkFFvEhOxjftKvXKoPbN2I8cKFu 7zXLKCwQTThSrDlRkWgxJ39t85xt3Aan4GvahUEZxW8FOjGJ88Km48we9ni1Owc= X-Google-Smtp-Source: AGHT+IGV77t74zXqumvBBSYJpdOPZfRZjrz4nC5DPyoQfvVW026my7l2yC+lQVQ7WYkkThW6carIhA== X-Received: by 2002:a05:6a00:3a19:b0:6e7:48e3:7895 with SMTP id fj25-20020a056a003a1900b006e748e37895mr308776pfb.2.1713200584491; Mon, 15 Apr 2024 10:03:04 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:03:03 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 15/20] irqchip: riscv-imsic: Add ACPI support Date: Mon, 15 Apr 2024 22:31:08 +0530 Message-Id: <20240415170113.662318-16-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100306_035591_FCC482AA X-CRM114-Status: GOOD ( 25.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org RISC-V IMSIC interrupt controller provides IPI and MSI support. Currently, DT based drivers setup the IPI feature early during boot but defer setting up the MSI functionality. However, in ACPI systems, PCI scan happens early during boot and PCI subsystem expects MSI controller is already setup. Hence, in case of ACPI, both IPI and MSI features are initialized early itself. Signed-off-by: Sunil V L --- drivers/irqchip/irq-riscv-imsic-early.c | 52 +++++++++- drivers/irqchip/irq-riscv-imsic-platform.c | 32 ++++-- drivers/irqchip/irq-riscv-imsic-state.c | 115 ++++++++++----------- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- include/linux/irqchip/riscv-imsic.h | 10 ++ 5 files changed, 144 insertions(+), 67 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index 886418ec06cb..d8161243791d 100644 --- a/drivers/irqchip/irq-riscv-imsic-early.c +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -5,13 +5,16 @@ */ #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include #include #include #include +#include #include +#include #include #include @@ -182,7 +185,7 @@ static int __init imsic_early_dt_init(struct device_node *node, struct device_no int rc; /* Setup IMSIC state */ - rc = imsic_setup_state(fwnode); + rc = imsic_setup_state(fwnode, NULL); if (rc) { pr_err("%pfwP: failed to setup state (error %d)\n", fwnode, rc); return rc; @@ -199,3 +202,50 @@ static int __init imsic_early_dt_init(struct device_node *node, struct device_no } IRQCHIP_DECLARE(riscv_imsic, "riscv,imsics", imsic_early_dt_init); + +#ifdef CONFIG_ACPI + +static struct fwnode_handle *imsic_acpi_fwnode; + +struct fwnode_handle *imsic_acpi_get_fwnode(struct device *dev) +{ + return imsic_acpi_fwnode; +} + +static int __init imsic_early_acpi_init(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_madt_imsic *imsic = (struct acpi_madt_imsic *)header; + int rc; + + imsic_acpi_fwnode = irq_domain_alloc_named_fwnode("imsic"); + if (!imsic_acpi_fwnode) { + pr_err("unable to allocate IMSIC FW node\n"); + return -ENOMEM; + } + + /* Setup IMSIC state */ + rc = imsic_setup_state(imsic_acpi_fwnode, (void *)imsic); + if (rc) { + pr_err("%pfwP: failed to setup state (error %d)\n", imsic_acpi_fwnode, rc); + return rc; + } + + /* Do early setup of IMSIC state and IPIs */ + rc = imsic_early_probe(imsic_acpi_fwnode); + if (rc) + return rc; + + rc = imsic_platform_acpi_probe(imsic_acpi_fwnode); + +#ifdef CONFIG_PCI + if (!rc) + pci_msi_register_fwnode_provider(&imsic_acpi_get_fwnode); +#endif + + return rc; +} + +IRQCHIP_ACPI_DECLARE(riscv_imsic, ACPI_MADT_TYPE_IMSIC, NULL, + 1, imsic_early_acpi_init); +#endif diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 11723a763c10..64905e6f52d7 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -5,6 +5,7 @@ */ #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include @@ -348,18 +349,37 @@ int imsic_irqdomain_init(void) return 0; } -static int imsic_platform_probe(struct platform_device *pdev) +static int imsic_platform_probe_common(struct fwnode_handle *fwnode) { - struct device *dev = &pdev->dev; - - if (imsic && imsic->fwnode != dev->fwnode) { - dev_err(dev, "fwnode mismatch\n"); + if (imsic && imsic->fwnode != fwnode) { + pr_err("%pfwP: fwnode mismatch\n", fwnode); return -ENODEV; } return imsic_irqdomain_init(); } +static int imsic_platform_dt_probe(struct platform_device *pdev) +{ + return imsic_platform_probe_common(pdev->dev.fwnode); +} + +#ifdef CONFIG_ACPI + +/* + * On ACPI based systems, PCI enumeration happens early during boot in + * acpi_scan_init(). PCI enumeration expects MSI domain setup before + * it calls pci_set_msi_domain(). Hence, unlike in DT where + * imsic-platform drive probe happens late during boot, ACPI based + * systems need to setup the MSI domain early. + */ +int imsic_platform_acpi_probe(struct fwnode_handle *fwnode) +{ + return imsic_platform_probe_common(fwnode); +} + +#endif + static const struct of_device_id imsic_platform_match[] = { { .compatible = "riscv,imsics" }, {} @@ -370,6 +390,6 @@ static struct platform_driver imsic_platform_driver = { .name = "riscv-imsic", .of_match_table = imsic_platform_match, }, - .probe = imsic_platform_probe, + .probe = imsic_platform_dt_probe, }; builtin_platform_driver(imsic_platform_driver); diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 5479f872e62b..608b87dd0784 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -5,6 +5,7 @@ */ #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include @@ -516,12 +517,8 @@ static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, struct of_phandle_args parent; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ if (!is_of_node(fwnode)) - return -EINVAL; + return acpi_get_intc_index_hartid(index, hartid); rc = of_irq_parse_one(to_of_node(fwnode), index, &parent); if (rc) @@ -540,12 +537,8 @@ static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, static int __init imsic_get_mmio_resource(struct fwnode_handle *fwnode, u32 index, struct resource *res) { - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ if (!is_of_node(fwnode)) - return -EINVAL; + return acpi_get_imsic_mmio_info(index, res); return of_address_to_resource(to_of_node(fwnode), index, res); } @@ -553,20 +546,15 @@ static int __init imsic_get_mmio_resource(struct fwnode_handle *fwnode, static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, struct imsic_global_config *global, u32 *nr_parent_irqs, - u32 *nr_mmios) + u32 *nr_mmios, + void *opaque) { + struct acpi_madt_imsic *imsic = (struct acpi_madt_imsic *)opaque; unsigned long hartid; struct resource res; int rc; u32 i; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(fwnode)) - return -EINVAL; - *nr_parent_irqs = 0; *nr_mmios = 0; @@ -578,51 +566,60 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, return -EINVAL; } - /* Find number of guest index bits in MSI address */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", - &global->guest_index_bits); - if (rc) - global->guest_index_bits = 0; + if (is_of_node(fwnode)) { + /* Find number of guest index bits in MSI address */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", + &global->guest_index_bits); + if (rc) + global->guest_index_bits = 0; - /* Find number of HART index bits */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,hart-index-bits", - &global->hart_index_bits); - if (rc) { - /* Assume default value */ - global->hart_index_bits = __fls(*nr_parent_irqs); - if (BIT(global->hart_index_bits) < *nr_parent_irqs) - global->hart_index_bits++; - } + /* Find number of HART index bits */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,hart-index-bits", + &global->hart_index_bits); + if (rc) { + /* Assume default value */ + global->hart_index_bits = __fls(*nr_parent_irqs); + if (BIT(global->hart_index_bits) < *nr_parent_irqs) + global->hart_index_bits++; + } - /* Find number of group index bits */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", - &global->group_index_bits); - if (rc) - global->group_index_bits = 0; + /* Find number of group index bits */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", + &global->group_index_bits); + if (rc) + global->group_index_bits = 0; - /* - * Find first bit position of group index. - * If not specified assumed the default APLIC-IMSIC configuration. - */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", - &global->group_index_shift); - if (rc) - global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; + /* + * Find first bit position of group index. + * If not specified assumed the default APLIC-IMSIC configuration. + */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", + &global->group_index_shift); + if (rc) + global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; + + /* Find number of interrupt identities */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-ids", + &global->nr_ids); + if (rc) { + pr_err("%pfwP: number of interrupt identities not found\n", fwnode); + return rc; + } - /* Find number of interrupt identities */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-ids", - &global->nr_ids); - if (rc) { - pr_err("%pfwP: number of interrupt identities not found\n", fwnode); - return rc; + /* Find number of guest interrupt identities */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", + &global->nr_guest_ids); + if (rc) + global->nr_guest_ids = global->nr_ids; + } else { + global->guest_index_bits = imsic->guest_index_bits; + global->hart_index_bits = imsic->hart_index_bits; + global->group_index_bits = imsic->group_index_bits; + global->group_index_shift = imsic->group_index_shift; + global->nr_ids = imsic->num_ids; + global->nr_guest_ids = imsic->num_guest_ids; } - /* Find number of guest interrupt identities */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", - &global->nr_guest_ids); - if (rc) - global->nr_guest_ids = global->nr_ids; - /* Sanity check guest index bits */ i = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT; if (i < global->guest_index_bits) { @@ -688,7 +685,7 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, return 0; } -int __init imsic_setup_state(struct fwnode_handle *fwnode) +int __init imsic_setup_state(struct fwnode_handle *fwnode, void *opaque) { u32 i, j, index, nr_parent_irqs, nr_mmios, nr_handlers = 0; struct imsic_global_config *global; @@ -729,7 +726,7 @@ int __init imsic_setup_state(struct fwnode_handle *fwnode) } /* Parse IMSIC fwnode */ - rc = imsic_parse_fwnode(fwnode, global, &nr_parent_irqs, &nr_mmios); + rc = imsic_parse_fwnode(fwnode, global, &nr_parent_irqs, &nr_mmios, opaque); if (rc) goto out_free_local; diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index 5ae2f69b035b..391e44280827 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -102,7 +102,7 @@ void imsic_vector_debug_show_summary(struct seq_file *m, int ind); void imsic_state_online(void); void imsic_state_offline(void); -int imsic_setup_state(struct fwnode_handle *fwnode); +int imsic_setup_state(struct fwnode_handle *fwnode, void *opaque); int imsic_irqdomain_init(void); #endif diff --git a/include/linux/irqchip/riscv-imsic.h b/include/linux/irqchip/riscv-imsic.h index faf0b800b1b0..e08680b1932b 100644 --- a/include/linux/irqchip/riscv-imsic.h +++ b/include/linux/irqchip/riscv-imsic.h @@ -84,4 +84,14 @@ static inline const struct imsic_global_config *imsic_get_global_config(void) #endif +#ifdef CONFIG_ACPI +int imsic_platform_acpi_probe(struct fwnode_handle *fwnode); +struct fwnode_handle *imsic_acpi_get_fwnode(struct device *dev); +#else +static inline struct fwnode_handle *imsic_acpi_get_fwnode(struct device *dev) +{ + return NULL; +} +#endif + #endif From patchwork Mon Apr 15 17:01:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630402 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 767CBC4345F for ; Mon, 15 Apr 2024 17:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AFtpmDjKz+OqX8sr6ZMirDVfT80eFspRgI/ddXZ+BfY=; b=qDZ6V/y4EcZ1LJ qHuaNOISkCRJcNTbVHpseRgBkxf8qi8FsnovNm00wj/cZRmeoMx3W/kj2+Ed9LzjoV1UzBuWTW9R2 0t0RK4VnR6p07hsTySIuLKG7TSOPmqbP77YuJflM2Gf8uEDLPNATY2XdbuZWFLh8ZaNRi7CAkMLRE L1COjY6m8XAPVRo1k6zDfXnureQKP+tAnKXnqJER6ta6+ZLgGDotjq+9zcjgUYR5C/25+VBgZLvJy c7ZzNleACf/ug688Hl8aDa1kog6Gp8+ot1b5IVyyTq4Fjsx+xT76OCOhuyp1rz2S+zETnWngg5bai Mzz9pJqB5t/GnIFIbsZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPlm-00000009E7U-3p2d; Mon, 15 Apr 2024 17:05:26 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjd-00000009CN7-2fxC for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:03:27 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6ed627829e6so3794111b3a.1 for ; Mon, 15 Apr 2024 10:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200591; x=1713805391; darn=lists.infradead.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=H3zPkz1xxC1CxVIHCuATW1be05yVqY6yZ3K4WTU3dxk=; b=F0jYOB6md/xRCJUojSDEbhegF+1wWCnUrsil54PL8t8TMfUvxo8Y0cn7zM94+nNVHe 3U7Ui3jrkjgHsopZ3VksQ3b24sdWvftwk3PkNgsvMRmL+mPwPpWyrEoUnB1LRqJmqaLx OeIFT0UoKozNksk2rix7cndHcW7TQOZTa+/7v1d7BMrxQ79Mwg9zd9n9nhZawxcaJrMx drq3DjdXRlxDCqVYlLsM0nz0Ph5cnZeoe3i/d+PxWXl885TyhepEz8vdN9s2qs4WcCSI /cbJFTrcFxQq7bSFi82Z8JE7/rHv+5hsyCdrCS3QeLryhdUPwaDEeiOLXNByGrbsg+2/ coBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200591; x=1713805391; 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=H3zPkz1xxC1CxVIHCuATW1be05yVqY6yZ3K4WTU3dxk=; b=nbR2qNmGZKfwmHQWdjj9N9txvOUre0pOcMCpP6gqWVLF8gdhKsnt+9gG74XQTJPzmN ZETxmauKJk18EMixGUbMP9eN4Z8zpP/l8uSxD78jansjq/WRSFBhqSeobljNp68fp5JH POq/H1LGYWM3G2nnQ3Ts1g8hnLHTH/GZKAlpGWnm6AGsE/jk9TryGfRU/uD1q4cjdmGr +eScxhv5u8wgi6tkBjoKm3qK2k2vEQP4J82HnTFdlf2xgXIqnRxggt1e/L06XJ6lgJdO z4nAUmMyG95c0h8YsZJ+YzTL+N4tszO45ukEy7GOU3sl3sUFYVqwu5INseXxNSb9qCMI DG1Q== X-Forwarded-Encrypted: i=1; AJvYcCVs1zX+o4X0AsjgOiFOTHaN6u1hPjX63x2vpPz3TUikJOBgQUmw9ZmYBliYTxhCoSgQ/ZY6R8c3UoHnme2LsfUYOtINOMMd44iBhxY0cQL+ X-Gm-Message-State: AOJu0Yzd09zil1GqpdgN/x++Y0wZOgmRdtxedG63rMBP9WnoJCnBKonj z9UYRnqtjq+rHg3ohhdO2zsBWG+IKrqCUKMq90PqVE5P8RwX/HQCIwiyd6gQnVw= X-Google-Smtp-Source: AGHT+IH0ficLpEhaCe8Pnb6wxywvR8vuQmlkndUIbxirsZ7VdL0/Vy3OLDYye3r5jTi06t4U01f4Dw== X-Received: by 2002:a05:6a20:8420:b0:1a7:ab39:4356 with SMTP id c32-20020a056a20842000b001a7ab394356mr14647289pzd.10.1713200591065; Mon, 15 Apr 2024 10:03:11 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:03:10 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 16/20] irqchip: riscv-aplic: Add ACPI support Date: Mon, 15 Apr 2024 22:31:09 +0530 Message-Id: <20240415170113.662318-17-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100314_390264_81ED4688 X-CRM114-Status: GOOD ( 26.95 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add ACPI support in APLIC drivers. It used the namespace device to probe and MADT to get other details required. Use the mapping created early during boot to get the details about the APLIC. Signed-off-by: Sunil V L --- drivers/irqchip/irq-riscv-aplic-direct.c | 20 ++++--- drivers/irqchip/irq-riscv-aplic-main.c | 70 ++++++++++++++++-------- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 ++- 4 files changed, 67 insertions(+), 33 deletions(-) diff --git a/drivers/irqchip/irq-riscv-aplic-direct.c b/drivers/irqchip/irq-riscv-aplic-direct.c index 06bace9b7497..ccf08e617e5a 100644 --- a/drivers/irqchip/irq-riscv-aplic-direct.c +++ b/drivers/irqchip/irq-riscv-aplic-direct.c @@ -4,6 +4,7 @@ * Copyright (C) 2022 Ventana Micro Systems Inc. */ +#include #include #include #include @@ -192,17 +193,20 @@ static int aplic_direct_starting_cpu(unsigned int cpu) } static int aplic_direct_parse_parent_hwirq(struct device *dev, u32 index, - u32 *parent_hwirq, unsigned long *parent_hartid) + u32 *parent_hwirq, unsigned long *parent_hartid, + struct aplic_priv *priv) { struct of_phandle_args parent; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; + if (!is_of_node(dev->fwnode)) { + rc = acpi_get_ext_intc_parent_hartid(priv->id, index, parent_hartid); + if (rc) + return rc; + + *parent_hwirq = RV_IRQ_EXT; + return 0; + } rc = of_irq_parse_one(to_of_node(dev->fwnode), index, &parent); if (rc) @@ -240,7 +244,7 @@ int aplic_direct_setup(struct device *dev, void __iomem *regs) /* Setup per-CPU IDC and target CPU mask */ current_cpu = get_cpu(); for (i = 0; i < priv->nr_idcs; i++) { - rc = aplic_direct_parse_parent_hwirq(dev, i, &hwirq, &hartid); + rc = aplic_direct_parse_parent_hwirq(dev, i, &hwirq, &hartid, priv); if (rc) { dev_warn(dev, "parent irq for IDC%d not found\n", i); continue; diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c index 774a0c97fdab..c1fd328ddf7d 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.c +++ b/drivers/irqchip/irq-riscv-aplic-main.c @@ -4,8 +4,10 @@ * Copyright (C) 2022 Ventana Micro Systems Inc. */ +#include #include #include +#include #include #include #include @@ -125,39 +127,50 @@ static void aplic_init_hw_irqs(struct aplic_priv *priv) writel(0, priv->regs + APLIC_DOMAINCFG); } +#ifdef CONFIG_ACPI +static const struct acpi_device_id aplic_acpi_match[] = { + { "RSCV0002", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, aplic_acpi_match); + +#endif + int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *regs) { struct of_phandle_args parent; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; - /* Save device pointer and register base */ priv->dev = dev; priv->regs = regs; - /* Find out number of interrupt sources */ - rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,num-sources", - &priv->nr_irqs); - if (rc) { - dev_err(dev, "failed to get number of interrupt sources\n"); - return rc; - } - - /* - * Find out number of IDCs based on parent interrupts - * - * If "msi-parent" property is present then we ignore the - * APLIC IDCs which forces the APLIC driver to use MSI mode. - */ - if (!of_property_present(to_of_node(dev->fwnode), "msi-parent")) { - while (!of_irq_parse_one(to_of_node(dev->fwnode), priv->nr_idcs, &parent)) - priv->nr_idcs++; + if (is_of_node(dev->fwnode)) { + /* Find out number of interrupt sources */ + rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,num-sources", + &priv->nr_irqs); + if (rc) { + dev_err(dev, "failed to get number of interrupt sources\n"); + return rc; + } + + /* + * Find out number of IDCs based on parent interrupts + * + * If "msi-parent" property is present then we ignore the + * APLIC IDCs which forces the APLIC driver to use MSI mode. + */ + if (!of_property_present(to_of_node(dev->fwnode), "msi-parent")) { + while (!of_irq_parse_one(to_of_node(dev->fwnode), priv->nr_idcs, &parent)) + priv->nr_idcs++; + } + } else { + rc = riscv_acpi_get_gsi_info(dev->fwnode, &priv->gsi_base, &priv->id, + &priv->nr_irqs, &priv->nr_idcs); + if (rc) { + dev_err(dev, "failed to find GSI mapping\n"); + return rc; + } } /* Setup initial state APLIC interrupts */ @@ -186,6 +199,9 @@ static int aplic_probe(struct platform_device *pdev) */ if (is_of_node(dev->fwnode)) msi_mode = of_property_present(to_of_node(dev->fwnode), "msi-parent"); + else + msi_mode = imsic_acpi_get_fwnode(NULL) ? 1 : 0; + if (msi_mode) rc = aplic_msi_setup(dev, regs); else @@ -193,6 +209,11 @@ static int aplic_probe(struct platform_device *pdev) if (rc) dev_err(dev, "failed to setup APLIC in %s mode\n", msi_mode ? "MSI" : "direct"); +#ifdef CONFIG_ACPI + if (!acpi_disabled) + acpi_dev_clear_dependencies(ACPI_COMPANION(dev)); +#endif + return rc; } @@ -205,6 +226,7 @@ static struct platform_driver aplic_driver = { .driver = { .name = "riscv-aplic", .of_match_table = aplic_match, + .acpi_match_table = ACPI_PTR(aplic_acpi_match), }, .probe = aplic_probe, }; diff --git a/drivers/irqchip/irq-riscv-aplic-main.h b/drivers/irqchip/irq-riscv-aplic-main.h index 4393927d8c80..9fbf45c7b4f7 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.h +++ b/drivers/irqchip/irq-riscv-aplic-main.h @@ -28,6 +28,7 @@ struct aplic_priv { u32 gsi_base; u32 nr_irqs; u32 nr_idcs; + u32 id; void __iomem *regs; struct aplic_msicfg msicfg; }; diff --git a/drivers/irqchip/irq-riscv-aplic-msi.c b/drivers/irqchip/irq-riscv-aplic-msi.c index 028444af48bd..f5020241e0ed 100644 --- a/drivers/irqchip/irq-riscv-aplic-msi.c +++ b/drivers/irqchip/irq-riscv-aplic-msi.c @@ -157,6 +157,7 @@ static const struct msi_domain_template aplic_msi_template = { int aplic_msi_setup(struct device *dev, void __iomem *regs) { const struct imsic_global_config *imsic_global; + struct irq_domain *msi_domain; struct aplic_priv *priv; struct aplic_msicfg *mc; phys_addr_t pa; @@ -239,8 +240,14 @@ int aplic_msi_setup(struct device *dev, void __iomem *regs) * IMSIC and the IMSIC MSI domains are created later through * the platform driver probing so we set it explicitly here. */ - if (is_of_node(dev->fwnode)) + if (is_of_node(dev->fwnode)) { of_msi_configure(dev, to_of_node(dev->fwnode)); + } else { + msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); + } } if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, &aplic_msi_template, From patchwork Mon Apr 15 17:01:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630450 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22C83C4345F for ; Mon, 15 Apr 2024 18:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wSvLXpJXpOl1suwKeZXrImJ7UQr9U8kBfOWoHGjsnBk=; b=D+aOVd1MoftOnX OlQrfHtpgPr2sEkFRYxFdmI7xONf7ISWtIxv7ZUgx8codhK4Hvbu5gIpGhYIRf8W5DWMp0KxgtGdV oXqOZrJ1dVpa+AqdIfYxCHVdUWDRg7FY9M2yVjlBwMFu9NgBtsHjBz30wwpCKufrZXyv0YD6WsmgJ NoBHa8eev/r71BnG4/HC2b3xhNFYMxQb87fmDdjuO2rW+bfWotKKAlynNvWE9B8uYonpwaLfjTvph pkRctadJLiI0W9ZeVbXdKuY0mph1yQeUMKVAgv9NPQif+jgl/yrBvZWt/LDnaMD11QtGE1qy21vTo jYQK440tFMl93d0sHjTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwQrb-00000009Pv2-3tzG; Mon, 15 Apr 2024 18:15:31 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPji-00000009CSH-2Mz1 for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:03:29 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6eddff25e4eso2893452b3a.3 for ; Mon, 15 Apr 2024 10:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200598; x=1713805398; darn=lists.infradead.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=ThUaZ42acH6gIoHt/Xyyai1xsGISjU0BkoEw/XHj/Ns=; b=I+JrwKsCzo1Iz1NVn2wM+XjufCHHF0omANRVcIYi40M/8KijCiBXi9Zi7EfmeJEhcC ZAXSAju1HnrITPe4wZFuugPxCfCeJueze+/Q5s7eVCgsMcmoFsgedLU65XNSGzcewiDw Bc8gpBAihzwC5jK1eNwDjmJLFcuMu9H4GRKEQn47S5uubg3cfWcKgVnE3bm18H0+oiJD KTg9oL/kuCHeuOvd/4XQNqhW/AHsl66fP5FrKyStJ6L65mDey5A8daAOoWVtO7OXJeGB kE+QSZv3O2LHZapV+O2tTrM3T6PEtTquO/COT/9Mj0f+SvSUuDgEBFKSPp8oCkqhUnXM GgXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200598; x=1713805398; 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=ThUaZ42acH6gIoHt/Xyyai1xsGISjU0BkoEw/XHj/Ns=; b=YxHu8aUdb5v1s45SgBepn8i/3gMToFzoWiqZ2raFS1GuDaijG/K4A989jQ5v+WJ+6K kw9guJznHU6dhXfcNPJbgTks7jSJK+/v+4jChdGXJ8y0dbyxDQdMV3pgdWlmAvSjgVLZ y5J87kDsws+ons1cI1kgfv7xfkwWb3X34/47tclV4nM1uDsQ5FJbnUi29pVfVrUOf3a4 JcHy1pThdVqa7sfGd5fAemaScl90E7PGq8pvo28XDlXq+sK7M/LNWawS4knTIOo3MkpB jp/u0BnQy+up2EMDqOH4WdOULGJ9AVQHSYOKJX5N9GM4UtMAHzoGqSC7WZcEciD5B08Y klJA== X-Forwarded-Encrypted: i=1; AJvYcCWjYfXD2UAFB2MwH2k6YZKPUqrTxAMGvlAcO8u9eKGZJwHUqlfAL2um6ZBx8wkJTOlNVZnEbv83Gsks24NiwAgDt/kfMYBHOfV39CLVqvQ4 X-Gm-Message-State: AOJu0Yx+OZxEQnvSYVFNR8YIYy4BjgkJCiqFF9Opgl/NnWsbosPmI8ZI VQc38VtB2qKPx6eWs4bNt22WFDdNto0K18B+t3/UmGsQJmB0L8rRCDTyyv6MjEg= X-Google-Smtp-Source: AGHT+IHhuE17NgEEPGD23nh5CnQ5veXRbEyfj/0HGrVBsvBO1xoLfPY+OSt88142jHvtos+eqeLYfg== X-Received: by 2002:a05:6a00:391c:b0:6ec:f5d2:f6be with SMTP id fh28-20020a056a00391c00b006ecf5d2f6bemr10232711pfb.1.1713200597605; Mon, 15 Apr 2024 10:03:17 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:03:17 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 17/20] irqchip: irq-sifive-plic: Add ACPI support Date: Mon, 15 Apr 2024 22:31:10 +0530 Message-Id: <20240415170113.662318-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100319_074249_10880E82 X-CRM114-Status: GOOD ( 22.08 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add ACPI support in PLIC driver. Use the mapping created early during boot to get details about the PLIC. Signed-off-by: Sunil V L Co-developed-by: Haibo Xu Signed-off-by: Haibo Xu --- drivers/irqchip/irq-sifive-plic.c | 89 +++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 21 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index f3d4cb9e34f7..5fa45701ea24 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 SiFive * Copyright (C) 2018 Christoph Hellwig */ +#include #include #include #include @@ -70,6 +71,8 @@ struct plic_priv { unsigned long plic_quirks; unsigned int nr_irqs; unsigned long *prio_save; + u32 gsi_base; + int id; }; struct plic_handler { @@ -327,6 +330,10 @@ static int plic_irq_domain_translate(struct irq_domain *d, { struct plic_priv *priv = d->host_data; + /* For DT, gsi_base is always zero. */ + if (fwspec->param[0] >= priv->gsi_base) + fwspec->param[0] = fwspec->param[0] - priv->gsi_base; + if (test_bit(PLIC_QUIRK_EDGE_INTERRUPT, &priv->plic_quirks)) return irq_domain_translate_twocell(d, fwspec, hwirq, type); @@ -427,18 +434,32 @@ static const struct of_device_id plic_match[] = { {} }; +#ifdef CONFIG_ACPI + +static const struct acpi_device_id plic_acpi_match[] = { + { "RSCV0001", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, plic_acpi_match); + +#endif static int plic_parse_nr_irqs_and_contexts(struct platform_device *pdev, - u32 *nr_irqs, u32 *nr_contexts) + u32 *nr_irqs, u32 *nr_contexts, + u32 *gsi_base, u32 *id) { struct device *dev = &pdev->dev; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; + if (!is_of_node(dev->fwnode)) { + riscv_acpi_get_gsi_info(dev->fwnode, gsi_base, id, nr_irqs, NULL); + acpi_get_plic_nr_contexts(*id, nr_contexts); + if (WARN_ON(!*nr_contexts)) { + dev_err(dev, "no PLIC context available\n"); + return -EINVAL; + } + + return 0; + } rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,ndev", nr_irqs); if (rc) { @@ -452,23 +473,29 @@ static int plic_parse_nr_irqs_and_contexts(struct platform_device *pdev, return -EINVAL; } + *gsi_base = 0; + *id = 0; + return 0; } static int plic_parse_context_parent(struct platform_device *pdev, u32 context, - u32 *parent_hwirq, int *parent_cpu) + u32 *parent_hwirq, int *parent_cpu, u32 id) { struct device *dev = &pdev->dev; struct of_phandle_args parent; unsigned long hartid; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; + if (!is_of_node(dev->fwnode)) { + rc = acpi_get_ext_intc_parent_hartid(id, context, &hartid); + if (rc) + return rc; + + *parent_cpu = riscv_hartid_to_cpuid(hartid); + *parent_hwirq = RV_IRQ_EXT; + return 0; + } rc = of_irq_parse_one(to_of_node(dev->fwnode), context, &parent); if (rc) @@ -493,7 +520,9 @@ static int plic_probe(struct platform_device *pdev) struct irq_domain *domain; struct plic_priv *priv; irq_hw_number_t hwirq; + int id, context_id; bool cpuhp_setup; + u32 gsi_base; if (is_of_node(dev->fwnode)) { const struct of_device_id *id; @@ -503,7 +532,7 @@ static int plic_probe(struct platform_device *pdev) plic_quirks = (unsigned long)id->data; } - error = plic_parse_nr_irqs_and_contexts(pdev, &nr_irqs, &nr_contexts); + error = plic_parse_nr_irqs_and_contexts(pdev, &nr_irqs, &nr_contexts, &gsi_base, &id); if (error) return error; @@ -514,6 +543,8 @@ static int plic_probe(struct platform_device *pdev) priv->dev = dev; priv->plic_quirks = plic_quirks; priv->nr_irqs = nr_irqs; + priv->gsi_base = gsi_base; + priv->id = id; priv->regs = devm_platform_ioremap_resource(pdev, 0); if (WARN_ON(!priv->regs)) @@ -524,12 +555,22 @@ static int plic_probe(struct platform_device *pdev) return -ENOMEM; for (i = 0; i < nr_contexts; i++) { - error = plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu); + error = plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu, priv->id); if (error) { dev_warn(dev, "hwirq for context%d not found\n", i); continue; } + if (is_of_node(dev->fwnode)) { + context_id = i; + } else { + error = acpi_get_plic_context(priv->id, i, &context_id); + if (error) { + dev_warn(dev, "invalid context id for context%d\n", i); + continue; + } + } + /* * Skip contexts other than external interrupts for our * privilege level. @@ -575,10 +616,10 @@ static int plic_probe(struct platform_device *pdev) cpumask_set_cpu(cpu, &priv->lmask); handler->present = true; handler->hart_base = priv->regs + CONTEXT_BASE + - i * CONTEXT_SIZE; + context_id * CONTEXT_SIZE; raw_spin_lock_init(&handler->enable_lock); handler->enable_base = priv->regs + CONTEXT_ENABLE_BASE + - i * CONTEXT_ENABLE_SIZE; + context_id * CONTEXT_ENABLE_SIZE; handler->priv = priv; handler->enable_save = devm_kcalloc(dev, DIV_ROUND_UP(nr_irqs, 32), @@ -594,8 +635,8 @@ static int plic_probe(struct platform_device *pdev) nr_handlers++; } - priv->irqdomain = irq_domain_add_linear(to_of_node(dev->fwnode), nr_irqs + 1, - &plic_irqdomain_ops, priv); + priv->irqdomain = irq_domain_create_linear(dev->fwnode, nr_irqs + 1, + &plic_irqdomain_ops, priv); if (WARN_ON(!priv->irqdomain)) goto fail_cleanup_contexts; @@ -622,13 +663,18 @@ static int plic_probe(struct platform_device *pdev) } } +#ifdef CONFIG_ACPI + if (!acpi_disabled) + acpi_dev_clear_dependencies(ACPI_COMPANION(dev)); +#endif + dev_info(dev, "mapped %d interrupts with %d handlers for %d contexts.\n", nr_irqs, nr_handlers, nr_contexts); return 0; fail_cleanup_contexts: for (i = 0; i < nr_contexts; i++) { - if (plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu)) + if (plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu, priv->id)) continue; if (parent_hwirq != RV_IRQ_EXT || cpu < 0) continue; @@ -647,6 +693,7 @@ static struct platform_driver plic_driver = { .driver = { .name = "riscv-plic", .of_match_table = plic_match, + .acpi_match_table = ACPI_PTR(plic_acpi_match), }, .probe = plic_probe, }; From patchwork Mon Apr 15 17:01:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630403 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 798A2C04FF9 for ; Mon, 15 Apr 2024 17:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9GDz8PL7+eTA3H+USu8RaHPVbfuolw8k6JGQdGBjg0g=; b=i2QfCXdlzgRt2t Hu9yaL8UtZuysXqJTnqfnUVxOUyXIctokVxNrFPrBHmM2ePrK3361tnbbXnBM7SIBuV+KKCBtc9jF NSKpqEH8fA87qA7dpOKMwhMbRMqnkab5ttAcFBf8jbCnm2z+yHjbdiW/ms8F5Ih0eMhAbGLDTb+CL G+5vPK/64flutWhp4oe5ANKT2hWWf9+XY4OhUro1464YsrTUjAH1T1Z5ZRqMispBT7TgD4kuK1/Kb mMM2JXa2IOgNc71XvZSL+d7ocsof5id7MBhPNAnJ8Pb51HSZEwPzBKkS0Jn2Yn8RNF8MQLRF60hr4 ma33Upz8OZ2cIeDH8m9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPlz-00000009EHR-07Pv; Mon, 15 Apr 2024 17:05:39 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjv-00000009Caf-11B7 for linux-riscv@bombadil.infradead.org; Mon, 15 Apr 2024 17:03:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=tgBDpDYGQ0glprRFD8yP0RdoCRZMFoPF1RZGUEi3Dy4=; b=S7bVLR5YE2xLi6/xPJkQrDbgl1 L3VebR9MwwYto1nMkRRJOk9VTd1kEBgfHSzsKGcqdBi2YfHeqG5t6KUejsuEm7RhSvdxtc5yBF/pS 7xmXybjVXsDxVvnDJ4YtDD8QgRbZdiOxmJBPv7ltICCQwTgTBZv8XGpybI9XngR/kTKGBDGFFM4O9 tcjMKIahPh/B05uAptbfGTpm0HD2PO6WeuS6BC7f/WW+J2dAfiXmW6TIaBunwXkY4fPJMSmmTgLMx ki/uzHXXR0o92LEAeLUT+VoKofMHNhl4hNi0cPvluc91Xl1O24qB1JkHKUTAvNQnU5Wtiwt/Ngz5Q mLkPhW6g==; Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjp-0000000Afb8-2VFo for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:03:29 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6ecee1f325bso3227438b3a.2 for ; Mon, 15 Apr 2024 10:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200604; x=1713805404; darn=lists.infradead.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=tgBDpDYGQ0glprRFD8yP0RdoCRZMFoPF1RZGUEi3Dy4=; b=gkPRUWGsdiyyJ8X+Y/YomrWGhsDJyhFZ5w6lCPZcJH/obPJx121ZqIb2HKUi/mbI6d 8VBoAbjlvCwIFyDU9q7lBKThepDOXzi0IjJLbHcxrY33Yb7R6lD3C+GyvBGuOSIbmL6R 7cqrvCSPVlLHu66HjE3SmmnvkKhFXSS+qCG/XsdGSno2vUD7YbyNpLQgWMmk/WbbwraT LQndydE0Z1uCbO2b84/eY/8GHH96XtNNrgCNYBdi8P/Y+H/CMncbPT+PjXbX+1K7ZeJp yif42xWemK2EhHXOR7dgJdV7WEYe9UxEXazOnLRjvz12Vpb67QvqJa0tOPe65PsxPpXM 6evA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200604; x=1713805404; 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=tgBDpDYGQ0glprRFD8yP0RdoCRZMFoPF1RZGUEi3Dy4=; b=N464y6ddXtCgKynoRwX8d4IgRMwlPeezO5v0k3o4Edobvz2xiVuI27jyL8dpcweQFP uB4AKRZf9pawfe1H5GJDrUBEXknEMRLcCqfGP4k9LGukpyd8qwPN6bpPdH+iyUCKKdiA Dgbz1mhYoEU3Fl02yeKJ0SqpOTdC6h+iCN+gfmP5Go88CQyw3ojKAwR3mY8g7B9OJcB3 He8UrQ1ByLkRPKWBU4wyWuUg0OKr4u0iEl6EzmEu6NPnrYxCQqHZZa9e20eBBHctw9mE dtDYv44ni0izfGEv8ENPcbIhch3O4f3F5nWiUxu8xiRs3Cc3kKLw1NYlWEm2w8PTWOaa /4DA== X-Forwarded-Encrypted: i=1; AJvYcCU0fpuPMxNGa+KxNIkXqdS9m/56c0mf5kCpGD+cKO0RJ3aNbXX/4X5qTouHJ6Fxk3s8RAR+z0BOIu9p2JTZ6XyCUxgJ2ZiCmufN33SQ/Ylx X-Gm-Message-State: AOJu0YxwTn5r3XxcCdKBaTMjbBVpEj9HB7w3MYZz4YlreDFelMHTPBz6 YQzTJofCqN+HyF/vcf4aaoBkleybET8ZzqfoseogGkJzFJQCrxdii2K7BwQyLsb6Da3R7mgdj+N aVQQ= X-Google-Smtp-Source: AGHT+IGfV3g4HnB1SEs58HPZghQyLF4oCdd9NUua8vNYxrzLQb9woMp8qFN8pqykKJDwEhBAY0XH6Q== X-Received: by 2002:a05:6a00:23cc:b0:6e7:29dd:84db with SMTP id g12-20020a056a0023cc00b006e729dd84dbmr14671886pfc.31.1713200604137; Mon, 15 Apr 2024 10:03:24 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:03:23 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 18/20] ACPI: bus: Add RINTC IRQ model for RISC-V Date: Mon, 15 Apr 2024 22:31:11 +0530 Message-Id: <20240415170113.662318-19-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_180325_982915_FBE8DD37 X-CRM114-Status: GOOD ( 10.43 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add the IRQ model for RISC-V INTC so that acpi_set_irq_model can use this for RISC-V. Signed-off-by: Sunil V L --- drivers/acpi/bus.c | 3 +++ include/linux/acpi.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 17ee483c3bf4..6739db258a95 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1190,6 +1190,9 @@ static int __init acpi_bus_init_irq(void) case ACPI_IRQ_MODEL_LPIC: message = "LPIC"; break; + case ACPI_IRQ_MODEL_RINTC: + message = "RINTC"; + break; default: pr_info("Unknown interrupt routing model\n"); return -ENODEV; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index f8f92aaf97ad..c4b6d5c3aaed 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -107,6 +107,7 @@ enum acpi_irq_model_id { ACPI_IRQ_MODEL_PLATFORM, ACPI_IRQ_MODEL_GIC, ACPI_IRQ_MODEL_LPIC, + ACPI_IRQ_MODEL_RINTC, ACPI_IRQ_MODEL_COUNT }; From patchwork Mon Apr 15 17:01:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630404 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A4F40C4345F for ; Mon, 15 Apr 2024 17:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WwtrQPnQNovG1Gs2RgbTw9bAyKNv8kLxFimRYPZi4Us=; b=Bcbt5kyzt70EFK VSLc8xNWXH5vN2DPNbtnPyZ/zHszzw5U2x+I01PPXW089l0HCDY5OcIt2UY1xkizkUFjQ8XD8qvzR 5Mf9Dm8gJrBSVsGxIWA8skcSdDMibxBJdY7VU98HB6DDifGNrnKjn0qhi15KcoXO1+/5ThijuCUo5 8w26XQo8mgZVdslgo7fCWzAZfG9Xh8NsrOjDDoLvoU9Cj8zLs4ii7x9ngUv0TKHJk+sHqF+ZlMPR7 in7LqT1gphw5Bm/RAQP8rEgNgFTjge9I0Z2DXIjYnkvUWivRr9I9V/MguYsVC1+/aRMo+d6ar2j8M 2U45QLKGGieEXnYt1D8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPm8-00000009EPH-1W9H; Mon, 15 Apr 2024 17:05:48 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPk3-00000009CgY-0CnU for linux-riscv@bombadil.infradead.org; Mon, 15 Apr 2024 17:03:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BiK7floMzb7J5dAtjxG557Fp/B2Bd1rBgLoGJEgu0Mc=; b=c2AsBKpYQziIE0CBSeErSQpLrq DqxXAisXTmbCEcUfoN49OJ5eigWCMgdRUH12Vm+vatiLBOrcimmGV48rTkO1Fm0i/8tZn/lTmaBsJ pEw0BYQMqjqo5BxUSIB0+x8mvST8BKo+SADX+HaHqpIt/I7JWHA+bsb0zYpGXGb/XOEAxcwqdmLum nb0tYGhzEnKCV7Qr2YxFcQRl9dETv5OBr+G0eIwFZKqZJzX5FCMcBTBulFWYGDmhNVcXL/XPpsiMS Qh8TMXs6Tm3Yl7iK8UkY4y4DInYK8kljRnUrOxsVuI/tuSNIGWhcFwSlLP67/teTceJ8RvDSzOAF4 5P32fcHw==; Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPjw-0000000Afcj-3zlH for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:03:37 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6f00f24f761so661019b3a.3 for ; Mon, 15 Apr 2024 10:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200611; x=1713805411; darn=lists.infradead.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=BiK7floMzb7J5dAtjxG557Fp/B2Bd1rBgLoGJEgu0Mc=; b=SWWomIuL6iqnnztOk81Beaa1Ega/Jh4+hJBk6npDP5iyz7tPhDRsJLAGQ/U/CHkTH8 9TYD09lLDu66/FZujzLwtBnezOFBDWjXZHmCdA38lUyhI15sM4072WgrpoLCMww+xDh+ BfcmLEcdT5FXIhSrzKmGQqlDP0K6COVTQ2BXw4vzASSHOSoS7tKNiPsJE+I1PRYdjsAO DByoPiWQh8Ldqk4y9V0IIob735sONpjtMXaMZzFsPyOKwRibbVJrmSdrMm2FTU2RSLrd z7QGpr79A5shfwwhL1GIF8vznvnVfqE8r2rO9F2uMCTtz70wU53s8iVCJFy88nWbN2kB dLJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200611; x=1713805411; 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=BiK7floMzb7J5dAtjxG557Fp/B2Bd1rBgLoGJEgu0Mc=; b=YRYaYRLhSa0ottYpomjt1eypcZCgoz7gAyFdYvCOxDnd7kTgPvldjUckfjpIn0//Ns 6COJ7eY2cV5QnWdmJHbxYVxRd02aARLCHVs3K2TWiQOljApHSHikcKq+yFmzvtCnMvUD GgsYROAtSN8wIUkqB12UNVY6FgkWOzPweys5W/zPe2Y1I5dLdLfxN/AXkc7tnHhD0sCH jjkhhnXE79CD/qE9dklJc9lCX+BebPfHx0Sog7Aeda543s/ltdNVH/gp0iUnLwIKBadR U6XRSU/wmqH/i4aodhyCLlnvywcMhfREin0Tne6gPq35fkVoa6PyODMV7IIzQdIj1RnL ruog== X-Forwarded-Encrypted: i=1; AJvYcCXVKB+CIe9GaqTYcBlG8juj+K89+pD4ytJBOTUSCXCuDREjcuZKrm+DYMZE+oi/5rlkhTmcunEUKX5WMY+b0MMpnmzWkCilvJAiMX22Zzzy X-Gm-Message-State: AOJu0YzkxNUQkmTPqtMCVVfYYg1RqmLfHzPeH71ks0hlNBt/oBXiy09A HAEkHOtNh+sgufSOY6ayKqc1YKBqigO9CSuiXvdTJyDnlPGeQHGwlVxM+VtBVRc= X-Google-Smtp-Source: AGHT+IFd9+zDBggMUEnYbs4X0hsHQYh+Hj4Aej+R4rn7fzXqChszrhGpkzejjAS1RwVrkPfA71InHg== X-Received: by 2002:a05:6a21:3182:b0:1a9:da1f:1679 with SMTP id za2-20020a056a21318200b001a9da1f1679mr4846522pzb.34.1713200610709; Mon, 15 Apr 2024 10:03:30 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:03:30 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 19/20] irqchip: riscv-intc: Set ACPI irqmodel Date: Mon, 15 Apr 2024 22:31:12 +0530 Message-Id: <20240415170113.662318-20-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_180333_157029_A427691C X-CRM114-Status: UNSURE ( 9.68 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org INTC being the root interrupt controller, set the ACPI irqmodel with callback function to get the GSI domain id. Signed-off-by: Sunil V L --- drivers/irqchip/irq-riscv-intc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index b20272151aed..af7a2f78f0ee 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -326,6 +326,10 @@ int acpi_get_imsic_mmio_info(u32 index, struct resource *res) return 0; } +static struct fwnode_handle *ext_entc_get_gsi_domain_id(u32 gsi) +{ + return riscv_acpi_get_gsi_domain_id(gsi); +} static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, const unsigned long end) @@ -366,6 +370,7 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, return rc; } + acpi_set_irq_model(ACPI_IRQ_MODEL_RINTC, ext_entc_get_gsi_domain_id); return 0; } From patchwork Mon Apr 15 17:01:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13630405 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EE4FC4345F for ; Mon, 15 Apr 2024 17:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f/Yx0B0ysNYeW7dIL5Pxh6J7MNvEuOAjUQd/M5tnBj4=; b=M4qJfCiDnkaEXQ OnAyfzbzt3PbMw2za5NLJtSzmqAu7vm4H6CC7rv8hazBvZ74SBt6V7pjFgdfxJd1gQmLIdjgAJMR0 tARzzxTk30iLjkEudSR/URmQyQ3XBPCwXI5l+4KWQE9u5ZSrHHYNRUczOYvNxSAPdYyX5o+HT3tb7 YN1eE8qwPxzlD0y1hMiR3s3VGuFbTxGL0viuD/mne/o5yXw40k64CuvvSkutyexaViwllM35dM6LM xSG8PNrLwqQ3+Nw7a4v5LPODosIkkbsmsOEuPNIcmO0cd+riotsTCtAIeGdXmOlqz44QdZ9v/ncru lplp6tf+0kNhSyt66rVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPmK-00000009EXB-1KIs; Mon, 15 Apr 2024 17:06:00 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwPk2-00000009Cga-2zoJ for linux-riscv@lists.infradead.org; Mon, 15 Apr 2024 17:03:47 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6e782e955adso3474923b3a.3 for ; Mon, 15 Apr 2024 10:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1713200618; x=1713805418; darn=lists.infradead.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=O4XnyCkVtMil3j8A/KjvpJf48jXr01BLYuVmlXnWMII=; b=AOSTBGfwJld2+KHSPUWivgENSTWMQwPjj9wdBYi98mH+OQHRvIoBLj7nSGZ852+bPS e+0A/mkOlXZnovGmho4huqYhDApU+ix38G28B3E35OUd+ecQ64Fta6jxBSRnMWpWdxwv ii+J3IvU6OyZpbRJCokGfC1BgGGV+b2b3GulXpa/kqQlrDjAFcNWe9CIVglbpDSi93HD 92wnb0xa8KqgSVRzb0OnVOrRflxXKF/jY3zf8oYusyQ73AYF/36Mj6iisCduswhGH1Oy zM0s/ghoxDFPHKD/if6wVnIOqfshuiH4bchnMgGKoSv58P897aeQyxdmYxaUWg/2Cn1L 6dTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713200618; x=1713805418; 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=O4XnyCkVtMil3j8A/KjvpJf48jXr01BLYuVmlXnWMII=; b=oaDHGjxESuLU7fV+sKMVXSM/GiU4fTJFLQGvtbaM5Hbozwe6m2VI330C7HbNSJP+UM XBqZeYksyMyd6TZVrUDwrfPAhKs257UP5CUhNLhk8Q0VNeb0Ib6MBUppbV6UtnUAXXap xZwn+hRTDXTn3xAs43kHF1OTNMMJzuYDd3K/huAQJa4EapNzd9ffzlTNw6J7yPTKtUW/ 9L6EpyCux1EOdd0a3fYnGG1yFaFyLIqElyU3acqdM1aBo0Im+l7Q3gm39Qr9IZwBJTHu WUneMmGV5txEf5Tv4hibSIsR6NTzrFwrdNdA9lNb4uuvBuJmIZsJwEzvc5Pb2aZnnI/R bz1g== X-Forwarded-Encrypted: i=1; AJvYcCUaGH8V2XSu+g8KnBZm8gWoaOdG2Mppw69jewfcNuhYHHIXYgUcJtCD7FG8ho+5RPw4AzYCS8Roo2GFabhkDq6ECMK8xTOHF0sRHFZJqghQ X-Gm-Message-State: AOJu0YzJW7eSrzkLctK0iOU+4QMLcE80aBqg64M2ltB5X12WD20QC3bW affykt5TREOTZVqQbfdf63CP27GXZ5uELVn+03zkjs6guD0RPxwmZ/LTXcqBPC4= X-Google-Smtp-Source: AGHT+IEZ3MSxzXsGAz+ZLkxl8S7XJ3zcQ2NIg6LwPVYoJf81xxbiq6s9OomXLtGiFPJD3YOtkLtUPQ== X-Received: by 2002:a05:6a00:acb:b0:6ed:21d5:fc2c with SMTP id c11-20020a056a000acb00b006ed21d5fc2cmr12682862pfl.26.1713200617123; Mon, 15 Apr 2024 10:03:37 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.230]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm7433158pfm.25.2024.04.15.10.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:03:36 -0700 (PDT) From: Sunil V L 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, acpica-devel@lists.linux.dev Subject: [RFC PATCH v4 20/20] ACPI: pci_link: Clear the dependencies after probe Date: Mon, 15 Apr 2024 22:31:13 +0530 Message-Id: <20240415170113.662318-21-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240415170113.662318-1-sunilvl@ventanamicro.com> References: <20240415170113.662318-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_100338_894880_5D7F5EAD X-CRM114-Status: GOOD ( 11.81 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Albert Ou , Haibo1 Xu , "Rafael J . Wysocki" , Catalin Marinas , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Andrei Warkentin , Paul Walmsley , Bjorn Helgaas , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org RISC-V platforms need to use dependencies between PCI host bridge, Link devices and the interrupt controllers to ensure probe order. The dependency is like below. Interrupt controller <-- Link Device <-- PCI Host bridge. If there is no dependency added between Link device and PCI Host Bridge, then the PCI end points can get probed prior to link device unable to get mapping for INTx. So, add the link device's HID to dependency honor list and also clear it after its probe. Signed-off-by: Sunil V L --- drivers/acpi/pci_link.c | 3 +++ drivers/acpi/scan.c | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index aa1038b8aec4..48cdcedafad6 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -748,6 +748,9 @@ static int acpi_pci_link_add(struct acpi_device *device, if (result) kfree(link); + if (IS_ENABLED(CONFIG_ARCH_ACPI_DEFERRED_GSI)) + acpi_dev_clear_dependencies(device); + return result < 0 ? result : 1; } diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 086ae040a5ad..32865af071ce 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -835,6 +835,7 @@ static const char * const acpi_honor_dep_ids[] = { "INTC10CF", /* IVSC (MTL) driver must be loaded to allow i2c access to camera sensors */ "RSCV0001", /* RISC-V PLIC */ "RSCV0002", /* RISC-V APLIC */ + "PNP0C0F", /* PCI Link Device */ NULL };