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 6/9] ACPI/IORT: Convert IORT devices to use the ACPI static fwnode IRQs
Date: Mon, 30 Nov 2026 09:54:38 +0100 [thread overview]
Message-ID: <20261130-acpi-static-table-irq-probe-defer-v2-6-7e854fe7aecd@kernel.org> (raw)
In-Reply-To: <20261130-acpi-static-table-irq-probe-defer-v2-0-7e854fe7aecd@kernel.org>
Static devices created out of IORT nodes might require GSI interrupts that
are routed to interrupt controllers that have not yet probed (so their
respective IRQ domain is not registered yet and therefore the GSI
mapping would fail if tried) to be mapped in current IORT code.
Instead of trying to map the GSIs at platform device creation time and
save them in the platform device IRQ resource, stash standard GSIs numbers,
trigger/polarity and names data into the IORT ACPI static fwnode using the
acpi_static_fwnode_add_irq() helper so that they can be later retrieved
(and mapped into a virtual IRQ), in a uniform fashion, by the device
drivers requesting them.
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
---
Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Sudeep Holla <sudeep.holla@kernel.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
---
drivers/acpi/arm64/iort.c | 206 ++++++++++++++++++----------------------------
1 file changed, 80 insertions(+), 126 deletions(-)
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 1020ac953e42..478aa2802cc9 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -1567,47 +1567,14 @@ int iort_dma_get_ranges(struct device *dev, u64 *limit)
return nc_dma_get_range(dev, limit);
}
-static void __init acpi_iort_register_irq(int hwirq, const char *name,
- int trigger,
- struct resource *res)
+static void __init acpi_iort_add_irq(u32 hwirq, const char *name, unsigned int trigger_val,
+ struct fwnode_handle *fwnode)
{
- int irq = acpi_register_gsi(NULL, hwirq, trigger,
- ACPI_ACTIVE_HIGH);
-
- if (irq <= 0) {
- pr_err("could not register gsi hwirq %d name [%s]\n", hwirq,
- name);
+ if (!hwirq)
return;
- }
- res->start = irq;
- res->end = irq;
- res->flags = IORESOURCE_IRQ;
- res->name = name;
-}
-
-static int __init arm_smmu_v3_count_resources(struct acpi_iort_node *node)
-{
- struct acpi_iort_smmu_v3 *smmu;
- /* Always present mem resource */
- int num_res = 1;
-
- /* Retrieve SMMUv3 specific data */
- smmu = (struct acpi_iort_smmu_v3 *)node->node_data;
-
- if (smmu->event_gsiv)
- num_res++;
-
- if (smmu->pri_gsiv)
- num_res++;
-
- if (smmu->gerr_gsiv)
- num_res++;
-
- if (smmu->sync_gsiv)
- num_res++;
-
- return num_res;
+ acpi_static_fwnode_add_irq(fwnode, hwirq, trigger_val, ACPI_ACTIVE_HIGH,
+ name);
}
static bool arm_smmu_v3_is_combined_irq(struct acpi_iort_smmu_v3 *smmu)
@@ -1644,43 +1611,35 @@ static void __init arm_smmu_v3_init_resources(struct resource *res,
struct acpi_iort_node *node)
{
struct acpi_iort_smmu_v3 *smmu;
- int num_res = 0;
/* Retrieve SMMUv3 specific data */
smmu = (struct acpi_iort_smmu_v3 *)node->node_data;
- res[num_res].start = smmu->base_address;
- res[num_res].end = smmu->base_address +
- arm_smmu_v3_resource_size(smmu) - 1;
- res[num_res].flags = IORESOURCE_MEM;
+ res[0].start = smmu->base_address;
+ res[0].end = smmu->base_address + arm_smmu_v3_resource_size(smmu) - 1;
+ res[0].flags = IORESOURCE_MEM;
+}
+
+static void __init arm_smmu_v3_init_irqs(struct fwnode_handle *fwnode,
+ struct acpi_iort_node *node)
+{
+ struct acpi_iort_smmu_v3 *smmu;
+
+ smmu = (struct acpi_iort_smmu_v3 *)node->node_data;
- num_res++;
if (arm_smmu_v3_is_combined_irq(smmu)) {
- if (smmu->event_gsiv)
- acpi_iort_register_irq(smmu->event_gsiv, "combined",
- ACPI_EDGE_SENSITIVE,
- &res[num_res++]);
+ acpi_iort_add_irq(smmu->event_gsiv, "combined",
+ ACPI_EDGE_SENSITIVE, fwnode);
} else {
+ acpi_iort_add_irq(smmu->event_gsiv, "eventq",
+ ACPI_EDGE_SENSITIVE, fwnode);
- if (smmu->event_gsiv)
- acpi_iort_register_irq(smmu->event_gsiv, "eventq",
- ACPI_EDGE_SENSITIVE,
- &res[num_res++]);
-
- if (smmu->pri_gsiv)
- acpi_iort_register_irq(smmu->pri_gsiv, "priq",
- ACPI_EDGE_SENSITIVE,
- &res[num_res++]);
-
- if (smmu->gerr_gsiv)
- acpi_iort_register_irq(smmu->gerr_gsiv, "gerror",
- ACPI_EDGE_SENSITIVE,
- &res[num_res++]);
-
- if (smmu->sync_gsiv)
- acpi_iort_register_irq(smmu->sync_gsiv, "cmdq-sync",
- ACPI_EDGE_SENSITIVE,
- &res[num_res++]);
+ acpi_iort_add_irq(smmu->pri_gsiv, "priq",
+ ACPI_EDGE_SENSITIVE, fwnode);
+ acpi_iort_add_irq(smmu->gerr_gsiv, "gerror",
+ ACPI_EDGE_SENSITIVE, fwnode);
+ acpi_iort_add_irq(smmu->sync_gsiv, "cmdq-sync",
+ ACPI_EDGE_SENSITIVE, fwnode);
}
}
@@ -1730,55 +1689,36 @@ static int __init arm_smmu_v3_set_proximity(struct device *dev,
#define arm_smmu_v3_set_proximity NULL
#endif
-static int __init arm_smmu_count_resources(struct acpi_iort_node *node)
-{
- struct acpi_iort_smmu *smmu;
-
- /* Retrieve SMMU specific data */
- smmu = (struct acpi_iort_smmu *)node->node_data;
-
- /*
- * Only consider the global fault interrupt and ignore the
- * configuration access interrupt.
- *
- * MMIO address and global fault interrupt resources are always
- * present so add them to the context interrupt count as a static
- * value.
- */
- return smmu->context_interrupt_count + 2;
-}
-
static void __init arm_smmu_init_resources(struct resource *res,
struct acpi_iort_node *node)
{
struct acpi_iort_smmu *smmu;
- int i, hw_irq, trigger, num_res = 0;
- u64 *ctx_irq, *glb_irq;
/* Retrieve SMMU specific data */
smmu = (struct acpi_iort_smmu *)node->node_data;
- res[num_res].start = smmu->base_address;
- res[num_res].end = smmu->base_address + smmu->span - 1;
- res[num_res].flags = IORESOURCE_MEM;
- num_res++;
+ res[0].start = smmu->base_address;
+ res[0].end = smmu->base_address + smmu->span - 1;
+ res[0].flags = IORESOURCE_MEM;
+}
+
+static void __init arm_smmu_init_irqs(struct fwnode_handle *fwnode,
+ struct acpi_iort_node *node)
+{
+ struct acpi_iort_smmu *smmu;
+ u64 *ctx_irq, *glb_irq;
+ int i;
+
+ smmu = (struct acpi_iort_smmu *)node->node_data;
glb_irq = ACPI_ADD_PTR(u64, node, smmu->global_interrupt_offset);
- /* Global IRQs */
- hw_irq = IORT_IRQ_MASK(glb_irq[0]);
- trigger = IORT_IRQ_TRIGGER_MASK(glb_irq[0]);
+ acpi_iort_add_irq(IORT_IRQ_MASK(glb_irq[0]), NULL,
+ IORT_IRQ_TRIGGER_MASK(glb_irq[0]), fwnode);
- acpi_iort_register_irq(hw_irq, "arm-smmu-global", trigger,
- &res[num_res++]);
-
- /* Context IRQs */
ctx_irq = ACPI_ADD_PTR(u64, node, smmu->context_interrupt_offset);
for (i = 0; i < smmu->context_interrupt_count; i++) {
- hw_irq = IORT_IRQ_MASK(ctx_irq[i]);
- trigger = IORT_IRQ_TRIGGER_MASK(ctx_irq[i]);
-
- acpi_iort_register_irq(hw_irq, "arm-smmu-context", trigger,
- &res[num_res++]);
+ acpi_iort_add_irq(IORT_IRQ_MASK(ctx_irq[i]), NULL,
+ IORT_IRQ_TRIGGER_MASK(ctx_irq[i]), fwnode);
}
}
@@ -1801,20 +1741,6 @@ static void __init arm_smmu_dma_configure(struct device *dev,
acpi_dma_configure(dev, attr);
}
-static int __init arm_smmu_v3_pmcg_count_resources(struct acpi_iort_node *node)
-{
- struct acpi_iort_pmcg *pmcg;
-
- /* Retrieve PMCG specific data */
- pmcg = (struct acpi_iort_pmcg *)node->node_data;
-
- /*
- * There are always 2 memory resources.
- * If the overflow_gsiv is present then add that for a total of 3.
- */
- return pmcg->overflow_gsiv ? 3 : 2;
-}
-
static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res,
struct acpi_iort_node *node)
{
@@ -1837,10 +1763,17 @@ static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res,
res[1].end = pmcg->page1_base_address + SZ_4K - 1;
res[1].flags = IORESOURCE_MEM;
}
+}
- if (pmcg->overflow_gsiv)
- acpi_iort_register_irq(pmcg->overflow_gsiv, "overflow",
- ACPI_EDGE_SENSITIVE, &res[2]);
+static void __init arm_smmu_v3_pmcg_init_irqs(struct fwnode_handle *fwnode,
+ struct acpi_iort_node *node)
+{
+ struct acpi_iort_pmcg *pmcg;
+
+ pmcg = (struct acpi_iort_pmcg *)node->node_data;
+
+ acpi_iort_add_irq(pmcg->overflow_gsiv, "overflow", ACPI_EDGE_SENSITIVE,
+ fwnode);
}
static struct acpi_platform_list pmcg_plat_info[] __initdata = {
@@ -1878,12 +1811,15 @@ static int __init arm_smmu_v3_pmcg_add_platdata(struct platform_device *pdev)
struct iort_dev_config {
const char *name;
+ unsigned int nr_irqs;
+ unsigned int nr_res;
int (*dev_init)(struct acpi_iort_node *node);
void (*dev_dma_configure)(struct device *dev,
struct acpi_iort_node *node);
- int (*dev_count_resources)(struct acpi_iort_node *node);
void (*dev_init_resources)(struct resource *res,
struct acpi_iort_node *node);
+ void (*dev_init_irqs)(struct fwnode_handle *fwnode,
+ struct acpi_iort_node *node);
int (*dev_set_proximity)(struct device *dev,
struct acpi_iort_node *node);
int (*dev_add_platdata)(struct platform_device *pdev);
@@ -1891,23 +1827,28 @@ struct iort_dev_config {
static const struct iort_dev_config iort_arm_smmu_v3_cfg __initconst = {
.name = "arm-smmu-v3",
+ .nr_irqs = 4,
+ .nr_res = 1,
.dev_dma_configure = arm_smmu_v3_dma_configure,
- .dev_count_resources = arm_smmu_v3_count_resources,
.dev_init_resources = arm_smmu_v3_init_resources,
+ .dev_init_irqs = arm_smmu_v3_init_irqs,
.dev_set_proximity = arm_smmu_v3_set_proximity,
};
static const struct iort_dev_config iort_arm_smmu_cfg __initconst = {
.name = "arm-smmu",
+ .nr_res = 1,
.dev_dma_configure = arm_smmu_dma_configure,
- .dev_count_resources = arm_smmu_count_resources,
.dev_init_resources = arm_smmu_init_resources,
+ .dev_init_irqs = arm_smmu_init_irqs,
};
static const struct iort_dev_config iort_arm_smmu_v3_pmcg_cfg __initconst = {
.name = "arm-smmu-v3-pmcg",
- .dev_count_resources = arm_smmu_v3_pmcg_count_resources,
+ .nr_irqs = 1,
+ .nr_res = 2,
.dev_init_resources = arm_smmu_v3_pmcg_init_resources,
+ .dev_init_irqs = arm_smmu_v3_pmcg_init_irqs,
.dev_add_platdata = arm_smmu_v3_pmcg_add_platdata,
};
@@ -1951,7 +1892,7 @@ static int __init iort_add_platform_device(struct acpi_iort_node *node,
goto dev_put;
}
- count = ops->dev_count_resources(node);
+ count = ops->nr_res;
r = kzalloc_objs(*r, count);
if (!r) {
@@ -1994,6 +1935,9 @@ static int __init iort_add_platform_device(struct acpi_iort_node *node,
platform_device_set_fwnode(pdev, fwnode);
+ if (ops->dev_init_irqs)
+ ops->dev_init_irqs(fwnode, node);
+
if (ops->dev_dma_configure)
ops->dev_dma_configure(&pdev->dev, node);
@@ -2007,6 +1951,7 @@ static int __init iort_add_platform_device(struct acpi_iort_node *node,
dma_deconfigure:
arch_teardown_dma_ops(&pdev->dev);
+ platform_device_set_fwnode(pdev, NULL);
dev_put:
platform_device_put(pdev);
@@ -2082,7 +2027,16 @@ static void __init iort_init_platform_devices(void)
ops = iort_get_dev_cfg(iort_node);
if (ops) {
- fwnode = acpi_alloc_fwnode_static();
+ unsigned int nr_irqs = ops->nr_irqs;
+
+ if (iort_node->type == ACPI_IORT_NODE_SMMU) {
+ struct acpi_iort_smmu *smmu =
+ (struct acpi_iort_smmu *)iort_node->node_data;
+
+ nr_irqs = smmu->context_interrupt_count + 1;
+ }
+
+ fwnode = acpi_alloc_fwnode_static_irqs(nr_irqs);
if (!fwnode)
return;
--
2.53.0
next prev 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 ` [PATCH RFC v2 2/9] ACPI: Introduce IRQ methods for static fwnodes Lorenzo Pieralisi
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 ` Lorenzo Pieralisi [this message]
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-6-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®