mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	Marc Zyngier <maz@kernel.org>,
	 Daniel Lezcano <daniel.lezcano@kernel.org>,
	 Thomas Gleixner <tglx@kernel.org>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Danilo Krummrich <dakr@kernel.org>,
	Hanjun Guo <guohanjun@huawei.com>,
	 Sudeep Holla <sudeep.holla@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	 Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	 Bartosz Golaszewski <brgl@kernel.org>,
	 Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	 Leo Yan <leo.yan@arm.com>
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	driver-core@lists.linux.dev,
	 Lorenzo Pieralisi <lpieralisi@kernel.org>
Subject: [PATCH RFC v2 2/9] ACPI: Introduce IRQ methods for static fwnodes
Date: Mon, 30 Nov 2026 09:54:34 +0100	[thread overview]
Message-ID: <20261130-acpi-static-table-irq-probe-defer-v2-2-7e854fe7aecd@kernel.org> (raw)
In-Reply-To: <20261130-acpi-static-table-irq-probe-defer-v2-0-7e854fe7aecd@kernel.org>

To describe and map GSIs for firmware nodes created out of ACPI static
table entries in a uniform way later than at static tables parsing time,
it is required to store GSI data (number, trigger/polarity and name) in
the ACPI static fwnode for late retrieval.

Define an ACPI static fwnode structure and add to it data that can store
GSI number/flag/names to describe GSIs and their trigger mode/polarity,
and implement irq_get()/property_read_string_array() callbacks for static
fwnodes so that core code can retrieve and map IRQs for ACPI static fwnodes
in standard manner.

Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
---
Cc: Bartosz Golaszewski <brgl@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
---
 drivers/acpi/property.c | 41 ++++++++++++++++++++++++++++-
 include/linux/acpi.h    | 68 +++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 100 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 8ee5a1f0eb48..4df29c725e44 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1766,7 +1766,46 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode,
 
 DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
 DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops);
-const struct fwnode_operations acpi_static_fwnode_ops;
+
+static int acpi_static_fwnode_read_string_array(const struct fwnode_handle *fwnode,
+						const char *propname,
+						const char **val, size_t nval)
+{
+	const struct acpi_static_fwnode *node = container_of(fwnode,
+						struct acpi_static_fwnode, fwnode);
+	unsigned int i;
+
+	if (strcmp(propname, "interrupt-names") || !node->irq_count || !node->irqs[0].name)
+		return -EINVAL;
+
+	if (!val)
+		return node->irq_count;
+
+	nval = min_t(size_t, nval, node->irq_count);
+
+	for (i = 0; i < nval; i++)
+		val[i] = node->irqs[i].name;
+
+	return nval;
+}
+
+int acpi_static_fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
+{
+	const struct acpi_static_fwnode *node = container_of(fwnode,
+						struct acpi_static_fwnode, fwnode);
+	const struct acpi_static_irq *irq;
+
+	if (index >= node->irq_count)
+		return -ENXIO;
+
+	irq = &node->irqs[index];
+	return acpi_register_gsi(NULL, irq->gsi, irq->trigger, irq->polarity);
+}
+
+const struct fwnode_operations acpi_static_fwnode_ops = {
+	.property_read_string_array = acpi_static_fwnode_read_string_array,
+	.irq_get = acpi_static_fwnode_irq_get,
+};
 
 bool is_acpi_device_node(const struct fwnode_handle *fwnode)
 {
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 9d3f039ebd94..8a4d218841c2 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -64,17 +64,58 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
 #define ACPI_HANDLE_FWNODE(fwnode)	\
 				acpi_device_handle(to_acpi_device_node(fwnode))
 
-static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
-{
-	struct fwnode_handle *fwnode;
 
-	fwnode = kzalloc_obj(struct fwnode_handle);
-	if (!fwnode)
+struct acpi_static_irq {
+	u32 gsi;
+	u8 trigger;
+	u8 polarity;
+	const char *name;
+};
+
+struct acpi_static_fwnode {
+	struct fwnode_handle fwnode;
+	unsigned int irq_count;
+	unsigned int nr_irqs;
+	struct acpi_static_irq irqs[];
+};
+
+int acpi_static_fwnode_irq_get(const struct fwnode_handle *fwnode,
+			       unsigned int index);
+
+static inline struct fwnode_handle *acpi_alloc_fwnode_static_irqs(unsigned int nr_irqs)
+{
+	struct acpi_static_fwnode *node;
+
+	node = kzalloc(struct_size(node, irqs, nr_irqs), GFP_KERNEL);
+	if (!node)
 		return NULL;
 
-	fwnode_init(fwnode, &acpi_static_fwnode_ops);
+	fwnode_init(&node->fwnode, &acpi_static_fwnode_ops);
+	node->nr_irqs = nr_irqs;
 
-	return fwnode;
+	return &node->fwnode;
+}
+
+static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
+{
+	return acpi_alloc_fwnode_static_irqs(0);
+}
+
+static inline void acpi_static_fwnode_add_irq(struct fwnode_handle *fwnode,
+					      u32 gsi, u8 trigger, u8 polarity,
+					      const char *name)
+{
+	struct acpi_static_fwnode *node = container_of(fwnode,
+					  struct acpi_static_fwnode, fwnode);
+	struct acpi_static_irq *irq;
+
+	if (WARN_ON(node->irq_count >= node->nr_irqs))
+		return;
+	irq = &node->irqs[node->irq_count++];
+	irq->gsi = gsi;
+	irq->trigger = trigger;
+	irq->polarity = polarity;
+	irq->name = name;
 }
 
 static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
@@ -82,7 +123,7 @@ static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
 	if (WARN_ON(!is_acpi_static_node(fwnode)))
 		return;
 
-	kfree(fwnode);
+	kfree(container_of(fwnode, struct acpi_static_fwnode, fwnode));
 }
 
 static inline bool has_acpi_companion(struct device *dev)
@@ -890,6 +931,17 @@ static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode)
 	return false;
 }
 
