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: 181152 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2109141dyi; Tue, 19 Dec 2023 09:47:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlVzKT5iiyaE97deSP5fiVC2LXuZ14qVhXxBMH3waedAng9dYGk1c0RtU8gM75gwulYH4h X-Received: by 2002:a17:906:103:b0:a1f:7065:1efc with SMTP id 3-20020a170906010300b00a1f70651efcmr1646256eje.5.1703008021050; Tue, 19 Dec 2023 09:47:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008021; cv=none; d=google.com; s=arc-20160816; b=x9OA+fuHboBom7Qr/GrrV1yf+wLB+flB4JFwM9dv0VJENzfQRbahaQPABWJ9hbfEK4 /Yf0eItqBorQFCJ4X+hYddCn/vkyuLrhvCxciAmDvDy8AeYC68xnhfwTxaOWoATy7wAq M0u4nyGc2ZMnBo6Ctsz6wkPJlDeO6H7e8MPQuvWK+w0/7xX4r1Bd4itjPMnWw0PRWV6f 7VVogM7UNDnqFD96C90Z/oCd+VaYqDMzoSMvt8x2yMPj0HVLUdPG6dBLevhjIqCZ16ZJ cdRBAhA2W+fEo4uqW2Egfo44BAA3pA4zfWvDf5OLkb/giV3azSBQG9QNcm+0XY7MsScG +2LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=sTCmyL8q1x2NekUk0mD7VzWJPBPZf/tU9IYpoiSJ7Kg=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=ef9Y4MdXvL3iLSwVxcgNyQjbP7A3gfFJTI0hD5Vd/QLq/h9JS+6+dKFXLNPGhATbcJ yKdXLaNeMrX2svxwX672LMNYuUs+Bius1XDW5wAK28XnSOl3Duqyzvn4uYo7Vbf58pIR J1EThG/BX+MxBCfiooycZINQLyWv7fR+tCw76rNKkTgmN6jhryHUfmf2UzSNuvGClAR4 jT6f46iKdtmWEZpQo7wboGrv8blX9/0a/fP77+xE4K7vYiQpylP2L2f5Yla54wWpoQ/D IgRNK7X6HyZak6jrPTThDeCc1cQGOa5yaLJwx6NxDzfdvnUJk4lfgpCIl5S0BbAZsU/0 Xl4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=h4nQxSg7; spf=pass (google.com: domain of linux-kernel+bounces-5713-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5713-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m9-20020a170906234900b00a233766b7c2si2586526eja.925.2023.12.19.09.47.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:47:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5713-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=h4nQxSg7; spf=pass (google.com: domain of linux-kernel+bounces-5713-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5713-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 810941F25DA9 for ; Tue, 19 Dec 2023 17:46:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1515D37D1D; Tue, 19 Dec 2023 17:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="h4nQxSg7" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D42CD37883 for ; Tue, 19 Dec 2023 17:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6d66a0d10dcso1647606b3a.0 for ; Tue, 19 Dec 2023 09:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007941; x=1703612741; darn=vger.kernel.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=h4nQxSg7gnMMOiJFn/C/dZXUV0d2eQHSj7ghMsXkHR7XubRmJsxAJXk+sRYeB+icY2 vfvtCG4BMPk9F8OGsyABCfE/T/7HZzOddm7uv9fF7NgcEVIi1Z5z3qGxOzZoO1+qcD4J 6D6mJnd1nw2sceKa1eRO/1sCqVKEqKU1U2yckMSahGed7np7iohLuxUZBY1Owc5JF2M9 Ua6Q7UZd6mPQSx6+WyUJJxdZp5GpvPW2VGvcBLA1j4tIYlov+e3Q4WY0DPPTtc3W+1NS K29X/kxUXw+HpnQaBOZiH4GtSk5Xq64YQB4oFuF0D0NSbbhBJSbObctxVidiWDebKkJy PliQ== 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=RN1n4FZVFLReEpJEinpi0Grs1LVfF65siE4yWj2HJmXJIKBeDc13tsH/LvkSc3rCY9 +1P0Gr/hpnztpZj0xGk4maThykPqtII1s5UAtj5a6eNnUAUnO8g9iCPnp5gxmNPLT6JZ QxaMGC/Ax/lbsBWaFlK9RnskeOhYt5GxAMu74x/yNiVG6d8bo6DeGDSMEKdpRQMcUrvC yolVyLtHj01Vn4U4JaPeYM1gqyOtxWEG7Nk3xxja/on+mZYrOy9VSd6lT4+eErDeaVqL 1JKLYabLn+G+0TESElq6RlX7DKYx0Y3IjDe5iZZkscJSxV5mlJI0ntrTBlAx9G3BSIxp ImqA== X-Gm-Message-State: AOJu0YyconxlWPm3nzkaM0K+7mZfhZjkmi7H2XF/c5S+iquyt+RSpZ8b 5w3NyC7cJIkLVTrlSnf95+fMdA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733339017967666 X-GMAIL-MSGID: 1785733339017967666 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: 181153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2109240dyi; Tue, 19 Dec 2023 09:47:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6GPawsspyvH3vjoHLDdfFD4w7VFgNQSMdvPq2hEYHVv2deB5BDC9PFoGYqPrS5tXNtaoL X-Received: by 2002:a50:96c4:0:b0:552:8a69:8100 with SMTP id z4-20020a5096c4000000b005528a698100mr5482292eda.77.1703008032576; Tue, 19 Dec 2023 09:47:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008032; cv=none; d=google.com; s=arc-20160816; b=U9qCj6sxUwCCKH1YFUUekFpu2XKrKqAii79wRSPvpCaoywCWLPqco89ssSSveMz8+6 RkJ/tmR6682g26zD0PjGPOIyV1bc/d0eqQ35Zu/Tz4iCxaTsd7FhY5lzoQDpFm2487Lx FzSXHbBJTtONNj1dEnVI43Bv+dLN3Uzq29kjTiWEcyyWec1m3X5B27cjn134ssqehmwo WfNh2tL/aWUHcMqBM8SjqcbjZmA4XW1zxW9bzsFqLFQ2bRD8nhNWT5jwRvI954vqXR83 dL/gHFVxJ4zVkiOFPkQAFr9KimnLzW8/sivrZZDpmnWgbzD9jIZbSm/TcyiGuWAxXUcg JpRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X2my/S8LtCsC0GLqIKOd4U0OgSfb/RvK23itt/cKu94=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=rJAjiFwItkVHVUM7amH1oZya4W7oNnMQDWM8KAuIGTiuqW4eseMZrNzgZFHMsyzbAO nwUeeYYSMfSLwoM7AVpdWWoHTSVXD6h8D0WpWc2gZhO/LQ9+orNw+sTTxrAE4W/vJhHq YcuF03JWCi9etgf38bMDl4quHTMO06hZF/ofslhqxrmfW2mBY50O5aBl9HKl9Z5V9WBI LaETlUZjeSpxNKcqHtJrfLu+L44HHItZEa/hqUWo0rWh5+FtDyt73BlqlZ0FAvP4BiJI aKTiC8Ef8XX8HPOhApsNV61SI7h9qOzGL1WUD7KDj5gseurBpO7gBHSKIDIMaXFz6J8k 3oKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=guIa3of5; spf=pass (google.com: domain of linux-kernel+bounces-5714-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5714-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n21-20020a509355000000b0054cd052378dsi11040932eda.320.2023.12.19.09.47.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:47:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5714-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=guIa3of5; spf=pass (google.com: domain of linux-kernel+bounces-5714-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5714-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 381C91F22E17 for ; Tue, 19 Dec 2023 17:46:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA755381AD; Tue, 19 Dec 2023 17:45:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="guIa3of5" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 567F637D1E for ; Tue, 19 Dec 2023 17:45:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1d3dc30ae01so7886925ad.0 for ; Tue, 19 Dec 2023 09:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007947; x=1703612747; darn=vger.kernel.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=guIa3of5y0E0QnLpFeQUUhNT7PQOs7KpjPkOkJFZKw32+thRMo7Jmd20mYjxsBf1L1 9goc1/0whT/LW2unmi7St2c5fk1+/oTjR1dY17fWmxeKMCXK9wG6brulOJWIZbRPCZ1s BdnDRLdchL3eXHpKm30BM8HX1C2BaxXj+5abyJiptidu9zSSSXdOm1XOg2FDm6e3pkJ3 uQehfcw5GqtpgKMMOkGdgAuISuj54sGCJnCz1Bt68sdYS3Xe/jZ07FRgX1gh5UrO0nDl QQL/luI+bcXQC5f5g0OAEWhUD7nKRBWQQRt/y0ki+za7obgb4+DBU2u8Pi1oaH6tUKyK jvcg== 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=HreRFfmAL9z5NQQYaDAkKPI4RdFyRqL5IelZLRFS8AXJgmVzXDNlMO+geRtTZxuPEj RFiofdN5qxHC5ILqB6E6w24UT8Uy21qn++w3VG71I0n639SjgXQyYV+casnLZUGn/wnM vpmn/UfKYTquCwz8nN1Sk0tE9mpRevor44AeHhgvfh1RpDgiSVt3mj6KZmR2Xs/fFaPs sco4TZugZhXyurQyIqycvG2yb5cPUFG2Fa/oiPjRBfNWrs0m2WeYGGvG33z7LO/mVgUa bsipbfmfjST3kGLi23pFTIzSnGMZJiO3xBQrxYq4IK7I41j9Ia5yc8o9mbI2s9Nmegz9 w5WA== X-Gm-Message-State: AOJu0YwfsZCB6V4AfTj2ETV6hN2buaLEfkqLyVTXcv97+95UcVdwcvQM NBFb5HuIPpwoeK6X4vEImG+qrk+7f8o/YZVmXEg= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733350959225617 X-GMAIL-MSGID: 1785733350959225617 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: 181156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2109944dyi; Tue, 19 Dec 2023 09:48:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDOTFjhBpjeNVV4pkMiwRyCNmBVDIvdIVQGLVdq7hgxm80xAXj9YwcJSIOUL9hLj5G2QNk X-Received: by 2002:a17:902:eb91:b0:1d3:c3f0:463a with SMTP id q17-20020a170902eb9100b001d3c3f0463amr3758958plg.137.1703008104732; Tue, 19 Dec 2023 09:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008104; cv=none; d=google.com; s=arc-20160816; b=hhLhEhQiNIJw083WXVa6xdKctb2fNkwTo9Ae55MH/kZ0yVJzKMUXidWt7BkYuOAKeI YZqV40ZbETVRMZmw6IlL2sAE04R+1Ra6FuSvIujx6oT86PmibgWV/Ywr6U1RZuEJ8wAH bmIOE+rDYQIkaeIyZEVQZJgYge/9tgEy/djVUYZGBqSUVgnkR0ivOm/aKqgnJTEKokga 9sHI8J37kbCwtteD0xk3f+fdsovu3niLL2lzJkYHVm0W0JWvDhGlYcn0fsZgH05m/fmw KJUwEP5eBz6frpWiZYVmkQXgvyisIRa8Q3smgQu0vhMa+GXcnuyZcYVSETgHtjWKSuoQ xIXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BmjC4RdyrxsTphcSUlyn0FA/9YESGtMGM8wLh/XfFs8=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=sWgtK8BSncWwOggsocM2YF6BwC58pQH25ku5OGEdcsKg/bY6uDO8BKfPLf8XtH61HP UQOTKxYERuR30+1F2Z4pWe0FIUY7O95IcO3kkxXrRZBS2J+7s/0+65uMXmgrgsuGw5Tt aOfSpZoJAk4wHF2h/SwJPOFfAvs75bejUFEkFxWq2dR58vYFoBkk9fa2xIt5UOqBSbgn YxaaM2vfd6I4QR/938+SQP48zgcYif9gHYHKEvv9MfedecIkisSY7GnWkYY1R87+EGaT fTZrgkDfrSsOJru6azGlx300atOlpeCdDQykHcyxfsAy6HJyJPIIf9/x1WV6d22UceEE BXPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=VYk5jQLL; spf=pass (google.com: domain of linux-kernel+bounces-5715-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5715-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a5-20020a62d405000000b006d944e5fb34si12047pfh.265.2023.12.19.09.48.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:48:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5715-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=VYk5jQLL; spf=pass (google.com: domain of linux-kernel+bounces-5715-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5715-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4547DB234BE for ; Tue, 19 Dec 2023 17:47:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B548C38DF9; Tue, 19 Dec 2023 17:45:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="VYk5jQLL" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD9ED381CA for ; Tue, 19 Dec 2023 17:45:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d3d0faf262so14927965ad.3 for ; Tue, 19 Dec 2023 09:45:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007952; x=1703612752; darn=vger.kernel.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=VYk5jQLLM4AbCuQyveyo78khOaNC9MRdSg+6Dx5b9GxOcudFQ7e7UJJJaklvbLhJnY bY3e0algfYGfVnuOZzN6+rEPV3BJ2dMv4ITFO/bMo259fRd4gvzv2evbiomE3p+VL0mi qkS5wrT0bn44s7/FLO5cQ3NkS43mVdlsW5aO62DAyjN/tI/bnl0uBiSiGjC19PR4cHyS QPQYwzYHxESdkXgQb4APPQ1zW/RFmjylwuF4IAwghlOoYX9MSFCxnjhNAp0UMo6ICWe/ vqzJZBAh6R5RGgQA7HW5CG9B5IS8SM6UjtYz6NyMcIzTUpxdcgmPKkr06SiKeM/OKO9m wG+w== 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=kVgWFgVZt5rz0oPSqvxlvy8rpzWNFgp+cqgAd2TWdAv81Tq5GF/gT6VtEmKlphPORI 7Vcb3AbDjxUrBYMDj8R/HMsEM3CBWzUL05aXAFjqTegvvMYJvLg6fE5E/P728wpGcacy gVhtlxtL8IzJjKLoMbJZIvD3et0xo8gVbKRuFpgSU971eG/b4Zv5UdcirvIaKmO8Tod9 VedjShpsAi/ypT/WF7zgP1DJT4y4CJ4lW+Tvvc8yd2OK/q+1XWAAV23l80heSyMVL1Is asc/F+4H1u577JTOqu60rNOYi+6TAsOzjNRtFGHKdrT0kKXAKWuKPBQNJx2/WcU57n/c sZyg== X-Gm-Message-State: AOJu0YyrRi1F5FnwCqsV7QJzbM2NsWJ369TtxTnpazsDO4vJaQUF/vYT 4iNttgRmmSFHC9rv6oHevt7SuA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733426196751862 X-GMAIL-MSGID: 1785733426196751862 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: 181158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2110181dyi; Tue, 19 Dec 2023 09:48:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdBy0Dzy6a6zKosa2DnCdaG/YIQJkCQZDd/Iw47OKILMGf2WHEhg7s413qsS07TMuJgMhA X-Received: by 2002:a05:6a00:805:b0:6d8:8506:9bff with SMTP id m5-20020a056a00080500b006d885069bffmr2687041pfk.50.1703008132831; Tue, 19 Dec 2023 09:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008132; cv=none; d=google.com; s=arc-20160816; b=mk+hAeYu0cAffRq/17xF1JBdxhUauV0M/jpQR7FdbGJdGzSJVeTLzqfhb4R47aqBMK OPRmNfExaHQ806+wj8rQg4HuZ/z37Qjkp8DIU8HxZoq76boxCIHRADMGK3D6er+Naj/7 iOqhxbT4SE3JABjadPNKl9dtT9T29AAMVbMLEqIUK65bBbPE+xq9CxqIGaF7BYYQtXQn PyO5kS/8s6dZPdrq+flo+NhBbMKjr9/jHIslVfM76yS6b0+4LiI4es4BIUSirzjFP+Xd Ba+aY10lsRGQFL2cdW2abRKHMHOfFgRhs8OrAhGr+2nanfn1sSWN/3J4KOJH+YQx7O2n DXnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EebfT5RsMliPiqXCl62hkrmh6d2gQOm2GsmEL35aFBc=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=0RIAUs8HTGNnAWqZ7PiMQPuwTan/lSBjxU69Rt3WcV9GaPT464yJnicO4QaliNPSgt k9oGomRyXxhgg3il7VIavAYAI2nKdhrp3EeXMU5FR5Vnj6Jwy31KDmeqecybIetc68jy IAF+vUWGhnihyJiLDwhDcx42DnKaM/l5S/PYIB6/KJdjp81Iqp76sxXrrc6Dsd7rvc8F 9AdZafzyHjHHybp5r/ngreuBRgzTjPlkXI2l7qjT28EPOH3mJU883zCpH4Oce68EsjdP Ny68jCZy64fqtNNu2/82/SKiCQAD5mq4/QpjlNFKo5C2ai6uNoG2CGsSuCaeeJqpgpua aEIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GpR0JG7y; spf=pass (google.com: domain of linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c31-20020a630d1f000000b00577475ee5f6si19494333pgl.618.2023.12.19.09.48.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:48:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GpR0JG7y; spf=pass (google.com: domain of linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5716-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6BBC8B2473E for ; Tue, 19 Dec 2023 17:47:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67F3D39852; Tue, 19 Dec 2023 17:46:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="GpR0JG7y" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7176A38F80 for ; Tue, 19 Dec 2023 17:45:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d3e416f303so4778605ad.0 for ; Tue, 19 Dec 2023 09:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007958; x=1703612758; darn=vger.kernel.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=GpR0JG7y32IcVQUyyiIWXRSCTAlrdXdwpA9H5PjWS3ZEympZMiooxVdQ9QYeygpkb7 tobK/aLnf93JfNEAQ/lvhv4PI5+RyOL2XM/IBBCqoeTFK09FMY/9EUg19LVtYHkcWXx6 9zlTCDmuF/SLTaZr/9oYB9ynAeGrRGiI1ByAkIgqtoWwGd8HHhboOU1IjnXZnfOGG7Q3 30KUQ0QVK8SOcsNZzrs8HYNkW8hgcOXV1Vb+K+baNfYMUwWTKgTesubJ1IUTl5p9ehjI tMPXtSm/I/N2SjwnC2LXIt7j3nVZdsylSTGGSTAvhVr/Mdi+KofY3mND4Iz+znYlYXOz pRSw== 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=dNGWBODsUEvlkuZ3NGd3yRdera2hw7kM6xk2fs7uwbPZgOowq+TJf08KZuipI8vV0B Bvx93FOkIYbWhwEaLFoUQbvjCqRuheHUpPimLxYXkqOKeRx1JvyFiqqC1iALCZMOBySH VZs75dX3CjqMRA7KNosqOpLWKR/YpoW28V96nJUVLkUwBgPfrt+Cciy0OB6JJo76NUM6 +X2h6EVWk3fydbcK0a6L/CKgbOqq138xoBYAXaYLSRTJg9BETbgL5VnP2nkuy1fOR9KS og/uDadqaevZAbIXxcaApQvwqlXdElqXi4nzBYvYjBnMggtEjSQruoLtM8iFpxG80Ryq LTwg== X-Gm-Message-State: AOJu0YwJvbTmAjPsDupuiQsLe/kJ2dA7T5tMAm1FiYVbjwH83YHx/1a0 w/aBplbHqlAe2/rN5DDt0A3MpsLKmsjRihC9Pr4= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733455576800353 X-GMAIL-MSGID: 1785733455576800353 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: 181154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2109656dyi; Tue, 19 Dec 2023 09:47:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHizt8GR+VGo1DZVpHgO/SdmR8avN26rED2Pa/Jkx47OMQPNb6Zrg8nj2FIc8apXrZ1H/1F X-Received: by 2002:a05:6512:102d:b0:50c:180:2154 with SMTP id r13-20020a056512102d00b0050c01802154mr8837872lfr.61.1703008074185; Tue, 19 Dec 2023 09:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008074; cv=none; d=google.com; s=arc-20160816; b=gV7+OgGMBUIAFVOJjiJB7XV0lRyYmTcmE92kKBr/tDbAIPA+wLhLrZzZHwwkfsiWoV y7xkc611Q4umIOzGk25628QchrR/yeyseF7CuqGbjX2/Eo2iEOSsjz2Oq52M6p0He4WT FHcJyrLNhsdqcGcpGLnuNnI+sEzhqumtuSvhwcPBok5uxcvkiuA2N2lEbIaWonHEVSXO O9Wo1qsykhcMq6/fYbH+2a90AMv1rnFOYJLh4urnnaggslfRWcI5sYN90ERTPfLfrZWf ffBeD/sQHXV6ng0EdHY4+CGty8i4DQBJDj5Skz9eMZpleH65Di70p6DWvhasd7iEu+6+ 6ohw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rIbnDt1gfwHKXHRoQ8BCVk+wpgvY6XHWajEKia0uA/M=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=E1mLVfJ5twfs9CGhNnGy/ockgwIlZ2ksGZMYKuAI/E8601xyG/w/enpE6yFEuDk60F nzOq+OQ49dYnyNFdRQXUEi+8Yjh/VKNFayyoM++JiGeR6p8o3A9BhlBeRRixtsNaSTCG AVVKP3v9fVEQloBuqmhr0fBz33xLaU59meBQstXHJUAc7p68zjIuHFzBVSK/AIdVbS7C X6Rj3346n6sHEVIFWUAD1eD9Wlib8WqryGigeTPDqA5lKBJd0KU6R8B3szhkrAQk/v7J 817UIDhhlinrzKGg0+6mjP5tdnAyrPd5lpnusl3T5xmIRSJHhpYs/c51h2Og7YKCiLxX hGnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=KFyKhop7; spf=pass (google.com: domain of linux-kernel+bounces-5717-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5717-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n25-20020a170906841900b00a236338fddcsi1426258ejx.545.2023.12.19.09.47.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:47:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5717-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=KFyKhop7; spf=pass (google.com: domain of linux-kernel+bounces-5717-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5717-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AED9D1F21FA4 for ; Tue, 19 Dec 2023 17:47:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05D1239AC3; Tue, 19 Dec 2023 17:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="KFyKhop7" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D26E639860 for ; Tue, 19 Dec 2023 17:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d3e6c86868so4411625ad.1 for ; Tue, 19 Dec 2023 09:46:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007963; x=1703612763; darn=vger.kernel.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=KFyKhop7ECu5rw/sSYQbgCww+757PQ6kmfPwXm9c3sIQAiByCy9xjewSl3U0abbDs2 emwje+crxrvSWMjCcECMri3HMpotwQ3hXHv2AG5D6EOnj92L/q+XFryw2lyFxX9m2CL+ Cm8UoXhbLnimyWTgwSzJeNv5T7a94AcdBw0GW2cqEdJaMbzIQmiffk/C8yN2gF8kmvqn Ksxt8llKwdbOTxu/TMgiAtEFPZmiNQZ/hLn67dSC3bRWg19ZighYK/4PDc5sBbKj8dJZ cHa5ntKhTvEIqiez/TePaWu/v7nq5NG4RENhAq1SkVRCmn0J/ZKfKN8lE5g8f9LJ/VLi wpqw== 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=XV6/Y/NDsdZz3YWx2siQ5PrH98oLWXGv9VuIlFnk+jOIcF/TPuKR460pVR4DoUku2f nAVfTh+uub9abTCcDkv+EryiYsH4IzpAKBiE0lgApF2F5NGcZ5OzQbn1099JFH2q+fcK CvM8hjkhMwVHEj0qFRFzUhBIwzUxNbCZRwBlZqyvP96cWA4ziL6HjEzYEpcqtsJ9jLoq t8dBe03JVUQVIAFQ/+2/310Tnw+2+qUHjqK97ELQsRryWN67VwFfB0RuESYaBQLQZe80 Y5ViIX5qM2DNzh4+krfv8GX7Rmp0BszV7IgNUGCSnXdXv1chCL65LLRDX9hw5gdrDl+Y y6Dw== X-Gm-Message-State: AOJu0YzmcwGMb8Ojxc2nsDy6sarAd6GGcEi/Ere4bRn7XQ25vyvTKG8I McV45s2Va+e8Wpw8SuyN2TBKhQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733393922694741 X-GMAIL-MSGID: 1785733393922694741 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: 181155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2109863dyi; Tue, 19 Dec 2023 09:48:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvfwQ0rz83VfVbDtnZT3mYVFoiDtIm/vseUNRxcMzBZRHXqj4b3K/YDHTCPIJ9/XDSDADs X-Received: by 2002:ac2:53a3:0:b0:50e:39a6:2c2f with SMTP id j3-20020ac253a3000000b0050e39a62c2fmr1089070lfh.86.1703008095444; Tue, 19 Dec 2023 09:48:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008095; cv=none; d=google.com; s=arc-20160816; b=SlOEeZUJP7qMHvC2TOlO8Tjh/TtsiBkoVed+4SfDpZs3HLP/1jdJ2M78JyutQYY15s pfz71abtsKJ37KNAiDXKMaKDolfPjmQleeW1PatSN8GOvv7obJQ3GK0eX9E2/ufXTQnf 8sVEgGkr7gwXjFyUQZOc32h7MfXa7vF9obbL1NvdD/LW7qFPYTFQm4InRUn6VzMbN/rT s37i8k/7biBxid0mQDqnZlZtMe2Fz2LQj5XknSzWA5W+TFni8YpKlJxjWvtWogRGWdYx o8NW+9P4KZYo73EJvQFaUjggZXC0f2Oz54twn5+8FpUCH6mJZA89EXzPoo5klbNJUea4 DOqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8LBkXmYKNUx+bSYPP6p7CLC2p/4CszGfBGCJeSRJvdc=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=QnQyyw8qTkcQ0bXDWiElCa/VuYUzXNcVzcjDMq2d0NJtZTWuvmV4AXHHBBSt52m22Q mjQEk7Bv9sBahWXfk9rt6qsZHeCPIeluS2hWXRnoKaUUgFNhaVqhH0UjfOUjiCEyqqdK NQvvgb3enY8ocA3wjTE0ZOKnyGgeHEj+gfm4VoqnCUp/NqPxU61SGw1vdUkq/xhJH++z 2U+zSfOYaZ2B6Us+N2PnptqwLF/9jNvj4kTKfeRJn7aSztuE/KGB8KIKOa4QDTONUQ4Q T3FhcPaNqCS1OxkiKLpuFvkBCXAntkFvPEmMPchK54TlWFuR6mV6rJzmRXrdUkvpd8tu ixAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=IVkfP62W; spf=pass (google.com: domain of linux-kernel+bounces-5718-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5718-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n21-20020a509355000000b0054cd052378dsi11040932eda.320.2023.12.19.09.48.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:48:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5718-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=IVkfP62W; spf=pass (google.com: domain of linux-kernel+bounces-5718-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5718-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 113481F20CFE for ; Tue, 19 Dec 2023 17:48:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCF1F37D0B; Tue, 19 Dec 2023 17:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="IVkfP62W" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90D9339AD0 for ; Tue, 19 Dec 2023 17:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1d3e6c86868so4412655ad.1 for ; Tue, 19 Dec 2023 09:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007969; x=1703612769; darn=vger.kernel.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=IVkfP62WI+qGPDHiQNflIsShzQ0QzHA4Q6atD5bgBaFLqE9/Bep0FLhLg9kmkF3ej5 S2/ZXXXNuwvsjBE5wa9G87UzGrN6olr6AifbNiaIIJE7hxSOmLVMowG8iWUPn1l3tcPD 4PWfx+GjMtyGxMqAivoX4jVBdhzurZwB0o+yLDLyLTcUw4FWG03+V+FC6o6GHt+zi8ya CLontBxmsHcpUAx18wa/Ev6lS0nvwLQ5w5vClVsXrY9s038d7mOtqH164fzy6BNSYmCn UcjrWZsqMROHvQGIC84agyGZ1iBXyLJbjby9gO9kVSyWU0UtJuq1VmKIcMx/76ftRlk3 7+Tg== 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=cX0dLoV9HMa6LzcpZOK+P+5/HWf4GO6o3YItMUJFQIkeAvODebmsCkMYMYOntC+lkZ 5mfT4/pxaUodZ+D1ABVlraNwYMcCQ78rGsob6rf8tKQQfIyFyLe2jx9P50n756KC2aTg GE7PdM07UL+d9Zm2aiYqhGZlXxT4l6bqc9vXsOzdN5mnpL9a02wjMz7xz5mDgecOAlF6 sPH1986B3EoJxUyzl35qTV/2g2+7pUOpqPC8ktwpFzgTwjrwrWNCguSkRzetHAqbEVWv QL9Vs00IOyApWOYe9zPoy7c1l19PPWamSFeNkDTW8BJY1pFlDPgjb/eQpsbnYwj2YSFe JPMQ== X-Gm-Message-State: AOJu0Yzze5Jp98ddmp+3Niv7QttLU+yvE8eHmtZks9abkWyLj+3I2+0e 76Xw1DO5hSdC8mUIrIyBwh8hMw== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733416807482720 X-GMAIL-MSGID: 1785733416807482720 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: 181157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2110034dyi; Tue, 19 Dec 2023 09:48:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEo2vdIS3sGQqxmFXDRpHlr6CA5wijQJ+e86J6k+92VvorXrx37sAFoXja2XXGg54UdD9eh X-Received: by 2002:a17:906:73c1:b0:a23:1d:20b3 with SMTP id n1-20020a17090673c100b00a23001d20b3mr3546187ejl.100.1703008115674; Tue, 19 Dec 2023 09:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008115; cv=none; d=google.com; s=arc-20160816; b=rYrQxNLfWYCXgvlcmHV26St30lg1izxJLuPTTkTSwr9nY+Xr5QSSH3KzNVr6xurKqk eE9hdSW97Otzi4uUSJW/SjnPMmpxVSNhX/neMIJH4pGt/gdoa40iAHssr/WXd7QgEFRo kc02+Bs4tUObFmL6AhU1VfSCUltbDKbbJkWufsxJqH1gFIy6YCiBl9D7R2gDzsVtOEFs aINJ1y9eTln0dWqc9AAtLkIh4YyNSkAQcQb2agNh8/69bdLduiUu/rb3lHHY28oOqfXW x+05vWRv1tJDNLqdSZUpKV4ddAUd1M8lxqmUdigd9b8DRwxNXKjT6N9L/Wh4ctNCRw6D sakw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wXn1vXDcIcY9aE9ZluWKdogaSHoQIJLjYHgL6fRVi5k=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=go/fMvhxqnbsOG35uUoL4bc3CX4nC0zfiyksB7E2/te9yB1sMk1FzrjEI1YlSFzE11 1AVOQkeHD8mZwEINw8slqWUnCmfCUXU+6njwvgwJnlnlE10RKhsqirRDWQro3T8Mo82k 3Cz1OQ5Rqn70G9nFky3qtQ3DulJc7vyy6uXulC87RyPgsQw30xRMxrHOihxOM8irtibN /rrJKo9pZuZjEgXZUDoP3PYzDbSHlZDc39L/SazmeKbzrAETq1PKZV8grBxvFFsekIFZ ECdgOOFPg7PjcK6SdaUYNUyKDDIODcQFo8K72zTucNJSgtA9ZIHGj3xRPS+HTX49Sh8O v/XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=fN0YXFY+; spf=pass (google.com: domain of linux-kernel+bounces-5719-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5719-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l14-20020a170906078e00b00a2354a0447asi2049729ejc.494.2023.12.19.09.48.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:48:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5719-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=fN0YXFY+; spf=pass (google.com: domain of linux-kernel+bounces-5719-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5719-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 23B781F2128D for ; Tue, 19 Dec 2023 17:48:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F01239FE5; Tue, 19 Dec 2023 17:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="fN0YXFY+" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0746B39ADE for ; Tue, 19 Dec 2023 17:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6d87eadc43fso1494423b3a.1 for ; Tue, 19 Dec 2023 09:46:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007974; x=1703612774; darn=vger.kernel.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=fN0YXFY+gKPhiZ28irmQajOEihnMc2/x/Tb8coMkWVkhcvzCYaAqElbcdFrydToIxB jhtUFiv9wKlfT3L/g+An+Sb3ZKwLSCGcQ8PsFoSVeV0C81+XtOgdMCIvXUHph8l8FOxI IncCGyZZXZGpDL/lqgeYBq6ubejtYR8AceNniMAXBjJZwExKxlXKzHsTuK6RapdIHJD0 K/bU14mD+vslgXgse2YkFiexegHQN/rVX7JzNSf8lTVqC576BMG4/St5tKzeBNTd9Ary Nf9LN9e60ksjQNs0viggAeb+KmhubBlOvim677CS8cALprD6z3xcv63WX/3EFkUROwMS lFHA== 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=FAhqX+Em4HISop6YrTZ8IgR6VCeq8GBNoD4LAhf/4XZ78KtBTM4wCPISaV91iZw/ey 2K5LOAjyEYCs2tg/bG0Ew+8eVSYQDPqxWbEQ6LpSF6QXRJxWRwUbzG08T8KGhaKEP++Q IOrJvUJbjBTrmkmWOHuvOxXU2n+LYKuftPJaHSxK2v1NqXBmo3MRl9E96FLFrq1uAXDx I6c45tmjXdqG2X42OD+U3VYMclEBoSKIxNihVCcCbI4KUNTKTQxHYehSL8HCYRW9Umae oTdmyid34ayvVUyeeDSLwmSakF1wJ/e7CRPMBuuZWQz/TgVCLpd7tXMZsCTUCLy9iNnm 2wZg== X-Gm-Message-State: AOJu0Yxztxlv3hI4f5TDD4m4XTTgfvhweas09kfbmYi7fF5+1su0QK2P 48mv8wUXi/Dbkd+R7RVrVo5+0Q== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733437625223120 X-GMAIL-MSGID: 1785733437625223120 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: 181159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2110196dyi; Tue, 19 Dec 2023 09:48:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IG97uFUuGH5bb90Axom26r3sYXdN921DZaAXuwKuf0avFvtBecefxDSbGiUUMcMcROF4NfB X-Received: by 2002:a05:6214:5092:b0:67f:3c4b:a9c9 with SMTP id kk18-20020a056214509200b0067f3c4ba9c9mr5160565qvb.22.1703008134024; Tue, 19 Dec 2023 09:48:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008134; cv=none; d=google.com; s=arc-20160816; b=xqjHIUeBSUNDz2p0zE7hYh1UL9XsdkCLiWATVqdUhqs1GWsMe2DWJjYqpe7RR5N42t pfW+6zYfaWlP3H8EOckx9KqALE/Y7FShioLzHNhW841rE5bbjn9YAB5Eq9pXx+Mzly8y y5ob6WeSAeGCsW6NxnKYVQO7au8zuXoTDP0tWyjp56O035hL1TkelPtqpfZFLBYRiKEY E3Npz0cjgGp3eZVoZJx6gsa26g2GFXXtkDvhaRXhzbhSAuw0my9k2aQQa787IVnu6TyD 7KzTBGJhaU/NGUBVAk0+Y5VgYgCJfWH4wAkehM6bLAY1kfJslfES18lWN2vHg/fWzzKF 8cLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=DxzCTJ+m1lwBq+RMy/cftySc6UneYPqTwJF8JhbniDw=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=bqFdaO6TgjlGFFaf2FFl+HoW4bgOIRNOMzT5tbat6v2AMYyS3NY83V1Vp0l7V9FxOu zUmq5LPJTVQcGsEEWFw20JLPt34SJHUnKdhnLB5lQ0nF8MKh36TW7UNwi4uLMxH2rEl5 0REJZkiv1T3sY7hwxrZz1rPR2QXLEOhprVWoyxLPS7XxBDxa3/VzsZBuBkCeGWiLr51N sxjGzso3wgxM3yP01Wyc9X3XIJduhhzCTO9K192/KEHNriQTlqnBMOL0igf2Qx8QXDVT 4QMHaBA/aiE/jmdjpgf2XCViW20rO0uyaaOa6+EyEb1ewgK9vSAvDF2fZo5Rlx78M7PP RKmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="hXeec/N+"; spf=pass (google.com: domain of linux-kernel+bounces-5720-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5720-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 30-20020a05620a049e00b00780fbb0f4d6si2118319qkr.268.2023.12.19.09.48.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:48:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5720-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="hXeec/N+"; spf=pass (google.com: domain of linux-kernel+bounces-5720-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5720-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BF91F1C24D29 for ; Tue, 19 Dec 2023 17:48:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E5A03A8E2; Tue, 19 Dec 2023 17:46:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="hXeec/N+" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAEB13A1B9 for ; Tue, 19 Dec 2023 17:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d3e84fded7so3141565ad.1 for ; Tue, 19 Dec 2023 09:46:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007980; x=1703612780; darn=vger.kernel.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=hXeec/N+8w/TaInjdCZDrwA5oxBuB2FqPrscUupZ/mHRD7vS0bP/9ortxDQJfhhWlq Btu267dcv/FSnCuA0hbLdqLG3jcn/iRqoyYaJDEbtKGTRW9jDnTscM/iX2bifzw6OOnw +7eVmklAy/HVpmz8sj4gl6aBgYUa3w9phzafjcZLNOZeZAZZqRqXvXtMTNjlJZZYxDdN WYYGD4q3WdhPn2XT00MaI7piSCUqWG+DrZzDEgiM/aKPEWyx3DbXaNutdhdwOs042tPt 0jGDHitJhY1cuDoBVrGrtIuCvDnfM6yy6tb7en4gtEWcDm8Hso86Dyu2NZ17pz4NnvTr A1DA== 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=sp8MVY97uz+FhLA6BQd3lB4loLoRQQ1A8jtUntBGn313kZ+v5gAEXeTs5mccurCke2 mKABN0tAnOK3bwJqooVoZUjXHIEKAJp4n87TpFgQ2KWWlT56udicN5XloRCbYylC0t2p HE7LmDPqMC/Y1yFhVsT6WTErcO6zCC890pX4dpgtgY4nvF+BLSAyGxEoablz1zQyayj2 i06mH7Y+ZAko/Ce3RCLbq9m0r6OKaPYr+FsJPm0GhzzfFRx3TgU/QLn8X4PdNWrOMByk 7fX4laVmj3ckx3uxSDfjozQDTLzEGxDGyglAk7Cf769/Cgq8E9fHh7A2NVlgYPyv9eKf +G8w== X-Gm-Message-State: AOJu0YzYXM9xS1WL3+f3M9TKzA8B8iLunTlBt9BsbdY0OwTCNHLMo9tW FLo2QRdSmrc+kMsl/Ri1bWGWGg== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733457006856070 X-GMAIL-MSGID: 1785733457006856070 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: 181160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2110422dyi; Tue, 19 Dec 2023 09:49:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5WthSEt9KcB3thAylktxLpL2xZcQVRkHHOBDnvksJ0nRUpRI5DL7gbbTSy9kXbwfd1C6Z X-Received: by 2002:a05:620a:1a89:b0:778:b0f5:d4e7 with SMTP id bl9-20020a05620a1a8900b00778b0f5d4e7mr24396867qkb.46.1703008156729; Tue, 19 Dec 2023 09:49:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008156; cv=none; d=google.com; s=arc-20160816; b=F7++bui5l6ArN0UNwC57yIXrvHOCSDqrxpemY0O2PMN76xJSDXeX9GRDufYm45LmJK PTP3vBPKXErMuzSbX+nkXN77OTgTJl00s+iA4Rj31dNiFPtCYwH1cmIQhWrJb53i5HT+ +nb/09SjFfcvfDwzbI7WWxt+D8PyGL9sEJdXavJ+OsMonTJRJ8BIUg4aEq4yJFSADKIY ilWUzymvdbU0n5Jux1Pvi3yodIEg3J2SU3H8d4e6GjtX/nDnUHMjArZqX5LPugbUnMCI XNata6J5N1oWlk4T81FER6lGT4Xbb1d97rb3mJ1KQHCLHzqDLC3u8esUuvt0TqeRrqYM rBiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6M2Ttr5IEog4zhXC7a0v2EI78vgaHJj9cNeT2PJ69Bo=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=ERuZ0lEb2IDN3rZagq2L+ZsbvyFRFoVFvOtdduoHFCJTq4hcFtBz/aVfPm2wBHfBWm JOeAy/P0HEZeD9LXUy2czgCzxc3tpIouL7Vvwv8e+VhjUZLKQDyBRDO63JyN3bGQymUz HyFyxP5aqKhoMxVno0gUwCwCmduMjuj1A1nrJYaPlQEdIvIolbjhvL6U8fCkIG2ZgzDh hR4F8oVYwSN1rgwjUpeK6zC5r2eB5YdxmcRxcMOfddZ/JkZBKSHy6tOpx9BCXMBKZ82N ogQKER6ifmpVrPqr26bjM9jTGHANydvK9gAukZERq3nnuPwxHYAlWroqhzsoI2PWga+u mnKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=B5UFlInX; spf=pass (google.com: domain of linux-kernel+bounces-5721-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5721-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 30-20020a05620a049e00b00780fbb0f4d6si2118319qkr.268.2023.12.19.09.49.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:49:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5721-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=B5UFlInX; spf=pass (google.com: domain of linux-kernel+bounces-5721-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5721-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 72B7C1C2484D for ; Tue, 19 Dec 2023 17:49:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0081A3B193; Tue, 19 Dec 2023 17:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="B5UFlInX" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56FAF3B198 for ; Tue, 19 Dec 2023 17:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d3eae5c1d7so1010595ad.2 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=vger.kernel.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=B5UFlInX+D4zHQn5jvIHIgAYNRAiJriaJe4mFP3ddjr2RbXq0TQN1GrkJFlBs5uJUU 2/ZMVqZYEGOWybxpBeRva5VcWGLgsv/I1jJENuOilQoyv4CKxaXjG53jNYdYGryoQqjG rxUOZgnaPCTQlebIkEG6N+Dw5NxSHUL6nm3RoIN9/ucEus9+nQ99hPAMrkudtDmVp/ol bUFI/15EY1HklnvVdchWkkuJvfcfKdyDwXxbYo/PPVsu29s//Zc8kOek11/ZL6AiVaR9 dK1b1cwLW2uIWRfMB+l0PQgpOPkHyJbz0iJi59olSW65tNNoXX1O38xxIvRY7FzypN4t 6f/g== 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=C0DrHj9rUYgnxO0sTcc0L4f4ajBg/rN2turyRVa/mnvW2LKI6E2g85pgQaF8+9/diG PfSNdDPhJUZy9bKuDM7wzYp9DXSiTLHW9EmTnzGJzklsWBxXrSdUwLaGPZgwuTU9FVdR 6Jb1jsdUrv1Q25WvvG+VMHgR/0R1xYFXU15GCyZcdHDEOCM7sgIS+Q8Fm+PMEMILIekI h1bHhFE7R7B/0q9yzdfjAUmM7LAV8uN6aaVkYv6nZQY99uio1R0eILFhKlO4kFHw30/S WU14xAA6TPpV7FegC49mPPndVsm/EVaA7zp2LBdf57MF1UDgX7b/mu5CSRlGRqUDFpK0 9K6w== X-Gm-Message-State: AOJu0YzaXpMUHoXcbYeaVHlRs1iFxUbC5tW9OjNuRolbXXdUYsrC7VD4 vTc5hdlidJXvT4zt388tLm6WNQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733481344968451 X-GMAIL-MSGID: 1785733481344968451 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: 181165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2112157dyi; Tue, 19 Dec 2023 09:52:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8/+N3YvUJJWj/FHlkSUgRT0OuBz3A1+f59SCUULRu+RNePhPA1MVPwo4dH9TnW5bjStKh X-Received: by 2002:a17:902:ce8c:b0:1d0:9228:575e with SMTP id f12-20020a170902ce8c00b001d09228575emr22438260plg.43.1703008328826; Tue, 19 Dec 2023 09:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008328; cv=none; d=google.com; s=arc-20160816; b=lAl/KOsKTXGa5CggcU8uF3Lp+CUbxc5B1aORKZfQzkZVrT6ACn5sfkYwEL0vboHovR dk/9w97+F9uKEaVdHdvvkq2PZl8aNayw4yn6rSKyivlsIWnFYf5TomY6CD9XiOzulXZ4 qWGPIZRAvO8yq8sj0fJD9pKW/Sq8JFTEekET57S/NpeUE3auU6Bh4Nb+PHAGh4T0Dfm9 6GiCapqbITCWOmHeWaSsA5M60WHZnGxJXokKAf+2SzcYYDhnsdAInksgNBtfJlD68Cuk MrTEe/Dxt648au72oR2kYhrtJ2Sz4ndPV6nlevy4KEoBIuHqtNdn6NVTLGbpTQ/fd80c 3aHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=t3fyfZ6Lr7w+r0MJIn4zdZonb9lVGi9+7cBScTQl4UI=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=f0PSn5pUoV96bpst0XP+y18b8cawquV2HILiCpIUw2cPLr7einCRjfnDYMwDDfiP1p jDDdQggFTtrsleXEXFH+80x6tGjd32/NpJTpFV8R0JWVFKjRmk7h84mjz1Ju81nYuaEK dftFi/eXNSZ4t8HIL2uYLgPGTIeGp4Q80dJSXqXGk1GkUhTcFyCinjbO+YdmZEOAyElB 6eEOIRGnX49ShndenH3cgFw/vRkOEv0dAXXCZWVIfpu9GdtH9DXsbuoOEYIph76FpVqW 2prGED0IlZABmH+xUWYmRXAs0bdOWzkpDOvtmbWvMCwB2UIuQSHHL2YsslNV6mA0HXGM EhUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=nKgXOThj; spf=pass (google.com: domain of linux-kernel+bounces-5722-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5722-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id jf2-20020a170903268200b001d3bc864923si3840176plb.531.2023.12.19.09.52.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:52:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5722-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=nKgXOThj; spf=pass (google.com: domain of linux-kernel+bounces-5722-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5722-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 131A7B22D85 for ; Tue, 19 Dec 2023 17:50:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B10663D3A0; Tue, 19 Dec 2023 17:46:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="nKgXOThj" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DACE83A1B5 for ; Tue, 19 Dec 2023 17:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d39afa1eecso29693195ad.2 for ; Tue, 19 Dec 2023 09:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007991; x=1703612791; darn=vger.kernel.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=nKgXOThjT+Ob1ywOXasApoQx0l8u9nXQx/NG75vg2z6+DzrDNkQnfT+en8zsc6uCzn HHg/X/SrGQq0vsmx/AqZQR0JM7ppOeHb1wze+PpLg+yFV0cMRxKEIEh5N1hJ5HPuJ32C Et3hS2vCnNyJpDKdeS2WyV+/BvF2hq0sJyLRcUjqnICFPxMzwzw1I5YJqCX2wfQDNCnz l7I2sB9G7AbFF0gNtE9Z++jdYxPuTr5UY7kHXOZ4vhlJ7Vpmvg7dM9O0KMADnflZ/enI 81avZscwYQaCb95zpouRYQrR5AL0p649FUCAZg9uoy3gzcOkfnyacNN3+GscYggSpMsy HZVg== 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=bZrfubyExLDXb/K9oaFsbahsHP+oPdzFxUjTEdgWfZhdT1QlJo/PfRpI3BgCUhgt2T z//2GzgVEjLsjHO8O3nb/HAr5n+Ni3/9laOCO1Bi1oTzeUiNAw6Fp0UMnlnvTx9+YApP YAuURACVUx5NlBlj4RAg6y66DQzsypMUo7MrEZpdWULD04ewg11YsI9NSqIRmNX0mJml 0WsO3aY6IhGgDfJbGT9v8Y5GDdJi0PZN3JoSWrGAjzDAk/iVWm7jws2ZMbbOWi96QfB4 U+P94nISAiBVGSckIgdxqMeQLixvKYUfvzaRJWmnKfFrumLJyYZ0aiuU07e0Vn423Ia8 5Jog== X-Gm-Message-State: AOJu0YyO4gsh6Gc83uw59iRtQ9hQZ8LbKsraSVc7BZ5k1YfNiMRtM1MN D6fH6undUYl3OYUowU1PW6CQ/w== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733661762734186 X-GMAIL-MSGID: 1785733661762734186 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: 181161 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2111336dyi; Tue, 19 Dec 2023 09:50:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFh6DGQZsuR8A06Ohy+6or6tDvzMUBj6NswMALLypJcpUNE8s/Da+FSFkzAFLEB5v5tvPC0 X-Received: by 2002:a17:90a:2d89:b0:28b:90bf:3991 with SMTP id p9-20020a17090a2d8900b0028b90bf3991mr1992677pjd.47.1703008243646; Tue, 19 Dec 2023 09:50:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008243; cv=none; d=google.com; s=arc-20160816; b=fPNMxyb1ZcDY2bvIorN8wWLz57mVMY5qyPSbxg8WOEsH4Yu79OdSvQa9KHh+ZU8POO SK+vEFvkmgsHqC7yvFpkq8JpXPvB4Aem4r9soTy8sGIzwTomRkYO/JnYGtJBC7i0wHtU lmsUt2SGLQq0EeKlxmK8vNRjtreDKVJRGdFh7zKMZ+2Yo+RAMoOUXR0mAbzntGaPNfPj fiw5wzbyHqIl1OqcYxwfDt//ezMXeQgWLtJZ8pF9iUMSuFQRnNXmCbfD4Sm0b3LV76VL +zKFj/HrWr1P5RhPzFh6eDbkW3v4FI2mKpppH3PXykAphKw6oEcZdvOaAdpBAnx3kGvT IVCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=c4ypyUsQkr7EY8e5fntZynE18HeG+okjQYWqm+Ns7+I=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=KHZhcIiimRSCYjbNYQhhe4ziQpQKlW8vxW7hKHb+TFHic9FAP8SJy0Y7BKt0QPxVVB /R7DNiEYNOElRqndAvtUnsThfN5Yotn/I7wGQn5XzXjCpCsNaVpSohxfsRGYn8tSHehs ZMz89LMKKUeygI5a3ILEXPey3NG9sMKriWpvzZIjH4I8S1mBtrBITvR2Je33+WuTgz+h P1BQxjmpcznBUKbhbvsHGS4WF6aASxLy9ppDYvxw8XAf5z5mSm1TOKCkjbAnMVepScNd Nw5osr/CG/zA5IQqZsD6FNRtbAB1U3dXHqQ/fg61jF0KWgtQvjymtkp/9xgO5C+KJKyU +iZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="ad6qfL8/"; spf=pass (google.com: domain of linux-kernel+bounces-5723-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5723-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y42-20020a056a00182a00b006d4805da71dsi5572510pfa.118.2023.12.19.09.50.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:50:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5723-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="ad6qfL8/"; spf=pass (google.com: domain of linux-kernel+bounces-5723-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5723-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5F9A2285E15 for ; Tue, 19 Dec 2023 17:50:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73E023FB04; Tue, 19 Dec 2023 17:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="ad6qfL8/" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D8193D0AE for ; Tue, 19 Dec 2023 17:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1d3b8184a84so12631785ad.1 for ; Tue, 19 Dec 2023 09:46:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703007997; x=1703612797; darn=vger.kernel.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=ad6qfL8/Y8kW/Qpz726slNUgU9a9s7dmIMadiSmywjM/ah91s04hZERJ96z75WvHQ+ zUd0iFND5/1ssJLZ42ppAB5biDACpuTtJJIhsBYCUFG+y7d7yPqVCtQ4t61hJbKoUby3 79mliIiPB6twUAGNmSZHwvifgaqAa4cBolTDQ/l+7anSllGerzX7dLxHYL+ZZxeJQrZC vpghRE7o5sJidv2gObePTHRaJ+p9LJU9JNIe3SOJ6v3NeZ2xc7o7BqgSMGJc1nl/Rd1I kvWW1M7dPdYQVJwenGlDJjgeSGMe2n2BYcq6EatoFFxQLXy/1kNvjlOWv6iwcOojVakt HNog== 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=F+Ecww553uDDyvU4wsZwUetm1QIEwcGXmMe1F/okKyORz/d4Y0B+CNVLzabbuloMR/ JjKxnRWze+STZYYL8/yao2KQ4/yQX7FoYb9sj4Zlgz5MgMXaOFwA9uKMmidJDyAbXH/A yXwKDMLMwi7PJw853PNogVZyrVaM8axnPwr0J4HXzJKxlgE9Oz3tDWUi7bEyI26Eivgw PlZl9y1qEb2QLN9Zwsz6fAVupHcn0e8FleoTvP2YSrP1FK4YAa8HX0jg93A6M+EZsyci Dira8b3eGoAfUyCGE12r8uDhUX/FokolY0yT4Uej6/8hCVNacXNGvCCiYrs7TwH9D9+T tZpQ== X-Gm-Message-State: AOJu0Yx+QKIfGyygvmED8+p5nFZ94wcn4BijE/t4xFReeaAs3ElSSy/d BlbJHMZsN6/sLtTHiDnLw6z57w== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733571942490556 X-GMAIL-MSGID: 1785733571942490556 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: 181167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2112569dyi; Tue, 19 Dec 2023 09:52:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbi9dddaHin+BpU9NhDT//qV+oEYNEMJGYXPzvKcSQhh914NAJM598M+BSBeS3u63oGXOp X-Received: by 2002:a05:6358:590d:b0:172:bb4d:91b2 with SMTP id g13-20020a056358590d00b00172bb4d91b2mr7021218rwf.46.1703008372999; Tue, 19 Dec 2023 09:52:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008372; cv=none; d=google.com; s=arc-20160816; b=f+TUXu7BNeGVtEaNqUKtiEAnG/IqRU+nTi3nSqveTpkpTa7RHYNVgPTciidDHHXzR+ 45326oSJhfKlNSnFUN4a3UkuFDxpZKBOb0JV3hd0/u1bnKEjOaLJYRtqOgBdWInWYNAA eAtQvcHLGyynpId+4WtczUDA/Rn9ltD8H83aw2dwDGhrg4hTxo+VYm6wxHbAw5ZkDUCY H+9JTCBshlU5ug4XzgbN4A0XPIMHsaC+kJeCCHp7M6lz41SMW+XaoZV+p+9ftEWK/dmc 933q0I9PQUsumy+B51q3xFvCL655sOBC4vzOOjZsmdHi+nVz6igJf/R3i7aWdfhFeLRe q+4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3ZH2VVLJxNHvriakOOoWr5FlZ4jVyb+u72AVTrlwbgg=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=Y4RWVjXTVlDDAVikvvUJ7vRf9d5fRPtQ23Vwe7+QajF1br1REDZR5pu1kOUitnD6Q4 RSmc2NCANFLmF6NYX5AuNhq3psleeX+9N+YdVMeCuw546cDUJshzEd8genJUpLO4qjCn Mc/cY+APqLsbaDlBb9BqSFUxi2uNcg/wrNnXupICACXlETjbcNrjINudA9AX/4S5S5nH PZ/gW+9v24ZSidHoUmaiQGrUkIr7DIkW7erEDGk4BgWmAWa8BdjY+8E1FJMuwhPSv+PA yHrxSHJ/yDxykvR5f4kEyvaVVYTFuohgrwNjzcp5gRfsMr8Au9HTyz+UVS8XZpXcWQnq wCtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="D/sP50/o"; spf=pass (google.com: domain of linux-kernel+bounces-5724-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5724-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u5-20020a634705000000b005cd7dd81164si6301099pga.222.2023.12.19.09.52.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:52:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5724-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="D/sP50/o"; spf=pass (google.com: domain of linux-kernel+bounces-5724-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5724-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2DD4FB24C19 for ; Tue, 19 Dec 2023 17:51:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 504C2405C6; Tue, 19 Dec 2023 17:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="D/sP50/o" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38F623FB11 for ; Tue, 19 Dec 2023 17:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d3eae5c1d7so1012565ad.2 for ; Tue, 19 Dec 2023 09:46:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008002; x=1703612802; darn=vger.kernel.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=D/sP50/osE/XVQ5JJt63JoC5BH/nxC1BnGu5xk8ZNOPvKhDqYYiwVl+nWraaHMB9LH dOIGyANx/jcxYPodABNGNgy3riAbaPDryhVl7y2bxMZOBXd38IF09Yi3WSP263fOC11k uPt3CCTaZ3BwoCZ2wVZvBgo8+cN2R6J1VdH9gOmLYUDjER69a7zVPqpF1tBYCsn8ffKe VKGY7WjdXDgvV85metBMhXKv4J2NT7vKzaVsYmqg7O3tGqdE/kvzT+DCivMsr9lhYblC BypFB2Ta3X+Bn5n7e35kukhNGOZAGSnD8sKHzVBYtmBX5UBtb3bVgQ7XqUa0OvV9P2wG Pmew== 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=c8M1GKqTmyerQhIl2VsFrNACKI6RDcdDLDQYNdTYFTF191Kdsx+9W/lzCxII8XCdms ULKI/Xip30q7E8CmE6oAK5ZZZG9LUfHP7VLTi/epjOodNxCdTfDFW5wgVA+/GzamEsTr HcujvHSKmv/H52mKxy8fW8vRsHQ8eTRNeqcVhBQ53ALOs3aiDTR8+3fIj/cdjRRfN0rv hkZEQXaJx3XWrvSUr2BcnO3xy3SGPldKzzoTQ1Yzie/hL0fdDldP3caEQyA8G9MW0LAN 4AhXV1oQXSEPRo55k/iA7I8ETH8ufccOF59ndt2Ljs4axgdE3Y1iCio8GN7XsNGkTozr N+3A== X-Gm-Message-State: AOJu0YwcrIEkDa17vwI6S3MzDxaKFw9a6nQdshdeLMikNfEamxAt6ygn TBcowB7pLe2eRrrq5aw53ad28Q== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733707769375780 X-GMAIL-MSGID: 1785733707769375780 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: 181170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2112807dyi; Tue, 19 Dec 2023 09:53:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqjC6bAtXyjsPDGAqvS1l+bT3maWCJ1PCdRxwRTHF5GKoQeydzRRrpS/WGxSDsFyD3ynv0 X-Received: by 2002:a05:6870:b012:b0:1fa:e471:12f6 with SMTP id y18-20020a056870b01200b001fae47112f6mr21025581oae.51.1703008397973; Tue, 19 Dec 2023 09:53:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008397; cv=none; d=google.com; s=arc-20160816; b=aSsftto7+MBwZ088JG8TeMvc7nClHa/ESJk/QYQEb+vfTcNEeaXThG3q6jGkFFo3Tv cFsB6kgc2OvS9jQDNUFD0W/F9g3zxfEff6wi/DsoDuUKIShQd//Y2GIc3pp2J1WAT1cr JmtDkAAOD/mQ1G4xGVWYBIP0cHdji2kBxMBIcU5ymhv2Ycqgw7axQwQi0PLUJaww1GjB L2MPIYyK/4TveuFKRbkRb+1Regs6B+eOKCyMYf85vT6s5dOJXy0ItrgrbsZii6CezB6d KVOGG/95rb9A+2yuKU/Eh7Z+GbALOFWQTG1MF3IZsYZWq52e3ZzTjq2Q9pKmroNPT+YV /fWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SP5qUoiFDc31MnkvQviOGvw0IT7UG54DgquaP3mAr+M=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=FAmsJlw9SwYgQNiOOkMgGFVvvHTloIjCdUboppzsKcckBPIRXCqjaNx3dd4NQJpGWJ 43kM9zaA9T0RzCZwj0b48MK6Wbbby+yxt1Xvwe0BrKO7ctN6SPmhgalaf/sT3HE83OZX xZnIXnN9cjFTSkcnu7EA2z4xGBiw+wUU4pdxkOgC2atXpKQmYOK5sfkTMEALBJsDSKcW kJoh5s9HlUgmV3YQ+AWywzOits5ULsNoH5FJJi1gf6FIqUVf1BtVylkO2M7gSw7D0+dS M/fe9k9Uiuq5SzO+nKM6MqHE9Hate1KjuCZcCGsIYVEB9NcS2M5byI0H9bzBDD6ILbGM 1Gmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=otrcrHRU; spf=pass (google.com: domain of linux-kernel+bounces-5725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5725-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h10-20020a63e14a000000b005c67bb15866si20378762pgk.52.2023.12.19.09.53.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:53:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=otrcrHRU; spf=pass (google.com: domain of linux-kernel+bounces-5725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5725-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AE575B25134 for ; Tue, 19 Dec 2023 17:51:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A59A440C08; Tue, 19 Dec 2023 17:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="otrcrHRU" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8787405EF for ; Tue, 19 Dec 2023 17:46:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d3e6c86868so4418285ad.1 for ; Tue, 19 Dec 2023 09:46:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008008; x=1703612808; darn=vger.kernel.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=otrcrHRUm9i1fCUkWomPlZqVh49wsH48P/vxeKmchXV38vQQFb39AnQA9jqkicdaYx AWOD6Yz4p2MHlJTYgL8Wy4n28t25Beb3Z/IMTfH8WB4bBD2OS9QEiQTrnLsQkZOWEI+2 r8MVVfF9kvG843l2+1r2SBBEaB+NsyoX1D/i+e/NOCoTISikBWhW5kUPptE7KtGkdQ5Q luaxBstIilprDCAGwUiQ/FCSIhrCTrYmznKD7FDL+lgwH+M0Irpor9IzVj1iYvzJJuW1 /kkwOnsyvBK1sik5iLPvHKVDgoRgaxyZFDI9uXjb/KTNoQ1GgXnrJgcq36toiIsTb4NT 65Qg== 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=WgEpBg+jXWExlBuN826B17z6h0Qyx43x23oyHPzCLWMH6GIujAMI8Puzp3tHWrQc5C E5cUoNedq4WWrnvAotf5iobuDUB+/sZcUIih++0Uy2msOtmyp/uHBNa3p+4qtHC+zIrD xVfF2ivSXgLeIPowdG7U8YqOAKJ8xPow7tAOTY6ZwBvaRo+QYpLiCRvWT+spl/UXTyer TxmPOxFwboOvT6MX03TSqTZEMbvC7joJMQ40Llp/JIsDh7wRptPmXd3Fe9uVO7hx0/0s 1H915/O48s0TP/xaeg+WjmYHzGPvn3h7iTTp5HmhZXjWmhFzeHrBViJiy/O5hKApGq1L l1TA== X-Gm-Message-State: AOJu0Yzw0Fs6IwiB4UpspMYo1bLImAg4P2+5BpEe0c/7eBGR3rV8oo7n Cy9NhIA7AVTwBajDFinReyza3Q== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733733852526803 X-GMAIL-MSGID: 1785733733852526803 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: 181163 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2111943dyi; Tue, 19 Dec 2023 09:51:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfOdUOycQ+ZaAs0bjQD99RGmRCQhC3Eh4ncqmtnKKMNDr6qWUwF/GHIAyXR09Pq22a7bF/ X-Received: by 2002:a05:6214:21cb:b0:67f:1290:4ff0 with SMTP id d11-20020a05621421cb00b0067f12904ff0mr13640819qvh.76.1703008303120; Tue, 19 Dec 2023 09:51:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008303; cv=none; d=google.com; s=arc-20160816; b=K4xVxSPS/7FnsSenXdM0P2yLbnZeYowlLoGdp4OmJhhEJMnzhiXSaO9nnNtc1vzVCj 3//luGEED4AcyHGjhLngXs2L+77VPK+okMGbq7Zy8cG1OWRVqUrMXv58WFtZzWqDdCxe 85DEZL+2i0r3+JYSURV3GQCroYwbyGaNRVKVeO0eXYbjRRocDjPzr8VknnNPgr5dRahz nhS9xlHbQUhpVnmB1FCAsfOtc0HOyLLHZZ12yLcbcrS29KcHQdBSBDZnRazRlqcMcK5n dy+ZffWZzK4UxCiIKTTEVEA7o0MKNqL429JHdc3Y/RdiGnoCMdn2Vi/DwLlmcGu6jF33 5ZiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=g0uCfTOZnl72LckIuFeuzwRvzQWn6/C5y85H0bronQc=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=pgInAOx/sIqIIbgAebZYLnA3uufUH/o3Fte+B8dltmZzsUiRyrVf9fKnXJCneJROgk C+p0IPHIrggJuC7sIS8w69qf89J7eBmFMYYpiYvEl+CdUDIYoQl1EFwZmbyaKAYJFnFd 3oaX/9kNwxY1LzZ7oaPaHl9DlFjtx8z3XAgztVfQE1xt8g0ckz4XiZuid+AkVrWYvLAW 9xFo5lDzxvBu0kb0tHB9QkztUqLYBRt/ngMrqxW86cuvGfa0YO/b1YHjDdPozEBbrOYf QT7vWyI2x0tgbGZmwZdsbrfsBuVIpal3DO1pfVYrr6ilQ31dUCmsrsPlVmVzTfu0NbzM Tb0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DGBDP4yY; spf=pass (google.com: domain of linux-kernel+bounces-5726-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5726-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u4-20020a0ce5c4000000b0067ecc931df2si22384464qvm.579.2023.12.19.09.51.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:51:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5726-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DGBDP4yY; spf=pass (google.com: domain of linux-kernel+bounces-5726-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5726-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E40C11C22F24 for ; Tue, 19 Dec 2023 17:51:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8BB1240C04; Tue, 19 Dec 2023 17:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="DGBDP4yY" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72CF340C01 for ; Tue, 19 Dec 2023 17:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1d2f1cecf89so22640915ad.1 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=vger.kernel.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=DGBDP4yYm2TSIA7nVLia33bztGvzZ3Fa/2Jp/k3giNwLELuBKMcWqyw/WI5AmaR8pr f1Osq8dGQVCMj37qVzdmKnkgHHLdH6g3/3b+Jm7v4EwPULSB8Zx2i0/iETSakv0pghl2 QYzkp0jFl3EaQPufPzIouPhfAcSNofr9LRjS53eWuoEDZj6E7JmRwo/hdyckqGRaApn+ Qz4JY93pT9v+RaY+qPFRsKP345EIC/JOiWib9tXbPPBcns7YEghvsBhKcWttU3SnI/wH xkDarqvK7AFhB/NP646BLCZYRorrp1hC86KgoTAJ9WfMHne5iEiclwY0GzoCvlYPBP3S kkwA== 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=FP4LD2Pykj+Qn0+jHeFoHfS1qmDExEz8s2lAyCYteVQFbo03uB39EukFUpmYvI8vQ9 8Iq0PqPPLY+wo5lATgXxRlh0uI+4+7JK28Pb5sFLm9VqWwDCp9wRtplYV7CmfkJf+YCL maonk1IK2kvLuf1TuaREcmWWpbsni0sO8qxzJkS40lZl25XjXHHnlzVQ/pkE3zR/UPO3 VQyFelPwtc+XCXEGTA6sgGMMCwph6FznLhhum+z5OH+q8DHGWRLaJ7wFArx7xRkzVD8B bMUzcsN3Ie6miIBalU/aGQw1kj9MCBr9kBIzOaHxJcj+LAMVx6NLfs/dhVmpdKHgb5dO Teuw== X-Gm-Message-State: AOJu0YyKmjwD18Tx9H8OygbHbtoIubTQUrOk3wqbc2TtdaGbXZKvMniA cEOwZUmrchNycoF8g5IEpuKmsQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733634240187540 X-GMAIL-MSGID: 1785733634240187540 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: 181164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2112119dyi; Tue, 19 Dec 2023 09:52:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+X6gTzZY3dJJ+7rvA5WWZV42HyBvAkNnxQrdYmzOJYkkqUdDy4HFrVQTfPMF5S2c9nc5X X-Received: by 2002:a17:902:b708:b0:1d0:c4af:4635 with SMTP id d8-20020a170902b70800b001d0c4af4635mr9015861pls.98.1703008323312; Tue, 19 Dec 2023 09:52:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008323; cv=none; d=google.com; s=arc-20160816; b=XKirT8iiRCHPqb+GrpsS2TDCBjmdzHKMVsBGFUGzpMVpKNAhsmM8R+jazENqzA3sXs cs9TkblhfRE/VuVNgFxeeNfK3dWNBgZHd+lQ0Mz9Jo9sH+yVrDwuEP3SnNwuKakOfQbw 19G8iN/wG9QEe43PqqSnXirloS4ko52FN8URgIOWav/zhBF+NZVY938NbylqqlXotXkt 3wSzsBeH5ugydGSyeOx8bJ3XsP1sgoqJG/oTnIzwNnE9UJhT8lFwOzY4rIM8n01+1T2z CWTIQRZMGI5hnWMh+MM8N5LtvGjU4wiT+cCOg+rFUtk6E+JgP/8nXigwm79HT83IVVnZ ymKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rMG56uSWd/ufo/nc8FBDk9fzkMf+1BzSryO0Av4W69w=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=NvknCdc5+uy1+go61/61M2AHh6mW0PaJtV1ky+FUV5Bv0qLZGwlNt5q8gcf0x3Av99 bMxVnbcB1pvq3BYkaVSSvuq1thN5uTWFXoelmPFFHbJXppUEBUrkoP6Xke6kwqWZ4SJ1 nUTIgwSLHXzIFslXeJnuMIOgGNBuiM05fKhGUausraAEirwSvnBKFUZPCYWsdaFS4QmR Aa+U2nBCx7K06r6RjdoMx5zfGXGKlex5NZ5uC5y3KEYun0E8KSiLLvFdhtKlFqdCplET Tauftg/pk8XqLgvZtaAkD4CsrhfT6WhvXwHmo/l+QDN+RwPmfs9wSvbn8Hgjwos6XFmo I6Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=WsgdaWQA; spf=pass (google.com: domain of linux-kernel+bounces-5727-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5727-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id kk4-20020a17090b4a0400b0028bbe24f30asi1211705pjb.132.2023.12.19.09.52.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:52:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5727-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=WsgdaWQA; spf=pass (google.com: domain of linux-kernel+bounces-5727-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5727-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 156C5286312 for ; Tue, 19 Dec 2023 17:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBAF84120B; Tue, 19 Dec 2023 17:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="WsgdaWQA" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 547E640BEE for ; Tue, 19 Dec 2023 17:47:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6d089e8b1b2so2538507b3a.3 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=vger.kernel.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=WsgdaWQAUfzZZJcTIlfK1SZGlqDw3AjZkU2fQx/GMWXGj7NfWyp/x5DLjA86c3P/wE mOsAc597URWmWVAK8mXf+mbcJYCKKCEnaTeUCWbipxcDyHPpkLJsyQ2JHb847+2rvpmi r3LZZDvES8rvq4nzd+Af7ypJ+eBDL68yFM80EMnB5uQCCIgI7YiBdgzUGlYndHvhpTPb k4d8o1IRVZ9QjrgOP8CL5jyMinjpf7mKfgpJk6iW8IPw9Cf5U8HFurn3bz2ledXMtBh0 aPgXgVqIlnNgMIpKfdiHwjFCDM+lKiZ2pvhUYcUCn0tFmUAOLWXlL8TjDukDd33ay1yd zPnA== 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=vcSl9diT4c029+CMWOZlcT8EmZZ330oucrEZw5+xoN3ubVJevnftWsEgEnlb6/Z8pr hG5PLpEzcU4LSDU+jTiMKOsL8tz17B/V4WABfTkH0LsjBSmASivIBxuyNzfG2J81onrd DWVgD57mr6aHXiPacTWk2MFDB9b2nqp2UzMyVdUeE6vY1LHySdZPl75Y4FVxEdtWpp8D iLwQDaiwVpm/LTXXA1xYxSi0sygFeVlos9UBfOSnB+bRCRNefspx+XNpN6Hl6bmkJzdi wzkp6/PR1zpovg1Ul7+/LiWAnUrJWPkIcksc2YmzniiBmjoTIW+cgRsyzyoVoJ8Xkgf9 6C9g== X-Gm-Message-State: AOJu0YxA7DWtNznoIijOliylPtJTV0lm8C5uE1OXt3nbliKG+OjUlzJv fVyBx+L8uwwCEKkuLO0QIgMcfw== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733655489825243 X-GMAIL-MSGID: 1785733655489825243 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: 181168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2112573dyi; Tue, 19 Dec 2023 09:52:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzzG+CHvrjskDFzGJBIc7l4vdfEPMpyi+lo3HJfjsIt0d/uEMHxTiWGbDEMXgOwoQZMwLb X-Received: by 2002:a17:907:9408:b0:a1b:64a6:5f00 with SMTP id dk8-20020a170907940800b00a1b64a65f00mr11904990ejc.5.1703008373613; Tue, 19 Dec 2023 09:52:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008373; cv=none; d=google.com; s=arc-20160816; b=0Qz9HoR2IIIb1M3AUJQvcF82HUO2zC3ridXQdJPhgu2m4DZQ+HHUAvcO6qzxcANDxH WWUtIcCF7bAFJV6QOPDU3OgXTOPRJ5bPy6U7yN2cd8pc6MJ9rZjNDxzCHDTtSsiC6S1c q49pXzOaNHO5eV+NRH0BzrJxQTjRwb3kk0mS+XaAUIlk+T/NZipXpSLc5ZVdWSwvgpbi BYmPq13I6bGm/FTsy9LPP7vIdxjeL8Uh4I/II5Km1ITe6p5UWqNNCMAdsG7lzTqMe90D B5twtEsmwzZ7Ft3AmumFo7FeK9LYc3kQlKCmmqAv/VPlQCM0NWBDduz+7ReiEDC5qtn2 wgrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XaVzwwT2ecLOtMDBM5TdFJiJ9XdFZ6MUpboDwIj/4ug=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=Jus72TlpnbEJh9JzhJgMlQDBIYGbT3fLW1Ybirq3lObBlX0lhAfOrA46RYZQL1xSya 5qT0RkJj7P+FocUG5kFxObeDxJE95h0agg/r7apADryU9LS307Xvr5c/qsdkcHg4Wciw t7a5TKeNaGmVBx7p0xLMpiVNbvDW54aAn3g3JizkFtNt+6pFd7jCfYrqG2xioENOwq1g ShZh+5oGjJuXh/2+A+SHDLgChOOtHMANYdfcLjsR4bUGQpRuYUUuurP67tFIDIp0AMIM q1CBHGAnnbvFGqQGohTLtoIRxhDZDv3dRPu8jWJ5F9aSip9byZFnN9k5aFkS5xu39THj ZahA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=OwdMO+Dy; spf=pass (google.com: domain of linux-kernel+bounces-5728-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5728-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e18-20020a170906045200b00a24901b6057si631769eja.392.2023.12.19.09.52.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:52:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5728-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=OwdMO+Dy; spf=pass (google.com: domain of linux-kernel+bounces-5728-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5728-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9A6A31F25284 for ; Tue, 19 Dec 2023 17:52:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA4A641849; Tue, 19 Dec 2023 17:47:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="OwdMO+Dy" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D067541212 for ; Tue, 19 Dec 2023 17:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d3aa0321b5so25338965ad.2 for ; Tue, 19 Dec 2023 09:47:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703008025; x=1703612825; darn=vger.kernel.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=OwdMO+DyVotX9tmk1xRIsraAElYFlr5ThzaBzSh7oPVDYa8hsVFFb6066ici19XRHg Y6WBeMXC2BPYDoydWlpIfBi4CgE/GG5YE9CDZHsxTlXlACfJQ8IEDxBwvrcc6hDl+gpP +eNPO7GMP+ddTzRoRXZqfLmhnFBJN6IOVi+mCM4crUVLjXyCkuEi38cW/8eHyEfZaVe5 wCsfexqpWND6NugDDnaHgMaw5FZnfswZAnCRygZ64HnkwiNNvktxEmB5D59MlXtx4g4M XI1VbKpv1GGbtTG1FwOusSamDObMBU90lQ4FW/j218mKBgCFCfWDlO0yYAiUworYFrBj xmXg== 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=GkQ+KrfMgD8BiycVO8PvZyF/7TZq3QiHjqsQGryOPJyCcuZudn4PnN7fyCiKWkB0mZ tc82XSg/nqkTuMLEDvwFXnhcfw1QifIZrGgxXi07pYuFokNHzRyHRYe5mF9DdXA9HUcN tSsZM9N2GtJeUUkSQfexPvOI7Au4mjRR+9NPmANQcDaTLouU7wQYM8IYyfHfIZc2LcP0 lM7itPgW+cOu1JzYJa8lQ0r4DMfjZBTXgFeGnIA01I/0eMmHeso2CFqgOsg+y1Xqfco3 JRAL+OkT+bULNwCs0upAN474OzcWhLk2qgbkVV3UhenLkO/xYwggQRyj0dVADgsCb+xc VCpw== X-Gm-Message-State: AOJu0YzpnSUSZD1YXWQOEJI17NZHHkxClP5yqz9QXVxjgmV8l2y2Qtz6 PIcF9VOFSZ6rltt6JbIL5kTQPMafTSFsJEh6REM= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733708366184516 X-GMAIL-MSGID: 1785733708366184516 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: 181166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2112464dyi; Tue, 19 Dec 2023 09:52:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFd2OChciubV+L4h5Hsi4nlC+tm1oCwj0b19q9idGTZJShxec1ChM8nY5dISOvleyuJE3fM X-Received: by 2002:a05:620a:688d:b0:77f:6e1f:bf5b with SMTP id rv13-20020a05620a688d00b0077f6e1fbf5bmr21514226qkn.116.1703008362209; Tue, 19 Dec 2023 09:52:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008362; cv=none; d=google.com; s=arc-20160816; b=iJsxC9aiUAOuiD1tMesBzfOAiO5dpzbOb0jnx9YYKaa6ue7JyzkduZ96cA1AVnzaCW UfC6dhBooU+Ry1HT4e5zes9SVm6MV5/9nIeW8ErNsjbIKKHbC3z2GwSJdmEdJrn+8A/+ f5cGx19lFZuni40Z1U3++JFpM5oL9DiJ9GSu8RznZ5bYR/J5ffOR+KDalo9EbnM/IfmM rsOtl7CmqULMkxRZCWk2hq5Eg9EAnJKUxYtI0dKAeEtZ6acUOYVjW7mzimA8Gm8XywTQ 2ANaVsucMF9U883Q1a83xNMc5eW/tZt+NwjiKheoDjd2SDiq4YaJS2pWv73b6cb0GCSn bnZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eiwIpb7xuTq5TPRrwpmxnXk+wGzqHEHNo03fDZVsc7I=; fh=G3MkS2cP7FkeH+7kxy0LRzNpJgfwnUWZciURRBohxGI=; b=GhCEo8wRjeOXSDsOTnIvW0Ns8PC0kAn+kT2npwdm6JWpilNeTSD1IegtH59nLTjEE+ J2+v1sT6DGTe8jXN5OKTeVVaDoX17WD64IFiY7WoIuGfVWV/u1ceGzE/VC3N8iMs8uUM K7TC6zA/q1uieXHSlISuQq6Miv0EPC2qhe7s30f096O5/dAkWEfttaUcfaZx3s6iaIpq kfTNydlBBVlk9FXR/AQOWhY4NWk/26Y+L/B7PYRWcKvIBElcdEQdwWux7+p6wCLAX0cs cq30Vncu5QJM65OgoR15geH0Kc9m3ILLOd5KWQG3WP5yjoKTVuII4orjIkKNb+MmbOQ1 W+ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DPqUhByv; spf=pass (google.com: domain of linux-kernel+bounces-5729-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5729-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 10-20020a05620a040a00b0077d71d468acsi16027710qkp.407.2023.12.19.09.52.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:52:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5729-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DPqUhByv; spf=pass (google.com: domain of linux-kernel+bounces-5729-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5729-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EA9301C24D8B for ; Tue, 19 Dec 2023 17:52:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42BF441C71; Tue, 19 Dec 2023 17:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="DPqUhByv" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BA3F41866 for ; Tue, 19 Dec 2023 17:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d3aa0321b5so25339755ad.2 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=vger.kernel.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=DPqUhByvHwkhPIztuIP+ZkaooDYqBqXQkKL9bf42J6TH0G1MXLHdqk5g0NW5syJiNM MZZd+3qXcrhq1fMCi4D2HFR7ILvl5r7WPtOAVrJ1XeUMuVTaXCGsosOYAkPQ4VsFDt3/ ecQgO5vNjNjNYZCnSBbCE30J5gY7ZRXN0yU4U3y6BeDIN9EX/8vdw56vpHfxc/gGoDJB drtKNkS+8hLJN1RsP2Csm0LxiRMt3RzIXHZll+pEdfG0Oh99/8XIQ1zNwVvNEbIcBViE LaOJ5B0futn1P3DRy9v3FNmiTemwsppADdCfXj0nLpx01zYxoaM0EeBEvbMQkS/NUkN5 wnDQ== 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=vzTDyX7gV+9Pj9spQ9FU5sRLP4zi1N75XaMKLf/t/QOLXgnPwoq+TfhHCNgKZMdnrv OdzSxuEC4NPVXS9FycHqBXy01u/xtDv5lTltZQCu/mDGG8XSnyqQkM68a+jt+pUCeC6a rbyuOzc31uRs3D0bTdqCsf4vrTHwWMWJRTPcKATx+Jy3Sq7ORRTxPmhNctsZnt+WvEJX e9XdA65qbBssfFIvP0vFGWZDLvH69HO0LgEomtWVb2Vp38sXB2G2Um57ZL+9K+TXSMJY qSVvIopWHs3VwnRtlJfGITVooqLUbs8Vmgzj6jFl32VWf0YRtc5qXJTss3ddSEDWXGOX +wlw== X-Gm-Message-State: AOJu0YxSdh7+vyQSJpnAYjlnPPVEpkg+T2MCiU1U+utcgw39fHY3AAwz o/joeuyIhlp0BxJTxlu3mWbDCA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785733696618081531 X-GMAIL-MSGID: 1785733696618081531 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; }