From patchwork Mon Jul 29 14:22:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745090 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 9685FC3DA4A for ; Mon, 29 Jul 2024 14:38:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hSxngftEiBZGICTJUojSdU3dLXXHwvvk27H6OBfgGDY=; b=SlXxOXx62IECzV MXrnPNy4x1zZ1Iul9ER6oZhdsvkks7TAOUj+QoQLqlO/PVCmdtaIN9B2d0CsoGB2ZBYwDUwGt2mBq c3AIgMGX2b4U/kq7dQaVwTeMcdasplEnMMgefy1DVgxi4BZR4T2KQTqRzjWDRNdW7m478Be0C/K/R BrO5FJMPaFRBvNm44UKStJRkI/JtpZVshMCY1q2NuhIhJYQDiJOITLTiSA4HFAbmP7c2TpTHxq17I g58s7vYBlM//NzOWG4bbFK80V2DdoaWAVkkpbalS/DQaNmx9rENQEKs5TmTdGy2Be1kLdyPTdtw2h 6izvPuQMBNJdbQT7IDQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRWM-0000000BfQv-2DCV; Mon, 29 Jul 2024 14:38:42 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHC-0000000BYTX-08fA for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:03 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1fc6ee64512so19626975ad.0 for ; Mon, 29 Jul 2024 07:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722262981; x=1722867781; 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=A1e/9nxDibJ070eAfg/zT3PtW3/KirZQ3ZpE+at0v4w=; b=OVzPduLRM0P5vPp2jBQ0mk818ftqyGbJ1lr/uBb8nD8iOZltmJQ5hEoyEp87QXSzS+ Xw1filqpIuPPU+vXkhawmlzgzcODxa1AysP67z1h1DfZcAJxEa2LLfcCpGbMCKRHhvmA kjlOWWQCmEx30h13qEqBfkKns64UCBDrfEbAQSwO+zxahWwUkEnLAz7aF1o5BnxuODWB 8PGZwR810ITQib/wPo7An7KHngHRswRxLeJtNzLdEVPPIYtZ2cGmunTvsEnXHIUPgwsP q7pJUbNtn3cF8oXaDsEA316DdY90boqVtLR4+oAVhzEk5a+YAdkXa3IxLL5vSMUP9i1x BB+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722262981; x=1722867781; 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=A1e/9nxDibJ070eAfg/zT3PtW3/KirZQ3ZpE+at0v4w=; b=aQVTs77PKCYV5bOfstT921SeTO+Mz9FNGoGCaBHdvRU9lCi9XktiJLXRhNkhX/expo cpzKjdVvckf/cphZArrotxyxtMZ3g2B1aQItPjwBlxMsWkDCgHFyLL666sJTDt73vBp9 +qkN6MzH270iorupV6aBbMBAWdCf8pP/GdBviKKX3+pC2Z86K0gIASmccDca9jNvSQfh 0777wpxMiXi1ucXJIpjhNuyx+RIQj7USAz1D6R/mxVTwVQbK5R88CkkvansJOXpKKGd0 /ghl98PtOfQCV80qjQN+aaPoOdihK9h+hC/wiXaXI1fDUNt8VTs8kzMn8cwC4H9QKKRR qZKw== X-Forwarded-Encrypted: i=1; AJvYcCWxecSldynR0uir2kNSgNvMq09ZIXrOEMMx3Y5Wph4fXfrcQCHuqYt7C+UYR9U0yvCHmI9+kw6a7cgwTWSDX3mYBE/YC7b+SE0LgV4ADHVL X-Gm-Message-State: AOJu0YxwiMeU0f6Z5XhM2UI2vJe3LPNRKfHI9A5iw8hg+CRDQBjgGQYv TknePKZ7N4fcXk3lhW/o0wKZEINwbaSz6l3taSqk+AX139x0ysgQ1kiNKdcL6Bk= X-Google-Smtp-Source: AGHT+IFORLmkj32RLEBpuI2kgsPz1jemTsoN6n/Vf5+kIYun2OskeuAkA78gnrEr84cd/KJkiH+mDA== X-Received: by 2002:a17:902:c412:b0:1fd:92a7:6ccc with SMTP id d9443c01a7336-1ff0483e03emr60207015ad.30.1722262980776; Mon, 29 Jul 2024 07:23:00 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:00 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 01/17] arm64: PCI: Migrate ACPI related functions to pci-acpi.c Date: Mon, 29 Jul 2024 19:52:23 +0530 Message-ID: <20240729142241.733357-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072302_118495_9CC8D4D5 X-CRM114-Status: GOOD ( 20.99 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745091 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 E6AAAC3DA4A for ; Mon, 29 Jul 2024 14:39:15 +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=VY7LyOLW+S99EgIV764DXtWByZSYjwLOlGDemtluiLg=; b=GRsP4tqvmRASdg F1HVdYA47kLpDXHmwKyY97wxDSffxzTticjD7Fmy4osF8CURxmBpsLWqf0HjboUOpx9DndjLwJ90R f3//FfGyxmNSkkCoTZDq7vzZllZMNgFpIXmqxjDjuDaPwIQJKU6gERuna33VEUuDOoRcvljkjYL0B tBVnGz2kwy8cBtVgTug+euXaOnZNp3KwB0qKSJ1QkKrg6QkiaseI9+y+m1VTZ5oNDu0ufmIwHEIub 5SynR34sqcDrSjo20LPuU9gyHlgK/qnSXvjpQUmkj6Sgugz1fJ4aImrSezq98kkLF5BfzHrlruosi BcwH5YGoUPStWrAcPV2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRWr-0000000BfdI-0y66; Mon, 29 Jul 2024 14:39:13 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHH-0000000BYWC-2UgC for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:09 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1fd65aaac27so19278945ad.1 for ; Mon, 29 Jul 2024 07:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722262986; x=1722867786; 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=1v7P8DgVWEOiQraKJZCp7Th7levU77nqOCGgGfYFy3k=; b=PkoDwsu0vP8cpQRm4FgQpLnjY5tj1+0BEIEn0RfnY6T/Lv+o5MeygjY0/0+Nzzu+h4 bsZmsoca49OgM3MoRiJrmfA7KpG67FwzcBfsm36IfwSNWh1c3NcSMfjWE3ffCgt3xrAY LqrbMGQ7zwq3yscoefTf9+uOcnmPq1DxYvwkOTn9EMUkMpgpaKLntppb94d+5bc7c3wc gTeycSYBOUJAuZIqcCccesObqHgt9tF2GajYeoQg4R97UD4A48sc2tBIYpgs6dLCll9B BxKHAhKCOX6EXn+ZAFui7B6hQgo6FDi3ihtNpFpOCbwvIFCd5KowYqNmW8qWlb3IJirM 2tIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722262986; x=1722867786; 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=1v7P8DgVWEOiQraKJZCp7Th7levU77nqOCGgGfYFy3k=; b=iVASTejcwg8RUjG1bW0z5s37/cGw+GvkLK2ag8SVS+j7+q8z1OKJBmKNfDIA1p2/Fa w2jP/jdld2pQzQKOgsbHRSk+WzT1JVMe0htnwnfP6N1wjOtj8yrwsYXsYIkEYxOdtP0q H2vAWCDIHaX6FhxOuDPJQxFxDrOiUMFJHB1I+IBaFoiAZ7fNv4a5AOefcm3PtB0vy7Dy 5Efdupxuzw8gSMdn3sZ71e7sm3T1i8x5OQiAkhyN+gOnrOVr9ImZGhyZpxYyckeDRiKw WdMOxRd0jsZa3ZqLzHZ2HEFn3IZKwqBuLaGp3qMLsXe9rKncMnXhw9PT5xYWGGqGZwkK oDwQ== X-Forwarded-Encrypted: i=1; AJvYcCXFa6UbRGEDYsO4txdbjRJhJGy0cqZ9qNFx7VLJHmc3V8KJTE6xp5+Hu58OTk5GQxfdOhMWT3O+uQCha6EqYMN7FkXXEU+CayoptkyonZnn X-Gm-Message-State: AOJu0YxqckREJP1k0srE7rkolrK7yvja5Kmdv9l7RampKIzBXAXKmmzy ArzbN94vSETaa+ZZmdyybqQ0BMUZBbLCMqSnEg9JIsRTQYMhflumdG2pHisdSxc= X-Google-Smtp-Source: AGHT+IH0i4SJoksic7K7uCsgqP3M+9IpULgJ5o8eJTMb+FKn2Lo8UBe751+qjL2E7UCdZzZIpyOlyw== X-Received: by 2002:a17:902:d4c8:b0:1fd:6f24:efad with SMTP id d9443c01a7336-1ff04b01aebmr124703345ad.26.1722262986279; Mon, 29 Jul 2024 07:23:06 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23: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-pci@vger.kernel.org Subject: [PATCH v7 02/17] ACPI: scan: Add a weak function to reorder the IRQCHIP probe Date: Mon, 29 Jul 2024 19:52:24 +0530 Message-ID: <20240729142241.733357-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072307_659942_851FD566 X-CRM114-Status: GOOD ( 13.58 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 a architecture specific weak function to order the probing of the interrupt controllers which can be implemented by different architectures as per their interrupt controller hierarchy. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 3 +++ include/linux/acpi.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 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 Jul 29 14:22:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745092 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 558F7C3DA7E for ; Mon, 29 Jul 2024 14:39:16 +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=hJCmiS6vQBrKBxpieS+WlukuiX6x0ZneSlwQtdowfes=; b=4JmMHcnfcseJQB 9kwAR80a0ywf5UORRV1ihL/H7pPtyYzrWqq4HTtSXMTtcSNfhKUdnM1q8b30jNRfnU6eZXRIvZhWu WPuq9Vw0J+VjjzBYxzDnbGEoFDStn7VsyZ6RLrQyzrNs2bDVAu0ANYQ4LYKVysaowSyHu2IPlY9bq SHN1KmGYqRl6I2d7jz/0egYyxA7TQbWrkRQ+RyeujIlU9KwDIEPybqk1Af73pEVWMXzEA1/rJ+b6e ByJwRFcD/su4rox/qmtz4QuDPNdfPlTRe8yDUdTmeJ8UO68Ke20lRwZRNXBaFcVFd56JuLMkN6xop InhsXJ9TUXYmh5MrScqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRWr-0000000Bfde-3hcv; Mon, 29 Jul 2024 14:39:13 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHM-0000000BYZP-1NuA for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:13 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1fec34f94abso20410425ad.2 for ; Mon, 29 Jul 2024 07:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722262992; x=1722867792; 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=fpUpzTn31uAv59eRsYCCTGHf2UwttQw3/INKSz7Rgp0=; b=NnF/mFIOLvGUy9a+iivmeYc0KEI5+72iaoJ/16ElHj6bVhcfSk/gqnNo4c+M3Nj6VI Py95gm58WVYqeTUXLYfcVG6JpDNS+YLSgJ6Ert66l9K4ZeBvImFdACQtc17bKVIkSAsV SQKRX1m+iUhN5ZzsU/Qfl9LnRNAAQuyi0XQqXgWRwNISf1PPNu58xNAo7Ts71F3vYB0C TB2BQygxprvm1b7O0gfPQmSCsnGTnqDCuUQOSD+KM/2bmW6+gSNw7VG8UfEE03lAzY00 6dK0pt5RoluauaQIMHqHvuOaFgxh2iZsTNkJ7r9unpRdbuJTYqLChDUgWFfIRlSVcuD7 sT/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722262992; x=1722867792; 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=fpUpzTn31uAv59eRsYCCTGHf2UwttQw3/INKSz7Rgp0=; b=i14U8TupaBaPaN6kb1yTaR0HumMWvr/PRddyXU+I1zA+fqXbGLjWz1oA1hi/bh5ydx 1RekLC3aV1P7TTGFo2fwRRbf0xgUB18ykAcogeSYrBcajFaBjXC8xEZMh/VPQWbQZJdQ cjmUsIe4WgPsY6Hv8wERYxt8pVo/+Qc942OMEWE7s6MC1rJuWubZdNpd/sFot4KRIuf7 TaQIlS9xvt+RUaGUhBS7V0vUF+U92Yhm7BwVE5x7iPhVqwY36CMd3qRV3dLp6auTBf8Z 49hF/XEvyY3Y01FxMHwekB+lrDE8VSKPmW9uk+3DwqZCbGdg99bIpj6U1I9FPDqMoY3y AzWQ== X-Forwarded-Encrypted: i=1; AJvYcCUqZvixiEHTWBrcJwxaUOa0V04oUwWu7INNQHKm2SJfqXlC+abQU96m/0herr2bUDedgnOrOwqE4IRBiX1zAtZUWgOsmc9HmQKB+QcrniCD X-Gm-Message-State: AOJu0Ywg5is32kUiVFeSFTfXx3QEdF4qhs+wYKxCEGoFypiIQZrv8oXJ B9V0oEEBu0THqdGlyNoKoSJuRYae/fJdZJvpkJyxrDmmLoJHaajO5fczxtYIxug= X-Google-Smtp-Source: AGHT+IH8iPMjHAqTJtzMrAyY/pfHaeY/boKXW8uZbGvPFkTDNr09tJ3EGqjomR/myMHI4FJBrBAsNQ== X-Received: by 2002:a17:903:1c4:b0:1fd:668b:ac4b with SMTP id d9443c01a7336-1ff0481ada8mr54039975ad.15.1722262991841; Mon, 29 Jul 2024 07:23:11 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:11 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 03/17] ACPI: bus: Add acpi_riscv_init function Date: Mon, 29 Jul 2024 19:52:25 +0530 Message-ID: <20240729142241.733357-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072312_389552_CD8E4F81 X-CRM114-Status: GOOD ( 15.62 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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. Signed-off-by: Sunil V L --- drivers/acpi/bus.c | 1 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 12 ++++++++++++ include/linux/acpi.h | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/init.c diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 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..5f7571143245 --- /dev/null +++ b/drivers/acpi/riscv/init.c @@ -0,0 +1,12 @@ +// 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 Jul 29 14:22:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745093 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 7B1C2C3DA61 for ; Mon, 29 Jul 2024 14:39: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=e2M3E5w97S0GDcJ1q0/pdfM/ZFqa6U3eHaRVrsXpt8E=; b=iHoiyFPIs0YRxs ZGLztTILCRlvSorIN05eEkU6lwOESvkhTEAUSJGX5MFmAFulCSxuOeDqjZfvW0rd0nzFxthf3xqoc 7+hnGeqian42p0RzCmECG8ua/nzsubhmZCeOM1lAxwS8XdXqV1wFhibaKFCz1sFKYM9C35xAd3QUA GcyQDcWUxG9k8GZTAEt7stveZUqBUz3GKQZ7sHayqmV0aWfvTWUS59usYTtSW9K5oBJZSGzRZTvID AMyUuOprzO2nsJLit3tCBmUy0g7qnmihQvBTI/yx6YTOPfy+1H/ReMEZ3Fk4FyDGC18vAih9e5FxK mwbcFxvC8ELThf0PSOow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRX1-0000000BfhI-3zfm; Mon, 29 Jul 2024 14:39:23 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHS-0000000BYdC-1czQ for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:19 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1fc60c3ead4so18740175ad.0 for ; Mon, 29 Jul 2024 07:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722262998; x=1722867798; 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=sQDYeCPMpR4X4S963fAEbe/mK838iVz52tFUEQviIac=; b=URMlvFH5QHlxR8f9eVjNNE0GGH1sA2/5DVodbKBoo8PdO5jnbpR91aXYnmbMplLkW3 Pkjt0P+of+nrAJhv4XcK5g8SufUGIX6yKK7sNXmmi1oKuXshsIP/W21j3J3+IipveC0i gb8NWhXUqlzIP7iByWCRahOmxPhJK9S/xeubuMX//sUMl1tI0uPyCEtCnAGjtcwAYwLG g9duJt64sEuD0W+cGf7Xnf1zN+0MWrytX1RTvKJKSkiZuTNUBXU2yCbjlM1VEgj10t9t nk3jHDWgSG/FGexT4aUQMCMn32rnATNGBb2UdnmyIW03dnxD2+F3ZIS9eJv3N4sE1rGg 4kjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722262998; x=1722867798; 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=sQDYeCPMpR4X4S963fAEbe/mK838iVz52tFUEQviIac=; b=oc1rsAzUe08HLxizp4QVaMOB9BEoIlKho4yy98hByLX1e+uFgWZBdP06OSxepxCa0l blWPkwhtS8J3CDIYcHl4V1HbTd6tCci9q+NvmTp9Rnk/DODacb0smyPfe6pG7w/9vJHZ ltuu754ro8AdzMaUn3s2iGNikzjUZobskjubukKy8OT91uBuu7oJ5ycMb84EcXQSfVP+ tWw8H62Nk38aZ6lFNuvulH3tfQQ1qpIPzL/z0htWkOBpWheJwqDj96GxKIe4KRDq32H5 SC/dmuId+sMjbC0TBYkoa/tZqWiB4AnyUrpOEOYNipMxM4SBWMowYjLDGVwEWs7hd6gy 8hRA== X-Forwarded-Encrypted: i=1; AJvYcCWLa/PFHyOIhEEIjHKJXWJlKHFANcSwOb9xmVyKCnp3E6SePT/1EkFBOmnX0y9neDZTznlX6OkUH+khvjq0dJhmNTfNF2qs4DcnyZo5oC0C X-Gm-Message-State: AOJu0Yw78+cBeOjVewYBPfXndUpnWNENKbzX0m3+0oflSnGQjNzeB9nh z/PRglxfTjdJrkNgtqyj/SqgUhNNvwcib0MoP0Al9VX95E91AlVtUL7dE7zC9FE= X-Google-Smtp-Source: AGHT+IHRfKhuOi58y2gNq6JrnPRM6LI4wl21FmFrPGpsAor4rfs3r540grBj2gDL5SzyBewH4Ncnbw== X-Received: by 2002:a17:903:189:b0:1fc:4197:d786 with SMTP id d9443c01a7336-1ff048434bcmr60175465ad.30.1722262997684; Mon, 29 Jul 2024 07:23:17 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:16 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 04/17] ACPI: scan: Refactor dependency creation Date: Mon, 29 Jul 2024 19:52:26 +0530 Message-ID: <20240729142241.733357-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072318_480155_075E2F3E X-CRM114-Status: GOOD ( 15.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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745094 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 1E896C3DA61 for ; Mon, 29 Jul 2024 14:39:49 +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=UhriiV+j974agBSyZNhPKC8XAd1jamG92aPju/2k/dk=; b=kjotltvg1JqA9o q8LiS63uQFsjLvKDMaAsGnCs9Cq+nr2/k9ofMhXMYuGekqwxZSAFnu2uXQ20kiCNPTh4+LHnLzBAi eWljYsKZ1nd8HiMnuf/qRnOGhsONWKtH61J4AgmfIZXd+thk1jHi84yXIYQrjqBrguKC6T0SpiksS 2bDrRiG00PdK40mWb8fnLXo/PEe0eic/JjJFayahSxpHKQRyGd6xt80WjpNcFbFhQV2SaBqxLadH4 IeeaGxnHFOZ/CL9CX3TFdetmQuOnb35VOPtBaRAbVvSIVS8dJIHJJtnqQNbbwjZyg8feLJ2nAi810 IGLUb99tNL3XujoX+2XA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRXM-0000000BfqH-1pZO; Mon, 29 Jul 2024 14:39:45 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHY-0000000BYgZ-2hDB for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:26 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1fd70ba6a15so19915905ad.0 for ; Mon, 29 Jul 2024 07:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263003; x=1722867803; 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=IKYwRAs6GZjX8rwxqPz6RZqcRKMFxP3sTbkHp6BG6OY=; b=ZYr12WgbFSzx1ff87/M/HP/DVpEdfY/Z3bGkAkksmDsJZSVXq9pA5Xmc7ZiXaUlbbw PAqaPk6F4blOvTnQVa6QYlU4LIaHfPU+Ey1lzyQZ5LQtB9JQR/v9mmZjycuCTBM42UiY tQstnCxXJJPZDWt7JHIHP1t+dTnyzY9X9TIYym88Nhc9tkBgoGOWPfpplMtrMAN6e0eu Dvfbjp/J9RO1NGelYkej5APbGNB3nXXByPPOlBIW1g8sFMwOA6FADuDwy3NV0tedshrx SlIq7WTOGbF8Qvzshs5qx6CBS8r7wjeU8YFffuZkb9mxyv0HdyiBGS3eezBGqEezmw+Q DnIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263003; x=1722867803; 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=IKYwRAs6GZjX8rwxqPz6RZqcRKMFxP3sTbkHp6BG6OY=; b=bWX5QpU9YmoBwPOSYkmBTAitiXax9Vxlte5CcfHogprEkg5PV3m1KwxtzD0SlAgrcU nFL21DxCpwqvAlg6WlItuKFw2JDStekFvF/aIr+u/sQL9qPCo7cwYAXopbMvVp8HCh30 CeHj7xwcADqgCiigDDCWumL2N6g49ItfpXgI19SN0lLSQSOq55SClATP0sNJkEHCPuiT 2CKYqBXaCgHOTRT2gComOVbRUGMlZ3WVR5Ek2B4dTdgiHuJao8D9JWPvkgTtYduF2lfV mHh9HK9awlFJyULKCCP5OpitS7FJNHwzoM+caNZwMBozadaIBzlrkZnvQG4mdXZUdYDj Ep4g== X-Forwarded-Encrypted: i=1; AJvYcCU7Zsd40q5jkOG9BHV07w5uqm9bg5wwEas9Qi7FjUjJ6jHKUwTSp1QbFu+ntwPIW+l8bglrnkOP5vb3XYPpaeB56hMgZoAQEhjHIwhOKdXQ X-Gm-Message-State: AOJu0YzzK742enI6YuYNePdo6kUOjRviD95mKIl9BZHGl654XIOGAX1N F1ghjVlgJ/f0mxKnf9TZ7x0ZF8Ag7L9J9CLJVa/xoS+M9/3juL9KNgVvOiJ4Gfg= X-Google-Smtp-Source: AGHT+IHlmBVDHSe6PUvNsr600YNWcBMY907Dx80p++dt4s49fUoZ70tkMwcDAnmuTUCJtN3oxZs+cQ== X-Received: by 2002:a17:903:191:b0:1fc:6b8b:4918 with SMTP id d9443c01a7336-1ff048e1db3mr52120535ad.41.1722263003482; Mon, 29 Jul 2024 07:23:23 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:22 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 05/17] ACPI: scan: Add RISC-V interrupt controllers to honor list Date: Mon, 29 Jul 2024 19:52:27 +0530 Message-ID: <20240729142241.733357-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072324_867442_4B889C42 X-CRM114-Status: UNSURE ( 9.59 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745095 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 B9BC0C3DA61 for ; Mon, 29 Jul 2024 14:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aj1IeIADVgRX/KL11N5/T76js/v/dO453VnaPoDB2Dc=; b=F5jHIldC0zKCD/ aZ5d7xfWmmnL77UTlaPG1QQpe2oggfE4xI9wTvAG00bFZPygj3n3YwaxD1TllxDRps7TsrvfYwgB9 8MX7HmRKl8ppCaiRM/wq6ui+7ksslkbM6P4LyDEHrbLLiJydkjpNgeMOAMSFFS9x22bcRmXCm3uZi mwxzuxwe2MqydNP/WHXpGkapoDMDgMPACpiyT1UCGjw/OWWDcCd148dM22/iiCC7+pQJ8r3lKqHQ0 /fCv/Hnj2c4OvG8Qrtn2MjpgWxazr8huD3Yk5uPkz6ey2uab2wBDt9l61r5Q+AubLlbpwKbSw7iGn gbTww0N+Rrnqw5+jEDng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRXX-0000000BfuY-0Hgr; Mon, 29 Jul 2024 14:39:55 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHd-0000000BYjA-3ht8 for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:31 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1fd6ed7688cso21056225ad.3 for ; Mon, 29 Jul 2024 07:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263009; x=1722867809; 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=ivFx7Eb2KNlJll+d2W+eJ7NSuljATLtswxxJxue4OO4=; b=L1aZ2ElKlKULsCwMek1A2Q1ZQ7mCoeE2sV1nfx7hmxXbI1zRd1t5+GEGP6KI7jKCm/ RAZwD7X4W9143cjGnhqTONVKHXXR49FE8grOee27NYcbQlSC/GQxOHU8XvHP72Xf4kWK l0XlbZ+K7d8LKnwj1otNEaSUtTw0yncbAJ1Vv8dvEcWD/X5y9zZz7V9usAOAewhDPNW+ BVNg3azE4ZyxqPj3t4wvkVOXRxO2RVLybSWQBOE7/qntwx5Zq3SNYXBFQyNRfunGL1Y/ Kxnd9yIVtMTB8y5zwf3x5HboUy1NRdoClGmLeShgpKlInckIZmTQHGxVOKSf7BNiaeUM eGFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263009; x=1722867809; 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=ivFx7Eb2KNlJll+d2W+eJ7NSuljATLtswxxJxue4OO4=; b=iGA3I6SDibK/PNYrf4RXGdUKR1JqE/dczJYOhEYjV6o+bYmtiExt4rsBmXsQeWd4ZY Faa5lluw1bBT5vQOgWj3wobmL+DXBBs4OkNHicjPlO00sVFU0rtO0//lw06zBLDhInWU MSnhkD48ATx8x743V9my/nsEau/uDb38KbAm0n56VSeV7T6Lc58HOJH+e+1hJNQvwFbU uTuHYL38brpTCKx3ku4sXii6xR+ny+dWVINiLrjEtsnfdcWLrHUg1aCXud5KiAqPCMko ushCnisyKFKwm4m+DVayQ/Whc5dL5iQzTbiI4JP7zyiYpYQAu2BngZvRaAeE2dG7ic+o PcCw== X-Forwarded-Encrypted: i=1; AJvYcCW+BcjMnDBNLbLZPP/JBOC9oVQ0pAW/XXC9dyjuBO9Xw4WEj2QX1q1in+2A2j6ds0OcqKV608kaw2kqTrCAg8lRdnMK22Axcfl7535n4vYa X-Gm-Message-State: AOJu0YwwywpUco3HB1lk/KiLddgaobYBK1INFJE/RVW8b1K8MQeL9Q58 fMsXw0gP+xmT22HkwDsDvAGFO7txshfUsm8GES0uoA9G922v2zsdNqAtJPYXdeE= X-Google-Smtp-Source: AGHT+IE8RqsmNLGZwn4UKGI9HbMHE+3KC0OV1lt+Ckv1MptlwMQ/WvrHjQX+XujtO97bjUDIb+rzyA== X-Received: by 2002:a17:903:234a:b0:1fc:369b:c1de with SMTP id d9443c01a7336-1ff04805ab4mr61618075ad.5.1722263009198; Mon, 29 Jul 2024 07:23:29 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:28 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 06/17] ACPI: scan: Define weak function to populate dependencies Date: Mon, 29 Jul 2024 19:52:28 +0530 Message-ID: <20240729142241.733357-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072329_947624_9929A984 X-CRM114-Status: GOOD ( 12.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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745096 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 9B620C3DA4A for ; Mon, 29 Jul 2024 14:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VnkrhVwHxoVgkBaGWf/Oh0HqLreyML731We9zPvYU5M=; b=POcuc9S5yjPS0o nN8Qc871sBAP4FPUeMnI7T/s5+7zlKPa9YAAJku0a+ycoZC6wGke/em4kqYCwqP9cq8YdqALiU8vv lt9cErGepohTxymVkNC4cZ6lhiav7rFOhVfwyLzYXdTj0WSKCuzOk0E2scw3m+JOzCr54swbc0rC7 FikyM8uCUWBpFu25aP53jw5bSBN8Sk9yEIoXTERPmP3FsLE+ohK7NV6WpvcOAYxmGxy6roKt7Lkzd 2AGGtxaSKiX4fg2/lZDGEiubfJfSAj0D7ZvppDE939ZHHf+DN6UJh1jyRJvUJNOoaqPfmRfqMj7iO xrBPlXAww1OoPlejjCUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRXh-0000000Bfyk-4BwN; Mon, 29 Jul 2024 14:40:06 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHj-0000000BYlH-1ip3 for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:37 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1fb3b7d0d56so14461235ad.1 for ; Mon, 29 Jul 2024 07:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263015; x=1722867815; 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=w6K3rvuzx+kcxCA/RkAijYB8PiaVxGHgknWl7+W2h8I=; b=gh+cJ9RG4KQPgl0WRxf4fQdgXTM8OYvorFWaHM3OodRyCEfwQtxazriMLC40D5772E SYFNi9tqjxYQRhz+DdsRmb6K1k5EpfbUfP3S2i09RMhWvlzzC6mtyllLgXby9seJx3VS ur/kWa+d020JKDLGurfFBWpwUvZIQXhR3verT4BneX/6JebngVRhUuENEUNXedwoxkhE OSD9Xsz0L6xthPZcS7wW0aaMMOGOwt2Usk/AGj8mkoSnSO1StuZsCXoGNWlJpqUtsKKe WkaBLnkXPYXGiDFSFnE7PlWI1aSjbhC2GEx0h2ZJWm/DFSx5Djt6zq5QFxGxM5wChSeN uQNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263015; x=1722867815; 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=w6K3rvuzx+kcxCA/RkAijYB8PiaVxGHgknWl7+W2h8I=; b=H4wWd3zzUftTA3Wkhgz5+ml1N5fnmkJN4uFpQ6IFjQgvj0O/yUHBxyjvoTqsPe6TZB +wN+eZE5z8tMkKnB8VXtH+kDIPyM1wK1u/6HO5YisO+UBNIahKQWFxfUiQRBpMbvaySa AGGTCl67igSKuD+jPWL8pR5IvivLCsUOR+fZv/eESRSA3yT0tszhCx+CFEHqH6q3PVYG jaoak5jD1DHeObtg3oF9KxGLaEjfwDeW9LSKWl+59jHgXQSidiXaa5pMdBtUbF7ztbB7 x2xf5xiZUNgDLwkJMpSDplK2cZe/9QdibPA9O26llfjbsmQJL7lBq6t9lsdpWxXsi3Bx krIQ== X-Forwarded-Encrypted: i=1; AJvYcCXGWLM5MCTiqj2zAQe9/ZkjccUlM6PDA6ZyxEA/6kIdjRTjakMggVJuKMAlqXHpWZcCihvSxO+RZ066lZYFFACjrY6PMoO5w1EGWl2O9y7i X-Gm-Message-State: AOJu0YwOnT21OuNR/IjH217lA04v+kygyezV83Np/9KqrQgG/U/Oe9/B GmGiP/KhjPxqY6ifdscb0LsJFGbQJ0yHBzpt1KkNsaFyaA4D4om4hosiB6a59BI= X-Google-Smtp-Source: AGHT+IHuqnyr1wGz5leAhutHIAJO97R4WBnGGYBJopHkXMNgwgilRpOmng0OCq0p9dkCz8Wkxaglow== X-Received: by 2002:a17:903:8d0:b0:1fd:9105:7dd3 with SMTP id d9443c01a7336-1ff049711f5mr56820415ad.64.1722263014706; Mon, 29 Jul 2024 07:23:34 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:34 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 07/17] ACPI: bus: Add RINTC IRQ model for RISC-V Date: Mon, 29 Jul 2024 19:52:29 +0530 Message-ID: <20240729142241.733357-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072335_509280_27FE6FD2 X-CRM114-Status: GOOD ( 10.21 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745097 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 1EFF6C3DA61 for ; Mon, 29 Jul 2024 14:40:10 +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=ylEQeJ3Q6LsWdLo8noJb17ZvBeGjqCgj/kNDJrHZXzU=; b=C+EOatcG2gIGT0 oPtHwnAM5Y9zTcpzRdQPDi3KfeYZ6XbTUVWl5wcO8IWnp+rOvJHsGLDeBQSerRyLu61oAQkSiFeQV 4MvlFIKFqvG/l/JYri4JUZGp80dnPLdzSVVSqDyjXzI7nxHpRF7mVmB6CZUAF8hmLhWLTXh2DIFjZ 6JsUOgxJy8SlDlWLEBLx4Cq+X7f15FtL5nnGVl600s0n74aXDnFnEMYfg2qnF2DgdgKTCVVUq5RHv Ho0Zqve2CTRhdzzfCi7Pn3bxQayCimQ9GPRW/e2p7eoLgZ4jvcq9JViNRn7WBtVKI643D7hytkvDe gLFZXAYMzNUK7bHCzRSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRXi-0000000BfzB-2rFL; Mon, 29 Jul 2024 14:40:06 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHo-0000000BYno-3Fo7 for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:42 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1fd70ba6a15so19918595ad.0 for ; Mon, 29 Jul 2024 07:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263020; x=1722867820; 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=SFDunmtzDxNSJrEf+jYEf48MjjKh1U2DF8SfSHqhi3s=; b=nOOVv3UsoUD63dyHUjfSFKbXj41XwcYINO2FnzVMsoklr+1chJVadoJYj50iOs4Vnn S1xE0AbSZCC+al9+ZtWZcSd3p/pKAQ44VYQ02aOF4lZCoZXmXHOuQTrFFWSOK5KBMVlL 2h+3KNBUdnOYvgzIwtc5p5X1HM6iZtD5dAcKs4URwxb/ViYsUY+AKv2QUTp3nmZ7nHT4 W4pjZo2UsBt6ctNjCqkYC9VeOh5muMd2++VLx1Q4KZUhNB1Q9GUL9RRmzRRgh4cYA4a4 ww1lAvCc3ENmLW+GJHo/xjz30fDqqVrNb3fVGvuuIpHHToD2TtkafD/82vIwMY6EJfTL L1Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263020; x=1722867820; 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=SFDunmtzDxNSJrEf+jYEf48MjjKh1U2DF8SfSHqhi3s=; b=F1UK2mGP5oBH8QHhgKJHfaZ5R5XC/CRvRIooDrcrt/46xHjR+mGctTNf/jW1gvvjWk EPmJsWIkzomzNDv9ei/BHR/1DeDEnO5f6mPaUV5ecqTorEAtWjF9GQNTxcB7aEvPhoez /cPMALTdPCwshqkpCOp0PFr2mbzLUx80dbXXERMSbhJF81MWcIL0UvdzuzJgvKxc2K8g +zq3XFTnziL83hNroEc/VT4ExmykXlOi5w27wrjEH+b6FHUA6l4FsKmvRckyFhbtxKsu /jH2t7nPc6LDZmLvHnxBZt59xiQTa+njzS/YM3k60mjUTqH/mFaTK1iA/nEp/all/1nA ODkw== X-Forwarded-Encrypted: i=1; AJvYcCXOz7kyAfcMAvk7KW06v4cwrGBWyF78GM3PRpnLlmsT6DGNy/7M3U9rJEqRT6WYWfRoPjavTh0aBItMceeAE5zf0KmM+878odSS5FFfD36w X-Gm-Message-State: AOJu0YxrXjCB5eiJZu6nkBN0aGKte8gKxCH24YFk+tmbH5zEjUZrp/TD cwoCM36O6qwUKJ1yjg+fw3Zf5wX3owUyIqAb3kmHONfhhI3kL+x6J91lP9uCk4k= X-Google-Smtp-Source: AGHT+IGU3odbD3sPqAp4C/YNgby17mm2kU5A273xs06JOeimMLExymMBUikKyGUV8C6cXEETPaqERA== X-Received: by 2002:a17:902:e84a:b0:1fb:82f5:6641 with SMTP id d9443c01a7336-1ff0481bb94mr68486545ad.23.1722263020193; Mon, 29 Jul 2024 07:23:40 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:39 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 08/17] ACPI: pci_link: Clear the dependencies after probe Date: Mon, 29 Jul 2024 19:52:30 +0530 Message-ID: <20240729142241.733357-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072340_852230_F37B3211 X-CRM114-Status: GOOD ( 10.50 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 added between Link device and PCI Host Bridge, then the PCI end points can get probed prior to link device, unable to get mapping for INTx. So, add the link device's HID to dependency honor list and also clear it after its probe. Signed-off-by: Sunil V L --- drivers/acpi/pci_link.c | 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 Jul 29 14:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745098 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 B5DF4C3DA61 for ; Mon, 29 Jul 2024 14:40:29 +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=2/VjKFwP+/lyfwmrQ/cRanheqSUVnnX/d6Fa7J3RRA4=; b=LmQOLfV9979IiQ e0jEI1yfAOBEL/BP40erjBeIpIC13XauLK7gBlWR/a5UcGVPC3b2VXYoLCsdaY/B7AA//qZISwcPy 2GIKkmwKuDtgEJCjxYqlCHRHcWMECrvqLGmzuOkEbhnFT8BGAMsVh3CmT3K86EOMnmOxeq44Zg4re YHQm6O7r/+2xVQ8XPunFALS8kTJw2YF5d8tC0wYUxx/GRxxOBeXook8H6XW1JfnvIHEEt9MC7HRzK U4szWcYgTlqLMaP3bTB7z8cDiXkiCQ7ZEEMnW0CtjjnJFvA7TU//NILZmKU8IlIHjMXLjys6Xks7D gOFC0VWyuSTsCz3yjStg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRY3-0000000Bg9h-0vWH; Mon, 29 Jul 2024 14:40:27 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRHv-0000000BYqx-0vf3 for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:49 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1fc65329979so25472375ad.0 for ; Mon, 29 Jul 2024 07:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263026; x=1722867826; 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=wik61eI9STwwE7HFXon2+/PZ3nVDVD4F5v9olaEmjiw=; b=knmalRYOEDeanc48pmrS6kBYS9bKFQi3+sG4lg/qK+81GkT+xYCxIS1zAP5M+r6OwQ Xcou9yKnGrwaoCShMmKWosQRz7mTQHkZ5o36HLPoAXSWclRmx6AM4wRT+YqOtndabcmz lIdTpyEYVd3SOyWxzphU6SEet5Agk6trsgu6JmnnRqlDOxXpP3qlpaYBkHhp/eCa5TJl 421VTFeMEVyH83yCYbMPGa5hBeyABKyrwfVGmzkQH0McELxT9eMH9bM3aFOcLEm/ctIo ddpUw8mD78+V65LjPt4UQDvdNprNBC/f9UrJqtlum3lHVxhdvobqsl/97Ynpx3TUmy8Z 1xKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263026; x=1722867826; 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=wik61eI9STwwE7HFXon2+/PZ3nVDVD4F5v9olaEmjiw=; b=xEAAk9TLRSD3M4d4Wl6GzGhXSFilZdZG4M4+gkXJpML/hK7j2gykdxX5qSAxfV5iU6 wXkLIGRNCVZ4aYxmGUqaprRXwiwBUyu2G3WeykgPxGBIwS2tAOlVTYf3l/ywzntUtvus 1NnIam5kAdmGLoCvlFzdHMHArw7Sk1uvh409sK5qgpSM3sSTpkU3yK3yssNr0F4KA58t DAIbHYPbAe5iq94MEroVJVLE6qUFwultl62+Yf+z0QNLM2YpnkebLpPCR07bD7oykT21 NJtQMCAonMb0GSCnEVihg27zA6i4GmhG/njp4OJmiHXzESK5oI/V/tQ1tdMkG1GJAUa1 SrMg== X-Forwarded-Encrypted: i=1; AJvYcCWaXT8mXUXiwcvaSD4xW0pl2Jzc3+w2ZVvdDHiX52xOfewDI123PHAI4NhPgSzFZl0Lp/S3eniTpWLUllICvGpNLBBblfIzMwMmCIya+j6O X-Gm-Message-State: AOJu0YwMLkUXMgTQvhAXaov3hDF5UNCw4BxRNVYVLFPaJTSnOuDsjeye KBApKGleJQxQDvjb7wPR7l7Qzw+/u/QwPv02qPqirAy1El7sQKMvrBPCOVPRp9U= X-Google-Smtp-Source: AGHT+IE3ECdlWv0nwo/WvLQaYyG8zcevZP66vRc2T+ol778my9cQeDUxkiVxja9PHSoePX+A01NXaQ== X-Received: by 2002:a17:902:dace:b0:1fa:b7ea:9f0f with SMTP id d9443c01a7336-1ff047fed8fmr110813265ad.7.1722263026091; Mon, 29 Jul 2024 07:23:46 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:45 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 09/17] ACPI: RISC-V: Implement PCI related functionality Date: Mon, 29 Jul 2024 19:52:31 +0530 Message-ID: <20240729142241.733357-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072347_352794_24A3757F X-CRM114-Status: GOOD ( 13.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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745099 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 95520C3DA4A for ; Mon, 29 Jul 2024 14:40:30 +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=VEpChhi0TgK/35qNuPdmSWXVNpO+65V2bDt/ktQbWhM=; b=ZIFn1df/9eYTns 5jtaaT+qRgcNKp61YetqFVBLy8amZxTGPXh0Ao4kOul9RiRIlJon/IVFo49JtMvqXAAXpoiMerPNE MUrySh3wY+Uf5pf00kqIERmyE0D+morkOpzINo3/YriOKHvP6bI/yx2sclSQNnPtc7RUdH3FryUeT f9r11+wQrvJhJBFhOY3kSTT6G/M8lbhw8iMzDF7qdNbr2LR3Px5X8G6zi5edQUMC0cCFEL+Vhdd/2 hQCX+1xnwqQZ/EA5javI5Amy+CUoHZ06qS0HA4Z4RZyt17vIPGGLvuq2phFUI9gsR+6fqNJOpHmTD eNBDlApfTrfy5eR2hUuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRY4-0000000BgAI-06ga; Mon, 29 Jul 2024 14:40:28 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRI0-0000000BYud-0zG6 for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:23:53 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1fda7fa60a9so28832465ad.3 for ; Mon, 29 Jul 2024 07:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263032; x=1722867832; 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=JbM0a+feX6KT++9LC9tUXyb/bLPakmTLy8AENK3qxq4=; b=njtDhEk4Wvc64or7d5sMwyM28mLkg6FOnldPvyQI2IydXqJb/mGlS+0/LjhCmh+UtE cFv8++qiVd1UfcIV5wpBHrfiwBVq1au8H/nx7RZinLPlnFPAdvfdUZ4pixN0FIsxiWcN 0yhTOj9MBRNAPNY6PEJSX2+C0hg7btC4e2A/OA4v4TzcQJVCFYYWZ+m8ypakNZ8hGwgV 4F2FGIcqDGqMtbJvShPKfD3Ri/MFsHm5OhKMOjozBvvbDwWOfoZijeZLU2vF7sW2uoau acreoulj5NjMdf0ABfZvjSeEoBmsevcFFqluiAMY3Kkn9BRP5gYRj7+PgjoUYpg5L788 tw8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263032; x=1722867832; 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=JbM0a+feX6KT++9LC9tUXyb/bLPakmTLy8AENK3qxq4=; b=cj8RJ0UuHKssIJ5r9AsANheqSq3mcUBS0KZrqw568rfKPntlRF9UXwn/BzlzmEMxYz V67Oy+3ABANoEinjJ6BGJTV+ZPQOjLGmZziPZkj7HL+R0vzFa7AleuUFlxqx2BXhScQ0 bPuS+b27nHD4Ln60lONBTtFX+wF1gMXqJ7MPZOU1b04T+F3hTwetEsRxSQpK7usH1u+z /oapwnnzDjnWpt1x21U6Org++Y9bwu3wT/gj+39pYb52yuDefr3oAdz8ta2yWRql0WVA +ek66q2KFH2WGXiD7a4CIihGpPXxmOVNbVUVCvL4uAWCGdhst3zB+8uqPL1W6DRqsoaP 4QEw== X-Forwarded-Encrypted: i=1; AJvYcCWVM32qTqNLCDUx0iwm22x2YCZczMhZ19THO1MxR5+Xk5ZEQPHuLMr4TmR8mx6zWzrFr3Jt0r/8WkIR9SKlRRlMo1k5faOG7u2MfuaC8ZFP X-Gm-Message-State: AOJu0YzcpDKoBxDKN13tl5L2dbu3rIV1NXbOu4hEGzs8a1Tbpd838Pb8 YaIHZBtZrK5zY+9qWJsz6Axi6cAcWCrtrCvB/4Q0xVJaExaN86xUjR4zpmoJEjQ= X-Google-Smtp-Source: AGHT+IFH4IFEEqFnFuD3LFxB9/YGdoZ1voAL0RS56DOiFLXrkbkYEDIaLZyWRT2+lCXe+UQYlpMB3Q== X-Received: by 2002:a17:902:d4ce:b0:1fd:a360:447b with SMTP id d9443c01a7336-1ff048b7daemr104566225ad.52.1722263031612; Mon, 29 Jul 2024 07:23:51 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:51 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 10/17] ACPI: RISC-V: Implement function to reorder irqchip probe entries Date: Mon, 29 Jul 2024 19:52:32 +0530 Message-ID: <20240729142241.733357-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072352_320466_0473E788 X-CRM114-Status: GOOD ( 15.99 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745100 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 38625C3DA61 for ; Mon, 29 Jul 2024 14:40:55 +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=XE2rl6QhMG8lv6RaRiYs4Rc252e8c1zJ//cEKYlNjZs=; b=4B4HwH/rLpt8sv MFN21mweOCbb4n0H33gN64Lr9xKwssvrwKBEAnxSR9ES1+ky1xrmjLXBvwVETX/uR9xOnQfS1QEoz uci0spsY9uaCF/6xnUbF0dTVhx9w/EY9C5WdBK0+UxM6zaOmJ4ZnmD2BX6aKt4p6ynfKqZYGss2Ww uAF8AJCmjjSKNMhS9kCDIL3pBKkveAOnSGsjuUSToD5S8CcCb60jn0GuFIuxWvkUcQ49Hem5nyITy TuhY662HyxOgaJNLpK9Y6gIfDzqOXOWUCVz1RwoFGcKSHX7u4JivNPRmutiAc4Ze2BOaMWyw6ctNb haV/0Q4eQ1DyCh+xOyZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRYQ-0000000BgLc-08Pz; Mon, 29 Jul 2024 14:40:50 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRI6-0000000BYxB-1P79 for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:24:00 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-70eb73a9f14so2489600b3a.2 for ; Mon, 29 Jul 2024 07:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263037; x=1722867837; 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=faQAT1JYz4uKgs1JiW6v4seMVdvUx1pSLIJRc+OrnCU=; b=E7VxPWZ3hFMb9xY+PxhaUEYmlju58fvyfusSiuOtjwr9T2NFWTRnaM2bxtNIC8nLkH tXm67J3QiRht34RWEY6TCi8buBlrhevwBn8dNX2TfXdniK9AohF3LJP+T+hZZ7M0QUiF 1N0KhzqmmVNOUl690+6Oc/5Oom2/wiPTyeQEsGD1duxKgM77wyLM1w10gRsXRVDGIAmQ Y5faWhE7JSVfQkD4HZ/seXqiRH/nTbXVsXVkwrqtHMuipg8hs/ESHC/aH5edNORVRIsJ N5M80QssNKXHNgHGeCh+LmxS0nbNoU1NZiHmA0jEsetNJeSoEj/d0Iq/xPQKjtNgxHiM Px6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263037; x=1722867837; 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=faQAT1JYz4uKgs1JiW6v4seMVdvUx1pSLIJRc+OrnCU=; b=OO3KGP3XNfUNm4BRMyoZsyMVx4tKYbk2WxCrYP7jZrsooTjwZLhQiQmkM/zv53zdD+ l3++3SD1DItUr90axMJTuwdrZ14zAOD3suI02yKGM1lbynQfqOEdiEPjcJGEdMatrgvV 1ORFlNgMkvcRAwqcBMwRJXrSRD9smChMcX7AUjhVQzzhHe2o3yB7B4uiP12NbeB+Sn2E gcr2drQDOr4eCHiodsMCvGPlarQG03Os6kDEky7OrOPHLt4gBVHRko3Qt8DrY8oDwvS7 bL5OIUU8F1j7HG48FIDqMZ6cfWTqzRqMTiGw9vOHDppLr5+boE585fhcL7GWcNIrWgr0 aQaA== X-Forwarded-Encrypted: i=1; AJvYcCX5y5khmzcKIEm4bEmjksfZx1e6NxZ3GKbfSpfi1GMfUxDgtJMJVts6tYFGNEZQImZH+G2iIpoK1N94DtQU/1CLLyVIS4j2tsdjXoJd5xrY X-Gm-Message-State: AOJu0YyhJ8Crws5iNN45pkRQZWMdqp4XPqbh38IP14VOpdEEhTQb3Rrp 6dVEzGm47cOLg1qeLIoXZqcP1rg74U8GbT5Q+6OoujIuG1t4y/c0+PTCdko9nCU= X-Google-Smtp-Source: AGHT+IHlNJOaWOv9P6EA+WSzfVqrKSPrT5Gc2L8g3dIqAtwsXWtcNKuiNkZFmX1M/bo3S6ce4Gfr2g== X-Received: by 2002:a05:6a20:4394:b0:1be:e6d8:756e with SMTP id adf61e73a8af0-1c4a1512bf4mr10901917637.53.1722263037394; Mon, 29 Jul 2024 07:23:57 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23: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-pci@vger.kernel.org Subject: [PATCH v7 11/17] ACPI: RISC-V: Initialize GSI mapping structures Date: Mon, 29 Jul 2024 19:52:33 +0530 Message-ID: <20240729142241.733357-12-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072358_408199_155821F2 X-CRM114-Status: GOOD ( 19.90 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Haibo Xu , "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 5f7571143245..22db97f7a772 100644 --- a/drivers/acpi/riscv/init.c +++ b/drivers/acpi/riscv/init.c @@ -6,7 +6,9 @@ */ #include +#include "init.h" void __init acpi_riscv_init(void) { + riscv_acpi_init_gsi_mapping(); } diff --git a/drivers/acpi/riscv/init.h b/drivers/acpi/riscv/init.h new file mode 100644 index 000000000000..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 Jul 29 14:22:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745101 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 5E289C3DA4A for ; Mon, 29 Jul 2024 14:41:03 +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=WcmA5He6jOtEGQYpEV2Z+5ZAXMlrj5kxvFHcf1LbuOw=; b=lmqq9NcVsJE7gI cvSYhBcOaiKP2vZbzgdcxMIRHZJ1CeKLSgJizJ+japwPbTt7J0UFwvibr+0smoqTK+lI+IHndX0l/ vgkkRQcoy+xtft8PyKLgm587BW87wtKJzlmaUoiTblpfIaCxQNSkNr+Nh+uMtJDEGiG3Cx2UhWpC2 1EhQTgT6TZSan1LDIBuOTeXVF20OGhUcVV3IQht2446Ct4RuWNThp4uiQmOTg2giuExGCmdzb/smf MBb4vTPAdgssJdnVMSVLL5TPUS0sRU/I8OsMT18jeo7AOAdI/OPEVcO80qv1tGzvVsJcXlrMPFUn4 +sapzlWbC+pxbYq1j/2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRYa-0000000BgRK-247b; Mon, 29 Jul 2024 14:41:00 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRIB-0000000BYzV-3Vxz for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:24:06 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1fc6ee64512so19636165ad.0 for ; Mon, 29 Jul 2024 07:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263043; x=1722867843; 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=7lh+FxZ2Oaqm6/wZ61/7rTE9jIlv42s4WyHVAKuIs34=; b=lk6gEtDcqsTTDL1I+FWXIwQaFcM0ZNYGBflchSpmFWP34FgglJz+Us/udI+bTuVa2g olUEpn46dOjf1LiVGzlu4nMUff/XgWDIjKW1x8dXSWpRZDVX/dSt1VkqEplo6Sr2/2ip AuMm2L6gJCXoQuFhSdAiNIwqpvwaRkLN+joLRma826ooRhjlOnrWZu/od3t0jDHza2BT mf+ffoJBRV3H1UoIU1Q2fEEdFVWdX816RNqEtaQ7gJcZNUIRdHROh7iPq/bxtJ+5/tfz ag0dP/oroH3LVKh5We2exhG7zJ1VFm2aWkGBaQ9xTFLz2PGvGDFl3BapRpIAjbRQ+7qw dSHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263043; x=1722867843; 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=7lh+FxZ2Oaqm6/wZ61/7rTE9jIlv42s4WyHVAKuIs34=; b=B/iGjC0mBTlvQ1OMm+C+kJfOWXjcZB/m3032D7P83vLeO8LA6DC0UV30Jkbz/+uDou mWpJA/95cSp3seOlP/ao0VO7hznqSwcXvS1NsLNH1p+zdxZByNilE7Pr0AUI+XElVqPR 2n4fMB4R+/V0j97QaHrDvKcAJMVAdiI7UDEUpUu90R7NkSdJrfRha7YZvDBglGKDkLvX 9aR9ERhyRKJxeiNNkSlW+t4R5N3kEbyfc9lcrMIrG6MsVv5bmQwHgI5yB4s7Aad1f5hO bFMVDcXPBBgK2gLkUILEWNlFJmVlgpDATPNnidvypWrCXftdL2n13p6IGAJAmsIggaCr fCdg== X-Forwarded-Encrypted: i=1; AJvYcCX5Pk2Q1ulttbYeGLG87A/HaWwMwC8YX/dGPBAG/4h0XxovY4zNQM2XpXlJI4ZXwvaUSurCOOyoJt6+54RmboeKnXZhckhp4VoH1VuNnkaZ X-Gm-Message-State: AOJu0YwQLwBjulPo4QiT+SNnz0NIWOqlQV/tAR2Yfu33rCrbVvMqgUEi nnOVcAMZtklVh9B7INpuivGgVPtFT6OnImNr5e8psj+ToDwRsVCWpvYii9tRuvU= X-Google-Smtp-Source: AGHT+IHcJJ7ZUpRxIoDgsE0liV0w2H+LBbMjTY1pRliLvaH8zHgZTiy3qiBM12OS8Q+p8MlCNj4oPg== X-Received: by 2002:a17:902:d4c6:b0:1fd:73e6:83ce with SMTP id d9443c01a7336-1ff046eca8bmr56689045ad.0.1722263043208; Mon, 29 Jul 2024 07:24:03 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24: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-pci@vger.kernel.org Subject: [PATCH v7 12/17] ACPI: RISC-V: Implement function to add implicit dependencies Date: Mon, 29 Jul 2024 19:52:34 +0530 Message-ID: <20240729142241.733357-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072404_024057_AD19A051 X-CRM114-Status: GOOD ( 19.74 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745102 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 E794EC3DA61 for ; Mon, 29 Jul 2024 14:41:13 +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=Rsmq2mB9nb45q7AIYRF4zvPRhZKNj2Wa8/C2vYBKhQY=; b=I4RSt84m95foyz A7O0pn3rlQjjqLb69ERl2VRy0Q7caOWrCuI+5r3DhALGZM4RZ1acb83xRQHckIt/zLwOnh+PfCAlX IbG4svBJZAZ+JfpgQtPrJnBCa8ydk1C6mTMRqTxbqh7OmqQMLPe8rht//BimcdMVOc8qlDAtMvXrW Gws6YXWpAdt+bwfmrFrfLD2Lo86g74grZ8ICWUDBjjBdpBZm263wtXl0ciTpDVQCK2tDLTG5tfrLW AdvJ3nRoWSKbuZwGmV9/emE2zbKS/VgsgyeYD8+Qaq7HDrK7Bb1t5noelOpJaxIFcPq1mx5mEwvYx a5//FSHBdnB9mAkI1vIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRYl-0000000BgWr-1heI; Mon, 29 Jul 2024 14:41:11 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRIH-0000000BZ3A-3sjF for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:24:11 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1fc60c3ead4so18747845ad.0 for ; Mon, 29 Jul 2024 07:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263049; x=1722867849; 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=kYlVQjcWuKOe+NFOp1Wh7i++2nCqItwyO/PCNQ13gxs=; b=Nu9q6qEev5nLb6JlwCrNAkc5BAUE50j88pXj5AYeWN/fPE7xfb9OKvjOKyC0SPkBcZ oXrKXf4G72nBwovI6IAWrqXfanHoX31nGIIt+PS2y4t8C2u5y+LpqFAdmbnjx7DfBC8G nIoryvEm61PgR73SbxsOpJBIjQeGMNjWKoJvz9NSa2HA84IDzrts3EH+UTVnNZHoL9kO S4jA7eeuoFZgXGx5NjPfiKwy6f24pKbvHP9zA5xIbxLYxIzLlCNk0nf8d890QadHlSF5 8FlpPrWeoWNNFOAdVSnphxfJCBIH74ryYQLCD6HmuXXq0ExksZYpfwEJo9WuJ6Kcv0Ht ZOXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263049; x=1722867849; 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=kYlVQjcWuKOe+NFOp1Wh7i++2nCqItwyO/PCNQ13gxs=; b=YdzRzeB1oDn+1rYIamHpWnqUEBpvq7N+i0fjKzcmOyeYabeNdlQu8+79UrwyX/6W3L d36KJNZkKo1YqEwPBp9zEMgpFVnPC5D29Gthfy344X3Qkbla9i+uiiBrxdP+h+we7RnL Df1HZbgqQkC2kzFt/BS1r6laTO4zMkhjhNkgmZL/t5buj51ptRahx1GVyMculvhaJL26 hundhd+JuvEv78BGVHfHh1PIMaFDseLAt2637oJThz1xpRYeCVLuK0nWzGLJQSAdsGoi K/NjWDXZhAO+d2BRUCIlURAK09CjkLzU33gJMDu+C3RqmNWQ051w7cxVgF3nyKHeMjKA Pq8w== X-Forwarded-Encrypted: i=1; AJvYcCWbNOL7sV1y47AE80MpjpXJU8LLMcZzLS5h6B5d8Jfzx2LC5JrBP2Jfw1uuy0azHYTuzyeCXkfv7gOTs7+Z/YWP7tgf+htclz0/v6I+WgIZ X-Gm-Message-State: AOJu0YzteYndO8PgLo8BfiQ6VQkTiA0ktTMnQpIosnWpaZ5jpk10k/C1 j2gqNXAFyvQKG6ixoBlmG50Pt2GV/0ep+K9VPswI5Tq261iBPZdYALjXH4AXuAs= X-Google-Smtp-Source: AGHT+IHv8OfHL+oywHkMVCyqgu6uiipWK5S4kQQJeyBrieT8AIn2g14TSQmHke4oYp0sVgW17J6yFA== X-Received: by 2002:a17:902:fc46:b0:1ff:52c:34ce with SMTP id d9443c01a7336-1ff052c3e33mr60989715ad.53.1722263048905; Mon, 29 Jul 2024 07:24:08 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24: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-pci@vger.kernel.org Subject: [PATCH v7 13/17] irqchip/riscv-intc: Add ACPI support for AIA Date: Mon, 29 Jul 2024 19:52:35 +0530 Message-ID: <20240729142241.733357-14-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072410_008923_75316F44 X-CRM114-Status: GOOD ( 15.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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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..51d86f0b80d2 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_get_intc_index_hartid(u32 index); +unsigned long acpi_get_ext_intc_parent_hartid(unsigned int plic_id, unsigned int ctxt_idx); +unsigned int acpi_get_plic_nr_contexts(unsigned int plic_id); +unsigned int acpi_get_plic_context(unsigned int plic_id, unsigned int ctxt_idx); +int __init acpi_get_imsic_mmio_info(u32 index, struct resource *res); #else static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, @@ -36,6 +43,32 @@ static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi return 0; } +static inline unsigned long acpi_get_intc_index_hartid(u32 index) +{ + return INVALID_HARTID; +} + +static inline unsigned long acpi_get_ext_intc_parent_hartid(unsigned int plic_id, + unsigned int ctxt_idx) +{ + return INVALID_HARTID; +} + +static inline unsigned int acpi_get_plic_nr_contexts(unsigned int plic_id) +{ + return INVALID_CONTEXT; +} + +static inline unsigned int acpi_get_plic_context(unsigned int plic_id, unsigned int ctxt_idx) +{ + return INVALID_CONTEXT; +} + +static inline int __init acpi_get_imsic_mmio_info(u32 index, struct resource *res) +{ + return 0; +} + #endif /* CONFIG_ACPI */ #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 47f3200476da..5ddb12ce8b97 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_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_get_ext_intc_parent_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_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_get_intc_index_hartid(u32 index) +{ + return index >= nr_rintc ? INVALID_HARTID : rintc_acpi_data[index]->hart_id; +} + +int acpi_get_imsic_mmio_info(u32 index, struct resource *res) +{ + if (index >= nr_rintc) + return -1; + + res->start = rintc_acpi_data[index]->imsic_addr; + res->end = res->start + rintc_acpi_data[index]->imsic_size - 1; + res->flags = IORESOURCE_MEM; + return 0; +} + static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, const unsigned long end) { @@ -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 Jul 29 14:22:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745103 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 5AFA4C3DA4A for ; Mon, 29 Jul 2024 14:41:15 +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=tDnHETQiQtuQGhWNmFkc1qgTruNf1MAsXcKn+Li4EEk=; b=F8c1zUiNed7l6y GObmNNQQRJtZabON040ZYfYSojLJlJKJ/BUCd+7xgDN9KKGGMC09OCo85lZ8nbchfU1/BYgiMqYpK uJ/+dzZFJwBcfqBI/F+Vo82ou1YrvlykcW7BrQjifgivT6KU1uoP04sWx3/XOeXdVdLgI7LL5QuQk pvV+TXCVRxRnGWL59VEfIUR6X+RR0VVbNaT4O22iRvj0hqZIhOHfszspOnhiIsKjvIDZIuU0SQf9X kudbWxD5B2+k4NwMWOzfCwir6HLEo2RscuAyWPLN105HUACX7ln+LXrIRdblcWWpsfjSAlZTZiEkV KIzCTuJIaRm7sDvWliHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRYm-0000000BgXV-2WlK; Mon, 29 Jul 2024 14:41:12 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRIN-0000000BZ6H-0ndL for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:24:16 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1fc49c0aaffso18640765ad.3 for ; Mon, 29 Jul 2024 07:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263054; x=1722867854; 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=S+3yiupMcqBHVKtDhH7R825y7QwUyIVJicMeCQk9e3U=; b=Csd9LRGBJ8AqZaWzPQIDT/I/mQk7vE/hJNVk/9xSsmZTpK0N+HFVhFZ88kbLyy6AMM TIvDRqlzXc8uPWM2RaTWmUA8mFor+6V6XVRsb+60L9MJ/di4sfsKrjjs60BUT7AOhINC C+6dD5dk7XDXSoYO9gze9z5NjfpyGlSs353OL7Ba4TUckZgF3Gc6HmpkM6dgtZFkHZx+ 5PF+ed8po8TrrMMpI2YupRO0bmyOOhQ0NtXCo5Sy/buOk7w+sL1/bvFvKUwuom3IoCwN w1IV4LpHnwvb0W8Z5zz/01MfZ8Y9UKyXU9mCKuOmgCNh5YuRwVODwy/J9KAobWf9lawd eXxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263054; x=1722867854; 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=S+3yiupMcqBHVKtDhH7R825y7QwUyIVJicMeCQk9e3U=; b=en0sjlVqEG4e23vs4wH5juLE/h80tzX4yx+NSFutfEOeDI/ckOnfh+pNOTwQc6D40S /wtUleOzz3/W1SUEiNJAjTKjN4X1O+6T+nG9l21gjLF14i2ttu9bZ0vfrj2CZsEW4GHM 7v/xL8MwIe0+XktbM8rzUZUPXmwojewjxGLOr3MyhJKjun/7iYbmmT+K4oek5HeUp5q8 m0j4hqW+Jr5y+p7/3I4jKO078YUwQ4WJnuUUrcF+bSpx7cvTH3lHoEQ4Fy425wQztLcF rrvjjhctsdW83rSGi8ztGEjWpw30Ls/uK4l8UhIL4rxALqGYXLq5JtAFVdydQSjAdeZ5 iI0Q== X-Forwarded-Encrypted: i=1; AJvYcCVOvtzWIotfwj/ko/vK0Ho0u1Ul5KiXnLruM0FdCiv4m+hGIwsiGBPTOGLAM5k9kRdIZagYenyAeMfS0I/57uoJJIM4Ne/nonOmKGC0EqOy X-Gm-Message-State: AOJu0YxVgAZ5P/2ZgFyezbwFI8rKFiNvlOuWVyXu1wNXoFjLoQ5n/MSj g6RCGY00remNjUMvLNTgyDg0WTWYgJSoxtoZpgFFIEAGEX83ycPMcDpvrpB3ULs= X-Google-Smtp-Source: AGHT+IFyyx8DenY+eymy3lA0x+mYXtwZv9suwKy/4HPR4IzJLW5mFsnZTjAN7/+4Xj4Bjaq4qxjxyA== X-Received: by 2002:a17:902:ec8d:b0:1fd:6f24:efb2 with SMTP id d9443c01a7336-1ff0481a419mr65542815ad.19.1722263054397; Mon, 29 Jul 2024 07:24:14 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:13 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 14/17] irqchip/riscv-imsic-state: Create separate function for DT Date: Mon, 29 Jul 2024 19:52:36 +0530 Message-ID: <20240729142241.733357-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072415_271253_494F17A8 X-CRM114-Status: GOOD ( 15.46 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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 Jul 29 14:22:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745104 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 F3E47C3DA4A for ; Mon, 29 Jul 2024 14:41:25 +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=KnoKWTAjvAAOwWsplnNiaheAqV7JJuoV0NghyLXycVc=; b=cBwOihx+xnFltI nh5ccVYgzI1rs4JXL7fRTs3TsLG+kacVsyGxwEL7+WNQtJbGgVf6kGB0bStN3TH8cNcBt6p7brEZ7 xfkXtMQNyKFZzvmktp5D16FDjFYsQqVPkrej1N6lY9vY8dr5Jp3yBDVgbVlHWiFyY4uc9pAU+d3lj EYxOfMMrH87l8Y0ogYzUOGhtjgKpGpL9CjCycxmIqxyN2Pf29lEZ8IY5gyvXwLaRHOQCA0ILoR2tJ A+KE0ohUpEqpYIB4x32T6kLQX7zEeAxL4eQBcGvXcKq5cmxpTA0m5cfKBhAP2eulY0kU9wIyoS47C /Kuyr06zP5qLJ2lC1bTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRYx-0000000BgfW-09zc; Mon, 29 Jul 2024 14:41:23 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRIS-0000000BZ9r-3kRl for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:24:22 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1fd69e44596so20650295ad.1 for ; Mon, 29 Jul 2024 07:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263060; x=1722867860; 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=tEavi2oCbfZUL041rDq3pUhsFVNcsCR7JV/lSvs1zjE=; b=JZX5psNxQQ2l/am67ZcAT7yNFjsSYll5aXuUFvdSJ0GfJEs85pl6au/1OVaZRiVJgn dteuj1FoYp4RhtzGcczce5oOZQEy11Pl2m0dYiMdIZdzXyah2XNd2wr7AdMHm8i9Rjnh BppBPdvFHzgJreLY3vgVL6q2pm7vAlMr5tC5gOXuVRMCYfGO3HUCYmt9zpPd4WAVFZ9h /tJy25kgxB2GgQ3Rn6qVnQqXRwsQCDH1S7937MTNuOzIuO6UQQjLw9/qX1zKaGKC4aeL ol8DX8ZhEIqcfsY+ouKIQap+aiUemHiVzB3oRjmw7Mo2iXeMUrkegAUGCWjaP7LUz8hY UObQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263060; x=1722867860; 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=tEavi2oCbfZUL041rDq3pUhsFVNcsCR7JV/lSvs1zjE=; b=RMhLCYjgUDGo7Uh+lKOfys/m9/GkIYIY1PR1EPIczIDwg7AYuYZjXKaxHK0mMGrIsp 6y8UKGZFeMcTRKwuMe3Ew9yj03s8hHUG2sRDfHQ7otL1KmqL6TWy5Lu9cfrDCMBqHK9R Wf69p4HXhkygADiAQbqhRYrNofdNXMzDzWbNNH+lXenlHCclhhGq/ptZFjR4CQGBCQNL pmIQ2qVYDk8d2gczZxt20qQ23hDwiXJtJxkUx01QlNhYmmTr5dmEFgy1docVjuWGR+L4 U8zbJvmk3Q+YH2KUHG3t4aIZAYzX2kRIm3H8iF/41w34Vddn/QbLTBH6JyZV8b/qkd7Y xMYA== X-Forwarded-Encrypted: i=1; AJvYcCVwDN+sCgQ1d93MFOrKjqtnbOLNpySP1UlXE9Q8irhC6oeyOWnlHxUvJ0ZN4cbogZVu4WTKpGjpgwwI014IZwuDE6nc4AyeJWmOsxSZTVxg X-Gm-Message-State: AOJu0YzDO7FatooeacCFEdWUTDA1tqqLEjSDx5HvXhp1Z33iZAuBQOqX yw3oWnIu2sBpfo0/rwylYNDKHrWQkk8o/oqqWvkRzU6BjEhjihQ1mibM+ao8u3s= X-Google-Smtp-Source: AGHT+IHpL4tMIkOEacG2+8mAK1PfaiVTS/v+kCY6IpxY2HmFK244CWhCYJb8BR2pVzEQrYXct8BHbA== X-Received: by 2002:a17:903:22cd:b0:1fb:5f9c:a86c with SMTP id d9443c01a7336-1ff04a23828mr133458135ad.3.1722263060022; Mon, 29 Jul 2024 07:24:20 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:19 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 15/17] irqchip/riscv-imsic: Add ACPI support Date: Mon, 29 Jul 2024 19:52:37 +0530 Message-ID: <20240729142241.733357-16-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072420_996259_6D09A1BC X-CRM114-Status: GOOD ( 25.40 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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..73faa64bffda 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_get_intc_index_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_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 Jul 29 14:22:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745105 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 9CC6EC3DA61 for ; Mon, 29 Jul 2024 14:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wAxpsyFVfAbZ5xY9ZRA2LlnkUDRo8oA0MIVk7UBQ8OQ=; b=GOiTGmh3daL5WG MvmTySkZRRWTEYSxaQCWsxeSt0kEKTovWNWfn9085VgdTDbJyM5JriLLMoRwDBAXd0bkDNBTgSYUO oVzJMhJeeseXRvKTbSu7GHPlJUdRl/54lU1HkjWkH6+uRdK54mz4YYlL4lm4S1UUA2q+HwyCrvWTR 9R3Q4zEW3DW/rpHrY34AQxxD517IX0LVtA2YimK1k4z8WZs11o4R/IWtW2JXGq2ararFPZ/0Ao35N YHMRAmSvMbReCSc1c2Qam0HYhKNAlhSycdzwHOflZoL3yda5T2u2tovqyECtH++S4Q0E7zbmH3Evk SUlQ+tl6sonVAUARs+mQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRZI-0000000BgrK-27tI; Mon, 29 Jul 2024 14:41:44 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRIY-0000000BZCH-11VQ for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:24:27 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1fd70ba6a15so19926405ad.0 for ; Mon, 29 Jul 2024 07:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263065; x=1722867865; 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=GtHN5RSatiirKkuRPrN7Xezrvz6FAse7wNTwc5cY9vQ=; b=CDPxF6LVV5sasQdR+PoDz2iABiu9KNQVZPfA9mb9HkQkHFnLxbDY6Ze7TaSGlmw8mU g0GNbxVoLeB6f+tvWIgtEqanK1c0jgHiBVKOY5NA4OITSKsYvxZov4ZCign4cpU0yFwV jpvx4I94x1BNXCMCwrqQlx74C9dJaMMytrTLfTWA7VvZ9DD0XdEtx6HkB5Vh3+yhppCO 9qv80kB82GKz+9Z/h+6no1KIJ7jb620sDmCEGJ76xqTtDiCvxD9lkxEdfta52rg2xpVM En/cCFcKosuHjmyEQjKJZhco9U8jpkSCo+43CX12SDquktJkvG307Jt2Jm05jcXVYKCF snFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263065; x=1722867865; 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=GtHN5RSatiirKkuRPrN7Xezrvz6FAse7wNTwc5cY9vQ=; b=l9tdEM9BTHY/o19y91Vh4ilRixyHuBzLiwBxnoZJNxxj4N98+KF6jZpuSQTHBI+ZGw i9xSeAVE7kBgU/5TpIs5DtXzUcy943OgaplFaOvFmt+sjzzsBO88Doj708ROc05F/lTV TkBtR3IZTLB12olZe+Z0ErNjgANIm9DaLrDXGpcFc+U9R7GLfeDHZ9LOghg4ly0lyMEd L2tj7nsHmcIOzAh5FA2Pjd4/Wk6xV86C5BclIx2RgJAhacuiswqkyGETvhjRUYXECwE0 +F3N+u/tOcRn6gZWZVs4x6spvYfWu4uNOPt2JXUP9sYJQd/PlyvvqNLOyq/blqBV7E1u qpIg== X-Forwarded-Encrypted: i=1; AJvYcCUa6dWxB5nFmXaW9kzvHA3sl0mhuXA2OVG2PMv3/x36G6k7og+UnMHoU8Whd3s0mRZ6M8P6A6+VI4uz4hp77TWtn86ZvUD0v2+DHzobtdMs X-Gm-Message-State: AOJu0YyH+PgonYKF4pmL0Xx4Ax3sMxV8s51o55Knh1C2ieCGG22Tr37S pM4f1tYZ+Yxz/jFySQOMq6nsz57ApwkXMwXF0vMSpMDRlMUHQqWB/jvfqh4Y7Kc= X-Google-Smtp-Source: AGHT+IFQUf/+EhYfgsVrzK2L/oleohsnmuLKT1iKr9sPO9lBK/mJauG7ujc+tgm88sfndaMqzPY+Eg== X-Received: by 2002:a17:902:eccf:b0:1fb:34ef:4467 with SMTP id d9443c01a7336-1ff048e2267mr57478325ad.43.1722263065556; Mon, 29 Jul 2024 07:24:25 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:25 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH v7 16/17] irqchip/riscv-aplic: Add ACPI support Date: Mon, 29 Jul 2024 19:52:38 +0530 Message-ID: <20240729142241.733357-17-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072426_292490_98AA448D 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- 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..34540a0ca4da 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_get_ext_intc_parent_hartid(priv->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..8357c5f9921a 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->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..9fbf45c7b4f7 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.h +++ b/drivers/irqchip/irq-riscv-aplic-main.h @@ -28,6 +28,7 @@ struct aplic_priv { u32 gsi_base; u32 nr_irqs; u32 nr_idcs; + u32 id; void __iomem *regs; struct aplic_msicfg msicfg; }; diff --git a/drivers/irqchip/irq-riscv-aplic-msi.c b/drivers/irqchip/irq-riscv-aplic-msi.c index 028444af48bd..f5020241e0ed 100644 --- a/drivers/irqchip/irq-riscv-aplic-msi.c +++ b/drivers/irqchip/irq-riscv-aplic-msi.c @@ -157,6 +157,7 @@ static const struct msi_domain_template aplic_msi_template = { int aplic_msi_setup(struct device *dev, void __iomem *regs) { const struct imsic_global_config *imsic_global; + struct irq_domain *msi_domain; struct aplic_priv *priv; struct aplic_msicfg *mc; phys_addr_t pa; @@ -239,8 +240,14 @@ int aplic_msi_setup(struct device *dev, void __iomem *regs) * IMSIC and the IMSIC MSI domains are created later through * the platform driver probing so we set it explicitly here. */ - if (is_of_node(dev->fwnode)) + if (is_of_node(dev->fwnode)) { of_msi_configure(dev, to_of_node(dev->fwnode)); + } else { + msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); + } } if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, &aplic_msi_template, From patchwork Mon Jul 29 14:22:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745106 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 C0A3CC3DA4A for ; Mon, 29 Jul 2024 14:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xNgAP1vP6XR4FMQk+grtPXRS5JaMhDp/M5jbq08Nj/o=; b=RZwuPN8GvUqVpl rWrXJpKGINNwclEyW3ouriTSa2orXeMZjuldlRr5DDmkszMK7I+6vRw7D6KHPTEy9NCsXhWxQtPPh /LPWW/5quptgWVAFSRhswS9sgguV3uLswwjXv3AL5xYJBiA3hcjxS2EZ5m9t6VvnvyTXZTLzR9Y4k 7E1s/pkOCcXRw18zn9okAgbW6bIQbzYikb5c/9Mq9zv67Km5vcbGKEif/9Kh1s7YWsuDxyiUIKZzJ Tp6Ni+n1WVMqryM6wpSpDzywYb9CtSymemzYkQkL8A0RDjjL0DVdpMMzDojOHejPSeYSpBHWDlI3a 9hrAcjDmFT/4m19goHig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRZS-0000000Bgxt-0ArI; Mon, 29 Jul 2024 14:41:54 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRId-0000000BZEu-2uIT for linux-riscv@lists.infradead.org; Mon, 29 Jul 2024 14:24:33 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1fee6435a34so18394775ad.0 for ; Mon, 29 Jul 2024 07:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263071; x=1722867871; 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=I0GXqbjRdlQgXLR20WsWn0Zb01kTXlGc4SKzlInZ9zY=; b=EHMFi63IRR/NPHRs6AWh+D4JleQTlffo7vzLF+1JJb8znnwHQC2CnEnH9gUb1IQfS6 a2H6Ouw35GnCaAG8aet3dCauPbqE64ashIpijIE+DyFcjJ9byQi1cWeN/YPa1SnfoNlt pyQEYfwsYe6ZFWjmn4RXGwahg+triutE09MdShK6GBiLdL2EbWp5oabQj6Rl4owIXg7u vpzn5ElggOEIxuVN9PlypezePqFKLWUgW0WMHlJJKB5ACfO+IcknQPdgyxGXsycOHU69 dBwBHUJBEf8FJGHvdfD5mwHQRzblUJAIiW/6BKIKY5P6IPrVpxqAtdqN0/cNBSkEGeAV CfHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263071; x=1722867871; 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=I0GXqbjRdlQgXLR20WsWn0Zb01kTXlGc4SKzlInZ9zY=; b=qrGfAE5hyQJnfWoger4hsROxbsqln4BLPAN/QPV6kvfnmek0hRsaZIFOJ9Ss+bFXa9 +JMezS45BzllLoEkNzOHM45KmOCuzGWoHnygC9tVSsDiw7xIohUgrXh2rr0I2N8YOz0y wQ03zjBWrEAJGGSaPt4qLKHr/gPDfEmUPktlf0e8VvbfbTdCThly9EzZyKt/QefuOGlo tHRYg/FxpaxZ2R8Z2sXAEueNl79LODlj3uHC9zHp+riEaf+883Fivlnmr1ePa54G2Fu5 tlQsUSyA0SdYNsanm3SNl0tWGKBIuC6VLMDDor+xzUJ98hzv9UFzQHHiyBtGqNppsSmc LE4g== X-Forwarded-Encrypted: i=1; AJvYcCWJC0EtGYijIu6Umkv393VspKOFIWEfnuz+hQdTGtGjl0STFWTnPC85Q8GUTyDmLvBUejg1g1Oszn0G/mxUq2cl8IMoJ0F0bvcD7Y73jg1r X-Gm-Message-State: AOJu0YwQvAP63siXDU1TvM+9sgfBDrNDm5OhkLCUHeo1nundkgKZ23nh vEtfsgkTA7A/nyn6dzzYvK/WXcsh3NrwGcS6t6p4CiqnCe6XR9EFR+zVKEHQ3Jw= X-Google-Smtp-Source: AGHT+IHN8Sao+YlrrwzuKpm8WQR4yfMRcvn309oxoZCX8m59egD+A5Fg/n7LZZJO/PhhxP1zIyPB4g== X-Received: by 2002:a17:902:fb08:b0:1fd:a72a:f44 with SMTP id d9443c01a7336-1ff0482b8acmr45391535ad.17.1722263071002; Mon, 29 Jul 2024 07:24:31 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24: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-pci@vger.kernel.org Subject: [PATCH v7 17/17] irqchip/sifive-plic: Add ACPI support Date: Mon, 29 Jul 2024 19:52:39 +0530 Message-ID: <20240729142241.733357-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072432_010674_4850E6D8 X-CRM114-Status: GOOD ( 22.28 ) 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" , Catalin Marinas , Atish Kumar Patra , Robert Moore , Samuel Holland , Conor Dooley , Palmer Dabbelt , Drew Fustini , Anup Patel , 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 --- drivers/irqchip/irq-sifive-plic.c | 94 ++++++++++++++++++++++++------- 1 file changed, 73 insertions(+), 21 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 9e22f7e378f5..12d60728329c 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 SiFive * Copyright (C) 2018 Christoph Hellwig */ +#include #include #include #include @@ -70,6 +71,8 @@ struct plic_priv { unsigned long plic_quirks; unsigned int nr_irqs; unsigned long *prio_save; + u32 gsi_base; + int id; }; struct plic_handler { @@ -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_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_get_ext_intc_parent_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->id = id; priv->regs = devm_platform_ioremap_resource(pdev, 0); if (WARN_ON(!priv->regs)) @@ -519,12 +555,22 @@ static int plic_probe(struct platform_device *pdev) return -ENOMEM; for (i = 0; i < nr_contexts; i++) { - error = plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu); + error = plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu, priv->id); if (error) { dev_warn(dev, "hwirq for context%d not found\n", i); continue; } + if (is_of_node(dev->fwnode)) { + context_id = i; + } else { + context_id = acpi_get_plic_context(priv->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 +608,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 +627,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 +665,18 @@ static int plic_probe(struct platform_device *pdev) } } +#ifdef CONFIG_ACPI + if (!acpi_disabled) + acpi_dev_clear_dependencies(ACPI_COMPANION(dev)); +#endif + dev_info(dev, "mapped %d interrupts with %d handlers for %d contexts.\n", nr_irqs, nr_handlers, nr_contexts); return 0; fail_cleanup_contexts: for (i = 0; i < nr_contexts; i++) { - if (plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu)) + if (plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu, priv->id)) continue; if (parent_hwirq != RV_IRQ_EXT || cpu < 0) continue; @@ -644,6 +695,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, };