From nobody Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F816158DC1 for ; Mon, 29 Jul 2024 14:23:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722262984; cv=none; b=D2R3xbsAt2Ty9kQ1FU/QeX23TxP1ZDa/vR969URsxzGAdN7ku72A4JUkm6HrAeOkWDU0PEnEl/VAl1XaGlEIJ8Dh9hYC0mna1vPuY5aIQSlRlhu4rfZkQCXKxdFcb7MrOxF2Ddy9Y/0QAGubepNEtH95T0km4QGMdQo0q80gUO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722262984; c=relaxed/simple; bh=E6MzcbhzI/PGtTwApoh6t+ad3dRwfD8hZuxojAhqTbk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KLcYgK3M3Bn6jpZgdeH18mfiIxLaojChm8LDUpmGq0UWSktmxhr9f5pdWagp11N7VOD1inrPfkNIDophyHtkjZvsVnydZaUpL5GPpVQkUtAxb7wzUzbWvlBPM6YzHWGM349DOjmHYJsfxJ0ZD//jLRWDAM4sajHP8U4A3Z6sxjY= 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=l5i6JqC7; arc=none smtp.client-ip=209.85.214.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="l5i6JqC7" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1fc49c0aaffso18627875ad.3 for ; Mon, 29 Jul 2024 07:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722262981; x=1722867781; darn=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=A1e/9nxDibJ070eAfg/zT3PtW3/KirZQ3ZpE+at0v4w=; b=l5i6JqC73q+E3WdtktbZGRRb7wrZqWQJuCO3QGBsVgbxkY52PHeBpIvT3NpvEyabSz DxP4OLPiFKnleDfilHNBAL5cOQIzuoMxU7Hep2XvMujqpxLpwZEy9dG/bgwFflfuYFM+ gU0vKPfZrw2unVKRAuH+snYCwaHu9hTjfI7UaTKx6+vmy60WsogsuYma0a9IpPtA8rTa rrZZZ6aPjZc2hKjB88Mp96DHXlIUj+aE4xQd1AW/jsBSvWMo4a4GgZac5AXDWSGsSKVy 3UGFtRzhEE24fIdXoh9rUN/buQng3FP76Fo2SsNz3Y1h2hyR+EcnuUJlqDknhz81xSfw kEFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722262981; x=1722867781; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A1e/9nxDibJ070eAfg/zT3PtW3/KirZQ3ZpE+at0v4w=; b=Kn5El3gSdjF5En9ahpnOKrc5fQKuh6fEuqrlaUWlDXAj9Gpv0gbKuLoD1GReV4wW57 xj0Qc2yzmnADb+9N9JqvD9HaNEYXVIvueOaOKBdV273DCnoa/Gw/YFKmLUgqdO37iL6O y2N7CEKMYgr5G3TBAYdk0SHRDA1aiuhctrNfiNNItGBsFrsQyth265HcFL873BcpVVhN sj5J560Edx10nxGONefrdUiWs+MwFv4UstChY2i3s962gqeew4Dzp1bMfBmgmAetJ8YV 1eMQkr/kWNepv+s60h0U8GWWi9Tr0MYEM+XwIYP/weh7URkBfspE1O9oRMfYKMz2vTzZ qC0A== X-Gm-Message-State: AOJu0YwO56RNRj8sy3Ifvs42BUoWVQMzOYBQKFlyYgm5ed4quUJntOZi hBW5wDAuygoQvWv2EBa9e2rnpiN28ZTQJgHrpb/WBr+Fdn06ao+XqcIuWeIVOdou9mUD1++jKmz iz1GR1g== X-Google-Smtp-Source: AGHT+IFORLmkj32RLEBpuI2kgsPz1jemTsoN6n/Vf5+kIYun2OskeuAkA78gnrEr84cd/KJkiH+mDA== X-Received: by 2002:a17:902:c412:b0:1fd:92a7:6ccc with SMTP id d9443c01a7336-1ff0483e03emr60207015ad.30.1722262980776; Mon, 29 Jul 2024 07:23:00 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:00 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 01/17] arm64: PCI: Migrate ACPI related functions to pci-acpi.c Date: Mon, 29 Jul 2024 19:52:23 +0530 Message-ID: <20240729142241.733357-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 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 6C1B518E77B for ; Mon, 29 Jul 2024 14:23:07 +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=1722262988; cv=none; b=FUVIvjCeHfimRLJEQ99rYNngjhtNKBLZYpCHRqnpe8jTnpO4HVlgO2MF76v2PviwBDL/ENKO8R4+fPx3cOHBTL+Vr6NdxrNc/8mLNjYCgfkASjZYrHlAczGfqYORGyon5nomx4wkFn6fXjFeIhvGOo4TWipvGDjWAf0hvdPiFyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722262988; c=relaxed/simple; bh=dIAC5ACjszKWc4p8Ai+3npuM+9XIxGXpMSvp0kw9aIs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cEg/nZjuo4MaU4Qvn3wPBwUratj+QfDbp6qUL3x4u5yiHhWBxjLsXBH6V7Uau2HT3arrHtpQCU8H8q6DbEGJjf294HkyFv0itXg5ops0jbnnHUqZjge636Nx/bCgqUMU18PRTsPauqB179odeozI/TIlLbWhr9nRrDH381qFYLE= 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=O3hMCUdp; 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="O3hMCUdp" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1fc66fc35f2so19359735ad.0 for ; Mon, 29 Jul 2024 07:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722262986; x=1722867786; 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=1v7P8DgVWEOiQraKJZCp7Th7levU77nqOCGgGfYFy3k=; b=O3hMCUdp+5sEdNHT6tV4YjWbFZN93Ltj3VUd0YhCVu6egiGxVaaWNKV/+S76CeyAiJ uNQQWz0SBQO8wkk/C5moGSSQP6m1862sjIvMqJE0kwHvJtWV88AVTm/WemL1c62vEsC3 MGzQtWvw8mFMSN0H7sUuFxHOSZQX7fRGOPHhk4vLFFtfyTn5Cjx/7UHKfH0GS0xSighV mjE2JL1Iq2csGdMuyMwSxIkjYWiPE/KCpezECmqNDm3UvXEVzqAKC69LixadXpYrIWC5 9zmEei+V0TBxNc9QiVF+oYrSBlda2cF5mN9NVv8aPBWeVR5UT4ypj4EYR4WRdrPlaGZq +0bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722262986; x=1722867786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1v7P8DgVWEOiQraKJZCp7Th7levU77nqOCGgGfYFy3k=; b=KkWpweTrqussrwcZoBTA+1ZCx8Tbuh4LYJUBoy5e66KSYl5WRqAMbHsUWr6dlrN2qc Z7p9NhNZO70FRywSbTLCkXt0tumNRhvaVHhLEWVBq/EYpMdXXMQX3dK2qEpDXBlIBPLM L2ZBL6l/AZYI7KbM1R8cjd4SWNB+JfU945OC0BYT+Kzk+NzF2JRmDBq4uFkS0fLILOR6 VTubsQt6mQ9I6BCDI97Wrr2s89iGJcmoVQEsV/D8XdPsCkxVVSxuxbiyybxaMYGgLmhN ozbKYX5yaFBRQAKy6PFgk59qX1Gz5cpTA/SB6uZjadzoFWfo1spDUHhAnYh+qb8DUuW1 m4lA== X-Gm-Message-State: AOJu0YwLd6w3wIPH2BNbSjtBsq+esHL3+0i61JTRKiw5j+cmAK86iZi8 011W76uo7vjT1MceYJEZNS9k4PPOydX0b1jBNBaygA7bz09lsqrZoaGSJxjQiXW/+5AUL6+dJQ0 SH9NW9A== X-Google-Smtp-Source: AGHT+IH0i4SJoksic7K7uCsgqP3M+9IpULgJ5o8eJTMb+FKn2Lo8UBe751+qjL2E7UCdZzZIpyOlyw== X-Received: by 2002:a17:902:d4c8:b0:1fd:6f24:efad with SMTP id d9443c01a7336-1ff04b01aebmr124703345ad.26.1722262986279; Mon, 29 Jul 2024 07:23:06 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:05 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 02/17] ACPI: scan: Add a weak function to reorder the IRQCHIP probe Date: Mon, 29 Jul 2024 19:52:24 +0530 Message-ID: <20240729142241.733357-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 a architecture specific weak function to order the probing of the interrupt controllers which can be implemented by different architectures as per their interrupt controller hierarchy. Signed-off-by: Sunil V L --- drivers/acpi/scan.c | 3 +++ include/linux/acpi.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 59771412686b..52a9dfc8e18c 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2755,6 +2755,8 @@ static int __init acpi_match_madt(union acpi_subtable= _headers *header, return 0; } =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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C26D7190058 for ; Mon, 29 Jul 2024 14:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722262994; cv=none; b=pZkcdVfyG8NAUwqgwEQ8Gtniy4lyWqVoJHSGFA13/EVcFjX7tsXCBjKT1/Zrey/XAT1+7G3aMD3jI2gap4QK5aLi/XLxov5li38tKX87+uVNIPBkg2Z1PD1meUwAxFiMlhLdWVIPNcqTmyDHVdk5+LQwMUQh45RXZDsFFvJLPUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722262994; c=relaxed/simple; bh=My3CH+lxqRC1ZfX93NQY26GkZQdIRwImIJElB/31blU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uc4ilJK8KvN4VzJ+jKNvXqKpE8VHYod3r5ai7zCfuJdHluJAyxh2rwDIze9XhYhCCctO7t1KKXFR4jwTcawB7QvzKXHV8gaSyedV2qXXYhu0edwrRAey+/7mMG5uMniBgDaSvXpa+OwQ2XVHe+0+NVITdht5Oq6MNHRmZmLPzek= 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=S96h38p5; arc=none smtp.client-ip=209.85.214.172 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="S96h38p5" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1fec34f94abso20410575ad.2 for ; Mon, 29 Jul 2024 07:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722262992; x=1722867792; darn=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=fpUpzTn31uAv59eRsYCCTGHf2UwttQw3/INKSz7Rgp0=; b=S96h38p5rNgdz2Z5AxqkZ6Ai5K2pBUiRuuNHo0IejcAZCJbFDuYHUybLcuySTdCMyC LSvUny/wRnu2aImVGnDfDN6I0O7s6CfcOpEdTHbn1usfneS9mi5UxaOqpsOqV/dnfCy8 HQllK+QMtxHbXytWCpKJY9cBJ5V+zUyVanGFXwyd/WoG1EF30q/x/Iv3mgk5dKf5rFcU VsN4/S9XLrxgn9I3u4IvPflMZpKhWQaaWpRiTQ9fYyFavFf/QRRS3Q6YmqcUIRUBJQA6 pgsEScJA9DaSyF6fqWzcCvpZfwDHd96wLqlEADZC9MlCw8H3NHkS+pgVcRG3ZNp1bbZy Zolg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722262992; x=1722867792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fpUpzTn31uAv59eRsYCCTGHf2UwttQw3/INKSz7Rgp0=; b=Eq8bAP4TQuI5AORRxqfPFUv7e3qkUZKcVYe7Yrb/3AOyiRCBiEQyyHL7Hdesc+oKk5 huX54AloZV/mQvyk8EuXWPJ5fUntcZ+xwSqFgUxJpiqBU3sy8wqvsg9Cq6t98kUQxPI2 YwsExhWKprmSP7Z10PHhrHxUSCt7QIhPkcD+ycd6Gr85GKDKIelYoxmj2Zsh1rBw9Dva 3FcPgAUKQyLlyOI4CQRsHeF9VJbVScNIb8RkZ+U7ZLsQVTnTTjPjvv/7T4NiVGRzqUOu ju/X6Un2c+3QgwM59xSFDpfN6CCGjcxkWefRnI9ovYO+8VBUczq7Q/9dJdGf84jWh7O0 +XZw== X-Gm-Message-State: AOJu0YxJ84wHaosxDaBxVyvAVXRYBBxicmebpAOfUlV3LmkTyIWPkcDE gc2eaB/PJfl+SHuuEecGE15yvpEbYp8pO30NuEwyljoIZ+qm0bz+tJY1veEhLBHXAgLIa0N949W TK+G1Jg== X-Google-Smtp-Source: AGHT+IH8iPMjHAqTJtzMrAyY/pfHaeY/boKXW8uZbGvPFkTDNr09tJ3EGqjomR/myMHI4FJBrBAsNQ== X-Received: by 2002:a17:903:1c4:b0:1fd:668b:ac4b with SMTP id d9443c01a7336-1ff0481ada8mr54039975ad.15.1722262991841; Mon, 29 Jul 2024 07:23:11 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:11 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 03/17] ACPI: bus: Add acpi_riscv_init function Date: Mon, 29 Jul 2024 19:52:25 +0530 Message-ID: <20240729142241.733357-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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. Signed-off-by: Sunil V L --- drivers/acpi/bus.c | 1 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 12 ++++++++++++ include/linux/acpi.h | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/init.c diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 284bc2e03580..48d277657203 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1459,6 +1459,7 @@ static int __init acpi_init(void) acpi_hest_init(); acpi_ghes_init(); acpi_arm_init(); + acpi_riscv_init(); acpi_scan_init(); acpi_ec_init(); acpi_debugfs_init(); diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 86b0925f612d..877de00d1b50 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y +=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..5f7571143245 --- /dev/null +++ b/drivers/acpi/riscv/init.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023-2024, Ventana Micro Systems Inc + * Author: Sunil V L + * + */ + +#include + +void __init acpi_riscv_init(void) +{ +} diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 3fff86f95c2f..892025d873f0 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1531,6 +1531,12 @@ void acpi_arm_init(void); static inline void acpi_arm_init(void) { } #endif =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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E25FE15D5BB for ; Mon, 29 Jul 2024 14:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263000; cv=none; b=ixF1izmnPdZIMSwk2vuIlkNZ+UrGc2FPxUiGPO8JnEOzgbaRjdMbW6tw8dJIVxrKsS44mUHZBHeaTbld/1ycV215to2sbSqSwdaRIFiH1KTp45k34+CPMzOJoLQqqWjQKlAqG32lAPWi8U+t1Rr+Tacev1HP6y7MIRI0ZO1d57w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263000; c=relaxed/simple; bh=gYe8Acoq1pYfCPuSY82IUXZ3f3Ne+bwOq2e9EgeJCLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qz+qmGrWE1t5McxBfravoqbE97BKrltUv0zrg9fKCkMJ6RHHTRmMqciGYLl1DH8XNzFP5DZOdXSIQtihrqtP6Q1oLPQa0W6sRlxaBSR0DB34qXc8puQEZHZwpdMWxQnj0s3nVnYJObPDsmABb6So1Pt165se3cPZcw2To6FBLxA= 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=NDPSipNI; arc=none smtp.client-ip=209.85.214.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="NDPSipNI" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1fc60c3ead4so18740305ad.0 for ; Mon, 29 Jul 2024 07:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722262998; x=1722867798; darn=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=sQDYeCPMpR4X4S963fAEbe/mK838iVz52tFUEQviIac=; b=NDPSipNICF5gageMHOUZtWdPCli2tHzAKszMpbnEixrl48hxBfMhpZdUZ1m3XUV7dt tmMNb09uFZLwsp8L1+fPOxL7Juc+BZPzRsVDrGsH49eH41VwLS+lloknFpBCSkxi6Ei0 Sx1bUFfl1eDrbp5kogU+bx/wyVQyJME7xri2eFtcQGDUZ6VOKnAJOsmgae52d9usw9UD kh+TDfDEMFav+A2ux6dCrEDqkfS8KmHZcI6tDDnj3Tux+utMqWBvFE1aZqXEmNnFwiCT tRvuH9Noyc0Sh+uuagC/pNJUD9E3/yaBsnxV04EWS+pT9VevxVv+J8lfAr1uE0HrZ9zc Vp3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722262998; x=1722867798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sQDYeCPMpR4X4S963fAEbe/mK838iVz52tFUEQviIac=; b=lMYkCYgnH0ZjgsbRP309EBktBRgg3of8rjLUM6eM3ME4y/Gb0T0Hk1hrpcqMiw4IJV H6FaKAZwGeAPLxDsKmEVqNmdDlZ+Gz74FenZ7nTmViboz0PlN2QK9SIH0hToMvuLnrUv wVcD7M1eaDU94CSC5bB2sts0Sjn6fkn0sxHrheeJQZx/2EvSJAc6Wb8+YGkxTmqG7B1c rvdex+2yh371ZVs+N1AJtvEPjbsSYFB4i/itnlCU2SHarho8Gv12U7vhpLfaSgjqVX1v zWXvGeAY14Kk7CKhKkFAUho+o2/lfH98/IzFfQ8NHdjt2uBEuzS3sJ2Bv2lhNCpzIHaO OfnA== X-Gm-Message-State: AOJu0YxDqGMIqEbdnZAIjuqVVVS2eAzJTeJtXGoKoTYE4QhihQ+p+yTB cyp3+ft9c15x3PIK45aNC290zoYYlxOJdlLByYQzL/CRlgqMWem8QuDKGuH8bVcWc6GleIUkqZw w3tMKMQ== X-Google-Smtp-Source: AGHT+IHRfKhuOi58y2gNq6JrnPRM6LI4wl21FmFrPGpsAor4rfs3r540grBj2gDL5SzyBewH4Ncnbw== X-Received: by 2002:a17:903:189:b0:1fc:4197:d786 with SMTP id d9443c01a7336-1ff048434bcmr60175465ad.30.1722262997684; Mon, 29 Jul 2024 07:23:17 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:16 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 04/17] ACPI: scan: Refactor dependency creation Date: Mon, 29 Jul 2024 19:52:26 +0530 Message-ID: <20240729142241.733357-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 8EC80154449 for ; Mon, 29 Jul 2024 14:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263005; cv=none; b=Ik/49yeLtmDrZNeHaAGfF0BMvZg71kTOMHWIp1GTKnysKQBa6IIbH+w/Kp6rSr2EPOJiI2ImlkpmZ6HxmJRRQnSu/j8EEDBQ/ek3VrqBNTN5h06qgCtoK8CEvtxnl6tm5zlhwKzhf5IUKV9vGwEt0X83rxC4WDIhleYsht9r6sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263005; c=relaxed/simple; bh=YbAVdkDhATK17JF+AivZDXdHFeXfvAlpUUxX6dv05dQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lH+ittE7xITS3Nal6tkKDr340vjML62gAK1h38DeQGLpOo2FM+INoiYZHj1hL8oxNvFce6smu0lWWz/dNniOSYl4X4bIkznvxrQqn2SbnxCUI+Tl9D3JuzQZskAB3ZOX0p4Uua9vr6K1v4rLCsniwMIZ4tc5726fjU+PNjoc/9Q= 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=FEE6VnZ4; arc=none smtp.client-ip=209.85.214.176 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="FEE6VnZ4" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1fd70ba6a15so19916025ad.0 for ; Mon, 29 Jul 2024 07:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263003; x=1722867803; darn=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=IKYwRAs6GZjX8rwxqPz6RZqcRKMFxP3sTbkHp6BG6OY=; b=FEE6VnZ4rAL+FkT7LSCfu0VHTGypLrQRDKjJwUX1tZ+fEINSmBB/lB7f2P2tqaen9F OF0X1WlEYqu3t5Tcx0chszc0kT+xmjOZZZ/razbB/zuiCmxDWa7kIZU823mGokl0EOWx s62dYK4m/mrfbzAy4NpnbVFGQ9VbULe+RQ4dUqWQBeOCWiDCFMl4nXu4AW/xJGbgWr4L nY40g1F1WuTJAuje+DHa0TTvP9ZhwfTfvUkKbdnPNWiPWJ+5QOclo7LNRFZlpiogd2/f IwTQHqtTkbe2V4e3uNxJhWUHETlTKFRIAoI8Yr3slUQg7ckmvJOffNQeOwgJrp/Hitwi QKbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263003; x=1722867803; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IKYwRAs6GZjX8rwxqPz6RZqcRKMFxP3sTbkHp6BG6OY=; b=ZDKmFm4tFyEFKRmVUpij5lB6Ml7p24f8g2b97tRyfQL4xeZp2q0hk2PJG+lBx/9SJO wcHvRTisfRA25rdZm6HpOt/fvOiXOkhLNbItNQk2CH+1hJYpQL0UTS0a7/r15xS1FyOc VazHQh3O5yiYEPAfUL18AsgbB04oZVvlkNxMBBHX0ZemJTs6YeJ4Uf1xRuxkAzZ39wJY U3+nwnuTh20AxwfAp/oV5eapAHXjxBji8jxuCXrnWNKtlSnYmS+Z8RUpf36lnvF5/pxR Dy9FeviA+x/zSTCILb0zgLvkODqYc5PlJkqLwMvecQ9sAGQt6hZU1t1KoY0KEWh/okgj +SNw== X-Gm-Message-State: AOJu0Ywx365zPfUpUAyW6BlDtsqY/KX7/uYCQqBBE+3zsrO1g8zYLISO a5WX+ax6WjiiISXGnMTeDmnH1jCJ9oJYhWnQjNEJlv9WiC4WvLzUVhdGpZVexQQNq5i76jM/jBI /a7z6vw== X-Google-Smtp-Source: AGHT+IHlmBVDHSe6PUvNsr600YNWcBMY907Dx80p++dt4s49fUoZ70tkMwcDAnmuTUCJtN3oxZs+cQ== X-Received: by 2002:a17:903:191:b0:1fc:6b8b:4918 with SMTP id d9443c01a7336-1ff048e1db3mr52120535ad.41.1722263003482; Mon, 29 Jul 2024 07:23:23 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:22 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 05/17] ACPI: scan: Add RISC-V interrupt controllers to honor list Date: Mon, 29 Jul 2024 19:52:27 +0530 Message-ID: <20240729142241.733357-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B58015E5CF for ; Mon, 29 Jul 2024 14:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263011; cv=none; b=ZpuMuhS3HHoj4bQzwKchTbtxU4NKRN2mTPCKxhIRqnDANcVv45Ye9vVAHdTGezMM9dI7Cc6igsRlzRUZ0vXcYg/NDyRUBQAuOAW6mqdfoSocz+GzfPXv6dUXsAlQ6+3703vA6IQFJgB7IybKKvCxD4VFe6EMC+DAmDmRrTG5szc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263011; c=relaxed/simple; bh=RhFi/JwaWzrMm0sTOK6QJBNwoySQ3CPNvlWykemrPCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i8a533A1TcQBO3sXd31I/jtP7NtG9xu1IkhB05YyXIqafvXZzs+ElRSZ4I93aXm9wyhQv5PSs5UPL8TfC2A6CH25WnGyJYZSZDMus2xAch+VWjCgfxIDZ7Dz6vXDr4Bu6L13y/iA0fEj9cMba1lUZ+yEk6mHLshhbG2kdz9j5FQ= 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=nU7dBGKy; arc=none smtp.client-ip=209.85.214.169 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="nU7dBGKy" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1fd66cddd07so19662425ad.2 for ; Mon, 29 Jul 2024 07:23:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263009; x=1722867809; 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=ivFx7Eb2KNlJll+d2W+eJ7NSuljATLtswxxJxue4OO4=; b=nU7dBGKyqerN4l4YAtdJtppiWdsYee/nj2Cqxc3C+o33ZRPadxLThBbCblo0wBJF2s A7zhhpg795jjXZAHHmhVtSlO8Ev2BHV2EvoGDvPw6MxH0TtdcoWYQ/Mhq4VT0eR8fvfL 1Dr8r/YRLJ+kXTX3jKKouSUt7b1agc12JnuNXOH1j1Hs6yKzCS9oqVth0ur2JXDqIkxT aPERfBdCy+HzSQGi0WQfpHivQHh8qDOQ8gXrEpBQiH+vijtwp0SJZNIU225ItdAvNlfh kMLXNc5rxAXd2Qhkaz/kQ6f9fmqTuRM16M+hZlphwVANjpsc+NKTtzCIzZJ8qXWkCA6i jM1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263009; x=1722867809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ivFx7Eb2KNlJll+d2W+eJ7NSuljATLtswxxJxue4OO4=; b=ZIEib8vxQnhLx0DtJO0qr5MnXg4IXcdxvOZCvaYPO3cG/a1DkRWvs4FJBNXJMWJjHi cqKZPxkgoMjzA2ptOUVViHpkswLD+BvXCKgSgzyr7W1ByHm4lPDOCRU6ROgatQDmAaJc V3NjZaxL0pk6p/tpAKLIVUOpJTL1M43jI5f1yQW7jWbY4H8Om8jrcReaZh7/AM9YqAOI eBD0V0UCXRKcs+9NoMDMGEbDfPSS5/Na0BCCUJiP2EgL4STCxbh6DQu8osYS2wAZrrHA N+L0GH4n39J+di8PZnlTpWvwF3SJE8UnlKmMJej+V/ZqOVr0vkNvKs2O6xU/ovLAZjPx NV2g== X-Gm-Message-State: AOJu0YzFnEGYCxh5aRCVC+SH2hdmymDVwMQ14SH9mUU+rR8IAKON5rml UAXLuC/AR1JrfjKXlNa7/n1BcGZRrQ0IwYvnlhnTvDwumQSpmeWb2WRCmtDm3+7Q6zwF46BQupO HB0qh3A== X-Google-Smtp-Source: AGHT+IE8RqsmNLGZwn4UKGI9HbMHE+3KC0OV1lt+Ckv1MptlwMQ/WvrHjQX+XujtO97bjUDIb+rzyA== X-Received: by 2002:a17:903:234a:b0:1fc:369b:c1de with SMTP id d9443c01a7336-1ff04805ab4mr61618075ad.5.1722263009198; Mon, 29 Jul 2024 07:23:29 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:28 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 06/17] ACPI: scan: Define weak function to populate dependencies Date: Mon, 29 Jul 2024 19:52:28 +0530 Message-ID: <20240729142241.733357-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D86AA15EFA0 for ; Mon, 29 Jul 2024 14:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263017; cv=none; b=pXNJbFgzn/rId/hIB5cAN4sM4zJhuHwFFP2nENh5D4esHzJXPGuK1TgHS9sXk1fZ4b2+5xtxioHCksLP2kND7GMyoSB5xkW7JOFYc7cJwXQo3xR6yXvIyj0H9HkspY8oId59C79HF16kRAvI7LOdZNKKoKNN6Ce+sVUPEwpH/+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263017; c=relaxed/simple; bh=qJRebCqrm7pwIO+IpT+0VoIBqHNcWGYUdekFfnvXGMY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IlL+VnF2bjmkoxc0IMB80NB7XeetApUYHWQOZroY5sCkBtc8WfaSKwLn3MvPqyzG7m46opHzdgd5E0ugIkAK4IaBk/glGVgzJX2i5NorKa+epczB8tzW+x62HUM/VtirTZ/5c1P3W+MXlU4TZSStBACj5gd2eGZoA4gfDVcPbcs= 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=TXHKdDQ4; arc=none smtp.client-ip=209.85.214.174 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="TXHKdDQ4" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1fc6ee64512so19632405ad.0 for ; Mon, 29 Jul 2024 07:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263015; x=1722867815; darn=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=w6K3rvuzx+kcxCA/RkAijYB8PiaVxGHgknWl7+W2h8I=; b=TXHKdDQ4xIAxUmFpLGgGpg6RiblaD4O+4pxC6YxCVCqCBZSjyQAJHBO+Mn1Y0Ug2lR lOCvFgDJ/SKX/IizXJkfW9Pt3lstAwvxjGsZ/Fd+gNw2WQhFqRN4XNPTeQSTmvs2dUT+ 2aK9IFObYKe2Vg/Stk57hfWoop6m/ScE/3OPjjUDbMdrQRybEFTuTUNxQmqRXf8+UjD8 xeNJQvhyidWRZqbZk+1B655x+RZZCbs75EZpCiEvZnqSkUZz+qmQ8ipiVYr0gGz428aq Fw8HDIK/2nVJbtp9nrXrbBYbs2VrK3KVAljS+j+Je5A9pSMIpiuaqqPcA2oGVV4vHYuW JUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263015; x=1722867815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w6K3rvuzx+kcxCA/RkAijYB8PiaVxGHgknWl7+W2h8I=; b=G43JHQulc3G1hWcB/nzY7h4qx88anDUd7w46lEFERcLqe/kZtkTRCMPUWJ518fVTWo 2SRmBUflJ/wEA1JpaBBkNfwiGw4bFrwnLIjry6bhU3nNKnAxaxzrVq0qLlLs2rDLZK29 dfqVlzrGcwcNX5rhhU67ufMMvtuaMegKqvvMhd+PvhflCCK9VaWeO4/lWGPN+hp6AagG nVfO442Ur+QFcEtpMKKkylz5bUyhNDAiOS3dLhV2ai1WyleakxY6XKoxX+kpj3kLTiJP Wr55OTlLzqj1f9QlBBe0UaTpFMWwJbB8ADJJ839K4SwXjnp9xXeGKArVg1Om4OQBnmvx dYhA== X-Gm-Message-State: AOJu0YzPSlqvCuptdNT2+2JGeKZs+lpXxHaXVcR+Sjdc2SlPcZJdb5kc fJvLr2RyuzSk4ONYDnhzLjSQFkB07aoXKO3I2ImPbHELSapvzoxl6KLtavTzCYh9AOtsAFUPfYI MO2Fb7g== X-Google-Smtp-Source: AGHT+IHuqnyr1wGz5leAhutHIAJO97R4WBnGGYBJopHkXMNgwgilRpOmng0OCq0p9dkCz8Wkxaglow== X-Received: by 2002:a17:903:8d0:b0:1fd:9105:7dd3 with SMTP id d9443c01a7336-1ff049711f5mr56820415ad.64.1722263014706; Mon, 29 Jul 2024 07:23:34 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:34 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 07/17] ACPI: bus: Add RINTC IRQ model for RISC-V Date: Mon, 29 Jul 2024 19:52:29 +0530 Message-ID: <20240729142241.733357-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 C7E1415EFB6 for ; Mon, 29 Jul 2024 14:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263023; cv=none; b=ikLYL+VKWaj8TyxVUuuE/dAXPOsSarc0OA5hLVnuvC109bQKtnTVXCnuuOkCpyLe83W+Cxg4l8eLUMujFV5+qjmGr5xAFE14EuIhz616Xxt1aVma2TW4CcqN4JRNNcQ60wOuoYi1f4/+TBBMTE97/aKc69gUsOii0OJz6mmi3KY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263023; c=relaxed/simple; bh=clij5LMJhAkONXrZiTSgfsNtHRNuVw9zPAYSRnbzf08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mHSkW5lFFL9fDOJGrXoS1RmyDgU3N1QNO3r28/655s1UAQYBItMbnJZ8LyoUPbogZUoXrbCB4KB25Dp4yDf4eLmWHQgsdpCHSgCounbgdgt8b4jwPBqCypDPJyHIL273ekwQNzvt7NWbVzdGlWQQGNIet80n7trk2HtozEtgkY4= 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=kC+ig75z; arc=none smtp.client-ip=209.85.214.176 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="kC+ig75z" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1fc5239faebso17764595ad.1 for ; Mon, 29 Jul 2024 07:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263020; x=1722867820; 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=SFDunmtzDxNSJrEf+jYEf48MjjKh1U2DF8SfSHqhi3s=; b=kC+ig75zr9kQ6wgvHx8coZNoz+ThRIKd7bC8Mmb+UDrie+D5uoI5UsVP1QcxdumVnn K6t/W5c+qgzoAPOoB+w2LDDc6VmkakQGx0sHjv0QXQ9zQtiDe0Jker6YDq2ANH0mqvjY /lSq2Vin8BFgynt9dEXKDHIb3tgnl1oDqm7p/UuBX/tq/DNts6qiCdW10dZ20KVWpxhD lgri9u5YNrd0oC+BCKmcbrDxKmFo4u2BdQ3k848kRSdnc0Yqylk7LCv+0nKATcKRtDLf B3jzryaxAMH7GXigiR9c5facqWQfQkFIJEM4g9ZtExaq/1uLHSE/aWWZvFd2/od+IFDv h/yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263020; x=1722867820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SFDunmtzDxNSJrEf+jYEf48MjjKh1U2DF8SfSHqhi3s=; b=oZc9xiKbZJCkgR0C5xZkwrCXiNPkN9GIooA8sHFBxVpaRkRSVVeRd/4PAj4t+zp6XF +mLpgoS204+RvY0GTJU1R+GdZPSrUZQvi/ZdFFQ+i/hDwRUPV+cAHqUTSLvSQ1NEDihd sIOzm4RfKxWaOnwT89CCpGDKeg6T8y0TEaNaUacq1yjuUvaY0o9AJ0FZ8fZKUMZM5fCg ++CLwO920GSB2zXOxZUtIgX3OMixENzjP/+NwlbFac9WSqPKqznTZpx16m5NNeIgDydW 6Uoq6S1hjSyUmZxfm/7f9jxW6VDK8NJCy/aFWzMZz9hVIpkqU0xrURAn5y1fsLTOaUR+ Ol0A== X-Gm-Message-State: AOJu0YwC6y5SGF06Y7xznKfJ1veHaMRId1SKiHnPz7DoLKUlVtKWT0XO Uv/AGrOjsvdAH/kwnpiz0gv2RHy3BwDV/Ubw57LE84bV6ehV6bvywDDfp0BU7Kfk/rIn2PEWis5 ZmYhZwg== X-Google-Smtp-Source: AGHT+IGU3odbD3sPqAp4C/YNgby17mm2kU5A273xs06JOeimMLExymMBUikKyGUV8C6cXEETPaqERA== X-Received: by 2002:a17:902:e84a:b0:1fb:82f5:6641 with SMTP id d9443c01a7336-1ff0481bb94mr68486545ad.23.1722263020193; Mon, 29 Jul 2024 07:23:40 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:39 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 08/17] ACPI: pci_link: Clear the dependencies after probe Date: Mon, 29 Jul 2024 19:52:30 +0530 Message-ID: <20240729142241.733357-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 added between Link device and PCI Host Bridge, then the PCI end points can get probed prior to link device, unable to get mapping for INTx. So, add the link device's HID to dependency honor list and also clear it after its probe. Signed-off-by: Sunil V L --- drivers/acpi/pci_link.c | 2 ++ drivers/acpi/scan.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index aa1038b8aec4..b727db968f33 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -748,6 +748,8 @@ static int acpi_pci_link_add(struct acpi_device *device, if (result) kfree(link); =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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47BF615F401 for ; Mon, 29 Jul 2024 14:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263028; cv=none; b=JpRQcoUtVcFyKDUjBn3fJyg0DWHNCbbSxOnGGIfdbUIl0Mm6zKmcjhhakFDKZa7tw4IenvfY11llbQgrUYGEte91OvcMm8AZ6/nC19C239gdvcu95InYmzbJ13UIaP++Xh/CoZzKqL3NUh4F07NCmRU2qUrjDE7kHrm5Sqa61qA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263028; c=relaxed/simple; bh=HxrXD0laEpvyBk3qLakEkJuteuJ7RxqyIWOvrRu2DTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u8N2YKsAWjU0AXt9rD72FfWDYSvoFEFw9QIfL4b8fYjagMdYX6ibLpaYJdGsU1KbFUv3Iv2Frj8IDJBDHNMF3wEfmTdDREeO7oMHatcYGDMgUEPX03sSp/MOeSW7S8rZcLoNgn3Fz+uncvXGRvDrmKvy4IGEF/eoZIK/c79rSmc= 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=kQvFhvyO; arc=none smtp.client-ip=209.85.214.170 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="kQvFhvyO" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1fc65329979so25472485ad.0 for ; Mon, 29 Jul 2024 07:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263026; x=1722867826; 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=wik61eI9STwwE7HFXon2+/PZ3nVDVD4F5v9olaEmjiw=; b=kQvFhvyOE1SDoF3M6W0iYrXmyaZDaghljbJIKNn7FFKLR565bFdq5V4yVsR4mIvYU2 ioPsZc+ziLy0OMmYSEVucyhNhNuskbtFgyBA1XkO0I0tfVGdiVLiqzlRfRf9sx2nVnmM U2SatZ31b1OlbTuVtA+MrCCSfk+wbu+zvlyHG6JryL/FSEfckLkTpMO24hupcOPGV4fo 8lEYjUocUCqSViFKcG8nKpTA7FXHwCNU+zbj9rSTA9zxHTOSJ2cmHt62T0Hq/QVi0UQ7 ztUX2TD9SvP4tlTk+lrKXQ3aBE5lmL0UvuhmS66U3jjuOTRwsp8zasHZjDWJnuZcVsqy 3wEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263026; x=1722867826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wik61eI9STwwE7HFXon2+/PZ3nVDVD4F5v9olaEmjiw=; b=pQiELVzBLWntxg+fD4Sh3zXBq24QjxpGZWSR7nV2ZDrQP13i8oXpQ1PC+O+IWbzMWK 69FT5Zw957f/AkC8hFFssiMmOFoB+4d9NyjIifniyiaCs+CAmwKgJS1yzeLSO3be9dML XoeWRcB9w+betKmo59YTlSecffi+acfbztFnEaXjvAfLnRJijFRtkZ/9BMNAMge3YyDP 6UnE0gRueld5yduxjRn3ve9CKbkN+JMEb95b9KLP5bLwPO+WcsktAUp0g9uYTszawqL9 6lmvcG4dStHmtm9/7+4qjv5IgSP1lUqHd7lqbIiOIrWj/QnwgR3QBTRm6lFSX3pEUAfW KBzQ== X-Gm-Message-State: AOJu0YzlGz03QjWY+AjkgfEWZILzL7rjB3b8GVNPznnejqapemLsSCsV CVG/QyLXVDEMX/IcI9P3VWTdQvXl1O50gKX6jCTt5bBsgqf0OaWb/Lu+d5UDFsT6Xv/8GC9Ge4y KksKAGA== X-Google-Smtp-Source: AGHT+IE3ECdlWv0nwo/WvLQaYyG8zcevZP66vRc2T+ol778my9cQeDUxkiVxja9PHSoePX+A01NXaQ== X-Received: by 2002:a17:902:dace:b0:1fa:b7ea:9f0f with SMTP id d9443c01a7336-1ff047fed8fmr110813265ad.7.1722263026091; Mon, 29 Jul 2024 07:23:46 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:45 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 09/17] ACPI: RISC-V: Implement PCI related functionality Date: Mon, 29 Jul 2024 19:52:31 +0530 Message-ID: <20240729142241.733357-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 B75FB16631A for ; Mon, 29 Jul 2024 14:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263034; cv=none; b=Ft9tGRR80IiHahaVxeH9ChMPotmRxZ0Fn4xEv1ndWQpdcYVLHXpqKAEZWgotgvMu94qKJ5Xxe61Z9lZ9fsI6Nj4jMyfCkV8JAZDtiKI28hJB7ro7EXzlvt2TSVA6LwLWJbWfrpct2Tb2LBWKclaQEVyeCIN7Eu7dSwB9ntM6buY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263034; c=relaxed/simple; bh=0BRXE0HINhvBM6jlUkXiX5qm7dADdRByHIusW0vynz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PbxFRucV3WvVBAxhtITlU/CvCAloxgl67GR/LlfBR0XIlw1v16H5Aed6iZ1BO25LOd4qpw/RHcEowJHp8iMuW8QxrlPd5bP6SaK4/KOCg9i2aJuiEmS7zGe1t5XAQfrxjq7xBy6/ACA71V+zQKRbz32hehTJexeTmMoB77msZTM= 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=epHVoGJJ; arc=none smtp.client-ip=209.85.214.173 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="epHVoGJJ" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1fc5549788eso23956795ad.1 for ; Mon, 29 Jul 2024 07:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263032; x=1722867832; darn=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=JbM0a+feX6KT++9LC9tUXyb/bLPakmTLy8AENK3qxq4=; b=epHVoGJJ8VmOwSU9/iKLQpE+2ey/hZ5bUi0xGwJZl66GoU++ihy8rnFAI6KUEr74ad 4Q9SRm6M4ATrJFtWCxurHkx4QlgwX0UzSOuj8Usb3uw52qHJ+8ApGvdSprXi29PQqPQQ yusWacOmkVn5ZNr/ToArzHP8iAHHbPHuCk7sZ75GATo8zgLuNa9dIbts9HCzv3w783iQ w7EXSKvhjHnkYmC2t/hI3H6Fc8Ls4nVndTzd86dt6pMSmAL1qqp4QsZTgHDvnG69VqNN CWS/iz0MBzD9Z11G0H6jT4i7/KjpDIyYPa/GkiEe72WFuxkOcPZ28+RiwNYpS3PB+AIF DCJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263032; x=1722867832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JbM0a+feX6KT++9LC9tUXyb/bLPakmTLy8AENK3qxq4=; b=Rcm/UoPBXY4vicSYeSmHfvIGkGf/cYQ1IS9uqGtCqYlLDc7/vov1MEP2FI0lEfvy/W GjPP2EHG0hs5tQWSb3EdoVlxf7WSBd4wcs/VofHc+3ZZxlrcGI3q4yB3QsUjKuyEtaUb mVkgyP12SQa3K8x/c0pym4gUGJyiwt/l/LEdDzu0hkZDyn/gKqBU38dNK29QGx86UWDi vsQRLnS6hb3SuP86t8lrxXecuBHf0VsTG5EXXnERFLiQORvBfAQ/rg4VF+TclQNHDsKk yZTlS89Qd+7V7WhvWrNDqHRzK1h3g7Sfp0Pox5bDWFuCIevX03aNLi1xNoMRu/WLbYuE BRvA== X-Gm-Message-State: AOJu0Yx7oY7vX9HwLALjKbdG3S42tooBBrMMK3LR0JDmNEIx6YGzDT6R +QeH/ndDRAXJqTVy+MRZ4WnBbcrzOiCIuj2fkBW4ELIc9B4OChPwWHNgDiYw1hNPtYmOuG4pFcH woPBSLA== X-Google-Smtp-Source: AGHT+IFH4IFEEqFnFuD3LFxB9/YGdoZ1voAL0RS56DOiFLXrkbkYEDIaLZyWRT2+lCXe+UQYlpMB3Q== X-Received: by 2002:a17:902:d4ce:b0:1fd:a360:447b with SMTP id d9443c01a7336-1ff048b7daemr104566225ad.52.1722263031612; Mon, 29 Jul 2024 07:23:51 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:51 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 10/17] ACPI: RISC-V: Implement function to reorder irqchip probe entries Date: Mon, 29 Jul 2024 19:52:32 +0530 Message-ID: <20240729142241.733357-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13D0E16631A for ; Mon, 29 Jul 2024 14:23:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263040; cv=none; b=lkmJnvRZwv5Ao/KD39ynnIbgAh/DPD9VrEa3bcZpZCIuarLLzuyEjTJFMEu/ufC64716mZcMBZKUyYZNdYrK7oLUbsCI1PRjy9fZDvIl4G58wkhOyUVB34gGX71SCHEKDiotZB9sqbuyXyPsbYIIJCb5FfKL5C7iHvo5zrrsvfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263040; c=relaxed/simple; bh=mxjx/BlUYG2w0mz5G76SIHP2sKV9B9/KnJhQw3W83Pk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dFl1jybUKAu90oMdrY8dyY01fGPSCKv28qrWdgVZQ3eQ5gdWvcreXZVThmCqWu1xDVOgGa5O0blOi+Gl4K1GSyt32lloD/HT5mG0+z1SUYLY9k2fnrfZzLWlQpEdvdwDweGjVA8MEMclAOIbJF5qil2Ur0WUmR1laa1mENyMrB4= 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=GmBTR4qW; arc=none smtp.client-ip=209.85.215.174 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="GmBTR4qW" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7515437ff16so2643033a12.2 for ; Mon, 29 Jul 2024 07:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263037; x=1722867837; 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=faQAT1JYz4uKgs1JiW6v4seMVdvUx1pSLIJRc+OrnCU=; b=GmBTR4qWenfCPpZmI+zLN16mBY3XsezXgJKkUTA1CuJ8l76cxs4ywzHAftsfMODZML WQlbmBv6oN0QxbcoxXG7BvP6N7h+Lt6doYiAqctJQEwA7HvZnidgH7q3ZlEopADEi/yI nT8ieOCxIIGBSqU0cHwekoy7sZvr8LgL4v42CZyOR+u7YlOsrdACl2aiDg6rGvjhrcDl zRr314KAY1feT1x1h4FtG+40gS5IAjVGTxK1z3as+71ggliIlkuLYH/dhIROrURkaNX3 l5MGIDG4/J4n9Tdc3RiZmLWiSw1F9p6SMCkztsYyJE/1/ChL/pWzESB7gTeHJbBjfU6L rMhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263037; x=1722867837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=faQAT1JYz4uKgs1JiW6v4seMVdvUx1pSLIJRc+OrnCU=; b=oD33rH/0X0XmxK/UvRwqNx4AheDS3ePjih1Kdb0+CJidnHYmd6a4VR8FiZTyABZCH9 tNshz3/LS7t5pkP42Hr3qsUJitCy3WZ97xTT4gki3j5VVQWflxBZT+MvEi6osrchB6Dt JgTf2zlRkJUEDqQcWdJsug06suA5wex/aszl6tH5azepCq4yGxeMnpFG2obhqRLd8cRK ZTS8DJxKE30vDy42tH5C3PY3VoVbYHawPlTOfV5J87HuvcWcCzlEYfCKNwkDJTemv52q rBFCnaQxSXFb1PUtsCKluH75JoTWInkPwwLkOeiwvoJGoxAq/fJQ8b+tX2/5SUDLZINX WWng== X-Gm-Message-State: AOJu0YxFdUJO/YcCHAZKhlI+Io2WpK7/xxQwn4HGW3ALgXVqjLCho6iK +cjp7v8Gokfz4CoCrTRBMjbKUTCu367CmlyW8Hgr6Z2xjpZrLps+8MvED0s2YTjY4a7oWLCufyC sBbv7SA== X-Google-Smtp-Source: AGHT+IHlNJOaWOv9P6EA+WSzfVqrKSPrT5Gc2L8g3dIqAtwsXWtcNKuiNkZFmX1M/bo3S6ce4Gfr2g== X-Received: by 2002:a05:6a20:4394:b0:1be:e6d8:756e with SMTP id adf61e73a8af0-1c4a1512bf4mr10901917637.53.1722263037394; Mon, 29 Jul 2024 07:23:57 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:23:56 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 11/17] ACPI: RISC-V: Initialize GSI mapping structures Date: Mon, 29 Jul 2024 19:52:33 +0530 Message-ID: <20240729142241.733357-12-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 5f7571143245..22db97f7a772 100644 --- a/drivers/acpi/riscv/init.c +++ b/drivers/acpi/riscv/init.c @@ -6,7 +6,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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.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 6D12A191F8A for ; Mon, 29 Jul 2024 14:24:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263046; cv=none; b=OyjQmOH8tsyhal6OqIwea9jXdNeeA7zozBr5Il9W1wWhtgMCMI3QRvuFjApa1gwmxoQy88ae2gIiEIh353IEGWUj8ZNKpiHbYnnuLQfNOL7oqcLOBZpR6Zms+NZKk5gBQXSxe8SXioNzEurzTWg3IveJ5pe9ii4OI8nhve3fBss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263046; c=relaxed/simple; bh=nK3Z34NqvTIdaRuEGgDn01kQf2S/IEQAYX7rT6t0suY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bVgz1DZquLJacP51+Ef1xSI+bStkG1FTkY/EjAkfoqvBo1KLZZ9CW1w7pJmImYen3vUi9vVZ8P4U6XTe/AD8CsFC0TcMqsU8V9PRD+Kpuv+HAudtlyT+z1uwDxX5y/GYGs02Eiyq8Jtw5kzp5EmCvtYViMnGDsr/MZ1ogSZV2Nc= 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=Z5lOri+G; arc=none smtp.client-ip=209.85.214.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="Z5lOri+G" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fc49c0aaffso18638775ad.3 for ; Mon, 29 Jul 2024 07:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263043; x=1722867843; 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=7lh+FxZ2Oaqm6/wZ61/7rTE9jIlv42s4WyHVAKuIs34=; b=Z5lOri+Ggy9w1tHu4wbuKB4a29IncegmVPlZgWt/9ViKdG68tljnRiALhHjnEhcEW7 g8H950IGSDJWSdqwN5L/2zXfRZHSglXRjraRxLzS4VQJfv8QTarwDcUCZg+QISQk6hrp MX190AJA25MQepS7sKsp1jsILULPS792HKAmiUoPZUB8jqi/zhATjBLjo6DNudO7zPSs f7z9POWuasNmxgRZLpyk0jDhsCa5Y6pqRmPrC77Da0bAgMBwyE/eA6r0Xpuc++MHCHls j26h6qvjFzK+8N6c6AqrDbMNsdu03qsAv/EevY8I6FdxUM6BiwnVMBCBZtoR+UPAdvqL g3Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263043; x=1722867843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7lh+FxZ2Oaqm6/wZ61/7rTE9jIlv42s4WyHVAKuIs34=; b=O+sT19R5Nui3g8dlYb/xtOmFQTz+N0WkgbQ43okZsOmNO2dmgEFyiZKQL6Cdhx/X6T Bu3zO7HRLVO0sJndxcWSDHBVHO1s7RikKmrO0dSN0OYqGdQvAj9TNTgwInhf1fPgmGZB /v99zZpts8QtBY1R+wb9qUWiGfIRXIIaWsKtGXvv4tnKojEPS67Y0x7CxMIUCq+iaIxI CnETSHPrx/pEW3PyGKJ//Of2Q9H84pwMCgbXdokNmccsve7+H30DmjWNhDa3T6mN2O0m xEmzT/vsvAbrf+y/wW4yKQCzcYZGdocJmpGG1KqK9xsYQxov0/PcqIuW0Y8Z1m01ge2c 168w== X-Gm-Message-State: AOJu0Yy3Aetee04SmgKxslzSZUgLjaOEiHnsYudAjVVXhwnmma/bRhU9 Fg25XQrI31x7iPtJ3fp8OtuT1vzUe16Fb2NujbCW4K0/y9EDFmiUR7aK4AclrMQLQCBtNviXmPD FmX6hsw== X-Google-Smtp-Source: AGHT+IHcJJ7ZUpRxIoDgsE0liV0w2H+LBbMjTY1pRliLvaH8zHgZTiy3qiBM12OS8Q+p8MlCNj4oPg== X-Received: by 2002:a17:902:d4c6:b0:1fd:73e6:83ce with SMTP id d9443c01a7336-1ff046eca8bmr56689045ad.0.1722263043208; Mon, 29 Jul 2024 07:24:03 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:02 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 12/17] ACPI: RISC-V: Implement function to add implicit dependencies Date: Mon, 29 Jul 2024 19:52:34 +0530 Message-ID: <20240729142241.733357-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 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 840C9191F8A for ; Mon, 29 Jul 2024 14:24:10 +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=1722263052; cv=none; b=hu6fo8Ph5QjeN/IPKjXfyN3e/1NRd9NY7H7Odkk68HrAlQMBt6u4VoiHKyEZ1OiLYBeEYQIqsxEtdTrCipzJDKSoEE+0QW2vzbp8iENYQr6RndFqfVD5UwHi8yVDf6Sop9p+Ie9v3YyOp5fz+IAbF6t/4hKBiuWUXNoRMwQz0zk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263052; c=relaxed/simple; bh=OrwfiHoWI5snN21rvRMu3x1zz1XqGGlBe+KHS3BHII4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XU91h3qGyQC6amvYVnvAWdmYfHQLiuF8t+znNjmTME/tQv2p8R4rfrD7x1tqYlPSzCN+HhyF+bxEU6Mf/rvoof/vN0Ydce00ezuU8Au2Ldkzf8iv1zcpZgzCq+sb38mxDuviE9k/oVDYicQdZz/yB0ZN1MR7VTFAtwJQusIMRds= 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=GdpxYCtq; 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="GdpxYCtq" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1fbc3a9d23bso17953905ad.1 for ; Mon, 29 Jul 2024 07:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263049; x=1722867849; 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=kYlVQjcWuKOe+NFOp1Wh7i++2nCqItwyO/PCNQ13gxs=; b=GdpxYCtqTE63NNZjrG1FSbqsDg54dO6WMwJEpCBdM62l2wnsiTbZDZnImOto0XbWyN w9cPOlhbbqKassYvYJdFO8Tzay78OytkJI0g2/1hPfiIaJ94SX4XB1D1cMLq9OZ2H8Zi 6yZt0mWLuaMWyTZSFMC+nersCVBrfAPMW6xIZqQesC8zrfwfXVYah4UJd7v5mNb9Jddh gKZDIcU7xD0CZbL/yTMQsBXF//3DwZK/DJJohtE3MMR2yUcVfihSn088n6l1lkBmRSJl pQt5jgBUUVMIipJILO/BsgoHnW3SZf28oaYewV1dUqG7oGVo5+0i88M207crnVoXVhxV kGww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263049; x=1722867849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kYlVQjcWuKOe+NFOp1Wh7i++2nCqItwyO/PCNQ13gxs=; b=MYj+VWtCUAl+u5z7YI+dTNhxHJdOPSNUlRQMyzmMau92D9KZQV0FQEltPKMWqKbjTP qvQhv8UnmcnS1ELjMCnOQD/pc1lTv7IH+GU2zXYRLiVUauovPxHCeN80QOCu4YknIPih C8p+vjnAy2mUNnONFZXahkA/0+NhmR6H+hJmwOhJmsdc0Y+4t2P/JYpx8WBOSfXtODsW qH9dJunta/iD07Rgg4EeIXsPUxY5f89S9RPDCMPEQ5VBkeG8HWD7wI2ec9iy0AOmA3A+ T+Fk92ZrF5S9mjPt7kf7/L8qhRvhmvbBzR//iyXBm7pSfkk+z3vH/CMr/tisZDBhpOkV 5P2g== X-Gm-Message-State: AOJu0YwPRalztKJJlc4LWZglUch4YBMlb+GQB9isUSOGr33DPLxvAE1Y J4SeyjHYa/mekLjYPr0IVzeIVi0c1wjrOb+TalLL6Ihu/DDBKv6gchUrgRlRlPg2aog72EBDb92 f9Kakmg== X-Google-Smtp-Source: AGHT+IHv8OfHL+oywHkMVCyqgu6uiipWK5S4kQQJeyBrieT8AIn2g14TSQmHke4oYp0sVgW17J6yFA== X-Received: by 2002:a17:902:fc46:b0:1ff:52c:34ce with SMTP id d9443c01a7336-1ff052c3e33mr60989715ad.53.1722263048905; Mon, 29 Jul 2024 07:24:08 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:08 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 13/17] irqchip/riscv-intc: Add ACPI support for AIA Date: Mon, 29 Jul 2024 19:52:35 +0530 Message-ID: <20240729142241.733357-14-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- arch/riscv/include/asm/irq.h | 33 ++++++++++++ drivers/irqchip/irq-riscv-intc.c | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 44a0b128c602..51d86f0b80d2 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -12,6 +12,8 @@ =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_get_intc_index_hartid(u32 index); +unsigned long acpi_get_ext_intc_parent_hartid(unsigned int plic_id, unsign= ed int ctxt_idx); +unsigned int acpi_get_plic_nr_contexts(unsigned int plic_id); +unsigned int acpi_get_plic_context(unsigned int plic_id, unsigned int ctxt= _idx); +int __init acpi_get_imsic_mmio_info(u32 index, struct resource *res); =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_get_intc_index_hartid(u32 index) +{ + return INVALID_HARTID; +} + +static inline unsigned long acpi_get_ext_intc_parent_hartid(unsigned int p= lic_id, + unsigned int ctxt_idx) +{ + return INVALID_HARTID; +} + +static inline unsigned int acpi_get_plic_nr_contexts(unsigned int plic_id) +{ + return INVALID_CONTEXT; +} + +static inline unsigned int acpi_get_plic_context(unsigned int plic_id, uns= igned int ctxt_idx) +{ + return INVALID_CONTEXT; +} + +static inline int __init acpi_get_imsic_mmio_info(u32 index, struct resour= ce *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..5ddb12ce8b97 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -250,6 +250,85 @@ IRQCHIP_DECLARE(andes, "andestech,cpu-intc", riscv_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_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_get_ext_intc_parent_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_get_plic_context(unsigned int plic_id, unsigned int ctxt= _idx) +{ + struct rintc_data *data =3D get_plic_context(plic_id, ctxt_idx); + + return data ? data->context_id : INVALID_CONTEXT; +} + +unsigned long acpi_get_intc_index_hartid(u32 index) +{ + return index >=3D nr_rintc ? INVALID_HARTID : rintc_acpi_data[index]->har= t_id; +} + +int acpi_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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D54AD1922E7 for ; Mon, 29 Jul 2024 14:24:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263057; cv=none; b=aDMoeGCuj1RrIZinpZHohkaSy/O0OLB6XlZQgVdcOa9ziYmDzlfJAzLTihr66kTpTrRmnHpeelUpsPB0zH21+ygb7yQXzW1UD9wG0xovPhtGkaBUMYQv0ctpvPsPVyjIooGLlHgmZUDVCO2rrETF5V8pEq2qCQ9Z3mOM2/vUzTo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263057; c=relaxed/simple; bh=3v6GeaJyGylX1JhRqA0q+Qffx/UKJbYSVwq4vV71mFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jKJ8/hyB9V49oywfNF+9ttpw0N8oPalbkTTkcbcgn/05mdLh/6dLkCSdyzLwD60nTggSmjeOJSpAGGDnV5aw7yIFhc3w3lMyuGf68VlDaygE+sbMTplVijFrcvZzJuRt0QWiXsaTHRUPzfHtj7cEtdH4+j+Tshpx2+w6aEsJ7Tg= 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=WWmXVgKD; arc=none smtp.client-ip=209.85.214.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="WWmXVgKD" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1fc587361b6so19404855ad.2 for ; Mon, 29 Jul 2024 07:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263054; x=1722867854; darn=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=S+3yiupMcqBHVKtDhH7R825y7QwUyIVJicMeCQk9e3U=; b=WWmXVgKDOQrqmCTv78cSZFrQPCdAbBBvZiHX6zC2oqQqxry5bCGsDbeGEGWt1F4Yks SjoefU6BLJYg5zXvb6gGQw46pF/rMQaaa09I4re08b6SY+melz3IPlq/dODQVgfFt3J8 vFfIdoRXuAV58NDodfi/3HB8CNmSf7RI3h61zzvXbt/vGjnzpA8XHHlklgGBWTq/U2sJ q4BRfs2WhhpUoTBKomxownrUC4VDbGS3uyV/eAqmqKYoM4b8hoI3v1NQvhVyfpR/L2Cl UDeAXjwIezO2LQbwTWKHh/E5onIo452TQ485yM/rRXxU0W9o2APZppxH6SQCFu2lyqpW 080g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263054; x=1722867854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S+3yiupMcqBHVKtDhH7R825y7QwUyIVJicMeCQk9e3U=; b=Dor1zJBq7Gop64ruxyMSEsxgpdiYFIV7eeAoBA4MSaPOT6hmcMWafKdB4ALDtesi1S IB510hoVrBk9/PVoEVH5nuzoBIkedWLId+xDNMCsPVu7y+ac1Cv+sHRgCZ0m/7tfRUue mXzdxohbPEa4UoqFmCFMkRyObfwIILrJ1Zg9A16V/kqSDNTPLYlsVMw2D92zW6IWyX4x DQD9QHHiNKfCxxnnPW1IzmrpUYMDCMUf3ZUP2K/6gTQ0qmCyLol8gvTytKwcwBMaK7vb sl3drVkR+lBtiaDjESDo/zM/NNzHVUElEPX0gHdVqfQMRpQkWJUeYizv2PKWAG6UJT4G mRdA== X-Gm-Message-State: AOJu0YwevVK0an2FtyMOE+CQvhHLm7aIqHkT+/0Kvj1dDs93fyD5yxXZ H1qWlS+6Vy8NJdXA6jClodDuHEf9BxCnBZhObi/JbsM85oWRBls2fzBvnLkcpgkDff7aOEfkYQq MVRjB5g== X-Google-Smtp-Source: AGHT+IFyyx8DenY+eymy3lA0x+mYXtwZv9suwKy/4HPR4IzJLW5mFsnZTjAN7/+4Xj4Bjaq4qxjxyA== X-Received: by 2002:a17:902:ec8d:b0:1fd:6f24:efb2 with SMTP id d9443c01a7336-1ff0481a419mr65542815ad.19.1722263054397; Mon, 29 Jul 2024 07:24:14 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:13 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 14/17] irqchip/riscv-imsic-state: Create separate function for DT Date: Mon, 29 Jul 2024 19:52:36 +0530 Message-ID: <20240729142241.733357-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 522D71922E7 for ; Mon, 29 Jul 2024 14:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263062; cv=none; b=XENiXriKNbfmyzqH7cKO6JguHQ/3k8y5vHZHPlcOZLgH1poIQXgJBrLOwCXVikhp+UHKXdjrj08PWdvx8Pu0Cr+/BOXI59X9G1+tqpq9bmCGBJgBVnqwsg4YFmWyfRJgMLAp5YaciKnO0BVUBXxu9KyzvW79YeIhmjrup2NEhc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263062; c=relaxed/simple; bh=9lJVyphjY0BAzy5we3ocHsm7N89Vz5rw7d1oslrbQiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NnXAdDkrO5skWMp1WEVoNGNJY0uYXuVDb+Xh2fxGzBf8Do+AYoZ+lCkg1D10GoidxOmDp3XLTJLKKf8f3AA+05Lyi08QI9w0ty8FOVrBzu2G5oFSerZIDr4Km8iCsky+DwU1Oevai5G4uYLzNOcaqs0Fk6jFZDyfFIcVnmZ3nek= 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=kKp/eGoL; arc=none smtp.client-ip=209.85.214.182 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="kKp/eGoL" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1fd69e44596so20650365ad.1 for ; Mon, 29 Jul 2024 07:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263060; x=1722867860; 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=tEavi2oCbfZUL041rDq3pUhsFVNcsCR7JV/lSvs1zjE=; b=kKp/eGoLqFs69dE4ggTP/dVlRahtcMRWk66PFZK9xUJ8JrwH//RsfpzE8Vfz743TTD lei0xdGripmPVmsfWPHbv7x3srzuQ8GYgFryP3FA2T31CK3vIKhcusxfnj6+nYWjJ1a3 rRxdmsAfu+pW4AgBbKPiNwq3yZU2dQCMOwXzk9iWT/53/igXAt5GzBhUJJ3r5L47QcGv UpH5GiSZ+Q+y3n0GwiaGDFqqkO8vS4e+joYDauXlVALHIvwTpW3fiG6Pza/7g/KrcaRP RHDC/8urkMp0WwYVeyHc7AiCAIFgOrtoZw3Ka1QIrytBY+YaST2ZhNd+n6CXrP5s+Y10 v8gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263060; x=1722867860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tEavi2oCbfZUL041rDq3pUhsFVNcsCR7JV/lSvs1zjE=; b=Zagw8GOpbKrP7EoxkrydTNAbds2uBo1cvwDwlSRuGXikIgrWQcYyic71jJL6qZSDMx rRizDoTKKIk4QUYut+k5l8CG3klrHdCl2lBQ8AHQPfOdvJOu5CWsErC6GYtMlT06Fx09 ZAZTaGJ8F/ciT/nsMMCBQqb3AccYxn56qFaFGRJDxaaUmL4nh6N/4frwty9NO383dhZA 5AFjK+K+3cXpoj0K3TkJ4/msadNaYnelbbJ5i0W2wMu3NImmY8aXLP7uE3uEOG500yEh U1P4THuqPMMMsdYIaZCQTe/a0w88cbCA12vgEppgczjg74fFFjJbN1HknEa2nLTWvmtr SUmQ== X-Gm-Message-State: AOJu0YxGS8ahngJaS1Wb5OAOQfrndRlbJkRv2RI5fU1cZQIiH5NsKpii SguxpuZODWpPJ0AdjNBcmjSCTtB3dEvESjmqEQbGvH0TD+e3R+UjIr8OgIWnvVIWQDYH7H29O0j cfs0d5A== X-Google-Smtp-Source: AGHT+IHpL4tMIkOEacG2+8mAK1PfaiVTS/v+kCY6IpxY2HmFK244CWhCYJb8BR2pVzEQrYXct8BHbA== X-Received: by 2002:a17:903:22cd:b0:1fb:5f9c:a86c with SMTP id d9443c01a7336-1ff04a23828mr133458135ad.3.1722263060022; Mon, 29 Jul 2024 07:24:20 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:19 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 15/17] irqchip/riscv-imsic: Add ACPI support Date: Mon, 29 Jul 2024 19:52:37 +0530 Message-ID: <20240729142241.733357-16-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- 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..73faa64bffda 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_get_intc_index_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_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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7D9F192B68 for ; Mon, 29 Jul 2024 14:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263068; cv=none; b=aJhmBzhlnT9PQ7ZDkOY5vigpAiBtCLDyQ03h8XyZcGZmZ2WWcQolYv/2Pn4r44Mq3cGlW5Z3cksK40z9b4QjGnuOOQodmr693bMhSgIuZ+bNfPB/MaekbCqMUbDl0vPO1YARs66myeReYE+DAG2ypCDqybf5DfWeQec4AKaZ+zY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263068; c=relaxed/simple; bh=+UbqGuHJb3QdYvkfHtcWyGnRGIWHv4ptKTm8t7QdFQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WwUBQH2ICWRxxmVQzuPo/FZJ/pyqDdx9cTl+hoGFvSMPMi5ZcKw7iUhWoqySANFzQn47tXZvAS6QMn9nNxvju39DChhmpouVAIaNIQtKlk8eOTXrq88qDfZfgZ5rrEeXY9SQg+mh3Gzb19UG014yzi8nrH83jWwE8nIVjOpXZQM= 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=Tik8Gk5T; arc=none smtp.client-ip=209.85.214.174 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="Tik8Gk5T" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1fec34f94abso20423295ad.2 for ; Mon, 29 Jul 2024 07:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263065; x=1722867865; darn=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=GtHN5RSatiirKkuRPrN7Xezrvz6FAse7wNTwc5cY9vQ=; b=Tik8Gk5Tp4XjyCilNJmfwAkvPInVAWJnaW182dqrPSOA0Pp1CPw6Plr9ss6JDoRXDT 9pgFLqM3e3NhNksPQM+V+HEc4f2JMU40XcCSennk99JNb6cbRBFtQdVvjKF0455u/oMC zWbr1SP/k8mFVbpL4Y/vPj5qw74YRic3LGq46NHL57OuK/pFcZw6zg+GmFOWZlwfuEuy +PQX4qXu5kBl0npaa0qf4eBoVxyIkoxAUDsZn+UN9M+N09/uqyrcXaMwFJ9f1yyF3Kdp a4mp7m9NizuFHhMdmkGPq22NUzTZhJFW/RY2xhIbZ1zcNegFprhFDvHMoS8a2f1R0h4U JzMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263065; x=1722867865; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GtHN5RSatiirKkuRPrN7Xezrvz6FAse7wNTwc5cY9vQ=; b=vbXVTxFGhRdgR6MmJg4x5Zw0FpPWpqjRDaru3kCxQH+d5O3WiMo9qyWt9usE1Z2oen kD+PlD9TbOV2AGcqRxO9VoRS32GWSoMJC8kdVkOH8pAhWnpf0bQeGA8MuyiqiRb2r7O+ v8SSIen+N8KzAIuG893HZzCCH7xjAZgkkB/KhdiXX3ck0QiHFowQAkb8NOz+uSzGrClw 6rUeURIGC12FF+HYc8+NSFqGVfkI7AHvTBW8NxUrXzqjp3OvejYd9Q2jHJeUuGsybCZT c1qV1DcYzzf/ZnF8lIT/NNkaPNVYfpQpsvlmAOnjZt/KP4/mUMBsKPC2RPaukOOrPOqQ 8WAA== X-Gm-Message-State: AOJu0YzwUboaPYR5jzqC1ac+gcpQdh2vHGDGdzInuoipRmpW3pmNYaGE PSpqTLRnjAbes8OIKnm0tOi4Y/au6S+TqEFfRyrXe4DkopEntOBYH9RsqmzNTynIT9QuLzYB/Vp 9oF2XcA== X-Google-Smtp-Source: AGHT+IFQUf/+EhYfgsVrzK2L/oleohsnmuLKT1iKr9sPO9lBK/mJauG7ujc+tgm88sfndaMqzPY+Eg== X-Received: by 2002:a17:902:eccf:b0:1fb:34ef:4467 with SMTP id d9443c01a7336-1ff048e2267mr57478325ad.43.1722263065556; Mon, 29 Jul 2024 07:24:25 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:25 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 16/17] irqchip/riscv-aplic: Add ACPI support Date: Mon, 29 Jul 2024 19:52:38 +0530 Message-ID: <20240729142241.733357-17-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- drivers/irqchip/irq-riscv-aplic-direct.c | 22 +++++--- drivers/irqchip/irq-riscv-aplic-main.c | 69 ++++++++++++++++-------- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 +++- 4 files changed, 69 insertions(+), 32 deletions(-) diff --git a/drivers/irqchip/irq-riscv-aplic-direct.c b/drivers/irqchip/irq= -riscv-aplic-direct.c index 4a3ffe856d6c..34540a0ca4da 100644 --- a/drivers/irqchip/irq-riscv-aplic-direct.c +++ b/drivers/irqchip/irq-riscv-aplic-direct.c @@ -4,6 +4,7 @@ * Copyright (C) 2022 Ventana Micro Systems Inc. */ =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_get_ext_intc_parent_hartid(priv->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..8357c5f9921a 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.c +++ b/drivers/irqchip/irq-riscv-aplic-main.c @@ -4,8 +4,10 @@ * Copyright (C) 2022 Ventana Micro Systems Inc. */ =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->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..9fbf45c7b4f7 100644 --- a/drivers/irqchip/irq-riscv-aplic-main.h +++ b/drivers/irqchip/irq-riscv-aplic-main.h @@ -28,6 +28,7 @@ struct aplic_priv { u32 gsi_base; u32 nr_irqs; u32 nr_idcs; + u32 id; void __iomem *regs; struct aplic_msicfg msicfg; }; diff --git a/drivers/irqchip/irq-riscv-aplic-msi.c b/drivers/irqchip/irq-ri= scv-aplic-msi.c index 028444af48bd..f5020241e0ed 100644 --- a/drivers/irqchip/irq-riscv-aplic-msi.c +++ b/drivers/irqchip/irq-riscv-aplic-msi.c @@ -157,6 +157,7 @@ static const struct msi_domain_template aplic_msi_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; @@ -239,8 +240,14 @@ int aplic_msi_setup(struct device *dev, void __iomem *= regs) * IMSIC and the IMSIC MSI domains are created later through * the platform driver probing so we set it explicitly here. */ - if (is_of_node(dev->fwnode)) + if (is_of_node(dev->fwnode)) { of_msi_configure(dev, to_of_node(dev->fwnode)); + } else { + msi_domain =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 Sat Feb 7 08:42:55 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 2D18E192B7C for ; Mon, 29 Jul 2024 14:24:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263073; cv=none; b=mWeNmN8TAAVfDf0jWfMpvQj6hH06ocEX5B3PiiJmrinqClMBnFU0ZXbG56DwciLqfqNpWCMtQ45XkrugwNAYQ5dTJcFXUUr4f4VG05kbD7NnNeqND06/U1krunm2yM5rVslM+zhieCyg/AY+kSVrpEuHRXlm39iCYPQ/4G94O94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263073; c=relaxed/simple; bh=2/ZdmE107x8GmnyshQvBoz8Rb8LNzY3O19gTIqskLDk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e1unE8/Buf6Jrq9WL6MvffoQ2JD9sga4hb94y3gyTRKRjiYo4J0WxVFUtsSsdxmMTmK5jL2UZcaj44bNgUUjT/tcFc59C0pyA4Oznq+nWABnEUtIXX6aE21edyx5eXbqEapbPkMOyEJ2d1iVZkvLw4fW1KQj5gp8Bf0hh5GOzRM= 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=ZPjXjJ3d; arc=none smtp.client-ip=209.85.214.178 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="ZPjXjJ3d" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1fee6435a34so18394835ad.0 for ; Mon, 29 Jul 2024 07:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263071; x=1722867871; 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=I0GXqbjRdlQgXLR20WsWn0Zb01kTXlGc4SKzlInZ9zY=; b=ZPjXjJ3dQSmyk5tdrCYcYbzr/i1bLUNRaCeHOKUHqZH1Fbbg+OZ/KvtGJLXW1K767N xy5mqACyWLJzOVDGojlVfERYfNnNt9phyUWkX7ELG3qGJ/2VMlU3A15FsF/xwt6hbpzY GiPPKBM0XPCpOjzJ9x55fIeEGSbcz0LjQNwDLZFm1SUsGdWveWHRgqE2SRDC51GmFcsJ L6nGvV05qIf8mCgHXMaJgGOQFQ4gVrmalPQH/odPi83WNBj9E4Nfkbs2e6DCNYEpS/0E qMet0n9tGm7kVJbkd5NWoFrQP1EBVGGSnlL35hjdaDJOuGlZ0Uf0mkM5vcUwNkFQwRzl 0pXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263071; x=1722867871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I0GXqbjRdlQgXLR20WsWn0Zb01kTXlGc4SKzlInZ9zY=; b=HJNm0JVTQSodpvVvNQxXuFknGt2iU0e7N1KSI1sSILyd+8pMlUIR3VaDYefrThULcr 7XhwKIdDmji2Ajj0vxZwMoaUMAhowytPOcpzfPys0s9eMKL5n05SHnmmugVcfcG5IBE8 0qplWTe5MWGa0a/6kNgkTcBwDCM+OCz4Pl3Ioj1MZuJY81U8+OAqjD58JgZ1cDgUogid VmaYOUglDevSrVsVjSB4/AVwG1GSKo7BsDhY5h74RtqdV+BNOREPa1Ot7QHS+W0Uw6+Y VUEXFgQ58SvpO6NBbfwJWYUA+mQQZxestMSbfEHG4H1mq47NlNP/PLTGr9GAMXM0LS72 y3wA== X-Gm-Message-State: AOJu0YwVQfTZEuacO8DUJ1+IgnOIDSUCcJAynmLLWxamj6wDtPhT43BO 2ShdCtRbJoTsxCotvQR8+BJgOpUgBgKMrvnuj7z8KcTwtXXg3GRJVQKiYU4UPdY7tkyxdombUrb lNdK8sQ== X-Google-Smtp-Source: AGHT+IHN8Sao+YlrrwzuKpm8WQR4yfMRcvn309oxoZCX8m59egD+A5Fg/n7LZZJO/PhhxP1zIyPB4g== X-Received: by 2002:a17:902:fb08:b0:1fd:a72a:f44 with SMTP id d9443c01a7336-1ff0482b8acmr45391535ad.17.1722263071002; Mon, 29 Jul 2024 07:24:31 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:30 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 17/17] irqchip/sifive-plic: Add ACPI support Date: Mon, 29 Jul 2024 19:52:39 +0530 Message-ID: <20240729142241.733357-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> 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 --- drivers/irqchip/irq-sifive-plic.c | 94 ++++++++++++++++++++++++------- 1 file changed, 73 insertions(+), 21 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive= -plic.c index 9e22f7e378f5..12d60728329c 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 SiFive * Copyright (C) 2018 Christoph Hellwig */ +#include #include #include #include @@ -70,6 +71,8 @@ struct plic_priv { unsigned long plic_quirks; unsigned int nr_irqs; unsigned long *prio_save; + u32 gsi_base; + int id; }; =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_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_get_ext_intc_parent_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->id =3D id; =20 priv->regs =3D devm_platform_ioremap_resource(pdev, 0); if (WARN_ON(!priv->regs)) @@ -519,12 +555,22 @@ static int plic_probe(struct platform_device *pdev) return -ENOMEM; =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->= 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_get_plic_context(priv->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 +608,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 +627,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 +665,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->id)) continue; if (parent_hwirq !=3D RV_IRQ_EXT || cpu < 0) continue; @@ -644,6 +695,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