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=1796158825; b=WO4RlOu8qDEjjPetZqvNJTWG7Zt92gnj1FW9b3E7mulAh47jgm7ou6ZMkWtp7S2YjoMH 6T1MD0dOmhfUFI7K46fTHDVjV3tc1gYV2550XTdbRX3Qg6RsW5inSE8u6oajRcxi/uoLT To+adIDiQGrBOA8ucu58kIkhRrhcNUjB5ajzbVkPaDWYrj74tDMlcTkAp2WivDQsSARAg JmDhWo7z0yEJuMgIQRiHgHvU9fAO2DnIGqqxNoO24GxccPxDfdDRvJitZK8Rj3ZH6mO6I C04fGQN7+Le+o+AzOyYtRdAuSqmq+dt5oUWZewz+JnAuooHq54dubXv24NZZCR9jd1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796158825; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type; bh=UFPVG+ZmlXNuw2sRj7ir+s2m11kyL9WPEBgtiu3Iy4o=; b=QaYCrU1fdAoe5OOzZVQ3WMDMwLYr5lE76aqoTYRM8jw+W1h3e2/SdXTvLl/ML4K/vbqc JDh/SRSWvzqCLuq4uIawH80rNCGzriao/u4Po96Bolc79fF8RD+eRYH1y1LU9TJRiGU8M bdFxTCQzC4oUao+SrJYnLAeZC13Ia/xwgQbB5c4pwSHmvH9i+Fv4ThHc4YF+izuTfEOg8 QdgYrSQEIjstJp5MvOnnubD8lgGDeghdfDE/dedPGJaLE4zTBRLvvvbFIs0aTAgxACJn2 LMCbLgOvlrDHDUkMdDi1uaRQmB1Nr9wtXw/HMotjW3MydwqQxiXl49AApL7VWK8uL9w== 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=a9toWUC9; 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 BCC8C606A322; Tue, 1 Dec 2026 21:00:25 +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=a9toWUC9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D13031F00893; Tue, 1 Dec 2026 21:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796158825; bh=UFPVG+ZmlXNuw2sRj7ir+s2m11kyL9WPEBgtiu3Iy4o=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=a9toWUC9ahMxbzNYMJlgbjU0G2l3/W//oJOPiQW0WtyAUjdE0XlxvdrwOVgk+SWuy 94DypgbgXOGXlz+gpX7tipDyLaNZMbf8SxpV9rcc8XHUuVLlR/IGEBQRFM7ZpAcBYH YigPpBZQ2Aso+s3hSbDM756NwuDJSeA4AGXlTeKZEfxLsWvdJncD5hQ2iFX4M5s12Q cU/gLqFLf20uGsXglzrw0VDiRG91HEiq1abImXHrG4aH4usZI/mn2ccFc+5nYaBJsz vcbIq//YiEoWSU6hfBhgjMxvJWNo2yq6jedLUWD2m8XRZyR4zfFzaSLpfujG+Khk01 yNrwjCO6uy+bA== From: Thomas Gleixner To: filipp.dunsky@gmail.com, Radu Rendec , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v6 2/2] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller In-Reply-To: <20261201-cs75xx-intc-v6-2-bcd0a80afd62@gmail.com> References: <20261201-cs75xx-intc-v6-0-bcd0a80afd62@gmail.com> <20261201-cs75xx-intc-v6-2-bcd0a80afd62@gmail.com> Date: Tue, 01 Dec 2026 22:00:22 +0100 Message-ID: <87zeuoogwp.ffs@fw13> 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 On Tue, Dec 01 2026 at 19:32, Fil Dunsky via wrote: > + > +static int __init cs75xx_intc_domain_init(struct irq_domain *domain) > +{ > + const struct cs75xx_intc_setup *setup = domain->host_data; > + struct irq_chip_generic *gc; > + > + gc = irq_get_domain_generic_chip(domain, 0); > + gc->reg_base = setup->base; > + gc->chip_types[0].regs.mask = CS75XX_INTC_ENABLE; > + gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; > + gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; > + > + /* The setup data lives on the stack and is only needed before publication. */ > + domain->host_data = NULL; > + irq_set_chained_handler_and_data(setup->parent_irq, cs75xx_intc_handler, domain); > + return 0; > +} irq_domain_chip_generic_info has its own init() callback for a reason. The point is that the chip has to be ready and complete after irq_domain_alloc_generic_chips() returns. Your admittedly clever abuse of the domain_info::init() callback relies on the behavior of the current core code. That's not really clever as it is prone to hard to diagnose failures down the road if the core code changes. I pointed you to an example which got it right, no? > +static int __init cs75xx_intc_init(struct device_node *np, struct device_node *parent) > +{ > + struct cs75xx_intc_setup setup; Handing host data in with a pointer to stack memory and then clearing it in the domain somewhere else is the other "clever" thing which makes me cringe. I can see the "charm" of your approach, but then it want's to be done right. Something like the uncompiled below should work. You get the idea. Feel free to turn it into a proper patch. Thanks, tglx --- --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -149,6 +149,12 @@ struct irq_domain_chip_generic; * @gc: Pointer to a list of generic chips. There is a helper function for * setting up one or more generic chips for interrupt controllers * drivers using the generic chip library which uses this pointer. + * @init_data: Controller private data pointer for the init callbacks of the domain + * and the generic chips. Can safely point to stack memory. It is NULL'ed + * after the callbacks have completed and before the domain is published. + * The init() callbacks are not allowed to store the pointer. It's only + * there to provide data for domain and chip initialization to avoid carrying + * unused allocated memory around in @host_data forever. * @dev: Pointer to the device which instantiated the irqdomain * With per device irq domains this is not necessarily the same * as @pm_dev. @@ -188,6 +194,7 @@ struct irq_domain { const struct msi_parent_ops *msi_parent_ops; #endif void (*exit)(struct irq_domain *d); + void *init_data; /* reverse map data. The linear map gets appended to the irq_domain */ irq_hw_number_t hwirq_max; @@ -325,6 +332,8 @@ struct irq_domain_chip_generic_info; * domains are added using same fwnode * @ops: Domain operation callbacks * @host_data: Controller private data pointer + * @init_data: Controller private data pointer for the init callbacks + * of the domain and generic chips. Can safely point to stack memory. * @dev: Device which creates the domain * @dgc_info: Geneneric chip information structure pointer used to * create generic chips for the domain if not NULL. @@ -345,6 +354,7 @@ struct irq_domain_info { const char *name_suffix; const struct irq_domain_ops *ops; void *host_data; + void *init_data; struct device *dev; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY /** --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -332,6 +332,7 @@ static struct irq_domain *__irq_domain_i domain->flags |= info->domain_flags; domain->exit = info->exit; domain->dev = info->dev; + domain->init_data = info->init_data; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY if (info->parent) { @@ -352,6 +353,8 @@ static struct irq_domain *__irq_domain_i if (err) goto err_domain_gc_remove; } + /* info::init_data can point to stack memory. Don't leak the pointer */ + domain->init_data = NULL; __irq_domain_publish(domain);