Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp969445lqs; Fri, 14 Jun 2024 10:37:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcLr07FaBa7kV54BKX0OjoCp/1m+yxlAWsNJs/MOItjrM26dxcHyjg5xurGcBX8NdkQuMcr62FP581yl7OEREK9i6kRQEt0lN8EjdPkQ== X-Google-Smtp-Source: AGHT+IHJ2fJGVgnfxH9G8bVgjg8EGHldj6ku4TAgf01n8zE0dcxkeLPJu7gY6ynQh5lNNIxCe6Mc X-Received: by 2002:a9d:6659:0:b0:6f9:a996:80ac with SMTP id 46e09a7af769-6fb9375c64emr3333423a34.9.1718386636920; Fri, 14 Jun 2024 10:37:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718386636; cv=pass; d=google.com; s=arc-20160816; b=Yy0IKZcMy1Ch5CYf9cEdG1VDhTcfL18rXrL/TpzJ8n9kV+SZYNJW7YcRKh5YaqOEHb 2aW7g3BhkkXoTfDF1nsfUiW7WJUKGsC1XHtgfOKlbJXzmA9E/Erz30tkt59qxeveKbQ1 6Z7ZKwiNOxDNU72XOzYvb6/0FnNx/QdrswuLde054E6jDAJqGW9IqTagOyNIYYq8UZLa 4gDlRRIRbjzFPw3i06axicaw4aYpUEeuQCTK5pnIItPIzzE45nKhAcZnpatPHperzYy6 98zX/8Mirz4nOOKyKRdSceFtuIAz9ijwS/Jmuf5IlzpmgBlgzC7ge7eFdmVBHvdqX7cY Ey3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jYNoEWBZlzduIVJgCOvsuNgUKgrmtRin0j3Jv9ZGB0c=; fh=bujJSrd+k1h/0aZbC1LeFD2/cY2NpcCgJFppOaBslqM=; b=UGZcBzabLIrO/0fgDSOcd+ucyZDeB/AiHgTp5Ehd0eygr3F07q80tRgIYOztMM5ENF Kz1R/iMmPpZYFsPWbD2MFyb86tbDLLpxhNeRJYhoppjH6wWuVYy5TvoIzc4SGde4MaBi eWKW7xWJWNrNb1jihhkv+4BMKchdyjMM4Ehv+Gz5vpgXHiOk12VVHoAV4KqG7zJGohlD unvUDnl+bRZPoFVlZxDAUh8ZixfRSVbNoPBJhNm1X/Sr9QpHeGH/SKzhxw0mXa4jL9W0 QR6TA7YdzyGyLW6ulaKEQw1D8m+cMV3+L8rNDe9Id+SUlg9N9Vh3wGBagDLg7uOxm+X9 KQXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ez3HgDN5; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-215376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b2a5b37f21si43049526d6.403.2024.06.14.10.37.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 10:37:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ez3HgDN5; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-215376-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5F3981C211DF for ; Fri, 14 Jun 2024 17:37:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 680191A38E4; Fri, 14 Jun 2024 17:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ez3HgDN5" Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F671AC45F; Fri, 14 Jun 2024 17:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718386382; cv=none; b=i8Py4Q9ZZHmPRp2yAh7k/zw91Oy5AXH71HM86ECMYRjHRoiW1CAaAwydye+5imGQLv21cosNTF6SMlM3XoDsTlni9RPnCWgA6tCH72x/TyGcyVUSkLayR9F/svhsNzcKF+aWK0HKoBynWqXBAZgEwk08swR8SewNiANouKTReng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718386382; c=relaxed/simple; bh=VlvGKRRpo5xWBJoejsLyt7nigRzK4ZhbFT7a46KLwNI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tTv40NsPOWe3N4xuSikWYIkN4hMA8B8355qMORoMsI7maziLKFwyUsjHQPCNdIi3QRuztedly2CvN3SX6o4J5/etvgHr9PTsdCzdAzXyFbeQnLl8iPNjXRH8eko8Vc+hOfuoivav6HiWxM40tog6NH6ow+eFR8zPe3xxoKvMGWk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ez3HgDN5; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id 4869DFF803; Fri, 14 Jun 2024 17:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718386378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jYNoEWBZlzduIVJgCOvsuNgUKgrmtRin0j3Jv9ZGB0c=; b=ez3HgDN5+vlxZQZG+rEbv4mPtd20Jh6XPRZ9uxw3I8+BErytIt+OAYVo4zhZLQ0vAfKpUO b0Xlm6nC17l5QUZMzNACZuWBjiaK26labQ9G7oornNfGsCCHESnlxBH7Z9AfcBDzI1AzeF xQTdnTGeLhJYqUFpmInrsyvocUdKtPnWoyN8ddQiM4jn+xh/+ob1D3vHJQQTM9Va8v/VsG HNLZ3o4f8kuYi5+ZIYEMDBIlH0IQUjM/Scvuzz1mFOdWWQ9oLCHSH8dxIoBBJ9tv5bFs1u Iiu5rzH9AWc35IVwQj19e+3qWiMS9j+lx3rMhfwQODHD4PdR9DLVA3PEdypJGw== From: Herve Codina To: Matti Vaittinen , Herve Codina , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Weinberger , Anton Ivanov , Johannes Berg , Marc Zyngier Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-um@lists.infradead.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni Subject: [PATCH 15/23] irqdomain: Add support for generic irq chips creation before publishing a domain Date: Fri, 14 Jun 2024 19:32:16 +0200 Message-ID: <20240614173232.1184015-16-herve.codina@bootlin.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614173232.1184015-1-herve.codina@bootlin.com> References: <20240614173232.1184015-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com The current API functions create an irq_domain and also publish this newly created to domain. Once an irq_domain is published, consumers can request IRQ in order to use them. Some interrupt controller drivers have to perform some more operations with the created irq_domain in order to have it ready to be used. For instance: - Allocate generic irq chips with irq_alloc_domain_generic_chips() - Retrieve the generic irq chips with irq_get_domain_generic_chip() - Initialize retrieved chips: set register base address and offsets, set several hooks such as irq_mask, irq_unmask, ... With the newly introduced irq_domain_alloc_generic_chips(), an interrupt controller driver can use the irq_domain_chip_generic_info structure and set the init() hook to perform its generic chips initialization. In order to avoid a window where the domain is published but not yet ready to be used, handle the generic chip creation (i.e the irq_domain_alloc_generic_chips() call) before the domain is published. Suggested-by: Thomas Gleixner Signed-off-by: Herve Codina --- include/linux/irqdomain.h | 9 +++++++++ kernel/irq/irqdomain.c | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 2c927edc4d43..5540b22a755c 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -210,6 +210,9 @@ enum { /* Irq domain is a MSI device domain */ IRQ_DOMAIN_FLAG_MSI_DEVICE = (1 << 9), + /* Irq domain must destroy generic chips when removed */ + IRQ_DOMAIN_FLAG_DESTROY_GC = (1 << 10), + /* * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved * for implementation specific purposes and ignored by the @@ -259,6 +262,9 @@ static inline struct fwnode_handle *irq_domain_alloc_fwnode(phys_addr_t *pa) } void irq_domain_free_fwnode(struct fwnode_handle *fwnode); + +struct irq_domain_chip_generic_info; + /** * struct irq_domain_info - Domain information structure * @fwnode: firmware node for the interrupt controller @@ -270,6 +276,8 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode); * @bus_token: Domain bus token * @ops: Domain operation callbacks * @host_data: Controller private data pointer + * @dgc_info: Geneneric chip information structure pointer used to + * create generic chips for the domain if not NULL. * @init: Function called when the domain is created. * Allow to do some additional domain initialisation. * @exit: Function called when the domain is destroyed. @@ -290,6 +298,7 @@ struct irq_domain_info { */ struct irq_domain *parent; #endif + struct irq_domain_chip_generic_info *dgc_info; int (*init)(struct irq_domain *d); void (*exit)(struct irq_domain *d); }; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 9efc9f180308..d95ca575a108 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -292,16 +292,25 @@ struct irq_domain *irq_domain_instantiate(const struct irq_domain_info *info) } #endif + if (info->dgc_info) { + err = irq_domain_alloc_generic_chips(domain, info->dgc_info); + if (err) + goto err_domain_free; + } + if (info->init) { err = info->init(domain); if (err) - goto err_domain_free; + goto err_domain_gc_remove; } __irq_domain_publish(domain); return domain; +err_domain_gc_remove: + if (info->dgc_info) + irq_domain_remove_generic_chips(domain); err_domain_free: irq_domain_free(domain); return ERR_PTR(err); @@ -369,6 +378,9 @@ void irq_domain_remove(struct irq_domain *domain) mutex_unlock(&irq_domain_mutex); + if (domain->flags & IRQ_DOMAIN_FLAG_DESTROY_GC) + irq_domain_remove_generic_chips(domain); + pr_debug("Removed domain %s\n", domain->name); irq_domain_free(domain); } -- 2.45.0