From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796028915; b=vKlbxWPIGsSru45QcnNnXDEd4YfWwmTJhTDxHUGCPvfECZt5BVAFIEIvZRYiuIbe4Ujd xLsThnL25U+ZPMCnbeRJLA5v1jfVtxF+sHgP4//5bcN7sxpqbr2NOYl6VE4MXuKhIN3V/ /d+EOzn2F1axnpwswXPB+1bISrSATbXBBl430J0zAreoXgMLf/kWpgBwJWm1gMTs1PEot X73hUOKIYBWoTDeMtarz+UH3cMplikGvfVMi0KtnfWmmmKprF5quVsAUtvvOVM7qjGeMY qLcIQSzLXfTfCbKS5t0yHshQfZH+n/v1I315QOGPJJm+g6lo9vgSI1wXf8iE/fycAFA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796028915; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer; bh=8ij+wpcsmUDOYzO1iyFlqetDywZlHBIm001MImADEvY=; b=jGVRLVDrttR6gxMYMlFhKNt3HzuhDXL7AjbsxWCDo0PbBUtDSs0lpBmhhvmvX4zgJeVM IkFWADKxdyJq0mm/IkLRdIRgPDvV1ebz5K6mGSXQymjnw76brwYTfln2a2K+4iomTMNE4 kmQPcbsbnqbtAiLDXdc3PcCS0DqeXXDhu6JzxoasNHttBjnpB4VeQ5LLI5lp1rmwvSpap QEyVA5WPGQ2w7oZijUEkfYo7CzTjHWTnDgxmMuCMVBQUg9JhixWjQCie8uGgQFW+o5J2q fWzNfty7WJqSbZ9UsAdf0hdURT7fe3a3lRQVrQMFiOABSrMrvcix2mM93GZRfjI2tIg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XwX46yTv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17DDD606A33A; Mon, 30 Nov 2026 08:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XwX46yTv Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBD311F000C1; Mon, 30 Nov 2026 08:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796028914; bh=8ij+wpcsmUDOYzO1iyFlqetDywZlHBIm001MImADEvY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=XwX46yTvkfztu4+ENgWd/fmr5yU5CY3l9VMfIbhJ0MFz01U4tMofJh5cQpyC5Bzkd Hkd7YBCoA0MBA9xwYk2cpxg/CvNPB34eojjNZ80btdmI2jarN4YIN81A6fds4FoUCq F1Ppj+mVqcQE1DfAQAxAanZTJyBpAJk8L5BBBpnGK855NSz3EgjyRHwPXxx3j4KFOb RNJ78VjHeo//LOsPvLkbSyH1obW91DGMhWTTSRpgY3QtYvKLxVhrGBF6mlF2ONfyyb 6u/q3cGcSH9KuM3k2/6g743RivJ0NfhdraO/SM+g9gnzJjYxE+/mV22/mxtWn61xLH NeJE8FfiISRbw== From: Lorenzo Pieralisi Date: Mon, 30 Nov 2026 09:54:34 +0100 Subject: [PATCH RFC v2 2/9] ACPI: Introduce IRQ methods for static fwnodes 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261130-acpi-static-table-irq-probe-defer-v2-2-7e854fe7aecd@kernel.org> References: <20261130-acpi-static-table-irq-probe-defer-v2-0-7e854fe7aecd@kernel.org> In-Reply-To: <20261130-acpi-static-table-irq-probe-defer-v2-0-7e854fe7aecd@kernel.org> To: "Rafael J. Wysocki" , Mark Rutland , Marc Zyngier , Daniel Lezcano , Thomas Gleixner , Greg Kroah-Hartman , Danilo Krummrich , Hanjun Guo , Sudeep Holla , Robin Murphy , 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, Lorenzo Pieralisi X-Mailer: b4 0.15.2 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); + 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