+static inline bool is_acpi_static_node(const struct fwnode_handle *fwnode)
+{
+	return false;
+}
+
+static inline int acpi_static_fwnode_irq_get(const struct fwnode_handle *fwnode,
+					     unsigned int index)
+{
+	return -ENXIO;
+}
+
 static inline struct acpi_device *to_acpi_device_node(const struct fwnode_handle *fwnode)
 {
 	return NULL;

-- 
2.53.0


  parent reply	other threads:[~2026-11-30  8:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  8:54 [PATCH RFC v2 0/9] ACPI: ARM64: Implement IRQ mapping probe deferral for static table devices Lorenzo Pieralisi
2026-11-30  8:54 ` [PATCH RFC v2 1/9] ACPI: irq: Return -EPROBE_DEFER on missing IRQ domain Lorenzo Pieralisi
2026-11-30  8:54 ` Lorenzo Pieralisi [this message]
2026-11-30  8:54 ` [PATCH RFC v2 3/9] driver core: platform: Add static ACPI nodes IRQ retrieval/mapping code Lorenzo Pieralisi
2026-11-30  8:54 ` [PATCH RFC v2 4/9] clocksource/drivers/arm_arch_timer_mmio: Dispose IRQ mappings on probe failure Lorenzo Pieralisi
2026-11-30  8:54 ` [PATCH RFC v2 5/9] clocksource/drivers/arm_arch_timer_mmio: Implement arch mem timer deferred probe Lorenzo Pieralisi
2026-11-30  8:54 ` [PATCH RFC v2 6/9] ACPI/IORT: Convert IORT devices to use the ACPI static fwnode IRQs Lorenzo Pieralisi
2026-11-30  8:54 ` [PATCH RFC v2 7/9] iommu/arm-smmu: Add arm-smmu IRQ mapping -EPROBE_DEFER handling Lorenzo Pieralisi
2026-11-30  8:54 ` [PATCH RFC v2 8/9] iommu/arm-smmu-v3: Add " Lorenzo Pieralisi
2026-11-30  8:54 ` [PATCH RFC v2 9/9] perf/arm-smmuv3: " Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130-acpi-static-table-irq-probe-defer-v2-2-7e854fe7aecd@kernel.org \
    --to=lpieralisi@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=dakr@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=guohanjun@huawei.com \
    --cc=leo.yan@arm.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=rafael@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=sudeep.holla@kernel.org \
    --cc=tglx@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®