From nobody Thu Sep 11 12:52:54 2025 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.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 7E1DC79D1 for ; Mon, 12 Aug 2024 00:59:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424391; cv=none; b=T6Jdg/k/KzZwC1g4xD16bDAjTA/7e6ZdOhh4BVORqpHhpY9pJbFQzCVHKgZU/yvDEjAoWJqL7DFdAYVgCOZbGjo8yTIu+Z4nYcb6SzKIzM9cLnEIWjUdzXsiYeuYjqPWRjHFc9am0RXVsk9q7x0rtqhanB4SUJ+pS0zgKMu+Dqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424391; c=relaxed/simple; bh=C+i0U6VGde+1v9kIi2tE1b1sf1jRuHcxIrWnNcHIpqg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RTqcEwvaHSm9cBm9g5whQJ0WjnVEFz5QXUHMoMVyYxXEEocziS1DGDb7HCH5qHH+VQWI3aADiQSNTZAoozD2tGTU+eo0Xxq176PrhUXO+96S3LRf0RHTLB0++34hUYbr23Ctw6x+oepiSzB/wDARhZuav7Q81f1r7IPVCTb4eCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=kamCaM+0; arc=none smtp.client-ip=209.85.166.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="kamCaM+0" Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-396e2d21812so13818915ab.2 for ; Sun, 11 Aug 2024 17:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424387; x=1724029187; 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=8jeK3ESAUl7YxTE1Iy3jfhVYgTpS15SSq0iPGR06s9c=; b=kamCaM+07fvJ1p7LbpYKhgflBoWCvxULLOfM7e6S02LIjdKKi1ce55qmL222t72HSr +dv5fmTA/STb+AzsNYmgVmpIuBwmNyCQZ1vUyHPu5ZjQ8mLEnK+JhaFzqES1A6tDMiHO 8l66ifZuwPxWY+y9VORbNDjHbbvyLx6JCkd+nDNnonnSZ9Exyp5CPkkk8/+W1TRgleR5 l0QLNajWl9Q3CYRI3VmymVggNZNF4Tz4Zi+WKryu6N1l7xKRwDDzKdpkmPPbFV4IlIdJ 20iAnXdXEMQyuquurlpdWYMW7Zvo3kNvmwifOB8+XotPsk4h4yVbS/F2KeFYx32b8i1z aksA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424387; x=1724029187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8jeK3ESAUl7YxTE1Iy3jfhVYgTpS15SSq0iPGR06s9c=; b=UTvuWI0z4Tar3q6oZ9Bt7EuW8ayeFxbXb2nBY+wyR0YvhqTQSErp8GC4CYxpqnNLs7 hBnzeLatclbjsKOyYXNymDI86FH7q6ilK/3drdPCaLwd1Xu8oo3lT+/Fhp/agssyR8xo rZ1bP16AbRFobLkD5mYSZX+08YALvIpx3TJ/VQXyL0bfTaU4ReLwt3POg9QBJ8F+5AkJ TvY2OyPpcSvI7SavyJqvfT1zXQqXH3V6z9uTwW84clDF4mNeqOUQf0dmKVkah6W2NmSU gniSTOQV85ZJCTvMS3Kdck9jNlbDzbZuB5J/x+At8YycDYWuV1dkSLjk2ZR2TipaEpw/ cGgg== X-Gm-Message-State: AOJu0Yyi5jwjsJhxjZ6FvBFZx0OhA/roB3d5mnU9RE4M1x42PF4MkZJl 2PuceWwUVBwUkjqT2egOAE+/NeLSdcIXEw+39JzYfgL0/5HXHQUPL+oPcb2zdc3K5X4hVG/VfRj ylaAvDQ== X-Google-Smtp-Source: AGHT+IFIiqNGjgTEsTyA01AhWlCd5/qrU642pe+8j8qsMImF8/xohIsj9BzQ1yvF+gyWEF8FJGTC6A== X-Received: by 2002:a05:6e02:1a29:b0:398:81e9:3f9e with SMTP id e9e14a558f8ab-39b813345abmr101145885ab.12.1723424387549; Sun, 11 Aug 2024 17:59:47 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.17.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 17:59:47 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 01/17] arm64: PCI: Migrate ACPI related functions to pci-acpi.c Date: Mon, 12 Aug 2024 06:29:13 +0530 Message-ID: <20240812005929.113499-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The functions defined in arm64 for ACPI support are required for RISC-V also. To avoid duplication, move these functions to common location. Signed-off-by: Sunil V L Acked-by: Bjorn Helgaas Acked-by: Will Deacon Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- 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. */ =20 -#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 =20 /* * 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); =20 #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 =3D bus->sysdata; - struct acpi_device *adev =3D to_acpi_device(cfg->parent); - struct acpi_pci_root *root =3D 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 =3D 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 =3D NULL; - else - adev =3D to_acpi_device(cfg->parent); - - bus_dev =3D &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 =3D 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 =3D &root->device->dev; - struct resource *bus_res =3D &root->secondary; - u16 seg =3D root->segment; - const struct pci_ecam_ops *ecam_ops; - struct resource cfgres; - struct acpi_device *adev; - struct pci_config_window *cfg; - int ret; - - ret =3D 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 =3D 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 =3D 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 =3D 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 =3D kzalloc(sizeof(*ri), GFP_KERNEL); - if (!ri) - return NULL; - - root_ops =3D kzalloc(sizeof(*root_ops), GFP_KERNEL); - if (!root_ops) { - kfree(ri); - return NULL; - } - - ri->cfg =3D pci_acpi_setup_ecam_mapping(root); - if (!ri->cfg) { - kfree(ri); - kfree(root_ops); - return NULL; - } - - root_ops->release_info =3D pci_acpi_generic_release_info; - root_ops->prepare_resources =3D pci_acpi_root_prepare_resources; - root_ops->pci_ops =3D (struct pci_ops *)&ri->cfg->ops->pci_ops; - bus =3D 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 =3D pci_find_host_bridge(bus); - if (host->preserve_config) - pci_bus_claim_resources(bus); - - /* - * Assign whatever was left unassigned. If we didn't claim above, - * this will reassign everything. - */ - pci_assign_unassigned_root_bus_resources(bus); - - list_for_each_entry(child, &bus->children, node) - pcie_bus_configure_settings(child); - - return bus; -} - -void pcibios_add_bus(struct pci_bus *bus) -{ - acpi_pci_add_bus(bus); -} - -void pcibios_remove_bus(struct pci_bus *bus) -{ - acpi_pci_remove_bus(bus); -} - -#endif diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 9cc447da9475..8ed81a373bd7 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1541,3 +1542,184 @@ static int __init acpi_pci_init(void) return 0; } arch_initcall(acpi_pci_init); + +#if defined(CONFIG_ARM64) + +/* + * Try to assign the IRQ number when probing a new device + */ +int pcibios_alloc_irq(struct pci_dev *dev) +{ + if (!acpi_disabled) + acpi_pci_irq_enable(dev); + + return 0; +} + +struct acpi_pci_generic_root_info { + struct acpi_pci_root_info common; + struct pci_config_window *cfg; /* config space mapping */ +}; + +int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +{ + struct pci_config_window *cfg =3D bus->sysdata; + struct acpi_device *adev =3D to_acpi_device(cfg->parent); + struct acpi_pci_root *root =3D 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 =3D 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 =3D NULL; + else + adev =3D to_acpi_device(cfg->parent); + + bus_dev =3D &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 =3D 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 =3D &root->device->dev; + struct resource *bus_res =3D &root->secondary; + u16 seg =3D root->segment; + const struct pci_ecam_ops *ecam_ops; + struct resource cfgres; + struct acpi_device *adev; + struct pci_config_window *cfg; + int ret; + + ret =3D 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 =3D 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 =3D 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 =3D 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 =3D kzalloc(sizeof(*ri), GFP_KERNEL); + if (!ri) + return NULL; + + root_ops =3D kzalloc(sizeof(*root_ops), GFP_KERNEL); + if (!root_ops) { + kfree(ri); + return NULL; + } + + ri->cfg =3D pci_acpi_setup_ecam_mapping(root); + if (!ri->cfg) { + kfree(ri); + kfree(root_ops); + return NULL; + } + + root_ops->release_info =3D pci_acpi_generic_release_info; + root_ops->prepare_resources =3D pci_acpi_root_prepare_resources; + root_ops->pci_ops =3D (struct pci_ops *)&ri->cfg->ops->pci_ops; + bus =3D 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 =3D 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 --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.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 A8CEBD272 for ; Mon, 12 Aug 2024 00:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424397; cv=none; b=X0eLHVG5vSF3bYSvryWxEIQml+dld3uQUbU6pXWmW8NVPkBmKbQDxg+IrPZpkae029vEdNZUo8UOqRlT/QRnFAcV55hE4Ug5Joo5A7lB+Bd8ANN8UCWsMj63X02x+wO8pK0Idu4DIpFPLTNIaJyVr8QYCS+TYs2lDjaEdeziO18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424397; c=relaxed/simple; bh=nknKRePYpstHJXNT0D7LVZ4HEWBMbMCFh+6ycmonEIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Eq2z1/zLE3Cl3q7yv4HWF+9q6oloUSyjx1R1zjgYRsV+iNUwGHFLl43/Qq57KGG3RWG1S1Snk1qEguOGyoQCw6xXkKK0J8SYknAfP0A44TRh4GGrvZ6eUqUmfFiBtz1jz4vaFHDmbD7FbBiFdsJI5yzAQ/ttSVpRw5ZUhztw8LI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=MMGNp8/d; arc=none smtp.client-ip=209.85.167.180 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="MMGNp8/d" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3db1e21b0e4so2817312b6e.2 for ; Sun, 11 Aug 2024 17:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424394; x=1724029194; 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=cDiQZULOrmkIQ76w8p/0qXlEheAvD+F8k2bdCW40Dj8=; b=MMGNp8/dEZHz8D5kZ8z2Hz0TfkLDcuWmIXTjiCNqi8epkJ42bmpNeyv3WUVS1cFEa0 9aGgjK+vErnROmR6V6MDkgf0Wcn/nh0zq8Qfj2dAFAnLzFOPw9GicZWvrFL8nvZ0ecNj Fgs+8fk4ooBbymzCfWPme/REfRRMlp+NXYwbYL33hUwZIuR0VjLh8N7Cb7kG5anzjPbx yhlncVaPecmtBjOklGzwDXv5ZKG2s6PZQ0P9m1tUMzywp7lMX+2XrNp/W8HuuDrEP4Tl 4PC5DpFduJCPq5Yfhvvb0PJXCFbGvzyWdwHWhqbpGTG9NLR6GGumxlmsmY20CTCw5Iyh Vajw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424394; x=1724029194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cDiQZULOrmkIQ76w8p/0qXlEheAvD+F8k2bdCW40Dj8=; b=hy3mEOfnxeoKBkD6CIfxrL0qW9itMZjEyZU9NdklzZytfECyc7O/vCYl6CIy4FySWW PFcMLNYB4XJW6zGOgWcLr0vLhZt/nxWtzujE1PCKP7NCday26QBAw5ky5spxF9TmvnJ4 /FHNWD1RFF17v7/wRCyfAZKqtAVJQJ72ixrKE0llsQD1UQk807+q93z8QZ6KKQclE7Sa /DVYasIReXgxszxJjg74XOCMouoRms637nPh43VJOLAmU/6JA0t5rHycY+5+RjbC4LWd pQ8hxEJZiBgLlkwQ0tmUPvDoZLD6bUKYaVWYTe3UZ2G9X+6RaaLUNEAt81fqJllQU4Ui Zlrw== X-Gm-Message-State: AOJu0Yw5UZ475CexZoY2m5DnawwAXYGbpNZriuMaS8ort2XyzOjsC+lV XnrxWiNs48PLtFrY/M4TNrO4nyFdDAylmrgd9mYkxrXwdxbLZdKEjw56S6bqwMQyENNKMxbPxPD IsVm8Ng== X-Google-Smtp-Source: AGHT+IFZ+1tDJ3142HVFsLE4ya3SPYZxnEcsV+61Xh8a+xb4OPG7zVmGoKf++d88AMIRm4sWlhcOOQ== X-Received: by 2002:a05:6808:2185:b0:3db:fe8:f744 with SMTP id 5614622812f47-3dc4168aac0mr9047447b6e.24.1723424393786; Sun, 11 Aug 2024 17:59:53 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.17.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 17:59:53 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 02/17] ACPI: scan: Add a weak arch_sort_irqchip_probe() to order the IRQCHIP probe Date: Mon, 12 Aug 2024 06:29:14 +0530 Message-ID: <20240812005929.113499-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Unlike OF framework, the irqchip probe using IRQCHIP_ACPI_DECLARE has no order defined. Depending on the Makefile is not a good idea. So, usually it is worked around by mandating only root interrupt controller probed using IRQCHIP_ACPI_DECLARE and other interrupt controllers are probed via cascade mechanism. However, this is also not a clean solution because if there are multiple root controllers (ex: RINTC in RISC-V which is per CPU) which need to be probed first, then the cascade will happen for every root controller. So, introduce an architecture specific weak function arch_sort_irqchip_probe() to order the probing of the interrupt controllers which can be implemented by different architectures as per their interrupt controller hierarchy. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/scan.c | 3 +++ include/linux/acpi.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 59771412686b..52a9dfc8e18c 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2755,6 +2755,8 @@ static int __init acpi_match_madt(union acpi_subtable= _headers *header, return 0; } =20 +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 =3D 0; @@ -2763,6 +2765,7 @@ int __init __acpi_probe_device_table(struct acpi_prob= e_entry *ap_head, int nr) return 0; =20 mutex_lock(&acpi_probe_mutex); + arch_sort_irqchip_probe(ap_head, nr); for (ape =3D ap_head; nr; ape++, nr--) { if (ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) { acpi_probe_count =3D 0; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 0687a442fec7..3fff86f95c2f 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1343,6 +1343,8 @@ struct acpi_probe_entry { kernel_ulong_t driver_data; }; =20 +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 \ --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 C9FA31170F for ; Mon, 12 Aug 2024 01:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424403; cv=none; b=mfcw1O7yaqa1C8N+ZImu80x4J9xlQWcVOgIqHwwBWOJwFn2npbjhk8iFKoZKISsFPEHVRDdg6YX3aFUs9EuGawj98hK8gcF8l/YJagEL/dMCHGRdnI6c5FLz0j/V0VszwFQ3wNAVZh+F96UJc+qXYjDDP8/W8+pxzM+Pw4kTHMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424403; c=relaxed/simple; bh=/NjNF2gM7TvKKHeRf2SUhc4H3zCep0Sq72OK0O5um8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MK6/Q//RqY76QcRvXAYdFsq8Ts9UJS9koxdKprLlKifZzwcmzqzFGy9g7uK+MoB4fbUEwQKOHCcHTNjepTKRehS4AdE9+NDIPxhoDnu9bt5iiEms4ceqFnvrMrnEeZi1p+ov1JKeKdi7NAFhG81xxeWq58EfcvR5yc8wf2bLaCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=ivTerrKN; arc=none smtp.client-ip=209.85.210.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="ivTerrKN" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-709346604a7so1610574a34.1 for ; Sun, 11 Aug 2024 18:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424400; x=1724029200; 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=kH+4pIB9prP9kOEprexbBfphBFyJQXg0yq2xsmagq1s=; b=ivTerrKNNS6WArC5x33F/kCeZPN5TzZe/Ir6m3js0N7gW5mNsEqnnXvkz4B+5n7kk0 lWSCZ69kwuVYIv7/TtNBu5q5JQUWOTd0TgpVr9mGW3LMQXw3G3Ax7BymOheqMySmzitE M1OWrJ1F1906ltefFffZW11duYc5+AlpAUqtC2ZqmJecDRxoP33Kr+V2upaefQ1KK5tc IOtfTbyBDG43QG6ZP5wN8fqK+wpaGSkHw6YXXz4HoHSDpqU44G06WVfk/zh14pvX3GuA le4DPF4SPkfX8nhELfo5i7+/na2evVuHgKBDgtuNtBAEuAsTrjosVFL/Gs6tL1ptMAr1 bGIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424400; x=1724029200; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kH+4pIB9prP9kOEprexbBfphBFyJQXg0yq2xsmagq1s=; b=swePLRUMRDDECAjsn6YAC5eL5MuWBg+jplGs03wdS8fXKD4eHvxHRUr5tkywFv6ldK gzv4LV73VV0ihuYvYD8KBk7T2bFCkU0LopXLkb1zjK+eBdh0m7k1c9CmbxT4JIplggK2 LdpCtkZWYRE4OULRqAbUj7bowRsk2B5DZ4kV/zgTNLVW750r+//uAOTecDrzwnn9FeHm JS3gIznUA2sgQPZTt0aTBnpZDwvyhykslTkMqOLta9MhEaWuc8meoP0lXbW7LjsByOs/ VKmyH9FEOaHwZXQBaKcQPRA9f4WdlI94v/f15rlW1lhvnTkTR1J9lluQdIpga1WQwU5+ HJjA== X-Gm-Message-State: AOJu0YwSTovaGzVPY1/vcFx/AlEqkk47TQoZCLFhIR4G1ZVejbW/K1z1 JignhGs1drIM5oKEKMK7O+TdsDQq3P3+ZZR/UXHD/JS/xT3NgMlc9870jwJGJLF4FT6TpoMrwqw g+1r/EA== X-Google-Smtp-Source: AGHT+IHrAlknP9L5C6h6kRrSytyVyD8ukh4CBeZCWs5vO7PGS1mxPUN26YUu6El93VBg0yE0hzkTrQ== X-Received: by 2002:a05:6830:6c0f:b0:708:8c07:c646 with SMTP id 46e09a7af769-70b748745c5mr11624369a34.33.1723424400027; Sun, 11 Aug 2024 18:00:00 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.17.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 17:59:59 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 03/17] ACPI: bus: Add acpi_riscv_init() function Date: Mon, 12 Aug 2024 06:29:15 +0530 Message-ID: <20240812005929.113499-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new function for RISC-V to do architecture specific initialization similar to acpi_arm_init(). Some of the ACPI tables are architecture specific and there is no reason trying to find them on other architectures. So, add acpi_riscv_init() similar to acpi_arm_init(). Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/bus.c | 1 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 11 +++++++++++ include/linux/acpi.h | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/init.c diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 284bc2e03580..48d277657203 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1459,6 +1459,7 @@ static int __init acpi_init(void) acpi_hest_init(); acpi_ghes_init(); acpi_arm_init(); + acpi_riscv_init(); acpi_scan_init(); acpi_ec_init(); acpi_debugfs_init(); diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 86b0925f612d..877de00d1b50 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y +=3D rhct.o +obj-y +=3D rhct.o init.o obj-$(CONFIG_ACPI_PROCESSOR_IDLE) +=3D cpuidle.o obj-$(CONFIG_ACPI_CPPC_LIB) +=3D cppc.o diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c new file mode 100644 index 000000000000..a875a76aa44c --- /dev/null +++ b/drivers/acpi/riscv/init.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023-2024, Ventana Micro Systems Inc + * Author: Sunil V L + */ + +#include + +void __init acpi_riscv_init(void) +{ +} diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 3fff86f95c2f..892025d873f0 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1531,6 +1531,12 @@ void acpi_arm_init(void); static inline void acpi_arm_init(void) { } #endif =20 +#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 --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.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 10D051170F for ; Mon, 12 Aug 2024 01:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424409; cv=none; b=NSQAVfNgl9WcGc5y3WD4NlXSPKQStzGkVrrORofj1EAuqPHkPIE40BkDzpJZWIR65/lToi4fYFlzsHx9ykoQY/MD0Rk/Y0cZP9nji9eUFihsw3PSsTMiB6wvfEjxesWgteTKXOYaK5z+3VxI1npo2KOh8zjqzRYIAk9sL32MBgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424409; c=relaxed/simple; bh=K0yy2Cz0AHQ22O/DOvVoBVInCMziuYu5zVI87ewmQhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ixty/m8bEbkgZ1rtIoI+YlZYceRitC9feA5Ymv4JcbPVd0rPXHaK9wSMPfyUTF7xPOyhErbKhxAKT4LuotKaSL5buCmeTXndg+O+tLRKGLL4/IhvLhhJ65ecq1nriV9+9Cn3HwmBmRBwkjSVn5poH8XGq3JMg0lb+AAjhmPhI+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=DPupl6mD; arc=none smtp.client-ip=209.85.167.180 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="DPupl6mD" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3db16129143so2265761b6e.0 for ; Sun, 11 Aug 2024 18:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424406; x=1724029206; 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=Fg7MKJMwlR+eRmszvFqgWwl0l7xFjetJlLXQ4McHDXI=; b=DPupl6mD8Li0+PwzeoZ7ghDCDT26Mm/9JDUve1DG4jAEnOhonmr4D8Nayk1fdZ3WAc E36uSB4R0LsyqY45B6MSGq/xCWZKrjXDWe/2ekB0CPf57t0Og2Jd71n9Ngn8T7iKJYj4 HTkotHhuhcRS+5bUAHZsrMCoCI++JF4S40u4hyZYlRDjFieRQGmoCmVvF8BLq0G3mQhJ EKQWXOevBD8/+SkLP756ywzuA1HpX6Z8MhqLNHZMU5hXyIu+y3Xh4ZfQFzVIYb6I6VWu ZlXyQyy55dxyAAeFo33Xzu8Ea4e6I8+FcdL9oH4gSlNpWjGoEMEkvduEGHaiRT2BsUKS /+/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424406; x=1724029206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fg7MKJMwlR+eRmszvFqgWwl0l7xFjetJlLXQ4McHDXI=; b=KQKiW4kWmDLca4G1RVmFGiYaZ0Cq0+KXo3eU6/qMVkInDeBacd0I6GgDLqMZyVC+PW pJgjMqF5C0ZT1jqXrci4LtfS8l6pcpukI/aDet7WrMpoTTczDySB6Gu9nrQnC/8/8oxC j+WAVrxbfnk69193AFkWt+wCChJO6XWIkTSsRCIbTptT+BcaJS1GLR+iSlE69RunUxsb fEdqHwLW03BntUzBM/8dFxSBO9+z3iwt4aucofdccu6B56F4arZA8em3tyj4SjUEHoWB NrRaSPcDzbAiPDqRIVDXn1GCHFmHYS9tWcByydq/t4X7mj6paFn6Cw5S/DWuh3Xaovrg vhxg== X-Gm-Message-State: AOJu0YzVwuTojUsV1pmTGmDgiPWNfGDnlEJ6NkxTfXjUQ8qe5YXDXF76 0ENwd0Ctet0unLFu6AfJP0eDdGVL4EJnhC5z154VfXmFAC+L9PSl7pCQ5d/d72TLU5o6R85w83D Glf3Ogw== X-Google-Smtp-Source: AGHT+IFq/2aqIFIbaZVtORXZ4ma22Wclt9l+I9epH3oTGlfkp+sVOBf6L7LmmBy3q6/DeC+M+tbDQQ== X-Received: by 2002:a05:6808:3a07:b0:3da:a16e:1764 with SMTP id 5614622812f47-3dc41667c8fmr8781731b6e.4.1723424406285; Sun, 11 Aug 2024 18:00:06 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:05 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 04/17] ACPI: scan: Refactor dependency creation Date: Mon, 12 Aug 2024 06:29:16 +0530 Message-ID: <20240812005929.113499-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some architectures like RISC-V will use implicit dependencies like GSI map to create dependencies between interrupt controller and devices. To support doing that, the function which creates the dependency, is refactored bit and made public so that dependency can be added from outside of scan.c as well. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/scan.c | 86 ++++++++++++++++++++++------------------- include/acpi/acpi_bus.h | 1 + 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 52a9dfc8e18c..374cae4aef78 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2013,6 +2013,49 @@ void acpi_scan_hotplug_enabled(struct acpi_hotplug_p= rofile *hotplug, bool val) mutex_unlock(&acpi_scan_lock); } =20 +int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_dev= ices) +{ + u32 count; + int i; + + for (count =3D 0, i =3D 0; i < dep_devices->count; i++) { + struct acpi_device_info *info; + struct acpi_dep_data *dep; + bool skip, honor_dep; + acpi_status status; + + status =3D acpi_get_object_info(dep_devices->handles[i], &info); + if (ACPI_FAILURE(status)) { + acpi_handle_debug(handle, "Error reading _DEP device info\n"); + continue; + } + + skip =3D acpi_info_matches_ids(info, acpi_ignore_dep_ids); + honor_dep =3D acpi_info_matches_ids(info, acpi_honor_dep_ids); + kfree(info); + + if (skip) + continue; + + dep =3D kzalloc(sizeof(*dep), GFP_KERNEL); + if (!dep) + continue; + + count++; + + dep->supplier =3D dep_devices->handles[i]; + dep->consumer =3D handle; + dep->honor_dep =3D honor_dep; + + mutex_lock(&acpi_dep_list_lock); + list_add_tail(&dep->node, &acpi_dep_list); + mutex_unlock(&acpi_dep_list_lock); + } + + acpi_handle_list_free(dep_devices); + return count; +} + static void acpi_scan_init_hotplug(struct acpi_device *adev) { struct acpi_hardware_id *hwid; @@ -2035,8 +2078,7 @@ static void acpi_scan_init_hotplug(struct acpi_device= *adev) static u32 acpi_scan_check_dep(acpi_handle handle) { struct acpi_handle_list dep_devices; - u32 count; - int i; + u32 count =3D 0; =20 /* * Check for _HID here to avoid deferring the enumeration of: @@ -2045,48 +2087,14 @@ static u32 acpi_scan_check_dep(acpi_handle handle) * Still, checking for _HID catches more then just these cases ... */ if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID")) - return 0; + return count; =20 if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) { acpi_handle_debug(handle, "Failed to evaluate _DEP.\n"); - return 0; + return count; } =20 - for (count =3D 0, i =3D 0; i < dep_devices.count; i++) { - struct acpi_device_info *info; - struct acpi_dep_data *dep; - bool skip, honor_dep; - acpi_status status; - - status =3D acpi_get_object_info(dep_devices.handles[i], &info); - if (ACPI_FAILURE(status)) { - acpi_handle_debug(handle, "Error reading _DEP device info\n"); - continue; - } - - skip =3D acpi_info_matches_ids(info, acpi_ignore_dep_ids); - honor_dep =3D acpi_info_matches_ids(info, acpi_honor_dep_ids); - kfree(info); - - if (skip) - continue; - - dep =3D kzalloc(sizeof(*dep), GFP_KERNEL); - if (!dep) - continue; - - count++; - - dep->supplier =3D dep_devices.handles[i]; - dep->consumer =3D handle; - dep->honor_dep =3D honor_dep; - - mutex_lock(&acpi_dep_list_lock); - list_add_tail(&dep->node , &acpi_dep_list); - mutex_unlock(&acpi_dep_list_lock); - } - - acpi_handle_list_free(&dep_devices); + count +=3D acpi_scan_add_dep(handle, &dep_devices); return count; } =20 diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 8db5bd382915..d6a4dd58e36f 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -993,6 +993,7 @@ static inline void acpi_put_acpi_dev(struct acpi_device= *adev) =20 int acpi_wait_for_acpi_ipmi(void); =20 +int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_dev= ices); #else /* CONFIG_ACPI */ =20 static inline int register_acpi_bus_type(void *bus) { return 0; } --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 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 5AC1117BAA for ; Mon, 12 Aug 2024 01:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424415; cv=none; b=CyqtyeSEzt8KHvHUSS4Xw3W3niFiTAjUnhMKHhle/LoEyWMscHOorrwC+cyOoniaKrEa9eRJNVfp/+ECzB/KQkIO76xRawTCuhsgBYEpOfwtp6+9PJH3KWKoYQUZvCbqqV2oqh6qRRct7BdI1lWB/vUvTMYIotuY4TClo4HHTXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424415; c=relaxed/simple; bh=Vcq+n8JQdTk3vmf6hqmLO7PiXIRS5Btk4ojcnv75rJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IIb8CXr42zScDRh2ARxaYFhDEGYSrZWx4CvxOnuv2WeIkra0IKEq6HOoEdK/84AQvebPlnjACyxpVoSRtCsI4EihmEfKAJLM1gPbY9aAnB2TTTHbxVDoMgKt2iiV/SHLfeLqsnLECi/s3Ny0WanaFBJfy4ZqZKkrN6UaA22mKiE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=GNNcUdik; arc=none smtp.client-ip=209.85.214.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="GNNcUdik" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1fd65aaac27so32127405ad.1 for ; Sun, 11 Aug 2024 18:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424413; x=1724029213; 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=uJwTiJ9RwivJpxYHWXKjwIEWKuv7B7ooXczAECPccKA=; b=GNNcUdikKsWtnzLHTFz4yF7DfWuZtjqDRc4cvfjQsyu9qRcL6ZZ/E3rb2eYGfkYqsW YIHPfeeKa6vTZ7dgD2cFQGACQ1NW+HJDBzy6oF8tKpPTH5DOCatpknaOLwF6Ou9ifKU9 6k1KkH0H44jFAf30Cm/xocA8PLZRq87DmXRpD+4dehf5/btReVM/vB37uhP++Uk/Cg6D yuICpdolKl4tx4kAp0xrpahfBGbOg9Wp52GtMVl2tfXuJCkAXRNIaDnnOic37FmSukMi 9ysjltXUN8vGKVCwzWQGLnCZlqRZyXQXfUWnEYu9eGRQkTtQX9aEqliJrQed6OuRopJa nQwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424413; x=1724029213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uJwTiJ9RwivJpxYHWXKjwIEWKuv7B7ooXczAECPccKA=; b=eqPj+XZTJqUu7S4dN70B+GuheRoOUX9ZZF1a7Jb8+f6oUtH9UxK2R10AR+g8p9+NOo HiLHPvWIZ2qJi+ZMman14u03Gk0Ox6XAqVcGfn8DAJ5jJBv+OieU+yPssEWvzETPL1w8 b1HcFKBUtmelHQ9jCtwk/e4gBVgUEVKHV7XZ68pvKpigNOlf2O536tm8hVd6UA015J8c nW2ufyjD2YCulGTFstOyz729vsw6iH5+rzFN+m3VaKWxb/HLtJjtOVKecjO6Pn3Rmd9o o2FcGbJSrX2Wb460tzAqwHHdu37GBIvKm4M5+8R5kuyBDfhI9Ot27qztm/n9qZoqboFp L5fA== X-Gm-Message-State: AOJu0YyZojFGjbsj0TPp+903k6hbGVj2w+cArBz0wutmKwskOitOPul7 hnl9BUBvuMyuNf7bEtzBjwim+BUxsNVlgQIlFI2k86jBC3saf8XxU1EOxzwgBe0/2oCe1Z8OpP/ ioiZesA== X-Google-Smtp-Source: AGHT+IEe5Qz6cd7b/1zBihHx5AlfGtYBeT8sDhSQ+DFn35gv+sWFK8VgaNh+IQbBrU4whiezDiQL7g== X-Received: by 2002:a17:902:e5c2:b0:1fd:8f7b:1e88 with SMTP id d9443c01a7336-2009681bff6mr206131935ad.12.1723424412492; Sun, 11 Aug 2024 18:00:12 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:12 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 05/17] ACPI: scan: Add RISC-V interrupt controllers to honor list Date: Mon, 12 Aug 2024 06:29:17 +0530 Message-ID: <20240812005929.113499-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISC-V PLIC and APLIC will have dependency from devices using GSI. So, add these devices to the honor list. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/scan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 374cae4aef78..39b3ccae9f79 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -861,6 +861,8 @@ static const char * const acpi_honor_dep_ids[] =3D { "INTC1095", /* IVSC (ADL) driver must be loaded to allow i2c access to ca= mera sensors */ "INTC100A", /* IVSC (RPL) driver must be loaded to allow i2c access to ca= mera sensors */ "INTC10CF", /* IVSC (MTL) driver must be loaded to allow i2c access to ca= mera sensors */ + "RSCV0001", /* RISC-V PLIC */ + "RSCV0002", /* RISC-V APLIC */ NULL }; =20 --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.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 135E079F4 for ; Mon, 12 Aug 2024 01:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424421; cv=none; b=Ur/zes86f6a69QVOZf+D5ePBO1sNCVdtHg7RL76RU0rjN0JoPVyCqkXa/8Hm9Ny3za3Ku9BC/QJ8fEPx3rD7rQSGGf++I1pb1jUSWbTgttyw0Pz4clwpBT9xZ7hH30etxja9Wu6um5EZki4ZBsXbwzJzumY784elCrnHppPkk9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424421; c=relaxed/simple; bh=zrv9AUs5Cq6Bk8OZWZZlXW2L//FNGQ0gb5DlOwPjduA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LcL6tEcm64zkFJHhgc8ubqZypeaw3B9fUvo7zQ4dMvfYMkTkLfj7dmnG/wQqf1gIYzC3Jqd31xfHaaT8u09zmprHtqmrirDlaYCbajV6owUUN8psZDFBXQAaYdoRBp0TDwxCFMAYD2ylEqINW6IRveLAb+Z7zMIirO22WyS8Fis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=YHx7co6s; arc=none smtp.client-ip=209.85.167.171 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="YHx7co6s" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3db1270da60so3095362b6e.2 for ; Sun, 11 Aug 2024 18:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424419; x=1724029219; darn=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=iVnO8D9tH0sab/WeUvbej3ReIYXoTsQSEaRkiw5yKWo=; b=YHx7co6sHpUhq1irkKooz/97Yu9EZO47IUDT09vvzthBbZbNLgxoi46eqnCIfsDwLc C/hoECDXahxGmjxdNhZ6PAUVS+rdR1dOhvKSocV0gh64niVOy44xAgIL3mGCqRCH1Xrd 6Fiec4ORlELvXXCdMBd8x2EOuwhzGa1V8nPsQCrtd/wJpSMZEtkKwmhdGnJUCRBixI7y otUvO857yl00YeEDM336Gp8HC2LIMcN3Dg5ZLzswfMaT4AVUv1hgnX9Tyiqg3XyZpSp/ WqCKqxlblEPvSbqYV5eX1NwYtkNe/cZsg8LmPsIvZpXy4QpYgea/K7YMFNMQ8W7QVUgF 7KQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424419; x=1724029219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iVnO8D9tH0sab/WeUvbej3ReIYXoTsQSEaRkiw5yKWo=; b=sFecMkoik4dZ0KlY5O5FAOjtnfsvRT1n5tih5LpH4gBsH0ONTxKt2VhvxJmjemLetA OgnvnqY8/h9qHnFkk34OQnOfYynlfsLz4IxvX9oBCcXYBn2WryyKfLD+nk07ruWvnwFS uKi/yAdXFcY2qmkyo/uWzYY7oewrFApTHLiF5y8aAy2a/wEpIPdpCGtRKRSEV5wceDuk b6fOdEtOM9iiTNErO21hQp1Xaq3ZlfpLog3ogmvthMm8dIRTr9ciWlXpoY/wexfjKWlg l0mzwKCC+tQlgWYIDR5K3lC1EHpGvWomLeVQ1GEuTvKYL74bGY8tMxtoGDMVcibuEhAi uFZA== X-Gm-Message-State: AOJu0YzmTXDErn7pOqVdsnvD0avMMGIbLuKINKv1j3Dtxen2dAWEZxFJ tM15hLKgEavT0TUETpfDVXbHAqBoxdW6ilX5YkY7yrYNDkQwm5Z7jv2eVoQ5q6dSPluA9mxvCly hVbmv/Q== X-Google-Smtp-Source: AGHT+IGgnQrX14dxOj3yn291622Lxvm1iCgbP6yN6u9XpX8bxmUnRZf2Nt8a7HJ6YawHB1+ioO6EHA== X-Received: by 2002:a05:6808:1513:b0:3dc:299d:c4fb with SMTP id 5614622812f47-3dc416ec02cmr12205900b6e.40.1723424418770; Sun, 11 Aug 2024 18:00:18 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:18 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 06/17] ACPI: scan: Define weak function to populate dependencies Date: Mon, 12 Aug 2024 06:29:18 +0530 Message-ID: <20240812005929.113499-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some architectures like RISC-V need to add dependencies without explicit _DEP. Define a weak function which can be implemented by the architecture. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/scan.c | 11 +++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 39b3ccae9f79..28a221f956d7 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2077,11 +2077,22 @@ static void acpi_scan_init_hotplug(struct acpi_devi= ce *adev) } } =20 +u32 __weak arch_acpi_add_auto_dep(acpi_handle handle) { return 0; } + static u32 acpi_scan_check_dep(acpi_handle handle) { struct acpi_handle_list dep_devices; u32 count =3D 0; =20 + /* + * Some architectures like RISC-V need to add dependencies for + * all devices which use GSI to the interrupt controller so that + * interrupt controller is probed before any of those devices. + * Instead of mandating _DEP on all the devices, detect the + * dependency and add automatically. + */ + count +=3D arch_acpi_add_auto_dep(handle); + /* * Check for _HID here to avoid deferring the enumeration of: * 1. PCI devices. diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index d6a4dd58e36f..af72a5d9de99 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -994,6 +994,7 @@ static inline void acpi_put_acpi_dev(struct acpi_device= *adev) int acpi_wait_for_acpi_ipmi(void); =20 int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_dev= ices); +u32 arch_acpi_add_auto_dep(acpi_handle handle); #else /* CONFIG_ACPI */ =20 static inline int register_acpi_bus_type(void *bus) { return 0; } --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (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 0E4D51CD24 for ; Mon, 12 Aug 2024 01:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424428; cv=none; b=ndl4trQB5jkd4S/bgqg8hL/oyN7jXUQ/9xo5xILvRUmv5cq1wEua92TB2HcAUNqxm22ncvsU3yaEkKWaV9h25S7Vf8e7H/fq/qmJswU6NuNz2MoKPMq+5sDkLIi7LXa21VCLhCkcunKWj9TPAWvQ7b040lmN2z8my0W1U1f1zBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424428; c=relaxed/simple; bh=8EwPwWa3yJI98774dHhpFkxvDEk2uSVsbNpCxj1n9SY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O3wJXk8QCVRvlvcKIxEz7l/UGN2+h+1EdKbz8llaVW1As1CEP/TeDCCUCoSGYXHYrEfu+atCG6pjD5Y/Nmyr4c5Tx06SKTZwo8A/KIKEcbS3PEaXdG93blM6QWnlGM7QALK++6lYYVM9fL2InGcpP/wXnoUvedKyO9QK7Umczno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=J+GnryFQ; arc=none smtp.client-ip=209.85.166.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="J+GnryFQ" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-81fd925287eso150017539f.3 for ; Sun, 11 Aug 2024 18:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424426; x=1724029226; darn=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=pBzMby0USGxgSPaQIBT4AQA8EH7Ak7bVCmTWfoSfRt4=; b=J+GnryFQ7i9JXCza3j1/+/bvPi+QD4mssQVagEriBiMRPEKEU0BGTlXYtKSzTN+2+V HzF4Ip+IWmL43dOZND1PzFdVypHXNSXfSAQT7xRlLZS3BPECFD+rXQ4zWqm6Wx6tceYg 6H6oS7JKDyVC4Z1cqg1C9OeoX+33SjyZs4kasH0IDl1eaEdpgWmAP8Q8MeDRwUyBX+Vx xi7h0STdfH1rVHQDcvFZUfWMqX0KfdTuzd3IlSg/11xynRM5XdAnBI80muzuWmoOS2LW I1wf6pbGGqUuiiRnaZOvFP7RMoi3kVkIZVBB/dwwclwKVYXdAeWN9rKfuPokDif0cGYc tlUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424426; x=1724029226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pBzMby0USGxgSPaQIBT4AQA8EH7Ak7bVCmTWfoSfRt4=; b=m/cm25mQpYdNx8wLH9Rv9KW8kn18n0HTF0xsn2vrpLAkt2b85f+jcGHDbthP1q8XPL 2XdWRP0Ayigp4SmFROUTCFfa9T5qvjbxRz8a2z4a3qQf+Z5Y8vci5SbjfGyPtkifolbJ yhbSYJXOgcWRydXGPEoE5HYfqAiq3haoKFcM3u/y5AisvjAflGapQHFKn/ydYmtTLKLN am2II78EiMP/MpZ+k3Tg9HJpIQVFRqnantNIPUQ3LJjpy8j2Qut5BDx2446Ku0T+5t3N zVQL/6IvDERX05fVm3W5ASKKW5xOps6ayBA9ri2hC0613XXcmCkIKPeXeeE8qNbNbMMK qPig== X-Gm-Message-State: AOJu0Yzqw2dRokJxDf21BoH7roOZdBOgNmt33H71glgEWCoD5C9HYEnq h4Tu1UM2J6X9t6HHC9eqzFfN2kMu0bq22LZfe6HINBcaIcjyd0eIn0eoOxCWg1nDi03I85fIdRh ZKn4cOg== X-Google-Smtp-Source: AGHT+IGLgGjZy1f4lXkyD9IeGxkMxZC7bl0GKZ86dlIJhEZNBpnAOTW5ak8/coJIxlUXH7m3lfD9qw== X-Received: by 2002:a05:6e02:20c9:b0:39a:ea4c:8c26 with SMTP id e9e14a558f8ab-39b7a475a0amr105191515ab.1.1723424424986; Sun, 11 Aug 2024 18:00:24 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:24 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 07/17] ACPI: bus: Add RINTC IRQ model for RISC-V Date: Mon, 12 Aug 2024 06:29:19 +0530 Message-ID: <20240812005929.113499-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the IRQ model for RISC-V INTC so that acpi_set_irq_model can use this for RISC-V. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/bus.c | 3 +++ include/linux/acpi.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 48d277657203..16917dc3ad60 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1203,6 +1203,9 @@ static int __init acpi_bus_init_irq(void) case ACPI_IRQ_MODEL_LPIC: message =3D "LPIC"; break; + case ACPI_IRQ_MODEL_RINTC: + message =3D "RINTC"; + break; default: pr_info("Unknown interrupt routing model\n"); return -ENODEV; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 892025d873f0..3a21f1cf126f 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -107,6 +107,7 @@ enum acpi_irq_model_id { ACPI_IRQ_MODEL_PLATFORM, ACPI_IRQ_MODEL_GIC, ACPI_IRQ_MODEL_LPIC, + ACPI_IRQ_MODEL_RINTC, ACPI_IRQ_MODEL_COUNT }; =20 --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.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 6ECE8225CE for ; Mon, 12 Aug 2024 01:00:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424435; cv=none; b=qArYgg9DRSuf52R65Z8TAQYTa7L2J4EIokRTV1iiZYNLf8Oz/xutjyPw7GOZcBm2Ld5jVYO19wH3eapottJGpMXwzw0ioeFTaPhGlhmL+A+XWXVnCFQG/+06SRhN1CW3S7oQdHkO+3V7yICmApj/CD0DBHL0gnR+b4CFVAprw4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424435; c=relaxed/simple; bh=ju78PKw5X3jrPkd4u5aoarH1747E7AoqhDQWmGlAe6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J52dilPCnAn3YcTDiJw4AGA6AN4XcEP9FNXqq+Ii8OtHGMyv1CuePjbzYNOoq7cuiTILj5IFf4WxUBsb4VVzgEYjco7+afyL14lApLXuR0af8jrRojzZea/JxkAb76WpavoZq2NFVhKd4Mz7EWGoIY4RidTcPxGntwYC+OXJ6yc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=OtWndrTe; arc=none smtp.client-ip=209.85.167.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="OtWndrTe" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3db51133978so2811233b6e.3 for ; Sun, 11 Aug 2024 18:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424431; x=1724029231; 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=7ZXNFNaxM8vBPLxvkIIPrWaUY6tMJ6nPhDNbuDGhUyQ=; b=OtWndrTeqolnNYuTu6lPAIYMFnRg5PZakcxBfsOpi+NIElZATnRkmDvW3OGrNpy7xA 3sOuakefAJoWE84807tU8zBzZImG+WtGp+zujugqZIG4L8pfJ1Xw2sRzTwLoHXYyhJam pCu/GfRm2sCdT1kzBgK+zC0Jr3vkfg2xcphVnGjvTJ1v7beqjqbA+pjjyHHdMO+wG/Ju 1Gm9aMt9H/phrIoOxfWDCuoVPTrLqGLSnk7e4ChWZwmtbR34oLqvnVCCKDv8+x4wjXmQ 2KZIhf5wKxGd1/hsSakaP8asqAwzfzrykFv3eHHsS+Td9Tx2NsdSBKF5U8XES3TRKfSk za8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424431; x=1724029231; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7ZXNFNaxM8vBPLxvkIIPrWaUY6tMJ6nPhDNbuDGhUyQ=; b=PCsAT7hjxbDdZca9RUuaCqOGfwc21lXP10sttSq2qECaOWfO9emUapsSTUOuP01PAy yz3vn2RDQIKxzC3Dx+Eq2rSDnc6ShF72QSlXh0g8b6h8Kk0Jb3cbxh5VMhbvwHDtVM/F FirPATvww6QuTJz2Wxr7j2h3qTjbX2uAf2eSd7FEBQblnLqI7zUfMQ568TZ2HNvi3LIC v0HW/KRq4cYSSZCBNKRCtxExfhKXbKE8yKUf1sntteSFduqI8ViWVPasarsbJRZQQsuS rYim0LgDuhP4as+CVPEsR2qGEWWlBlWmwajdLKb+ICgeO0Gp0LJmF76yWrSXvKi9BlbC EIDw== X-Gm-Message-State: AOJu0Yx9SnhUCna5eZ9TZG/xxxkIwr9PKKTKa9t//lQhN5vjIT/ci1aw jZVziKttGZnidUJrQUoqXssM3BGRLrWhoJGH+7mdxcmG+WOpFeM6EqtSlRoBkqvxqsrl0+QS/yV Lysp4tQ== X-Google-Smtp-Source: AGHT+IE9UN/eFl1Fb5sxAtzGTPfmVg74o1vo9nXqbGis0UuD39tez7iI9A3QbSPr+XUfKWTJWNIKOQ== X-Received: by 2002:a05:6808:2f10:b0:3d9:40c2:eb54 with SMTP id 5614622812f47-3dc416688bdmr13217183b6e.5.1723424431425; Sun, 11 Aug 2024 18:00:31 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:30 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 08/17] ACPI: pci_link: Clear the dependencies after probe Date: Mon, 12 Aug 2024 06:29:20 +0530 Message-ID: <20240812005929.113499-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISC-V platforms need to use dependencies between PCI host bridge, Link devices and the interrupt controllers to ensure probe order. The dependency is like below. Interrupt controller <-- Link Device <-- PCI Host bridge. If there is no dependency between Link device and PCI Host Bridge, then PCI devices may be probed prior to Link devices. If a PCI device is probed before its Link device, we won't be able to find its INTx mapping. So, add the link device's HID to dependency honor list and clear the dependency after probe is done so that the dependent devices are unblocked to probe. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/pci_link.c | 2 ++ drivers/acpi/scan.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index aa1038b8aec4..b727db968f33 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -748,6 +748,8 @@ static int acpi_pci_link_add(struct acpi_device *device, if (result) kfree(link); =20 + acpi_dev_clear_dependencies(device); + return result < 0 ? result : 1; } =20 diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 28a221f956d7..753539a1f26b 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -863,6 +863,7 @@ static const char * const acpi_honor_dep_ids[] =3D { "INTC10CF", /* IVSC (MTL) driver must be loaded to allow i2c access to ca= mera sensors */ "RSCV0001", /* RISC-V PLIC */ "RSCV0002", /* RISC-V APLIC */ + "PNP0C0F", /* PCI Link Device */ NULL }; =20 --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 D2D162AF02 for ; Mon, 12 Aug 2024 01:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424441; cv=none; b=rV0ejP/j+K6+ZLvU6YzLnYEo40UAA85d6JH9woTHE3DhGr6TDV/VeQkoQ/LVK5YNT6jqDhbrbfn9Zqg70N60G0W45QpqqmT2izpVzcGoIC5yD06gfSS6t77xe6cD+vzznKsiFPKR9UbOO0PSbzStjdZdE+wCvqO7MS4qFPRvepw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424441; c=relaxed/simple; bh=GWjuZw4Eu5cTg7uGwWvYjxpFMMpJ9eJlTAedDtcBMYY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mLW54spBJV5i+BC2fpDuOUtb/AYnWEWvAOrX7ZgimKPIWufjPmrzQ+8AgRMiBaD6gJSlrJZa62epZBlw25GY6HtdcEckozDbVJHNQtfsM+IwbxQY8C/Gti6lyuLO3oKwdMh2qdgdEkMnCHZaISoPsZyt3XgosGUBFq2uWzyANGo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=ba++SpCK; arc=none smtp.client-ip=209.85.167.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="ba++SpCK" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3db18c4927bso2326647b6e.1 for ; Sun, 11 Aug 2024 18:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424438; x=1724029238; 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=3yHv4RQ+8m8uuAieiHb/ndAopbPkfvfPnrF/+OTZxeU=; b=ba++SpCKmiXWz+t6oreV3+r1Yv514f1QoSyXJIEvGhiYEVSgAE8WP6gW2Z7/uRdI4C gOIX8Z2amimpRMGWMaPyTS7mjWzlTkeJRCQBDjM1jH3jn+3rvT0yKmh8QUkLsax1Gthx JJJxJISdY7mN9w6Hk4tONGV4U059vKScGXTTDwJGtx1u9gZanka5mBnLowXecAKqM6+e q0Meo2EiLDhTimytoIu9glbtULudDMCD3xcXGK9O2Vqnvq7Rs3SjYqrOX8TXAnFzk08j YTDRXRh7UWF63w5vZOd537+UsMZDNUpoheOEvmkBNU5mEHerplLNgtElMcvQhkROwr7e ajEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424438; x=1724029238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3yHv4RQ+8m8uuAieiHb/ndAopbPkfvfPnrF/+OTZxeU=; b=qfxrrsr8rZZZhCMUeX4mVJ3rxDCWVGedGbHmWC4KpKWexFNDgCtC0meJx5Z9B5tvi4 1i4i9SmQdWNvzFXQFEhsZV3TZLYBuSbE5IjHuzTK5TfANtpsppa5asNaXNl6gf8DWP9b oo9r2ng6EQgtWwYCPnLiWWe7XpskTBmCTpJ7zcjzgXY9deQQxdn0RIOXEX2eTqjU5x2H MPnxjokvcXfg2f/0KFn5hon3tGxluNc59bTfDI2zSptdTdgxdfeJWl1wlW5eHXqf/vco 9Pd8V3SOIp+yh69PGGJkrwav6S+nsApq9I6Z0H76rCPJqytapYbsJfUeooO5shR8HgHQ a1qw== X-Gm-Message-State: AOJu0YwQdlEfAHA9Qb+RU7T2S5s2CmVB/ZtixdQIDhKJmugAADEupaNd Dg4l+tb9jAFCT35nn3PDbZM6I0LODwdRAbEe5nHU6SW3cRwNkQmmCKGfdrCUooFn1BKO0lzb6xc UpdpQIQ== X-Google-Smtp-Source: AGHT+IFun0gorfvtl1RVjdN/jm32amrHRkag2ROgDMVcRhqDHKcAfRdwMw49PRBtm4+7+S1MCEJ11g== X-Received: by 2002:a05:6808:16a0:b0:3db:fe8:f74c with SMTP id 5614622812f47-3dc41689574mr7836368b6e.24.1723424437728; Sun, 11 Aug 2024 18:00:37 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:37 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 09/17] ACPI: RISC-V: Implement PCI related functionality Date: Mon, 12 Aug 2024 06:29:21 +0530 Message-ID: <20240812005929.113499-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the dummy implementation for PCI related functions with actual implementation. This needs ECAM and MCFG CONFIG options to be enabled for RISC-V. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- arch/riscv/Kconfig | 2 ++ arch/riscv/kernel/acpi.c | 33 +++++++++++++++------------------ drivers/pci/pci-acpi.c | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 0f3cd7c3a436..a269e577284e 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -13,6 +13,7 @@ config 32BIT config RISCV def_bool y select ACPI_GENERIC_GSI if ACPI + select ACPI_MCFG if (ACPI && PCI) select ACPI_PPTT if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ACPI_SPCR_TABLE if ACPI @@ -188,6 +189,7 @@ config RISCV select OF_EARLY_FLATTREE select OF_IRQ select PCI_DOMAINS_GENERIC if PCI + select PCI_ECAM if (ACPI && PCI) select PCI_MSI if PCI select RISCV_ALTERNATIVE if !XIP_KERNEL select RISCV_APLIC diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c index ba957aaca5cb..6e0d333f57e5 100644 --- a/arch/riscv/kernel/acpi.c +++ b/arch/riscv/kernel/acpi.c @@ -311,29 +311,26 @@ void __iomem *acpi_os_ioremap(acpi_physical_address p= hys, acpi_size size) #ifdef CONFIG_PCI =20 /* - * 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 =3D pci_find_bus(domain, bus); + + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->read(b, devfn, reg, len, val); } =20 -int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devf= n, - int reg, int len, u32 val) +int raw_pci_write(unsigned int domain, unsigned int bus, + unsigned int devfn, int reg, int len, u32 val) { - return PCIBIOS_DEVICE_NOT_FOUND; + struct pci_bus *b =3D pci_find_bus(domain, bus); + + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->write(b, devfn, reg, len, val); } =20 -int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) -{ - return -1; -} - -struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) -{ - return NULL; -} #endif /* CONFIG_PCI */ diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 8ed81a373bd7..af370628e583 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1543,7 +1543,7 @@ static int __init acpi_pci_init(void) } arch_initcall(acpi_pci_init); =20 -#if defined(CONFIG_ARM64) +#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) =20 /* * Try to assign the IRQ number when probing a new device --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (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 6A9ED2B9DE for ; Mon, 12 Aug 2024 01:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424446; cv=none; b=VWsFVaMjXGwzFs8amCXo1sHiV7FaAN5BhTFWhewjwqJYMXqdYPHyyiL6I9ipN527dMduivRvAgIajzSsLPoXTUwF6PdihekXN4W2joZfaIP58o+mMedvQmg95nPKsmPuz5Xvv2T/ziKagvyTYHnAU+3ie/uJmw6pt092DB9lE70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424446; c=relaxed/simple; bh=RKAOGnY5SFDT70NOv7EmPS7N/KTCn0fTkoDBsaqVdxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KPzFmEki1Md7qjUJrd5j9O6u8fkup+ADWciLCz8PTbUWgm2Q6OOraqZknGPzBDsO6EfojJasC9ohNl0ziuS17gv4qaKSlpdf8uUpk12ovNxH0xEEoxqoX+oqBnGFI9MOBsXjbxqg+6zfsyN0xXZlVEtcLUeuItCDws2X0jp39N8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=mwEoQZxj; arc=none smtp.client-ip=209.85.161.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="mwEoQZxj" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5d5d0535396so1914480eaf.1 for ; Sun, 11 Aug 2024 18:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424444; x=1724029244; darn=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=xbG/jHg21LcLoDzwk6IzVsucBn3jZiDtmvIm1r3v9tk=; b=mwEoQZxj1I02s4od1ZXkMlzivk82uZBXh3FxiF3ES5w1nhuk/xVJpRgRlufxX+6kVN 9AuxFqdkpEyn0BfpnhHyArMErizIJ8XkPjLS1sMW1owggaj5c/XhKnArvn5e0n10w+b7 xukTMzECjJX1LAnWXQl0aFKBhX+vtbVu1VUT0qIP1Iq0sSLyZE5K0+Mibov3BPUH5pSL zYQrsICKT4JuYmEMj5Yzts9Nb4nSDoX/+l4ivogwu9qwziozQu2C7EjyCmvi6M/+7tCs PsagMwkkWv9805BPLaYVWiMEAh57HrZGgdgax8x7uVkchD7G4AcAngluptxB2Zvp21po AwKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424444; x=1724029244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xbG/jHg21LcLoDzwk6IzVsucBn3jZiDtmvIm1r3v9tk=; b=EmnbazkxE7ZnYkpMmsXnFVZ8cyAU2dRgIKmM6wB0dqdl629Icb5c+TFkSdXNDFLtPy 58rBAiGyesUWAd50fKH98nh3Uk5PmSSfdTxAjmxZRW11Q35YX4gAAxRulE5ebkHFKTzI 2RWLfxEGdKRe5P5jk7QUhhgHrRorVkhIL84HtU4r2vJEv8wqsQrVW+o52cCXAiDJH6qy 4km8FtnKnBuN39RpVxIkwY1vB30IAIf56AJJelRA8x4mmRwcI0EwS6z23l09ZKiQ+8C2 XbsdFar8cJbIAW8v7q4aHFeDqi4ZMbp3iwDwnCS55X4Wx5Jf9CsesbmX+JP4aJr5bEIh 6XXw== X-Gm-Message-State: AOJu0Yy5Wv+PSetK3+nfl5eGOU82mgwsuTHodDTs5pCUkXr8h1acVRsc Azkffeow1SC/xiny763NIlwNxJs4O0W0dL8b8OVfiHAMgRszHWnN80faGw9pqh8ECDR1vlhhI40 ++ZMbyQ== X-Google-Smtp-Source: AGHT+IGtpWS7DBc6qnLRa7J1XKsHLrlfePxKw3cHvC5D7SmpvnVph24/oUKeRjRFTeAU1sM99c7TNA== X-Received: by 2002:a05:6870:1585:b0:260:e7f9:f4e9 with SMTP id 586e51a60fabf-26c62f21db8mr8563110fac.35.1723424444123; Sun, 11 Aug 2024 18:00:44 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:43 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 10/17] ACPI: RISC-V: Implement function to reorder irqchip probe entries Date: Mon, 12 Aug 2024 06:29:22 +0530 Message-ID: <20240812005929.113499-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On RISC-V platforms, the RINTC structures should be probed before any other interrupt controller structures and IMSIC before APLIC. This order is established by using MADT sub table types which are ordered in the incremental order from the RINTC. So, add the architecture function for RISC-V to reorder the interrupt controller probing as per the hierarchy like below. ACPI_MADT_TYPE_RINTC =3D 24, ACPI_MADT_TYPE_IMSIC =3D 25, ACPI_MADT_TYPE_APLIC =3D 26, ACPI_MADT_TYPE_PLIC =3D 27 This means processing all RINTC structures (in the order of appearance in MADT), followed by IMSIC strucutre and then all APLIC/PLIC structures. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/irq.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/irq.c diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 877de00d1b50..a96fdf1e2cb8 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y +=3D rhct.o init.o +obj-y +=3D rhct.o init.o irq.o obj-$(CONFIG_ACPI_PROCESSOR_IDLE) +=3D cpuidle.o obj-$(CONFIG_ACPI_CPPC_LIB) +=3D cppc.o diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c new file mode 100644 index 000000000000..835eb6eccd53 --- /dev/null +++ b/drivers/acpi/riscv/irq.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023-2024, Ventana Micro Systems Inc + * Author: Sunil V L + */ + +#include +#include + +static int irqchip_cmp_func(const void *in0, const void *in1) +{ + struct acpi_probe_entry *elem0 =3D (struct acpi_probe_entry *)in0; + struct acpi_probe_entry *elem1 =3D (struct acpi_probe_entry *)in1; + + return (elem0->type > elem1->type) - (elem0->type < elem1->type); +} + +/* + * On RISC-V, RINTC structures in MADT should be probed before any other + * interrupt controller structures and IMSIC before APLIC. The interrupt + * controller subtypes in MADT of ACPI spec for RISC-V are defined in + * the incremental order like RINTC(24)->IMSIC(25)->APLIC(26)->PLIC(27). + * Hence, simply sorting the subtypes in incremental order will + * establish the required order. + */ +void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) +{ + struct acpi_probe_entry *ape =3D ap_head; + + if (nr =3D=3D 1 || !ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) + return; + sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); +} --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.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 5A75F847A for ; Mon, 12 Aug 2024 01:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424453; cv=none; b=aa01lnETAv1/UoAMPYAu4NFZnxeQhDY6+RGA7rYawdexg5zAlb9x+ZqcuOILKRv9fv4NxmAa0QD1+wd8uFT8gsKdpNEqbw/swI4qYcAeijQlQp++rgPQeN+AgdqpSo18Tu17EK8bk9ysN7rSwl6RjB+gaKi133BYwGjusSkt+CM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424453; c=relaxed/simple; bh=xZxlyDcMOh+rhR2esklH3kbgHbWDV2ZIJQfnY0eZOqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AxL1S6I1WO+4LGcwpfm5flo8NOdPDV3BLA9gcqjQJSAaeiuA96Pwsrns/6//QIzn9N2UwS5CdBK94kRjMn0dFsPW/WM+HkDBkOCp+Kyap1EITpGVXlSZYAVc1ScNRpKEWS3bQLYkLkouUmP5ZorQAMehLgDjYXIy24aKwck+Uio= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=nPkYE5Ky; arc=none smtp.client-ip=209.85.210.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="nPkYE5Ky" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70d1fb6c108so2651711b3a.3 for ; Sun, 11 Aug 2024 18:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424450; x=1724029250; 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=zGfeskz8g19r+OqajKxPNYjNNE+F0wltIvoajFyWVok=; b=nPkYE5KywNnZncmpeGKj0K0O4kLz0mH+p6AK50IF0MFjUY0323Dz6u4bHGiHHvctvi DQz1HOxI+8tiYOL3rou31Eg7OAnjlXyThkSu5XL6LACW9TokI0qWE3b0aI4GnM9cTh8Q VOQ0aDLxwZS4HwhkUOMuFIjx5mAdZ39KqHCt56VBxr0HqqmhhQG+hlOkzt5dwSYi0f3z h93suKW3zc3sfQQjcEyjmNTSvjF0WEevPP93KRhSCW0Zqi2pHCl+BjIBJoF52wrsjRMA v1yGM0bD3kZiL5wO7T3GaW737w4+5tVcZDEnB/p7RuAOZ0oVnAH91vW/dMhRQNxHfHTQ zw5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424450; x=1724029250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zGfeskz8g19r+OqajKxPNYjNNE+F0wltIvoajFyWVok=; b=vSrV+N55pxyLjuIknlyo9yqnAVnc2/vkcVzl4OyZJcsPKO/PvOkjy+GLXG69kN3JAP KqKuBx7ZidWAyePhvp1mbyWn/qsAiyWfC+l/LjZLRuHRICozGV9PP0mOr4MW4KVenL0S ho23zErSCz6q2SPa4zi3kEYku+9ueN8sKjBiZxASbXUOZNPHlipwp5l0x9YYoDIZuTUQ BKwtyh9meNrFAxaEk5SCiE1GQXZY+Tuz8e2ZjsVc1SG2D9D0FSurpJ0K5nslw7Y4aCjj EhEBNSxPCIdOxP/ZBWMl/hwT+WHVbUQt24vQxpHGrw7iUOpbN+Rx3mhTz6TivGN/Dzho XyeA== X-Gm-Message-State: AOJu0Ywv46Ths+ZvNG+nDgHTMryG3Kums4ujBvUwjHIx3sKBMQg5y1GZ 4qIm6LB8GjjyHhpQ2RuBJ0/VHV1WL7WFB9Nexc2Xf2DU35xAPAVsmyCMA+dfDuLdn+jyBh9KwCv M7if4Nw== X-Google-Smtp-Source: AGHT+IE3q8lKgHgWLAwxE/0Wiss9V/UMieO99InX6OgVwr4G4I59tEn3alleuzimlu24LFWs915ICg== X-Received: by 2002:a05:6a00:2da1:b0:710:7efe:a870 with SMTP id d2e1a72fcca58-710dcaeb509mr5600452b3a.19.1723424450430; Sun, 11 Aug 2024 18:00:50 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:49 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 11/17] ACPI: RISC-V: Initialize GSI mapping structures Date: Mon, 12 Aug 2024 06:29:23 +0530 Message-ID: <20240812005929.113499-12-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISC-V has PLIC and APLIC in MADT as well as namespace devices. Initialize the list of those structures using MADT and namespace devices to create mapping between the ACPI handle and the GSI ranges. This will be used later to add dependencies. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- arch/riscv/include/asm/irq.h | 22 ++++++ drivers/acpi/riscv/init.c | 2 + drivers/acpi/riscv/init.h | 4 + drivers/acpi/riscv/irq.c | 147 +++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 drivers/acpi/riscv/init.h diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 8e10a94430a2..44a0b128c602 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -16,4 +16,26 @@ void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn= )(void)); =20 struct fwnode_handle *riscv_get_intc_hwnode(void); =20 +#ifdef CONFIG_ACPI + +enum riscv_irqchip_type { + ACPI_RISCV_IRQCHIP_INTC =3D 0x00, + ACPI_RISCV_IRQCHIP_IMSIC =3D 0x01, + ACPI_RISCV_IRQCHIP_PLIC =3D 0x02, + ACPI_RISCV_IRQCHIP_APLIC =3D 0x03, +}; + +int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, + u32 *id, u32 *nr_irqs, u32 *nr_idcs); +struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 gsi); + +#else +static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u3= 2 *gsi_base, + u32 *id, u32 *nr_irqs, u32 *nr_idcs) +{ + return 0; +} + +#endif /* CONFIG_ACPI */ + #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c index a875a76aa44c..5ef97905a727 100644 --- a/drivers/acpi/riscv/init.c +++ b/drivers/acpi/riscv/init.c @@ -5,7 +5,9 @@ */ =20 #include +#include "init.h" =20 void __init acpi_riscv_init(void) { + riscv_acpi_init_gsi_mapping(); } diff --git a/drivers/acpi/riscv/init.h b/drivers/acpi/riscv/init.h new file mode 100644 index 000000000000..0b9a07e4031f --- /dev/null +++ b/drivers/acpi/riscv/init.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include + +void __init riscv_acpi_init_gsi_mapping(void); diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 835eb6eccd53..9028787c73a7 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -6,6 +6,21 @@ =20 #include #include +#include + +#include "init.h" + +struct riscv_ext_intc_list { + acpi_handle handle; + u32 gsi_base; + u32 nr_irqs; + u32 nr_idcs; + u32 id; + u32 type; + struct list_head list; +}; + +LIST_HEAD(ext_intc_list); =20 static int irqchip_cmp_func(const void *in0, const void *in1) { @@ -31,3 +46,135 @@ void arch_sort_irqchip_probe(struct acpi_probe_entry *a= p_head, int nr) return; sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL); } + +static acpi_status riscv_acpi_update_gsi_handle(u32 gsi_base, acpi_handle = handle) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i, *tmp; + + list_for_each_safe(i, tmp, &ext_intc_list) { + ext_intc_element =3D list_entry(i, struct riscv_ext_intc_list, list); + if (gsi_base =3D=3D ext_intc_element->gsi_base) { + ext_intc_element->handle =3D handle; + return AE_OK; + } + } + + return AE_NOT_FOUND; +} + +int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, + u32 *id, u32 *nr_irqs, u32 *nr_idcs) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i; + + list_for_each(i, &ext_intc_list) { + ext_intc_element =3D list_entry(i, struct riscv_ext_intc_list, list); + if (ext_intc_element->handle =3D=3D ACPI_HANDLE_FWNODE(fwnode)) { + *gsi_base =3D ext_intc_element->gsi_base; + *id =3D ext_intc_element->id; + *nr_irqs =3D ext_intc_element->nr_irqs; + if (nr_idcs) + *nr_idcs =3D ext_intc_element->nr_idcs; + + return 0; + } + } + + return -ENODEV; +} + +struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 gsi) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct acpi_device *adev; + struct list_head *i; + + list_for_each(i, &ext_intc_list) { + ext_intc_element =3D list_entry(i, struct riscv_ext_intc_list, list); + if (gsi >=3D ext_intc_element->gsi_base && + gsi < (ext_intc_element->gsi_base + ext_intc_element->nr_irqs)) { + adev =3D acpi_fetch_acpi_dev(ext_intc_element->handle); + if (!adev) + return NULL; + + return acpi_fwnode_handle(adev); + } + } + + return NULL; +} + +static int __init riscv_acpi_register_ext_intc(u32 gsi_base, u32 nr_irqs, = u32 nr_idcs, + u32 id, u32 type) +{ + struct riscv_ext_intc_list *ext_intc_element; + + ext_intc_element =3D kzalloc(sizeof(*ext_intc_element), GFP_KERNEL); + if (!ext_intc_element) + return -ENOMEM; + + ext_intc_element->gsi_base =3D gsi_base; + ext_intc_element->nr_irqs =3D nr_irqs; + ext_intc_element->nr_idcs =3D nr_idcs; + ext_intc_element->id =3D id; + list_add_tail(&ext_intc_element->list, &ext_intc_list); + return 0; +} + +static acpi_status __init riscv_acpi_create_gsi_map(acpi_handle handle, u3= 2 level, + void *context, void **return_value) +{ + acpi_status status; + u64 gbase; + + if (!acpi_has_method(handle, "_GSB")) { + acpi_handle_err(handle, "_GSB method not found\n"); + return AE_ERROR; + } + + status =3D acpi_evaluate_integer(handle, "_GSB", NULL, &gbase); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to evaluate _GSB method\n"); + return status; + } + + status =3D riscv_acpi_update_gsi_handle((u32)gbase, handle); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to find the GSI mapping entry\n"); + return status; + } + + return AE_OK; +} + +static int __init riscv_acpi_aplic_parse_madt(union acpi_subtable_headers = *header, + const unsigned long end) +{ + struct acpi_madt_aplic *aplic =3D (struct acpi_madt_aplic *)header; + + return riscv_acpi_register_ext_intc(aplic->gsi_base, aplic->num_sources, = aplic->num_idcs, + aplic->id, ACPI_RISCV_IRQCHIP_APLIC); +} + +static int __init riscv_acpi_plic_parse_madt(union acpi_subtable_headers *= header, + const unsigned long end) +{ + struct acpi_madt_plic *plic =3D (struct acpi_madt_plic *)header; + + return riscv_acpi_register_ext_intc(plic->gsi_base, plic->num_irqs, 0, + plic->id, ACPI_RISCV_IRQCHIP_PLIC); +} + +void __init riscv_acpi_init_gsi_mapping(void) +{ + /* There can be either PLIC or APLIC */ + if (acpi_table_parse_madt(ACPI_MADT_TYPE_PLIC, riscv_acpi_plic_parse_madt= , 0) > 0) { + acpi_get_devices("RSCV0001", riscv_acpi_create_gsi_map, NULL, NULL); + return; + } + + if (acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, riscv_acpi_aplic_parse_ma= dt, 0) > 0) + acpi_get_devices("RSCV0002", riscv_acpi_create_gsi_map, NULL, NULL); +} --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (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 19DEA42A87 for ; Mon, 12 Aug 2024 01:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424459; cv=none; b=NqWwI1ALP7u/PW3rMm48P/7ZFKS4qNAAqWWV3r/ypwI6FBfJNwKU6EBhCWs45mEOLF4Jg5xqiWZn0lf9h//zaApkMgLWa/+5iYK4NJYW2TKx/DY1ryRPFxhVOchcH77ow9Wv7SSUEcDYpJjm4GjsKZcKLm3LfFjP6DTCF6HyDsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424459; c=relaxed/simple; bh=iGwYOvrwXbSwOk6tDmwtihd5FyLmpwbhGFgFf5/6nKk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iHC/PwAawj7hBv+XXLouaLRKFXnACxZmFbYUlVN/i5mwvCnvaWI7W4mTWpRv4RSGH1CWhw6wOdRjvHbFsEAqOsMYvFK/Zpl+kqhsH3WqAewCU0SiIUMhhX5929XGk1yHFYIYAp0zsXIeNc/8zsbhRCTs6gAVG3XsCh41hW+KMwc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=Nu9cgdVV; arc=none smtp.client-ip=209.85.160.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Nu9cgdVV" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-260f863108fso2356804fac.1 for ; Sun, 11 Aug 2024 18:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424457; x=1724029257; darn=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=qMNBqe/9cTzO1EXtoBS3N5wT2H0f1rIMH9omusI+3YU=; b=Nu9cgdVVyh+Y8uT2C+fgYHpqd6I7NNpOs9E3ttt/mnjU+Y6dEi9sowSosNe0y3NxnB JEbY3jYeBOWm0PTfjyi7cWWVu6NKjuFQ3lGV8659iP0EBD4fAA9h+CyRSQNAGYRxIiYF wN6jBPPhIdz2sKbvIunjTKf0JXV+1RTX98XEP+9gH7tI4c0JOCvTDsOl4iOjwBKu2n/k +O6qKvFUbYEt93IzveXJ4g2ZdAXLseBEUMzeMHnkSrYPRgbpG+yN/3y/TOu++snx2LAu bV1HsT/2Yqb9YuGM7PHgX+5B76EKFtoQu0b+XcBEgM2X9SyFf+7OqST2nueV4LDtQ6wK MsZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424457; x=1724029257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qMNBqe/9cTzO1EXtoBS3N5wT2H0f1rIMH9omusI+3YU=; b=JbCZRt17NiQZ9ABjT5tEuCKjUOwpGmqhS5jkT5BWhD4DJxk6p61T8Uc8emqxSE1g2r Q9gVY2yriVQ9s8ElpyNdfWw4dXwx9+HNgHJLNfk0IlmbYRjGVlXZIe0y1jwXYs/sdzYI u2sy6X/MadgzZNY5mx9f7di7zLEqX8bfNVd7yFqx/CVNcv8YElqGoQ+c0UjvDQ1Zd1C5 zece/p9ih8X8oq4tW/Nj7wdZULvMpWeDqW+APZEy6xm6x/71D3uD9FcIafrYBtiggSvU q67LdJfgBRZ2sp7DDnkRnmOMfZLGMVliRbkOJUs8O+pRtcezhdsRcfrQylavEQbhw/bo reuQ== X-Gm-Message-State: AOJu0Yw627AYXjcx+KMVUy3Nc9K1V6csR4MYwygVHEf2a7hyinbVWKiP tF4cKdFjsyvIsfKv+19Zxt42qCXo8fa3SK0H4NIlKBxB5jHnOjYBjJP5q8KcHbyxVjCE4hVV/br M7ZQJ7A== X-Google-Smtp-Source: AGHT+IHH0tD3H2b4nYjMLU3yefWBfcIBabXBtrcMk+XbHZMJ1kwyx0P2UJ9m1CeDn96dZhdAvQwZUw== X-Received: by 2002:a05:6870:d8cc:b0:258:5143:a21a with SMTP id 586e51a60fabf-26c62c69d1cmr9739322fac.13.1723424456739; Sun, 11 Aug 2024 18:00:56 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:00:56 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 12/17] ACPI: RISC-V: Implement function to add implicit dependencies Date: Mon, 12 Aug 2024 06:29:24 +0530 Message-ID: <20240812005929.113499-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISC-V interrupt controllers for wired interrupts are platform devices and hence their driver will be probed late. Also, APLIC which is one such interrupt controller can not be probed early since it needs MSI services. This needs a probing order between the interrupt controller driver and the device drivers. _DEP is typically used to indicate such dependencies. However, the dependency may be already available like GSI mapping. Hence, instead of an explicit _DEP, architecture can find the implicit dependencies and add to the dependency list. For RISC-V, add the dependencies for below use cases. 1) For devices which has IRQ resource, find out the interrupt controller using GSI number map and add the dependency. 2) For PCI host bridges: a) If _PRT indicate PCI link devices, add dependency on the link device. b) If _PRT indicates GSI, find out the interrupt controller using GSI number map and add the dependency. Signed-off-by: Sunil V L Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/acpi/riscv/irq.c | 155 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 9028787c73a7..cced960c2aef 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -20,6 +20,12 @@ struct riscv_ext_intc_list { struct list_head list; }; =20 +struct acpi_irq_dep_ctx { + int rc; + unsigned int index; + acpi_handle handle; +}; + LIST_HEAD(ext_intc_list); =20 static int irqchip_cmp_func(const void *in0, const void *in1) @@ -178,3 +184,152 @@ void __init riscv_acpi_init_gsi_mapping(void) if (acpi_table_parse_madt(ACPI_MADT_TYPE_APLIC, riscv_acpi_aplic_parse_ma= dt, 0) > 0) acpi_get_devices("RSCV0002", riscv_acpi_create_gsi_map, NULL, NULL); } + +static acpi_handle riscv_acpi_get_gsi_handle(u32 gsi) +{ + struct riscv_ext_intc_list *ext_intc_element; + struct list_head *i; + + list_for_each(i, &ext_intc_list) { + ext_intc_element =3D list_entry(i, struct riscv_ext_intc_list, list); + if (gsi >=3D ext_intc_element->gsi_base && + gsi < (ext_intc_element->gsi_base + ext_intc_element->nr_irqs)) + return ext_intc_element->handle; + } + + return NULL; +} + +static acpi_status riscv_acpi_irq_get_parent(struct acpi_resource *ares, v= oid *context) +{ + struct acpi_irq_dep_ctx *ctx =3D context; + struct acpi_resource_irq *irq; + struct acpi_resource_extended_irq *eirq; + + switch (ares->type) { + case ACPI_RESOURCE_TYPE_IRQ: + irq =3D &ares->data.irq; + if (ctx->index >=3D irq->interrupt_count) { + ctx->index -=3D irq->interrupt_count; + return AE_OK; + } + ctx->handle =3D riscv_acpi_get_gsi_handle(irq->interrupts[ctx->index]); + return AE_CTRL_TERMINATE; + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + eirq =3D &ares->data.extended_irq; + if (eirq->producer_consumer =3D=3D ACPI_PRODUCER) + return AE_OK; + + if (ctx->index >=3D eirq->interrupt_count) { + ctx->index -=3D eirq->interrupt_count; + return AE_OK; + } + + /* Support GSIs only */ + if (eirq->resource_source.string_length) + return AE_OK; + + ctx->handle =3D riscv_acpi_get_gsi_handle(eirq->interrupts[ctx->index]); + return AE_CTRL_TERMINATE; + } + + return AE_OK; +} + +static int riscv_acpi_irq_get_dep(acpi_handle handle, unsigned int index, = acpi_handle *gsi_handle) +{ + struct acpi_irq_dep_ctx ctx =3D {-EINVAL, index, NULL}; + + if (!gsi_handle) + return 0; + + acpi_walk_resources(handle, METHOD_NAME__CRS, riscv_acpi_irq_get_parent, = &ctx); + *gsi_handle =3D ctx.handle; + if (*gsi_handle) + return 1; + + return 0; +} + +static u32 riscv_acpi_add_prt_dep(acpi_handle handle) +{ + struct acpi_buffer buffer =3D { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_pci_routing_table *entry; + struct acpi_handle_list dep_devices; + acpi_handle gsi_handle; + acpi_handle link_handle; + acpi_status status; + u32 count =3D 0; + + status =3D acpi_get_irq_routing_table(handle, &buffer); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to get IRQ routing table\n"); + kfree(buffer.pointer); + return 0; + } + + entry =3D buffer.pointer; + while (entry && (entry->length > 0)) { + if (entry->source[0]) { + acpi_get_handle(handle, entry->source, &link_handle); + dep_devices.count =3D 1; + dep_devices.handles =3D kcalloc(1, sizeof(*dep_devices.handles), GFP_KE= RNEL); + if (!dep_devices.handles) { + acpi_handle_err(handle, "failed to allocate memory\n"); + continue; + } + + dep_devices.handles[0] =3D link_handle; + count +=3D acpi_scan_add_dep(handle, &dep_devices); + } else { + gsi_handle =3D riscv_acpi_get_gsi_handle(entry->source_index); + dep_devices.count =3D 1; + dep_devices.handles =3D kcalloc(1, sizeof(*dep_devices.handles), GFP_KE= RNEL); + if (!dep_devices.handles) { + acpi_handle_err(handle, "failed to allocate memory\n"); + continue; + } + + dep_devices.handles[0] =3D gsi_handle; + count +=3D acpi_scan_add_dep(handle, &dep_devices); + } + + entry =3D (struct acpi_pci_routing_table *) + ((unsigned long)entry + entry->length); + } + + kfree(buffer.pointer); + return count; +} + +static u32 riscv_acpi_add_irq_dep(acpi_handle handle) +{ + struct acpi_handle_list dep_devices; + acpi_handle gsi_handle; + u32 count =3D 0; + int i; + + for (i =3D 0; + riscv_acpi_irq_get_dep(handle, i, &gsi_handle); + i++) { + dep_devices.count =3D 1; + dep_devices.handles =3D kcalloc(1, sizeof(*dep_devices.handles), GFP_KER= NEL); + if (!dep_devices.handles) { + acpi_handle_err(handle, "failed to allocate memory\n"); + continue; + } + + dep_devices.handles[0] =3D gsi_handle; + count +=3D acpi_scan_add_dep(handle, &dep_devices); + } + + return count; +} + +u32 arch_acpi_add_auto_dep(acpi_handle handle) +{ + if (acpi_has_method(handle, "_PRT")) + return riscv_acpi_add_prt_dep(handle); + + return riscv_acpi_add_irq_dep(handle); +} --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 F29774D8B1 for ; Mon, 12 Aug 2024 01:01:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424466; cv=none; b=PhE9wxcqz50Lr0PqeUSNoz/GKKVrMqjpIm8eUdBeLmQsQozB/s32FlQOZRqlzWvPI2+u2aw/doKFeXa7+pS31F8X1ZtvbSzIeOocIc/my8NyPF358iGlhjseedk+Rt8fyLKfMvZzE6fxvTh5hTDnzKRpoxuWV6pVZBofpdeagGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424466; c=relaxed/simple; bh=c1qYc4e9QVIA4mjJd8so/MjtDZRnBh9X0X6PihmPtA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L0Q4d3ODGbK20YUKxwHjFVuzxWRyNoMInLQEuGE9ylsv9foxGkHM1B8h5jA7ODeVl/Vho76qQJL813c5Uk73Ow3dkt67lo3+xcoVrs1rnkaSWPegLftdG3VzEtcxeU/4cUeBtbtoQvmBP39Ni7hhXoexZM+OGtwNX7jL0MYiQe4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=fIrNQKkT; arc=none smtp.client-ip=209.85.216.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="fIrNQKkT" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2cb6662ba3aso2501805a91.1 for ; Sun, 11 Aug 2024 18:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424463; x=1724029263; 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=9eWLrHir182byqrnausz4PNiecB0MULYeCzMr04SHA0=; b=fIrNQKkTMkiUxfExrArXoVdzzk5c2ql1ftyieqizDZtgi1Gv+jb4NfEmb0HtoSd7Z3 dyStfuD692hBpKEot+vNOt9M5KHGwwYhGb3Apb/U5BTLrdjakkQ19ebWWsEtifK5Wz1e seblnTFDGN7tO2oYa+XS9HXV7lu9UH5q7GzWCSr+0m90wnPgAZKyt5VT2MStpL8iJBbk PSBh8tz4gFci92tuMF3fsraetQ8jyms/f/uQkH3OFJOGUOf/OIpjSGydIwP5+7AYPABl 5UUcuOnqUtuGOBn47L9Ka3+/6RBWX6vU4LteuylRJibHN/kwllccBsLGqX+/Hi1a+A0z ZPIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424463; x=1724029263; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9eWLrHir182byqrnausz4PNiecB0MULYeCzMr04SHA0=; b=VB7pmZYPto8GidcJqLh+6iiHm54WgfkP6tJxAJKpHmOs3JjrmWNUiRd7CeJShiyjXH LzC5x8LGE3y1IDerrORGj8pUE0yuvUZUqSLGmNeMPEXNBL7QilThJJ53e/2svzGas5to pmKexcbkd9o8NQGF5k8EzF/LyHghl2E5Ebu1Av2/2hovTSBRzcOa+OEd79xsArumdemO 2Q2mGqNiyVC3bf+yH6KMgAWCS3yv/+nAIKWg7+lr7Zb0lSO2bQeOZaIp2/pdO9pFm8Ib SnWyKZMKESZJ83VGAlMG8xuu+QDlTq1HozmZPt5HgpIoge8ItCxtrhh5jEDKkF9ZRFLI T57Q== X-Gm-Message-State: AOJu0Yx8d6TfZDuzlWxzG6sUZ+xBH5U8j47abY6g/MxhNdjTgvTjmFeg sF9VYbGkYNoJt6GoUhPZJEqZHeFWvfAf9SaBqAc+OTSfPHQXfqFmM9rxsmSuZOg/p+jrd7t6B7C T1mnrnA== X-Google-Smtp-Source: AGHT+IEmnnZO8yRXJ6ENu6bAM1Iq53DDo8oXCMY/2aarMSTJFhyCJE6z0a/eBIRQSdiXXTmWXrm9Iw== X-Received: by 2002:a17:90b:1887:b0:2cf:dd3c:9b0d with SMTP id 98e67ed59e1d1-2d1c4b674cdmr19256482a91.2.1723424463037; Sun, 11 Aug 2024 18:01:03 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:02 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 13/17] irqchip/riscv-intc: Add ACPI support for AIA Date: Mon, 12 Aug 2024 06:29:25 +0530 Message-ID: <20240812005929.113499-14-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RINTC subtype structure in MADT also has information about other interrupt controllers. Save this information and provide interfaces to retrieve them when required by corresponding drivers. Signed-off-by: Sunil V L Reviewed-by: Anup Patel Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- arch/riscv/include/asm/irq.h | 33 ++++++++++++ drivers/irqchip/irq-riscv-intc.c | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 44a0b128c602..7e9a84a005ed 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -12,6 +12,8 @@ =20 #include =20 +#define INVALID_CONTEXT UINT_MAX + void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void)); =20 struct fwnode_handle *riscv_get_intc_hwnode(void); @@ -28,6 +30,11 @@ enum riscv_irqchip_type { int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, u32 *id, u32 *nr_irqs, u32 *nr_idcs); struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u32 gsi); +unsigned long acpi_rintc_index_to_hartid(u32 index); +unsigned long acpi_rintc_ext_parent_to_hartid(unsigned int plic_id, unsign= ed int ctxt_idx); +unsigned int acpi_rintc_get_plic_nr_contexts(unsigned int plic_id); +unsigned int acpi_rintc_get_plic_context(unsigned int plic_id, unsigned in= t ctxt_idx); +int __init acpi_rintc_get_imsic_mmio_info(u32 index, struct resource *res); =20 #else static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u3= 2 *gsi_base, @@ -36,6 +43,32 @@ static inline int riscv_acpi_get_gsi_info(struct fwnode_= handle *fwnode, u32 *gsi return 0; } =20 +static inline unsigned long acpi_rintc_index_to_hartid(u32 index) +{ + return INVALID_HARTID; +} + +static inline unsigned long acpi_rintc_ext_parent_to_hartid(unsigned int p= lic_id, + unsigned int ctxt_idx) +{ + return INVALID_HARTID; +} + +static inline unsigned int acpi_rintc_get_plic_nr_contexts(unsigned int pl= ic_id) +{ + return INVALID_CONTEXT; +} + +static inline unsigned int acpi_rintc_get_plic_context(unsigned int plic_i= d, unsigned int ctxt_idx) +{ + return INVALID_CONTEXT; +} + +static inline int __init acpi_rintc_get_imsic_mmio_info(u32 index, struct = resource *res) +{ + return 0; +} + #endif /* CONFIG_ACPI */ =20 #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-i= ntc.c index 47f3200476da..8c5411386220 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -250,6 +250,85 @@ IRQCHIP_DECLARE(andes, "andestech,cpu-intc", riscv_int= c_init); =20 #ifdef CONFIG_ACPI =20 +struct rintc_data { + union { + u32 ext_intc_id; + struct { + u32 context_id : 16, + reserved : 8, + aplic_plic_id : 8; + }; + }; + unsigned long hart_id; + u64 imsic_addr; + u32 imsic_size; +}; + +static u32 nr_rintc; +static struct rintc_data *rintc_acpi_data[NR_CPUS]; + +#define for_each_matching_plic(_plic_id) \ + unsigned int _plic; \ + \ + for (_plic =3D 0; _plic < nr_rintc; _plic++) \ + if (rintc_acpi_data[_plic]->aplic_plic_id !=3D _plic_id) \ + continue; \ + else + +unsigned int acpi_rintc_get_plic_nr_contexts(unsigned int plic_id) +{ + unsigned int nctx =3D 0; + + for_each_matching_plic(plic_id) + nctx++; + + return nctx; +} + +static struct rintc_data *get_plic_context(unsigned int plic_id, unsigned = int ctxt_idx) +{ + unsigned int ctxt =3D 0; + + for_each_matching_plic(plic_id) { + if (ctxt =3D=3D ctxt_idx) + return rintc_acpi_data[_plic]; + + ctxt++; + } + + return NULL; +} + +unsigned long acpi_rintc_ext_parent_to_hartid(unsigned int plic_id, unsign= ed int ctxt_idx) +{ + struct rintc_data *data =3D get_plic_context(plic_id, ctxt_idx); + + return data ? data->hart_id : INVALID_HARTID; +} + +unsigned int acpi_rintc_get_plic_context(unsigned int plic_id, unsigned in= t ctxt_idx) +{ + struct rintc_data *data =3D get_plic_context(plic_id, ctxt_idx); + + return data ? data->context_id : INVALID_CONTEXT; +} + +unsigned long acpi_rintc_index_to_hartid(u32 index) +{ + return index >=3D nr_rintc ? INVALID_HARTID : rintc_acpi_data[index]->har= t_id; +} + +int acpi_rintc_get_imsic_mmio_info(u32 index, struct resource *res) +{ + if (index >=3D nr_rintc) + return -1; + + res->start =3D rintc_acpi_data[index]->imsic_addr; + res->end =3D res->start + rintc_acpi_data[index]->imsic_size - 1; + res->flags =3D IORESOURCE_MEM; + return 0; +} + static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, const unsigned long end) { @@ -258,6 +337,15 @@ static int __init riscv_intc_acpi_init(union acpi_subt= able_headers *header, int rc; =20 rintc =3D (struct acpi_madt_rintc *)header; + rintc_acpi_data[nr_rintc] =3D kzalloc(sizeof(*rintc_acpi_data[0]), GFP_KE= RNEL); + if (!rintc_acpi_data[nr_rintc]) + return -ENOMEM; + + rintc_acpi_data[nr_rintc]->ext_intc_id =3D rintc->ext_intc_id; + rintc_acpi_data[nr_rintc]->hart_id =3D rintc->hart_id; + rintc_acpi_data[nr_rintc]->imsic_addr =3D rintc->imsic_addr; + rintc_acpi_data[nr_rintc]->imsic_size =3D rintc->imsic_size; + nr_rintc++; =20 /* * The ACPI MADT will have one INTC for each CPU (or HART) @@ -277,6 +365,8 @@ static int __init riscv_intc_acpi_init(union acpi_subta= ble_headers *header, rc =3D riscv_intc_init_common(fn, &riscv_intc_chip); if (rc) irq_domain_free_fwnode(fn); + else + acpi_set_irq_model(ACPI_IRQ_MODEL_RINTC, riscv_acpi_get_gsi_domain_id); =20 return rc; } --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.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 B96EB55896 for ; Mon, 12 Aug 2024 01:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424472; cv=none; b=kGTwH9Bom4fuMcIYLtLdGk/l5qLouyMbAJiTPiBcbSwRxhx2JpFZAKnjSDzesehuVe9FdvJ5NtvqAVcp9TG136zskcA/GMS3iO+oBlKaU3rVhB84O21KrsS9E6MZX7AvncSXydikSySSCIg9u3/jASRohGDbXmbGBwjyIzSverw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424472; c=relaxed/simple; bh=kUGmilJtSEYHecokfsz1Dv8H4HmvP4hekzWOib2uw/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uC65DR9Fo+berxsvXEztXT9S4iS5P/C9D5UOsLb9P69SKNtitGS0XlyMlh9CiqTZQSucaJ2TigjinIIZFJ9yRV40AYiIYgVFMEtV7HbZPjI60fr6NwEVSOB2GTHJieWp4KnQ+Mwxw7bWMQ2j9nsrGOscgvThEpsMdREQBwKb/Cs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=kWYK6Fq/; arc=none smtp.client-ip=209.85.167.179 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="kWYK6Fq/" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3dab336717fso2632603b6e.0 for ; Sun, 11 Aug 2024 18:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424469; x=1724029269; darn=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=L2F9HlOmYYBgfOGZ5Y5XAW+7ZHo7CSZJxIOIoseG4Ek=; b=kWYK6Fq/HwdwMPdSnaD01bOjKw/O3sxBsSzc06M8JflmeLCiw8H2wVKZUrovQGpVJX EvYk47MD/ieoRgy60gt2rTOGt4lKlZJ9u3Gd81wgmKf/lwLf+OePaorIjOOJsTfViZ5q dS4LX5DgvX+qlI91hDr7yz5nya1JUYpSfOO2puRfodzSWthO4CiKL/oztDEneEo+LOEo A3fKPwRDUXTMuMXw0H/slEJPCSA3C3WTrbgEfpnBPhztFp+xE/GnghQvmkpxLtIFN9tS 1NubejwkX+KR1eaTead5IhTRpuYfmqklZKf52QEHs2x/lJsJWiJ+Mw3quCVE1FUejdu3 eQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424469; x=1724029269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L2F9HlOmYYBgfOGZ5Y5XAW+7ZHo7CSZJxIOIoseG4Ek=; b=AGMA8mlM3DgK0pmzyFPuZPGzO1lqTmG8G0c9sPadBhA7UZhY66WkHgG8jMsYQov+ns zqWHy6Gqhi/yYHvd7qockUexLMhxiBGK9HsL/5+BQZRIQ9lOIlEOPwUXE78xefZU0V62 nfmpYJOGuyqzeF6F2N4fFOUTNO2u0LphGlN4tQ0fnG+3noiiSEGM4Zl+r8ACrJVDwgLI rZcS+i1DmBAXln9iQlu04Re/4TBVe1aLq5wcvEiDkVrU6npCE3lUekpLuaLKATNlFjMI Z8sgkJ/XHONdEkhyFtTQ2+DO1vRXys0LLzepqqyWeLlUaPkciH1sgAunNVg+aazY9DCL rFNA== X-Gm-Message-State: AOJu0YzTMolaDfoniWn7pLnq0Ln6cee9lVSL4jFX5i9PvffqPO2bOAns x47kAUMEcdwxArdvZyzE91fdugcPMXhViZ94At+EROn5q5TLszSfPI9eOKcrma61HJu5hv5JbyQ 5F6AgKw== X-Google-Smtp-Source: AGHT+IHZXV1nZ3pGHtKOzIjfGzSIJM5PQQnjoEr5t/Q7EAetVkMKeElEktJkKAiBNFFJkWIu7MYWBg== X-Received: by 2002:a05:6808:bcc:b0:3d9:35df:8f2 with SMTP id 5614622812f47-3dc4169de4bmr11444935b6e.28.1723424469384; Sun, 11 Aug 2024 18:01:09 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:08 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 14/17] irqchip/riscv-imsic-state: Create separate function for DT Date: Mon, 12 Aug 2024 06:29:26 +0530 Message-ID: <20240812005929.113499-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While populating IMSIC global structure, many fields are initialized using DT properties. Make the code which uses DT properties as separate function so that it is easier to add ACPI support later. No functionality added/changed. Suggested-by: Thomas Gleixner Signed-off-by: Sunil V L Reviewed-by: Anup Patel Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/irqchip/irq-riscv-imsic-state.c | 97 ++++++++++++++----------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-= riscv-imsic-state.c index 5479f872e62b..f9e70832863a 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -510,6 +510,60 @@ static int __init imsic_matrix_init(void) return 0; } =20 +static int __init imsic_populate_global_dt(struct fwnode_handle *fwnode, + struct imsic_global_config *global, + u32 *nr_parent_irqs) +{ + int rc; + + /* Find number of guest index bits in MSI address */ + rc =3D of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", + &global->guest_index_bits); + if (rc) + global->guest_index_bits =3D 0; + + /* Find number of HART index bits */ + rc =3D 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 =3D __fls(*nr_parent_irqs); + if (BIT(global->hart_index_bits) < *nr_parent_irqs) + global->hart_index_bits++; + } + + /* Find number of group index bits */ + rc =3D of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", + &global->group_index_bits); + if (rc) + global->group_index_bits =3D 0; + + /* + * Find first bit position of group index. + * If not specified assumed the default APLIC-IMSIC configuration. + */ + rc =3D of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", + &global->group_index_shift); + if (rc) + global->group_index_shift =3D IMSIC_MMIO_PAGE_SHIFT * 2; + + /* Find number of interrupt identities */ + rc =3D 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 =3D of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", + &global->nr_guest_ids); + if (rc) + global->nr_guest_ids =3D global->nr_ids; + + return 0; +} + static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, u32 index, unsigned long *hartid) { @@ -578,50 +632,9 @@ static int __init imsic_parse_fwnode(struct fwnode_han= dle *fwnode, return -EINVAL; } =20 - /* Find number of guest index bits in MSI address */ - rc =3D of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", - &global->guest_index_bits); + rc =3D imsic_populate_global_dt(fwnode, global, nr_parent_irqs); if (rc) - global->guest_index_bits =3D 0; - - /* Find number of HART index bits */ - rc =3D 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 =3D __fls(*nr_parent_irqs); - if (BIT(global->hart_index_bits) < *nr_parent_irqs) - global->hart_index_bits++; - } - - /* Find number of group index bits */ - rc =3D of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", - &global->group_index_bits); - if (rc) - global->group_index_bits =3D 0; - - /* - * Find first bit position of group index. - * If not specified assumed the default APLIC-IMSIC configuration. - */ - rc =3D of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", - &global->group_index_shift); - if (rc) - global->group_index_shift =3D IMSIC_MMIO_PAGE_SHIFT * 2; - - /* Find number of interrupt identities */ - rc =3D 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 =3D of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", - &global->nr_guest_ids); - if (rc) - global->nr_guest_ids =3D global->nr_ids; =20 /* Sanity check guest index bits */ i =3D BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT; --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.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 973F87173C for ; Mon, 12 Aug 2024 01:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424479; cv=none; b=bB3i+FzfZ69DTzJdHmT7SNfNS01pLjn0dLfJ+tfSY2gyGhdfclPWhM/pYOpu5XHh+ric3WPYo4sh49lAbUlNk5SISMhT/QCVCLd0FZ/1AxBSMSed2Y/F+NLJ7zyy78xq0dR9L4nUZ/L8i7Qv92T5qwD4up9B84WakUGThusg7/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424479; c=relaxed/simple; bh=ReE9Srz82C0Zy/dKBRvUMOTV4htH2pkWtd/lD8GxrkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pikiGg27IBPXfCBoogrhskxQ/gw+Xg6nybIc/MJ8UIn16B1sBIvkt6Cw7BlpPKsOqCBh3RGhH4VcrVzETaBh0lcOgaL1y1RQXeOSPNs4GRhpMJPv6VUgu6euG4UnclwzEesOle/LszQExJQ8hy2GxOwWS4eocUzJeR0XGnm/Opg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=NNcz9afl; arc=none smtp.client-ip=209.85.167.180 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="NNcz9afl" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3db14930a1aso2956865b6e.3 for ; Sun, 11 Aug 2024 18:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424476; x=1724029276; 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=35RSvSvW6RgLqSoNwuCiOaL227s0j7qgYbyMMYQ5H7Y=; b=NNcz9aflSYL/BBb1Iu4U7E3ZV2leds3OzAQnPE7PnChAiJzPrtJqcpTPUF8gSu5y2s /9WCMjNCJGNC87lLZST1jk5UW9NdHkIutq6/WgGhYOi4evcH7t3+/VOMdDQI3NkbM/iS eV14jDFBJ8gtrxaHHsg+gRXXK5kCDRXvr8QlqPo4kVwgaDt0OwuPhCllkZc4yPmUy4q/ wr33oPz7RskNuPwmZjPuQ5scUYeKQg72SPKyfr8jGqF6mFhCI5mIgrSdAp+7b6qy/5pb CiVyiwWdaq78e3UCUKj9DvoUla+KpwHCNi2xODidTn1X3TRLC6TNI+/4dtT2luvy3vsb I36Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424476; x=1724029276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=35RSvSvW6RgLqSoNwuCiOaL227s0j7qgYbyMMYQ5H7Y=; b=Uy8484Kp57bYM8nUy4/4mk42T/aerY3m8OzIXFeEdw5sHJgZXludU/AoTWvR1RZOeF 5yuHmLR16twCa1zbCNfggf+0pvk/DQv9q3FzjpRzMPzEITIHQH/TylDKZhENZYQG+OZE tkuAZfgZfZTgYAm2WKikM0wpTU3xvrzoYAF8qiAOvEgCTGvUzxK4BmryAhQpDR3wZZN/ FjQyxuk/O/l5Almv23eogBu9dg1BwY/Q4R01M/zXyqJHx7caPibFPVnlcwczHAYwwxtI DAYBsnU8lctC2yKD/ChN0dFgJtS3qnLY2Zmhhb3blKzxoKwIFHGg09gklezzjOpleQ/6 nVkg== X-Gm-Message-State: AOJu0YwlZrmw90zxFnV+qXXhPvYy9YHfpWhZoizB20r6CiZo9RjKVTW/ HELUnbJzKq2U3ck+INn5Vh1WFeQadVIBf2Y57mCLJnj4UIB3YQRL9UiC3/CyrWdK8XUy+zY/DlC fvwwSzw== X-Google-Smtp-Source: AGHT+IHYcMx/Kelfyx+/kqYvp7mnCuHmz6lHSvmrk3Q0WFeD+E3yWJz8Mmv6EPhZaFQCiBxUacTGNQ== X-Received: by 2002:a05:6808:3209:b0:3d9:26d6:c6ed with SMTP id 5614622812f47-3dc41670fb1mr10153205b6e.3.1723424475694; Sun, 11 Aug 2024 18:01:15 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:15 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 15/17] irqchip/riscv-imsic: Add ACPI support Date: Mon, 12 Aug 2024 06:29:27 +0530 Message-ID: <20240812005929.113499-16-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISC-V IMSIC interrupt controller provides IPI and MSI support. Currently, DT based drivers setup the IPI feature early during boot but defer setting up the MSI functionality. However, in ACPI systems, PCI subsystem is probed early and assume MSI controller is already setup. Hence, both IPI and MSI features need to be initialized early itself. Signed-off-by: Sunil V L Reviewed-by: Anup Patel Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/irqchip/irq-riscv-imsic-early.c | 64 +++++++++++++++++++++- drivers/irqchip/irq-riscv-imsic-platform.c | 32 +++++++++-- drivers/irqchip/irq-riscv-imsic-state.c | 57 +++++++++++-------- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- include/linux/irqchip/riscv-imsic.h | 9 +++ 5 files changed, 134 insertions(+), 30 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-= riscv-imsic-early.c index 4fbb37074d29..c5c2e6929a2f 100644 --- a/drivers/irqchip/irq-riscv-imsic-early.c +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -5,13 +5,16 @@ */ =20 #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include #include #include #include +#include #include +#include #include #include =20 @@ -182,7 +185,7 @@ static int __init imsic_early_dt_init(struct device_nod= e *node, struct device_no int rc; =20 /* Setup IMSIC state */ - rc =3D imsic_setup_state(fwnode); + rc =3D imsic_setup_state(fwnode, NULL); if (rc) { pr_err("%pfwP: failed to setup state (error %d)\n", fwnode, rc); return rc; @@ -199,3 +202,62 @@ static int __init imsic_early_dt_init(struct device_no= de *node, struct device_no } =20 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 *heade= r, + const unsigned long end) +{ + struct acpi_madt_imsic *imsic =3D (struct acpi_madt_imsic *)header; + int rc; + + imsic_acpi_fwnode =3D 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 =3D imsic_setup_state(imsic_acpi_fwnode, imsic); + if (rc) { + pr_err("%pfwP: failed to setup state (error %d)\n", imsic_acpi_fwnode, r= c); + return rc; + } + + /* Do early setup of IMSIC state and IPIs */ + rc =3D imsic_early_probe(imsic_acpi_fwnode); + if (rc) { + irq_domain_free_fwnode(imsic_acpi_fwnode); + imsic_acpi_fwnode =3D NULL; + return rc; + } + + rc =3D imsic_platform_acpi_probe(imsic_acpi_fwnode); + +#ifdef CONFIG_PCI + if (!rc) + pci_msi_register_fwnode_provider(&imsic_acpi_get_fwnode); +#endif + + if (rc) + pr_err("%pfwP: failed to register IMSIC for MSI functionality (error %d)= \n", + imsic_acpi_fwnode, rc); + + /* + * Even if imsic_platform_acpi_probe() fails, the IPI part of IMSIC can + * continue to work. So, no need to return failure. This is similar to + * DT where IPI works but MSI probe fails for some reason. + */ + return 0; +} + +IRQCHIP_ACPI_DECLARE(riscv_imsic, ACPI_MADT_TYPE_IMSIC, NULL, + 1, imsic_early_acpi_init); +#endif diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/i= rq-riscv-imsic-platform.c index 11723a763c10..64905e6f52d7 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -5,6 +5,7 @@ */ =20 #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include @@ -348,18 +349,37 @@ int imsic_irqdomain_init(void) return 0; } =20 -static int imsic_platform_probe(struct platform_device *pdev) +static int imsic_platform_probe_common(struct fwnode_handle *fwnode) { - struct device *dev =3D &pdev->dev; - - if (imsic && imsic->fwnode !=3D dev->fwnode) { - dev_err(dev, "fwnode mismatch\n"); + if (imsic && imsic->fwnode !=3D fwnode) { + pr_err("%pfwP: fwnode mismatch\n", fwnode); return -ENODEV; } =20 return imsic_irqdomain_init(); } =20 +static int imsic_platform_dt_probe(struct platform_device *pdev) +{ + return imsic_platform_probe_common(pdev->dev.fwnode); +} + +#ifdef CONFIG_ACPI + +/* + * On ACPI based systems, PCI enumeration happens early during boot in + * acpi_scan_init(). PCI enumeration expects MSI domain setup before + * it calls pci_set_msi_domain(). Hence, unlike in DT where + * imsic-platform drive probe happens late during boot, ACPI based + * systems need to setup the MSI domain early. + */ +int imsic_platform_acpi_probe(struct fwnode_handle *fwnode) +{ + return imsic_platform_probe_common(fwnode); +} + +#endif + static const struct of_device_id imsic_platform_match[] =3D { { .compatible =3D "riscv,imsics" }, {} @@ -370,6 +390,6 @@ static struct platform_driver imsic_platform_driver =3D= { .name =3D "riscv-imsic", .of_match_table =3D imsic_platform_match, }, - .probe =3D imsic_platform_probe, + .probe =3D imsic_platform_dt_probe, }; builtin_platform_driver(imsic_platform_driver); diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-= riscv-imsic-state.c index f9e70832863a..b97e6cd89ed7 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -5,6 +5,7 @@ */ =20 #define pr_fmt(fmt) "riscv-imsic: " fmt +#include #include #include #include @@ -564,18 +565,36 @@ static int __init imsic_populate_global_dt(struct fwn= ode_handle *fwnode, return 0; } =20 +static int __init imsic_populate_global_acpi(struct fwnode_handle *fwnode, + struct imsic_global_config *global, + u32 *nr_parent_irqs, void *opaque) +{ + struct acpi_madt_imsic *imsic =3D (struct acpi_madt_imsic *)opaque; + + global->guest_index_bits =3D imsic->guest_index_bits; + global->hart_index_bits =3D imsic->hart_index_bits; + global->group_index_bits =3D imsic->group_index_bits; + global->group_index_shift =3D imsic->group_index_shift; + global->nr_ids =3D imsic->num_ids; + global->nr_guest_ids =3D imsic->num_guest_ids; + return 0; +} + static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, u32 index, unsigned long *hartid) { struct of_phandle_args parent; int rc; =20 - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(fwnode)) - return -EINVAL; + if (!is_of_node(fwnode)) { + if (hartid) + *hartid =3D acpi_rintc_index_to_hartid(index); + + if (!hartid || (*hartid =3D=3D INVALID_HARTID)) + return -EINVAL; + + return 0; + } =20 rc =3D of_irq_parse_one(to_of_node(fwnode), index, &parent); if (rc) @@ -594,12 +613,8 @@ static int __init imsic_get_parent_hartid(struct fwnod= e_handle *fwnode, static int __init imsic_get_mmio_resource(struct fwnode_handle *fwnode, u32 index, struct resource *res) { - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ if (!is_of_node(fwnode)) - return -EINVAL; + return acpi_rintc_get_imsic_mmio_info(index, res); =20 return of_address_to_resource(to_of_node(fwnode), index, res); } @@ -607,20 +622,14 @@ static int __init imsic_get_mmio_resource(struct fwno= de_handle *fwnode, static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, struct imsic_global_config *global, u32 *nr_parent_irqs, - u32 *nr_mmios) + u32 *nr_mmios, + void *opaque) { unsigned long hartid; struct resource res; int rc; u32 i; =20 - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(fwnode)) - return -EINVAL; - *nr_parent_irqs =3D 0; *nr_mmios =3D 0; =20 @@ -632,7 +641,11 @@ static int __init imsic_parse_fwnode(struct fwnode_han= dle *fwnode, return -EINVAL; } =20 - rc =3D imsic_populate_global_dt(fwnode, global, nr_parent_irqs); + if (is_of_node(fwnode)) + rc =3D imsic_populate_global_dt(fwnode, global, nr_parent_irqs); + else + rc =3D imsic_populate_global_acpi(fwnode, global, nr_parent_irqs, opaque= ); + if (rc) return rc; =20 @@ -701,7 +714,7 @@ static int __init imsic_parse_fwnode(struct fwnode_hand= le *fwnode, return 0; } =20 -int __init imsic_setup_state(struct fwnode_handle *fwnode) +int __init imsic_setup_state(struct fwnode_handle *fwnode, void *opaque) { u32 i, j, index, nr_parent_irqs, nr_mmios, nr_handlers =3D 0; struct imsic_global_config *global; @@ -742,7 +755,7 @@ int __init imsic_setup_state(struct fwnode_handle *fwno= de) } =20 /* Parse IMSIC fwnode */ - rc =3D imsic_parse_fwnode(fwnode, global, &nr_parent_irqs, &nr_mmios); + rc =3D imsic_parse_fwnode(fwnode, global, &nr_parent_irqs, &nr_mmios, opa= que); if (rc) goto out_free_local; =20 diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-= riscv-imsic-state.h index 5ae2f69b035b..391e44280827 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -102,7 +102,7 @@ void imsic_vector_debug_show_summary(struct seq_file *m= , int ind); =20 void imsic_state_online(void); void imsic_state_offline(void); -int imsic_setup_state(struct fwnode_handle *fwnode); +int imsic_setup_state(struct fwnode_handle *fwnode, void *opaque); int imsic_irqdomain_init(void); =20 #endif diff --git a/include/linux/irqchip/riscv-imsic.h b/include/linux/irqchip/ri= scv-imsic.h index faf0b800b1b0..7494952c5518 100644 --- a/include/linux/irqchip/riscv-imsic.h +++ b/include/linux/irqchip/riscv-imsic.h @@ -8,6 +8,8 @@ =20 #include #include +#include +#include #include =20 #define IMSIC_MMIO_PAGE_SHIFT 12 @@ -84,4 +86,11 @@ static inline const struct imsic_global_config *imsic_ge= t_global_config(void) =20 #endif =20 +#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 *d= ev) { return NULL; } +#endif + #endif --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (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 1712774BE1 for ; Mon, 12 Aug 2024 01:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424485; cv=none; b=BMsy5aAbYifPvwg4GWjdMc1LoRN6QCLVTBHT9/jmkdZ3+szzuEuTMDbi2/Hw/iHtmhA+e6Y7GFTowvGQFjPz0Hwpc9nVfimgh+iUs5bEiPWnd2DjgnmdjbDYT4p/YMnT/JN2NiLPhblFi4rT074RU9Ug3PZW+pbTJh+hlXh+Ugk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424485; c=relaxed/simple; bh=W+5wPYRyiEMTqdJlSnn47qe/NPZNGjm56TM6xxTbs9Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EPFyDN7Vd6ekwdzDNrb+/6IVdqsFaz078rAMeEPY1/pvAk7YqIGDKc90ZC7whvzfXRTigijnhvIbG/xh1bw1Ks3Hdoli/SCNfiFsg3DxlDhZvfdSgoX0d7DMKNYomdM39nsi67HD4eH8JWEsPip2DivN8HQE1wxtdQkuCPyILt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=geb3wDs9; arc=none smtp.client-ip=209.85.160.46 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="geb3wDs9" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-264545214efso2036254fac.3 for ; Sun, 11 Aug 2024 18:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424482; x=1724029282; darn=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=TMzQ3ciSNyAJUT1sxzxGDbpLjSEaz3yLiVcKcHEYKY4=; b=geb3wDs9/6yr3ZP7TovtZqQk7//JL+Lm49ngGCtbiTL0/+LxebVExKrRfxUgHPufC1 hQ/0QDP5BYjs0i0iyGhle8QnC8iNMMzHvSmf0R771oedmyEKMgIwmCaYmKuOrsRY0AE4 iNrGPt6AX+9b/8AS8+oLtvz+lkT1Yjk6AC06LMOr4oe0aEu+cwJGcuwRiKa71Uha0GDl THRE2ZiDsGZ0AQuoZvPQnb0c2iGHws8bzmlFAkw3HbC+7cXjloF5EoEnhEI8a0rRh+YG 6WxTaM8MAXH8byK73hTgAofdB7k5pUE716gVqTiTG0CpIGmOEOEhvhUquPVm/aq5uN2P fI2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424482; x=1724029282; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TMzQ3ciSNyAJUT1sxzxGDbpLjSEaz3yLiVcKcHEYKY4=; b=vYr9UexlTpdNyYhabjBzQrMHKv3DkZQGm0nKn8RwKDU4MPoN2OJgbb9SL1N40WqkZJ 2b2UXOn0X5txPt7D3cXjvwFElxoIa4fFKKZwyxZI27YYBwm4u5xUfEWwoFLHNItglACW N/lGrr/P9ZGrBoRBn4zuuzMCrXrkMbQpIe7ytDQ29zDXC1jDsDG2M/cMtTPnbh23HgL0 vLCkej914hXVSMhVEtHynsQ6Skhdn7J7ppPjfWp2Wb4UiO87UR9Z1iDPnFizDKIhwts+ BTQU8wl0lyTdvVRzWQUA53AoPJmsGfMr/OhTfKjnDCeb6UWe1fbgLCmfaZF9UTO3wsXf asJQ== X-Gm-Message-State: AOJu0YwZ0I2LOUy3ND+KfkZUsHeuWVN1Z8Smik5WLyJnQFiprVG7ae0U 5C15uiYsbG6ptSBoDwIjjCDXzFvtKeGVTjkWoFnxcX8yzDeD5NxTEJ7G55m8TxZ+Sp9i53nL08O f5PAHPw== X-Google-Smtp-Source: AGHT+IHvjLsKNVgfioV52ZJQ6mkbTpTRo5xo8Ywht9O8CCjHZJ+ipOfWkzdibzywTZdRtlaqHgD09g== X-Received: by 2002:a05:6870:e38f:b0:261:2357:5a29 with SMTP id 586e51a60fabf-26c62f9f8admr6644942fac.46.1723424482033; Sun, 11 Aug 2024 18:01:22 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:21 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 16/17] irqchip/riscv-aplic: Add ACPI support Date: Mon, 12 Aug 2024 06:29:28 +0530 Message-ID: <20240812005929.113499-17-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add ACPI support in APLIC drivers. Use the mapping created early during boot to get the details about the APLIC. Signed-off-by: Sunil V L Reviewed-by: Anup Patel Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/irqchip/irq-riscv-aplic-direct.c | 22 +++++--- drivers/irqchip/irq-riscv-aplic-main.c | 69 ++++++++++++++++-------- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 +++- 4 files changed, 69 insertions(+), 32 deletions(-) diff --git a/drivers/irqchip/irq-riscv-aplic-direct.c b/drivers/irqchip/irq= -riscv-aplic-direct.c index 4a3ffe856d6c..7cd6b646774b 100644 --- a/drivers/irqchip/irq-riscv-aplic-direct.c +++ b/drivers/irqchip/irq-riscv-aplic-direct.c @@ -4,6 +4,7 @@ * Copyright (C) 2022 Ventana Micro Systems Inc. */ =20 +#include #include #include #include @@ -189,17 +190,22 @@ static int aplic_direct_starting_cpu(unsigned int cpu) } =20 static int aplic_direct_parse_parent_hwirq(struct device *dev, u32 index, - u32 *parent_hwirq, unsigned long *parent_hartid) + u32 *parent_hwirq, unsigned long *parent_hartid, + struct aplic_priv *priv) { struct of_phandle_args parent; + unsigned long hartid; int rc; =20 - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; + if (!is_of_node(dev->fwnode)) { + hartid =3D acpi_rintc_ext_parent_to_hartid(priv->acpi_aplic_id, index); + if (hartid =3D=3D INVALID_HARTID) + return -ENODEV; + + *parent_hartid =3D hartid; + *parent_hwirq =3D RV_IRQ_EXT; + return 0; + } =20 rc =3D of_irq_parse_one(to_of_node(dev->fwnode), index, &parent); if (rc) @@ -237,7 +243,7 @@ int aplic_direct_setup(struct device *dev, void __iomem= *regs) /* Setup per-CPU IDC and target CPU mask */ current_cpu =3D get_cpu(); for (i =3D 0; i < priv->nr_idcs; i++) { - rc =3D aplic_direct_parse_parent_hwirq(dev, i, &hwirq, &hartid); + rc =3D 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-r= iscv-aplic-main.c index 28dd175b5764..cbe97886364c 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.c +++ b/drivers/irqchip/irq-riscv-aplic-main.c @@ -4,8 +4,10 @@ * Copyright (C) 2022 Ventana Micro Systems Inc. */ =20 +#include #include #include +#include #include #include #include @@ -125,39 +127,50 @@ static void aplic_init_hw_irqs(struct aplic_priv *pri= v) writel(0, priv->regs + APLIC_DOMAINCFG); } =20 +#ifdef CONFIG_ACPI +static const struct acpi_device_id aplic_acpi_match[] =3D { + { "RSCV0002", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, aplic_acpi_match); + +#endif + int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __i= omem *regs) { struct device_node *np =3D to_of_node(dev->fwnode); struct of_phandle_args parent; int rc; =20 - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!np) - return -EINVAL; - /* Save device pointer and register base */ priv->dev =3D dev; priv->regs =3D regs; =20 - /* Find out number of interrupt sources */ - rc =3D of_property_read_u32(np, "riscv,num-sources", &priv->nr_irqs); - if (rc) { - dev_err(dev, "failed to get number of interrupt sources\n"); - return rc; - } + if (np) { + /* Find out number of interrupt sources */ + rc =3D of_property_read_u32(np, "riscv,num-sources", &priv->nr_irqs); + if (rc) { + dev_err(dev, "failed to get number of interrupt sources\n"); + return rc; + } =20 - /* - * Find out number of IDCs based on parent interrupts - * - * If "msi-parent" property is present then we ignore the - * APLIC IDCs which forces the APLIC driver to use MSI mode. - */ - if (!of_property_present(np, "msi-parent")) { - while (!of_irq_parse_one(np, priv->nr_idcs, &parent)) - priv->nr_idcs++; + /* + * Find out number of IDCs based on parent interrupts + * + * If "msi-parent" property is present then we ignore the + * APLIC IDCs which forces the APLIC driver to use MSI mode. + */ + if (!of_property_present(np, "msi-parent")) { + while (!of_irq_parse_one(np, priv->nr_idcs, &parent)) + priv->nr_idcs++; + } + } else { + rc =3D riscv_acpi_get_gsi_info(dev->fwnode, &priv->gsi_base, &priv->acpi= _aplic_id, + &priv->nr_irqs, &priv->nr_idcs); + if (rc) { + dev_err(dev, "failed to find GSI mapping\n"); + return rc; + } } =20 /* Setup initial state APLIC interrupts */ @@ -184,7 +197,11 @@ static int aplic_probe(struct platform_device *pdev) * If msi-parent property is present then setup APLIC MSI * mode otherwise setup APLIC direct mode. */ - msi_mode =3D of_property_present(to_of_node(dev->fwnode), "msi-parent"); + if (is_of_node(dev->fwnode)) + msi_mode =3D of_property_present(to_of_node(dev->fwnode), "msi-parent"); + else + msi_mode =3D imsic_acpi_get_fwnode(NULL) ? 1 : 0; + if (msi_mode) rc =3D aplic_msi_setup(dev, regs); else @@ -192,6 +209,11 @@ static int aplic_probe(struct platform_device *pdev) if (rc) dev_err(dev, "failed to setup APLIC in %s mode\n", msi_mode ? "MSI" : "d= irect"); =20 +#ifdef CONFIG_ACPI + if (!acpi_disabled) + acpi_dev_clear_dependencies(ACPI_COMPANION(dev)); +#endif + return rc; } =20 @@ -204,6 +226,7 @@ static struct platform_driver aplic_driver =3D { .driver =3D { .name =3D "riscv-aplic", .of_match_table =3D aplic_match, + .acpi_match_table =3D ACPI_PTR(aplic_acpi_match), }, .probe =3D aplic_probe, }; diff --git a/drivers/irqchip/irq-riscv-aplic-main.h b/drivers/irqchip/irq-r= iscv-aplic-main.h index 4393927d8c80..b0ad8cde69b1 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.h +++ b/drivers/irqchip/irq-riscv-aplic-main.h @@ -28,6 +28,7 @@ struct aplic_priv { u32 gsi_base; u32 nr_irqs; u32 nr_idcs; + u32 acpi_aplic_id; void __iomem *regs; struct aplic_msicfg msicfg; }; diff --git a/drivers/irqchip/irq-riscv-aplic-msi.c b/drivers/irqchip/irq-ri= scv-aplic-msi.c index d7773f76e5d0..945bff28265c 100644 --- a/drivers/irqchip/irq-riscv-aplic-msi.c +++ b/drivers/irqchip/irq-riscv-aplic-msi.c @@ -175,6 +175,7 @@ static const struct msi_domain_template aplic_msi_templ= ate =3D { int aplic_msi_setup(struct device *dev, void __iomem *regs) { const struct imsic_global_config *imsic_global; + struct irq_domain *msi_domain; struct aplic_priv *priv; struct aplic_msicfg *mc; phys_addr_t pa; @@ -257,8 +258,14 @@ int aplic_msi_setup(struct device *dev, void __iomem *= regs) * IMSIC and the IMSIC MSI domains are created later through * the platform driver probing so we set it explicitly here. */ - if (is_of_node(dev->fwnode)) + if (is_of_node(dev->fwnode)) { of_msi_configure(dev, to_of_node(dev->fwnode)); + } else { + msi_domain =3D irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); + } } =20 if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, &aplic_msi_tem= plate, --=20 2.43.0 From nobody Thu Sep 11 12:52:54 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (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 17D2C8175B for ; Mon, 12 Aug 2024 01:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424491; cv=none; b=E5Amkoq1qF4vdY0bjgmHYN+pjteyJGZdCMtube13LGZpUt+5Qhs2Gsw8sAFVF6yJZGzRm9MjuQrDkeg7JuWtiu1zXM0Z4asli8w4jNYPVm7yyvW1r/hbl9HD+p7ofEJGvojbhXQXO01H7OaKHyUI/10XMPh7ILcm1Kx6Qi3KwXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723424491; c=relaxed/simple; bh=jjQu2jdS/HNK9a4N33zsmxheaJY85iZag0mOYvZYXqs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SHIAC1S4wPhHFD44ZsaWFbCkDmPMX+wLnp6uO5hf4ovEIkZEPRplPwzWb09QZLPs9qzLTuX2cwBkqP6Wrl3TwS0MV6jLHH73XqMdiidtkb6fWcQZ5PASwKlTuZjJ1lvl22FZYyyYBPTyyR/wc8pSzDYpbOuDy/kNGerwyQjAk4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=ICNYrSl2; arc=none smtp.client-ip=209.85.166.41 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="ICNYrSl2" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-81fd520fee5so150370239f.2 for ; Sun, 11 Aug 2024 18:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1723424488; x=1724029288; darn=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=cNLSK7wTLWm4CwE5KqZAhFa5+nxzSyIB3H2xsiVowu8=; b=ICNYrSl2jshsEWRsq2Glql3cDgQiaQh4SN0IRfKVs7qjozVD8tsvFyD3RZZenWU5E0 r7AChhgyKll0HFWNB1hxU1jDAAWSgzCeGqqS6DwOF6eZ1k/Z7+jtIlpwm87ipozmpzmk FcHBXGgp+YvJtxdWvoJEYFbv41+GVH3U3uqN/Wnh+dtZgu9zcZktgtAgHNwZqrPd1EP/ 3fVrZub8jwkuxep3q2b4Tr5xBxWJ2kEyUh2TUgwpFEdPRRkpiDjL/+Cg0GrJGBgOTJzi uGZMttdhxfdwEjLl5W6ZY+dSrQBoUzeo0jcLTDUqK4555WhyU5PiO1qlpvtwd9W37pAi O3JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723424488; x=1724029288; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cNLSK7wTLWm4CwE5KqZAhFa5+nxzSyIB3H2xsiVowu8=; b=NHN4FM5ts/+75P6dme1FY/33h4IvGX0f5xlK4FdRmDiGOyb4uDOOI7eEj4/19VXiJS 6GSBjtaNUG4Dksp6h1L6NOu7uhdxDnS7ECSlh+izRhzgDc9f2f42+rA4P2LfYW2UDN1i C836kNkguK4BDhhDBqp++gJVBLpfcuXUnjBNxlDaING7UjML3rCL01fg0wecoiwviTeX ay6WSaE6gTk/zHGt1Tzei+RwcUv+dexXkphoepwRpySNAWdgwoQIZtR3RkZMsVbh1FZf 4j9UM/9u8gYDuHl+1ocbACcNyZKQwcXBX72b7gxNGI1JK7FLFv+IrX+cX1CiEiFlngFo GpUA== X-Gm-Message-State: AOJu0YzdSbMCBVMqGhnFyAMw3M6hW58NIEKoY9p2cRz8KEWl3J8L6sYi p3/qCDVdCPFSm/QrT5s6OtviTp65Mnu/OzXr7tdm/C7yTikAvC9G1uzzPlkR3jDShz5r9B9FKtE IYtd/bg== X-Google-Smtp-Source: AGHT+IF383Ow04ACkTQv23O0jExDAeidajffTjgaukCfUfErQcvrXz/vXlnALl3G0O0SzK4yssEykg== X-Received: by 2002:a05:6602:15d3:b0:805:3d47:19cf with SMTP id ca18e2360f4ac-8225eedb1e2mr1121775039f.15.1723424488343; Sun, 11 Aug 2024 18:01:28 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c3dbe8cbdcsm3074062a12.61.2024.08.11.18.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Aug 2024 18:01:27 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Haibo Xu , Andrew Jones , Atish Kumar Patra , Drew Fustini , Sunil V L , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Subject: [PATCH v8 17/17] irqchip/sifive-plic: Add ACPI support Date: Mon, 12 Aug 2024 06:29:29 +0530 Message-ID: <20240812005929.113499-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812005929.113499-1-sunilvl@ventanamicro.com> References: <20240812005929.113499-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add ACPI support in PLIC driver. Use the mapping created early during boot to get details about the PLIC. Signed-off-by: Sunil V L Co-developed-by: Haibo Xu Signed-off-by: Haibo Xu Reviewed-by: Anup Patel Tested-by: Bj=C3=83=C2=B6rn T=C3=83=C2=B6pel --- drivers/irqchip/irq-sifive-plic.c | 95 ++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 21 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive= -plic.c index 9e22f7e378f5..207cfe18ec7f 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 SiFive * Copyright (C) 2018 Christoph Hellwig */ +#include #include #include #include @@ -70,6 +71,8 @@ struct plic_priv { unsigned long plic_quirks; unsigned int nr_irqs; unsigned long *prio_save; + u32 gsi_base; + int acpi_plic_id; }; =20 struct plic_handler { @@ -324,6 +327,10 @@ static int plic_irq_domain_translate(struct irq_domain= *d, { struct plic_priv *priv =3D d->host_data; =20 + /* For DT, gsi_base is always zero. */ + if (fwspec->param[0] >=3D priv->gsi_base) + fwspec->param[0] =3D 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); =20 @@ -424,18 +431,37 @@ static const struct of_device_id plic_match[] =3D { {} }; =20 +#ifdef CONFIG_ACPI + +static const struct acpi_device_id plic_acpi_match[] =3D { + { "RSCV0001", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, plic_acpi_match); + +#endif static int plic_parse_nr_irqs_and_contexts(struct platform_device *pdev, - u32 *nr_irqs, u32 *nr_contexts) + u32 *nr_irqs, u32 *nr_contexts, + u32 *gsi_base, u32 *id) { struct device *dev =3D &pdev->dev; int rc; =20 - /* - * 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 =3D riscv_acpi_get_gsi_info(dev->fwnode, gsi_base, id, nr_irqs, NULL); + if (rc) { + dev_err(dev, "failed to find GSI mapping\n"); + return rc; + } + + *nr_contexts =3D acpi_rintc_get_plic_nr_contexts(*id); + if (WARN_ON(!*nr_contexts)) { + dev_err(dev, "no PLIC context available\n"); + return -EINVAL; + } + + return 0; + } =20 rc =3D of_property_read_u32(to_of_node(dev->fwnode), "riscv,ndev", nr_irq= s); if (rc) { @@ -449,23 +475,29 @@ static int plic_parse_nr_irqs_and_contexts(struct pla= tform_device *pdev, return -EINVAL; } =20 + *gsi_base =3D 0; + *id =3D 0; + return 0; } =20 static int plic_parse_context_parent(struct platform_device *pdev, u32 con= text, - u32 *parent_hwirq, int *parent_cpu) + u32 *parent_hwirq, int *parent_cpu, u32 id) { struct device *dev =3D &pdev->dev; struct of_phandle_args parent; unsigned long hartid; int rc; =20 - /* - * Currently, only OF fwnode is supported so extend this - * function for ACPI support. - */ - if (!is_of_node(dev->fwnode)) - return -EINVAL; + if (!is_of_node(dev->fwnode)) { + hartid =3D acpi_rintc_ext_parent_to_hartid(id, context); + if (hartid =3D=3D INVALID_HARTID) + return -EINVAL; + + *parent_cpu =3D riscv_hartid_to_cpuid(hartid); + *parent_hwirq =3D RV_IRQ_EXT; + return 0; + } =20 rc =3D of_irq_parse_one(to_of_node(dev->fwnode), context, &parent); if (rc) @@ -489,6 +521,8 @@ static int plic_probe(struct platform_device *pdev) u32 nr_irqs, parent_hwirq; struct plic_priv *priv; irq_hw_number_t hwirq; + int id, context_id; + u32 gsi_base; =20 if (is_of_node(dev->fwnode)) { const struct of_device_id *id; @@ -498,7 +532,7 @@ static int plic_probe(struct platform_device *pdev) plic_quirks =3D (unsigned long)id->data; } =20 - error =3D plic_parse_nr_irqs_and_contexts(pdev, &nr_irqs, &nr_contexts); + error =3D plic_parse_nr_irqs_and_contexts(pdev, &nr_irqs, &nr_contexts, &= gsi_base, &id); if (error) return error; =20 @@ -509,6 +543,8 @@ static int plic_probe(struct platform_device *pdev) priv->dev =3D dev; priv->plic_quirks =3D plic_quirks; priv->nr_irqs =3D nr_irqs; + priv->gsi_base =3D gsi_base; + priv->acpi_plic_id =3D id; =20 priv->regs =3D devm_platform_ioremap_resource(pdev, 0); if (WARN_ON(!priv->regs)) @@ -519,12 +555,23 @@ static int plic_probe(struct platform_device *pdev) return -ENOMEM; =20 for (i =3D 0; i < nr_contexts; i++) { - error =3D plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu); + error =3D plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu, + priv->acpi_plic_id); if (error) { dev_warn(dev, "hwirq for context%d not found\n", i); continue; } =20 + if (is_of_node(dev->fwnode)) { + context_id =3D i; + } else { + context_id =3D acpi_rintc_get_plic_context(priv->acpi_plic_id, i); + if (context_id =3D=3D INVALID_CONTEXT) { + dev_warn(dev, "invalid context id for context%d\n", i); + continue; + } + } + /* * Skip contexts other than external interrupts for our * privilege level. @@ -562,10 +609,10 @@ static int plic_probe(struct platform_device *pdev) cpumask_set_cpu(cpu, &priv->lmask); handler->present =3D true; handler->hart_base =3D priv->regs + CONTEXT_BASE + - i * CONTEXT_SIZE; + context_id * CONTEXT_SIZE; raw_spin_lock_init(&handler->enable_lock); handler->enable_base =3D priv->regs + CONTEXT_ENABLE_BASE + - i * CONTEXT_ENABLE_SIZE; + context_id * CONTEXT_ENABLE_SIZE; handler->priv =3D priv; =20 handler->enable_save =3D devm_kcalloc(dev, DIV_ROUND_UP(nr_irqs, 32), @@ -581,8 +628,8 @@ static int plic_probe(struct platform_device *pdev) nr_handlers++; } =20 - priv->irqdomain =3D irq_domain_add_linear(to_of_node(dev->fwnode), nr_irq= s + 1, - &plic_irqdomain_ops, priv); + priv->irqdomain =3D irq_domain_create_linear(dev->fwnode, nr_irqs + 1, + &plic_irqdomain_ops, priv); if (WARN_ON(!priv->irqdomain)) goto fail_cleanup_contexts; =20 @@ -619,13 +666,18 @@ static int plic_probe(struct platform_device *pdev) } } =20 +#ifdef CONFIG_ACPI + if (!acpi_disabled) + acpi_dev_clear_dependencies(ACPI_COMPANION(dev)); +#endif + dev_info(dev, "mapped %d interrupts with %d handlers for %d contexts.\n", nr_irqs, nr_handlers, nr_contexts); return 0; =20 fail_cleanup_contexts: for (i =3D 0; i < nr_contexts; i++) { - if (plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu)) + if (plic_parse_context_parent(pdev, i, &parent_hwirq, &cpu, priv->acpi_p= lic_id)) continue; if (parent_hwirq !=3D RV_IRQ_EXT || cpu < 0) continue; @@ -644,6 +696,7 @@ static struct platform_driver plic_driver =3D { .driver =3D { .name =3D "riscv-plic", .of_match_table =3D plic_match, + .acpi_match_table =3D ACPI_PTR(plic_acpi_match), }, .probe =3D plic_probe, }; --=20 2.43.0