From patchwork Tue Dec 19 17:45:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498868 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 A8E89C41535 for ; Tue, 19 Dec 2023 18:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AbncdxXEOK/CL2y2N+EN8nMdqK4RvPvGxC2/QdHCfAo=; b=uhSl797PX/b5AV Ilhwv34+Sj1GBPooCbaapidkgRblIsUBE/ezCSbP2lbFAGDqshX56syl/nQXFqw7KPrlx7qOXn1VL 668JiPuFLqA0VUS24ohUZl/r5zrN+dWs5n/uFRwgTNVzJh0HPT9Jo1e8T0bE2NHkibkUasKd8azqk 4zyWbC86ZEmWdOFj769fEs6ocjMOOd1iGEaBHo31zoOMUmR6Rhj1fTXXkRwjP2bLZDck9StimsJc6 1S2x16G9MZkjlBT74ztDlYHmgFDqXbtRj1o2qsuFY8kez0txsXjjKnFsEtYYUjfeDxRCRzOZoXX5w VzHwQJ2lbzX+LtujuS7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFf7B-00FEIv-1O; Tue, 19 Dec 2023 18:46:49 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAB-00F0cq-1k for linux-arm-kernel@bombadil.infradead.org; Tue, 19 Dec 2023 17:45:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=sTCmyL8q1x2NekUk0mD7VzWJPBPZf/tU9IYpoiSJ7Kg=; b=bpGtF/WZz8mws0Pk/8w6Qm2f6K KKQ6mE/+jMkJaISaGRJzhR4WnFpMH46pAZrQgoWskHNKVaK1FKz09l5rD+jCxJeuA9pjz3gO2+MdX 6KzR29lXnpqxYvafqPrPfA1vWG4ssYJWvI70iUxkZAv4pHg6npGxZJEbv/kSpugGBHUKMAMM6ubI3 QYJ/55aqFj4LCfqOADuZj3vqiPcxI02Pe/NdWd51agS3nyjC6m4ngvROP+5cEmdY8+3fDBL3RqRJw pFBXLHyAez/WUTEZ8ay1pNJlPgsJ/P0zlwcfuzY1wPNW2s0T96T9okWl2AC55x4PwzTRA7NND8UKG g+a1Hpkg==; Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeA6-00DXuv-12 for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:45:49 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d3b5f9860bso12621735ad.3 for ; Tue, 19 Dec 2023 09:45:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007941; x=1703612741; 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=sTCmyL8q1x2NekUk0mD7VzWJPBPZf/tU9IYpoiSJ7Kg=; b=jDJOQp7DyTRPSAwvBpX2bLWmByeb95NkgKVzGDOAYwTgpY0tep4rho7AykHHnFWr6Q Ejsu1kz5PCpukOzexFU2l64nTtm3aaZ4qzW5yTWtXAE3y2tGRo6SJRHyQM0CfYG88rxp 6n9mNn5PsxQO05EDK8hjp5B7MNq7fF2ncZzL4NfLFBLRlEmCl+A5IWYWo3N1f0BZxtWu eyLh00vREpIfIg/LP7C5djoUbhAk6FWdhJY3u7rgyXlnT+D9Rd4vSQfokxzVyZGHrmCo HcNYVEQ64rGDDJYkIRCogjryOKhAgHcW3non902/eSV57MtIKbmkl6j0qwG8BQXeQKVQ iL7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007941; x=1703612741; 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=sTCmyL8q1x2NekUk0mD7VzWJPBPZf/tU9IYpoiSJ7Kg=; b=s/craWb4KbLOhkELgNMxgOabmbYSIlpU/99lupwrgm246/Ol0AeKOfaAGTCvbx0Npc 7e6PKPckWAp6FOC1786hOzw+tKL461Sbcj8TU7eEHgTyDcBnqS/2hXbZpfBCJUD84cz1 ElIroJw2dv+/DdZvABuXiUpot6ixT9IuLqp3Hv6l5YZqzIuCOEAv+OmOGBJ4HyydEQ3j d9pIkeTrqAyH8Svpi37dEK+Mq5J4eUEcuY/m4NsGX6X5WdKYxCy1yIPwwFHcB6aFL1lq Gxu/fWGDaBSW9dKFoYCOSfEBBRF2uk2iZrcFRG+joZCEi+Sw3INdIqgyvRN4+vcsHsFt oaNw== X-Gm-Message-State: AOJu0Yx9ao//IqmbmhfwGPUGIQyKVTEIMFJOCxKUZXLTh9Bxujw9/NHv sZCgZ7wFzp802mgRIedHP1Rc7WyQ4cixZjPms3s= X-Google-Smtp-Source: AGHT+IELnIzuBGe8+RpsYfu1MC+dDMJxMjOPO9pnKrkvwFqAtmLHYJqz6ZK2d+FJftV0n02FxckgOg== X-Received: by 2002:a17:902:ea03:b0:1d3:c08d:ba9b with SMTP id s3-20020a170902ea0300b001d3c08dba9bmr2802604plg.13.1703007941143; Tue, 19 Dec 2023 09:45:41 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:45:40 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 01/17] arm64: PCI: Migrate ACPI related functions to pci-acpi.c Date: Tue, 19 Dec 2023 23:15:10 +0530 Message-Id: <20231219174526.2235150-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_174546_516263_E22445DE X-CRM114-Status: GOOD ( 22.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The functions defined in arm64 for ACPI support are required for RISC-V also. To avoid duplication, move these functions to common location. Signed-off-by: Sunil V L Acked-by: Bjorn Helgaas --- arch/arm64/kernel/pci.c | 191 ---------------------------------------- drivers/pci/pci-acpi.c | 182 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+), 191 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index f872c57e9909..fd9a7bed83ce 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -6,28 +6,7 @@ * Copyright (C) 2014 ARM Ltd. */ -#include -#include -#include -#include -#include #include -#include -#include -#include - -#ifdef CONFIG_ACPI -/* - * Try to assign the IRQ number when probing a new device - */ -int pcibios_alloc_irq(struct pci_dev *dev) -{ - if (!acpi_disabled) - acpi_pci_irq_enable(dev); - - return 0; -} -#endif /* * raw_pci_read/write - Platform-specific PCI config space access. @@ -61,173 +40,3 @@ int pcibus_to_node(struct pci_bus *bus) EXPORT_SYMBOL(pcibus_to_node); #endif - -#ifdef CONFIG_ACPI - -struct acpi_pci_generic_root_info { - struct acpi_pci_root_info common; - struct pci_config_window *cfg; /* config space mapping */ -}; - -int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) -{ - struct pci_config_window *cfg = bus->sysdata; - struct acpi_device *adev = to_acpi_device(cfg->parent); - struct acpi_pci_root *root = acpi_driver_data(adev); - - return root->segment; -} - -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) -{ - struct pci_config_window *cfg; - struct acpi_device *adev; - struct device *bus_dev; - - if (acpi_disabled) - return 0; - - cfg = bridge->bus->sysdata; - - /* - * On Hyper-V there is no corresponding ACPI device for a root bridge, - * therefore ->parent is set as NULL by the driver. And set 'adev' as - * NULL in this case because there is no proper ACPI device. - */ - if (!cfg->parent) - adev = NULL; - else - adev = to_acpi_device(cfg->parent); - - bus_dev = &bridge->bus->dev; - - ACPI_COMPANION_SET(&bridge->dev, adev); - set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev))); - - return 0; -} - -static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) -{ - struct resource_entry *entry, *tmp; - int status; - - status = acpi_pci_probe_root_resources(ci); - resource_list_for_each_entry_safe(entry, tmp, &ci->resources) { - if (!(entry->res->flags & IORESOURCE_WINDOW)) - resource_list_destroy_entry(entry); - } - return status; -} - -/* - * Lookup the bus range for the domain in MCFG, and set up config space - * mapping. - */ -static struct pci_config_window * -pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root) -{ - struct device *dev = &root->device->dev; - struct resource *bus_res = &root->secondary; - u16 seg = root->segment; - const struct pci_ecam_ops *ecam_ops; - struct resource cfgres; - struct acpi_device *adev; - struct pci_config_window *cfg; - int ret; - - ret = pci_mcfg_lookup(root, &cfgres, &ecam_ops); - if (ret) { - dev_err(dev, "%04x:%pR ECAM region not found\n", seg, bus_res); - return NULL; - } - - adev = acpi_resource_consumer(&cfgres); - if (adev) - dev_info(dev, "ECAM area %pR reserved by %s\n", &cfgres, - dev_name(&adev->dev)); - else - dev_warn(dev, FW_BUG "ECAM area %pR not reserved in ACPI namespace\n", - &cfgres); - - cfg = pci_ecam_create(dev, &cfgres, bus_res, ecam_ops); - if (IS_ERR(cfg)) { - dev_err(dev, "%04x:%pR error %ld mapping ECAM\n", seg, bus_res, - PTR_ERR(cfg)); - return NULL; - } - - return cfg; -} - -/* release_info: free resources allocated by init_info */ -static void pci_acpi_generic_release_info(struct acpi_pci_root_info *ci) -{ - struct acpi_pci_generic_root_info *ri; - - ri = container_of(ci, struct acpi_pci_generic_root_info, common); - pci_ecam_free(ri->cfg); - kfree(ci->ops); - kfree(ri); -} - -/* Interface called from ACPI code to setup PCI host controller */ -struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) -{ - struct acpi_pci_generic_root_info *ri; - struct pci_bus *bus, *child; - struct acpi_pci_root_ops *root_ops; - struct pci_host_bridge *host; - - ri = kzalloc(sizeof(*ri), GFP_KERNEL); - if (!ri) - return NULL; - - root_ops = kzalloc(sizeof(*root_ops), GFP_KERNEL); - if (!root_ops) { - kfree(ri); - return NULL; - } - - ri->cfg = pci_acpi_setup_ecam_mapping(root); - if (!ri->cfg) { - kfree(ri); - kfree(root_ops); - return NULL; - } - - root_ops->release_info = pci_acpi_generic_release_info; - root_ops->prepare_resources = pci_acpi_root_prepare_resources; - root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops; - bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg); - if (!bus) - return NULL; - - /* If we must preserve the resource configuration, claim now */ - host = pci_find_host_bridge(bus); - if (host->preserve_config) - pci_bus_claim_resources(bus); - - /* - * Assign whatever was left unassigned. If we didn't claim above, - * this will reassign everything. - */ - pci_assign_unassigned_root_bus_resources(bus); - - list_for_each_entry(child, &bus->children, node) - pcie_bus_configure_settings(child); - - return bus; -} - -void pcibios_add_bus(struct pci_bus *bus) -{ - acpi_pci_add_bus(bus); -} - -void pcibios_remove_bus(struct pci_bus *bus) -{ - acpi_pci_remove_bus(bus); -} - -#endif diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index a05350a4e49c..58497b25d2ab 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1518,3 +1519,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 Tue Dec 19 17:45:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498716 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 272AEC46CA2 for ; Tue, 19 Dec 2023 17:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LqZLyQN1IktlOHPLbhOyIF5kjl9dTR5O50g4Cx4d+eQ=; b=SzambU/AAweo6o WK/Ku/Dd5aSlufB0PkMhbie9CAl5Phv0t2P8JAPQFvLLXwh4d6dc3cqXzr7A5qjN6F26tJcOEjnuG v0eotPIrMx7p5lK3bQuedPgR8JaTBv1DCqiPX1j0M3dOdVnvLRV+xv5xaw4RfbIaidMFtm66FfJrs zOknAeJoO5aRk5Krh33h/zyTO0spRxCwqlaa3J1lAJnDTMd/XiJijPwsX1Usv/Jv/PoL9V8Jogf5c mq9Co1S4qTMbhNZIpRrTP6+a+knFJBopkREkpZE1ODc7W3hhMQfK0ClkLxBjHfFiNqcbQn+PEqBdh oRdKRYXSV+DDFl8IEBqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAK-00F0gA-1B; Tue, 19 Dec 2023 17:46:00 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAD-00F0db-25 for linux-arm-kernel@bombadil.infradead.org; Tue, 19 Dec 2023 17:45:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=X2my/S8LtCsC0GLqIKOd4U0OgSfb/RvK23itt/cKu94=; b=Bn36/OyZ/4fQWzDUXqfuxPmwYk QF+s6EqyTtc8Ei10PTLlYCyonEBmP7h782vUN/ljCjzNpgpykFSTx9KuN4kvYaVay/qiEX/Dw9TRO rWT0Z8fwDpanJPH94kf7zY22oEAmtJo9o9QztgnqM3gRlLEHyKSB9qErN1+vMcp/Gy2pcZ9MvGj+/ ahCZcutevo/nguuovVdXNzQzj+0YFI1JoJenS98p8L7kVoRVUiYYZ66ShvDrToA0R0lfAL+y1qbsq a7NkaDKYyVaSUE7Li3Tq55wBLNeOCWbjdUXMBt54nDVkOF9yu/53NodL6K0MQXaeJ1rx9/bFwrDMx P0dxC7fw==; Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAA-00DXvC-1s for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:45:52 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d3dc30ae01so7887055ad.0 for ; Tue, 19 Dec 2023 09:45:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007947; x=1703612747; 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=X2my/S8LtCsC0GLqIKOd4U0OgSfb/RvK23itt/cKu94=; b=KKJt3UT82XsphgIfOonQ+cFYKrSwwME7leDdakQQ67oN1124DEYnaZw7CWQ7I7mQea AXsct/53WPvhXzSyYnXljQx2hlq1noiia3DNWdRSGV5+OhgxsDrpwbuhsjQVoz765zse khUur+dJC/EN+EnsKKNbUPEicZEPB+8abtoRR9bMUMMCq5j2tK44bnjsi55hz/JBtrp7 npWY8ewrvnhqSCn4qt2tW/xrzMneKKkWgT5OiIz7C7x+aH4KNNLJqK6Ant67D/hzAAm3 7DeCfbJwJGP6OKb7ZjFLP4XkQjUmPYxWug1KVXaaouQSrQ0rMXVHoOFyJhIc5bDrra3N vkNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007947; x=1703612747; 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=X2my/S8LtCsC0GLqIKOd4U0OgSfb/RvK23itt/cKu94=; b=aeyLUBBgFzEXQfB0gA131OtysLavAvnOGO2pAIMCVfl4RU4maHSvFNLZ6Kdu7M2+S/ YcDrVGA3+SsW5ZQeS9VG8CiEbYd2K89lKqMTRW1fwbIxmOqHz76yqKMupQRHPd5CB9rY ZdhOdtb+D1lhgQ53k3936DNQqQO0XyHINWSm+P8mNcJdEIJbkYuwvn98OH3Zb1VJnyd0 Ql/xyaZIT3kJ1cRQeOEqg408kECw2VHL6ebOz/cib8gEg3I/PGTbceWwj2WxONJU74ER fkjP//AJSUgZAs6a1Zw+/+XP/nLP3LSDSLHHVzGG+z9C0HICtiZv4+h2waP+sNg2Sum3 fzYA== X-Gm-Message-State: AOJu0Yye4fgpnySSGr50gxGeXO51jf5bR11iwuPm3zN8uL3Q4xL8JvxK PhnbpxcrZX9YpIWp/1oUYuJvHAeJ2K72PDEQQW0= X-Google-Smtp-Source: AGHT+IFDCMqXKe3sr6t+NRPle0lI18fn2yS4WEUvyrpP85oA70voh4ftGShJGXf8FNnSuam1RUEIzw== X-Received: by 2002:a17:902:6bc4:b0:1d0:6ffd:9e2c with SMTP id m4-20020a1709026bc400b001d06ffd9e2cmr17679545plt.126.1703007946725; Tue, 19 Dec 2023 09:45:46 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:45:46 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 02/17] RISC-V: ACPI: Implement PCI related functionality Date: Tue, 19 Dec 2023 23:15:11 +0530 Message-Id: <20231219174526.2235150-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_174550_689058_FA0768FE X-CRM114-Status: GOOD ( 15.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 45c660f1219d..d939fff5b5b1 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -13,6 +13,7 @@ config 32BIT config RISCV def_bool y select ACPI_GENERIC_GSI if ACPI + select ACPI_MCFG if (ACPI && PCI) select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ARCH_DMA_DEFAULT_COHERENT select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION @@ -151,6 +152,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 56cb2c986c48..b7bf1678241a 100644 --- a/arch/riscv/kernel/acpi.c +++ b/arch/riscv/kernel/acpi.c @@ -223,29 +223,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 58497b25d2ab..c8c3369fd69f 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1520,7 +1520,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 Tue Dec 19 17:45:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498717 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 DCF67C41535 for ; Tue, 19 Dec 2023 17:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JbJI8r6GrfcjQrXgIF/p11bxNW24AWqQp224KNQLm/M=; b=OXYNJhjsVlmIjL MfmTLfds/WEavVv6OIpMPHkMygn4VpxPPbuqIMfaGFi4EL/RvSBSIT9CU9DXhL3A1KmL75lwnTJYl o8wjJ4NaA3TxPxlt2AOxyeRwD9so8uH2iboSGLug6/ELN6fBlAT3YBNNF4qLKUNNxat957zmKj6yF 7t7lp/MWABXPh+kGcpZYtQ7IHl3ZpE+pNtY9FUrBd0npcuh7rrvj1Tj0gA4YefwkexiZKoLSSmzG9 LJZzEDA7Nr8Fm0pSJkXxO9CGKzgf5B2OLFKr/n3LeSVh7yS+i/76o+rMLSoefVmgjL57+8j5AnMza x04jyXzcX7+53Kvuh6wA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAQ-00F0is-2R; Tue, 19 Dec 2023 17:46:06 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAJ-00F0fk-2M for linux-arm-kernel@bombadil.infradead.org; Tue, 19 Dec 2023 17:45:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BmjC4RdyrxsTphcSUlyn0FA/9YESGtMGM8wLh/XfFs8=; b=csgJeXqb1gIddKjmnoFJGn/aNi s3/2olcl6XGjP3IjIJv2/FQaO4p0xjkL+6o03R1iPYBr09eSz/IKE6YYlmYkd2LOHE53OiSK8OXec SZTq7QNuF3qb4tBaTSM8BJYBIIZ1OQxBEnHUUeSD4xklcJvT2Ehi35J2rwA5DYZpQlWFwmzxCC/V5 DncrE6/5kwBbD5LuF8rWiq0FfMgzUjzNpIwIbdx8YbXZdXFlc37eq/ULcGziWnF2j35V80gVlTp+f HF3CcDztfmmlplmO+O7PD8/gtPf/Jza44Y6T5Src3k9yvMYK6SMPIu9xGrjU3nATMj+KJV4uBd8gC qI2Gj1zQ==; Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAF-00DXw5-0p for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:45:58 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d3d0faf262so14928175ad.3 for ; Tue, 19 Dec 2023 09:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007952; x=1703612752; 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=BmjC4RdyrxsTphcSUlyn0FA/9YESGtMGM8wLh/XfFs8=; b=oXJpzElgdocsq4cKSIWKDKJOpynKYUA6msSj3xM2pgp74Mnnlx1i7fYDnSJ/z7MauV chfJ467z+CEFtk1eu0OpgWGOmeEB668M0vcUCP6gBHRgyGv0ofObyLCDQCOyA5ACqYyg heRnMqP/5UQaSRuY8PRL4S7sanQ1jyC6hYbjwgkytTK4YdxVKlc5TimnwMPeOXAQiX2b cADzyp5YWL6sf/PCZ0sVEUgQJZ8HGGAR9iS2dwddr47H0M1+shi0goQTP8Lh3q8gIU9e SX4PK3wIDmRWglgNUU7a/O8Kp+rL9htc288M/xEjQvewNtHLRSWL9MEnawZVq+KfLDon GA5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007952; x=1703612752; 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=BmjC4RdyrxsTphcSUlyn0FA/9YESGtMGM8wLh/XfFs8=; b=MBtDd0QgKivjh0y/hw38IvwtDyFJAN0GGW98+jOmOKMLzbVOW4zp6uOuADKfvY+/2m m+Cv8Fr+nARv2aHxTLUfXG6P0sKRXFODUSpR2qQOaFdYvFhlm6dqDR2jq0XjyvSUl6rT OkwARvY2yq/YyVjGefQezPHNBjuhUFaRmQRvN3IjAkAAP5KzwUtK/sePK0ml7xhJ109Q 6nBuIKjQNcFfAuo+j3iUUmPwWmP3y41m2rY/UkqqqlneRh4XETiHh8uvBYF9OGAkIMiQ s4JHax5Qf5MGX/awOtgzsee/JA8RlYvLjHSvFJgMexWTo/MQ0Qa665o8LBrudiVQa89K gQqg== X-Gm-Message-State: AOJu0YwCx9xfGyB6r1JSmVHj8XegOqVk4ARiKDL/0y6gvxBql9d7BHj4 /xb0uknwHQaJxNL8UJ6M7L+bLm8ViE8XgjY4pis= X-Google-Smtp-Source: AGHT+IGWi2Va1Qi6uqFOhvnkUNZMLVftSlFBeT8Hj5dDFOU/lfjLFJQW6CDFmhglgioUotv/TL88Sg== X-Received: by 2002:a17:903:32c9:b0:1d3:c201:3bbb with SMTP id i9-20020a17090332c900b001d3c2013bbbmr3333704plr.18.1703007952281; Tue, 19 Dec 2023 09:45:52 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:45:51 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 03/17] PCI: Make pci_create_root_bus() declare its reliance on MSI domains Date: Tue, 19 Dec 2023 23:15:12 +0530 Message-Id: <20231219174526.2235150-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_174555_414124_B60E4E65 X-CRM114-Status: GOOD ( 10.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Similar to [1], declare this dependency for PCI probe in ACPI based flow. This is required especially for RISC-V platforms where MSI controller can be absent. [1] - https://lore.kernel.org/all/20210330151145.997953-12-maz@kernel.org/ Signed-off-by: Sunil V L --- drivers/pci/probe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 795534589b98..9e941cf55d87 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3054,6 +3054,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, bridge->sysdata = sysdata; bridge->busnr = bus; bridge->ops = ops; + bridge->msi_domain = true; error = pci_register_host_bridge(bridge); if (error < 0) From patchwork Tue Dec 19 17:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498718 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 CD56EC41535 for ; Tue, 19 Dec 2023 17:46:39 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kT4kKvA05fuT40XNdWPXGE4djsx7bmOJiC21S0RYVXA=; b=Nre1P10k1mAamW U4YSt87ayzhCDGWTDxn96Jd7asgG7opEY5HgiZKdhUtGYkdKvMSMaTFzY9KWywZCaXx0Zgmbd3nNV bcd3Usx32ondJXMBYTXEEBYdagRsvI0EHOb7oxhL/GoCt+c84sOS6fnN4Owo+XCEWIY4CAJetgCDC ynNG/T0V1ANwqlOKlZcm8Yj6ZRv5HqI85Q052oPHQ8XkOweqX9qEIjdeq77p4b+7eb6hFs7GmJQYV hz2XBEdaPTVk8Vb8gdB8RYkK+Gp4kUmz48RSEej5oVEwAWqFOrNBV8A7u3jwXIJRop1in5PDAbypO q3HOwyrx4+N6OkYFKYDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAW-00F0mQ-2z; Tue, 19 Dec 2023 17:46:12 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAP-00F0hf-1q for linux-arm-kernel@bombadil.infradead.org; Tue, 19 Dec 2023 17:46:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=EebfT5RsMliPiqXCl62hkrmh6d2gQOm2GsmEL35aFBc=; b=D2PmLkvGwbnBRAQPAYjESnDA8m KOV/r6Vo0LuVIZh7Ne5GjBUqmAF8SqlIEoAOIt36Isy9JfusTl9fSFFtL8AQPXpujgG7O0+4vCpd+ r8oaQbbVtt1MTHEdEeCb+uR0aoPxYERBH8xoOlZXAnS3z1nJsZ8ELprI5OyRLmmFmbDfwfC7g4UhM sLP7hb7JEx9dDrAD+pjuuR0Mc3Sy29Je/30vxBDC5HNpXDAdI2XapbiBVje1WiOBkLtAymMS/2rgA yP3YqpLPJsdQVo7+nBovIXw3hdqy+Bz+SyWrPeEpj1CUlqvaB1u49L4r9wbD2lKI7yetA9v9OdZIW 44efKzqw==; Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAK-00DXxM-36 for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:03 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d3b547cd4cso13560145ad.1 for ; Tue, 19 Dec 2023 09:46:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007958; x=1703612758; 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=EebfT5RsMliPiqXCl62hkrmh6d2gQOm2GsmEL35aFBc=; b=LucRnn4AP8hZLYQDdPgslNrAe/m6I2CshNJYbNeCd69sEa0eAox/hfbw2xsQosI8Sm uxp8Jnlgn7GCddKR+Mht69mBcerqvAUuWsck9xKrgj/R8GxC4GPJ4/Z4CbDrNcy287ue 6Oy9MW8LHeYrUhn3HIY3wiJ8o2SVfj5BOCZ/jHgzk7tPt35Y2QQ70wxTzyTAFveyE60y E+go27vAdV2jXfeITBHc7yGdaGxsqUe3RiAtC3qX8VsQ7Hn+KEi4wXuw/PXeEqMvcx6l FISlzn0bXmuPCzohQkfCMKu0WZUXHP8H9GoVsXf9umxRTiv09KUUP0gGgSQuJ4hFi5HN +sgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007958; x=1703612758; 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=EebfT5RsMliPiqXCl62hkrmh6d2gQOm2GsmEL35aFBc=; b=sakamLEemh6j2UpuuvW5M5U0NayZegNJLbOOH72jsOnAamCiUS/L5o1gbAjCx0wUY7 ctl3fKLCb0TpekXhl0/Ewa/knYgjwf1PynLD78s/dsKjkyWBaUhqjYE1res45rRYsbb6 84Dme7uAh7LhpONPLoG8CC6c3gHz7pAQJ8I+crZYQM5MLG0eRhiwZZAzbhIWowre3IHC 9pAPM69U7fsPeNrf9jtpDqGI7xIYCSAjS4tB7RZhRU7GgCd0lT1LSPOaKhz3xgYq0a+V r2slkFBCK5+jxHLMClEp5Apbc7SOTqtbbZCHEXUNgA0eetMBwwqg6xxJNm4GfxCc23jW 786g== X-Gm-Message-State: AOJu0YxVetk10LQjjrOLUjNeUYG2cRI7YW9dY6ckw1aea6DT/7aWED+y wgJop1e3YmvPZ5r/ZSp643d9xuOKCFZhheGzwwk= X-Google-Smtp-Source: AGHT+IFzyQR9Vgnsqa5WmyfTr/Nm6o19oAodCnDVZm95vLyPUVPinYImx8yjTiAOib7HfgdqSjZW3g== X-Received: by 2002:a17:902:7c8c:b0:1d2:ec9b:92e with SMTP id y12-20020a1709027c8c00b001d2ec9b092emr9877603pll.115.1703007957846; Tue, 19 Dec 2023 09:45:57 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:45:57 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 04/17] ACPI: Add fw_devlink support for ACPI fwnode for IRQ dependency Date: Tue, 19 Dec 2023 23:15:13 +0530 Message-Id: <20231219174526.2235150-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_174601_025051_38BB46A3 X-CRM114-Status: GOOD ( 18.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently ACPI doesn't support fw_devlink infrastructure which helps in ordering the driver probe in the order of dependencies. One of the dependency between devices in ACPI is GSI interrupt source. This interrupt source can be another device and mentioned as part of ResourceSource in the ASL. Or it can be indirectly determined by the GSI mapping. In either way, adding the link for this dependency avoids modifying all drivers to handle EPROBE_DEFER. So, add this new interface into ACPI's fwnode handlers. Currently, this is necessary for RISC-V architecture. So, kept the interface functional only for RISC-V. But in future other architectures also can enable this functionality or can be made common. Signed-off-by: Sunil V L --- drivers/acpi/irq.c | 18 ++++++++++++++++++ drivers/acpi/property.c | 20 ++++++++++++++++++++ include/linux/acpi.h | 9 +++++++++ 3 files changed, 47 insertions(+) diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index 1687483ff319..b3409e2e2041 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -354,3 +354,21 @@ struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags, host_data); } EXPORT_SYMBOL_GPL(acpi_irq_create_hierarchy); + +int acpi_get_gsi_parent_fwnode(acpi_handle handle, + unsigned int index, + struct fwnode_handle **parent) +{ + struct irq_fwspec fwspec; + unsigned long flags; + int rc; + + fwspec.fwnode = NULL; + rc = acpi_irq_parse_one(handle, index, &fwspec, &flags); + if (rc || !fwspec.fwnode) + return 0; + + *parent = fwspec.fwnode; + return 1; +} +EXPORT_SYMBOL_GPL(acpi_get_gsi_parent_fwnode); diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 413e4fcadcaf..88769acb13d4 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1572,6 +1572,25 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode, return res.start; } +static int acpi_fwnode_add_links(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *parent_fwnode; + unsigned int i; + + /* This is needed primarily for RISC-V. Other architectures can + * be enabled or made this generic if required. + */ + if (!IS_ENABLED(CONFIG_RISCV)) + return 0; + + for (i = 0; + acpi_get_gsi_parent_fwnode(ACPI_HANDLE_FWNODE(fwnode), i, &parent_fwnode); + i++) + fwnode_link_add(fwnode, parent_fwnode); + + return 0; +} + #define DECLARE_ACPI_FWNODE_OPS(ops) \ const struct fwnode_operations ops = { \ .device_is_available = acpi_fwnode_device_is_available, \ @@ -1597,6 +1616,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode, .graph_get_port_parent = acpi_fwnode_get_parent, \ .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \ .irq_get = acpi_fwnode_irq_get, \ + .add_links = acpi_fwnode_add_links, \ }; \ EXPORT_SYMBOL_GPL(ops) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index afd94c9b8b8a..e9a9659314f2 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1463,12 +1463,21 @@ static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console) #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI) int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res); +int acpi_get_gsi_parent_fwnode(acpi_handle handle, unsigned int index, + struct fwnode_handle **parent); #else static inline int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res) { return -EINVAL; } + +static inline +int acpi_get_gsi_parent_fwnode(acpi_handle handle, unsigned int index, + struct fwnode_handle **parent) +{ + return 0; +} #endif #ifdef CONFIG_ACPI_LPIT From patchwork Tue Dec 19 17:45:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498719 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 E1DAFC46CA2 for ; Tue, 19 Dec 2023 17:46: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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8ebq4mACgAqdw+jxVfK/xXLg1ZcSChBlsDsfFf8Pcjk=; b=SYAivLUTfv3Xvm t6hAIeFMS0Nxui4XU9WK4nhQBEc8hMmzF6+m3ewpOgO1QAt0F5XYNx8Fddh7Ka3GGVYXHx7eYBa9G h+HpyYSuFdWSnK0O3evZDotnSTcrW5lZE+jnlldAyBGWtahrpR1RqIDpc+tVaffDmYPinZERsrWGK KfTZbTkhPAonsTOcPNZc09a07+iXyOQdsn8VjhyNiwBMwYf/DNNNZG10+W6YSzjGVIEqOYpQ++beE eE/Rw5rI74j9fb864b3MDxHHGkgafxx9S8/In7RcifGt/V2Q1f4U2XEl+fwv7XF0ZOAxrvQlhOoGY 1O/3KRxbRYiWyv2p/hYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAf-00F0sT-2I; Tue, 19 Dec 2023 17:46:21 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAQ-00F0he-2E for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:08 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d3d0faf262so14930295ad.3 for ; Tue, 19 Dec 2023 09:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007963; x=1703612763; 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=rIbnDt1gfwHKXHRoQ8BCVk+wpgvY6XHWajEKia0uA/M=; b=H7rWLXiVCjVVWcBsRo7Q9ZE4od4x7l36Gm/VO1uraIkiSR+cldghZ2fOT9W0sh55XI Q3gqrWEKc0RtxHeTJ5lS8iBCypkQcljSYixiw9gAgbTP20keIkNj036+DbuUbvsjEbFB OPfuWKai7yZ7x9zgm1ghZkRtJWZ2+lzcPzuCd9mU/zWR3hnSBJ3YA3qmv0D4mlxRe+nJ EN3J9vDGyVPllF21P9z6UmPeWtkWFGMXww9UPnc66bEVRVZN1PzMZZ6e6aZLXu7XrE/G z4qnOJqJS59yAM77utm5LEAsNsd/oQTazP6GyrvkYoqaJXN8N4HrOLlwj9L76AQtwqXd FXdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007963; x=1703612763; 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=rIbnDt1gfwHKXHRoQ8BCVk+wpgvY6XHWajEKia0uA/M=; b=TtENrxA6Q97VgED0q+p5Os9ZmySLLS+jQaUY/9tC9O6BiNJT6C2BPLRBCxGx5VPJAh 3rredcDmfkJePlwKAHNmW8689m5vCmKQijKrn7nD8ARbn+z555vxm88Mm6UTcOPA57qf cx83I10OBfNKAFWN8DuG0+gWIsUATNOcVph/VPe2i7ffiYq9GrMz7dig9nAiTegoRwgc D3UwGEL2hlMqIaKK610CHz1MUirNwYJ7uz6Qanx4PCJmNb781sILwg6/wkj+zGbjkj5F G+0V46o/57AOi1wlkalYZsEtmnS1SGKeJULanmSAEIUrNaFgSSE9dYe1zujsjafhr25l WZrw== X-Gm-Message-State: AOJu0YwgGBdSofv74n337iWC3J/8Pn3fT0YlUOndaBTIE2wp1LIrDBwV qWbOQHDyfsd+qWT3D3uGtToPwJMVgRmKa394SVQ= X-Google-Smtp-Source: AGHT+IHoJyst8qKxevbQtQHjUD2Bmcj6vMHRjagPkED1xi9g/ptnAuHzMtmh5nHrJpPdrkAYQWohig== X-Received: by 2002:a17:903:28f:b0:1d3:d8e5:9e38 with SMTP id j15-20020a170903028f00b001d3d8e59e38mr2543797plr.2.1703007963429; Tue, 19 Dec 2023 09:46:03 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:03 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 05/17] ACPI: irq: Add support for deferred probe in acpi_register_gsi() Date: Tue, 19 Dec 2023 23:15:14 +0530 Message-Id: <20231219174526.2235150-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094606_752661_5342C693 X-CRM114-Status: GOOD ( 12.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The chip which provides the GSI support may not be initialized at the time of acpi_register_gsi(). Return -EPROBE_DEFER to support deferred probing similar to acpi_irq_get(). This is required to support ResourceSource as supported by ACPI spec for Interrupt resource. Signed-off-by: Sunil V L --- drivers/acpi/irq.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index b3409e2e2041..c4605fdcda77 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -52,6 +52,7 @@ EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); * * Returns: a valid linux IRQ number on success * -EINVAL on failure + * -EPROBE_DEFER if irqdomain not created yet */ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) @@ -65,6 +66,9 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, return -EINVAL; } + if (!irq_find_matching_fwnode(fwspec.fwnode, DOMAIN_BUS_ANY)) + return -EPROBE_DEFER; + fwspec.param[0] = gsi; fwspec.param[1] = acpi_dev_get_irq_type(trigger, polarity); fwspec.param_count = 2; From patchwork Tue Dec 19 17:45:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498720 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 C924FC46CCD for ; Tue, 19 Dec 2023 17:46:52 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bWmegncflH6XyPu48Vmzf8sZkZwbI4PtM5QihgG5q40=; b=4lusXTORCgyyJO yZq5SQqwp4S8+06d+zya/8/z7WHqtv8/0sZwTzIJkpkl0/j6P1wSm5+p1RfbG7HPE3zhFnWyBXjPO P6IHBuxzoluZJjpS7gDl6MTpuhODAPRZs5+q3fggi647pvLnINPIMzzqETXjXnnTDHz/xFVY0/xvm RZdLE5lwdTEAxWCp7mpucIQ1QIWUlCxORkEl8DH8Xi8Zs8XeseeK3vfXQHNAID26T/DZJkjn+FoaY aU+BCq/2duPncDfsqktn/SbMk4nkN07UP76QtBH5W3HoA92bbaDeNw/BJF0FU/oHhQnik78FUraAX 4Tp1p9ePZf1xlMeXWFBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAm-00F0yS-2E; Tue, 19 Dec 2023 17:46:28 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAW-00F0lC-2H for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:14 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d3ea5cc137so1864625ad.0 for ; Tue, 19 Dec 2023 09:46:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007969; x=1703612769; 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=8LBkXmYKNUx+bSYPP6p7CLC2p/4CszGfBGCJeSRJvdc=; b=L9L/N++gd3RL+jsEdhZohtnewTO9PbnhJJf12Nhj1knvQhK8TiQarLZtvEbuWFX7e0 38BF6SbjpcJGJohWCRd2g2gLL6MqVnVIMcBp8ygquxJjLHZVw7JQnq1Tn881ciZ+frEL 06pZT9bkOLhRagq5gQEL8ctB2POiUOUkQzqTYlHq1pekzFakfx9lG5iRo8CJFR/nD9I0 y5+6X66h2NWb/ao9lx/H1PvT5SMdmzEUa8ouXm7m35BI2uzR/ALalf6gD61pt7RektXT E67y/zNVfUnCYbQIYplkEhGMBT/EkK1upZJsx0GqUyYfT5RTv9z98UXAHeTogygcfv5Q bilw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007969; x=1703612769; 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=8LBkXmYKNUx+bSYPP6p7CLC2p/4CszGfBGCJeSRJvdc=; b=Z7xm85NU+RvRaOx7falICN36DbL8Z1fCMNG7/aYrihJSGuN+OfY3RX7VFyb+hopbqn d+gzY4HHGveRqhuZlO+LFsJcAnWeXbnVdNz2ZazDBvRtC15P2KRtcPADGfGhCTIyDY5G ybf3qv5W1QPRdpwl7vzLBIwPUZ3t1ql8ilbqSaNL2c17mGFlVY4vAzEuTXUztDClWm0c wq7nghggrqsFy6Hk2eUIux5iWf8i6bdhwTh4nB1o05Z2nFNvXdD5+fp4XPj5TglWl8+/ sf5fmZuMk3e3xpw/K4Gvz39+bQT04JdtAKDetCegHpN5GyoegMbQMBVh2A2qeA1KyKpe p6Cg== X-Gm-Message-State: AOJu0Yzq+WkEtK5bEbA+B8r0uVkwGDTx5/n8eBz7khjwqwFMzfVtZaJ4 y8byFP16bBxjl/pclV9jVuxp+HBIxrrFyiPlPYc= X-Google-Smtp-Source: AGHT+IEMvSYcrKMxqjyd3ACjSYFZyEXnOTwUkKyhJepg7AXslIP9xhn3TON8/gf45hSmF7UFc175LA== X-Received: by 2002:a17:903:1206:b0:1d0:7d9a:3bca with SMTP id l6-20020a170903120600b001d07d9a3bcamr23158609plh.52.1703007968947; Tue, 19 Dec 2023 09:46:08 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:08 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 06/17] pnp.h: Reconfigure IRQ in pnp_irq() to support deferred probe Date: Tue, 19 Dec 2023 23:15:15 +0530 Message-Id: <20231219174526.2235150-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094612_751586_7D619826 X-CRM114-Status: GOOD ( 18.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org PNP devices add the IRQ resources to PNP data structure early during boot from ACPI resource structure. As part of this, the Interrupt resource (GSI) are registered and appropriate linux IRQ is saved directly in PNP data structure while creating PNP devices. But at this time, the interrupt controller for the GSI (either via GSI vector mapping or via ResourceSource in Interrupt()) may not be probed and initialized. Hence, the IRQ number in PNP data structure may not be the linux IRQ number. When the actual driver for the PNP device get probed, it will get incorrect linux IRQ number. Fix this issue similar to how platform devices handle this. Basically, while creating PNP devices, the hwirq number is saved in PNP device and marked as disabled since acpi_register_gsi() would have failed. When the actual driver calls pnp_irq(), get the linux IRQ number again if the IRQ is disabled. Signed-off-by: Sunil V L --- drivers/pnp/pnpacpi/core.c | 7 +++++++ include/linux/pnp.h | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 6ab272c84b7b..239355977d4c 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -326,3 +326,10 @@ static int __init pnpacpi_setup(char *str) } __setup("pnpacpi=", pnpacpi_setup); + +void pnpacpi_reconfigure_irq(struct pnp_dev *dev, unsigned int index, struct resource *res) +{ + if (has_acpi_companion(&dev->dev)) + acpi_irq_get(ACPI_HANDLE(&dev->dev), index, res); +} +EXPORT_SYMBOL(pnpacpi_reconfigure_irq); diff --git a/include/linux/pnp.h b/include/linux/pnp.h index c2a7cfbca713..8753eb4275b0 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -26,6 +26,7 @@ struct pnp_dev; #ifdef CONFIG_PNP struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type, unsigned int num); + #else static inline struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type, unsigned int num) @@ -146,13 +147,22 @@ static inline resource_size_t pnp_mem_len(struct pnp_dev *dev, return 0; } +#ifdef CONFIG_PNPACPI +void pnpacpi_reconfigure_irq(struct pnp_dev *dev, unsigned int index, struct resource *res); +#endif -static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar) +static inline int pnp_irq(struct pnp_dev *dev, unsigned int bar) { struct resource *res = pnp_get_resource(dev, IORESOURCE_IRQ, bar); - if (pnp_resource_valid(res)) + if (pnp_resource_valid(res)) { +#ifdef CONFIG_PNPACPI + if (!pnp_resource_enabled(res)) + pnpacpi_reconfigure_irq(dev, bar, res); +#endif return res->start; + } + return -1; } From patchwork Tue Dec 19 17:45:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498721 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 6536BC46CA2 for ; Tue, 19 Dec 2023 17:46:59 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oe3WRzsopBSEW+mazax0D7MpiIwj86/5LRkf0EpGArM=; b=xHsTW1QbQ3D9P5 YIZBdVRHeGg3mlvw1mySLRFAbsIYoNbGR3OV0EKBe4KxN9TRhYWvsymTIrJ6z4SdjBa+C9qsB1AqS rFkH4aSLTpkiJFZk2lStLznk336WjDT+bkMzIgk/vJBLGzh4HSBk5CVtvfzIAI8B5IFqt1fveb4Fj QpV9qGG4+RO/EE91uJqDQYfjFcra7QCuMSnnac+uLm2ipMjcPJ52RxtdU27+7hYEUh0T9WZa6tUEe gB/Zd2EzxXC2jClD+3b2ZpGO6M1qdjveADXOMyDxHKynJdvyyOyhiVLCzFoysQzdkJd4jrTSHUP2s 0tck5MQGnqhtaO6ir7Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAo-00F0zI-02; Tue, 19 Dec 2023 17:46:30 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAZ-00F0o9-3C for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:18 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d3c394c1f4so13307175ad.2 for ; Tue, 19 Dec 2023 09:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007974; x=1703612774; 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=wXn1vXDcIcY9aE9ZluWKdogaSHoQIJLjYHgL6fRVi5k=; b=cJh7sgLpf3nNW6rBKB+KKcwVgHw/6QsThkRdQc9sBZUcrDl8a239Chm75ZQRKgSBk4 uzvM/e9D+xG5g3rRht65jTLK5a+usqZU9FLC6g334iqloQKCdC9+hQNggWHvgVaq5udV v29rygC9HdO5r8b46rhwCsNei8tNmztIxfuiSJscMx/1OMVXCFC1YpY0C+gyZy4i9JQB 2f+LxBPG4d6EXIHVSt3oQeSO+LdVXeOXtRGgDh2OzuLTW7t/z1JdfyciWlN5a2fOli06 JEeEeb4Xld8G5VhIwgRuHXxNQiO0tLdOLicGnmCHFalVRvz4OHLD1rPZkSuO63txOStx w1Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007974; x=1703612774; 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=wXn1vXDcIcY9aE9ZluWKdogaSHoQIJLjYHgL6fRVi5k=; b=lr/lthWq/ZoTbJqOOyFrymao39m1MRtjcx4PqsoxUPjB9AKxHddh2ir0OG4h4SSW7Z TjnNTFTRo0iPrIT4/IN+Elz8gYmos6PXjUF77zpMgwJqjkoias82Fa06VSdG+Xflh+KF MSYyFPjob8pa8E7cfmmbbuh1FXkANzkybqMXNUqyYLcC+IUBfRLwfGM61s2VzkzhXfQr JVPHal8TCNdW//z0FLZAwK79TIOO/ZeGNR2wGGp1ybFZpKTUGy34TFMG5Yda+TPrq0o9 ziuBiyrndB0WuOX70o1gg0g4Oh6v3I9Rz0mVSs/Ej8y70WBnylOMw26oKPw5/ROzTcpH QPJg== X-Gm-Message-State: AOJu0YwWnuB5KHrjNnegjBfvmfqe/a+Ozf9c48ocPMNE06B9S6HTnMLj NXorZKl5tn0af26QPDvWkq6p53RyKkZ51npU0rs= X-Google-Smtp-Source: AGHT+IEyMcGZ8gZDustI/NrEk9p7KXDerpeWb1pADnYIYBEjwIh1UqME5pxQY3avzxvrA+zMIvUqTw== X-Received: by 2002:a17:902:ab84:b0:1d0:6ffe:1e6d with SMTP id f4-20020a170902ab8400b001d06ffe1e6dmr8678824plr.80.1703007974481; Tue, 19 Dec 2023 09:46:14 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:14 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 07/17] ACPI: scan.c: Add weak arch specific function to reorder the IRQCHIP probe Date: Tue, 19 Dec 2023 23:15:16 +0530 Message-Id: <20231219174526.2235150-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094616_038996_07CDF975 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Unlike OF framework, the irqchip probe using IRQCHIP_ACPI_DECLARE has no order defined. Depending on the driver Makefile is not a good idea. So, usually it is worked around by mandating only root interrupt controller probed using IRQCHIP_ACPI_DECLARE and other interrupt controllers are probed via cascade mechanism. However, this is also not a clean solution because if there are multiple root controllers (ex: RINTC in RISC-V which is per CPU) which need to be probed first, then the cascade will happen for every root controller. So, introduce a architecture specific weak function to order the probing of the interrupt controllers which can be implemented by different architectures as per their interrupt controller hierarchy. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 3 +++ include/linux/acpi.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 691d4b7686ee..87f4baebd497 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2685,6 +2685,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; @@ -2693,6 +2695,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 e9a9659314f2..ae045e14126b 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1338,6 +1338,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 Tue Dec 19 17:45:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498722 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 4357DC41535 for ; Tue, 19 Dec 2023 17:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0qzwiW5vzzbCS8jW697ciibDxRDX1HbB38PUIjkpmrI=; b=G48BG0bnsxbBkC ekVs/BoVY9W9EGT+++rKI/RCcqpCYz/e8OEkQlZsM0KPfy5ku1vlcRcO7dB0fe7sitT/8XzOlL3Ex GrxZOpcNu86I5k1kbN/yJD+eazJvqv8ITw6AZR1paaKIG8YwiIswCOjSmW842u44nmZVCjtKxJ98k e08xL79O9TB02xb9ZqJ1eLypNasMgKZTi3i/5xV+7vlMFTCl/RmrW5az2YHYdgn/pWnyt9uVpCgOc uogGkFgF6/EkbdKFAAt2zgz7M7wk9A4rF47s6oP5J5KMHPZIDTT+PEYlatKpjjmuS97+ZBek5tu6J HMBQ6tR9eQFcwZMGV7jQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeB4-00F1FX-1g; Tue, 19 Dec 2023 17:46:46 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAp-00F0sI-0i for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:34 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d045097b4cso20625345ad.0 for ; Tue, 19 Dec 2023 09:46:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007980; x=1703612780; 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=DxzCTJ+m1lwBq+RMy/cftySc6UneYPqTwJF8JhbniDw=; b=XrA9wQCYcx3jpZo2hbxOgPjcCzZk12Loz38MHF/A19Ah8puL7EN0sIoD/mUXLkSA+Q iD14PdIEMw4WoiEwNa0s811SC2L9ujGAJuxDvY/MZDU/H3C8SfGkoHqt1b5984DQgWAv rr6aH6hjU6FaxXn3DQid7rmFs0LJg+59REZSy+nQgMJBtXsQ1ivJRf8BKdtnjk44NZXi 9vQLLi0MAqY6mNlV2GAWZMPPuBXjZaVQrw0+e65SjXZlxdTZVRC+JETGo5JQanKCw6T9 LqGJVyX5n5SNKFHYPHfBFMZmG+vtbUYGgf3NqUKbLusUjmJAzcIeeBwYV4rtgtgwcyuC EK7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007980; x=1703612780; 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=DxzCTJ+m1lwBq+RMy/cftySc6UneYPqTwJF8JhbniDw=; b=idSzO2JQJYgKA2j+cyFNKzzslakdDh6bLyaiQbCNu1lZcQI9g46pW2sDr2si/cyCWI JHZOBAHff1Y9+f0K8yRKmf0oRXNKlz/0ZLqDdkde7RrVqCiSnemmHA2jITv5JP422tgy xWuPJNS2mYwAFvOAhOsad3HNw2GNRc/EIih08mBTw9rcH5n9pqe6+DSPOwpYfJ0QjIig NsqalF5dur+SBfqQvod8nGzvCKpAFsU8GBHcFbP4m/CQKsdNmB6NxF2aVlmgQkLuPRic A/F7gOjIfB28kr1TM/WDl9bHnbVIzmOIymKR0mPuUj3lTxrxQ0A45Zwpe6N30pUFcvdM l+MQ== X-Gm-Message-State: AOJu0YyAgnCxHcCWYn8KmKsJVDMDLX9Bx8TajecvIszwJE7vK/NlyLS4 ZbvEm0o92GANcVVbhb18vw2qaEghorHj3ctK6YM= X-Google-Smtp-Source: AGHT+IGFtvkGTPcA5+8hPSE9xpA6pHB1AGzz+4bVKCbl0RMQ6TV2kDkPIPCZHZCd/3GrTRkpVagWdQ== X-Received: by 2002:a17:903:41c8:b0:1d3:c5e4:b2f3 with SMTP id u8-20020a17090341c800b001d3c5e4b2f3mr2609020ple.100.1703007980064; Tue, 19 Dec 2023 09:46:20 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:19 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 08/17] ACPI: RISC-V: Implement arch function to reorder irqchip probe entries Date: Tue, 19 Dec 2023 23:15:17 +0530 Message-Id: <20231219174526.2235150-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094631_367829_6D67A0EB X-CRM114-Status: GOOD ( 16.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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. RINTC->IMSIC->APLIC->PLIC 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 8b3b126e0b94..f80b3da230e9 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y += rhct.o +obj-y += rhct.o irq.o diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c new file mode 100644 index 000000000000..36e0525b3235 --- /dev/null +++ b/drivers/acpi/riscv/irq.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023, Ventana Micro Systems Inc + * Author: Sunil V L + * + */ + +#include +#include + +static int irqchip_cmp_func(const void *in0, const void *in1) +{ + struct acpi_probe_entry *elem0 = (struct acpi_probe_entry *)in0; + struct acpi_probe_entry *elem1 = (struct acpi_probe_entry *)in1; + + return (elem0->type > elem1->type) - (elem0->type < elem1->type); +} + +/* + * RISC-V irqchips in MADT of ACPI spec are defined in the same order how + * they should be probed. Since IRQCHIP_ACPI_DECLARE doesn't define any + * order, this arch function will reorder the probe functions as per the + * required order for the architecture. + */ +void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) +{ + struct acpi_probe_entry *ape = ap_head; + + if (nr == 1 || !ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) + return; + sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); +} From patchwork Tue Dec 19 17:45:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498725 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 15C7FC46CD4 for ; Tue, 19 Dec 2023 17:47:19 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ulAEjPJEWbelKLS0hUDIxrLToKDY9zm3zlQJJ8YFjQo=; b=q1mgKDOfHSNMY9 r21e/+5V3RCc6z/Ja6u1i2Mndg3XM8UpWElCL+Wdy/s2NiKLhqx9rM48Hm18fYmxAw94/cQOoHyui UuEe3yUFaaiwEqwibi4W5Fj0a3icIGglkQr0TdWD7usbemyccRWTNu6F7fENVEbDVy/c1FMdgqdBt HcQnuNUBtyzD823ciB8pPEzVPhWYDjEZILzy9oeIAaCOkU/nw+dJhVudoF4lwiaqvirZpAGs4xYmq xc9hAnoKWXUDw+mZNXcdVN3gHLico4SICWe4FKSsoMNOfU48UwzhJUK9FHGzMhtQaZoVTyA1Eu3hI kbmxl4zzZpjMJ7KdW+Yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeB6-00F1HK-0V; Tue, 19 Dec 2023 17:46:48 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAp-00F0wx-0i for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:35 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d3ab37d0d1so15619565ad.0 for ; Tue, 19 Dec 2023 09:46:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007985; x=1703612785; 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=6M2Ttr5IEog4zhXC7a0v2EI78vgaHJj9cNeT2PJ69Bo=; b=Y3RSIfrBC3iKdfocYvvYb/ODXsg8I1tmuwfi/APmUtG0jaO2dk3rczC5VPgJKZBGTi 1jOgjk5YWS2EfC3VuviyEjd7Ja2SLkK77fyHPAphSNDzNjCCwZpWAzmxTn+iXUfyjXzT IM+HqBngbKHAQ3VR/ySPkOTBxOaP8OL98+7l086bU2aYP5h8eP05ikupd2UF6YNfCVw9 bW7r/3KrQiGCVwZm9SbCGsl5BpHxMrG0nzHQsbHC5IHr4ZBgbenHrkBELn3w3cBUHrdC 37Bc9LZC7pQi8Zvtd6ZIIkryG08GexXQJftFo18lsPpcSsDl4UEdoyIydq3D/kvfjDD5 GFJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007985; x=1703612785; 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=6M2Ttr5IEog4zhXC7a0v2EI78vgaHJj9cNeT2PJ69Bo=; b=GxBwgqugiqqxIuw16Xx4rwy0RXmuFQxSEzBUgQyemHmrO3sCBlC3LiJYsPf+QXZaAq pMv4A4KSy1yrOSvdZGYXHpuU/JP1b70hbF8nW0R1LESvyzEZFYuBIl8lm5H8nG8yoRY9 gU0iVIp5uhBnrLnK3h3/8hPkwPU8vmjy/jJgdD+qn5DwYrtzCiEA495yND4jcjTfgsOb 3cT3IoEfaA88r/sLTwbv/c8VRrrYji0BpjqXDlbbOVrxi1h5phqqphsHy6HuO4IDgS23 S94GDXXDtMqYCqdigMKGzVyQXmOKIQ5LzPE6H0JIb4o/eNMZ1VhcXoZs46COxryXdmYc 597Q== X-Gm-Message-State: AOJu0YzByIR3bI0K6boDkTm0JNdhosRn9SbaDO6EFhppoa5ytzHwrAc3 mzMLZLsWtQayxaVnH4lI8/JKBrGBQj/cHjlgrxU= X-Google-Smtp-Source: AGHT+IEAjjn9pf8/hId5Sa4wpo1o7XJP2RBbztVfkHUMJTgjzPp06dL2QyNaPuDgFCe0l/XzTMzF2g== X-Received: by 2002:a17:903:98c:b0:1d3:e786:ab05 with SMTP id mb12-20020a170903098c00b001d3e786ab05mr648299plb.39.1703007985615; Tue, 19 Dec 2023 09:46:25 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:25 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 09/17] irqchip: riscv-intc: Add ACPI support for AIA Date: Tue, 19 Dec 2023 23:15:18 +0530 Message-Id: <20231219174526.2235150-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094631_311600_6E79F783 X-CRM114-Status: GOOD ( 18.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 | 45 +++++++++++++++ drivers/irqchip/irq-riscv-intc.c | 95 +++++++++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 8e10a94430a2..232314e5f007 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -12,8 +12,53 @@ #include +#ifdef CONFIG_ACPI + +/* + * 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 __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 struct fwnode_handle *ext_entc_get_gsi_domain_id(u32 gsi) +{ + return NULL; +} + +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 -EINVAL; +} +#endif + void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void)); struct fwnode_handle *riscv_get_intc_hwnode(void); +int acpi_imsic_probe(struct fwnode_handle *parent); #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index bab536bbaf2c..24bbc5bfc30f 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -195,13 +195,100 @@ IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init); #ifdef CONFIG_ACPI +struct rintc_data { + u32 ext_intc_id; + unsigned long hart_id; + u64 imsic_addr; + u32 imsic_size; +}; + +static u32 nr_rintc; +static struct rintc_data *rintc_acpi_data[NR_CPUS]; + +int acpi_get_intc_index_hartid(u32 index, unsigned long *hartid) +{ + if (index >= nr_rintc) + return -1; + + *hartid = rintc_acpi_data[index]->hart_id; + return 0; +} + +int acpi_get_ext_intc_parent_hartid(u8 id, u32 idx, unsigned long *hartid) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) { + if (idx == j) { + *hartid = rintc_acpi_data[i]->hart_id; + return 0; + } + j++; + } + } + + return -1; +} + +void acpi_get_plic_nr_contexts(u8 id, int *nr_contexts) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) + j++; + } + + *nr_contexts = j; +} + +int acpi_get_plic_context(u8 id, u32 idx, int *context_id) +{ + int i, j = 0; + + for (i = 0; i < nr_rintc; i++) { + if (APLIC_PLIC_ID(rintc_acpi_data[i]->ext_intc_id) == id) { + if (idx == j) { + *context_id = IDC_CONTEXT_ID(rintc_acpi_data[i]->ext_intc_id); + return 0; + } + + j++; + } + } + + return -1; +} + +int acpi_get_imsic_mmio_info(u32 index, struct resource *res) +{ + if (index >= nr_rintc) + return -1; + + res->start = rintc_acpi_data[index]->imsic_addr; + res->end = res->start + rintc_acpi_data[index]->imsic_size - 1; + res->flags = IORESOURCE_MEM; + return 0; +} + static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, const unsigned long end) { struct fwnode_handle *fn; struct acpi_madt_rintc *rintc; + 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) @@ -218,7 +305,13 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, return -ENOMEM; } - return riscv_intc_init_common(fn); + rc = riscv_intc_init_common(fn); + if (rc) { + irq_domain_free_fwnode(fn); + return rc; + } + + return 0; } IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL, From patchwork Tue Dec 19 17:45:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498727 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 02905C41535 for ; Tue, 19 Dec 2023 17:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u85MwYd6l06UkJnevzmjY518gjnPEiNVVPb3tJqUBFY=; b=wxpmQH/9zk25IG 4jbpqcA+PQNcZ3a1PdbvcrE1DSNYjibW7JXwcur0skozMA7d3cKRRp6FFcdSPsDCZyYG2qsZRs2ko 2kMhEX4GAss8pWdtJZSMT3fAhN4AVDD5rsbga0THF0YSSxYr05mo5RhTSd4rI77iu8RDnvNYtXz3i BA9ek4CQoy8AaCUlVJ+gz+wbEBRoUo3VOOxpbWPq6V/ruM0VG5HCLh+5tcXh4gwk7Ny7RAHSPFviJ lBdVD+5dzRF3xbUv+e6rIuA6A0nU7MnBfXAcGrLn/c+WwNguMwoYKN/ZvJIMUL2q//+gAX9lQKdO1 EV5n3r7V02hXQXqB9YBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeBF-00F1QO-0P; Tue, 19 Dec 2023 17:46:57 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAt-00F12i-21 for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:38 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d39afa1eecso29693335ad.2 for ; Tue, 19 Dec 2023 09:46:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007991; x=1703612791; 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=t3fyfZ6Lr7w+r0MJIn4zdZonb9lVGi9+7cBScTQl4UI=; b=m9ehLMzwLNHELpOt0SnOYhCW1HdGxH60DxTWrVnPRptSGlAjlHlc3kci+uUamKhrrG 2HUw59quSxb687GR6tHBIuwjWYwWmJS0NxeWSZchecbDWjhx8rS6mRZahGWybJqhwP7D TJrubIBuQ48LR1Rv3gcvsaEPXPnC2FVBm9qPShR/iJyN89wvLcosDMddQn1YXqdVBOP6 hxUIqzBU1hJH48VVsw2BvD8fLkewABVJjO4kRtoJ/yLK6n29Ju6BaufDwawIvwgO28zz MrTsBWdEzcPYx6yNnwT89bEBYjM9BkiX28UeKHMnNCoYPo3nl+AL6y5zrBWlINzK9EBq cu0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007991; x=1703612791; 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=t3fyfZ6Lr7w+r0MJIn4zdZonb9lVGi9+7cBScTQl4UI=; b=foF7x8/RVs2EV1WNSbRFyzQtj3Yy4wyAOYfm8/yhXWphZh1Q/mK2m1jjIJqf19iezd kOWcipQJ82cJq4/3aN76ffB5gcciS8zCKBonmLcsq/gewjXKmbqWsz91R7x8owY1Dq7/ Tp8kTGMl4eAV37AeRvIyzisFSqXh0MFJRBEm8JP1v/RcplxN9WUOWq4SbExM5s0WOqUB MT/Iz7274eVG6BxOfBc9fVemZymHbCGPRGxxE88d/tsLt+izRSEjHn//VGyvquo3LgjT fmPihKNSjFQwlmZg4HAp8Fo/1f1KBFVLQG3AWzcAbyigtWByAjtN795qSh/PW6DsuraB QE6A== X-Gm-Message-State: AOJu0YzANQCLFth5Lft2YfzV1xcH3bWjyzTj3wVnnkG5zY906fKZSXmT m5CjcnKM2Fa+Dzu5alLyvYBmZWIZpqHSDYnhk7I= X-Google-Smtp-Source: AGHT+IGvMgnXEDBDSoxKrnqEIHP2nZ5eywEEWz1Kq0rK1LvLd/V7z8NaX/xR7mnE5/nWPlUXPulrtg== X-Received: by 2002:a17:902:820b:b0:1d0:8fad:f18d with SMTP id x11-20020a170902820b00b001d08fadf18dmr18213249pln.95.1703007991260; Tue, 19 Dec 2023 09:46:31 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:30 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 10/17] irqchip: riscv-imsic: Add ACPI support Date: Tue, 19 Dec 2023 23:15:19 +0530 Message-Id: <20231219174526.2235150-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094635_697565_E992FBE6 X-CRM114-Status: GOOD ( 26.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org RISC-V IMSIC interrupt controller provides IPI and MSI support. Currently, DT based drivers setup the IPI feature early during boot but defer setting up the MSI functionality. However, in ACPI systems, PCI scan happens early during boot and PCI subsystem expects MSI controller is already setup. Hence, in case of ACPI, both IPI and MSI features are initialized early itself. Signed-off-by: Sunil V L --- drivers/irqchip/irq-riscv-imsic-early.c | 52 ++++++++- drivers/irqchip/irq-riscv-imsic-platform.c | 51 +++++--- drivers/irqchip/irq-riscv-imsic-state.c | 128 ++++++++++----------- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- include/linux/irqchip/riscv-imsic.h | 10 ++ 5 files changed, 160 insertions(+), 83 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index 23f689ff5807..866e97559e4c 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 @@ -216,7 +219,7 @@ static int __init imsic_early_dt_init(struct device_node *node, struct fwnode_handle *fwnode = &node->fwnode; /* 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); @@ -233,3 +236,50 @@ static int __init imsic_early_dt_init(struct device_node *node, return 0; } 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 cdb659401199..f905340d24e6 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 @@ -308,43 +309,47 @@ static int imsic_irq_domains_init(struct fwnode_handle *fwnode) 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; struct imsic_global_config *global; int rc; if (!imsic) { - dev_err(dev, "early driver not probed\n"); + pr_err("%pfwP: early driver not probed\n", fwnode); return -ENODEV; } if (imsic->base_domain) { - dev_err(dev, "irq domain already created\n"); + pr_err("%pfwP: irq domain already created\n", fwnode); return -ENODEV; } global = &imsic->global; /* Initialize IRQ and MSI domains */ - rc = imsic_irq_domains_init(dev->fwnode); + rc = imsic_irq_domains_init(fwnode); if (rc) { - dev_err(dev, "failed to initialize IRQ and MSI domains\n"); + pr_err("%pfwP: failed to initialize IRQ and MSI domains\n", fwnode); return rc; } - dev_info(dev, " hart-index-bits: %d, guest-index-bits: %d\n", - global->hart_index_bits, global->guest_index_bits); - dev_info(dev, " group-index-bits: %d, group-index-shift: %d\n", - global->group_index_bits, global->group_index_shift); - dev_info(dev, " per-CPU IDs %d at base PPN %pa\n", - global->nr_ids, &global->base_addr); - dev_info(dev, " total %d interrupts available\n", - imsic->nr_hwirqs); + pr_info("%pfwP: hart-index-bits: %d, guest-index-bits: %d\n", fwnode, + global->hart_index_bits, global->guest_index_bits); + pr_info("%pfwP: group-index-bits: %d, group-index-shift: %d\n", fwnode, + global->group_index_bits, global->group_index_shift); + pr_info("%pfwP: per-CPU IDs %d at base PPN %pa\n", fwnode, + global->nr_ids, &global->base_addr); + pr_info("%pfwP: total %d interrupts available\n", fwnode, + imsic->nr_hwirqs); return 0; } +static int imsic_platform_dt_probe(struct platform_device *pdev) +{ + return imsic_platform_probe_common(pdev->dev.fwnode); +} + static const struct of_device_id imsic_platform_match[] = { { .compatible = "riscv,imsics" }, {} @@ -355,6 +360,22 @@ 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); + +#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 diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 54465e47851c..b842c499df0a 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 @@ -593,12 +594,8 @@ static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, int rc; struct of_phandle_args parent; - /* - * 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) @@ -617,12 +614,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); } @@ -630,20 +623,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; @@ -656,58 +644,66 @@ 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) { @@ -775,7 +771,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) { int rc, cpu; phys_addr_t base_addr; @@ -817,7 +813,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 8d209e77432e..ee1f52891e89 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -105,6 +105,6 @@ void imsic_vector_debug_show_summary(struct seq_file *m, int ind); int imsic_hwirqs_alloc(unsigned int order); void imsic_hwirqs_free(unsigned int base_hwirq, unsigned int order); -int imsic_setup_state(struct fwnode_handle *fwnode); +int imsic_setup_state(struct fwnode_handle *fwnode, void *opaque); #endif diff --git a/include/linux/irqchip/riscv-imsic.h b/include/linux/irqchip/riscv-imsic.h index cbb7bcd0e4dd..c112e5559d88 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 Tue Dec 19 17:45:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498916 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 C745CC41535 for ; Tue, 19 Dec 2023 19:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XOSLH8Kr8j2wGQ4cyQitZ//rSaUIFjM39Z8sAssGbwg=; b=GdkWRgnu5V87h1 l7LzRDR72vWIaQUjA+9BcsxAuVVrGzohzekqPThlrZsIIYl4RovTak4gVeTUU6LoWNHOQultljdIA f+mvQKj1ZA1EPQTSa+xzzkCVdTBsYoul0QB6gAjqmGjt1Tmxwl1iOq4WUiPbEUlbq04LCmSV1YLgK CBPErSMAtiBuLLiTpev80LZhv2x+JpT4L7Tu0XzJoCQUl6KPOGD/SPNlA+N53XZ0vsak/gcKg928s ByKzZ3cGEiJbYDZQCRc2NFPbUuu9FZ7QAMZZnKvDtkI2/jp1YLCR8H47LDV9zY1oI9B5Un3sa+bhH lR06eWPrVJJl4oJeBRig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFfLe-00FGsz-1Q; Tue, 19 Dec 2023 19:01:46 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeAw-00F188-2H for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:43 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d3ad3ad517so12652265ad.0 for ; Tue, 19 Dec 2023 09:46:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007997; x=1703612797; 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=c4ypyUsQkr7EY8e5fntZynE18HeG+okjQYWqm+Ns7+I=; b=B+hteD0GCvqcQO5jIWON9K6t4+MAxJWKYcQrNHua8qmJWpLeXkliKvyFkBJAmdPG8o tPgor24dVuXV93SmJiuscTFppleui2jtpwqFfzmxz37qoT0H7/BdH7jBiSEyynAu47gd kuBqBaBi2+Yb2Yc9oEnVJYJP6xT4SElw62XDuPX87JQfq+lkhF2SmCFeWoEnnJ2VBkyx XAdxxVKskMCLYHjqc5ZmmZjMUpEaT65LQJFTl8a4xpFOEbZFS1QPManiEdqusR0/6zW3 BKTCWmQ41MoVUiUYLRZzcwcxbOt1UCEddvUJRVb5xCfu/OtIddnaqQvItLHHBh9ufIRK sV5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007997; x=1703612797; 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=c4ypyUsQkr7EY8e5fntZynE18HeG+okjQYWqm+Ns7+I=; b=VOlGfGU8tFZlKPDf9MwnKc05hu9lR0QlJU9eHA8gd7YL5S30uSdycN57HMFti0QKTa 8MpXO0cnJqfQc2DC7qTGt78c0DnEBlUP7V8azg8aTh+6BhaKWoFVnVwVKq+6ccLLzIDT 94tLMsfOsKYS1+mWKVph0Isd9Rpy2EmVnRon/pHJoSym4A3r3yikxLX+yU7TPe85Q4e7 136aC73dbbH4OBsT0wKxpFPFOOe1p9Xz9bD37lAPxP2ENwBSi4TSAvHFdzgzSN3a+vMx p473PLFrVnwqT3kUQJxdwzwU0ZqM9kfSKCg5IFCnEYbD1Hy1w3cm33LI7F4yfOwF7ECk O5eg== X-Gm-Message-State: AOJu0YzCAUFe66fdioSpApusx6m3sW+3+t2Ju0PXd2zgLn//C89+phAK HWFLBlVd6C0h8mFu0drexAMClCiOwopMExzdZ4U= X-Google-Smtp-Source: AGHT+IE76XB7tnKdL9tC+n8jwlqk/Jc+Hfp5dyr5WUhNbnt373mTfQ6cFtiDtzHjW586B7xwz4FHqg== X-Received: by 2002:a17:902:da87:b0:1d0:7244:f971 with SMTP id j7-20020a170902da8700b001d07244f971mr11268983plx.10.1703007996834; Tue, 19 Dec 2023 09:46:36 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:36 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 11/17] irqchip: riscv-aplic: Add ACPI support Date: Tue, 19 Dec 2023 23:15:20 +0530 Message-Id: <20231219174526.2235150-12-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094638_793953_3B345AF5 X-CRM114-Status: GOOD ( 25.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add ACPI support in APLIC drivers. In ACPI, IO devices use Global System Interrupts (GSI) which is a flat space split across multiple APLICs. Signed-off-by: Sunil V L --- arch/riscv/include/asm/irq.h | 6 +++ drivers/irqchip/irq-riscv-aplic-direct.c | 21 +++++--- drivers/irqchip/irq-riscv-aplic-main.c | 64 ++++++++++++++---------- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 +++- 5 files changed, 66 insertions(+), 35 deletions(-) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 232314e5f007..df59192a157d 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -22,6 +22,12 @@ #define APLIC_PLIC_ID(x) ((x) >> 24) #define IDC_CONTEXT_ID(x) ((x) & 0x0000ffff) +#ifdef CONFIG_RISCV_APLIC +struct fwnode_handle *aplic_get_gsi_domain_id(u32 gsi); +#else +static inline struct fwnode_handle *aplic_get_gsi_domain_id(u32 gsi) { return NULL; } +#endif + 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); diff --git a/drivers/irqchip/irq-riscv-aplic-direct.c b/drivers/irqchip/irq-riscv-aplic-direct.c index 9ed2666bfb5e..3e7a7e092120 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 @@ -14,6 +15,7 @@ #include #include #include +#include #include "irq-riscv-aplic-main.h" @@ -203,17 +205,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) + 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) @@ -251,7 +256,7 @@ int aplic_direct_setup(struct device *dev, void __iomem *regs) /* Setup per-CPU IDC and target CPU mask */ 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 d1b342b66551..31434b3ff690 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.c +++ b/drivers/irqchip/irq-riscv-aplic-main.c @@ -4,12 +4,15 @@ * Copyright (C) 2022 Ventana Micro Systems Inc. */ +#include #include #include #include #include #include #include +#include +#include #include "irq-riscv-aplic-main.h" @@ -137,38 +140,44 @@ int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *regs) { struct of_phandle_args parent; + struct acpi_madt_aplic *aplic; 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 { + aplic = *(struct acpi_madt_aplic **)dev_get_platdata(dev); + if (!aplic) { + dev_err(dev, "APLIC platform data is NULL!\n"); + return -1; + } + priv->gsi_base = aplic->gsi_base; + priv->nr_irqs = aplic->num_sources; + priv->nr_idcs = aplic->num_idcs; + priv->id = aplic->id; } /* Setup initial state APLIC interrupts */ @@ -204,6 +213,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 diff --git a/drivers/irqchip/irq-riscv-aplic-main.h b/drivers/irqchip/irq-riscv-aplic-main.h index 78267ec58098..dc022e89bc97 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 086d00e0429e..03a8ac6554c4 100644 --- a/drivers/irqchip/irq-riscv-aplic-msi.c +++ b/drivers/irqchip/irq-riscv-aplic-msi.c @@ -178,6 +178,7 @@ static void aplic_msi_write_msg(struct msi_desc *desc, struct msi_msg *msg) int aplic_msi_setup(struct device *dev, void __iomem *regs) { const struct imsic_global_config *imsic_global; + struct irq_domain *msi_domain; struct irq_domain *irqdomain; struct aplic_priv *priv; struct aplic_msicfg *mc; @@ -261,8 +262,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); + } } /* Create irq domain instance for the APLIC MSI-mode */ From patchwork Tue Dec 19 17:45:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498733 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 61BE9C46CCD for ; Tue, 19 Dec 2023 17:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9jaFq/UfS0iRr4Ae8s4ew5+YwHhERLhk9dZb0uVSWa8=; b=k3n0khsU1l5BNF ctG6pCg3Wuwt61Sd6EbJRZajUPDryBugO9rorqUPXKPgfu2usnxCcepAM+huv/xgvO+48BLL3bjYd pfYUSs1mwxbWMiJf2iclDEj3sUdr8HFLSjvKNEPHOFUJjXorRJEi8hLN/zqAW25QPj+M+6qY+buzN TUU9PO/DBxORQk3tef6YlY0msoju9jrPUjPhzgR/cFKyS/W6KQnA660MNrMPDzZ+0ksjK3ZMxR7vs a+FfW1D2R9d8Bf7abjLHggLaxqK/Ep/X6EluUh/L63aKKrUhhW9YtPW/bX06JnbL5XEimm+Lp0Gd0 vjDEgv7BJtirkerMlg2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeBx-00F25C-2s; Tue, 19 Dec 2023 17:47:41 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeB4-00F1Dz-2W for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:48 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6d8923fe26bso1356183b3a.0 for ; Tue, 19 Dec 2023 09:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008002; x=1703612802; 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=3ZH2VVLJxNHvriakOOoWr5FlZ4jVyb+u72AVTrlwbgg=; b=o6R1+L7T9MeIPNuZj2AYPRISCMjx78uqbn0nuCDz3lEgOj3eD1w13gNn7iKVpcD0H8 bTAaU2yg6HmNvckTyGRVGdAiK1p9CewExLEG0tuDJyayOKKNb3QW42/se/TO8K6gQELr Hq9q+lPloaXKZ1WMV2LO/0QIXhvxy8oNjuUWdh7Htkt9sQfN8CuyFeVi8m+uoRBCpPIU hRJO6KZguPgT+sqmDAszpX//SYrfWTT/Xjosq/wGewWQKqB/tAVhWTwweK1yAXNBrGwA MJg/jfieEcNoLYNK2gUfKXeJxI4VOw1Vq7lRupsK//6vfQFlpHZarwG/Lq4/xcOxd8YC U3xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703008002; x=1703612802; 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=3ZH2VVLJxNHvriakOOoWr5FlZ4jVyb+u72AVTrlwbgg=; b=ANVpt5esQT1GLEbYyg4p/m0iLE6iuOlg+dkdlRm+uaxCiFzzuKqyoTJqlbWj9CTBQP iby1+w0csTGc94X0kkzv7ibT1pvHwVTMs9vG5zP+y1Bv0eEvUAmOI6AMi1plFdw6mYji AneVjD1512LnGTl2HCUKS2sy9xdYIt+v8+7ZjdGjV0bFtj4cctR+NN7hTFRiBAOkFtmx k/AEbkXElyea0+get1GAoVGlUumZggndv53aoF6HvO9VY1ywwVAlR5UMBNOUe8GOiKHm e0ZDxdEL/WVUIVA2pdyDNymzIMcKIgX5jHGtHLnj/rO9le1FDymnxfOg32iNBxXf5sM4 95yw== X-Gm-Message-State: AOJu0YwYBhlEtnGEOWojeEmxSzBOZd/BZNtwuRF3VaL2l6AA8DPzbSv7 HeNIHjM7shRHFqa4TrmmxXft2Y8+8gx5DqUxOA4= X-Google-Smtp-Source: AGHT+IE6uf+usXMxRKVOaon8WyaEOOvOylj5AlLYp7ZK7Lf0piVNkksf6YQ/7YkGTuiL7VIoKgEHhA== X-Received: by 2002:a17:903:11cd:b0:1d3:2e0e:c889 with SMTP id q13-20020a17090311cd00b001d32e0ec889mr8798850plh.62.1703008002608; Tue, 19 Dec 2023 09:46:42 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:42 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 12/17] irqchip: irq-sifive-plic: Add ACPI support Date: Tue, 19 Dec 2023 23:15:21 +0530 Message-Id: <20231219174526.2235150-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094646_868145_5C6DEEAD X-CRM114-Status: GOOD ( 21.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add ACPI support in PLIC driver. In ACPI, IO devices use Global System Interrupts (GSI) which is a flat space split across multiple PLICs. Signed-off-by: Sunil V L Co-developed-by: Haibo Xu Signed-off-by: Haibo Xu --- arch/riscv/include/asm/irq.h | 6 +++ drivers/irqchip/irq-sifive-plic.c | 76 +++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 18 deletions(-) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index df59192a157d..7b14f3ebe242 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -28,6 +28,12 @@ struct fwnode_handle *aplic_get_gsi_domain_id(u32 gsi); static inline struct fwnode_handle *aplic_get_gsi_domain_id(u32 gsi) { return NULL; } #endif +#ifdef CONFIG_SIFIVE_PLIC +struct fwnode_handle *plic_get_gsi_domain_id(u32 gsi); +#else +static inline struct fwnode_handle *plic_get_gsi_domain_id(u32 gsi) { return NULL; } +#endif + 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); diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index c8f8a8cdcce1..d4c355ffa628 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 { @@ -316,6 +319,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); @@ -417,17 +424,31 @@ static const struct of_device_id plic_match[] = { }; 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; + struct acpi_madt_plic *plic; 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)) { + plic = *(struct acpi_madt_plic **)dev_get_platdata(dev); + if (!plic) { + dev_err(dev, "PLIC platform data is NULL!\n"); + return -EINVAL; + } + + *nr_irqs = plic->num_irqs; + acpi_get_plic_nr_contexts(plic->id, nr_contexts); + if (WARN_ON(!*nr_contexts)) { + dev_err(dev, "no PLIC context available\n"); + return -EINVAL; + } + + *gsi_base = plic->gsi_base; + *id = plic->id; + return 0; + } rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,ndev", nr_irqs); @@ -442,23 +463,28 @@ 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_hwirq(struct platform_device *pdev, - u32 context, u32 *parent_hwirq, + u32 context, u32 id, u32 *parent_hwirq, unsigned long *parent_hartid) { struct device *dev = &pdev->dev; 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(id, context, parent_hartid); + if (rc) + return rc; + + *parent_hwirq = RV_IRQ_EXT; + return 0; + } rc = of_irq_parse_one(to_of_node(dev->fwnode), context, &parent); if (rc) @@ -483,7 +509,9 @@ static int plic_probe(struct platform_device *pdev) struct plic_priv *priv; irq_hw_number_t hwirq; struct resource *res; + int id, context_id; bool cpuhp_setup; + u32 gsi_base; if (is_of_node(dev->fwnode)) { const struct of_device_id *id; @@ -510,19 +538,21 @@ static int plic_probe(struct platform_device *pdev) return -EIO; } - rc = plic_parse_nr_irqs_and_contexts(pdev, &nr_irqs, &nr_contexts); + rc = plic_parse_nr_irqs_and_contexts(pdev, &nr_irqs, &nr_contexts, &gsi_base, &id); if (rc) { dev_err(dev, "failed to parse irqs and contexts\n"); return rc; } priv->nr_irqs = nr_irqs; + priv->gsi_base = gsi_base; + priv->id = id; priv->prio_save = devm_bitmap_zalloc(dev, nr_irqs, GFP_KERNEL); if (!priv->prio_save) return -ENOMEM; for (i = 0; i < nr_contexts; i++) { - rc = plic_parse_context_parent_hwirq(pdev, i, + rc = plic_parse_context_parent_hwirq(pdev, i, priv->id, &parent_hwirq, &hartid); if (rc) { dev_warn(dev, "hwirq for context%d not found\n", i); @@ -574,13 +604,23 @@ static int plic_probe(struct platform_device *pdev) goto done; } + if (is_of_node(dev->fwnode)) { + context_id = i; + } else { + rc = acpi_get_plic_context(priv->id, i, &context_id); + if (rc) { + dev_warn(dev, "invalid context id for context%d\n", i); + continue; + } + } + 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, From patchwork Tue Dec 19 17:45:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498919 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 54428C46CA2 for ; Tue, 19 Dec 2023 19:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UANdibbVL0pn4d3IYK5k1H01pnQAwVsngFYc//IKlnY=; b=Uc5i8s4HB0DdCf QWyrDKNU9g0uzp8q/X4Zx+xFf+w6GQjyaaF6tbGhZmwckCWluwbvQVZGZtD7PXvHLQ0Gd59LPxLxZ T4Vtzk1evVBT1r/YLtzUlE+OTgC/6KB134k8wAABpM4AP67ffZ7jZMdgiUUTDXHuIgnb7Nie6L6Dp txDGMFNoX0boKSXdmOUTvGLB7aZR+8BsGop8VqHLmCJTedMRmSYndRaaq7KSe2pQZMfeXuatcR5NC c7q6dCZZ/K+t8BNjYtCY1cNG4M87GDc7H6m+tu0XoN4EsMkyGfOMfXZKsYMwg8CZ9N83bgaPvaoka Kzyc60VSRPHi/P0q5qQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFfLf-00FGt9-1O; Tue, 19 Dec 2023 19:01:47 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeB7-00F1I9-0g for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:51 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d3e6c86868so4418325ad.1 for ; Tue, 19 Dec 2023 09:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008008; x=1703612808; 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=SP5qUoiFDc31MnkvQviOGvw0IT7UG54DgquaP3mAr+M=; b=XgEhIijeIn8bLy8p6Z05sb6YXcunfm2yyhzUnK9w19tDYrO1RsrjGmYML3jorWMYrz JpYmObs0I3hQqz/VgwS11UB7bDhshgRzhKiC4SVXcQ4o6WxnH8lsb5URNxAxk+DakFWh RwwxsTVoODZYr+mFcKoLX6l0BGh1dR9hNVqTVFvYiQKmEtEyzQ9mlckz0CMu/eeoZ7EQ aJClv5xCc+lLqlAw8QSrTLeJjdyjj3mnclJd4fCKrNcLHrQixUXPuXH1JgfiERHJaSj7 Dwu73Crb6wNViuPtXAdCb45dtrD/2Ud7MABaDwfWdutj0W5kr2VLhTKFJFshvPM4pQJf aQ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703008008; x=1703612808; 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=SP5qUoiFDc31MnkvQviOGvw0IT7UG54DgquaP3mAr+M=; b=fkdk2PZec7+PUd5Aji3sNveeW+lcmEmz16dTee+Ol/JcHyFVzDSOWqXNrAg7h9T13w 1pb77k3xPOnGcqk7bNe77yGrcLz08GOE08uhldAR8IpRdEcHdUj7gLRnvxFNFJiB34wU BR2LbZ5zoqeW4P0RCHdhYT5sgpA1oBJa+3GtqvkLOY4BBVrbLOynY2DbjG1gj51m9r5e mk1upaqjhIunBW3zs5G4R1dyR7I/F2YhoeySp62UScNcO1UqomM4zcgXhctUG5Bv7YeX St6o4bxufv/0BLm7BQBw3sY8DTUikOUMKlcVHIbvvdc6N9iIirD0bpySDE6YbfC/9rQJ eLzQ== X-Gm-Message-State: AOJu0Yxyvi/+bnmMpSU/bVpExDZRqW4RjRkcrMFiHdQzPundTbW8sFRX usyoylTWzBs6mruWBlI1Jrwtwzkp6+0juCjOfrg= X-Google-Smtp-Source: AGHT+IEOQXmfDQVD1vBA63SzA+9hg3WHejFnv5r3sp4cTvGZBg1eOJzxTsxyyXCko2PiShNLOVwBww== X-Received: by 2002:a17:902:a3c7:b0:1d3:9d55:3d67 with SMTP id q7-20020a170902a3c700b001d39d553d67mr5367594plb.101.1703008008246; Tue, 19 Dec 2023 09:46:48 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:47 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 13/17] ACPI: bus: Add RINTC IRQ model for RISC-V Date: Tue, 19 Dec 2023 23:15:22 +0530 Message-Id: <20231219174526.2235150-14-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094649_317367_027C2516 X-CRM114-Status: GOOD ( 11.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 a4aa53b7e2bb..9eace6c7042e 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1158,6 +1158,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 ae045e14126b..b6766bded765 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -95,6 +95,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 Tue Dec 19 17:45:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498915 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 439FDC46CCD for ; Tue, 19 Dec 2023 19:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/PeP5vRf7Qygy/aN3gofOiSextR9m8lsw+Tu6AZfYrI=; b=rb2oKw+yomziuq F0Mf3JH5pEfPsPn0S0akbbGnb+nLBpVB/OSbh+QRIVCpRZq6x76CLIHxDP5D/cqWO6esVCo72ehM5 i55q7j7YItKckfPVekj6wvO+peHKwjSPDfhFDDufTHg2KjT4rwdmpVxSIMTO71U9R0TCl2nyqs+9R VSWppYx0Txg7fy5008iv72hHER4gDPGf1bGlXgHeDITdDZqvD4i8Y1tNThibBYdtkn8FhnWa5VHAP La/4MVCK/boe6lbayVvqrgtm7Fq8VIShnb0CTLlqsVdfDzxWSZ3fjT20FkizgV1oyKfyyz1J1ql0P hTDW+F+nMehPShEee5VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFfLg-00FGtf-1a; Tue, 19 Dec 2023 19:01:48 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeBE-00F1Ok-16 for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:46:58 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6d0a679fca7so2688487b3a.2 for ; Tue, 19 Dec 2023 09:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008014; x=1703612814; 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=g0uCfTOZnl72LckIuFeuzwRvzQWn6/C5y85H0bronQc=; b=F7adu5ows4kFbPsmdJdLmpJey0FgPW3wGSdkuw5aVVZHD7St7aXYGVjyPEwtMMxJDC d83mAf86nsaPKKuC8tDeDYWRiVR67JZMNyjA7vCyOgIaZ2Qk+G6K2VuEUl3BW8czGLwk 4jp8Pg+q38VilIfHe470qb6eMQGgZTKsP4To7m8K3ZAamDKyoglwxxINUceDF/M+6vbE tCcMtBFxji/LRS1VNpmnB8Arm/6TDhS5k8NGGtbZ08unUacgiHd2LUrSrREAUp/uFF2o HfpyjbtVMbT16fXdwfNN8sxWPhz/HY7xw6Ih5MJ4WhzcxwJXREt1gP89A/dVuLsX3hFo ReIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703008014; x=1703612814; 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=g0uCfTOZnl72LckIuFeuzwRvzQWn6/C5y85H0bronQc=; b=ltkv6yMDEcA+wQjUIgBYdV2wEBky3AHlXfTPnTk72bH5ilipcFMJ8btToC/9gbqsYy MhDs/SIXjK5iuGeUWoDtaPYhnbYfmJyPIZCLX5saSqloJqvb532EIoHXn3rmLtl7TC6/ Sn+KptvfANKzkptvS3P22uTxKvw1V/utnqDPJa5cjH79eXYCc8RExpiCe0WZOpi+fhMZ NbEebwygG8Y8r0/MeOPGXP9EFiAbvH64ZTMW+MJx+PwVnBcuMEuI6vdotEjIEU3Inp2s xzeOe0ocdKu5EkKb82upBdcvxufT66Xq1P9hw1orSmyGSvcC5lTIL0KontgFTBCQkWMk K/OA== X-Gm-Message-State: AOJu0YzNo4tgi06cuoTxIxCvpGphJcVeG8AU0HRI5pNR41nIwza0i8kq ZlvQDhKgg5fA7eKo1K8hfiWoad+4j2+Io8haakY= X-Google-Smtp-Source: AGHT+IHZcNfZ6die569wXMawkOkuZhvwuWzaoZMFwyoh6VY7ifl9VotSBnjv3TBcYle+Wo3ta+ExQg== X-Received: by 2002:a17:902:e5d2:b0:1d0:7c28:f806 with SMTP id u18-20020a170902e5d200b001d07c28f806mr9507684plf.3.1703008013802; Tue, 19 Dec 2023 09:46:53 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:53 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 14/17] ACPI: bus: Add acpi_riscv_init function Date: Tue, 19 Dec 2023 23:15:23 +0530 Message-Id: <20231219174526.2235150-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094656_442073_88613DA4 X-CRM114-Status: GOOD ( 16.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 9eace6c7042e..f7ac0caf04cf 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1417,6 +1417,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 f80b3da230e9..c4d679b1359e 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y += rhct.o irq.o +obj-y += rhct.o irq.o init.o diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c new file mode 100644 index 000000000000..b5807bbdb171 --- /dev/null +++ b/drivers/acpi/riscv/init.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023, Ventana Micro Systems Inc + * Author: Sunil V L + * + */ + +#include + +void __init acpi_riscv_init(void) +{ +} diff --git a/include/linux/acpi.h b/include/linux/acpi.h index b6766bded765..60dc1f1e9351 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1536,6 +1536,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 Tue Dec 19 17:45:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498914 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 13D27C41535 for ; Tue, 19 Dec 2023 19:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7DjhMXGmihZxDT8u2kn6UR4O0hhv1UFLiI6YGN8hJC8=; b=wOjgtdyEbRGUXr QGHahiOeh3oDiBGSQpebOorj5M80w/TQZ5CEQcfRx7OUEwe7CpA1eWZb2PJ1uWx9DjdqtdaIINqEf hWnsDVDUis1dXpRy3aYBokUWe/od1jhfpSu9KGYjAn9d7yW+wfJlsfp0VukvLbSacd8xY/017HLGe UeQhR3EJqS6x96wabuQQaw/trU/EV3Sv8zSW2tNPTltl2aKM5KM7752d72aX5nHu1wGx34Lw3SPY2 8xzeRQ1BzMDv5c/KoUXc5PDVfIBWBYeVj+txGc9PPXHEef2m1G5IIKsXIr76rbmRroFnBAKHl1v05 zHhCMszQC53K8GnXPEsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFfLh-00FGuJ-0r; Tue, 19 Dec 2023 19:01:49 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeBM-00F1U3-2K for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:47:07 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d045097b4cso20629415ad.0 for ; Tue, 19 Dec 2023 09:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008019; x=1703612819; 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=rMG56uSWd/ufo/nc8FBDk9fzkMf+1BzSryO0Av4W69w=; b=W0LKHmqq7igxUhhkvNt4+RSagZN04e0xVe6S1JBtATSdXAMl1zOvjNzgXnhzMj8xTK T7+hBSP8H610qZizsXugmZObb6rhw1WCcKf16mVVG+1ieOcoWBIwT3gJgF3WzoGa2xFZ VQpoejZGMa+/CIRq740VF2w1frBdw8vipDf1rpkRlnQxAItbCisi1EmkSaOgQzcwIYWW VZQmLago50eVqIZ0qx2gJUtsXpAKZ2QWOHKhFrDBBRgcjlLWMOwvQXkaINRJIc2LKsmn 1Mp7QyOdFMfo6iijivoJMwfE+0gtVqkU62uuKpgf59zDCUc/EznwFIHuxzl8fxbjQQFJ vFPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703008019; x=1703612819; 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=rMG56uSWd/ufo/nc8FBDk9fzkMf+1BzSryO0Av4W69w=; b=HxxRvoRCisJeu7w+ojdoQCDDhQ92drUJevSWn1AAwVL/qWAaFLpXACpEDb2Dj8cec4 nXqwUsJy7WfFYhQQ7uqBfvny3OUCrhuwc6S2KaaaA+bqouFDuyb6xi+i+81fc7ObJYRM dUXeRR1cD+GDOaxgmSGRsWOJXutlVboLzadw7G/cpQ2VmIEiflKhHh21fg4YCvXcOCcU 7/UhJtc8V8SasWWUMohlX5Ze737M10II6PYE7m+qi2Z+jAEsYvcqMOvvw9GCnsivg7U2 D+QJF55ltdW1yDw5xfeIB7V0uUyDMqL8bbtkUG+3VkZBkS9yNhnGwCJe77phlQsPlBag Ts+g== X-Gm-Message-State: AOJu0YxA/vvK4Q05w7ccy44s7/TcxLRFIBIYTGbw6jifkx2ckxfqprnH B6WTF4jptaSI4cKzD1k8pxykcMq4RGxLnAWauis= X-Google-Smtp-Source: AGHT+IHXM72nArT21GjLZtiiN3K06SzkiamqR5ZRviUGxMyVpE460cqqru+VtpRXXtaDP8/IywYfuQ== X-Received: by 2002:a17:902:eb8a:b0:1d3:da07:5731 with SMTP id q10-20020a170902eb8a00b001d3da075731mr1397869plg.22.1703008019566; Tue, 19 Dec 2023 09:46:59 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:46:59 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 15/17] ACPI: RISC-V: Create APLIC platform device Date: Tue, 19 Dec 2023 23:15:24 +0530 Message-Id: <20231219174526.2235150-16-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094704_827172_7AB87E0D X-CRM114-Status: GOOD ( 19.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since APLIC needs to be a platform device, probe the MADT and create platform devices for each APLIC in the system. Signed-off-by: Sunil V L --- drivers/acpi/riscv/init.c | 2 + drivers/acpi/riscv/init.h | 5 ++ drivers/acpi/riscv/irq.c | 118 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 drivers/acpi/riscv/init.h diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c index b5807bbdb171..e7eff7ab1474 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_aplic_platform_init(); } diff --git a/drivers/acpi/riscv/init.h b/drivers/acpi/riscv/init.h new file mode 100644 index 000000000000..17bcf0baaadb --- /dev/null +++ b/drivers/acpi/riscv/init.h @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include + +void __init riscv_acpi_imsic_platform_init(void); +void __init riscv_acpi_aplic_platform_init(void); diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 36e0525b3235..d08a851ab6dc 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -6,7 +6,36 @@ */ #include +#include +#include +#include #include +#include "init.h" + +static LIST_HEAD(ext_intc_list); + +struct ext_intc_fwnode_list { + struct fwnode_handle *fwnode; + u32 gsi_base; + u32 nr_irqs; + struct list_head list; +}; + +struct fwnode_handle *ext_entc_get_gsi_domain_id(u32 gsi) +{ + struct ext_intc_fwnode_list *ext_intc_element; + struct list_head *i, *tmp; + + /* Find the External Interrupt controller that manages this GSI. */ + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element = list_entry(i, struct ext_intc_fwnode_list, list); + if (gsi >= ext_intc_element->gsi_base && + gsi < (ext_intc_element->gsi_base + ext_intc_element->nr_irqs)) + return ext_intc_element->fwnode; + } + + return NULL; +} static int irqchip_cmp_func(const void *in0, const void *in1) { @@ -30,3 +59,92 @@ void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) return; sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); } + +static int __init irqchip_add_platform_device(char *irqchip_name, u32 irqchip_id, + resource_size_t iomem_res_start, + resource_size_t iomem_res_size, + u32 gsi_base, + u32 nr_irqs, + union acpi_subtable_headers *header) +{ + struct ext_intc_fwnode_list *ext_intc_element; + struct platform_device *pdev; + struct fwnode_handle *fn; + struct resource *res; + int ret; + + fn = irq_domain_alloc_named_id_fwnode(irqchip_name, irqchip_id); + if (!fn) + return -ENOMEM; + + pdev = platform_device_alloc(irqchip_name, irqchip_id); + if (!pdev) { + irq_domain_free_fwnode(fn); + return -ENOMEM; + } + + res = kcalloc(1, sizeof(*res), GFP_KERNEL); + if (!res) { + irq_domain_free_fwnode(fn); + platform_device_put(pdev); + return -ENOMEM; + } + + ext_intc_element = kcalloc(1, sizeof(*ext_intc_element), GFP_KERNEL); + if (!ext_intc_element) + return -ENOMEM; + + ext_intc_element->fwnode = fn; + ext_intc_element->gsi_base = gsi_base; + ext_intc_element->nr_irqs = nr_irqs; + list_add_tail(&ext_intc_element->list, &ext_intc_list); + + res->start = iomem_res_start; + res->end = res->start + iomem_res_size - 1; + res->flags = IORESOURCE_MEM; + ret = platform_device_add_resources(pdev, res, 1); + /* + * Resources are duplicated in platform_device_add_resources, + * free their allocated memory + */ + kfree(res); + + /* + * Add copy of aplic pointer so that platform driver get aplic details. + */ + ret = platform_device_add_data(pdev, &header, sizeof(header)); + if (ret) { + irq_domain_free_fwnode(fn); + platform_device_put(pdev); + return ret; + } + + pdev->dev.fwnode = fn; + ret = platform_device_add(pdev); + if (ret) { + irq_domain_free_fwnode(fn); + platform_device_put(pdev); + return ret; + } + + return 0; +} + +static int __init aplic_parse_madt(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_madt_aplic *aplic = (struct acpi_madt_aplic *)header; + + return irqchip_add_platform_device("riscv-aplic", + aplic->id, + aplic->base_addr, + aplic->size, + aplic->gsi_base, + aplic->num_sources, + header); +} + +void __init riscv_acpi_aplic_platform_init(void) +{ + acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, aplic_parse_madt, 0); +} From patchwork Tue Dec 19 17:45:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498917 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 4486FC46CCD for ; Tue, 19 Dec 2023 19:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i4DISYeJpMvV5YQKRVi61KwxcXaFNwSzHMEEKJNAJSc=; b=wBxCvzxoWedCA+ cIESpBn0Hq3+gqoztzcP8mJqoosrNwWMpeiB+m3I1mvadwqdGIWAydHQmt+N1upSFCRZIgGsJD9nl Ww9/CBJnBijd4OD1tcHD3YhMq0G9RW97DwewDb/FxwpKzC0zN+3rY3+yPdM0RQKxQmUpyWLj3+ms0 1Kmtwxawz80n2ixMN463s2BNzYK1tvhi+VhhTiXhcMHwcqSZgFugCnNGettaVSj+y9471XgxPlECn a1lmsnQitxEtycXSJn7JRLugtRcX0Wkr6IdGiK2bLoWGrOeoz93B1UhO0SsFmFuxCBegNr2k4sYmq P9ZHCZUj6OsUcfBa9HiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFfLh-00FGub-2a; Tue, 19 Dec 2023 19:01:49 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeBO-00F1aR-1y for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:47:08 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d3aa0321b5so25339065ad.2 for ; Tue, 19 Dec 2023 09:47:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008025; x=1703612825; 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=XaVzwwT2ecLOtMDBM5TdFJiJ9XdFZ6MUpboDwIj/4ug=; b=jaHIrw3CtURZfDLL5CdOrgdl4XiCxao8ndPVGp1RhjL9upeIAOzFU99HIdiqJPK0pX z3JJ+5hsg4z3/iLjjsml+JBx8GvZLXiByALaEdwPXVzIqFmd9PeQ5uKdqdACQEaGuTK/ CtPAmZWVhfm7FeHYcUjkb8qpgHYmnqt1/WFZDELFwnkU3aplVbTAQ83ozCdTP0cCwmUY e9Zb7MSyG5jhQfo5+5kuuoZRefqurKFeM8UCQR67821Ey2il/jWg4UK8MT+/dTLA+1Uk KuNnOBKWIfSnPbl3mGgb6o0kA1ZqixpZIIxJgp5odoshHhbg10EkSR6IrIh3WdoURGhr +rRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703008025; x=1703612825; 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=XaVzwwT2ecLOtMDBM5TdFJiJ9XdFZ6MUpboDwIj/4ug=; b=LPeMlzxR2llOVhthSsZjCrODx37kbBkfYjN71F//+7t4lsUXsm5P2viyCx9sMJ2GLW zmkedGTGcUO1R4SfFHZUzZAEywMlz9HqBzexeKyfE3unB41jZ+Fm/dwrGXCrrHBUrdwg I9geg5R23E4glNRTIqbrsH4evL6kAQCnIsOLwvW8UzLOaJVeg3hb7PL6BKThncLnc80L d7z6jgxzt7yVQjKZZaiI9sIpHhrvj5/4gbMYCI22OtJmOOm/U4DG3+w4bEc1mGxNzUWK 7hN6/9w/N4WCgU8cJafJpmSGxmX8rtXKxj0ehvkQ8RlMAfJ+IQH5v0gF9YUdonsMn+pB EA8w== X-Gm-Message-State: AOJu0YxRONqV8fesLj/cbB0ti5pS8IaW4DO+QRs81WHxc6IFlDF2Yc0m Txpev05F/YoAlrKVrf4atIzHK5rlZdIJa/uxDj4= X-Google-Smtp-Source: AGHT+IG5x81QIwdA146e8SSr+Pdh859h/oT2VMGTgxkFKS+ftvwwQnsNNroKYOvMgeiD+AUyeRhwsQ== X-Received: by 2002:a17:903:2347:b0:1d3:c730:f0a2 with SMTP id c7-20020a170903234700b001d3c730f0a2mr3728002plh.118.1703008025154; Tue, 19 Dec 2023 09:47:05 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:47:04 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 16/17] ACPI: RISC-V: Create PLIC platform device Date: Tue, 19 Dec 2023 23:15:25 +0530 Message-Id: <20231219174526.2235150-17-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094706_667746_8AC69409 X-CRM114-Status: GOOD ( 10.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since PLIC needs to be a platform device, probe the MADT and create platform devices for each PLIC in the system. Signed-off-by: Sunil V L --- drivers/acpi/riscv/init.c | 1 + drivers/acpi/riscv/init.h | 1 + drivers/acpi/riscv/irq.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c index e7eff7ab1474..c6fd4097e8ae 100644 --- a/drivers/acpi/riscv/init.c +++ b/drivers/acpi/riscv/init.c @@ -11,4 +11,5 @@ void __init acpi_riscv_init(void) { riscv_acpi_aplic_platform_init(); + riscv_acpi_plic_platform_init(); } diff --git a/drivers/acpi/riscv/init.h b/drivers/acpi/riscv/init.h index 17bcf0baaadb..b4b305d83b3a 100644 --- a/drivers/acpi/riscv/init.h +++ b/drivers/acpi/riscv/init.h @@ -3,3 +3,4 @@ void __init riscv_acpi_imsic_platform_init(void); void __init riscv_acpi_aplic_platform_init(void); +void __init riscv_acpi_plic_platform_init(void); diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index d08a851ab6dc..f14ea43b0178 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -148,3 +148,22 @@ void __init riscv_acpi_aplic_platform_init(void) { acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, aplic_parse_madt, 0); } + +static int __init plic_parse_madt(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_madt_plic *plic = (struct acpi_madt_plic *)header; + + return irqchip_add_platform_device("riscv-plic", + plic->id, + plic->base_addr, + plic->size, + plic->gsi_base, + plic->num_irqs, + header); +} + +void __init riscv_acpi_plic_platform_init(void) +{ + acpi_table_parse_madt(ACPI_MADT_TYPE_PLIC, plic_parse_madt, 0); +} From patchwork Tue Dec 19 17:45:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13498789 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 62B03C41535 for ; Tue, 19 Dec 2023 17:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cc0APUoPYW27UrvfQ3XTOtaDuygqTilvOkF6VCQeytk=; b=JiKaFekjpDJzKw KZzSS493rCNLLh0/wGmqUM+17za3J+jHCT+TYKIzRqR8LQpQmRWCwaXrl3yviv+8iUSmh/5k42YJT hcVl3Gb27X2MfS72Qdb1f4wh8E/c9uG5mlsPe8ofb++VwGMiCp4mWCbu/zPLK6qceSoenYJGKrbgV +N8J0F1wtE0Gt3t9+Up8fK/bjE0S+XD3oaBQmud53KcDekcBJZu28z/ZIKsd87L+bGyjA6GNG65QQ B66cHKcQVTOrQ7E1flnV+e9Qr7EEhEIO8mJ/KerkPHz95v9j7dZk77ZGpu6R96+RlGYVrapaHUZnw 5Y4ynUIrc3vRxU++JvlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFeCq-00F2qJ-3A; Tue, 19 Dec 2023 17:48:36 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFeBU-00F1fv-0H for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 17:47:15 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d3ac28ae81so24267105ad.0 for ; Tue, 19 Dec 2023 09:47:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008031; x=1703612831; 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=eiwIpb7xuTq5TPRrwpmxnXk+wGzqHEHNo03fDZVsc7I=; b=Jrk8rZnsncI6n9qbUvCpgsCExNWnTLYD7ozdFJtQPk+zCWi4ftBED5nNnJypY4Wkts 0Icu4giPHuIL2sde3A3SftNJ+vBfT3bVtM+bnHv0+gdFEvejbkebZOhKaKuHYQxTgr2P M5XXJ/3Eh/emwZCiufKuJTmoU9FeYzW1xV9W0UeQGh5tXsebV+fvGcG7O/j+0qGymAYm jyqQYBuhkEyHE+26o35j3Gly2RreSAOwT0yZEi1dJ4N002vj1YLM/Di4rCJUCoH9Qrf8 NLdwUB36mUaRBuRF8fbgycwoEI9EYnUle/CgDNlg/rg6kM+Urgy7yUh65BhgHVLX+h7n j+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703008031; x=1703612831; 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=eiwIpb7xuTq5TPRrwpmxnXk+wGzqHEHNo03fDZVsc7I=; b=QtKEXuyjSHcipnd5YRjYTsGwu2y2AtxpEGEdzMbZpiyFdFkMFWISDDCIz6J97xzZz7 vxqVP+Cuer9gLiuGviGPXW+8HLrVPqe6eOoAPOwdu4lrEsMSun3cw4/89eTQNg7nZFfH t5QZxE9CIN7AHzkvkkukG/1+LIsKh8JnzuWQ8xtTE7+rooRcD60STXLoS21NatAxypv7 zLFFl2Tihi1U2LROXFqVMPSO6h70HxRwrwhliNlqJE+UGDSKjqkCzHP7LYzyt9Xo8HZN MZEMl3+XPc6O1TAqDfwGay/MUzdbXoHDo0XSrkpG+PdKm0mr65PCJRFyNH7LvBVjvn/O 1+cQ== X-Gm-Message-State: AOJu0YzTN5qyfUjqCYSNgE+hvGjx59YuoytmpMeoRxusq6dgcArjf/Bu 8xvyMIw0ZYfuXxuoy4okhAaQ/I34p30+yj7uSfM= X-Google-Smtp-Source: AGHT+IEpUAW94l/bQ8GlpoYTs7IixfBFrUs4h8FHwGSRGLIfpQTk5UlG5GMDzC6dri1oqSEP3DUUjQ== X-Received: by 2002:a17:902:ec85:b0:1d3:ab39:abe2 with SMTP id x5-20020a170902ec8500b001d3ab39abe2mr5002223plg.14.1703008030730; Tue, 19 Dec 2023 09:47:10 -0800 (PST) Received: from sunil-pc.Dlink ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id n16-20020a170903111000b001d3320f6143sm14453015plh.269.2023.12.19.09.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:47:10 -0800 (PST) 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 Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Anup Patel , Thomas Gleixner , Bjorn Helgaas , Haibo Xu , Conor Dooley , Andrew Jones , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Marc Zyngier , Sunil V L Subject: [RFC PATCH v3 17/17] irqchip: riscv-intc: Set ACPI irqmodel Date: Tue, 19 Dec 2023 23:15:26 +0530 Message-Id: <20231219174526.2235150-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219174526.2235150-1-sunilvl@ventanamicro.com> References: <20231219174526.2235150-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094712_284737_66755E87 X-CRM114-Status: GOOD ( 12.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org INTC being the root interrupt controller, set the ACPI irqmodel with callback function to get the GSI domain id. Signed-off-by: Sunil V L --- arch/riscv/include/asm/irq.h | 13 +------------ drivers/irqchip/irq-riscv-intc.c | 1 + 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 7b14f3ebe242..9c2bdf4bd880 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -22,18 +22,7 @@ #define APLIC_PLIC_ID(x) ((x) >> 24) #define IDC_CONTEXT_ID(x) ((x) & 0x0000ffff) -#ifdef CONFIG_RISCV_APLIC -struct fwnode_handle *aplic_get_gsi_domain_id(u32 gsi); -#else -static inline struct fwnode_handle *aplic_get_gsi_domain_id(u32 gsi) { return NULL; } -#endif - -#ifdef CONFIG_SIFIVE_PLIC -struct fwnode_handle *plic_get_gsi_domain_id(u32 gsi); -#else -static inline struct fwnode_handle *plic_get_gsi_domain_id(u32 gsi) { return NULL; } -#endif - +struct fwnode_handle *ext_entc_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); diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 24bbc5bfc30f..bddfe47df27b 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -311,6 +311,7 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, return rc; } + acpi_set_irq_model(ACPI_IRQ_MODEL_RINTC, ext_entc_get_gsi_domain_id); return 0; }