From patchwork Mon Aug 12 00:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759941 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 23AB3C52D7F for ; Mon, 12 Aug 2024 01:00: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=OzPT2a1H1D7e3PegtZxINWKyv1yWcG/t2RbzDAqcAvo=; b=g3VoVA8s9mU37g 8icsA1sblQOJxb38etBU7LvP0qRYq2WQ+BUFL0s9kyrOmuN01HzJ8Z/yFZOFUuBOROB6Rt+7G9XGO 8ea3fG07gwCt/M3Y1pqgJKBl7/yQJCIz2M9u38VuvW/ZlfwqsZUu7YMwLqw09c4+zVMO3jC4Q17QT atmBZXHcdW1wgz3R4uyzgoRY4izChGFGpypzL/mktghge7ayodofVHuINGwAxp9u7tR20f99E7MME mjczvc3lNqVjTDsQWOjvMb9qCW9BDbyF9W5e/Oc6r7/DSZwR2zvPwuqS+lkqD1N4BPMSAx8fHrZmM HU/EHCRWepgRDCXpDWmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQ7-0000000Ga3d-46IT; Mon, 12 Aug 2024 01:00:23 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJPY-0000000GZrZ-2pnE for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 00:59:50 +0000 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-39728bbf949so14888225ab.3 for ; Sun, 11 Aug 2024 17:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424387; x=1724029187; 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=8jeK3ESAUl7YxTE1Iy3jfhVYgTpS15SSq0iPGR06s9c=; b=bsbQ8GD+fyFMsB3eZ3IvUjzcT2+UWHUy/SyKGHOBkr3aRO8XxQgdoBYgBwnLio2zR2 zTp5GfFFUUkNjGs48RLS2wjr4zv0VN6sguZrlIu98d/KBcYADMIgMN50kCosB4I0prAw X+UuiF77akVepDsD3tR592PdGp/wCTJlerHzeGQ/g5EA3ajEbl1SUoInmmTppTzZXZXf bG4oLq68DXSPDpL1fyFLOTcEuJ8mfIkavAOJcr6QiHF5LQnTwC5c68WJt7OYogHN/TJu CIJnZCgV2FvXLVL8Tw1Ral7nqdkpCxg/Du24VG+tBkCYKpTsOLXcEvL/1ULs/4kMFsNJ C3wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424387; x=1724029187; 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=8jeK3ESAUl7YxTE1Iy3jfhVYgTpS15SSq0iPGR06s9c=; b=fQnFUGi9y61Ee5R7OOlPSk1DRRx+uQFPGie2ubWNKW0O+CrrTTjWvBKJL99ZD8HiEq jOw7dd6Zt+C4CXGRxrr4seKaEfMhu6Q611BmgsXuHoJmvm1VrZAp6oXfuTpCkdYmxkqt Xnn7u6V0cMi5q/Pni3C/cgkgEEge9GZmwA/6pmJiOBdrkNRtlyOs64FmPpUdfNQYIZaf qyvH4pZrgSkhEhoCgnKhfKnB4+FZyC3XDAE3GaYF5tN8Y255HZJl/zu8eFNd9HQbwayB Vnrb+e9OOXKGeT7Wwwj8yRxwUS+rqnULufMYt4kMTzeg96S6NFbNaeUZ1RTkXe21gTlR Awfg== X-Forwarded-Encrypted: i=1; AJvYcCXJ4/B+Ilpf/bjxH1xwBLw1f+/vsZGtMk2BQeoex13XW8Fk62WMTk1saqZjYckCJNk2RnW5yDbZTWb/zooob9VJpPBdTmOory3xKdxsyf0h X-Gm-Message-State: AOJu0YxzPY9ICnrlFsMOdBFgeyqulQrtf5cOz48kSHQalmLd/AGC6wbN zelYpshTLdbghbdPqT/VjMeasOxDJ+fMAKxNOH4FM0YocRgD+3+F7D1lsWcVN9g= X-Google-Smtp-Source: AGHT+IFIiqNGjgTEsTyA01AhWlCd5/qrU642pe+8j8qsMImF8/xohIsj9BzQ1yvF+gyWEF8FJGTC6A== X-Received: by 2002:a05:6e02:1a29:b0:398:81e9:3f9e with SMTP id e9e14a558f8ab-39b813345abmr101145885ab.12.1723424387549; Sun, 11 Aug 2024 17:59:47 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.17.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 17:59:47 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 01/17] arm64: PCI: Migrate ACPI related functions to pci-acpi.c Date: Mon, 12 Aug 2024 06:29:13 +0530 Message-ID: <20240812005929.113499-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_175948_754476_40CF8971 X-CRM114-Status: GOOD ( 21.23 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 Acked-by: Will Deacon Tested-by: Björn Töpel --- 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 9cc447da9475..8ed81a373bd7 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1541,3 +1542,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 Aug 12 00:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759942 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 2391FC3DA4A for ; Mon, 12 Aug 2024 01:01:09 +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=XeBR6a4fARGb+Tt7ZRQG0e0quZGS87vOfNdRRdyuU+E=; b=LuIW0BdFCdk2bn WlSr/T79HISonARBB1Ud1OTr4SOWUJdEaykPGhM2NFYb5nTWCwgWQS6qpAn6KZ2K6mHDvefmL5Qys QjV5w+vFKHQoVF687NXvkl2agbH4RGgfWWSmcFrytMLFQHy59Phl9utbrINp0/qbREq2lx6arpUZv DDiK/F3wXy3e5NZO+p13nkkOXHz6LDbXM2mFvT8fmyxSQM4QiTiB0aKOr9vUPlQ12XuCPQ8OIuYTK ZB0Gg4kT8EYmz+DQt5uxgtwvRdRTbUJP3o+OsNSG66kxk3P5shCO18BGwDQfUeazSKf8AxU2pVKQl /aJjj5Qfl55b0CRJdIJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQn-0000000GaM4-45FV; Mon, 12 Aug 2024 01:01:05 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJPe-0000000GZsx-4BB7 for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 00:59:56 +0000 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3db1657c0fdso2718060b6e.1 for ; Sun, 11 Aug 2024 17:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424394; x=1724029194; 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=cDiQZULOrmkIQ76w8p/0qXlEheAvD+F8k2bdCW40Dj8=; b=FO4zhSiEB0cd//oKILZUydXn1L11s25NgiVYcL9GLqu0tFQzVjODQ2W1k2cfS1vXrd gJDYydX33lrMLNhFzN/Ne/HClaY+h99tXmr1UyP/mBDtIyTUKjkQlbzcqNdeCVXnD/VL hSC1bNWYqxyiTXqlpNcxoJJ12dYhnJzBLOMMhm9580sdFkqOkMPxqZN0rFmgDZQAfRD1 TThZNwG1/hqCwyQa7oS/nj8JYrV6KOtVTUNqv8wCtOJkZbytDEQXrPUICjL1MKnhJxlT 45WzTYKNiXsNaJwkLe8EIEerBgzrMmqP4+HP+zyYCk+mY4prUuZ4WkSF7zwhqIxokRIJ EZag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424394; x=1724029194; 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=cDiQZULOrmkIQ76w8p/0qXlEheAvD+F8k2bdCW40Dj8=; b=urMRWS3z6N+HgmSxjR00x/bYkZ1oCTFoCAexLvICAHkas/bUhDyEEerbUR644Lv7X8 XM5y0l77kVoZYZAnkT45mAOCUaP60YtpasAzHdbchvOqCCrBr9usle/OJtoTMC+cRHQe TZ/EpQG2YAphrY9JryOjR5oOZ8pxZxFLxR3pviAR5bxXXCQf3Am2esUg0UXVoa1fN1rW BxlPSe/CExoD5moqwr+iZuDCE2oC0NymG9y1kAdftOfqWZLjfDXoQ69uv8R1/V/95SQ2 msmuRx/jpaiB6JSU3IiF5bZw0U80TwizBx1dMqwSN8rUua86xiDCNg58ZK7GiI8n0U2U KviA== X-Forwarded-Encrypted: i=1; AJvYcCV0VWTkXfio3oWSGAHi47M3XwnbOEQ69RsIthxH4kuRftwFVIG/u/nMKn1T1rjXCjnhLJ+cSKCHZPWF8oYM8KdbRPBbzzyYSHM5uJHyq9Lr X-Gm-Message-State: AOJu0YzHWQ1ibRuSaZ7Vll99lSdxVD7cJO85kc2716q6zduwxOB+yN6g HwF6IcMmtmsKcIb945rSM6IbU98wdMHCr2MTobUFGlHefmVFfHc2+cJmwpQtEvM= X-Google-Smtp-Source: AGHT+IFZ+1tDJ3142HVFsLE4ya3SPYZxnEcsV+61Xh8a+xb4OPG7zVmGoKf++d88AMIRm4sWlhcOOQ== X-Received: by 2002:a05:6808:2185:b0:3db:fe8:f744 with SMTP id 5614622812f47-3dc4168aac0mr9047447b6e.24.1723424393786; Sun, 11 Aug 2024 17:59:53 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.17.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 17:59:53 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 02/17] ACPI: scan: Add a weak arch_sort_irqchip_probe() to order the IRQCHIP probe Date: Mon, 12 Aug 2024 06:29:14 +0530 Message-ID: <20240812005929.113499-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_175955_057105_7B8E4061 X-CRM114-Status: GOOD ( 13.63 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 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 an architecture specific weak function arch_sort_irqchip_probe() 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 Tested-by: Björn Töpel --- 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 59771412686b..52a9dfc8e18c 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2755,6 +2755,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; @@ -2763,6 +2765,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 0687a442fec7..3fff86f95c2f 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1343,6 +1343,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 Aug 12 00:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759956 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 008FBC52D7F for ; Mon, 12 Aug 2024 01: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=l0EaYGpYBenPXDKsozAtEBG6XpHeGjLsLTMkK9CHP2Q=; b=Qc6wuO92XnnSAt KQvaDl6GbarZL3Ygu3B9xGtwQ5HJdF1X1vpK2szn3n+2W0Yc3ux42aQE0I59EqWmfiSIJVmnvdhDV CNVCoWbUlyeAhdnhQMe0ljo7VoqEgh6oy49gUr7gMOkKKwH6jABtbnPVtm50JDIMOs1KwAPhWdtrq +zh7up44PQCPU+aEVrb4S93aaeH8rTTbDmL1UY4malecoSfrukRr5zXl03+gy800PWWCEAshYYSL8 h6BtNPb0W9KQpK6u9CMimza40nCV2vKvV+vGnrDS8qiMXXgmEgyB82V5sAKsDDCfC1UwHTEIDMl3m TNSP3skNImaNjkvV6quQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJRR-0000000Gagc-3kPy; Mon, 12 Aug 2024 01:01:45 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJPl-0000000GZvh-10Z7 for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:02 +0000 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-70942ebcc29so2689470a34.0 for ; Sun, 11 Aug 2024 18:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424400; x=1724029200; 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=kH+4pIB9prP9kOEprexbBfphBFyJQXg0yq2xsmagq1s=; b=fsHg+BNGa4pU0EbwsuGDK9Dbd7Jx+VUmA6ZothC+3Ns3J5+fyjlsqN4N/KlGcUP1im NLKwLTaihUthRFk8rdYUuzguMJSfQxDKU4MQOWWX2UQNUZSwghBG7khNXD8RXNnPkstt rqzrLyRgvUkw2dr12YLe/S5ZOAXMPcSdVl05+R+vtGgsaB7KGPd2s2ZLir4IEPpVhdbu Z+q177XahcMYUV2SFYFfwi8O+9otEEQKHrXdsQNjDBlvkYKizw4E00wEJdPzMwsgxosm qqgB2VQ4EDa6scjfjez1bvq/I5fx9aq/W+gAPjq8RvQLjHuxysJ6/045Q7ec5gqDt47/ aAYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424400; x=1724029200; 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=kH+4pIB9prP9kOEprexbBfphBFyJQXg0yq2xsmagq1s=; b=siB3SGP1EKdbLhwE0kdvFcO2ZXtWOPG4lcbg3Z8T+VRL5XoFIQZoymGqzi9H7scqNg YToggrKL/gukvk6nTHWRejn7NxBxlXieyoM17vlnYuNaTBJ1Rj8VOmNMJnTGkQJNHlJQ ZD1WH07nn6tNeE0VPq9IAy9If8nS3sESbCqH/h7IVGqDzHdlzxCjiEheVir3hAk9EyZ2 bF6i+hdJzLxle6z3AZNLuNzMlZmp8CSDoAl2QHltMcOvSCTSmZYIbJ7SoJz2UQzILq4X +ghfRzeVFCMTPDPCl1/Z//zGkABdaUb/0o44W6FBlOmCdkoM2F4++ENj0ka8QqvWnyZu CssQ== X-Forwarded-Encrypted: i=1; AJvYcCVlEAiYsThgyPvs08adNMHgGdHd18qMfvPZGu+8mHLxkhzyA/ylO4cAYSvvuR2SM40CQZvajoU2tipUbxY4Zx+r59jnakL9Gm73miLk4F2i X-Gm-Message-State: AOJu0YxaoocbbmHCikoeBJk/tfS/RmtbkHgODIy8PtzzuggVUeGAq3hd cB+RyOCNEVlcbmQDcEPN8IVmNFb8Wo26Pn82w2/+qqQarfgLEl1JT6n9eiLcVfE= X-Google-Smtp-Source: AGHT+IHrAlknP9L5C6h6kRrSytyVyD8ukh4CBeZCWs5vO7PGS1mxPUN26YUu6El93VBg0yE0hzkTrQ== X-Received: by 2002:a05:6830:6c0f:b0:708:8c07:c646 with SMTP id 46e09a7af769-70b748745c5mr11624369a34.33.1723424400027; Sun, 11 Aug 2024 18:00:00 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.17.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 17:59:59 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 03/17] ACPI: bus: Add acpi_riscv_init() function Date: Mon, 12 Aug 2024 06:29:15 +0530 Message-ID: <20240812005929.113499-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180001_316799_47428D16 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 architecture specific initialization similar to acpi_arm_init(). Some of the ACPI tables are architecture specific and there is no reason trying to find them on other architectures. So, add acpi_riscv_init() similar to acpi_arm_init(). Signed-off-by: Sunil V L Tested-by: Björn Töpel --- drivers/acpi/bus.c | 1 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 11 +++++++++++ include/linux/acpi.h | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/init.c diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 284bc2e03580..48d277657203 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1459,6 +1459,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 86b0925f612d..877de00d1b50 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 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..a875a76aa44c --- /dev/null +++ b/drivers/acpi/riscv/init.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023-2024, 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 3fff86f95c2f..892025d873f0 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1531,6 +1531,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 Aug 12 00:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759957 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 91CCDC3DA4A for ; Mon, 12 Aug 2024 01:03:01 +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=jmFG4LUdOHf9DCfdzVSYHE4BxP87sJrzivo/LqomXQ0=; b=3maBDJbmcqChJq 1K5q4BBoTeV7nmUFVsiJE+/MRxnorkBewHzpViW/oj4aIph7hjpsPf66d5j4yfu74qWb1GbudDkbe RCDNzWn85s3dhKTaRwZSOrQDX7yC+zsg3dunO42uO6BxDTEWCFM792Ehm+OYQcsFDasCPP0fkA9gd 6406a1J4nKhKA0xcGWlNKbzKy+szk/inDF5/fNFMPi9iNfaphdkVYaIlGBhSwZx+q/Mar5T/tyoi2 fBnZdZlkSRGUhvqp/bUuhsTD6oqDVAcc+nunRCvbI70pNE2vquQkWbBdeDv8YTQTnIx42pqgv496m 7dGv+2X1HaZJ1/lQpIjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJSc-0000000Gb9M-2LKH; Mon, 12 Aug 2024 01:02:58 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJPr-0000000GZxH-29wo for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:09 +0000 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3db1d4dab7fso2461736b6e.1 for ; Sun, 11 Aug 2024 18:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424406; x=1724029206; 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=Fg7MKJMwlR+eRmszvFqgWwl0l7xFjetJlLXQ4McHDXI=; b=Saw2lwIvxBK1sAVIlQbVyl582VclKulhoVwXOc0HwmMLsK9fG2JI0p14BHDbptvJPm /9nQIAyY3hThYsNS2NTlnGEopwgfl8AXz36u4Ixe473ltCBBtKGaWIzYCn7pusAiRqw/ Jg0QE78rlEcDidjk6kg6foaPmv8oLV1vWPFzJucywrTnzG6w670O377d/nWoVrZxdKJV bV5doTIuoOP0+SJp4TpPOPMpVKuWKdxCRVnVWt8rZWbyrTW5ZY8yOlO5Nw+hYKVwuP2q 0JsrW1FOJJySc8rZc8Mq1ULEaf+JV58aCNh3Oev9ECTeM5IzUqdNwDHVMDLoR8m3PTAj 32dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424406; x=1724029206; 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=Fg7MKJMwlR+eRmszvFqgWwl0l7xFjetJlLXQ4McHDXI=; b=AEy6WkAZAfmPDGoxptGLeHbt+Pyxg69E0L2QfaycHC/AfUtSIHixYKDw+qwLT/mehA u+eJrC5IAkk7UbCvyDZCD3Wge483wkVJ0722l5DzXbZ5VEoY3CWkZIua2hvokmxvz/Mr ZaXZphV3hfLyFQI1wMq4NteyqsN75PK6BdEKS6ggLCg5dnsRQG1ef4uaYcrH/jjPzQLA WA4QFYaSGpJcSMGdmTHYF4J+jH2hfJvRy+7plZWg4fIm0sJblX+9DApv/SEG4yZhlA02 pkroH/Q3GFvfDwgBtpK8MQKmuy14Vc/I0AxzJOQ71KizZZHP4KtpVreaGkJuMeulB+fj AB9Q== X-Forwarded-Encrypted: i=1; AJvYcCXJteovD4/ibKbYi59uhbFzpsHEL6YM+VQdfwQRO94o7RMdUBtNI8IAo7b0TIDK0J2z8f+xAII7iVnBavLq0sz8K3ID0hAl8SMaRtBdXRmt X-Gm-Message-State: AOJu0YzWKS1WZGamoMzGmS+HuVZ9xPFFm6jFNCXuioMEpndCAFJY5fNH e/M3iCgTflpHvMcxEYc4LiBLXVnfVzIYFjkMe0gZuRnDtEI6+tGlrWX4MH30jY4= X-Google-Smtp-Source: AGHT+IFq/2aqIFIbaZVtORXZ4ma22Wclt9l+I9epH3oTGlfkp+sVOBf6L7LmmBy3q6/DeC+M+tbDQQ== X-Received: by 2002:a05:6808:3a07:b0:3da:a16e:1764 with SMTP id 5614622812f47-3dc41667c8fmr8781731b6e.4.1723424406285; Sun, 11 Aug 2024 18:00:06 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:05 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 04/17] ACPI: scan: Refactor dependency creation Date: Mon, 12 Aug 2024 06:29:16 +0530 Message-ID: <20240812005929.113499-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180007_566240_C48B1E3A X-CRM114-Status: GOOD ( 15.61 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 Tested-by: Björn Töpel --- drivers/acpi/scan.c | 86 ++++++++++++++++++++++------------------- include/acpi/acpi_bus.h | 1 + 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 52a9dfc8e18c..374cae4aef78 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2013,6 +2013,49 @@ void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val) mutex_unlock(&acpi_scan_lock); } +int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices) +{ + u32 count; + int 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); + if (ACPI_FAILURE(status)) { + acpi_handle_debug(handle, "Error reading _DEP device info\n"); + continue; + } + + skip = acpi_info_matches_ids(info, acpi_ignore_dep_ids); + honor_dep = acpi_info_matches_ids(info, acpi_honor_dep_ids); + kfree(info); + + if (skip) + continue; + + dep = kzalloc(sizeof(*dep), GFP_KERNEL); + if (!dep) + continue; + + count++; + + dep->supplier = dep_devices->handles[i]; + dep->consumer = handle; + dep->honor_dep = honor_dep; + + mutex_lock(&acpi_dep_list_lock); + list_add_tail(&dep->node, &acpi_dep_list); + mutex_unlock(&acpi_dep_list_lock); + } + + acpi_handle_list_free(dep_devices); + return count; +} + static void acpi_scan_init_hotplug(struct acpi_device *adev) { struct acpi_hardware_id *hwid; @@ -2035,8 +2078,7 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) static u32 acpi_scan_check_dep(acpi_handle handle) { struct acpi_handle_list dep_devices; - u32 count; - int i; + u32 count = 0; /* * Check for _HID here to avoid deferring the enumeration of: @@ -2045,48 +2087,14 @@ static u32 acpi_scan_check_dep(acpi_handle handle) * Still, checking for _HID catches more then just these cases ... */ if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID")) - return 0; + return count; if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) { acpi_handle_debug(handle, "Failed to evaluate _DEP.\n"); - return 0; + return count; } - 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); - if (ACPI_FAILURE(status)) { - acpi_handle_debug(handle, "Error reading _DEP device info\n"); - continue; - } - - skip = acpi_info_matches_ids(info, acpi_ignore_dep_ids); - honor_dep = acpi_info_matches_ids(info, acpi_honor_dep_ids); - kfree(info); - - if (skip) - continue; - - dep = kzalloc(sizeof(*dep), GFP_KERNEL); - if (!dep) - continue; - - count++; - - dep->supplier = dep_devices.handles[i]; - dep->consumer = handle; - dep->honor_dep = honor_dep; - - mutex_lock(&acpi_dep_list_lock); - list_add_tail(&dep->node , &acpi_dep_list); - mutex_unlock(&acpi_dep_list_lock); - } - - acpi_handle_list_free(&dep_devices); + 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 8db5bd382915..d6a4dd58e36f 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 Aug 12 00:59:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759958 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 4311EC52D7F for ; Mon, 12 Aug 2024 01:03:02 +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=OxJsyPjPmaZ1bRqTiTHiuxQdsQ8ICxZqoHHRwd27+Dg=; b=JOtHFoihuPMH1M ST2OPXv19V5kv8rF6WP/+qQ5ZVCToBbpqhWNdSxx0C9gBU8kwcSTk+1WSsRs0Eu15qIxsFfabmxCj OonSKp/QQT7YMYRGse5okrThVWFjcUQVPTgvSiaZuAW6pfHFy3wMhaR2tbiX5OKo7skEBDATZvmPT P0+cR+IjqZce9T8l9i0cVuhr5dRd8v9IFKnSUH17ATiE2PGoYSX2bLa1twOXMVs89qZ4vKG9jU7mb Y/NzbC2EoDjsGaoijqcRgOi55NnXh92NHaUQvfW0loPS/GwNHpw4Q+wu7tRzZ3ajYn7222MyxoGwZ MaGzp2Cqu6jgiMFmPU7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJSd-0000000Gb9x-2VvR; Mon, 12 Aug 2024 01:02:59 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJPx-0000000Ga03-3wJU for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:15 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-7c3e0a3c444so627309a12.1 for ; Sun, 11 Aug 2024 18:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424413; x=1724029213; 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=uJwTiJ9RwivJpxYHWXKjwIEWKuv7B7ooXczAECPccKA=; b=l60YLea2Q46D9Dssm/q73F86xG8Vyr83Dt2ficP7+ST5wAiv+E5Z38MELsC1vF4iRJ 2Ih3S1ogmP/VQNcuQwt0yW0OLGeR5CD6gxmxJNSKEqqZfT3ECBYsQDyTrukfFmrFLM57 uDcMg3sjfTEj2E7myoRvZ6wkYrHyg2dr2fsvmrlSRC3dbjZIo8yAN0M0khedaKvFHiTh uBWk5RWRuM4Fxe6RW1+RoTSCihsNKi+cay/2lx4yNC+AhOIrYE4Mswz9+GCyWnC0bw9G tYWYiSJeb5RTNbl373FVh5JudU/yp3cOndDxYZFGXdnUqtyaG4kldSe1V88LM7SH2MO0 Q7CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424413; x=1724029213; 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=uJwTiJ9RwivJpxYHWXKjwIEWKuv7B7ooXczAECPccKA=; b=CKxD3lwDRzLXalNBR+LM9Yp8Sfn02Tu3gJctuOhpj41ZCICewIpbm/rWmO20lZOWyv Fio3NXxMKosEHHJoqatWd0++yQHkeEEYlBsmQUzmh1+11HXvlYBk8F1wBWxM5bya8AeA l/QyGN+PVp/OCvYJa7qpjupBH17mO37eyVhX9CA1nKUBM6y5k1deG/ZIRAZS5kC/B9Td LjfJdYsF/XdS9oolmMlNS0cbD/OMTGWxxtngmc9/tFsrR2cY0dGmRsIVQPvBeMt+t/ET v8VcbC8C/LnCoVuCTL5bqA7QAmurHDlGhR2756bPrM5tMgkPU4xlf5uAbg0aMcUzLYYS q2XQ== X-Forwarded-Encrypted: i=1; AJvYcCV+6KEdqJid6C/B1cpCFvApAEhflzLFTq8xDRLcNSpBiA3gIuU3c7GLZQtb/OeD7WLzHnY516cXx+5r7USsv0bRv0+E33Irjfr2bSb2vKSk X-Gm-Message-State: AOJu0YyM4iTZ3x+PWbWYmRFiBj5SbFIQ2zO1wFc6W/aaUoBd7338o2a8 4DBN1oL5b8CLq2SnO8vDw+ALjKn/8b+YZeB0SGqP0eGf0lsZCNvo7YmAV7WRmQM= X-Google-Smtp-Source: AGHT+IEe5Qz6cd7b/1zBihHx5AlfGtYBeT8sDhSQ+DFn35gv+sWFK8VgaNh+IQbBrU4whiezDiQL7g== X-Received: by 2002:a17:902:e5c2:b0:1fd:8f7b:1e88 with SMTP id d9443c01a7336-2009681bff6mr206131935ad.12.1723424412492; Sun, 11 Aug 2024 18:00:12 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:12 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 05/17] ACPI: scan: Add RISC-V interrupt controllers to honor list Date: Mon, 12 Aug 2024 06:29:17 +0530 Message-ID: <20240812005929.113499-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180014_040317_07656E68 X-CRM114-Status: GOOD ( 10.16 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 dependency from devices using GSI. So, add these devices to the honor list. Signed-off-by: Sunil V L Tested-by: Björn Töpel --- drivers/acpi/scan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 374cae4aef78..39b3ccae9f79 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -861,6 +861,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 Aug 12 00:59:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759959 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 7BD41C52D7C for ; Mon, 12 Aug 2024 01:04:14 +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=xDSdXT+/25tukKINeWiVwbEFy6E/k8M9nvWNTGOKbLk=; b=meVTCQlJGwvWOe mZWuCVGiiZyp7ac57qPSgjix1iYqJxws6gGz/Sq46bH5rAXTN5GXayASQ7eBN8nbVI5mmw/bK3ANI vXU8ZWF5h/Zx0G7EJRf1bN/D5q46879CM4qF3YuhGrZk/fK9JTiLZ/szrC0KIu1d1itewZXCmrLvH wT6OvbumDAipzKCfrwkTyEEkOjiU3lMznDW1lxAqVTQ1TSevV1nolzzmGDrCu/EZJ1i7XqCa3tnlh Ta5Wew6DJhH+HTO+RJS5b1FQN+j3T/YKXbRi+xoR49EOTte21PfTJUE2WsLHBTCM89diQvXm61fi+ fHTQcuixW5iI8hP20PGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJTn-0000000GbZi-1hVU; Mon, 12 Aug 2024 01:04:11 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQ4-0000000Ga1K-06Kv for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:21 +0000 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3db12a2f530so2893741b6e.1 for ; Sun, 11 Aug 2024 18:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424419; x=1724029219; 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=iVnO8D9tH0sab/WeUvbej3ReIYXoTsQSEaRkiw5yKWo=; b=PDGh1BxxbdIhHoHT8s4NUda0rTY8E+SdvytRhN4M1FBwhU/n03jhrjA7JvQ6JwZbb5 FaBhNqGdvYnpvDSA2CemxWuOfRwAv5kP9XDyHe/thasgje4hkPl+zSwvxANhCPrGGi43 pgIAXWg3zNt4nZ3TKzP/lTcCSqChAfsvqtT8OVvrYjqzK+4t6UsHSRqmhs7JxeitIOl0 /Qm5d9oJI7GxyPgpyRgJAvguCdYuaPSKI+MnfsJQfcssbpKh6Iem8jJ2eZBZA0gB0s3T icwO+3nER61Wmy8rh7KQD2OOTXWl0LNhcAJIT9MZv0TDwDe2TIFmbjQEWp1V+jegCddh lTuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424419; x=1724029219; 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=iVnO8D9tH0sab/WeUvbej3ReIYXoTsQSEaRkiw5yKWo=; b=i5r2NG53W7g4C/2EHa82dHPQHyowermHt/84fXxFFfQBCGtWJQPV6V+mpbMgrj0sRl tE8CZgdgF1UQVodgwSqW0MiR8Ussb+Z2IYHbxF5NPXKqEYdGgptmmymHO/wo5YhHiQEt d/biae5xZoSfsUiStxX7GIRp9Lip+zjKGc4pg1t5abjYDmh5ZrMb6gMkdIW6cpd/HXks Ab6sGige/ylXPseQMNMWiQHkfSbJClL4nRfDt3Oqm//LqJB+p6RgHavzoQTEQ0zrhqdi 3KxrRLxfPyPslFotzqbxkhNMYPAov4eH1vvYzHzWHiG9n6L2ZGPrb7upFiAgATdfcjPI eGDA== X-Forwarded-Encrypted: i=1; AJvYcCWFAVwcSwWXtVEb/5JtE1ErdGmvlp8mUT2evlh1kpVBekn1vXOTL77/IyYK4NdXcHreSxXBR0u+p0Ya3Yr8tW6KRRQRtDNUTobCXq0PWA+a X-Gm-Message-State: AOJu0YxHMgkllox0Euow2Gma30BEaRRGFwrwvQtyTMjVBEQNy0TKARsa f1hy14Mu3TewycuMkSOqO4yWwF/+HDEdSwWBMCXSW2gQuHNwM8VqFhBQDaIXeiE= X-Google-Smtp-Source: AGHT+IGgnQrX14dxOj3yn291622Lxvm1iCgbP6yN6u9XpX8bxmUnRZf2Nt8a7HJ6YawHB1+ioO6EHA== X-Received: by 2002:a05:6808:1513:b0:3dc:299d:c4fb with SMTP id 5614622812f47-3dc416ec02cmr12205900b6e.40.1723424418770; Sun, 11 Aug 2024 18:00:18 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:18 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 06/17] ACPI: scan: Define weak function to populate dependencies Date: Mon, 12 Aug 2024 06:29:18 +0530 Message-ID: <20240812005929.113499-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180020_088929_DEFC4AFD X-CRM114-Status: GOOD ( 13.05 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 Tested-by: Björn Töpel --- 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 39b3ccae9f79..28a221f956d7 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2077,11 +2077,22 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) } } +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 d6a4dd58e36f..af72a5d9de99 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 Aug 12 00:59:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759960 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 974A1C3DA4A for ; Mon, 12 Aug 2024 01:04:14 +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=zpIxgjpRG2soh/O10soSMflzFjLJZSQhqvfPER/z+t4=; b=o1nYG1pd2Lucb9 15tXoDP8m0b2/yXeNbHxBWiM3ZkWmT4wQDhQ9HCS1t/A/MmDfUAQAgdxq1cMr4/JYsnRoXzEhv/9l rB7J/6h5dPcsqhiPotAqrOdRv3uBFhBDHOiib1VyVskIZAHP1qb/lgxU2Dzd3OmKfV39Qp52uyPeK pBtc5aBD+6c3vMxpnnWwPVtj4asRa7XVLJMP2+L7P5KNogjQ5AikqepkfXFM/5NLzdm6Hdbji3tno KVlFzyvt9twxRGqlHkJBLQZt20GDinWqTV3itVO25ecChhlmEDQEhIUiON/EhWVykaMwnGkxMDs6N keVtXM0RPOptc65zoVYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJTo-0000000Gba4-0Emk; Mon, 12 Aug 2024 01:04:12 +0000 Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQB-0000000Ga5B-0A6p for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:28 +0000 Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-39c2f653efcso6923445ab.2 for ; Sun, 11 Aug 2024 18:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424426; x=1724029226; 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=pBzMby0USGxgSPaQIBT4AQA8EH7Ak7bVCmTWfoSfRt4=; b=TwR8wvBOYpvP9grUpBtoUmEyc9Ap1r1qzoemFRki5IV+KYuFi212lSap+ch/0QCnWI Nu0PlMQIzgyizQfYOfSXNKVG8Y6rQ2EfX5QTtLHaFw7eQo8GwN0ApxTbeJNnMDXfm12i b3cXmTy5J5Itg3WF+AlQouzT8Iu5SrusFZkU22IjtgyC3walx58y4H4MsBUrPUyejR1b FylmOpIDSVHHhoZUueicIB4oC9KoKGv60HB0ZdvGKA3qnf0WOG1kpUvvU/8xBKdy78NK On0+YasNegq1r1kZPQED7razlnsvVV+oKla5w7ndPORFE2AYkjjlZ16kuPAwRSyoTx4F BNzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424426; x=1724029226; 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=pBzMby0USGxgSPaQIBT4AQA8EH7Ak7bVCmTWfoSfRt4=; b=u8c0O7qGvDaaTv8QhFFibngGAhwq0wHQeg7/0AW5dj2l4fUcxACXYMc4U5NElyXxBk haUr1FrDRNPW1dMXWaWawqLQUpZ9veYcZFawWKE2I/HfdHL+3837bM7dNERtxB2KPf9D Fn/sjrvfUaiJGnZrfdSTpVMRFxH3T6qaoRjSMUltl+zuQRqIALQRSSc0ktd0CzvJ03b7 PyT8Z7skBvuJZwzDoqjuU3uNfSephAnPRilAaG6sIueuIFVOdPtYfQkzWDJLe6g8kFrU WH+POe1tyUnbxytIiVlBa7JvzZfIDOi21QbfD2IC0RQ2gMcR+ebEy2ll2YKSAlZ8L2DT wn5g== X-Forwarded-Encrypted: i=1; AJvYcCUmIqmh0ppPUe7qci8/pR7X32/OJBpZgzGI0U0aN4ssNokZuTPU+nBstq06oxE+73cZ7cVZBGkRjZRiA0+x88uiHAMmFVWwu4YQ2Q1X/WaJ X-Gm-Message-State: AOJu0YwliGXSLib5FpHsBv9/tnppZP9GXo1B1ZWcx2T+3lsrZIAvLN6H ovwHvWU/rTX+8W0qc0/4DXJQV424mUwWOeMNU5KH5X/bylAfy12gylB+O7FF6KU= X-Google-Smtp-Source: AGHT+IGLgGjZy1f4lXkyD9IeGxkMxZC7bl0GKZ86dlIJhEZNBpnAOTW5ak8/coJIxlUXH7m3lfD9qw== X-Received: by 2002:a05:6e02:20c9:b0:39a:ea4c:8c26 with SMTP id e9e14a558f8ab-39b7a475a0amr105191515ab.1.1723424424986; Sun, 11 Aug 2024 18:00:24 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:24 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 07/17] ACPI: bus: Add RINTC IRQ model for RISC-V Date: Mon, 12 Aug 2024 06:29:19 +0530 Message-ID: <20240812005929.113499-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180027_117931_2A09FA84 X-CRM114-Status: GOOD ( 10.16 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 Tested-by: Björn Töpel --- 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 48d277657203..16917dc3ad60 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1203,6 +1203,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 892025d873f0..3a21f1cf126f 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 Aug 12 00:59:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759961 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 ABD22C3DA4A for ; Mon, 12 Aug 2024 01:05:24 +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=aYurf6cClLI2y+xI+8lRN4RQgJTTxcUmX/sBbe5y/u8=; b=yqX6AoyCAm3/bN I672bMCjmN9PQZJrOUP/eDaqcRnK7KvcsjPxGK+a4f95hJJYh7oioZlhTtgcPNZmeOnTJ/HipbWSA TB3KqTBx2u85i78+YQnPZEQYlHZr3ZsO1ntKbtnx8z/l9bvZ6iakhyZ8SvmQqx6r0OxG/TuZDP+ov 7xJ1+49ZbpKOscfnLyQbI75bku5u5KxolzwUipPHOSke9+iDJqHvViae6q7Tp1ZLljz+mQVR5/VHR OmNJtHyUYS9WYcqntlv+ymsqTGbN8TRpCEYJ4DxImjavPp49tk7QBq8zSieWLXkKFSUsm56ertd5h W+n25B1j6VqCjS8jp4Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJUv-0000000Gbqp-3lMS; Mon, 12 Aug 2024 01:05:21 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQG-0000000Ga7H-2Exq for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:37 +0000 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3db51133978so2811220b6e.3 for ; Sun, 11 Aug 2024 18:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424431; x=1724029231; 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=7ZXNFNaxM8vBPLxvkIIPrWaUY6tMJ6nPhDNbuDGhUyQ=; b=XCtVA446Fxre2uFuCk+TmDYP5BZANcp0e9vAUNE+JIzCphmOf1T3ojeTKyB6LzB64a pvDp7p2G9yCABGcE+fp6exsw2WiLR/K4lx/NAvBaKokE6vLOA3R7kabA5efyUeTeqdmL 8zPEbi9Eu9zdjtWsJqT3gg41YqxnZX87qnUXyQsSX5506eeYuwJQXYZesWgBfxigvJhY og5ualS/JhKRIINXlwl73iNO9FrmkqMoq/+D7IUNEJ0P+oQSjGGE4Z7ttYD5h48/Dtat 2MpTdrcPhHncdctJ2ozOzc1KwaFihNDb5Eu7ZI7I1Rb0Oaf4u7bKzya2/H77GcL98WZo TjtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424431; x=1724029231; 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=7ZXNFNaxM8vBPLxvkIIPrWaUY6tMJ6nPhDNbuDGhUyQ=; b=dJQuKgWmgxLJDO43KZZOlA714rO/kbd+6lxpOYWkNMbn+aDphKAxXLJWG6bWLJ56Q+ BHPLJSh3mzFVbCNYVTM6xrYFxwWKhlueNKa1HVOA9om3EhyM+zqj58eV1+7OfiK5JBXv yaRhHDmgB+19G+BvlUNnXj9NVTVDUYno0lonJg2wm0h6Gh5ujHqDuRQ5DSrXvEcrsqxg N6FmD99aZj49OIe0277KdlQAn8tK2TSkPBWHBfe34iwEeBELSLHeWuGdE4ZENs1hyj1A Lw5KlrT5kpd1xjfdoIxHaqxtNeMDz9jy/5CnP9G/ZfroU8VymGO8EynyFCK/yJX/6Q02 /BTQ== X-Forwarded-Encrypted: i=1; AJvYcCUQSXeOREXHIVT8VBjlmimJbCo1gy5GGFm1/soYxgu48kHdYPHVmQtjMrMyw+fh7yNCsAoM/bzffc4W5ywK6oDJSxxhXBhyUbSlaj+khhLr X-Gm-Message-State: AOJu0YyHDAbYGPt2/ozJiodNS0PhH8GIOHyFVSm08guAJErvqTVNUBpD Mb03w+hNkBysaPz/v6K6zNHXISZMcBVnLW4htCcK3ntm+SwJyphaD8CfoDeuhuE= X-Google-Smtp-Source: AGHT+IE9UN/eFl1Fb5sxAtzGTPfmVg74o1vo9nXqbGis0UuD39tez7iI9A3QbSPr+XUfKWTJWNIKOQ== X-Received: by 2002:a05:6808:2f10:b0:3d9:40c2:eb54 with SMTP id 5614622812f47-3dc416688bdmr13217183b6e.5.1723424431425; Sun, 11 Aug 2024 18:00:31 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:30 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 08/17] ACPI: pci_link: Clear the dependencies after probe Date: Mon, 12 Aug 2024 06:29:20 +0530 Message-ID: <20240812005929.113499-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180032_613811_3A21C125 X-CRM114-Status: GOOD ( 12.05 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 between Link device and PCI Host Bridge, then PCI devices may be probed prior to Link devices. If a PCI device is probed before its Link device, we won't be able to find its INTx mapping. So, add the link device's HID to dependency honor list and clear the dependency after probe is done so that the dependent devices are unblocked to probe. Signed-off-by: Sunil V L Tested-by: Björn Töpel --- drivers/acpi/pci_link.c | 2 ++ drivers/acpi/scan.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index aa1038b8aec4..b727db968f33 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -748,6 +748,8 @@ static int acpi_pci_link_add(struct acpi_device *device, if (result) kfree(link); + acpi_dev_clear_dependencies(device); + return result < 0 ? result : 1; } diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 28a221f956d7..753539a1f26b 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -863,6 +863,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 }; From patchwork Mon Aug 12 00:59:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759962 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 7CC43C3DA4A for ; Mon, 12 Aug 2024 01: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=Ig7Nyh0Lix1wFtgFD/mV8Htlgv+BpsAkaEdnH0asbsA=; b=tmMqzA5kjdGUzM LEmhCONYl/Usl2Upwt8mJD6wBmEp2f+ODJobOGkB6NvmELsjeefPaq8DfLNF4LRJJhg/zt2BcoMI8 U2bvTwy8q/GibgPJg48tglf4+RO2flRDlwcpQdjAiaWmt32Bl7LX2h01CFfxvddl0h176/3iZVbgC VbOFyLfoy5t8wr+AUk9447EVjuwzJR0MANZK97F5Xkn1mHn8w8Fw9dWUF8M/jxtKAuTu3SU8trg5m EAOjD2cmr3vwYL/JvMvAXN9GgMPafSc+jIHHGMp2pJ5zO9gxogknbqT1D+5Rd6xdjHf8OyYk/AEVC 53DhdTY3q1u2yR/x6Bpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJV4-0000000GbtR-3WkG; Mon, 12 Aug 2024 01:05:30 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQM-0000000GaAZ-4B7d for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:41 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3db1e4219f8so2164465b6e.3 for ; Sun, 11 Aug 2024 18:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424438; x=1724029238; 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=3yHv4RQ+8m8uuAieiHb/ndAopbPkfvfPnrF/+OTZxeU=; b=ieLdqa8apK66DuwDSNsKIahqT4dyxxHmRFsZddYZnHeEzpASlUGhIz3A/DH9p7ZNXx BiIM/PxSw1xceZeWYEixLrIcgbdQXNCHIHxjMh2rktV9dYTXVlfb0py7hJSiw2bm6xl8 BmSTi6Yb8YyoCux7wUUgWe8B4fP5wsRAim5qD2i/e0PqX2REtLwQZPduHylRPcNbPyfb VE/gDOs57QOZb8ezIJPCYNB9oOFeivytm//jiQ0p0WrnuIISvpUccU/K4UY1n71wrmx9 o7wjUo+v5CEr/KEHXb83GFa5pseXYM7/RwyYDQgFdFimDcH0Xj94IxlVeuUgWqqqlRCf 4l5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424438; x=1724029238; 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=3yHv4RQ+8m8uuAieiHb/ndAopbPkfvfPnrF/+OTZxeU=; b=srR5fQIK86KTW75kqeO1zZD9raCXnPxWyahXxZZgLBgG1OfGTFcYdLaWQel8EnKqXp SWKjA0X/Edw8ueTg607ZS3zOiacHn3mt7Nz5j2ZE+HaDkzCom4ehYGAKaxmZEPx4KrXY 9dw7OzJVsvdcpSrDOgPcI3CrUU/9LT0JtaA9VimIvH48FgoKb+E7gCkUhl7OLk/SKzlp /rHD9C0CR9/3DOFGYXjVYWEtMYQk5THfNM6+uPG3+6K2o6TeQRMopVn7I1CSed8SESkR xI7Q0yOwumQrhPbSBOmNNr+6l2k6cWq+RHqkW0GQZcEUz4ge0/sr1YkyFb+mWEhXW1xI 0ndg== X-Forwarded-Encrypted: i=1; AJvYcCUDc5NFRYPqsY94fbY8SDUsCSALbM/843fAxTDDAO3wUlx/qv8TrAsosGVW1AxyrU1dQYeEaZIJWrUNUg==@lists.infradead.org X-Gm-Message-State: AOJu0YzaBrwCS4CO1An3dhpVEmRkft17AhtIKog6UCQZXWdS5zcPnQ9O I4hCtuwp+D7EAS8bTKLUSAFzoVIXGxFmL3a1GMJmV6mGZh09dXrfTOS4nbEU6ak= X-Google-Smtp-Source: AGHT+IFun0gorfvtl1RVjdN/jm32amrHRkag2ROgDMVcRhqDHKcAfRdwMw49PRBtm4+7+S1MCEJ11g== X-Received: by 2002:a05:6808:16a0:b0:3db:fe8:f74c with SMTP id 5614622812f47-3dc41689574mr7836368b6e.24.1723424437728; Sun, 11 Aug 2024 18:00:37 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:37 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 09/17] ACPI: RISC-V: Implement PCI related functionality Date: Mon, 12 Aug 2024 06:29:21 +0530 Message-ID: <20240812005929.113499-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180039_079493_DAC69985 X-CRM114-Status: GOOD ( 13.88 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 Tested-by: Björn Töpel --- arch/riscv/Kconfig | 2 ++ arch/riscv/kernel/acpi.c | 33 +++++++++++++++------------------ drivers/pci/pci-acpi.c | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 0f3cd7c3a436..a269e577284e 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_PPTT if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ACPI_SPCR_TABLE if ACPI @@ -188,6 +189,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 ba957aaca5cb..6e0d333f57e5 100644 --- a/arch/riscv/kernel/acpi.c +++ b/arch/riscv/kernel/acpi.c @@ -311,29 +311,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); + + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->read(b, devfn, reg, len, val); } -int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, - int reg, int len, u32 val) +int raw_pci_write(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); + + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->write(b, devfn, reg, len, val); } -int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) -{ - return -1; -} - -struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) -{ - return NULL; -} #endif /* CONFIG_PCI */ diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 8ed81a373bd7..af370628e583 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1543,7 +1543,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 Aug 12 00:59:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759963 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 7A509C52D7C for ; Mon, 12 Aug 2024 01: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=NyT6cN8D5liKpPSjxuT+WNfJdW5iQPmfWVPhMOf6F2U=; b=07CQPKfevBkSpr bfzCyWO41QoGvpFTrBisNqQD6Z6FQufMPZ4EFLKbiVyOUI3RsbluxeUdiYkYljTXk2XWB8qb5DE6u fG2bMiAoZYoFjs02jcGJWFKImtuBwMNpLtOtwHnLB5NviDlGIFd4eJ9pomkqwmNGCMz8lJmK/qMn+ QD63dWVaTGez4YLsDnF4bCMLjNX8Jdy6m4z7ia6iAaiEsXHaPjqFQ5nJUBzxbqbeuQtRnB7x51o5/ BHLN6WTlua7387E1HPuUMgkD/PjzREZSE4mu+Y/JJe3OKr7PCE21QXVw6dQqydGmvVOLpc7y8NAHg 5AOuBaa4SiQGbgB8HH3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJVm-0000000Gc2f-37lB; Mon, 12 Aug 2024 01:06:14 +0000 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQT-0000000GaDB-3Icl for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:47 +0000 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-5d5bb03fe42so1988340eaf.3 for ; Sun, 11 Aug 2024 18:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424444; x=1724029244; 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=xbG/jHg21LcLoDzwk6IzVsucBn3jZiDtmvIm1r3v9tk=; b=jrEfLovZJ6qM50knRFvZMu9GISbyg/53AZNIrTy07Lf03A1kvDs0/3qMYbQcjW6HzF Gax+uhqdMzdP/6+4LB32hwB13vILKmoWmQcRbcI7RWig5Y1WM2coPOLODt1CCuA8KF8H wBO0qRuOLCicDJvQnlilvjRqu7eBtxnw9H2+f2cDezTz37vl1ioPwo7US9K/gPFzHiSw G1afJd98zNWsb2cjOH39JIRIPuYm2uhtOmS7MIuB/zEUefTxYe+fpe563E5zNzDt6nHw wc/V4xilaz//jvVIzyxDpVlBqtXJH6amltuxdz5DbFaRzzmOYlD7+EW4EUr5gInQcrbb dqdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424444; x=1724029244; 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=xbG/jHg21LcLoDzwk6IzVsucBn3jZiDtmvIm1r3v9tk=; b=vcagfr7PLyyhmo1lgsgAsYKhCsCyK/gFN3jtV9n4MhXfjUEyNrqkygjvHwQaJMJu67 bBFsW1iLeAEBsudCOCeWF/JgT9GW5jgKSmjxGWm1bK4EYVvZxN8s6NZGDymlBkT3LlO8 5Qe3i5op/DTY72aY0Z7O37CeF7QsR0U06KEvsb6vbGVE+OqcO4FVz+cVKRxPxiGL+9PL 0dXaWaJ0ssOa6jrMuXdOZpB/aHuzkMS/rmQTjm16w2rV3WWiFq9iYp/NPMQXF78ZahUJ /uxnDqgpLcC7iag5vYO0+2hnhlFSFemWuBV1PzA5Mc5d3t3Lgtmsj9GqKWLkW4C36Zkl u0sQ== X-Forwarded-Encrypted: i=1; AJvYcCUDtoia3N4FCiIF3XkItE+aAX42j/3uGGvTMdZrhoFXqxZGOhVNi6DCJczqbi+qldXGjDLfKBvfq4TuVt1dum0UgzKU7xvrYmB6Fo2EGv8S X-Gm-Message-State: AOJu0YwZl+rjVgT+1/MtNn3HxqVB7sKRbGOX6SOXJJql1QCRmNxsvsit t3BeIBJ54weChXVnOz8ayfv6svboRq3IoUs25gcM5qIzQiT0W4UlsJFUFeI86GA= X-Google-Smtp-Source: AGHT+IGtpWS7DBc6qnLRa7J1XKsHLrlfePxKw3cHvC5D7SmpvnVph24/oUKeRjRFTeAU1sM99c7TNA== X-Received: by 2002:a05:6870:1585:b0:260:e7f9:f4e9 with SMTP id 586e51a60fabf-26c62f21db8mr8563110fac.35.1723424444123; Sun, 11 Aug 2024 18:00:44 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:43 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 10/17] ACPI: RISC-V: Implement function to reorder irqchip probe entries Date: Mon, 12 Aug 2024 06:29:22 +0530 Message-ID: <20240812005929.113499-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180045_849104_AEFB48C4 X-CRM114-Status: GOOD ( 16.17 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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, the RINTC structures should be probed before any other interrupt controller structures and IMSIC before APLIC. This order is established by using MADT sub table types which are ordered in the incremental order from the RINTC. So, add the architecture function for RISC-V to reorder the interrupt controller probing as per the hierarchy like below. ACPI_MADT_TYPE_RINTC = 24, ACPI_MADT_TYPE_IMSIC = 25, ACPI_MADT_TYPE_APLIC = 26, ACPI_MADT_TYPE_PLIC = 27 This means processing all RINTC structures (in the order of appearance in MADT), followed by IMSIC strucutre and then all APLIC/PLIC structures. Signed-off-by: Sunil V L Tested-by: Björn Töpel --- drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/irq.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/irq.c diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 877de00d1b50..a96fdf1e2cb8 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 init.o +obj-y += rhct.o init.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..835eb6eccd53 --- /dev/null +++ b/drivers/acpi/riscv/irq.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023-2024, 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); +} + +/* + * On RISC-V, RINTC structures in MADT should be probed before any other + * interrupt controller structures and IMSIC before APLIC. The interrupt + * controller subtypes in MADT of ACPI spec for RISC-V are defined in + * the incremental order like RINTC(24)->IMSIC(25)->APLIC(26)->PLIC(27). + * Hence, simply sorting the subtypes in incremental order will + * establish the required order. + */ +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 Aug 12 00:59:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759986 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 9C745C531DD for ; Mon, 12 Aug 2024 02:15:28 +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=cUhVOEJW+gviIq2J16umecpM/a2nlaMQy11KSaZ52JY=; b=ijBSx0zcbqjebi gYhHz1KtopXfT5bAqHpwwkLZLumyrBJrxwxGTDYPlGeghFt9tAAngP9wOzf6HyA+xTwS7OlVJGp5M fKtFqiKTMDEkAdDxZPTVdZbpyvkowUlQ0UyjD4LP8YgzxCEn/cgNAxEOJhTpXJ3SL85rZlJVNtGeD nsKhPe7Lg2+6UZ/3oagXxjGUe4AFWWzGDWScqLszMd+MLSL5N/8zQMm3bUrcuE7E7kL6yZBmiitiq MF6elTq0oXR5gI3XFYZWlMDVRw7LcjKs0PPHXyhOoBFIFEu/tYEP6l8FiHFU3as8tZdmKLQEAleQt QU1hFO2DlIxk2Mveoavg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdKae-0000000GgGT-3ApB; Mon, 12 Aug 2024 02:15:20 +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 1sdJQZ-0000000GaFo-37eF for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:54 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-70d2b921c48so2799177b3a.1 for ; Sun, 11 Aug 2024 18:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424450; x=1724029250; 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=zGfeskz8g19r+OqajKxPNYjNNE+F0wltIvoajFyWVok=; b=NtpN9wxCAFZWhc/0DKq5mhoIKXwKUU7cc2PMKwAsV8g18LSKK9uZaziXKoLKLAUq5w xF7QDpNFh8pa5khaW+lbcqjs6cfV3yQKzRiI1bghxZh+DjFEeaSg+zxk8FnVpSGCRiRI ACOeh85EjOlcMBb9omVamI7yV/61oexXeKGPJ0x90zjuppNSxv86CnnJmZ47qSYSRGWE 5ySR7izxIrfT6FeKGsOqq6BD5GJB4JVF4M4b8kgUXRy0qtu3pxJZ+nltNtU7KBr01sDZ uUANGKr0Oe5jN60oFegiF9z/FPgMEquxx+aa6d2sFPsYOQyKvFjpEAOq7l9VWGgML552 Fxqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424450; x=1724029250; 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=zGfeskz8g19r+OqajKxPNYjNNE+F0wltIvoajFyWVok=; b=KgPp81VvQ83snPeb15WlC6Q2YjKTtBp8rOmfzVR6AdV7xS7W1/Paevtlykgswn7b9G jLcyUONwZj8ebUJYiu7WNwlM/SopE351+F8bqzSLaL5k7uDKNQFQG3vukWtFT13o+WH6 AMqHTGr0BTeZJSblNpLLRJQZ4bNYnLdfKZ4vZlDoYnV9UEbYzU4suDDi+1QRHfKuCp20 WoT3NRCuHqzl3j1d2OyNQuMbmIjsv6i6q8TvOL/fy4qA1HId+SeLn8BX3kU/BbKBo32V nzsokJfzHvigD4U2AD0x1kpwIHeJHIUOb45noQO1mq1PX1tsQAWNACxsR8deG2XVfSEb bhFw== X-Forwarded-Encrypted: i=1; AJvYcCWRLp7Cq+uOLYGdJIOwJtdq8oD49A8r2VXCZ4/8Ez2lO1OQ1KOWXI4JavKJLJ+HxeHhTGMNGYbe8nF9XSrdCsJm7h9EWajvRKuJXJYAYZcx X-Gm-Message-State: AOJu0YwOk3E47xcOht7C0r/6mwSibHw/i/1LSKp7MMep16Cb26Y7G4RX deNFEvPoYhebCzKqXT32ClVZCP0CL+hApxzfAS1HzNwVIdsF6pJFEjwbezF6teo= X-Google-Smtp-Source: AGHT+IE3q8lKgHgWLAwxE/0Wiss9V/UMieO99InX6OgVwr4G4I59tEn3alleuzimlu24LFWs915ICg== X-Received: by 2002:a05:6a00:2da1:b0:710:7efe:a870 with SMTP id d2e1a72fcca58-710dcaeb509mr5600452b3a.19.1723424450430; Sun, 11 Aug 2024 18:00:50 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:49 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 11/17] ACPI: RISC-V: Initialize GSI mapping structures Date: Mon, 12 Aug 2024 06:29:23 +0530 Message-ID: <20240812005929.113499-12-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180051_941959_5E10F073 X-CRM114-Status: GOOD ( 20.09 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 will be used later to add dependencies. Signed-off-by: Sunil V L Tested-by: Björn Töpel --- arch/riscv/include/asm/irq.h | 22 ++++++ drivers/acpi/riscv/init.c | 2 + drivers/acpi/riscv/init.h | 4 + drivers/acpi/riscv/irq.c | 147 +++++++++++++++++++++++++++++++++++ 4 files changed, 175 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 a875a76aa44c..5ef97905a727 100644 --- a/drivers/acpi/riscv/init.c +++ b/drivers/acpi/riscv/init.c @@ -5,7 +5,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..0b9a07e4031f --- /dev/null +++ b/drivers/acpi/riscv/init.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include + +void __init riscv_acpi_init_gsi_mapping(void); diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 835eb6eccd53..9028787c73a7 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -6,6 +6,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) { @@ -31,3 +46,135 @@ void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) return; sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); } + +static acpi_status 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 AE_OK; + } + } + + return AE_NOT_FOUND; +} + +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; + + list_for_each(i, &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; + + list_for_each(i, &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 -ENOMEM; + + 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")) { + acpi_handle_err(handle, "_GSB method not found\n"); + return AE_ERROR; + } + + status = acpi_evaluate_integer(handle, "_GSB", NULL, &gbase); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to evaluate _GSB method\n"); + return status; + } + + status = riscv_acpi_update_gsi_handle((u32)gbase, handle); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to find the GSI mapping entry\n"); + return status; + } + + 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; + + return riscv_acpi_register_ext_intc(aplic->gsi_base, aplic->num_sources, aplic->num_idcs, + aplic->id, ACPI_RISCV_IRQCHIP_APLIC); +} + +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; + + return riscv_acpi_register_ext_intc(plic->gsi_base, plic->num_irqs, 0, + plic->id, ACPI_RISCV_IRQCHIP_PLIC); +} + +void __init riscv_acpi_init_gsi_mapping(void) +{ + /* There can be either PLIC or APLIC */ + if (acpi_table_parse_madt(ACPI_MADT_TYPE_PLIC, riscv_acpi_plic_parse_madt, 0) > 0) { + acpi_get_devices("RSCV0001", riscv_acpi_create_gsi_map, NULL, NULL); + return; + } + + if (acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, riscv_acpi_aplic_parse_madt, 0) > 0) + acpi_get_devices("RSCV0002", riscv_acpi_create_gsi_map, NULL, NULL); +} From patchwork Mon Aug 12 00:59:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759984 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 56DBFC52D7F for ; Mon, 12 Aug 2024 02:15:28 +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=su8lmhaJR7UOWWoVNAMSA5Ij1L6oDwjlZDA+iuKQLFY=; b=cgL3YmWCprs/iZ DSa4XqY2+dKxwTMV+r2VqviwdnrwZGkEgbsPIDtfiJTaB0mUQOakWD9yOYsxzsckBnSSpAn6txBKg QnvuAia8LpCtA9L+gZHyiY7MlBMQyXyQ1gBqTiaVm5Gq63npiFSTAvLx6FwNdQ7nsyxoi2paHmodl sEppgDbFXRzHcD1nn2bb+x9SJzWO2Z94FMqMhw/pS2NSrdIowBLbVb/DHNBUQTTqLibk/J1x//72/ VoJgnOitIUA95dAqnFkgGM+csUyEWsUldYabo6lOmrJMzNdtgVpZKBW3CNw7sKn729bbEM+Rl4/Lu 9Gja1wNdeAmRB9/18Wdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdKaf-0000000GgGv-1ivx; Mon, 12 Aug 2024 02:15:21 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQf-0000000GaIc-34WN for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:00:59 +0000 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3db16129143so2266150b6e.0 for ; Sun, 11 Aug 2024 18:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424457; x=1724029257; 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=qMNBqe/9cTzO1EXtoBS3N5wT2H0f1rIMH9omusI+3YU=; b=F8Lw9wGCxSlzgo+IprRmdoBia7grXFCPFL98IQGgKoDHx9XH08LfqWVz0M7+lKikt6 OWGV/5eoD4ymmkSInxiStk3HCIWWZyKMG3i5acHiGa8KhiVrTwUhhsyxKpapN87g5EMH cMTCGmOcILNaX22q1a6ueea+Ia//7zrjHI2pUiRB8iZPZFP13/ID0T1Z9BgzpNYe3lIU vUJ8xhRa2hzttFh5VjSwzEYvhXRpXEM0nb8B6reVR8DhnEYczJDDzGqQJaL61YHEArTV q21xI6Ild2w/LEfKZAE1HjfUrhniiIWGv9AlCZ0L4Bm0kBg1P3z8WcImlGAFvip5An5x KdlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424457; x=1724029257; 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=qMNBqe/9cTzO1EXtoBS3N5wT2H0f1rIMH9omusI+3YU=; b=QcRFLhcbuV4BcfNLx7+82g+qVhyakVdS3ea5AbQcVVCh0qnFaW+/+YwITdiCdEgEYO onodw5oLd3/ZFOfVIx2YtnA6aBk2JW/ZFTiLwBmeMPLu0HlRex0kLqQonVcdN2u2dBr4 7lHGQdOVIEUY5M0KJQ8ciBzws8hlu2Y2Tc/ybqoC+Xh8cvTHTmYXfsxN+4hzw5vP7pC4 209v5hYyjvembWZ16hcExYqnYH3ZTwAt2ga7qW8PV7GHnEHoH5b4Kwxpc06DJ+Yz+Tk+ +29AICMAqFvePWEDuC6GH6QWeOrXr3jntLL1T4667lMasf+wx+wJeC3mnZ4EKLrTAw6B zbyg== X-Forwarded-Encrypted: i=1; AJvYcCUiStl17tQpwbNW3LzIwk6CzWIXCIdP+mRRrOklhuZUOQrqojeNAxIp7cqHV4grHbgu8vf+Q4zoAKdjFhSPMa5Lnm1zHyOYdEABFcTz/snH X-Gm-Message-State: AOJu0YyF7xnS/cdM0o8xtnKQlY8ftX1zwKxTDMTciXnKl2yEzO51q6Bz ETDSNJiQuvD6XNPvryV+D3Aa5bVuu48UzxljCV28GVo+3LdCN/THsosQNINczC4= X-Google-Smtp-Source: AGHT+IHH0tD3H2b4nYjMLU3yefWBfcIBabXBtrcMk+XbHZMJ1kwyx0P2UJ9m1CeDn96dZhdAvQwZUw== X-Received: by 2002:a05:6870:d8cc:b0:258:5143:a21a with SMTP id 586e51a60fabf-26c62c69d1cmr9739322fac.13.1723424456739; Sun, 11 Aug 2024 18:00:56 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:56 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 12/17] ACPI: RISC-V: Implement function to add implicit dependencies Date: Mon, 12 Aug 2024 06:29:24 +0530 Message-ID: <20240812005929.113499-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180057_799712_76D70395 X-CRM114-Status: GOOD ( 19.91 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 Tested-by: Björn Töpel --- drivers/acpi/riscv/irq.c | 155 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 9028787c73a7..cced960c2aef 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -20,6 +20,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) @@ -178,3 +184,152 @@ void __init riscv_acpi_init_gsi_mapping(void) if (acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, riscv_acpi_aplic_parse_madt, 0) > 0) acpi_get_devices("RSCV0002", riscv_acpi_create_gsi_map, NULL, NULL); } + +static acpi_handle riscv_acpi_get_gsi_handle(u32 gsi) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i; + + list_for_each(i, &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; +} + +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; + } + + /* Support GSIs only */ + 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 = {-EINVAL, index, NULL}; + + if (!gsi_handle) + return 0; + + 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)) { + acpi_handle_err(handle, "failed to get IRQ routing table\n"); + 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) { + acpi_handle_err(handle, "failed to allocate memory\n"); + 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) { + acpi_handle_err(handle, "failed to allocate memory\n"); + 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) { + acpi_handle_err(handle, "failed to allocate memory\n"); + 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 Aug 12 00:59:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759969 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 26A8DC52D7C for ; Mon, 12 Aug 2024 01:08:01 +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=c0C8D2OLrDSzDckLW4PIeWcJeOj9lg58DtutcVE4a/g=; b=bd7XKSCSUjO9ZX rBZn/v8bz1s/xdtfn4NAc+0Klji1yqsS/fE4657qD/ZCd5tP5p3+K9EzIDIuthD5WKQO1ttRWuCZf twHIqDFdY5g+3ZYoG0Cycbj3yfHr1GJ6IqMj/atLSQt2EI6JXe9zbei+b6C6fDR6IppRn6T9H6yku /B7tzxQgLlptnYHS+AS5pRHamQ8asrD53PFSKzraKJ12gaD/hSs5HvfrVWIFmX0Ss1ENoTkW975WI uMD6RSI4MrfLfSPtW3RCHthFcrw64f//60VOT58ilp8gnb5+w1wtPOcPylIXT1iTS59WjT1GGFaGn CFGiUzU6kBRFwAtrCJYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJXR-0000000GcJT-2A5b; Mon, 12 Aug 2024 01:07:57 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQm-0000000GaKI-2u2B for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:01:07 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2cb53da06a9so2516438a91.0 for ; Sun, 11 Aug 2024 18:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424463; x=1724029263; 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=9eWLrHir182byqrnausz4PNiecB0MULYeCzMr04SHA0=; b=YmWxHy7kEJv928n+Af1ihDrX7ikGUSR9YfcO8c3G2vbpTGUrnW6GIaWOHyRkbDbwjx ocdiOxSStB+ghVy3wr/tzPvRRx0HwX6l0EicVlDy3miBhTSGEksT2D7IEH+aSxMHX6kW iTJAet3KnlwckQ1Hv6Jz491DsewNPSi+WK3Wh7Sj2SyWYwZmU3SVet9N4WKHR72Z+kL2 p51pRKsl8UTQ2HtXtyIJjUckmnitXBsciPHT76G/gANbp9wQtYSziz2ZUMpXIJNrmgBf xPhLOrJmI5pYSQEFmjV3oo2apOGYLV9XvBzG7DT4smbgqDRnPETeFKanq+PpedllujYB yINQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424463; x=1724029263; 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=9eWLrHir182byqrnausz4PNiecB0MULYeCzMr04SHA0=; b=ArzlBWpUI0izJETS83UB8eh8nd1PXfT7MmV+kyyMGSfWFm9m3VBvQ55IvU5ki4l3HQ 2cfxLBAsOfaAHdKPz3ijl1bv3QEjBAoALYyzQ6hPeX2fXyAJB99gLkJcyhsqpW4PrxgN gqgkpaVFkRF669WK4bQbw9BgkcnZ9OY9IMjM8S4WT19geQd895coBgy1iOVKsVw979G8 3uB3Hpl4McfJ/MZQBn2v5kjKjNGTbyqw8kKDLM60ppJ3pYlCjefm2W+mS99TZT4Uxg0Y AtoovuDsr0YzmSNaV8pZrGp8NjabvgKuWiW1bCrp+QQBa3oErjbiix23LicwqAA8HUA4 N8Dg== X-Forwarded-Encrypted: i=1; AJvYcCXY2NpMEfg2K/WziOVSTbrJD8ffVFp3ZuU72mpqA+C55t/7zJG6dceei3wpYSXK1FgZ+ksEtcMvWo/przoNmPrjFbJifOv5nQMQ123ujZxz X-Gm-Message-State: AOJu0YzFpFaSohevceXSzWVSjVPdjse3QAH9p9YkMlOjSIGxYB7rmSMm hJOVy+eBrTn7pxaeVtxf42o8eCeZSUrDEdBVZURU9WCnVuarq2uKOHoYhOssAKQ= X-Google-Smtp-Source: AGHT+IEmnnZO8yRXJ6ENu6bAM1Iq53DDo8oXCMY/2aarMSTJFhyCJE6z0a/eBIRQSdiXXTmWXrm9Iw== X-Received: by 2002:a17:90b:1887:b0:2cf:dd3c:9b0d with SMTP id 98e67ed59e1d1-2d1c4b674cdmr19256482a91.2.1723424463037; Sun, 11 Aug 2024 18:01:03 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:02 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 13/17] irqchip/riscv-intc: Add ACPI support for AIA Date: Mon, 12 Aug 2024 06:29:25 +0530 Message-ID: <20240812005929.113499-14-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180104_805628_B2581A81 X-CRM114-Status: GOOD ( 15.56 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 Reviewed-by: Anup Patel Tested-by: Björn Töpel --- arch/riscv/include/asm/irq.h | 33 ++++++++++++ drivers/irqchip/irq-riscv-intc.c | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 44a0b128c602..7e9a84a005ed 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -12,6 +12,8 @@ #include +#define INVALID_CONTEXT UINT_MAX + void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void)); struct fwnode_handle *riscv_get_intc_hwnode(void); @@ -28,6 +30,11 @@ enum riscv_irqchip_type { 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); +unsigned long acpi_rintc_index_to_hartid(u32 index); +unsigned long acpi_rintc_ext_parent_to_hartid(unsigned int plic_id, unsigned int ctxt_idx); +unsigned int acpi_rintc_get_plic_nr_contexts(unsigned int plic_id); +unsigned int acpi_rintc_get_plic_context(unsigned int plic_id, unsigned int ctxt_idx); +int __init acpi_rintc_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 +43,32 @@ static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi return 0; } +static inline unsigned long acpi_rintc_index_to_hartid(u32 index) +{ + return INVALID_HARTID; +} + +static inline unsigned long acpi_rintc_ext_parent_to_hartid(unsigned int plic_id, + unsigned int ctxt_idx) +{ + return INVALID_HARTID; +} + +static inline unsigned int acpi_rintc_get_plic_nr_contexts(unsigned int plic_id) +{ + return INVALID_CONTEXT; +} + +static inline unsigned int acpi_rintc_get_plic_context(unsigned int plic_id, unsigned int ctxt_idx) +{ + return INVALID_CONTEXT; +} + +static inline int __init acpi_rintc_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 47f3200476da..8c5411386220 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -250,6 +250,85 @@ IRQCHIP_DECLARE(andes, "andestech,cpu-intc", riscv_intc_init); #ifdef CONFIG_ACPI +struct rintc_data { + union { + u32 ext_intc_id; + struct { + u32 context_id : 16, + reserved : 8, + aplic_plic_id : 8; + }; + }; + unsigned long hart_id; + u64 imsic_addr; + u32 imsic_size; +}; + +static u32 nr_rintc; +static struct rintc_data *rintc_acpi_data[NR_CPUS]; + +#define for_each_matching_plic(_plic_id) \ + unsigned int _plic; \ + \ + for (_plic = 0; _plic < nr_rintc; _plic++) \ + if (rintc_acpi_data[_plic]->aplic_plic_id != _plic_id) \ + continue; \ + else + +unsigned int acpi_rintc_get_plic_nr_contexts(unsigned int plic_id) +{ + unsigned int nctx = 0; + + for_each_matching_plic(plic_id) + nctx++; + + return nctx; +} + +static struct rintc_data *get_plic_context(unsigned int plic_id, unsigned int ctxt_idx) +{ + unsigned int ctxt = 0; + + for_each_matching_plic(plic_id) { + if (ctxt == ctxt_idx) + return rintc_acpi_data[_plic]; + + ctxt++; + } + + return NULL; +} + +unsigned long acpi_rintc_ext_parent_to_hartid(unsigned int plic_id, unsigned int ctxt_idx) +{ + struct rintc_data *data = get_plic_context(plic_id, ctxt_idx); + + return data ? data->hart_id : INVALID_HARTID; +} + +unsigned int acpi_rintc_get_plic_context(unsigned int plic_id, unsigned int ctxt_idx) +{ + struct rintc_data *data = get_plic_context(plic_id, ctxt_idx); + + return data ? data->context_id : INVALID_CONTEXT; +} + +unsigned long acpi_rintc_index_to_hartid(u32 index) +{ + return index >= nr_rintc ? INVALID_HARTID : rintc_acpi_data[index]->hart_id; +} + +int acpi_rintc_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) { @@ -258,6 +337,15 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, 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) @@ -277,6 +365,8 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, rc = riscv_intc_init_common(fn, &riscv_intc_chip); if (rc) irq_domain_free_fwnode(fn); + else + acpi_set_irq_model(ACPI_IRQ_MODEL_RINTC, riscv_acpi_get_gsi_domain_id); return rc; } From patchwork Mon Aug 12 00:59:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759987 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 9983DC3DA4A for ; Mon, 12 Aug 2024 02:15:28 +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=gBGB1DRG/dp22lTr4ws9z0j0TbLHaAy0XoDZ6M5qBro=; b=jPCVvTNgq4O2ST o9OlKZIlk8Y42SHRRAQEl3asLENOJ0SK+dEchyhR7tnTvqZXlXLp3ek3JMuqhZURxZWEDpf4kalVU +/34+Wu6iGAf3ZVqsOy02NGij7B+5ZHOzkBPnXvHzCbTKbdr87VgMz00B4WBYlMk97DJW6xGCFWl4 4vVDOdP9gVi+KMeV4fy5R76RKSNb5xgVBZZEgpOXLw0jcPtBg8zbuMOg9BC3FQBbV9BZjVeSf54LD YGIcJf58bUccYk9TmS/TwMCDbNnn5Me96ekdt1CmQQ863qLzh6d8TTuab3KMr2YyZF6bg9fA1nF0L mm4waK20J5MH1q9JJ3iQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdKag-0000000GgHZ-31KA; Mon, 12 Aug 2024 02:15:22 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQs-0000000GaOS-0mxs for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:01:11 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3db14cc9066so2722759b6e.3 for ; Sun, 11 Aug 2024 18:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424469; x=1724029269; 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=L2F9HlOmYYBgfOGZ5Y5XAW+7ZHo7CSZJxIOIoseG4Ek=; b=JvDkiDM4LY4Let/Z10ykhhb9O+65gm3jDzWIAI4mB82Ca8kUhEINAF5HT/k8l+M6tQ ZFn6NcsShDOMWfUpvsE85y+kxvConqzQsoRUEMpK6qo0N6jUsbYZYfpRq47mHBuPmWBJ xK94BZSpS8zJC2wVV3lH0oUfG1Od3sM+wT3QhSuMJgwXdjkEk4Ew8MJJfXMFUeZD2/oY fuN0w0LgbD5qrfSiypJ79BqjM6qrW8BZ7HZ/dOaqIRRiR4CnkkqwY1rgQh7k0AUIfJlS 79j0ZEUJmYMn67H7ZSPdDi4ngnBFoRJU6YMU7tf4okKJa2DdbTACmcRyMx8VthNFUvoy Z+ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424469; x=1724029269; 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=L2F9HlOmYYBgfOGZ5Y5XAW+7ZHo7CSZJxIOIoseG4Ek=; b=Rv5KiQA9D5fu6CnFu9NZiwAdhtcX77WN/ezzf5k4XcYErTIMeja4eAJZCAFL0Aod/M tDj1tclR6uFkARLl+uiEno0rN4DdzrFJoVA+gkSw7jzPY2vODQf421tj7GRTlFv3XBqN afcH6Km/wgrHWeLH8PXrts6NDgTJJ1oK3fjnYma4f1Ak9RXOioRi/g3v2aRIJO4kU19f JsvRdjVIykxKskcYbZX+3kEltpwdr4MsOWh3FfIf2CqZVcBM4ciGFMl/VDBLtSXujeBX UfR4iVCu1eDnkHp9v+H9YmAxPMr6dOkybhZoGyLBlb14SVBSX9xp0v8S8ScLAJEyqGhf UqXQ== X-Forwarded-Encrypted: i=1; AJvYcCXGtjz53cMsZmVMHNq21BAthmYF6hNu6KLtXxk1psdpYbf6PWhGpe0jK6B0yUe/JmrTq0Czoq2QGRkDy/g3dTPMbVY1EHlgELs6iOxi1g6s X-Gm-Message-State: AOJu0Yyrco8mL1s0MncJ02bpOvGfzBb4jua1hUs6K14JSjSHRpbjTW2d 7DQsX89egd1Iqa5crU3ty1uXlA8FWMVQHtisngbEs/hcXKv43tdawFgqmW+z7W0= X-Google-Smtp-Source: AGHT+IHZXV1nZ3pGHtKOzIjfGzSIJM5PQQnjoEr5t/Q7EAetVkMKeElEktJkKAiBNFFJkWIu7MYWBg== X-Received: by 2002:a05:6808:bcc:b0:3d9:35df:8f2 with SMTP id 5614622812f47-3dc4169de4bmr11444935b6e.28.1723424469384; Sun, 11 Aug 2024 18:01:09 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:08 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 14/17] irqchip/riscv-imsic-state: Create separate function for DT Date: Mon, 12 Aug 2024 06:29:26 +0530 Message-ID: <20240812005929.113499-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180110_259427_3986A1E0 X-CRM114-Status: GOOD ( 15.51 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andrew Jones , Will Deacon , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org While populating IMSIC global structure, many fields are initialized using DT properties. Make the code which uses DT properties as separate function so that it is easier to add ACPI support later. No functionality added/changed. Suggested-by: Thomas Gleixner Signed-off-by: Sunil V L Reviewed-by: Anup Patel Tested-by: Björn Töpel --- drivers/irqchip/irq-riscv-imsic-state.c | 97 ++++++++++++++----------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 5479f872e62b..f9e70832863a 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -510,6 +510,60 @@ static int __init imsic_matrix_init(void) return 0; } +static int __init imsic_populate_global_dt(struct fwnode_handle *fwnode, + struct imsic_global_config *global, + u32 *nr_parent_irqs) +{ + int rc; + + /* 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 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 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; + + return 0; +} + static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, u32 index, unsigned long *hartid) { @@ -578,50 +632,9 @@ 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); + rc = imsic_populate_global_dt(fwnode, global, nr_parent_irqs); 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 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 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; /* Sanity check guest index bits */ i = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT; From patchwork Mon Aug 12 00:59:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759985 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 A219EC531DE for ; Mon, 12 Aug 2024 02:15:28 +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=HaUqahjBGc9aPem3lzhn52WW5U79xuzt59HPsRz+qmY=; b=jNlz9H9QH/sdol l0t5lVD3oWWPsK4petn0Hv0Ocqu2iOHNhLivqovOobbPnGviNGv9ptLD+CXTOKfU6bJbkcFfqCxHr K41e9dPbW8qIBWSKo96ogv9cJeEqVdWqeuoSyMoTcMVA/g7cE0ti0XhCrVjtgqisZGJDTVemz68jY zSJ2Q0SvF5w951m2kKbdZ7qJogXAWYeHcYSHDVOws1DyqWN/4xvjd+tX+N0/sv+6h+xPE5sJCJ+ra TJncIwdgBLy8l7WLsA6EN/Ya+9aEPWyBItyMzoXxfdh2/uOKmAgfmx3QmAooTnD+khDXAMFxrNzm9 XpPtf3x5eXj2Bqjad8Vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdKah-0000000GgI6-2LoB; Mon, 12 Aug 2024 02:15:23 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJQy-0000000GaRy-1tci for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:01:18 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3db157cb959so2760641b6e.0 for ; Sun, 11 Aug 2024 18:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424476; x=1724029276; 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=35RSvSvW6RgLqSoNwuCiOaL227s0j7qgYbyMMYQ5H7Y=; b=mAPYzr60yd9YDkz692NM0xd4+6kjSp9/wgatymSgV9VZlJYgrIxAH/mXM7n71JwFD4 ZODPI2aKvFzW+09Cc5BhSfhdSdnBHRQ/6U9ZhDqzb2Xg4kzsvBDLThfWJQMBYesjI2Ut tLD20p4Lp1SDKblucF8xz72dyYAg/u8fnGm4TIrHIH58koetV9izY8ECvBAJVanQU3XP 7G0qnafEimMOya2ttH+GEqcxfdCKCXOECueS3nsL93DlAh7I+sjjMhAOSAnz1ASolHWK p9FfFOGV9ohztcgYuvz+PBDxUpqyoA+sIDFDLIQDwAumCPtLAXrjfSJ7r7gIATNUYr+3 Ia3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424476; x=1724029276; 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=35RSvSvW6RgLqSoNwuCiOaL227s0j7qgYbyMMYQ5H7Y=; b=OXHHZMBxc1wyZAgCZ3DMRTeqBsW5jOYBKDCb3CTkAzsOlhBZ0RKpiLWM+uyv8eJgMJ 5sUgTi4l83gAXPwq3k0Sa7hS48RFh1EM+oLiIJ3Ye8iDlFbxB1DpnKjdZw0BrRHHMmgd tMZFmPWWS86LEW2xo6udtT+EZbNJljhVmCmJZ/zpEDaoAzTmBUzcOZyXGxNqr0YxRMGD IHffbXXbB5mQY0805aU3XoYW8H2qIuNxK13duCP2xBR6a+AYwDyT0deEvce4eajy/ZTM Nf3m7TS923xzwduv1sgDJ5CKEbVfYLtzaauUbbU13yJZWantS4gYd4texoVnzAvn/3sE 934A== X-Forwarded-Encrypted: i=1; AJvYcCWd4PEdk1styq8YlMEMPZFnnKzps2pdKmVcqnqKs7OyDvDbudv9aHiUHp4wFJ0/E+AcAmifZXKHMge95GJ4Y418LLtD2VlNm1maROfwjxTA X-Gm-Message-State: AOJu0Yy6BQ2LWwrEtv0fjMozW2Gg22OwzLKh/QEfHrD2sepu+BMGtvtw REew63wEYN4dJBDYNmeI4Y0eHcW31SeSECLJfP8vczHfkRcPQF43nj/49syJixo= X-Google-Smtp-Source: AGHT+IHYcMx/Kelfyx+/kqYvp7mnCuHmz6lHSvmrk3Q0WFeD+E3yWJz8Mmv6EPhZaFQCiBxUacTGNQ== X-Received: by 2002:a05:6808:3209:b0:3d9:26d6:c6ed with SMTP id 5614622812f47-3dc41670fb1mr10153205b6e.3.1723424475694; Sun, 11 Aug 2024 18:01:15 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:15 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 15/17] irqchip/riscv-imsic: Add ACPI support Date: Mon, 12 Aug 2024 06:29:27 +0530 Message-ID: <20240812005929.113499-16-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180116_567257_B8D9A5F6 X-CRM114-Status: GOOD ( 25.55 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 subsystem is probed early and assume MSI controller is already setup. Hence, both IPI and MSI features need to be initialized early itself. Signed-off-by: Sunil V L Reviewed-by: Anup Patel Tested-by: Björn Töpel --- drivers/irqchip/irq-riscv-imsic-early.c | 64 +++++++++++++++++++++- drivers/irqchip/irq-riscv-imsic-platform.c | 32 +++++++++-- drivers/irqchip/irq-riscv-imsic-state.c | 57 +++++++++++-------- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- include/linux/irqchip/riscv-imsic.h | 9 +++ 5 files changed, 134 insertions(+), 30 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index 4fbb37074d29..c5c2e6929a2f 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,62 @@ 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, 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) { + irq_domain_free_fwnode(imsic_acpi_fwnode); + imsic_acpi_fwnode = NULL; + 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 + + if (rc) + pr_err("%pfwP: failed to register IMSIC for MSI functionality (error %d)\n", + imsic_acpi_fwnode, rc); + + /* + * Even if imsic_platform_acpi_probe() fails, the IPI part of IMSIC can + * continue to work. So, no need to return failure. This is similar to + * DT where IPI works but MSI probe fails for some reason. + */ + return 0; +} + +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 f9e70832863a..b97e6cd89ed7 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 @@ -564,18 +565,36 @@ static int __init imsic_populate_global_dt(struct fwnode_handle *fwnode, return 0; } +static int __init imsic_populate_global_acpi(struct fwnode_handle *fwnode, + struct imsic_global_config *global, + u32 *nr_parent_irqs, void *opaque) +{ + struct acpi_madt_imsic *imsic = (struct acpi_madt_imsic *)opaque; + + 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; + return 0; +} + static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, u32 index, unsigned long *hartid) { 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; + if (!is_of_node(fwnode)) { + if (hartid) + *hartid = acpi_rintc_index_to_hartid(index); + + if (!hartid || (*hartid == INVALID_HARTID)) + return -EINVAL; + + return 0; + } rc = of_irq_parse_one(to_of_node(fwnode), index, &parent); if (rc) @@ -594,12 +613,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_rintc_get_imsic_mmio_info(index, res); return of_address_to_resource(to_of_node(fwnode), index, res); } @@ -607,20 +622,14 @@ 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) { 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; @@ -632,7 +641,11 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, return -EINVAL; } - rc = imsic_populate_global_dt(fwnode, global, nr_parent_irqs); + if (is_of_node(fwnode)) + rc = imsic_populate_global_dt(fwnode, global, nr_parent_irqs); + else + rc = imsic_populate_global_acpi(fwnode, global, nr_parent_irqs, opaque); + if (rc) return rc; @@ -701,7 +714,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; @@ -742,7 +755,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..7494952c5518 100644 --- a/include/linux/irqchip/riscv-imsic.h +++ b/include/linux/irqchip/riscv-imsic.h @@ -8,6 +8,8 @@ #include #include +#include +#include #include #define IMSIC_MMIO_PAGE_SHIFT 12 @@ -84,4 +86,11 @@ 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 Aug 12 00:59:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759971 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 33B7BC52D7C for ; Mon, 12 Aug 2024 01:09:42 +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=QDAf4emJNIv9pEY4+0oZeU6Zs1SHDgJqDaxcCwZojZ0=; b=ZbDhfiR/tsGH0b bF2xi3jepRLxMppBcBGmlxYg72tPJX7JVjiRep71i9/NLSmYTBljiXeQSbh1iVdk6z3jlFo6H3qAD 23M77qR9dV0gjwHyhpHr7yN5L9Tk8qa2EbwtCOt9Z60+5a+UOpx4Zjm8nRFtExOr0i1JwiTH0lhVW LBVxMG1Pe0T2WuZaGbXrszwV3QmUNkgwXkPitRZCGjwM8fAFwzFB8CLu88lyQYgtxT834CjeTKOAt e6y+PMu9mvdE1kGymii/FvoeJo9CPT2V7umkJxSURm/8SEYVkOGpjPPjGeeCPlHuawZwqy9hdeB9s le4ipBrBNe9CrpWazbVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJZ4-0000000GcZD-49op; Mon, 12 Aug 2024 01:09:38 +0000 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJR5-0000000GaVf-1jkM for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:01:25 +0000 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-26106ec9336so2035587fac.2 for ; Sun, 11 Aug 2024 18:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424482; x=1724029282; 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=TMzQ3ciSNyAJUT1sxzxGDbpLjSEaz3yLiVcKcHEYKY4=; b=Ub9tdufGw2anzGwW9Pr3UQzkLRYbgyjJceUY9MkYH/XsVwu3dk9ac1bNXcBThO9IF4 cGU0DC37ecftB0fciJOrbff1T0rTUPSbbHJDosdb0tvH/XoqHt7Q1ihTXdkfrQ5tkjmX XKVPsZFZcWwkS8zREMgh1UBmQSKLXDHYnFXZxsM+yh36qE/ytAhaiRsdgOlqFOl3P7/v KVvIcGW7bIiCuDJY2pJPvBD+h5WjXqNkg49cP8WCgRpkYSLFMkFKy1yTtS3AE9pOgZSK 69VGD9oNeMZ4sdwBjI6MvfEDPs0YhsmkeuHgPyoIich7pR21dw1FgTlFRR4SCGiR8KM9 JvPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424482; x=1724029282; 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=TMzQ3ciSNyAJUT1sxzxGDbpLjSEaz3yLiVcKcHEYKY4=; b=adpS2O4HqzLt3NlA5pXBxZSM+lS/7PhjlxqdOH19k74KvcSn316GMfcpOPv7rzsQs2 jQN6ondidm6hkd5lJbzNCsKlCBM+1NpWhh49vlreiQL4rZJZ4HRuTeZ53DAbf98089nJ HkK7gJB5lkwhQ0LjLdxh4cBVq3eb1fNV0OY7cXVP/HqSNBKAkHqidMKyVxEF4Njll8cE aHwvhxxQp2JGQrSnCyN1dYEEokLcduD1zOole3vJzXL155gLDmN13S6WVdfz2CSr9gGW diedIg4VAkLXzyEfZSZddhhfos8OC5XyuiyQoy38HXzc3YopbIGYCaEbk4pLxWWFbfRS N6Bg== X-Forwarded-Encrypted: i=1; AJvYcCVs+wKMBFYozlaS9Kzc26SarMtmv8aU5BeUXDnVPEAVlEcT1WFYH54AwCzsBFt736IJMRMz/S4aYZhy6NvG8H4LpIMpwewpbpeWK1MZKJ4q X-Gm-Message-State: AOJu0Yx48d8ozhEodOcAkX5Sx0zCvirJnunn7U2FbpZyt82zO4heve75 6ct73xiPGWpsReKb7OnbOsKZ/PFWoJPqTDVO3AHj2jfLI6o2HEWSMjKPfqfXlr0= X-Google-Smtp-Source: AGHT+IHvjLsKNVgfioV52ZJQ6mkbTpTRo5xo8Ywht9O8CCjHZJ+ipOfWkzdibzywTZdRtlaqHgD09g== X-Received: by 2002:a05:6870:e38f:b0:261:2357:5a29 with SMTP id 586e51a60fabf-26c62f9f8admr6644942fac.46.1723424482033; Sun, 11 Aug 2024 18:01:22 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:21 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 16/17] irqchip/riscv-aplic: Add ACPI support Date: Mon, 12 Aug 2024 06:29:28 +0530 Message-ID: <20240812005929.113499-17-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180123_486963_6FF27231 X-CRM114-Status: GOOD ( 26.53 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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. Use the mapping created early during boot to get the details about the APLIC. Signed-off-by: Sunil V L Reviewed-by: Anup Patel Tested-by: Björn Töpel --- drivers/irqchip/irq-riscv-aplic-direct.c | 22 +++++--- drivers/irqchip/irq-riscv-aplic-main.c | 69 ++++++++++++++++-------- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 +++- 4 files changed, 69 insertions(+), 32 deletions(-) diff --git a/drivers/irqchip/irq-riscv-aplic-direct.c b/drivers/irqchip/irq-riscv-aplic-direct.c index 4a3ffe856d6c..7cd6b646774b 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 @@ -189,17 +190,22 @@ 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; + 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)) { + hartid = acpi_rintc_ext_parent_to_hartid(priv->acpi_aplic_id, index); + if (hartid == INVALID_HARTID) + return -ENODEV; + + *parent_hartid = hartid; + *parent_hwirq = RV_IRQ_EXT; + return 0; + } rc = of_irq_parse_one(to_of_node(dev->fwnode), index, &parent); if (rc) @@ -237,7 +243,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 28dd175b5764..cbe97886364c 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 device_node *np = to_of_node(dev->fwnode); struct of_phandle_args parent; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!np) - 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(np, "riscv,num-sources", &priv->nr_irqs); - if (rc) { - dev_err(dev, "failed to get number of interrupt sources\n"); - return rc; - } + if (np) { + /* Find out number of interrupt sources */ + rc = of_property_read_u32(np, "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(np, "msi-parent")) { - while (!of_irq_parse_one(np, priv->nr_idcs, &parent)) - priv->nr_idcs++; + /* + * 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(np, "msi-parent")) { + while (!of_irq_parse_one(np, priv->nr_idcs, &parent)) + priv->nr_idcs++; + } + } else { + rc = riscv_acpi_get_gsi_info(dev->fwnode, &priv->gsi_base, &priv->acpi_aplic_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 */ @@ -184,7 +197,11 @@ static int aplic_probe(struct platform_device *pdev) * If msi-parent property is present then setup APLIC MSI * mode otherwise setup APLIC direct mode. */ - msi_mode = of_property_present(to_of_node(dev->fwnode), "msi-parent"); + 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 @@ -192,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; } @@ -204,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..b0ad8cde69b1 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 acpi_aplic_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 d7773f76e5d0..945bff28265c 100644 --- a/drivers/irqchip/irq-riscv-aplic-msi.c +++ b/drivers/irqchip/irq-riscv-aplic-msi.c @@ -175,6 +175,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; @@ -257,8 +258,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 Aug 12 00:59:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13759970 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 E6B69C3DA4A for ; Mon, 12 Aug 2024 01:09:41 +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=LY+R+acWHjUir0esPH929+XLrdawAIqnSD3k5f7mMZ8=; b=2LAwqg4LUsQB9a z0wfH6GXNoV4MjT+2Vd5f7RaYDZ/BHj8KRjv8P84j2Mv0GxvwqMyLTBJfbV6n/C4PNI2bORijSyAm TILdWaknx1Ums12/BWRgBZkThxeabGFdzn+EC+U5jJyVckJnS7ijIxySlfFjdgdZJ2okF0FFs/hi5 71xXfo+R0iGfuy/nMd/7uVBEcmLmJya5bvL0Cj4brFkt8s3mxcwa48iv2SDwUrcHSq02dkwbELU/p /pWt7Xneyqi8n39g21AqBaWpelqF+ECrRzSZK7rAo+UnnYFfctNwABAMMKy3XCNeVETil8pDA98j0 nGmuHrrync2adglYex6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJZ5-0000000GcZY-2l4y; Mon, 12 Aug 2024 01:09:39 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdJRB-0000000GaZa-3lsd for linux-riscv@lists.infradead.org; Mon, 12 Aug 2024 01:01:31 +0000 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-81fd520fee5so150369939f.2 for ; Sun, 11 Aug 2024 18:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424488; x=1724029288; 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=cNLSK7wTLWm4CwE5KqZAhFa5+nxzSyIB3H2xsiVowu8=; b=j9mDL31umRy5/i5Il/niqtlUP/t05RK+Bg6z+SoIMJ62vtjxH1uUgPldeO3oIDAbMm NJdsZNilPBO3udJRh5JYMi/Da7uk9aaDQZme82XrfXc50Xj493KKLrySQUGWLzQZLFz1 T//z5k/F/woHXB2jnDircpeam3WeTsWMJwmrGQicyuIDRlycPJtAmGUsMHOD9JKnSIRh eBsuxumqO/gmQwqumOfjS2hXmcw+xjLaGyBhMf6sE5BCFGP0paxOS550CDJkaGs+GExH R3/e2+phzWHHKRUXgGAYR/esw/qFuG2OOH1pvKDfKuQwJpzErhEZvQf0cJXFy/kGKPNm ugiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424488; x=1724029288; 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=cNLSK7wTLWm4CwE5KqZAhFa5+nxzSyIB3H2xsiVowu8=; b=T5P1cvvRdtNq+NT64BZjzm2t0vro9VcuI2/rLTvAhXU5t9sxzHqqyireAtA9Mujish CGbe17Csx5F0GBaBKyu5xvFl0btJUBQN+OyjrDzNYt+Wvb/Igk5WaSEB/qv4sSzs+wNv s66sByASYa/NhJ7rPJPnw9EvRIFO4Pf2eiuvawDWEMqKIBkgfWtV/WKKHAt4kmsWtbFP 8Y/KP0kFDGggR/vVriDgl7FYN27lHMcHvVlq33zpR+9Qx2E7p2NX2mUq6Sa6gOgMrSi3 xBgTDL/AEOPkVPRUa4rnM8gz3G7qunB7kCxpnuxrW7t6WO/0E6QTGI9oVbpbjY4kPJV7 3yrg== X-Forwarded-Encrypted: i=1; AJvYcCVXIjb1P5ZOBTlnucVri0MrohN0lrGap9G8a7EtVbXfGi/ZrEFAYyD5KrDP6NHlAdIPO+npRxx5DciZLxuFABRWQYbfJJPGzr6/fAAjFoiW X-Gm-Message-State: AOJu0Yw1ijvy9OQ3j4pBBu4mEeJ1dWvj193LUh2K6Cw5FL/bT3Qy5MTx RbnUdCkiGPQKxjT5p4kiQcxz9B5/RySRKrTsYDYlR+euvH62qCfE7uFEtpAKetw= X-Google-Smtp-Source: AGHT+IF383Ow04ACkTQv23O0jExDAeidajffTjgaukCfUfErQcvrXz/vXlnALl3G0O0SzK4yssEykg== X-Received: by 2002:a05:6602:15d3:b0:805:3d47:19cf with SMTP id ca18e2360f4ac-8225eedb1e2mr1121775039f.15.1723424488343; Sun, 11 Aug 2024 18:01:28 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:27 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v8 17/17] irqchip/sifive-plic: Add ACPI support Date: Mon, 12 Aug 2024 06:29:29 +0530 Message-ID: <20240812005929.113499-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240811_180130_002857_22016B84 X-CRM114-Status: GOOD ( 22.36 ) 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: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Anup Patel , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Bjorn Helgaas , 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 Reviewed-by: Anup Patel Tested-by: Björn Töpel --- drivers/irqchip/irq-sifive-plic.c | 95 ++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 21 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 9e22f7e378f5..207cfe18ec7f 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 acpi_plic_id; }; struct plic_handler { @@ -324,6 +327,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); @@ -424,18 +431,37 @@ 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)) { + rc = riscv_acpi_get_gsi_info(dev->fwnode, gsi_base, id, nr_irqs, NULL); + if (rc) { + dev_err(dev, "failed to find GSI mapping\n"); + return rc; + } + + *nr_contexts = acpi_rintc_get_plic_nr_contexts(*id); + 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) { @@ -449,23 +475,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)) { + hartid = acpi_rintc_ext_parent_to_hartid(id, context); + if (hartid == INVALID_HARTID) + return -EINVAL; + + *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) @@ -489,6 +521,8 @@ static int plic_probe(struct platform_device *pdev) u32 nr_irqs, parent_hwirq; struct plic_priv *priv; irq_hw_number_t hwirq; + int id, context_id; + u32 gsi_base; if (is_of_node(dev->fwnode)) { const struct of_device_id *id; @@ -498,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; @@ -509,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->acpi_plic_id = id; priv->regs = devm_platform_ioremap_resource(pdev, 0); if (WARN_ON(!priv->regs)) @@ -519,12 +555,23 @@ 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->acpi_plic_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 { + context_id = acpi_rintc_get_plic_context(priv->acpi_plic_id, i); + if (context_id == INVALID_CONTEXT) { + dev_warn(dev, "invalid context id for context%d\n", i); + continue; + } + } + /* * Skip contexts other than external interrupts for our * privilege level. @@ -562,10 +609,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), @@ -581,8 +628,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; @@ -619,13 +666,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->acpi_plic_id)) continue; if (parent_hwirq != RV_IRQ_EXT || cpu < 0) continue; @@ -644,6 +696,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, };