From nobody Mon Oct 6 01:28:20 2025 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 6E4AA25A32E for ; Mon, 28 Jul 2025 09:43:55 +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=1753695837; cv=none; b=QNh5mq3CY4W6d19FtYVgOACyx+XdpDM3yn+kFnidmFDCu1nOpVq/W+nCjHvuyYTOue/YismYDgDnNrTBxQJnsDYUGCGtNtIJK43hng9qMo5brKFz6siOfu5Dm8bwx308QbJs+0r7mROtxLx4N9YN0s2k8Vc84SibFoCI0XYSkgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753695837; c=relaxed/simple; bh=bDMVpDUTCKSQxIzYquuybqhsrFm52uIQJL3fLHSkHZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o5PYZMJ7YCgAJ32/ED7N35P7TvdDuAfe0nu20/5LKnJdIRDXNBnZqbB1QFaQsKXAGWYgxUUR+tGE8SvoLUme+YuBrmk66a/gU9Iof457Krvz9g2UxtTf++2F5GAItFzAT7LWf/JRpl5sXLFk5v6K0nT1ubX69/ngVp1a8mgl+nw= 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=cW8SE6Qr; 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="cW8SE6Qr" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-23636167afeso36121185ad.3 for ; Mon, 28 Jul 2025 02:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1753695835; x=1754300635; 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=P3TJh+HyLkyeQ1VqRyPxzf43XEd03uT1gCuO+kpCcOM=; b=cW8SE6QrSmkYw5KbPGjctVwo/AqaY3FoTHFy2GyanNBJCjrNZ/NptlzqrH1bEDiRTs 5GCumIP6310khyD0Rem4HsW/ArDHzNQFRXr193xTTx8OoyCqnSa7Hd8pkCRmmkRr+Nd8 u9e+GeJzWcc+4g5lTgiBYtn7cE369cmOz2tY7l79NkL+YrVN4L4XtZa/+JNH9L8rWoOj mKaOyGfmHZCwifnRWzzOaDEWrqllNH2i18AcLPeyYtpi1SNIkmByEChgzAuntqsahc9H DGHKnbeossk3pqDK9D4Uqx/Fq/jc1wLWI7BXlsImvtwu27KsPcQINzY+TosLr9bSKA3j lubA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753695835; x=1754300635; 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=P3TJh+HyLkyeQ1VqRyPxzf43XEd03uT1gCuO+kpCcOM=; b=eKrqRmkUJtHF4lrjHPLdISbuVkIj7j7Zb1h0bBFOqr7nIzF+afwGOFd+Rm9c+xBFMG f/EhfEmLdvGCTVyL3z+zUwk7VBTi1Cttnt/E672yYejV6bCknef2PmBYdet6Q2r7Kz2h ArymkyAJre8ku6SETGfDJ5x439jjXgJ7lxmemRvI6+M7qBYBce3MsN6cEgemV5et4fLH 7uWrR4B4Rw0AZQhGwOpWQ7SEbrihMBp7KoojD1i6JZMrx5D5JsAoMVInKMjVwCOSKAqA LxrTrwwYJscsF98gKxCah20jLH0FG8uiJ/lBo3ETMmU4Rjo6XBX58PXWGrsefB/dPALl DxqQ== X-Forwarded-Encrypted: i=1; AJvYcCUA2nXukP/Ymrg2pjUBYpl/ylFe5hHmZC/cYUgHEjceWMlkWS0buma1bODR58ynLkS/lyMnYmhiQMw7cpQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyFx+KcRGmGbf+Fp/eDqNWyUftq3CIuK8o96/qfNCgvwHFCFqn6 qVZkMmXuqfhzJISm6+1wmQId0LrdDtNSUdw+/i/UNXDi0I5HUQ+yggWB3EewWFEgmqk= X-Gm-Gg: ASbGncub+GeDdpAhRJoiWXE2Gd4yCMwMjxD2zXO/Y8hIEuCD1QWiQ5EPwi7zaawwT5y T5PdDPNuGXUzuIk+rbJa+RnCYCJWPPA1rviGXB+VmwQ3csMXvpKwxTiV483FGSKSAh1rS6YqvC4 hILD0eDVyxItMoYvaHqJwe2nVShzT3oj2wGGHFHakLmdZII/uc7w50YyLnX9ynGL8GTUSoVGpzG LwySGrnq3EUeatQHIPMnsmhLEV2fEXZhkYYO+n/oYoYpIbV5q2Eehtezjs6Sm+SDYuJEDtZex3G UwL0spQvHKuSkMBrVH8WDGRq90fzh+heC9WPiJJF9eB52e5nMl6sX50Du8488hwDQIvDhI0/wnE xhvcRzDMhSuulJrb72mCAdq5RrNoCXLVMKfDS4pegetD/CgzhbP8gdYnz1Oii X-Google-Smtp-Source: AGHT+IHI2M7ktVDfnRXlbMOQx8cI9hQctNhXTmp4VHflXoE3OleDRvbaoO88+G60sLgtIf+JGimi6Q== X-Received: by 2002:a17:902:f30b:b0:23f:f983:5ca1 with SMTP id d9443c01a7336-23ff9835e51mr55263795ad.12.1753695834472; Mon, 28 Jul 2025 02:43:54 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([122.171.19.28]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31e832fbf99sm5396230a91.1.2025.07.28.02.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jul 2025 02:43:53 -0700 (PDT) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Alexandre Ghiti , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v9 18/24] ACPI: RISC-V: Add support to update gsi range Date: Mon, 28 Jul 2025 15:10:26 +0530 Message-ID: <20250728094032.63545-19-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250728094032.63545-1-apatel@ventanamicro.com> References: <20250728094032.63545-1-apatel@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" From: Sunil V L Some RISC-V interrupt controllers like RPMI based system MSI interrupt controllers do not have MADT entry defined. These interrupt controllers exist only in the namespace. ACPI spec defines _GSB method to get the GSI base of the interrupt controller, However, there is no such standard method to get the GSI range. To support such interrupt controllers, set the GSI range of such interrupt controllers to non-overlapping range and provide API for interrupt controller driver to update it with proper value. Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- arch/riscv/include/asm/irq.h | 5 +++++ drivers/acpi/riscv/irq.c | 38 ++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h index 7b038f3b7cb0..2caf049f09c8 100644 --- a/arch/riscv/include/asm/irq.h +++ b/arch/riscv/include/asm/irq.h @@ -40,6 +40,7 @@ unsigned long acpi_rintc_ext_parent_to_hartid(unsigned in= t plic_id, unsigned int unsigned int acpi_rintc_get_plic_nr_contexts(unsigned int plic_id); unsigned int acpi_rintc_get_plic_context(unsigned int plic_id, unsigned in= t ctxt_idx); int __init acpi_rintc_get_imsic_mmio_info(u32 index, struct resource *res); +int riscv_acpi_update_gsi_range(u32 gsi_base, u32 nr_irqs); =20 #else static inline int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u3= 2 *gsi_base, @@ -74,6 +75,10 @@ static inline int __init acpi_rintc_get_imsic_mmio_info(= u32 index, struct resour return 0; } =20 +static inline int riscv_acpi_update_gsi_range(u32 gsi_base, u32 nr_irqs) +{ + return -ENODEV; +} #endif /* CONFIG_ACPI */ =20 #endif /* _ASM_RISCV_IRQ_H */ diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 33c073e2e71d..cc1928422418 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -10,6 +10,8 @@ =20 #include "init.h" =20 +#define RISCV_ACPI_INTC_FLAG_PENDING BIT(0) + struct riscv_ext_intc_list { acpi_handle handle; u32 gsi_base; @@ -17,6 +19,7 @@ struct riscv_ext_intc_list { u32 nr_idcs; u32 id; u32 type; + u32 flag; struct list_head list; }; =20 @@ -69,6 +72,22 @@ static acpi_status riscv_acpi_update_gsi_handle(u32 gsi_= base, acpi_handle handle return AE_NOT_FOUND; } =20 +int riscv_acpi_update_gsi_range(u32 gsi_base, u32 nr_irqs) +{ + struct riscv_ext_intc_list *ext_intc_element; + + list_for_each_entry(ext_intc_element, &ext_intc_list, list) { + if (gsi_base =3D=3D ext_intc_element->gsi_base && + (ext_intc_element->flag & RISCV_ACPI_INTC_FLAG_PENDING)) { + ext_intc_element->nr_irqs =3D nr_irqs; + ext_intc_element->flag &=3D ~RISCV_ACPI_INTC_FLAG_PENDING; + return 0; + } + } + + return -ENODEV; +} + int riscv_acpi_get_gsi_info(struct fwnode_handle *fwnode, u32 *gsi_base, u32 *id, u32 *nr_irqs, u32 *nr_idcs) { @@ -115,14 +134,22 @@ struct fwnode_handle *riscv_acpi_get_gsi_domain_id(u3= 2 gsi) 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, *node; + struct riscv_ext_intc_list *ext_intc_element, *node, *prev; =20 ext_intc_element =3D kzalloc(sizeof(*ext_intc_element), GFP_KERNEL); if (!ext_intc_element) return -ENOMEM; =20 ext_intc_element->gsi_base =3D gsi_base; - ext_intc_element->nr_irqs =3D nr_irqs; + + /* If nr_irqs is zero, indicate it in flag and set to max range possible = */ + if (nr_irqs) { + ext_intc_element->nr_irqs =3D nr_irqs; + } else { + ext_intc_element->flag |=3D RISCV_ACPI_INTC_FLAG_PENDING; + ext_intc_element->nr_irqs =3D U32_MAX - ext_intc_element->gsi_base; + } + ext_intc_element->nr_idcs =3D nr_idcs; ext_intc_element->id =3D id; list_for_each_entry(node, &ext_intc_list, list) { @@ -130,6 +157,13 @@ static int __init riscv_acpi_register_ext_intc(u32 gsi= _base, u32 nr_irqs, u32 nr break; } =20 + /* Adjust the previous node's GSI range if that has pending registration = */ + prev =3D list_prev_entry(node, list); + if (!list_entry_is_head(prev, &ext_intc_list, list)) { + if (prev->flag & RISCV_ACPI_INTC_FLAG_PENDING) + prev->nr_irqs =3D ext_intc_element->gsi_base - prev->gsi_base; + } + list_add_tail(&ext_intc_element->list, &node->list); return 0; } --=20 2.43.0