From patchwork Wed May 1 12:17: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: 13650560 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 3EE63C4345F for ; Wed, 1 May 2024 12:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nZnnPlQ3X/NWO3SMcCevOoV1Sl+kZOvMWUrCs1XurSo=; b=BqntDYuN8Gx72V fMh2WDjDrtwGGpgIVaZTYLmV62luvJf9trO1OgF+uvUfupwtfuzLQ1YuqsqR01d15UJMFqg72qvxE v6GPYOIe1YDuJWkwvCi0U/Ypf9dM+Ml0JOkQbo3gu2+zeTnWHj5/zJhYwxow5q2SGR03hTWLS0pc8 I+9YXHVJx/EsN6yDCmQjUqLmug3EpBbNUjBRcaBcm6Ak0Qen/alzGVhY3mrf1/DdPG4BDIxJAiHKI UH96PXcRJpxyFBj9pK0oYzmabW99+ghSPlUkvZfJFi5Nx6j5zRyq7BcddzZ5vCJOhGcW4Jgek9iGg BYwYail9HojRQjoVK7Xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29DB-00000009UYD-0QOQ; Wed, 01 May 2024 12:37:25 +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 1s28ua-00000009MQf-2XXG for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:18:14 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e3ff14f249so5762655ad.1 for ; Wed, 01 May 2024 05:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565892; x=1715170692; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TBFCNaiZG8SDhd9Avy2NjVgbIzDcy1byPrgimW8Jnrg=; b=erbWq+wQ+AXIVff1ppO3Alwh9h72hoZr5jWNvX4LhHxUr48k+c6bJ8IGx/ZKc8+8RW mP8WIRAmcZLHCiMdOZ8DH2DRMWT0XPwz2V1zFXTqYfeN3iJYskMChUIsBnW1tT2Od0WS XsMqcZqs0c5NrjDCMnK3V9KIv2feX3/9jYqQHoXHAeKWdDBvC3xZKnowPsFVTSE+WzOH 1oPyj5Lkka0VKypmtYWwS5VHKFGuszOIZ2lKrVx2CAF+rMl2cPuYKrmPBjDnDKvahuka ooT0Ih2Kc6g5v6DWI/2cC+MYTsbNKzHLakESq8Xv+p580/ro0tXdakvE7Gt9veF1CxzD aYzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565892; x=1715170692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TBFCNaiZG8SDhd9Avy2NjVgbIzDcy1byPrgimW8Jnrg=; b=XjOMAy4LqOu1zoQIS+vZl1L/Y8NkuPvl1FQZh/NUpDAqdIO8KZUUhWf715hPFRkeHU Hk2opE9Q8Vf1IJiAtupK6UpPoOOeUSUDXNJj1krSZJgD9yJmD98PwvyyHrTW9D8puwe/ Kc3sEqHiidxqRK3n4/2pn63QAxNv7QRTBQgiEimoH9WPTCslxX1XI95O5Sw6O1bqIFGg TXegyoMgPwCeGs+PWZRE24DoGSJw0PHqDkZFx4IvU4IvAlu4Hy2A3zmxq8QaPA5GkpaR dqHjcMWiaP29Xo4Tp13p2f6V2GNz8eHp/8anGqnKrdm1kSn9GHiFEUFhQy7/PjW476id 9DRA== X-Forwarded-Encrypted: i=1; AJvYcCXRMrrZIejf0GK9ngHLLXzm8gNPdtxdib/FtuNHFasJH6qVDU5ghJDWEfZJSKq52AV2NOIyoryXEdMHiG9OLJumil6nEddx8NHX90q5Z3P6 X-Gm-Message-State: AOJu0YzOSLz/MFA4He+dvCeYI+ti7BJLkmsRrKs2JZMg9Q2MobPaIMwR ebPfrwpdweElSfGUuBPzp3/04V8cz0h9u+9dDHJHtJsCWOpqXaAwb4dvYEM/m14= X-Google-Smtp-Source: AGHT+IFCz+8u/X89VsHYsAyI7LAYB37fwi80edU6U2OxBpGy7t88sQSAo0aUQcHa3ElV/kemBD1B7A== X-Received: by 2002:a17:902:c40e:b0:1eb:527e:a89e with SMTP id k14-20020a170902c40e00b001eb527ea89emr8243829plk.26.1714565891753; Wed, 01 May 2024 05:18:11 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:18:11 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 01/17] arm64: PCI: Migrate ACPI related functions to pci-acpi.c Date: Wed, 1 May 2024 17:47:26 +0530 Message-Id: <20240501121742.1215792-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051812_683264_906A8C9F X-CRM114-Status: GOOD ( 21.80 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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 004575091596..e8d84fa435da 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1519,3 +1520,184 @@ static int __init acpi_pci_init(void) return 0; } arch_initcall(acpi_pci_init); + +#if defined(CONFIG_ARM64) + +/* + * Try to assign the IRQ number when probing a new device + */ +int pcibios_alloc_irq(struct pci_dev *dev) +{ + if (!acpi_disabled) + acpi_pci_irq_enable(dev); + + return 0; +} + +struct acpi_pci_generic_root_info { + struct acpi_pci_root_info common; + struct pci_config_window *cfg; /* config space mapping */ +}; + +int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +{ + struct pci_config_window *cfg = bus->sysdata; + struct acpi_device *adev = to_acpi_device(cfg->parent); + struct acpi_pci_root *root = acpi_driver_data(adev); + + return root->segment; +} + +int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) +{ + struct pci_config_window *cfg; + struct acpi_device *adev; + struct device *bus_dev; + + if (acpi_disabled) + return 0; + + cfg = bridge->bus->sysdata; + + /* + * On Hyper-V there is no corresponding ACPI device for a root bridge, + * therefore ->parent is set as NULL by the driver. And set 'adev' as + * NULL in this case because there is no proper ACPI device. + */ + if (!cfg->parent) + adev = NULL; + else + adev = to_acpi_device(cfg->parent); + + bus_dev = &bridge->bus->dev; + + ACPI_COMPANION_SET(&bridge->dev, adev); + set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev))); + + return 0; +} + +static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) +{ + struct resource_entry *entry, *tmp; + int status; + + status = acpi_pci_probe_root_resources(ci); + resource_list_for_each_entry_safe(entry, tmp, &ci->resources) { + if (!(entry->res->flags & IORESOURCE_WINDOW)) + resource_list_destroy_entry(entry); + } + return status; +} + +/* + * Lookup the bus range for the domain in MCFG, and set up config space + * mapping. + */ +static struct pci_config_window * +pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root) +{ + struct device *dev = &root->device->dev; + struct resource *bus_res = &root->secondary; + u16 seg = root->segment; + const struct pci_ecam_ops *ecam_ops; + struct resource cfgres; + struct acpi_device *adev; + struct pci_config_window *cfg; + int ret; + + ret = pci_mcfg_lookup(root, &cfgres, &ecam_ops); + if (ret) { + dev_err(dev, "%04x:%pR ECAM region not found\n", seg, bus_res); + return NULL; + } + + adev = acpi_resource_consumer(&cfgres); + if (adev) + dev_info(dev, "ECAM area %pR reserved by %s\n", &cfgres, + dev_name(&adev->dev)); + else + dev_warn(dev, FW_BUG "ECAM area %pR not reserved in ACPI namespace\n", + &cfgres); + + cfg = pci_ecam_create(dev, &cfgres, bus_res, ecam_ops); + if (IS_ERR(cfg)) { + dev_err(dev, "%04x:%pR error %ld mapping ECAM\n", seg, bus_res, + PTR_ERR(cfg)); + return NULL; + } + + return cfg; +} + +/* release_info: free resources allocated by init_info */ +static void pci_acpi_generic_release_info(struct acpi_pci_root_info *ci) +{ + struct acpi_pci_generic_root_info *ri; + + ri = container_of(ci, struct acpi_pci_generic_root_info, common); + pci_ecam_free(ri->cfg); + kfree(ci->ops); + kfree(ri); +} + +/* Interface called from ACPI code to setup PCI host controller */ +struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) +{ + struct acpi_pci_generic_root_info *ri; + struct pci_bus *bus, *child; + struct acpi_pci_root_ops *root_ops; + struct pci_host_bridge *host; + + ri = kzalloc(sizeof(*ri), GFP_KERNEL); + if (!ri) + return NULL; + + root_ops = kzalloc(sizeof(*root_ops), GFP_KERNEL); + if (!root_ops) { + kfree(ri); + return NULL; + } + + ri->cfg = pci_acpi_setup_ecam_mapping(root); + if (!ri->cfg) { + kfree(ri); + kfree(root_ops); + return NULL; + } + + root_ops->release_info = pci_acpi_generic_release_info; + root_ops->prepare_resources = pci_acpi_root_prepare_resources; + root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops; + bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg); + if (!bus) + return NULL; + + /* If we must preserve the resource configuration, claim now */ + host = pci_find_host_bridge(bus); + if (host->preserve_config) + pci_bus_claim_resources(bus); + + /* + * Assign whatever was left unassigned. If we didn't claim above, + * this will reassign everything. + */ + pci_assign_unassigned_root_bus_resources(bus); + + list_for_each_entry(child, &bus->children, node) + pcie_bus_configure_settings(child); + + return bus; +} + +void pcibios_add_bus(struct pci_bus *bus) +{ + acpi_pci_add_bus(bus); +} + +void pcibios_remove_bus(struct pci_bus *bus) +{ + acpi_pci_remove_bus(bus); +} + +#endif From patchwork Wed May 1 12:17: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: 13650561 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 DAEBAC4345F for ; Wed, 1 May 2024 12:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LBlHHNxIG9BTbuG47kGOc9x+5hj9u+ZkueAMfBbTfUk=; b=srZ9HCMRAL9J6C RZ7j4L5n4afROrCo5y1KXmVg54OrWSxNqIC1F+9QsqvBH6mJUubaqShUuWMW+djutQG5EqRf/7dFF 1rdZJaQLGaeNwnhKLxUlkXhvC1JaIHLk5FfsR9d1AsQRzBNRCib6ZzPk5gRVjrWzO0SZVkeXnAIJH idMeBvWHXrV3zcU0nMCgKCRcURg1tZpT9Dz6vzJ2eews7ky9GKGSLmjZ8AL08N9cWNQVBnhF/Obr9 B5L50vwLGnLQ9SYh+AL37b9j6ZVaVdJTJjtgL3KlF7NATuyZU0iTKXMUNaiAoXkQWWffsC93jVw6B f7teujVCVeXyRSEaB0SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29DE-00000009UaL-2YH0; Wed, 01 May 2024 12:37:28 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28ui-00000009MUE-3PaB for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:18:22 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1ec5387aed9so13688085ad.3 for ; Wed, 01 May 2024 05:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565900; x=1715170700; 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=2U21IbVpVYWuDXnfpPitFjz/aLJhntW1ExhoP7hEzCc=; b=pR9bxwsq9Zmon7c2d1rrCGADzjiNkbJ7NJEM4wWVC9pUscHpgokcSF5Eo6U58AdMAl GR90Qno8S/poFKemvPhsF8eIAyGjPviYj4hQzIdvgSxls5QzNHaD2+gWPNUsOwMJyc4k FWl0eNavbENwn9MnyslODVdB9aZye1zUMBIZZyAMSz0PI7wY49N4N7RExWG2l9I0tj1T QILS54coW7EGcU6+WTlZ+7EuFQRrlwiFt6fmqC4ptuPl3aHnTpDeb6hOomsLG7nF8gGI LV3HzQMy/eNnc40HzcLqTFt6UzOyU3s+tvSB3fkW6zgfHecgG37CHe+WwZNaSzDyfjZP J81Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565900; x=1715170700; 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=2U21IbVpVYWuDXnfpPitFjz/aLJhntW1ExhoP7hEzCc=; b=YOacFZlhpWAnimk0DOfou3a1xtebE0pU1DPfksYSUChiryp5J3tZJL4bVQVj3sPsg7 4Mu5sMGf5u+4GmJ1uXg1GG/0jHXnVZc8+Fyl3kla5ASpCtTU5JAY2r1wOC7mUeqhcYDU ArmTQqqJo+M4R+KAQl23cRIPkT0WCd1MhK2bW+jSfKtRy81aJbTVnXRWdZ9HZFbZ1sGb FlO5olQWJj/Brq58JjCiJIgaOZeTsbaKkeCqi2Ak8Nc8o5p8TmPXEYrSJXGl+QJAmxwU tQfKbPrzPr6jDmuAFrhmzGjzwfnip3DBZ3E3f3q8/MlGMvi3aGZs53QbIuRwO74UWdH6 8yjg== X-Forwarded-Encrypted: i=1; AJvYcCV5GT11UpUdz5QCJFg3vXKFfTLwPlZSHVOsBTNYzQLyPvUluJ+Gg/TqVQ9+6sCnEfA4IHQQA0U942dYJGqk5OHgAUc4CdTUrnHwi+ODha9j X-Gm-Message-State: AOJu0YxZNO37Bz+MOqt4oIzuSC92p/k6m+vFd/KsNRuSAKq4n4NXIlOW sWr8kktgsYcOn9cBG2vYcEOLZWeR4QCkZPrx3PSb3K+2D0GBv4G9r2l4bar2y80= X-Google-Smtp-Source: AGHT+IEhKN1Gue1zmrkCOUBSqcJjzhxCt/OVWXcOEWxant109xhmvof+8Br6KhAL2UNxeD7n9gvBjw== X-Received: by 2002:a17:903:11ce:b0:1e4:9c2f:d343 with SMTP id q14-20020a17090311ce00b001e49c2fd343mr2700552plh.7.1714565899631; Wed, 01 May 2024 05:18:19 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:18:19 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 02/17] ACPI: scan: Add a weak function to reorder the IRQCHIP probe Date: Wed, 1 May 2024 17:47:27 +0530 Message-Id: <20240501121742.1215792-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051820_888477_F15F648F X-CRM114-Status: GOOD ( 14.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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 4804a2ad1578..837b8fc89dfb 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2744,6 +2744,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; @@ -2752,6 +2754,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 c2ae33b8dbb6..1afa289f1f4e 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1339,6 +1339,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 Wed May 1 12:17: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: 13650562 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 888A6C4345F for ; Wed, 1 May 2024 12:37:38 +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=Y/4vnhtrrIk57/5MUhPN9aqd/mINdtQO3OeieYXGqtc=; b=xYiqncMnmCyq+d TZ+JCbU2DGTRMgke7tig4YCDHMDar0jA9BYEdQnyUo8IOiM3ekK2ZkbE0cEFrZyxOJnOchkbwp2km lfCHkmfI4avVYtVV8brccgFMSDRyckWZB8chEETobPp05dEbluA4lVRGs4Q41Yy1tNDrKD/7gqumC 0ZGjAoT4UbtEasAVYktgdX+MJbwHnMoo0FgNGUgorCmlNajmjTfSuJdxJRl79B0Hb6wfZVIaQaOUH 1IOXfyQuaDPscIJigxD7GCIFzzWQaQYVAcqoulEFNtmuw0CERfvdepiSw4bLEk3SxCMx9u2rTjaj8 n8UEdruEDZf/zj9nWWhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29DI-00000009Ucy-33xW; Wed, 01 May 2024 12:37:32 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28uq-00000009MYv-3B7I for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:18:30 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-613a6bb2947so2188872a12.3 for ; Wed, 01 May 2024 05:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565907; x=1715170707; 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=pcwxR1GQk9U2hRbWPBz3q9MYCED3shcxZKp1VHv0hAo=; b=Gn98wY+ZK6vGcw+1aVAeFU9v/u130x+fRyS8IN5FszQ4u9LYtQ67fxStmcu6VgQvyl SPt1MCnWMF3NiCWGcxecmhiwOVFAhhrOAFXiaY8leyOV0QLlsy/N//3FZAEo9v/9MP4c s4FxUgI7bGWHfH1R2SAT4Ojfflogu983CrZsFrKtqapyKqyFl0il8Kh3IHZFgAPtUjzR sDkB/3FMyveRqoh/XalvHGcGCeWJVteE5qxkU/kvDB1sOpg0SFhlKZaDX1pT2IofHkNA 84bAcAmaOyWaKA3io0mMB8vhYFqvuGWhwCYOk4yukjUyRQFiKCqk30Io3JP7ABVt5a0k Lbwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565907; x=1715170707; 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=pcwxR1GQk9U2hRbWPBz3q9MYCED3shcxZKp1VHv0hAo=; b=MukXvyg6nQw70FJgKQ5yW6lX5G8DbvRpOnyybC00bIEQdyB28P927fyDdDzSj5uNbV QP9rgTIkBZ5Fiw7dOKBYqzlg84+kEC1W4HshQNM02qXGkEmYDzK3QV5/XlQSPuTv7rW/ Fcydtz/dN8Ozt2i205YposDJhXrcoX0czogrR1lek/xmrNGa0abyrtCvR1jifqtMxMC7 9vTNzhAfjoX5o9jC9WCmqK9D79IEVo2njqnBv/9qRs89RGIcwuWs+HO+LCV+GkYN3jPI ZR+lHDpjT9u5LMVtNZxVqJXbRbHRpYWi0NTW11UF9jga0vLrGwO5vc2FMD6Cn+1GcwPG xvCA== X-Forwarded-Encrypted: i=1; AJvYcCX2LeEjKY8FnyU297btPsmMdGxTDU0rIHQFK9ES4y1ziU4aJ/6H1AJesxhYrg/CXUCKKqQa8r1Mr02WiJKcW/eJDlJ1muo8LT9LRodMk0Mv X-Gm-Message-State: AOJu0YybxR1mdJiwccw8SQZVqlIkp6YTXSZtJP94QgqcEeDsjXkMV2PY EfIXbEJ7Z9mcxaWBimH15zI72pai2DUkXs9BoIfmhsP6A8ohTJ/l0UiDTwXm3leUISzWVgYWnbi cP38= X-Google-Smtp-Source: AGHT+IEeK1bdY+NiF6yJem6nH8XOZPBP0PcZb/eHB80G50De8R+NdOj9l68iFqCiSXYmU0FqhQ9LGA== X-Received: by 2002:a17:903:188:b0:1e5:5bd7:87a4 with SMTP id z8-20020a170903018800b001e55bd787a4mr2316455plg.16.1714565907491; Wed, 01 May 2024 05:18:27 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:18:26 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 03/17] ACPI: bus: Add acpi_riscv_init function Date: Wed, 1 May 2024 17:47:28 +0530 Message-Id: <20240501121742.1215792-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051828_850592_4C15FA0A X-CRM114-Status: GOOD ( 16.04 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add a new function for RISC-V to do any architecture specific initialization. This function will be used to create platform devices like APLIC, PLIC, RISC-V IOMMU etc. This is similar to acpi_arm_init(). Signed-off-by: Sunil V L --- drivers/acpi/bus.c | 1 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 12 ++++++++++++ include/linux/acpi.h | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/init.c diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 844c46447914..17ee483c3bf4 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1446,6 +1446,7 @@ static int __init acpi_init(void) acpi_hest_init(); acpi_ghes_init(); acpi_arm_init(); + acpi_riscv_init(); acpi_scan_init(); acpi_ec_init(); acpi_debugfs_init(); diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 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 1afa289f1f4e..846a4001b5e0 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1527,6 +1527,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 Wed May 1 12:17: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: 13650563 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 AF683C4345F for ; Wed, 1 May 2024 12:37:45 +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=9LLB6rWykjj+mZ8iBQ9DYwfgiD6xDJ89PLkxFtQ/IWI=; b=Y6kQ/WUg+8Rkbj MuNKLSNjO01oUL7wKVfU2kxkPb6wuVLrQAyjQxssX+yoGDhLIefhKO2DW4RpskaamjpQEELg37I5R rhZOFIB3M/wVG00eKX524sOrxUoOlGRtNhJ3GuTwrwVCa4a28L9xW3uoyKd2mnpqZaCXr7JuPeM77 mY8r63jL1aXSOlWC5RBLdBv7SS9hallf5BjpIEYmZ/2glGazasaAXWkgY4+C5uxnA0SUSpQMF7RGm dnmmkxUpsfh6q6HeX88gfXaFpa68IZGTaop5G+Gxk+xg/6AR6yLU+ObVNYZhNAKAIyj44bW/qYYdJ Z2vEA5xXtXkslfF8lq6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29DO-00000009Uhf-3ClK; Wed, 01 May 2024 12:37:38 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28uy-00000009Md2-1TE3 for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:18:39 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1e65a1370b7so62843385ad.3 for ; Wed, 01 May 2024 05:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565915; x=1715170715; 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=lRvT/oDJzrljnZE8hh4Mfx8UjypBfU2BU36kOdk78lo=; b=I6NvFdNHdJ3UDj/4OYitYVEvZseFUsP6XGwagdQrV6g8zD2m6yK7IYiSGak1gNg/gP g6mM+P9nfvKFn7TH5We4orPPy6wZ4elah3tKCVj8IFA5plq7WnNdx3Az4AEKBESztXOp x0Q2kONspiCIXyTXnODl+3YqYUnERAmmgiRUXLm1vda7yhpQIWBsCjrQnlcqgPF7N47r JAiCHvWVo2N7aHw5g3OyjRMGzFMrJelibW5bLXlIBXmR/9yh1JV4vGsOaz4Gct3ZPmzN 7tFDbXx+CgKTydTuOJdwbjexeWrJeV50lqE/xDM16KJiNyKzpHWELSR0dSG7a7gW0b93 7bQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565915; x=1715170715; 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=lRvT/oDJzrljnZE8hh4Mfx8UjypBfU2BU36kOdk78lo=; b=ZMuEmykQtLYl//+a9WAuWa4h1q/qt3C6IlS95MdpaJnUH6y5xInB0XqUCcrH+KQMeI GZXnppT2GEJvgqXaJUK5+RAJq8xXgYpzuRK+lwzAJIOQYN1Q/8s+696IG/BUY1cHsA3s LMjN/ronQdxVwuy/I/2pQVAACga/WJinIcI4hrGzwIeY0nknTgGklYoLcJXUkEs6RlD5 Zanj7/ZHl1vR37E7bobKeXIaTJRQ6zjMMuS7rjVlbkuedaVlx6tidA2gKoJVpq5lZJaG 5FWoJqaqRuvAG+XIUD23TeiNwlaZr2tiegQsEiO6SuIRz+kFWYyk5UoDxn55xKwq9gRg YbJw== X-Forwarded-Encrypted: i=1; AJvYcCXHvdJOGGbN3/C4Xmfl7PA3kNOXvsaDqE7L7HqRhzkt2svo9TBNqIhcLTjdZvtd6LM2G9ZFACnaXbZMto9kUzMH775fk6ERGWGS2OpiGEqW X-Gm-Message-State: AOJu0YwKI22hEpl/iXKqxoq1pNytOg8zMXzYNbrO+MJKoLbe0IdmJFAd +StJdvJs5wCP4bwAQvrxtFO5UbWJq7kjjVHdhMNbIVReVfMuNyKAIHKXc0t35hg= X-Google-Smtp-Source: AGHT+IFj7UjbvAZWh+cyRVOuEeVGC8mPfC0AaziB0MuMPmALOJzUu9Sq7LhvOrdMq5PmFj31+IKF9Q== X-Received: by 2002:a17:902:e5c4:b0:1eb:4a72:91ff with SMTP id u4-20020a170902e5c400b001eb4a7291ffmr3011610plf.49.1714565915161; Wed, 01 May 2024 05:18:35 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:18:34 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 04/17] ACPI: scan: Refactor dependency creation Date: Wed, 1 May 2024 17:47:29 +0530 Message-Id: <20240501121742.1215792-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051836_437879_2B0FFA81 X-CRM114-Status: GOOD ( 16.11 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Some architectures like RISC-V will use implicit dependencies like GSI map to create dependencies between interrupt controller and devices. To support doing that, the function which creates the dependency, is refactored bit and made public so that dependency can be added from outside of scan.c as well. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 48 ++++++++++++++++++++++++----------------- include/acpi/acpi_bus.h | 1 + 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 837b8fc89dfb..3e3320ddb3da 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2023,33 +2023,18 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) } } -static u32 acpi_scan_check_dep(acpi_handle handle) +int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices) { - struct acpi_handle_list dep_devices; u32 count; int i; - /* - * Check for _HID here to avoid deferring the enumeration of: - * 1. PCI devices. - * 2. ACPI nodes describing USB ports. - * Still, checking for _HID catches more then just these cases ... - */ - if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID")) - return 0; - - if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) { - acpi_handle_debug(handle, "Failed to evaluate _DEP.\n"); - return 0; - } - - for (count = 0, i = 0; i < dep_devices.count; i++) { + for (count = 0, i = 0; i < dep_devices->count; i++) { struct acpi_device_info *info; struct acpi_dep_data *dep; bool skip, honor_dep; acpi_status status; - status = acpi_get_object_info(dep_devices.handles[i], &info); + status = acpi_get_object_info(dep_devices->handles[i], &info); if (ACPI_FAILURE(status)) { acpi_handle_debug(handle, "Error reading _DEP device info\n"); continue; @@ -2068,7 +2053,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle) count++; - dep->supplier = dep_devices.handles[i]; + dep->supplier = dep_devices->handles[i]; dep->consumer = handle; dep->honor_dep = honor_dep; @@ -2077,7 +2062,30 @@ static u32 acpi_scan_check_dep(acpi_handle handle) mutex_unlock(&acpi_dep_list_lock); } - acpi_handle_list_free(&dep_devices); + acpi_handle_list_free(dep_devices); + return count; +} + +static u32 acpi_scan_check_dep(acpi_handle handle) +{ + struct acpi_handle_list dep_devices; + u32 count = 0; + + /* + * Check for _HID here to avoid deferring the enumeration of: + * 1. PCI devices. + * 2. ACPI nodes describing USB ports. + * Still, checking for _HID catches more then just these cases ... + */ + if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID")) + return count; + + if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) { + acpi_handle_debug(handle, "Failed to evaluate _DEP.\n"); + return count; + } + + count += acpi_scan_add_dep(handle, &dep_devices); return count; } diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 1a4dfd7a1c4a..28a9b87c23fa 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -993,6 +993,7 @@ static inline void acpi_put_acpi_dev(struct acpi_device *adev) int acpi_wait_for_acpi_ipmi(void); +int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices); #else /* CONFIG_ACPI */ static inline int register_acpi_bus_type(void *bus) { return 0; } From patchwork Wed May 1 12:17: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: 13650564 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 4A9B8C4345F for ; Wed, 1 May 2024 12:37: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=e4isGbIozky8o9EsLq9ZlRIx+Bs0mSSu7QqPjT+7KjQ=; b=XycKotZDIP9lOU XgC9lZcnq9vX5M1DVfjlxcIupIrfLYfhF8keji7/hFzS9UkaCO6eiFajDaWQhXe6apEH5U+KYiVCY oodqXIVZiAeuK9LZNTXYFSlTK45ofg8ovfnRd5G9FohVgF1REC4ioXqbe6Yae7Ofq5IPpI/R151dL eXak+16ImA8xYOv+DF34MD3pbtszJutXVco3dFqAgACmZ9Km3hgzAhAZfqdIk34/46N2db/nYLn7c YSKZ5ON6Xe9YaWdyW4pZg2e34fTz4E9dtjwCORYoM/9ied20p1TmhfMmrGtIFSPtowHN329GjBkcA 86Nno5gts66ZemUz22cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29Db-00000009Usz-1JjN; Wed, 01 May 2024 12:37:51 +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 1s28v6-00000009Miz-2PEL for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:18:46 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1ec92e355bfso5028605ad.3 for ; Wed, 01 May 2024 05:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565923; x=1715170723; 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=uNK+H7F1X6JmEpHoq/SVvyVT2dyL9n7lyqIUUwemfkM=; b=Vwk4Zx6O5GjkCmwl2lSCh7hjiaAe6yAsAYKkJ+kh+qYcBblewPf41/EALgrYuzcRiv XkepdreNWkcNQw0vO+FII7bGBsTSV35W4S52TfPpSXFwFIP7o8lDn9DkeSL+NQpqgYK4 jeiSU21pO+V9WTP3siFTIXl5xla2WWjNnBZ+A/9CDJXKKEvme0W6PLe5/H4RPs7fxY+g zxpboScKU+BukDvmFpFnVYB+PIpJvC0Tsm5e30MCswz5UkKr7LuoNe5s0+O2buguaXOc U5pJe6PshbxCpvPKMb5KAOJlge8Ve7rFy4GhwD25eaRHyD5FCXjixojKTf0ripjsiquQ /Fhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565923; x=1715170723; 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=uNK+H7F1X6JmEpHoq/SVvyVT2dyL9n7lyqIUUwemfkM=; b=JVUUu5x/KbaOBAtDvp2n6i/pm9vqZh0Gv9kyGXP7GIX68Ha9TUd7cZ/+3/o2crXaHx DmMwxPYSY2xqzJfJdUbxTgGD5q4BcOX7m7jabxsjZhy74ozQ6xEFZbVbdbJrzgGDJzwg 48ua31iG/2vW4s4qCcxVfJGLdPm5i5oNUDXllDih4a1hztsNOt4DvVmHVVtYFJhOA/Fx RY+rVbwqFnL4BH4cvEukvAVGdYpBv9If4X0yZTjc4SsVio/YqKzc3IvOy0rwv751HQ+C nlRxgRPGJBN3GDed9bOEDQSJwGICNsUfthizew55n+qysyx6PQWVCqMgkJRA7qQpjEal psug== X-Forwarded-Encrypted: i=1; AJvYcCU47f2pWbf2GO5B4m1yjirgZvPAY/QqoTRUGstAI3ShlQILNb2EaclVvpvvevS2gsp/4jEuSNp+tQtbi8VJUoNG5+b7xZ6Fplljk//aokTj X-Gm-Message-State: AOJu0YyKNzXOI+OE5L85/cB3qrltjxlnxERc7Gi2AudcByBCWm44S9qk /V6+JxI36zezs1+a2dQu6zZftdZVo7qrSjD4moS8nDtMHPQOJeuIrR2mzc1Hssw= X-Google-Smtp-Source: AGHT+IGI5pV9TYR10/cfbIQ9JMek+r7tBzzTGhtdRl1CfIULDyfaZRTCxXSzFPv/bTagC0SBwcv3pQ== X-Received: by 2002:a17:902:db09:b0:1ea:cc:e123 with SMTP id m9-20020a170902db0900b001ea00cce123mr2687556plx.46.1714565922763; Wed, 01 May 2024 05:18:42 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:18:42 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 05/17] ACPI: scan: Add RISC-V interrupt controllers to honor list Date: Wed, 1 May 2024 17:47:30 +0530 Message-Id: <20240501121742.1215792-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051844_962955_B3EB327A X-CRM114-Status: GOOD ( 10.13 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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 3e3320ddb3da..beded069cb0a 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -832,6 +832,8 @@ static const char * const acpi_honor_dep_ids[] = { "INTC1095", /* IVSC (ADL) driver must be loaded to allow i2c access to camera sensors */ "INTC100A", /* IVSC (RPL) driver must be loaded to allow i2c access to camera sensors */ "INTC10CF", /* IVSC (MTL) driver must be loaded to allow i2c access to camera sensors */ + "RSCV0001", /* RISC-V PLIC */ + "RSCV0002", /* RISC-V APLIC */ NULL }; From patchwork Wed May 1 12:17: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: 13650760 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 416CEC25B10 for ; Wed, 1 May 2024 13:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tZyIOEYkrXWPi2ctsuW47+6h7pDCZiWMvFbTfGjunfg=; b=DAhznYpH2A6Ox1 4mFyFTvCIisRr+j6obaQ1pBLlkPh8I63hLrl2jLZtYax0gzGAPJEMcevOs5lccmvwoIS1Xb3NdouM 05x2GjmSODklqugQSom2pZgsGoLJX0t2G6oNu20icuhJ9se9o0VkCwZM+WeCqTl4VJ9u1ZGOIl1FD muWv0pxTltDmTmKZyr/ZWZ76zfyfgjc9EX9F5NOX0quN05ZUTUE5fU1dgQ6KIEhD0S10sb8daO2cN +mn9xAFhx6a9QbUursTagcghmo7oD1Tf9BFMp6xD6OvA5W5P+sZd9E8KLgxZYVkbPNh3mwo6SEt0r inkhBtgMH35pMcZUZcZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2AHR-00000009iVH-2pLd; Wed, 01 May 2024 13:45:53 +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 1s28vD-00000009Mmn-1UxH for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:18:52 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e4266673bbso60763195ad.2 for ; Wed, 01 May 2024 05:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565931; x=1715170731; 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=NJK7HUkOtgooa4XBRIgNv++I9VXVR1Nc/x5AlB9DEr4=; b=nf8fiv7sYaqw1rnr92A69dSp4C6CzpWnDfaHV6+3ZP5VGsdQhzSDy5UxWQJhw8MnEQ 35wfCZPxSyrUTybRvOGTSjv5sFMx2OPp1/3gEMFHEouYk+HxDs4mgVrtKXH9WN8Q7/XL JaQ9jtRtx0aAtd8YWZDuUHRQHBf3jYM51UDMeSi8F49ax6RW1qJVY+6nSYPrBtkrql9u T5LomZwhXLonyxxVtaKItue47MTSy5+WqVtR7/V63chvjaZ4wX/DRbyhjHkLDYIbXFne s8yVQn92r8IYieHgie644zZ1qCgdQGUP4Bs3pbGr2Ffonpvyk5QYeTszvh5syFyblvHp kMXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565931; x=1715170731; 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=NJK7HUkOtgooa4XBRIgNv++I9VXVR1Nc/x5AlB9DEr4=; b=Aw7PB1z9ioG1fusI21FxDXYerDwJFE4utqNNPApjeO9+LXnXfDRiLiHUaXer/1/b1b fldzDgJ5QAylxPn8hr6sW1sRL76wNjESaUwYB82FHv46d1dk+yiAqNjOi5fcFMF9neB9 8bAtRcRBMcD0O0QhW1n6BOkN4H1NtNV1xbFFDYsZ6vief/ZbwCbbsaGWaagODK7iohMZ SIHwIynu9GQBqib94osqvtBIt4sTvUs3KzYB+6GEH+NEqLOF4nE/73fBwkE4QSD/Oezy 5rPG6qmyxobPjjRmy9cRis60aoCInaaeU7S8lweFMy/McLI4QmLOmGjOS6sz0EhvXfLY kKbg== X-Forwarded-Encrypted: i=1; AJvYcCUNrsT5ZgaC6ZAxQi00d4C8ZTNLEFAH1kqzlSo+cscxgY8u1wsC7NFOT45zUEW7k8Me4PuHunOhVHEb73CDD5Aq2Zib87WY0HVWF0hpenDY X-Gm-Message-State: AOJu0YzJlXM8mJQ5KA+oWw0N8NfcyMb140l5tPf1Cy0IG9HcQmYA2A5N JtYtShBylDqevvhiovAGQUODAaZZw8+iTFvK62N+z1+j/c0QxdEH5U85Ok89SVE= X-Google-Smtp-Source: AGHT+IHqQHwdtyucv9ZMhP/dVbiOcapAJDdX24SUfAiXrmEd3YjBfB6sjT+VYhoitv18fuYmxMjC0Q== X-Received: by 2002:a17:902:eb4a:b0:1e9:470:87e6 with SMTP id i10-20020a170902eb4a00b001e9047087e6mr2178199pli.23.1714565930746; Wed, 01 May 2024 05:18:50 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:18:50 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 06/17] ACPI: scan: Define weak function to populate dependencies Date: Wed, 1 May 2024 17:47:31 +0530 Message-Id: <20240501121742.1215792-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051851_434005_2C0A6070 X-CRM114-Status: GOOD ( 13.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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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 beded069cb0a..3eeb4ce39fcc 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2068,11 +2068,22 @@ int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices) return count; } +u32 __weak arch_acpi_add_auto_dep(acpi_handle handle) { return 0; } + static u32 acpi_scan_check_dep(acpi_handle handle) { struct acpi_handle_list dep_devices; u32 count = 0; + /* + * Some architectures like RISC-V need to add dependencies for + * all devices which use GSI to the interrupt controller so that + * interrupt controller is probed before any of those devices. + * Instead of mandating _DEP on all the devices, detect the + * dependency and add automatically. + */ + count += arch_acpi_add_auto_dep(handle); + /* * Check for _HID here to avoid deferring the enumeration of: * 1. PCI devices. diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 28a9b87c23fa..5fba4075d764 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -994,6 +994,7 @@ static inline void acpi_put_acpi_dev(struct acpi_device *adev) int acpi_wait_for_acpi_ipmi(void); int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices); +u32 arch_acpi_add_auto_dep(acpi_handle handle); #else /* CONFIG_ACPI */ static inline int register_acpi_bus_type(void *bus) { return 0; } From patchwork Wed May 1 12:17: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: 13650761 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 998BDC10F1A for ; Wed, 1 May 2024 13:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1NXZivih5/7HaHv5SSWtlD1KAYnjGOFFBws1X9l/nVQ=; b=YqohhW4NyBPuwZ VtpPXpwb/9O7jj6ADWEQckgcW8cFy4MNlgLu1nuAwiZfO4z5mpAgCEcrECRDB6pUNM9sGHnwydrj7 48PoYV7y69JpMCbBXg3+zzhDelhPTCFHek0Lc1Mq2LmESGGCWtvw+Z3zO7yXpgqqZdB6qcts+PUF8 AhidptJe/1z4YmGQ/QU8GuI4X3pcPEfILpI8+3+yarXKGFS10T/IakQIZpEY+PY1TmTDjiJGeBe86 QNmGcZA3gGTI1K02130/6Scrjh3jTkYoH1nfzeJOIKxm34C1/7mPoFT8oVnC9hxRkp3pG66grenao 9LsXhi/2eCybyGFbSClg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2AHU-00000009iWi-0SnE; Wed, 01 May 2024 13:45:56 +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 1s28vK-00000009MrH-3hpP for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:19:01 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1ecc23e6c9dso651045ad.2 for ; Wed, 01 May 2024 05:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565938; x=1715170738; 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=WOIqEzOMfBRaM7n+Lh1Tvfg7gL7m541laQZW313gOHY=; b=n08oqRkdgPWF0uNG0SW6DPRcKhwcE4VcrryhGUOXXqKeT+qUVCI2V9Zd0h7y15Vb8Z dribaCIUjFjybtN1+d8lQ+j91n1ArUpUE7P55xqvVmxd/OwdS3D8k5oOeR3wHFg9jGzy edzZjQ3UpZDtJmIx5CsdK/EGJltkHaBMXBTQqZx7KJ8Ko0ysskoACFzsuXdhcYPdUzNs +TRMlnVI3NyHReC/+hI2RxfxayrFTUaKgl3h0lsv6IigfiVXgLujmWVwt6Kyfym9q5QV QL+UKZV/75EH0HO49ghez8qbIiTlgUphJgGYWgcm5eALIHXe01BCjzuKIa8C0CAQIAfw 4TNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565938; x=1715170738; 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=WOIqEzOMfBRaM7n+Lh1Tvfg7gL7m541laQZW313gOHY=; b=dWNyD4GSrO6jLhQKw/RxJy5iZplLCeHMsJDrJQmiC+IFa7IMp8P3mB5s/UVlc0X0Fp BHsSnwBpJOAOx1OzDeAJWkTa7cPwWYrx7ktSk8Gap4Ak6ykXxHd65UYd6K+JUOBgxrbM wymxaXOovG/oefQvJmSI9aPzhEAMuD98O1kDHqzyveM7Yy+w+Kcgo1+/kINQXN0OGutx nEfi5vBIr/9AwsWf3V9VVpc50tO6P9atemWUtWwVI2YKAh85pypEbEChGF2eFUt62N45 d85JqGDuP0qdEFcsp3u64ZQAiPCi3EjQkZOuAyQ2uCi32g85M29m13PEeNotKS98rVzi 35jQ== X-Forwarded-Encrypted: i=1; AJvYcCVufIhQA7UvpRQoKiZNCAu7mY4Pgq2+aE/htV1SJ1eBblD9oHHVXkyhHq/FxsVaaLCaQ0XKUnEaXCLmFeW7WEPAsQ+an6G4KrvXjtfq+jHy X-Gm-Message-State: AOJu0YzlPa+vj05ExLH6FxcNGCF6P8M5P/ZV5LoDshIvDbGe/o3ThoiP C4XCD4KX4MwYFPTryjBZcjmLrLHRMZnvqDCx42b16geO2OCDEPNu3A2oIf/q3/E= X-Google-Smtp-Source: AGHT+IGEfdWve8EtzQpflTL0dKP3MQxp+brvZfzYZ/NVGRzicQEMono2Ofsx4PyPFbkYzH1s9yqSdg== X-Received: by 2002:a17:903:496:b0:1e1:a54:1fe8 with SMTP id jj22-20020a170903049600b001e10a541fe8mr1877916plb.53.1714565938389; Wed, 01 May 2024 05:18:58 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:18:57 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 07/17] ACPI: bus: Add RINTC IRQ model for RISC-V Date: Wed, 1 May 2024 17:47:32 +0530 Message-Id: <20240501121742.1215792-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051858_943095_CAFF6D71 X-CRM114-Status: GOOD ( 10.77 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add the IRQ model for RISC-V INTC so that acpi_set_irq_model can use this for RISC-V. Signed-off-by: Sunil V L --- drivers/acpi/bus.c | 3 +++ include/linux/acpi.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 17ee483c3bf4..6739db258a95 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1190,6 +1190,9 @@ static int __init acpi_bus_init_irq(void) case ACPI_IRQ_MODEL_LPIC: message = "LPIC"; break; + case ACPI_IRQ_MODEL_RINTC: + message = "RINTC"; + break; default: pr_info("Unknown interrupt routing model\n"); return -ENODEV; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 846a4001b5e0..c1a01fd02873 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 Wed May 1 12:17: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: 13650762 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 B4441C25B5F for ; Wed, 1 May 2024 13:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ot+XKcfy3eegyI5eQ+E4R+BHqJxPWbGdlWfr8dng4lk=; b=xB50Hl1W1PUYSG ubzvVo7WbEBXefFvlqMj+IDoDenfOisppVTjhCAELO9q20TApszpscFdVlhHScTChdm4LMmndGl82 MnHrvzAletsScIHjz7dFjKcemLg8xHkQAlio6ubZXcjKXbUkmFT/h+JfVgJAXSxr9jcbNUc1aMfQz +jNqT8sD/7Jey5kyq64hA9dtykPzGbDmmqzCPgWQLs1NLaMW3Uevl0HwrmNSLxyHx2YKif2fUNkOc oFmB7roSWUCs9bTT/cR/qus/AeZqKQQ8on53VTEln+Dw3PlfHO3C47K7dIxveKPQPcFU1+5MuyClC +JG1uLdBLlBTSwUMolPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2AHV-00000009iXi-2PWM; Wed, 01 May 2024 13:45:57 +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 1s28vU-00000009Msu-10Yb for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:19:09 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e3c9300c65so57040755ad.0 for ; Wed, 01 May 2024 05:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565946; x=1715170746; 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=38bWUcD6VJHgu2OT2TKY+rPPpBYSs9fss+ITqZ/SBFM=; b=OVRf5l21u+yPqsiysErnQUw2L0Vo69gUhOl/tcKqu39MuJdd0QYdDPvsQ6sr0d7D4l HqsVHZTK91lLezfrHeko1uc5VZMroBbMgdzmu6jJlb4xpaFSQotx3z2RKiqXgh9VoCje BPxybhS66ZErxzuoelYUeKXbmbUhT5i6dCoFJM2ZWLheZzwkfy7a8fQzS+QK63GB8iO0 8s9FleZBEF8Omwyt6JF66wHI5g5ggcrgwfV+yBqEdwMgReRlA6QA775RNIfoaDtSYFm6 YlAMoKsqUiHFvYI7f3MHy5WneF/g/AjnDdTfuwlsMEUl5Y87N2+QHWsP2vYLS2tdoCSK dpYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565946; x=1715170746; 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=38bWUcD6VJHgu2OT2TKY+rPPpBYSs9fss+ITqZ/SBFM=; b=GisdfSGvdc/FrVzjl0ZX0ao/AdJ7FE8Kd8ciFReocBjxN3nGGwWVj4pcTMI4qFhYzR pDveJQPJ0n8lJ2m4osbZKLj9vwz0VdWjApE3nZkilyTkG6k8vAWRskgprKaEsYWw+4en 0rTfd9klZDAKepoi/P86ehFbLhHeJSBRgXZXGG9aef+kjL3iKFXIbu+vr2b/A1yWbjnk iDuV3fVxl1rjefZ34nC8CsjNKqU7g4tdSg+aDVShQeT0H8xKxoiIPC93GLGuK5Tlh2yP PutSm27/NNQHU/0BbMU/BnMV3dRcUTiIhV3rW20kW2ydfbSb5BaNZwmpSHYmVXynnSnx ISuw== X-Forwarded-Encrypted: i=1; AJvYcCWsRXxOf/AB69pQY4RO0Shc0LA2FXccV6QZPnQi8rEydToL2RmGAVgSFZEypaScSv2HwqK7pNXLtTv83IV0qi8jOeu8vVDQ8OjN5QB5mjvA X-Gm-Message-State: AOJu0YytpDZDOAHEEOnkLYqWKZbHFGdKZ5z0Kq7nufbUcnWTaDZNL6H3 Xhvg0/+prklh01rKlZtr6muO8/mQHoYEoKZWaURbWbk/pfiIRh5vcYflJatvLA4= X-Google-Smtp-Source: AGHT+IGXC7NkAjACd9P5pWtq+Fm60ySdE8zHPZMKCP8HvEhNdRXNAHHqpbDgXk2ZkzDTp6OP1jYRcw== X-Received: by 2002:a17:903:2591:b0:1de:f93f:4410 with SMTP id jb17-20020a170903259100b001def93f4410mr1645679plb.8.1714565945995; Wed, 01 May 2024 05:19:05 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:19:05 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 08/17] ACPI: pci_link: Clear the dependencies after probe Date: Wed, 1 May 2024 17:47:33 +0530 Message-Id: <20240501121742.1215792-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051908_547533_625817C1 X-CRM114-Status: GOOD ( 14.32 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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. Since this is required only for architectures like RISC-V, enable this code under a new config option and set this only in RISC-V. Signed-off-by: Sunil V L --- arch/riscv/Kconfig | 1 + drivers/acpi/Kconfig | 3 +++ drivers/acpi/pci_link.c | 3 +++ drivers/acpi/scan.c | 1 + 4 files changed, 8 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index f961449ca077..f7a36d79ff1a 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -14,6 +14,7 @@ config RISCV def_bool y select ACPI_GENERIC_GSI if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI + select ARCH_ACPI_DEFERRED_GSI if ACPI select ARCH_DMA_DEFAULT_COHERENT select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index e3a7c2aedd5f..ebec1707f662 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -587,6 +587,9 @@ config ACPI_PRMT substantially increase computational overhead related to the initialization of some server systems. +config ARCH_ACPI_DEFERRED_GSI + bool + endif # ACPI config X86_PM_TIMER diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index aa1038b8aec4..48cdcedafad6 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -748,6 +748,9 @@ static int acpi_pci_link_add(struct acpi_device *device, if (result) kfree(link); + if (IS_ENABLED(CONFIG_ARCH_ACPI_DEFERRED_GSI)) + acpi_dev_clear_dependencies(device); + return result < 0 ? result : 1; } diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 3eeb4ce39fcc..67677a6ff8e3 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -834,6 +834,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 Wed May 1 12:17: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: 13650763 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 36D03C25B10 for ; Wed, 1 May 2024 13:46:04 +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=B3Kr3hwYAPvC9CTHi0oN4cNAjh8a8HRqPZXBnfIU0R8=; b=weZ5tU9NAEH1pZ FUlJ+JjRxmr+RRQgwZcFmIlIcDntGwyS8EhTjzCnNiJmD+uIV8nZI6idlxI5Fd6aWj++oZksXCfto CTPyHp1jHfT3dksq3nGnPI3yB4iSae+K2bsYQHH8vhaO2Pf+6qSxgYsXXxKmQbYQtwgpdREVYbEnm f3nPwpdrCeDBiKMk3wNoHEr6VNH1tC38taUPPA6gCkGvwyF+dub9Dy4zVXjeuamHFo7Wzca06OgWY +JB/oLgocxBCuHjkKUtxq7BP7ZD7LpErq9uelZ1ekf40868mzAccCaY09O9aW/kWyLIeOsuRHU9Nf bkKyQGpi61WwOC97YvDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2AHX-00000009iYo-0QlP; Wed, 01 May 2024 13:45:59 +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 1s28va-00000009Mx5-2rg3 for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:19:16 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e3c3aa8938so44176515ad.1 for ; Wed, 01 May 2024 05:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565954; x=1715170754; 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=ycPsvBm29e5SjcL+mnP2CfCAXKwmh5unfT08m5gLAm0=; b=Ef8Oi1iqrcuPzZKrEBI/t4V4X6nNPW7FnN1cliv3reTDu4+R3iOH4ScDZXAL6GteRM V0qgBubpRzrPf7Su6cOuQc+Ll4fcdcGrooBsSaHRS2BsAVg8Gor2/MKMHxjbnMsbHzk2 96N5gHNcNOG2uWktSGGVucgcq2NjD7zta3ves5oABFlkHCCBN9k5n+9X71yV8ibaNfrx GUx0EpYFI9+zTiWRrKdB/0cwj6rfxaie7+ggE/eq3Vm1t/7wDlW51ueDT1y6SEvJlC07 2Yuok7sgBxoup/X2po57WVa9SH9VjekHsw4avzyg4TZzSwjURuI00+6KoT01qdKWlEXW tjTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565954; x=1715170754; 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=ycPsvBm29e5SjcL+mnP2CfCAXKwmh5unfT08m5gLAm0=; b=AmBMg7zLhPKPpKYceChQ36t+m6sS3cru/7j6eMzkEFAQPaAwG+u4vJYqLVrfYQM33s TWCJwoaVhAruOmc4/IsZuyjuzcTnXji7n8XierIHI75DhJroPFGwN2+bhZjIsQHqbGuW noBg3d6IVuT/zPNVVaPT+4aHOQdoruGkv+P2adNdURuveSvUs6el4ghtlHRg+TyM6paw Qc4qOsCUb6CfEtQU+CspFtXecE+FXcfCkzsuIcsZY8ol8+UNcIhS5VbbXRD6SWzk4117 WHZ4xJGdnvDE7IRTP5qxJXyiFZlGDtkyA+tCgqBq476Xwk/QpfWr5H1SFJKKPbeeisAS uWOg== X-Forwarded-Encrypted: i=1; AJvYcCVadD31RwTLZTLk8/dAtQGpdXW5Dzj96pTHopNS4op6LB7791aGZkCHvwXTLQZjxWg5djpX7c0+1mIXLv6uexoAd9o3Zq+VZFJPjVG5fLaj X-Gm-Message-State: AOJu0YyrtzV9uIhbcKHjo5NbLyA6pRRtaJZDjautuwNCOD2dRLNGIcOp CsF8gGmQ8N3pIOxBpcNv8LqTQxlDzWC9D0hWb/cd7bKBg+qwLxpp4UykPpN7B/M= X-Google-Smtp-Source: AGHT+IEDg6A+K3iip7ZStHi7uQnpL11UU8DLGuIplAfF1OsmX8JbUJctZLyYRcjpa+LuwJ/5zvxvdQ== X-Received: by 2002:a17:902:864a:b0:1ea:5ac0:ce46 with SMTP id y10-20020a170902864a00b001ea5ac0ce46mr1772335plt.66.1714565953984; Wed, 01 May 2024 05:19:13 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:19:13 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 09/17] ACPI: RISC-V: Implement PCI related functionality Date: Wed, 1 May 2024 17:47:34 +0530 Message-Id: <20240501121742.1215792-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051914_757254_BE99724B X-CRM114-Status: GOOD ( 13.98 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Replace the dummy implementation for PCI related functions with actual implementation. This needs ECAM and MCFG CONFIG options to be enabled for RISC-V. Signed-off-by: Sunil V L --- arch/riscv/Kconfig | 2 ++ arch/riscv/kernel/acpi.c | 31 ++++++++++++++----------------- drivers/pci/pci-acpi.c | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index f7a36d79ff1a..09a86256ddfa 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -13,6 +13,7 @@ config 32BIT config RISCV def_bool y select ACPI_GENERIC_GSI if ACPI + select ACPI_MCFG if (ACPI && PCI) select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ARCH_ACPI_DEFERRED_GSI if ACPI select ARCH_DMA_DEFAULT_COHERENT @@ -176,6 +177,7 @@ config RISCV select OF_EARLY_FLATTREE select OF_IRQ select PCI_DOMAINS_GENERIC if PCI + select PCI_ECAM if (ACPI && PCI) select PCI_MSI if PCI select RISCV_ALTERNATIVE if !XIP_KERNEL select RISCV_APLIC diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c index e619edc8b0cc..41aa77c8484b 100644 --- a/arch/riscv/kernel/acpi.c +++ b/arch/riscv/kernel/acpi.c @@ -306,29 +306,26 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) #ifdef CONFIG_PCI /* - * These interfaces are defined just to enable building ACPI core. - * TODO: Update it with actual implementation when external interrupt - * controller support is added in RISC-V ACPI. + * raw_pci_read/write - Platform-specific PCI config space access. */ -int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, - int reg, int len, u32 *val) +int raw_pci_read(unsigned int domain, unsigned int bus, + unsigned int devfn, int reg, int len, u32 *val) { - return PCIBIOS_DEVICE_NOT_FOUND; -} + struct pci_bus *b = pci_find_bus(domain, bus); -int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, - int reg, int len, u32 val) -{ - return PCIBIOS_DEVICE_NOT_FOUND; + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->read(b, devfn, reg, len, val); } -int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +int raw_pci_write(unsigned int domain, unsigned int bus, + unsigned int devfn, int reg, int len, u32 val) { - return -1; -} + struct pci_bus *b = pci_find_bus(domain, bus); -struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) -{ - return NULL; + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->write(b, devfn, reg, len, val); } + #endif /* CONFIG_PCI */ diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index e8d84fa435da..b5892d0fa68c 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1521,7 +1521,7 @@ static int __init acpi_pci_init(void) } arch_initcall(acpi_pci_init); -#if defined(CONFIG_ARM64) +#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) /* * Try to assign the IRQ number when probing a new device From patchwork Wed May 1 12:17: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: 13650565 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 1A090C4345F for ; Wed, 1 May 2024 12:38: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=pETFBfsSYGoY1wXXFX6fORfEQl0WHgF1QcuZEjBDSHo=; b=OxiysxsgD+Bvuw FkjRuLUueEZz798TqvWVeSfBV92ETBtGXamoVeYAjKyqoD+HOC/XCvbDzjezWqANhk1QfdZPZdXPE 6+3HqP9cAv61vDhnA0kd7YVmBPJk1PHXxIreRSnsfxcYabufmGB2Hhp0CNaPIvobim54jE0od7GX4 BRuS2ZlUMu8FnUWiItHHyMNx4xaEN+bc/oXQLe4vhJQrvckcA8hdtBepVsHsV0oSXH5k7atdVmfcM iRfUpfdwziqGk3J5T/oH0S5dzsbLw55kY4OCxo9cs5Vx0qej9FRoNkXjad6rBV4xwwBHQz8GcaXlX yr9LLzRG+O+h0IVIOZsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29Dl-00000009V0j-1Qc8; Wed, 01 May 2024 12:38:01 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28vi-00000009N1q-2D37 for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:19:23 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e3c9300c65so57041965ad.0 for ; Wed, 01 May 2024 05:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565962; x=1715170762; 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=Xxd/snqLqM7e5ONTmxzheAfPAEAmi9DZ2uBd4oJ/FYs=; b=DCY5LEN8GPHiIVrBMo9m50A9lxpa2xu2lNln25RsHqgWDHfos2cDMCxrVw/3aE+HJr jBS4XMIrS7SzTZTv6NxQmnA+GZPDbat8WXs6WNDsy5sE/DApazN7jwNYzgrCFgMpC/66 uaTJ9m6013irYQePFI2+k12pzPoq/Y/9y0Q3Cfb3Zvt/3sNxdwJ+Bs1gxzATnwTtpb+I opVsUSsUAevVYd/lyLkUgTeqNHo/zoRgcRvv0tzLiZCmCH510fwSSdIGC90T37IBE1SM gSd9AharHYKfIoCbasIT3m+sCXIhSTh+xHmvb4bU+nlHC8AsVYYY1DpjbQJHU1qLrjIs KAiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565962; x=1715170762; 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=Xxd/snqLqM7e5ONTmxzheAfPAEAmi9DZ2uBd4oJ/FYs=; b=XLimo1vU8ixfxmNb7vG4W0eAso7AOvOabbyL6wfqZDwN+WGxHRLZ415D7AOSCnBQzD IJpxlrQnqnndxwsIaRpVjbbhgwU7iNeNr23mp63zoSXs0Y1sSysW21y+MDTMebti06jm AtnWI2gxkqgwp1GZ7x+SxE9Ds0SR+3b98dRr9en6RK/vIZRNxoV5v0yUMqU3pyslGPsV vzEDxHrcIrjLOVGQctvAZKvI36KEUGSis2PzawJZna+uPUMy721YV+MOmCAeKWzgcVyZ nYeUE6ZBVfshs3SqEnPepyC0EsaUBvm7MUeDcnAwjVYJFmc7D/2dKTVhNxIwADgrZxAO /t/A== X-Forwarded-Encrypted: i=1; AJvYcCVtGV9EOF5u8syRrcWFthceG2RqhSsz57A8cjfVHSn4akKMhsttrgCTF1Tzri7u+c/ZAb9udmYHo99qELNIZybsCY3qSEW5Rv1tNYIboNWo X-Gm-Message-State: AOJu0Yzkw68m37nemGU91nRPKpG0DceSmqbsQQQWecM/pzenxIkqUZ8m vOZXB0KaexZE59m6Rluattr0JDeVaAN4DDOhAMBNu4dAy6Lh/RTulW+X/kC/knI= X-Google-Smtp-Source: AGHT+IGHJ7p4jwXpu3JYkUWYmOJNcHmWpwQOeQhUAAD/vtuVqVDXO7Ep5uVJu5jo4IP3B8sXFyhN1A== X-Received: by 2002:a17:902:f68e:b0:1e4:24cc:e021 with SMTP id l14-20020a170902f68e00b001e424cce021mr2637625plg.50.1714565961718; Wed, 01 May 2024 05:19:21 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:19:21 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 10/17] ACPI: RISC-V: Implement function to reorder irqchip probe entries Date: Wed, 1 May 2024 17:47:35 +0530 Message-Id: <20240501121742.1215792-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051922_603278_18AAA36A X-CRM114-Status: GOOD ( 16.16 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org ACPI MADT entries for interrupt controllers don't have a way to describe the hierarchy. However, the hierarchy is known to the architecture and on RISC-V platforms, the MADT sub table types are ordered in the incremental order from the root controller which is RINTC. So, add architecture function for RISC-V to reorder the interrupt controller probing as per the hierarchy as below. Signed-off-by: Sunil V L --- drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/irq.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/irq.c diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 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..f56e103a501f --- /dev/null +++ b/drivers/acpi/riscv/irq.c @@ -0,0 +1,32 @@ +// 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); +} + +/* + * RISC-V irqchips in MADT of ACPI spec are defined in the same order how + * they should be probed. Since IRQCHIP_ACPI_DECLARE doesn't define any + * order, this arch function will reorder the probe functions as per the + * required order for the architecture. + */ +void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) +{ + struct acpi_probe_entry *ape = ap_head; + + if (nr == 1 || !ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) + return; + sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); +} From patchwork Wed May 1 12:17: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: 13650566 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 5C6CBC4345F for ; Wed, 1 May 2024 12:38:21 +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=QFq5xDfBlg/DEI1vIOXpnF3QP5uJe/4ImKurILL8koI=; b=0EFc8Tu2nZ1pQZ 1IJY/AIve5aWfChDL9Wne2atq3uGIpWQPGXn8iTpPs95EG58LMAF3iMeehsksjpTYtZBgMJB+jNIg ScU9Zzbizwa0XgWg5xCRynTkP255EmZIBwjgcBBPHguU7pAVL5NFkh7tQCKbL6K3TeoqA36Vka8gT 6PdTzS/cNewcWeqM0IQDV4iitVeQxKE4D1UioPiN9jhYAaFJ0U74LM8sAbZVdz35vX0MwAOPjTx77 pbryH7DhRF4JhSRwMPblGmsfBxpw6/UcliYfGpcjbZkCimC714fH+xn8PmuMPm3eahjtF75AnzrC1 sjF5u3xW42C5vpS65x7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29Dy-00000009V96-47ll; Wed, 01 May 2024 12:38:15 +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 1s28vq-00000009N64-2WxS for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:19:32 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ec4b2400b6so14639555ad.3 for ; Wed, 01 May 2024 05:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565969; x=1715170769; 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=Dz2b5NSEn3co4GBYyIFhq4o1B5yNhLUdwhxGlUjO5R4=; b=U9HksR+9+sN+J0AXIlYW5e38tM728CswrCka8gPlVvAqFiIL5cPb2b4znKaWkoae4H 3iQFWbkk9qMh/Qwnr/MTJZHGaDUkEqkRlfTzgmCvC8WVh4RHeb0cNI2DRKD/Yc0w7vlo z8yxCTGF28J1dVslLTu70bSb5QF2CzMc4XUkp3wHGrWGnDrMPYBQLHkWfWX0A/20U+of IZW3HC7PSLWzi9OkR2VDqfPMbkv0VMeDaYIkb3iYX/JlRyk4P5gBILX/aclFT2yG0BkU Bo1sD6ckUDXZMCAAOKoMaP8Z5puCAcRJ5n3z7wyNHNlKbNGXhGjE8xEdElp3YnrlCcPm D27g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565969; x=1715170769; 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=Dz2b5NSEn3co4GBYyIFhq4o1B5yNhLUdwhxGlUjO5R4=; b=AV/rpkAQSgntSWGLAjB5wVP6G7e/i4Nf2QSOTDUhHuDW0GJgq/zSLJ/v0fS+S2vohH Skp1qOxgZ2v5xHdUszaP4wmwvAfSw9L6WF8YjL5zyqnqXMUQZtVkREBBRwKaC4f1dJpX GYkBMZpNwiLIf405ukQ3uYWlQ+gvyQG1BSQnYVaF7X/KlkX035u1x3X3yw6NUG971IfD VK+tGTj7/QpcK/fm9KtL08cDlvPpssq3nWHW3cwRjN5ZJyTfgGqL+kN9IQ6spliE5seo h1E6Usqt8fEemEs96lVqm/4kDFtEbJ6682kTntrHzfSH3FW6T1gmiMPqDYnURxq4fdLP eWjw== X-Forwarded-Encrypted: i=1; AJvYcCXTqRXXAg58EspTJOl/OF85MPM+9JBLAhabTZa6+pQxRAuzPh5WQ6s94bpY9L6ilJeLuCZZZXXDuubTbxgX+AFukIavczqTtldNc/d1uv/X X-Gm-Message-State: AOJu0Yz4tRQFzcUqGRCUGX+KwrzHUlLM9h2ZyxPk7Yrdpuo+EVuS+0nU i8TP4/M0UoH9R8Tfy1E3MUrrlF9PK97ZhYuvazqH3LNITZyDsu4llu0GWu7i0g8= X-Google-Smtp-Source: AGHT+IGuRwan9lf3M8PVSXZJfG+1Q3Prn5rtC3kcGZRvNV0TM+LqWfnB21N8buGjJXUbpyfls7vG+g== X-Received: by 2002:a17:902:6506:b0:1e4:471f:2fa1 with SMTP id b6-20020a170902650600b001e4471f2fa1mr2381346plk.24.1714565969394; Wed, 01 May 2024 05:19:29 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:19:28 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 11/17] ACPI: RISC-V: Initialize GSI mapping structures Date: Wed, 1 May 2024 17:47:36 +0530 Message-Id: <20240501121742.1215792-12-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051930_831422_5CC650CC X-CRM114-Status: GOOD ( 20.47 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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 | 142 +++++++++++++++++++++++++++++++++++ 4 files changed, 170 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 f56e103a501f..0473428e8d1e 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -7,6 +7,21 @@ #include #include +#include + +#include "init.h" + +struct riscv_ext_intc_list { + acpi_handle handle; + u32 gsi_base; + u32 nr_irqs; + u32 nr_idcs; + u32 id; + u32 type; + struct list_head list; +}; + +LIST_HEAD(ext_intc_list); static int irqchip_cmp_func(const void *in0, const void *in1) { @@ -30,3 +45,130 @@ void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) return; sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); } + +static void 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; + } + } + + acpi_handle_err(handle, "failed to find the GSI mapping entry\n"); +} + +int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, + u32 *id, u32 *nr_irqs, u32 *nr_idcs) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i, *tmp; + + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element = list_entry(i, struct riscv_ext_intc_list, list); + if (ext_intc_element->handle == ACPI_HANDLE_FWNODE(fwnode)) { + *gsi_base = ext_intc_element->gsi_base; + *id = ext_intc_element->id; + *nr_irqs = ext_intc_element->nr_irqs; + if (nr_idcs) + *nr_idcs = ext_intc_element->nr_idcs; + + return 0; + } + } + + return -ENODEV; +} + +struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 gsi) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct acpi_device *adev; + struct list_head *i, *tmp; + + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element = list_entry(i, struct riscv_ext_intc_list, list); + if (gsi >= ext_intc_element->gsi_base && + gsi < (ext_intc_element->gsi_base + ext_intc_element->nr_irqs)) { + adev = acpi_fetch_acpi_dev(ext_intc_element->handle); + if (!adev) + return NULL; + + return acpi_fwnode_handle(adev); + } + } + + return NULL; +} + +static int __init riscv_acpi_register_ext_intc(u32 gsi_base, u32 nr_irqs, u32 nr_idcs, + u32 id, u32 type) +{ + struct riscv_ext_intc_list *ext_intc_element; + + ext_intc_element = kzalloc(sizeof(*ext_intc_element), GFP_KERNEL); + if (!ext_intc_element) + return -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_OK; + } + + status = acpi_evaluate_integer(handle, "_GSB", NULL, &gbase); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to evaluate _GSB method\n"); + return AE_OK; + } + + riscv_acpi_update_gsi_handle((u32)gbase, handle); + return AE_OK; +} + +static int __init riscv_acpi_aplic_parse_madt(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_madt_aplic *aplic = (struct acpi_madt_aplic *)header; + + 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 Wed May 1 12:17: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: 13650567 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 1F3C8C4345F for ; Wed, 1 May 2024 12:38: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=WPOmeyvtS5Vq/5i/6bxJ/8z9LjtNUFVnz9ww+Ux0kqI=; b=vAMk35QDYI3Se0 OxtjMxISTSOi6fU8jfOCyE/PntUP37XEuggtK24OpP5KSd0sFGnCKlIEjw8O5vPFZv5d7QlJNB5Jp kLE2yT7Pc2hwMUr/emkpXoKrwIdMOZdgpFT71C9efwWi5bY3XG6jbr8//P/J54QiQJvCbo9aq6JOK dnMGbU0Ekxbz3HCZoP8Qx1p9gjBCExn1FBukOCJTSiCbd5Z0YmPFcikUXo5hn+7DqvaW8MvRK3zKb 1VkO1VQrLD46WeZU2L/Wpvl9NDdzzPWhC115ajD7tdgKdZbhQBqX/c7+0eGirf0bcBAM1n2H+1/dS zBk2eGABdnAi3wsOEtDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29E5-00000009VFA-2f99; Wed, 01 May 2024 12:38:21 +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 1s28vx-00000009NAE-3Fzr for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:19:39 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ec5387aed9so13699515ad.3 for ; Wed, 01 May 2024 05:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565977; x=1715170777; 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=BG93T+gcNC0mbkbP77au2VNz1Cnxnueu2TjA3uMrqLg=; b=EkCdIlFwyJnxpT3iB126yqbLtdxWZ2EIGnmWeKv7Lyh/+spys80twwUfMyuIjDVYIY o0hvVW2apRa1uw7agQEWoQxhwQerBSO8fXsaXST/SlvvUVrxd5bXSYyrxibc97Rukscm z5aZNNCV+LzAaSEQuC80x0nkaUGr9dTW4WQm7qI6H7DAxsSIf1BT6k1wRj35KFqHxOWQ 3Zqkr05ZSfm/5JYDck36YRVCQsJL+D1TwvU5q1kPsDEZMYBlXoCZeYMGN+acM8Pt7zGJ nA44tE37NvfFygETrV2UbkgDldVkvSsBUAmKcN+aFEYLCqvlRXuzTfuHXs9KLFC34yJW 95wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565977; x=1715170777; 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=BG93T+gcNC0mbkbP77au2VNz1Cnxnueu2TjA3uMrqLg=; b=VsJTQMSB8XpSDedr4ne2iKPhelkSdMiLQBHEs/qcHc9irgXrZBLYztyZqvwSRev4Fg /YVHDpz5SjA5DNIqybF4deXAKWJxYG4cX5sHEJbuQea+aK1U8Y2gMilfdamZ3i0kCkDo fheUYIU77n3gpE/6xlDhKTiEeR/HrdEC8dWwvZw/vpbb19gcpMGqJHceQeqRWH0Ue5aD D9DIaVhZ0qgd+DXYCyBZSPqAH2dK1wn4C6IHsNIP6Nmf1vYqMECOTPsKA33YQQNZfWp8 TGpuBgC30x2+tetOTg1A2JMvlkDc9mXy4SvJEb1GzcBKo/B+TjOEnu8enCxY4pkPqfYB byqA== X-Forwarded-Encrypted: i=1; AJvYcCVrCa3PJU98ELuNQ29pmWrS2uzdRDB+iSodDwg25ZrJQIcWlv3yfsa1tf33EFEMTknwOWaP4RkC3+Eilu5cr+Cuazuesm3MYFv4+X9rV+ES X-Gm-Message-State: AOJu0Yx/d7Kl6pN89Ww/1Ut+jNWcI7YkXbtSCSIoLWd9Nv+xV20/Njhw JVMjm5ztUvTzqYfzZyPPYVpvDBf3fRkwNQLl7j3Eh9uYKTtvoI7g55siRypsF3o= X-Google-Smtp-Source: AGHT+IGLOIZZtL2TIDSeb766WeGWfcN19Dx07RhHbWbDtJL/7Xyje2/Url/yzqxWmbrfaaNC2lVwOw== X-Received: by 2002:a17:902:eecc:b0:1eb:2988:549d with SMTP id h12-20020a170902eecc00b001eb2988549dmr2035967plb.40.1714565977219; Wed, 01 May 2024 05:19:37 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:19:36 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 12/17] ACPI: RISC-V: Implement function to add implicit dependencies Date: Wed, 1 May 2024 17:47:37 +0530 Message-Id: <20240501121742.1215792-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051937_884986_95990A58 X-CRM114-Status: GOOD ( 20.85 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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 0473428e8d1e..2878ae48131f 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -21,6 +21,12 @@ struct riscv_ext_intc_list { struct list_head list; }; +struct acpi_irq_dep_ctx { + int rc; + unsigned int index; + acpi_handle handle; +}; + LIST_HEAD(ext_intc_list); static int irqchip_cmp_func(const void *in0, const void *in1) @@ -62,6 +68,21 @@ static void riscv_acpi_update_gsi_handle(u32 gsi_base, acpi_handle handle) acpi_handle_err(handle, "failed to find the GSI mapping entry\n"); } +static acpi_handle riscv_acpi_get_gsi_handle(u32 gsi) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i, *tmp; + + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element = list_entry(i, struct riscv_ext_intc_list, list); + if (gsi >= ext_intc_element->gsi_base && + gsi < (ext_intc_element->gsi_base + ext_intc_element->nr_irqs)) + return ext_intc_element->handle; + } + + return NULL; +} + int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, u32 *id, u32 *nr_irqs, u32 *nr_idcs) { @@ -172,3 +193,137 @@ 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_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 Wed May 1 12:17: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: 13650568 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 7B38CC4345F for ; Wed, 1 May 2024 12:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xJHcIU6OXlVwl4a1R7Dze6CM5oY+2agA/KoYETkQ4uU=; b=xPFpOdIh6Pk79g 7gnoEetLHSqdwVo3LA2E9hcu99tWZryJE7ZASpLtNJii2RFOQH+6jSBxFRkY8sCHGGowfX+gT7cfR IJx5saTVoHIpsgWrsfK7KwUJz4Mg8H7b+D3pW0g+XBKk36psUgwOpzeqHREc38eLVWwTOXR8GjMK0 oHi9Vjm1t8S0YDEqAJ5SR00CdgrimvAqFtdGCsJnenMCAXi7AqCN8vDlAYAAY4UKomw6a5vBL/fCV k0SSLaNu2QFYadbUjP2B84hpQhTijSx92elY5ScGglUVU+36v0BUsdHtnps+MexJS5jvfAT7X/J3x vMIHYxjjPkrUeqyF6Sog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29EI-00000009VPo-0xAm; Wed, 01 May 2024 12:38:34 +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 1s28w5-00000009NF1-3ix9 for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:19:47 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e5c7d087e1so57737405ad.0 for ; Wed, 01 May 2024 05:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565985; x=1715170785; 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=zCPPOR1ckSAJZ1Ubedg9t4QsI9vLkLXGoLfn+9ixWV8=; b=lN6oaiemZWf1oSYTGicCr4xcmEL2j4pF8BHd/kd7vCPcPGPLBbPtb5M9PBELYiBL2r e/ixKQmBKL7yC3JvjrRjPLs7YAwKP/VAaxhCa4yIPrelZtxmKqx1dIA3sslhdTkshl7+ rUW9XqNHSUCaWmloCekhkoa9fCuDe6KmRhFH3Yzf5dLlV6oDB5GNf2PZ3kj4zDm0eJN4 z4CuWNb3NXLPKP5yWLkeYQ+koyuU8nYEkIINDa+u5NASOM2Ygm4h1aZ0S/H+18Xs8ZVR 9C7D07xj2GjnJmmbBfsoXX75U+2SRLx6cIGW+evnzDNw8lpMr+Y+oFwbtIfmC+iIGfrn dLHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565985; x=1715170785; 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=zCPPOR1ckSAJZ1Ubedg9t4QsI9vLkLXGoLfn+9ixWV8=; b=umi+i5ZaoYWnpb1425aGUIwEkvNIvp/Tc1bWKM+sIZ41GROlh9x7p9dqfcY+Bdt/g7 cGrxciXsh5PSLuSAwtWrQt1RJnwsiDDtmmBsBc1rVYMstNn7BMZadAjcmRj4k/h2E25m mowjr40YHpQ/VYddklT4G3Q9zTnIfCCf4xkLU8osQEpVEF7BpC1AIu2um1wMy9oKqKo5 4UgF3Uoiu7+ywc8bVxDmbb5rQCMPR5Ddh7MR/WrSbr2DQTJqNoJaq6caUIaErYjeD1rD lX3PKqsLFEwQes/zBNeYmfJ0pMigmtdXzPPXNHALLwrFJB459XFcNfUWuXkh3cCPtUYU hNfA== X-Forwarded-Encrypted: i=1; AJvYcCWNbepNBBSucBde/ISzhyf+S/WMCslfNbT3P8DEjuFSup9gfMXBcdsmNGyi0Nba4EAT8KkglDQOVegcMebLEUXuNne19AX8kp2USbrVI0K6 X-Gm-Message-State: AOJu0YwXNsYN4+SUREc3ivSx+eC3xZqQA1ucNJ072Rar/DDrGBiGpUE1 9j1RRxaKzW94Pvlq4psoyeZ6YDrxbHjeAbBKU4/Y4fJQQ1sVq4ih/mNdnPYs36s= X-Google-Smtp-Source: AGHT+IFGyfzN/5kExRpukpNj4St1rBgfudB/pj+gt5M5G+xrt6pZdmPm+vpc0dav1zcXRIM1c0Qiiw== X-Received: by 2002:a17:902:e841:b0:1eb:66b6:930b with SMTP id t1-20020a170902e84100b001eb66b6930bmr2252492plg.55.1714565984846; Wed, 01 May 2024 05:19:44 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:19:44 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 13/17] irqchip/riscv-intc: Add ACPI support for AIA Date: Wed, 1 May 2024 17:47:38 +0530 Message-Id: <20240501121742.1215792-14-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051946_038517_74C9F926 X-CRM114-Status: GOOD ( 18.20 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The RINTC subtype structure in MADT also has information about other interrupt controllers. Save this information and provide interfaces to retrieve them when required by corresponding drivers. Signed-off-by: Sunil V L --- arch/riscv/include/asm/irq.h | 35 +++++++++++ drivers/irqchip/irq-riscv-intc.c | 102 ++++++++++++++++++++++++++++++- 2 files changed, 135 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 44a0b128c602..6bd578b1ffc9 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -25,9 +25,22 @@ enum riscv_irqchip_type { ACPI_RISCV_IRQCHIP_APLIC = 0x03, }; +/* + * The ext_intc_id format is as follows: + * Bits [31:24] APLIC/PLIC ID + * Bits [15:0] APLIC IDC ID / PLIC S-Mode Context ID for this hart + */ +#define APLIC_PLIC_ID(x) ((x) >> 24) +#define IDC_CONTEXT_ID(x) ((x) & 0x0000ffff) + int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, u32 *id, u32 *nr_irqs, u32 *nr_idcs); struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 gsi); +int __init acpi_get_intc_index_hartid(u32 index, unsigned long *hartid); +int acpi_get_ext_intc_parent_hartid(u8 id, u32 idx, unsigned long *hartid); +void acpi_get_plic_nr_contexts(u8 id, int *nr_contexts); +int acpi_get_plic_context(u8 id, u32 idx, int *context_id); +int __init acpi_get_imsic_mmio_info(u32 index, struct resource *res); #else static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, @@ -36,6 +49,28 @@ static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi return 0; } +static inline int __init acpi_get_intc_index_hartid(u32 index, unsigned long *hartid) +{ + return -EINVAL; +} + +static inline int acpi_get_ext_intc_parent_hartid(u8 id, u32 idx, unsigned long *hartid) +{ + return -EINVAL; +} + +static inline void acpi_get_plic_nr_contexts(u8 id, int *nr_contexts) { } + +static inline int acpi_get_plic_context(u8 id, u32 idx, int *context_id) +{ + return -EINVAL; +} + +static inline int __init acpi_get_imsic_mmio_info(u32 index, struct resource *res) +{ + return 0; +} + #endif /* CONFIG_ACPI */ #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 9e71c4428814..af7a2f78f0ee 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -249,14 +249,105 @@ IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init); IRQCHIP_DECLARE(andes, "andestech,cpu-intc", riscv_intc_init); #ifdef CONFIG_ACPI +struct rintc_data { + u32 ext_intc_id; + unsigned long hart_id; + u64 imsic_addr; + u32 imsic_size; +}; + +static u32 nr_rintc; +static struct rintc_data *rintc_acpi_data[NR_CPUS]; + +int acpi_get_intc_index_hartid(u32 index, unsigned long *hartid) +{ + if (index >= nr_rintc) + return -1; + + *hartid = rintc_acpi_data[index]->hart_id; + return 0; +} + +int acpi_get_ext_intc_parent_hartid(u8 id, u32 idx, unsigned long *hartid) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) { + if (idx == j) { + *hartid = rintc_acpi_data[i]->hart_id; + return 0; + } + j++; + } + } + + return -1; +} + +void acpi_get_plic_nr_contexts(u8 id, int *nr_contexts) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) + j++; + } + + *nr_contexts = j; +} + +int acpi_get_plic_context(u8 id, u32 idx, int *context_id) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) { + if (idx == j) { + *context_id = IDC_CONTEXT_ID(rintc_acpi_data[i]->ext_intc_id); + return 0; + } + + j++; + } + } + + return -1; +} + +int acpi_get_imsic_mmio_info(u32 index, struct resource *res) +{ + if (index >= nr_rintc) + return -1; + + res->start = rintc_acpi_data[index]->imsic_addr; + res->end = res->start + rintc_acpi_data[index]->imsic_size - 1; + res->flags = IORESOURCE_MEM; + return 0; +} + +static struct fwnode_handle *ext_entc_get_gsi_domain_id(u32 gsi) +{ + return riscv_acpi_get_gsi_domain_id(gsi); +} static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, const unsigned long end) { - struct fwnode_handle *fn; struct acpi_madt_rintc *rintc; + struct fwnode_handle *fn; + int rc; rintc = (struct acpi_madt_rintc *)header; + rintc_acpi_data[nr_rintc] = kzalloc(sizeof(*rintc_acpi_data[0]), GFP_KERNEL); + if (!rintc_acpi_data[nr_rintc]) + return -ENOMEM; + + rintc_acpi_data[nr_rintc]->ext_intc_id = rintc->ext_intc_id; + rintc_acpi_data[nr_rintc]->hart_id = rintc->hart_id; + rintc_acpi_data[nr_rintc]->imsic_addr = rintc->imsic_addr; + rintc_acpi_data[nr_rintc]->imsic_size = rintc->imsic_size; + nr_rintc++; /* * The ACPI MADT will have one INTC for each CPU (or HART) @@ -273,7 +364,14 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, return -ENOMEM; } - return riscv_intc_init_common(fn, &riscv_intc_chip); + rc = riscv_intc_init_common(fn, &riscv_intc_chip); + if (rc) { + irq_domain_free_fwnode(fn); + return rc; + } + + acpi_set_irq_model(ACPI_IRQ_MODEL_RINTC, ext_entc_get_gsi_domain_id); + return 0; } IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL, From patchwork Wed May 1 12:17: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: 13650569 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 5F728C4345F for ; Wed, 1 May 2024 12:38:50 +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=n7DGJFZ9C6fdOt3haUH5k3jxM/9FSc0b1zhz7PYMw6E=; b=yz6YQfcoLjy7qd PeS/kC1HJKpoxuxgaHhReBLZvh8zt2eiU6w+bd/posn+sLm/rTLoSdAgr07aeTFUNl0wOmmnFOSrk ocNcO6py8nrk+V4ICkstjzpjXBRFVIOMGLzkLkbuuEf/mQuNgkFdny//cbFWPILu0cVZgacr0XLUz hLJWnkaEN9+7hWYhRNgJRTvF2vVho/0lihvepsYUwpe3JI8nIpZ/R4LG65IiJpiH3dytyOZ+7wUW5 MxxcfPbHfYaFXK8nh2oZGmwXRknZd3S8GSqo2UrEWeP0stBwHvR2LU2h1FREoemI5ZNB6ov2PIxX3 Hm5wS7P3TVW1IKPlDZcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29ET-00000009VX0-03uP; Wed, 01 May 2024 12:38:45 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28wD-00000009NIv-2wAO for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:19:55 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6edc61d0ff6so6693260b3a.2 for ; Wed, 01 May 2024 05:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565992; x=1715170792; 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=EXYTa+lyps4skrflQeX/iviyMZf5mebO38NcRgvfQY0=; b=bTI0HuCCXhMjEUpXYPGDZiVlO/JKbbdOutstPrxUzhE2noWxgC1V0o2VvCNejTu1Py Iz6aVN9rMvYWVbegDdeWB6cBHz/si08ZLjfhAUk5x+CDaYP+gtzwtpPeMYeccLXjDsRd iuu3F9GitNZvoVJPpspyB3HxcCqQnUy2WJzDKgfUdowAn9Os4wwvD4PKnP81ImlcYn8P 6n1bXzQ1sxrsJil0rRZICAIQQcKRhIvvknGsNwnMGiBsHe/fYSwwx5k17Z4L90Qegnjn lVRVV6Y7vXPP9JmxXgHfiIlVR2RmXzc91Uix205InzXSzx5NueMeW9y676o2xR4dC/l8 rDsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565992; x=1715170792; 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=EXYTa+lyps4skrflQeX/iviyMZf5mebO38NcRgvfQY0=; b=OQaAQSr8WMlA/0txsygnSH4kHgJCguLgw4kWl4ejpKfbqDKfmQpX9bARmfbAFfjpkO CqyOwEpLOx5fA9yl5Y/i0GBBS6mU6oGgvzXAE4EZvZbQ2x2NKNWRf+zlmUQ50ykGQKSE T8hV4/hcJB7JQX0GjjZ+TixeVL+V/HqSDTm2gipJIqUjz/io+QntqmQVzzq/WhldNBIZ KQvt77FcWWcphgB2HMAEEDdgXxabK1kO+zeMZvECCkQnUlvmcOLe5mZ8WyezaDyWwijj /TcqyNtTYdOpBWHT1jok8EXr3Hncyygw98/0n+mVk+lYbjgs3MxAgLtxLeICT+fJ9Lgm n6sQ== X-Forwarded-Encrypted: i=1; AJvYcCW6NIebFom0YjrmoIm7tI5gAyy4pcmwN2/oHYWPs7wK7ePus8At10xUyhXVY83XFglcTaBSokewlEODcxFboHNa8GmezXDRmyxX6y6LKqE1 X-Gm-Message-State: AOJu0YwCKFlUsV1bmzvv8yYPFKeQHN2ddQ4t9DER3wxN1I+1tskr7nyq mZ9/EV2FBZc5+DTS2Z4CYeMrZwZvMM+icskX8gxbOeiP2JXD5G03kJoBx8//QgU= X-Google-Smtp-Source: AGHT+IEYbbDg76A7S1g52ZK/aOehSAGVOKJv35qqCM5C5Vw6MRuD5Sdk6WDNaIS+1kkWSucq//am/w== X-Received: by 2002:a17:90b:1c0b:b0:2b3:2a3b:e4a0 with SMTP id oc11-20020a17090b1c0b00b002b32a3be4a0mr1170711pjb.32.1714565992555; Wed, 01 May 2024 05:19:52 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:19:52 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 14/17] irqchip/riscv-imsic: Add ACPI support Date: Wed, 1 May 2024 17:47:39 +0530 Message-Id: <20240501121742.1215792-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_051953_773973_74CCA4C8 X-CRM114-Status: GOOD ( 24.98 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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, ACPI, both IPI and MSI features need to be initialized early itself. Signed-off-by: Sunil V L --- drivers/irqchip/irq-riscv-imsic-early.c | 52 +++++++++- drivers/irqchip/irq-riscv-imsic-platform.c | 32 ++++-- drivers/irqchip/irq-riscv-imsic-state.c | 115 ++++++++++----------- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- include/linux/irqchip/riscv-imsic.h | 10 ++ 5 files changed, 144 insertions(+), 67 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index 886418ec06cb..d8161243791d 100644 --- a/drivers/irqchip/irq-riscv-imsic-early.c +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -5,13 +5,16 @@ */ #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include #include #include #include +#include #include +#include #include #include @@ -182,7 +185,7 @@ static int __init imsic_early_dt_init(struct device_node *node, struct device_no int rc; /* Setup IMSIC state */ - rc = imsic_setup_state(fwnode); + rc = imsic_setup_state(fwnode, NULL); if (rc) { pr_err("%pfwP: failed to setup state (error %d)\n", fwnode, rc); return rc; @@ -199,3 +202,50 @@ static int __init imsic_early_dt_init(struct device_node *node, struct device_no } IRQCHIP_DECLARE(riscv_imsic, "riscv,imsics", imsic_early_dt_init); + +#ifdef CONFIG_ACPI + +static struct fwnode_handle *imsic_acpi_fwnode; + +struct fwnode_handle *imsic_acpi_get_fwnode(struct device *dev) +{ + return imsic_acpi_fwnode; +} + +static int __init imsic_early_acpi_init(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_madt_imsic *imsic = (struct acpi_madt_imsic *)header; + int rc; + + imsic_acpi_fwnode = irq_domain_alloc_named_fwnode("imsic"); + if (!imsic_acpi_fwnode) { + pr_err("unable to allocate IMSIC FW node\n"); + return -ENOMEM; + } + + /* Setup IMSIC state */ + rc = imsic_setup_state(imsic_acpi_fwnode, (void *)imsic); + if (rc) { + pr_err("%pfwP: failed to setup state (error %d)\n", imsic_acpi_fwnode, rc); + return rc; + } + + /* Do early setup of IMSIC state and IPIs */ + rc = imsic_early_probe(imsic_acpi_fwnode); + if (rc) + return rc; + + rc = imsic_platform_acpi_probe(imsic_acpi_fwnode); + +#ifdef CONFIG_PCI + if (!rc) + pci_msi_register_fwnode_provider(&imsic_acpi_get_fwnode); +#endif + + return rc; +} + +IRQCHIP_ACPI_DECLARE(riscv_imsic, ACPI_MADT_TYPE_IMSIC, NULL, + 1, imsic_early_acpi_init); +#endif diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 11723a763c10..64905e6f52d7 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -5,6 +5,7 @@ */ #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include @@ -348,18 +349,37 @@ int imsic_irqdomain_init(void) return 0; } -static int imsic_platform_probe(struct platform_device *pdev) +static int imsic_platform_probe_common(struct fwnode_handle *fwnode) { - struct device *dev = &pdev->dev; - - if (imsic && imsic->fwnode != dev->fwnode) { - dev_err(dev, "fwnode mismatch\n"); + if (imsic && imsic->fwnode != fwnode) { + pr_err("%pfwP: fwnode mismatch\n", fwnode); return -ENODEV; } return imsic_irqdomain_init(); } +static int imsic_platform_dt_probe(struct platform_device *pdev) +{ + return imsic_platform_probe_common(pdev->dev.fwnode); +} + +#ifdef CONFIG_ACPI + +/* + * On ACPI based systems, PCI enumeration happens early during boot in + * acpi_scan_init(). PCI enumeration expects MSI domain setup before + * it calls pci_set_msi_domain(). Hence, unlike in DT where + * imsic-platform drive probe happens late during boot, ACPI based + * systems need to setup the MSI domain early. + */ +int imsic_platform_acpi_probe(struct fwnode_handle *fwnode) +{ + return imsic_platform_probe_common(fwnode); +} + +#endif + static const struct of_device_id imsic_platform_match[] = { { .compatible = "riscv,imsics" }, {} @@ -370,6 +390,6 @@ static struct platform_driver imsic_platform_driver = { .name = "riscv-imsic", .of_match_table = imsic_platform_match, }, - .probe = imsic_platform_probe, + .probe = imsic_platform_dt_probe, }; builtin_platform_driver(imsic_platform_driver); diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 5479f872e62b..608b87dd0784 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -5,6 +5,7 @@ */ #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include @@ -516,12 +517,8 @@ static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, struct of_phandle_args parent; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ if (!is_of_node(fwnode)) - return -EINVAL; + return acpi_get_intc_index_hartid(index, hartid); rc = of_irq_parse_one(to_of_node(fwnode), index, &parent); if (rc) @@ -540,12 +537,8 @@ static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, static int __init imsic_get_mmio_resource(struct fwnode_handle *fwnode, u32 index, struct resource *res) { - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ if (!is_of_node(fwnode)) - return -EINVAL; + return acpi_get_imsic_mmio_info(index, res); return of_address_to_resource(to_of_node(fwnode), index, res); } @@ -553,20 +546,15 @@ static int __init imsic_get_mmio_resource(struct fwnode_handle *fwnode, static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, struct imsic_global_config *global, u32 *nr_parent_irqs, - u32 *nr_mmios) + u32 *nr_mmios, + void *opaque) { + struct acpi_madt_imsic *imsic = (struct acpi_madt_imsic *)opaque; unsigned long hartid; struct resource res; int rc; u32 i; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(fwnode)) - return -EINVAL; - *nr_parent_irqs = 0; *nr_mmios = 0; @@ -578,51 +566,60 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, return -EINVAL; } - /* Find number of guest index bits in MSI address */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", - &global->guest_index_bits); - if (rc) - global->guest_index_bits = 0; + if (is_of_node(fwnode)) { + /* Find number of guest index bits in MSI address */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", + &global->guest_index_bits); + if (rc) + global->guest_index_bits = 0; - /* Find number of HART index bits */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,hart-index-bits", - &global->hart_index_bits); - if (rc) { - /* Assume default value */ - global->hart_index_bits = __fls(*nr_parent_irqs); - if (BIT(global->hart_index_bits) < *nr_parent_irqs) - global->hart_index_bits++; - } + /* Find number of HART index bits */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,hart-index-bits", + &global->hart_index_bits); + if (rc) { + /* Assume default value */ + global->hart_index_bits = __fls(*nr_parent_irqs); + if (BIT(global->hart_index_bits) < *nr_parent_irqs) + global->hart_index_bits++; + } - /* Find number of group index bits */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", - &global->group_index_bits); - if (rc) - global->group_index_bits = 0; + /* Find number of group index bits */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", + &global->group_index_bits); + if (rc) + global->group_index_bits = 0; - /* - * Find first bit position of group index. - * If not specified assumed the default APLIC-IMSIC configuration. - */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", - &global->group_index_shift); - if (rc) - global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; + /* + * Find first bit position of group index. + * If not specified assumed the default APLIC-IMSIC configuration. + */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", + &global->group_index_shift); + if (rc) + global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; + + /* Find number of interrupt identities */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-ids", + &global->nr_ids); + if (rc) { + pr_err("%pfwP: number of interrupt identities not found\n", fwnode); + return rc; + } - /* Find number of interrupt identities */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-ids", - &global->nr_ids); - if (rc) { - pr_err("%pfwP: number of interrupt identities not found\n", fwnode); - return rc; + /* Find number of guest interrupt identities */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", + &global->nr_guest_ids); + if (rc) + global->nr_guest_ids = global->nr_ids; + } else { + global->guest_index_bits = imsic->guest_index_bits; + global->hart_index_bits = imsic->hart_index_bits; + global->group_index_bits = imsic->group_index_bits; + global->group_index_shift = imsic->group_index_shift; + global->nr_ids = imsic->num_ids; + global->nr_guest_ids = imsic->num_guest_ids; } - /* Find number of guest interrupt identities */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", - &global->nr_guest_ids); - if (rc) - global->nr_guest_ids = global->nr_ids; - /* Sanity check guest index bits */ i = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT; if (i < global->guest_index_bits) { @@ -688,7 +685,7 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, return 0; } -int __init imsic_setup_state(struct fwnode_handle *fwnode) +int __init imsic_setup_state(struct fwnode_handle *fwnode, void *opaque) { u32 i, j, index, nr_parent_irqs, nr_mmios, nr_handlers = 0; struct imsic_global_config *global; @@ -729,7 +726,7 @@ int __init imsic_setup_state(struct fwnode_handle *fwnode) } /* Parse IMSIC fwnode */ - rc = imsic_parse_fwnode(fwnode, global, &nr_parent_irqs, &nr_mmios); + rc = imsic_parse_fwnode(fwnode, global, &nr_parent_irqs, &nr_mmios, opaque); if (rc) goto out_free_local; diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index 5ae2f69b035b..391e44280827 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -102,7 +102,7 @@ void imsic_vector_debug_show_summary(struct seq_file *m, int ind); void imsic_state_online(void); void imsic_state_offline(void); -int imsic_setup_state(struct fwnode_handle *fwnode); +int imsic_setup_state(struct fwnode_handle *fwnode, void *opaque); int imsic_irqdomain_init(void); #endif diff --git a/include/linux/irqchip/riscv-imsic.h b/include/linux/irqchip/riscv-imsic.h index faf0b800b1b0..e08680b1932b 100644 --- a/include/linux/irqchip/riscv-imsic.h +++ b/include/linux/irqchip/riscv-imsic.h @@ -84,4 +84,14 @@ static inline const struct imsic_global_config *imsic_get_global_config(void) #endif +#ifdef CONFIG_ACPI +int imsic_platform_acpi_probe(struct fwnode_handle *fwnode); +struct fwnode_handle *imsic_acpi_get_fwnode(struct device *dev); +#else +static inline struct fwnode_handle *imsic_acpi_get_fwnode(struct device *dev) +{ + return NULL; +} +#endif + #endif From patchwork Wed May 1 12:17:40 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: 13650570 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 CC909C10F1A for ; Wed, 1 May 2024 12:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LSiO0JeybRvhXcPLgl0Jrlo1qRqyug5NNCRG3SE9Owk=; b=MycAop3r2IUhIG sjqkADT20g5IJosAkPjjijIK6XoSST9CCEX2ih6GnnoH/AK+1yOCwGEyUr610dmOfhDrw9yJxu2PU ydZ14H+IQwHzwjulu14s/P0bac0IHL7qrt2j4tlPW90vKFkBtrpfbi4wCWGWcUu93u7qg7TMc/9sx RxWNaeUyIq1TFaidKwOCYW9ii3i1MohByFU0Lh5jtr0+sBZj2Qt4cNh1Fy/jshyl3LMFnJWAltScP xt0UlEYOXlERHdz3f+HzTGgLW1brH1p+OlkmYxngBjYqJu5gKdvtXZzwwycqC1Omaa2NcwYM70NpQ 9b2O6dibrgyPXP+yWSDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29Ej-00000009VjW-04Qw; Wed, 01 May 2024 12:39:01 +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 1s28wK-00000009NOO-3am5 for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:20:03 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e651a9f3ffso33948475ad.1 for ; Wed, 01 May 2024 05:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714566000; x=1715170800; 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=YKprQ9DjgmWeNOp2jgUX6DT/fQdt5/GgPVbDil8wt68=; b=P2xF/gUQNdzMZepSJMC5sPBmCgEfWnAmOofORLqLDIPVDP7SAtAmUJt/Wpbwy4ulW1 asUYGWTmHeRwWsjxGOCVH4PfGBtTFAlVLn/CXsgdAU2Gl9srWTN7o27/kEzPZIcYYiTi oGUfU4k/TKmMwISc9unkZ1CRmdrmwQuQ7EWFmRq0z9U2xIKHfDlV297NNEC4RKc5JNj5 NuTRQOhp744Y5Ra5sMxFtl1tqOtRo/ElcJEA02GqwHRDBwM+drIhRmQgymNpRzjBwzYs s6Q2/oRhSMqCxHHP6lwRhFdd1NwwdjgIlsoplk+/CiMCPRSUymB8Osa+QpWVI3v6uFxI cCvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714566000; x=1715170800; 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=YKprQ9DjgmWeNOp2jgUX6DT/fQdt5/GgPVbDil8wt68=; b=dnVrDS9nGQnXK+kbNAP1Q4RmjxiqN48naFC0sWMeQ2IQC9QeX2mmDh6u0DdDlxPMnn YFTkqQOCZ8xGf6fDjUO6ED6ZriEjPcmrRqgqaEFUFHbgmHZ/lfdFhuXwAtU9yNiwC0JJ FouQFZPCYwrJfcblthfk5sP4FPIKGOhwi8qmhsfgsAjQTVzMiwa41M9Zhli+Wp5CqV7q yoHUnJ2ma9dMrCBKKdjF0CPPsaF2rclwLsm7qEtVmB6nezFKXSn+ig9+aLY2aH5XnxYX pem+p/AG12HZAA24dNKx0oJDdYUtCHaDvQjlynndEkJzFzrZUz5bzOqtqxPwSgmONfe9 WGDw== X-Forwarded-Encrypted: i=1; AJvYcCWPEpEF9Im5UIoJWQiU5zC8UNLIaOfVirQKvvJY8DxX3jX+rSZFq+x9s7kxXINYxvSeHNvBxkbOWBszEyuUm6NPhx0bFvQpgoXhn61OBGM4 X-Gm-Message-State: AOJu0YzEz6wseIMq0Jg9wGBVMWw5PkFf2InPJsXVERwpzjcBLrjsTX/I ypjSV13RgZ3m/spqsdgxWw5ZLC2V4l4RpWFkLQQlHk1RFWp7Kcsk6rbV13UvSeI= X-Google-Smtp-Source: AGHT+IHXX5ILEyglT/Py3DGUVj43d4poupz49yi1BZblVtQazhBuHxJlZGQemov9OMPe6qk3xCXV3Q== X-Received: by 2002:a17:902:e841:b0:1eb:156f:8d01 with SMTP id t1-20020a170902e84100b001eb156f8d01mr2061754plg.40.1714566000196; Wed, 01 May 2024 05:20:00 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:19:59 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 15/17] irqchip/riscv-aplic: Add ACPI support Date: Wed, 1 May 2024 17:47:40 +0530 Message-Id: <20240501121742.1215792-16-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_052001_039895_EC129BF9 X-CRM114-Status: GOOD ( 26.20 ) 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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , 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 --- drivers/irqchip/irq-riscv-aplic-direct.c | 20 ++++--- drivers/irqchip/irq-riscv-aplic-main.c | 70 ++++++++++++++++-------- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 ++- 4 files changed, 67 insertions(+), 33 deletions(-) diff --git a/drivers/irqchip/irq-riscv-aplic-direct.c b/drivers/irqchip/irq-riscv-aplic-direct.c index 4a3ffe856d6c..e24c2d3c78f6 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,20 @@ static int aplic_direct_starting_cpu(unsigned int cpu) } static int aplic_direct_parse_parent_hwirq(struct device *dev, u32 index, - u32 *parent_hwirq, unsigned long *parent_hartid) + u32 *parent_hwirq, unsigned long *parent_hartid, + struct aplic_priv *priv) { struct of_phandle_args parent; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; + if (!is_of_node(dev->fwnode)) { + rc = acpi_get_ext_intc_parent_hartid(priv->id, index, parent_hartid); + if (rc) + return rc; + + *parent_hwirq = RV_IRQ_EXT; + return 0; + } rc = of_irq_parse_one(to_of_node(dev->fwnode), index, &parent); if (rc) @@ -237,7 +241,7 @@ int aplic_direct_setup(struct device *dev, void __iomem *regs) /* Setup per-CPU IDC and target CPU mask */ current_cpu = get_cpu(); for (i = 0; i < priv->nr_idcs; i++) { - rc = aplic_direct_parse_parent_hwirq(dev, i, &hwirq, &hartid); + rc = aplic_direct_parse_parent_hwirq(dev, i, &hwirq, &hartid, priv); if (rc) { dev_warn(dev, "parent irq for IDC%d not found\n", i); continue; diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c index 774a0c97fdab..c1fd328ddf7d 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.c +++ b/drivers/irqchip/irq-riscv-aplic-main.c @@ -4,8 +4,10 @@ * Copyright (C) 2022 Ventana Micro Systems Inc. */ +#include #include #include +#include #include #include #include @@ -125,39 +127,50 @@ static void aplic_init_hw_irqs(struct aplic_priv *priv) writel(0, priv->regs + APLIC_DOMAINCFG); } +#ifdef CONFIG_ACPI +static const struct acpi_device_id aplic_acpi_match[] = { + { "RSCV0002", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, aplic_acpi_match); + +#endif + int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *regs) { struct of_phandle_args parent; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; - /* Save device pointer and register base */ priv->dev = dev; priv->regs = regs; - /* Find out number of interrupt sources */ - rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,num-sources", - &priv->nr_irqs); - if (rc) { - dev_err(dev, "failed to get number of interrupt sources\n"); - return rc; - } - - /* - * Find out number of IDCs based on parent interrupts - * - * If "msi-parent" property is present then we ignore the - * APLIC IDCs which forces the APLIC driver to use MSI mode. - */ - if (!of_property_present(to_of_node(dev->fwnode), "msi-parent")) { - while (!of_irq_parse_one(to_of_node(dev->fwnode), priv->nr_idcs, &parent)) - priv->nr_idcs++; + if (is_of_node(dev->fwnode)) { + /* Find out number of interrupt sources */ + rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,num-sources", + &priv->nr_irqs); + if (rc) { + dev_err(dev, "failed to get number of interrupt sources\n"); + return rc; + } + + /* + * Find out number of IDCs based on parent interrupts + * + * If "msi-parent" property is present then we ignore the + * APLIC IDCs which forces the APLIC driver to use MSI mode. + */ + if (!of_property_present(to_of_node(dev->fwnode), "msi-parent")) { + while (!of_irq_parse_one(to_of_node(dev->fwnode), priv->nr_idcs, &parent)) + priv->nr_idcs++; + } + } else { + rc = riscv_acpi_get_gsi_info(dev->fwnode, &priv->gsi_base, &priv->id, + &priv->nr_irqs, &priv->nr_idcs); + if (rc) { + dev_err(dev, "failed to find GSI mapping\n"); + return rc; + } } /* Setup initial state APLIC interrupts */ @@ -186,6 +199,9 @@ static int aplic_probe(struct platform_device *pdev) */ if (is_of_node(dev->fwnode)) msi_mode = of_property_present(to_of_node(dev->fwnode), "msi-parent"); + else + msi_mode = imsic_acpi_get_fwnode(NULL) ? 1 : 0; + if (msi_mode) rc = aplic_msi_setup(dev, regs); else @@ -193,6 +209,11 @@ static int aplic_probe(struct platform_device *pdev) if (rc) dev_err(dev, "failed to setup APLIC in %s mode\n", msi_mode ? "MSI" : "direct"); +#ifdef CONFIG_ACPI + if (!acpi_disabled) + acpi_dev_clear_dependencies(ACPI_COMPANION(dev)); +#endif + return rc; } @@ -205,6 +226,7 @@ static struct platform_driver aplic_driver = { .driver = { .name = "riscv-aplic", .of_match_table = aplic_match, + .acpi_match_table = ACPI_PTR(aplic_acpi_match), }, .probe = aplic_probe, }; diff --git a/drivers/irqchip/irq-riscv-aplic-main.h b/drivers/irqchip/irq-riscv-aplic-main.h index 4393927d8c80..9fbf45c7b4f7 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.h +++ b/drivers/irqchip/irq-riscv-aplic-main.h @@ -28,6 +28,7 @@ struct aplic_priv { u32 gsi_base; u32 nr_irqs; u32 nr_idcs; + u32 id; void __iomem *regs; struct aplic_msicfg msicfg; }; diff --git a/drivers/irqchip/irq-riscv-aplic-msi.c b/drivers/irqchip/irq-riscv-aplic-msi.c index 028444af48bd..f5020241e0ed 100644 --- a/drivers/irqchip/irq-riscv-aplic-msi.c +++ b/drivers/irqchip/irq-riscv-aplic-msi.c @@ -157,6 +157,7 @@ static const struct msi_domain_template aplic_msi_template = { int aplic_msi_setup(struct device *dev, void __iomem *regs) { const struct imsic_global_config *imsic_global; + struct irq_domain *msi_domain; struct aplic_priv *priv; struct aplic_msicfg *mc; phys_addr_t pa; @@ -239,8 +240,14 @@ int aplic_msi_setup(struct device *dev, void __iomem *regs) * IMSIC and the IMSIC MSI domains are created later through * the platform driver probing so we set it explicitly here. */ - if (is_of_node(dev->fwnode)) + if (is_of_node(dev->fwnode)) { of_msi_configure(dev, to_of_node(dev->fwnode)); + } else { + msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); + } } if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, &aplic_msi_template, From patchwork Wed May 1 12:17:41 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: 13650571 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 3E9B2C4345F for ; Wed, 1 May 2024 12:39:23 +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=P7jYIATTkdT7Lh/p0RpcDzQX/RvdXzDa+SpvvObpvnQ=; b=DVKo3amwUE5F6A WLA9yRgYEf71+oK/8DPdWG5vI6XRQz1r5TgmByM5vdrrDsj/+iKmRSSF9B7W4XgVDI7UJMRmA69y9 LeyNr3ytZT4MSd2vVv2FHD1R99Ir+aPqj40lkSaO2Ks4ql5U4qtRJO5BmdDUk9U/vDZ1I1tOrz0+k 9hIC8UIFvlK0g8CDsXpmWbBO0Ik99Nt5Eg3O3L0NAexVmZOsnGQCAHEBZZcDu57olIF5BS6qmCjzU b6M+OyXBNYE2c5FQDHfOFE8CQSinLD53zrdWwdc0T8fBOPpFKlBNpiASH8C0qPdCDvizukuy1fEZu JUdS0srcgFykkYynV+rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29Ez-00000009VuZ-1E15; Wed, 01 May 2024 12:39:17 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28wS-00000009NUU-3w3E for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:20:10 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6ed691fb83eso5885272b3a.1 for ; Wed, 01 May 2024 05:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714566008; x=1715170808; 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=sCs3yrmzFwEswQj2N8wV0vpYdlRUqd+77n2ry9m3784=; b=oTSRPKsb6ODvn0sdHx/gV6C7oIo/lYIByHHOfuqvyB9mh92ErpOkIlQ79Z6DBirp35 Jp3FKahIoEOAfbghFuhnVTPVQnRrTnWehz76rPVZlHZL913tuJEOlTEndivn5xkY3BdF NUkDxDdFYtVYmc4aYQiZXlPgi9AUOwXpGXwlaK7f9xUoye7s9rYJ8tD9BloRbc6Kv2CG qrcfnT7xUbdp6ODWrgnMQDKKlv06x7pwTJigE1+SnPT5s+EzENVRXjJE+AKTsHveIrSh 9o0cfltEqu3paNgDZrheengh+UbOorcm6EsqEw1siNj7Enp/5gM8LaMkO+ihOERt+G2u ILTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714566008; x=1715170808; 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=sCs3yrmzFwEswQj2N8wV0vpYdlRUqd+77n2ry9m3784=; b=SzS3HJHsJFT1bytig437pvt99aMjnXHYezp3r4eVD/1iTSren2QrMcmQH4ghgjA1bb +KVGIkrtbOJLCKNsWVJM9mZdSurPfdOYok0Zz5Y9nmUzc1CMYxcICn+jUh+yXppOEe69 Dw+MqF3Xv7SAepXAiJQKx27MC5adjw9nBzUpcX1aAo1o4OYBEwCdJTVPZb5n7S3NPmRB HQnnmfwg5ZMjwuJEqOJdrtuC90wy6P6nCwmfLdLJhoOzhlCMEAeC68V7uB+XQ7RAOEEf xcIxaei7mfn6mFh3KsJTF8pxC+OeKd1VlNiyRITggQFden+Hh7og9DYm3+kTAwqZ2jO3 xKOg== X-Forwarded-Encrypted: i=1; AJvYcCXFKOl4n/Ml4vZSs9b9+62tpQt+XsZYXCAmEhf7Cu6X3QxETPWkxjc7p8eJtquRfujJ+xZ9SrLVjhvmepVEL3S2TjJRKOPejjsX1QkkFfe8 X-Gm-Message-State: AOJu0YwDbC/rP9pFrrTawKtqHZy3pIEw5W7y2XOi/zthzL/0xKXa0Jw2 8B3lcB4P/0k7QUZQiUhyyn8f2TB1FhlxfdPw30f4DsLKoIDOoJbyRLMcM8X7rk0= X-Google-Smtp-Source: AGHT+IEE0GElfwoFz8rK8ax73/m32/DYftPNktmYVGk+PoIc+wfQ5hYwE+vbTd662q3C/FXcAaIUlQ== X-Received: by 2002:a17:903:2303:b0:1eb:7172:673b with SMTP id d3-20020a170903230300b001eb7172673bmr2574288plh.16.1714566007835; Wed, 01 May 2024 05:20:07 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:20:07 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 16/17] irqchip/sifive-plic: Add ACPI support Date: Wed, 1 May 2024 17:47:41 +0530 Message-Id: <20240501121742.1215792-17-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_052008_989177_0EB1FEAC X-CRM114-Status: GOOD ( 22.43 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add ACPI support in PLIC driver. Use the mapping created early during boot to get details about the PLIC. Signed-off-by: Sunil V L Co-developed-by: Haibo Xu Signed-off-by: Haibo Xu --- drivers/irqchip/irq-sifive-plic.c | 89 +++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 21 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 8fb183ced1e7..b6b04b5923c2 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,32 @@ static const struct of_device_id plic_match[] = { {} }; +#ifdef CONFIG_ACPI + +static const struct acpi_device_id plic_acpi_match[] = { + { "RSCV0001", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, plic_acpi_match); + +#endif static int plic_parse_nr_irqs_and_contexts(struct platform_device *pdev, - u32 *nr_irqs, u32 *nr_contexts) + u32 *nr_irqs, u32 *nr_contexts, + u32 *gsi_base, u32 *id) { struct device *dev = &pdev->dev; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; + if (!is_of_node(dev->fwnode)) { + riscv_acpi_get_gsi_info(dev->fwnode, gsi_base, id, nr_irqs, NULL); + acpi_get_plic_nr_contexts(*id, nr_contexts); + if (WARN_ON(!*nr_contexts)) { + dev_err(dev, "no PLIC context available\n"); + return -EINVAL; + } + + return 0; + } rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,ndev", nr_irqs); if (rc) { @@ -449,23 +470,29 @@ static int plic_parse_nr_irqs_and_contexts(struct platform_device *pdev, return -EINVAL; } + *gsi_base = 0; + *id = 0; + return 0; } static int plic_parse_context_parent(struct platform_device *pdev, u32 context, - u32 *parent_hwirq, int *parent_cpu) + u32 *parent_hwirq, int *parent_cpu, u32 id) { struct device *dev = &pdev->dev; struct of_phandle_args parent; unsigned long hartid; int rc; - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; + if (!is_of_node(dev->fwnode)) { + rc = acpi_get_ext_intc_parent_hartid(id, context, &hartid); + if (rc) + return rc; + + *parent_cpu = riscv_hartid_to_cpuid(hartid); + *parent_hwirq = RV_IRQ_EXT; + return 0; + } rc = of_irq_parse_one(to_of_node(dev->fwnode), context, &parent); if (rc) @@ -490,7 +517,9 @@ static int plic_probe(struct platform_device *pdev) struct irq_domain *domain; struct plic_priv *priv; irq_hw_number_t hwirq; + int id, context_id; bool cpuhp_setup; + u32 gsi_base; if (is_of_node(dev->fwnode)) { const struct of_device_id *id; @@ -500,7 +529,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; @@ -511,6 +540,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)) @@ -521,12 +552,22 @@ static int plic_probe(struct platform_device *pdev) return -ENOMEM; for (i = 0; i < nr_contexts; i++) { - error = plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu); + error = plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu, priv->id); if (error) { dev_warn(dev, "hwirq for context%d not found\n", i); continue; } + if (is_of_node(dev->fwnode)) { + context_id = i; + } else { + error = acpi_get_plic_context(priv->id, i, &context_id); + if (error) { + dev_warn(dev, "invalid context id for context%d\n", i); + continue; + } + } + /* * Skip contexts other than external interrupts for our * privilege level. @@ -572,10 +613,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), @@ -591,8 +632,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 +660,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 +690,7 @@ static struct platform_driver plic_driver = { .driver = { .name = "riscv-plic", .of_match_table = plic_match, + .acpi_match_table = ACPI_PTR(plic_acpi_match), }, .probe = plic_probe, }; From patchwork Wed May 1 12:17:42 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: 13650764 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 E4015C4345F for ; Wed, 1 May 2024 13:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Hy+hwAwXtmw0vPkfYv9PPrn4RBKvVq12tinBM0TBgwg=; b=qcyf/HiSHzWbnN x+bMmPifhPV3wpWKubVlOtdbUswKLg2Wvxi5cPTnbGROmaGsjTmp7KqmOzN+23m9x2pYU87va+CgH Jk3LOJ58MfKGwmLLbCACn6rW9LABAfe7iQkfs0XgqqJ+yjUgyPt3mvAtsNz0TFPbebzU0ftMk1w/6 gss9gCveZZwvPsFwBl1ShViWfCfK/2MS0jVEZUr+8cAzktbarz0T48vWq5rTAboLsYxaNV3BjYvWi u6INPthqkwJy8eT8khZrV1DSBCHb9cUCGdkwwqOBMHxCsPT6aWM2I3+zZL2kfLiFmIEG3fKvVhN8k 8GxMxGmEZkSCxuPeu6bA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2AHb-00000009ibv-17kR; Wed, 01 May 2024 13:46:03 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s28wa-00000009NYb-0qlW for linux-riscv@lists.infradead.org; Wed, 01 May 2024 12:20:24 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e834159f40so53998425ad.2 for ; Wed, 01 May 2024 05:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714566015; x=1715170815; 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=NA6fALA+ztvPArpqc5Jdn/FWi0fZsP181uxTjKG28r0=; b=DFQOJXMgUUiVRVD4s4BiKNqLcMNLLKl6ELFmF1a1kWK+xx1LATX4iEDy4pV3YBPD4B rNPH/1Xa/F9MQ2YiiyYpyefG3K3QiwDi3JtFq7Fn1xMM8ivPoonwzPAJwoVmfLeGUqYq 6odexmqTmaYEVdAg6AYKznE7Cm3WEyv39aStEufbQSRL3JSxHEuht+0q72ajobR5AP1w Nd5BxT7xVdEcH+g+DPNADBnka5ZTk7m91KhJI4oG37/IYDD0tY3tI1ipzQXza10zIoL6 4xfhWibpah+70tt6RQgt9mtIuRlqbpP8sKX1r1tfJz5ZoQrPvXLz0rcvCBgL+tR+nvZH imvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714566015; x=1715170815; 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=NA6fALA+ztvPArpqc5Jdn/FWi0fZsP181uxTjKG28r0=; b=lQbuve6GDYrVBJIkzL2g4HUyR3+VqJZtW/uebtgXW/51qdTyfOL2AWaFMw0SWkmROB xk9i72jhqOPsR2rA++6aOlIT2k4p8gVzfq4uA1ahkx9xVwOc1rvF9xXd7Ssovb+pFhpk vGnCAwbP0E5ThGmhizhbaYwD5r4lcMFm213CB+AAmNriVV97ZvxQqnXvKUN72v8yvgoH ohmdaZTppEGtCJI4hfcorTzByAXOwsC4It1cNBFGsotKDjEeClEyNJgDVdvJP9bPUiqD lz+W9myKvcK7dOJEsZlPEPIKiNb1lay2K99026pohPqxRenJhZiwUfE19UnBGXUMTTS3 nF2w== X-Forwarded-Encrypted: i=1; AJvYcCWXMEFoisdokfhYwN3ryMklwb5EQMONJ697wvBfGbO6TQrvvdPEhNSlbc9ju8tqI6mp1vnkqugBt75kIbxDO7FCsXQji2xacB1Ju5tlczrc X-Gm-Message-State: AOJu0YwqypKYFxIsjXDd9L+58PvW9h2MA8rYUOwrIfowC//kSLrY4JCP LdCv9BcskBvGyWPb+uXgi5ncCU5Sq7lYc0c1OUKbjAiWTYW0TI3nwGVikzN/ZRc= X-Google-Smtp-Source: AGHT+IHYfyPObdgft5ubD0a+EdF/ZUFESa543BOMp550uRgpGcGY3JeWyQR+nmnrayByMoL+UjNZmA== X-Received: by 2002:a17:902:ed01:b0:1eb:494f:dc66 with SMTP id b1-20020a170902ed0100b001eb494fdc66mr2209312pld.23.1714566015601; Wed, 01 May 2024 05:20:15 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:20:15 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Subject: [PATCH v5 17/17] serial: 8250: Add 8250_acpi driver Date: Wed, 1 May 2024 17:47:42 +0530 Message-Id: <20240501121742.1215792-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240501121742.1215792-1-sunilvl@ventanamicro.com> References: <20240501121742.1215792-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_052022_774645_7D8C14E2 X-CRM114-Status: GOOD ( 24.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: "Rafael J . Wysocki" , Catalin Marinas , Atish Kumar Patra , Conor Dooley , Jiri Slaby , Haibo1 Xu , Marc Zyngier , Robert Moore , Andrei Warkentin , Andrew Jones , Albert Ou , Will Deacon , Paul Walmsley , Bjorn Helgaas , Thomas Gleixner , Andy Shevchenko , Greg Kroah-Hartman , Samuel Holland , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Anup Patel , Len Brown Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org RISC-V has non-PNP generic 16550A compatible UART which needs to be enumerated as ACPI platform device. Add driver support for such devices similar to 8250_of. The driver is enabled when the CONFIG_SERIAL_ACPI_PLATFORM option is enabled. Enable this option for RISC-V. Signed-off-by: Sunil V L --- arch/riscv/configs/defconfig | 1 + drivers/tty/serial/8250/8250_acpi.c | 96 +++++++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 8 +++ drivers/tty/serial/8250/Makefile | 1 + 4 files changed, 106 insertions(+) create mode 100644 drivers/tty/serial/8250/8250_acpi.c diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index 3cae018f9315..bea8241f52eb 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -150,6 +150,7 @@ CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_DW=y CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SERIAL_ACPI_PLATFORM=y CONFIG_SERIAL_SH_SCI=y CONFIG_SERIAL_EARLYCON_RISCV_SBI=y CONFIG_VIRTIO_CONSOLE=y diff --git a/drivers/tty/serial/8250/8250_acpi.c b/drivers/tty/serial/8250/8250_acpi.c new file mode 100644 index 000000000000..3682443bb69c --- /dev/null +++ b/drivers/tty/serial/8250/8250_acpi.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Serial Port driver for ACPI platform devices + * + * This driver is for generic 16550 compatible UART enumerated via ACPI + * platform bus instead of PNP bus like PNP0501. This is not a full + * driver but mostly provides the ACPI wrapper and uses generic + * 8250 framework for rest of the functionality. + */ + +#include +#include +#include + +#include "8250.h" + +struct acpi_serial_info { + int line; +}; + +static int acpi_platform_serial_probe(struct platform_device *pdev) +{ + struct acpi_serial_info *data; + struct uart_8250_port port8250; + struct device *dev = &pdev->dev; + struct resource *regs; + + int ret, irq; + + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!regs) { + dev_err(dev, "no registers defined\n"); + return -EINVAL; + } + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + memset(&port8250, 0, sizeof(port8250)); + + spin_lock_init(&port8250.port.lock); + + port8250.port.mapbase = regs->start; + port8250.port.irq = irq; + port8250.port.type = PORT_16550A; + port8250.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | + UPF_IOREMAP | UPF_FIXED_TYPE; + port8250.port.dev = dev; + port8250.port.mapsize = resource_size(regs); + port8250.port.iotype = UPIO_MEM; + port8250.port.irqflags = IRQF_SHARED; + + port8250.port.membase = devm_ioremap(dev, port8250.port.mapbase, port8250.port.mapsize); + if (!port8250.port.membase) + return -ENOMEM; + + ret = uart_read_and_validate_port_properties(&port8250.port); + if (ret) + return -EINVAL; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->line = serial8250_register_8250_port(&port8250); + if (data->line < 0) + return data->line; + + platform_set_drvdata(pdev, data); + return 0; +} + +static void acpi_platform_serial_remove(struct platform_device *pdev) +{ + struct acpi_serial_info *data = platform_get_drvdata(pdev); + + serial8250_unregister_port(data->line); +} + +static const struct acpi_device_id acpi_platform_serial_table[] = { + { "RSCV0003", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, acpi_platform_serial_table); + +static struct platform_driver acpi_platform_serial_driver = { + .driver = { + .name = "acpi_serial", + .acpi_match_table = ACPI_PTR(acpi_platform_serial_table), + }, + .probe = acpi_platform_serial_probe, + .remove_new = acpi_platform_serial_remove, +}; + +builtin_platform_driver(acpi_platform_serial_driver); diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index 47ff50763c04..fbfe4d3501b1 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -576,3 +576,11 @@ config SERIAL_OF_PLATFORM are probed through devicetree, including Open Firmware based PowerPC systems and embedded systems on architectures using the flattened device tree format. + +config SERIAL_ACPI_PLATFORM + tristate "ACPI platform bus based probing for 8250 ports" + depends on SERIAL_8250 && ACPI + default n + help + This option is used for generic 8250 compatible serial ports + that are enumerated through ACPI platform bus. diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile index ea2e81f58eac..8c0ef357fc4e 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o +obj-$(CONFIG_SERIAL_ACPI_PLATFORM) += 8250_acpi.o obj-$(CONFIG_SERIAL_8250_ASPEED_VUART) += 8250_aspeed_vuart.o obj-$(CONFIG_SERIAL_8250_BCM2835AUX) += 8250_bcm2835aux.o obj-$(CONFIG_SERIAL_8250_BCM7271) += 8250_bcm7271.o