From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796413309; b=1v0nadHNNxYMB4f8MgJ+0jVgeUWUGpXEWErQxRrZgv0/Mo7z8yQA43hvLgIhgNOE8as3 O5tXnD0LmGNV6C4t3nXoS3Kq859STFEUPiaUYHQ8oPkmJCDxgj9wwCv78neARYVVlDWI8 s9JZD6byOFaL2TIIdTlhFw8oqVnswGtKUfjDbUBQ/MaVeAkRojzeXqEgqaxDzo5vJndXx fyjddOVWxIZuACjIfYAwA4+6HDl5t41fwWLxBf0AMpgipPSULlM84AYLWaQkNaCQgGnFc JIvISNYtBMb0461OSeXL1Dt39WY6g2U8KpiT46jdbJEOMnAMr9BSVcNZVxhklSej3uA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796413309; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=SvY245d3SECscgS6GNlBwJGqVDqpb8JWNxnvfb3GMws=; b=VmDaACkKITbwt7yaLdYkwud88HgbJTMjHgUsd+Me7owfuMADNYJqNmb60eUQNWa9r/CD k41NjdQ9qRI7IOUbXPW92/ERkxrjiRPsc8wNQObtVgMZgpBTplxCt1hNhoUc9ahUP1z6Y RXyunhGXM6e0WLiq7VnTqeROa8RmoECNZ5t+7LRD4FFCDRKSeKKmPICxRFGz6jY9CkBUs aJhXSDAuE43nNL7Evv/IjhMPLa63FiVxkgOgS5drSP0kYNVsDN/vpgKNQXFRjtjrtK70Z xTm8YU9P4gUMe3Kbg+AVgya42Qzh4jzGBvS4wIeUNtqKb13MrUjRAigYn6n0HAQW4pQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=GTUreTJv; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EB3C606A6A4; Fri, 4 Dec 2026 19:41:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2EB3C606A6A4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=GTUreTJv Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 88B3714BF; Fri, 4 Dec 2026 11:41:44 -0800 (PST) Received: from [10.2.212.23] (e121345-lin.cambridge.arm.com [10.2.212.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 18B503F9AB; Fri, 4 Dec 2026 11:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796413307; bh=nLK9o6fcXLLxTC3WRSp7JTzwcCmBeUrrPi5lIHQX7Sg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=GTUreTJvUrzUzBkZ+i8+McaFlz9zYPCnR6WrR+wUjt8TFZg3IZZvisiDen6kJlXPQ PrgpJlBwiodeDZgSdj80wYSQ36R2Ay0TzfiSUuiWxkuZvAa1nA2itLwIUVCtX67SRC r5Wazwo/2UAsqT2A+d9n+lC+T85Pmm9jOMZaEszM= Message-ID: <8ba07015-aa6b-4d68-a455-f4695f520c8b@arm.com> Date: Fri, 4 Dec 2026 19:41:43 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC v2 2/9] ACPI: Introduce IRQ methods for static fwnodes To: Lorenzo Pieralisi , "Rafael J. Wysocki" , Mark Rutland , Marc Zyngier , Daniel Lezcano , Thomas Gleixner , Greg Kroah-Hartman , Danilo Krummrich , Hanjun Guo , Sudeep Holla , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Andy Shevchenko , Leo Yan Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, driver-core@lists.linux.dev References: <20261130-acpi-static-table-irq-probe-defer-v2-0-7e854fe7aecd@kernel.org> <20261130-acpi-static-table-irq-probe-defer-v2-2-7e854fe7aecd@kernel.org> From: Robin Murphy Content-Language: en-GB In-Reply-To: <20261130-acpi-static-table-irq-probe-defer-v2-2-7e854fe7aecd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 30/11/2026 8:54 am, Lorenzo Pieralisi wrote: > 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 > --- > Cc: Bartosz Golaszewski > Cc: Andy Shevchenko > Cc: "Rafael J. Wysocki" > --- > 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); Perhaps a to_acpi_static_node() macro to save undue repetition? > + 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; It took me a while to grasp why both of these and how they're different... Might it be neater to just require callers to explicitly pass an index to acpi_static_fwnode_add_irq()? Given that the corresponding get_irq can equally look up by name or index, it's arguably a bit weird that one is based purely on the data passed by the provider, while the other is implicitly dependent on the order in which they did so. In fact having a bit more determinism here could even be considered an improvement, since currently if an IORT consumer thought they could look up a particular SMMUv3 interrupt by index based on the clear order in the node structure, they may well get a surprise. Thanks, Robin. > + 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; >