From nobody Fri Dec 19 07:30:15 2025 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BDE51E511 for ; Thu, 8 Aug 2024 12:34:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723120453; cv=none; b=gS3DRbJWi4t8oeaacXAjJuSptuP61ws7B2e+IEJgNGTEaZ757TYvDDkFOPaku4dlisITmqglBz7aZCxdRCyFhf695XC76psjI8mTbGp+x08rDsnS+T8dfp0Mble4WD4l1eB+1fQAWCrqwwWYYTVk/RZkBE/8yfu+ctjX6bsLD8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723120453; c=relaxed/simple; bh=tz036277a8bDgHHfC2OQToU+PhUGD6SliTzSnU1sy3w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kW+PEImCU4Bbt72PniCo7wP65QNvHmwR867hSD1QHJ8QFqEQkCinFwzgO9anyMlcr7yIuygPCsNnkLC+0DAA/36UYlwY5wwFexhqCp5KbAVAD2iSZwz2PMoH/Yb2tugQzfKaXQijGA4zG1cwtmX5QJw9Tettcl6zaEmsxaJf590= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lzZJZsoq; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lzZJZsoq" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2f040733086so9207151fa.1 for ; Thu, 08 Aug 2024 05:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723120448; x=1723725248; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=KZHpAiTIt/O6A6h71tyCVcy7V+/AGzg65920gUuJPt8=; b=lzZJZsoq2n4VZqDIaVWh8fg7C32GmbyOrjPyMBLboT0wSX+m7ZWh56zJDg5MrdaKyP IcGWc/LFpBeG+k21vfuyfEnlVV1aN1lYEsUjv1PIfDTURm+nB82Wo2+sPpbuJKq0134V WOtafpy/oPPFl7/RUc42CWYW83cfKCskVz4oMxTK0OCnciSHH2O/E2IIbSjV9UnZrpm2 bh+dU9P7zATShWNEEoEoxlikHQ23u3jNbZwCkrAAy7S7hqbbDA9UIDdIMvcybF3o0+7Z o8VHhDYPiE7afTPsJXucxxXRPhcUh8lhOVOdnjWUdptROEHB/QdO9vnd8yFys+SQS1bQ dx5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723120448; x=1723725248; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KZHpAiTIt/O6A6h71tyCVcy7V+/AGzg65920gUuJPt8=; b=LiT8VMvQgQnZZkm3FR97S7LRpTsQYlEUcINRN2kE2FnVuL32NMJJw3R7iIMiGsoLwR LUMKTqrcnLC5WfsX7dlVnnVv3+jI3lC07bspOjJGV8JtV43McxzW8o5pChEDLiQjZD1E 96cO2DqL9tI59bK69Qifvc3ZwHaxppIVWQC4FaXwyduPTZ5flCU1Zx/W2r762DmQfhRQ La+Ky9mdlosWknx9WfD1OgRxWHLtI7wcTfGI4rZb5+KsTzvoZB+b3AQSLNgJzhbhmDou lWp/vAd7C91Zyn1gHv/IqnHwy0dEKHjx7laNlBJoTcxSE5zJ2gbol1RQPhN0sJWtjGjz +XHQ== X-Forwarded-Encrypted: i=1; AJvYcCU4W7XZziTlulJwtvYQSZI2Rjz9lDNhCAL9SpDPsyTQWDas0fuSRxuB28Dt/serDZLxnB38J5PQrunySkAb8HBKQTVAHkEmJR4o2Lgs X-Gm-Message-State: AOJu0YxQAD93q7oyXtiyZmsJbAJLjysPihi6Rw7ksTeJpBWNld26eOrJ PWS534corntXDKSduvOLio6edgEtc1svZwzA/zjzGyMEqX1v05ht X-Google-Smtp-Source: AGHT+IFkK9jWZi5v/SIXXRg2uAZefOiiOn0ABaCFkDJ23LcwIstpIIeF9NOudvlzsUppbihD39iG4Q== X-Received: by 2002:a2e:bc25:0:b0:2ef:2e3f:35d2 with SMTP id 38308e7fff4ca-2f19de1f942mr14767341fa.5.1723120447508; Thu, 08 Aug 2024 05:34:07 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2f15e1aea5bsm20824591fa.44.2024.08.08.05.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 05:34:06 -0700 (PDT) Date: Thu, 8 Aug 2024 15:34:02 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] irqdomain: simplify simple and legacy domain creation Message-ID: <32d07bd79eb2b5416e24da9e9e8fe5955423dcf9.1723120028.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5Fv/FwShYrc/riQJ" Content-Disposition: inline In-Reply-To: --5Fv/FwShYrc/riQJ Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move a bit more logic in the generic __irq_domain_instantiate() from the irq_domain_create_simple() and the irq_domain_create_legacy(). This does simplify the irq_domain_create_simple() and irq_domain_create_legacy(). It will also ease the use of irq_domain_instantiate() instead of the irq_domain_create_simple() or irq_domain_create_legacy() by allowing the callers of irq_domain_instantiate() to omit the IRQ association and irq_desc allocation code. Reduce code duplication by introducing the hwirq_base and virq_base members in the irq_domain_info structure, creating helper function for allocating irq_descs, and moving logic from the .._legacy() and the .._simple() to the more generic irq_domain_instantiate(). Signed-off-by: Matti Vaittinen Suggested-by: Thomas Gleixner --- Revision history: v1 =3D> v2: - New patch Please note that this patch has received only limited testing. Any and all testing with devices using the legacy domains is greatly appreciated :) --- include/linux/irqdomain.h | 5 +++ kernel/irq/irqdomain.c | 73 +++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 33 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index de6105f68fec..bfcffa2c7047 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -291,6 +291,9 @@ struct irq_domain_chip_generic_info; * @hwirq_max: Maximum number of interrupts supported by controller * @direct_max: Maximum value of direct maps; * Use ~0 for no limit; 0 for no direct mapping + * @hwirq_base: The first hardware interrupt number (legacy domains only) + * @virq_base: The first Linux interrupt number for legacy domains to + * immediately associate the interrupts after domain creation * @bus_token: Domain bus token * @ops: Domain operation callbacks * @host_data: Controller private data pointer @@ -307,6 +310,8 @@ struct irq_domain_info { unsigned int size; irq_hw_number_t hwirq_max; int direct_max; + unsigned int hwirq_base; + unsigned int virq_base; enum irq_domain_bus_token bus_token; const struct irq_domain_ops *ops; void *host_data; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index cea8f6874b1f..5af5e4028de2 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -267,13 +267,20 @@ static void irq_domain_free(struct irq_domain *domain) kfree(domain); } =20 -/** - * irq_domain_instantiate() - Instantiate a new irq domain data structure - * @info: Domain information pointer pointing to the information for this = domain - * - * Return: A pointer to the instantiated irq domain or an ERR_PTR value. - */ -struct irq_domain *irq_domain_instantiate(const struct irq_domain_info *in= fo) +static void irq_domain_instantiate_descs(const struct irq_domain_info *inf= o) +{ + if (!IS_ENABLED(CONFIG_SPARSE_IRQ)) + return; + + if (irq_alloc_descs(info->virq_base, info->virq_base, info->size, + of_node_to_nid(to_of_node(info->fwnode))) < 0) { + pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", + info->virq_base); + } +} + +static struct irq_domain *__irq_domain_instantiate(const struct irq_domain= _info *info, + bool cond_alloc_descs) { struct irq_domain *domain; int err; @@ -306,6 +313,14 @@ struct irq_domain *irq_domain_instantiate(const struct= irq_domain_info *info) =20 __irq_domain_publish(domain); =20 + if (cond_alloc_descs && info->virq_base > 0) + irq_domain_instantiate_descs(info); + + /* Legacy interrupt domains have a fixed Linux interrupt number */ + if (info->virq_base > 0) + irq_domain_associate_many(domain, info->virq_base, info->hwirq_base, + info->size - info->hwirq_base); + return domain; =20 err_domain_gc_remove: @@ -315,6 +330,17 @@ struct irq_domain *irq_domain_instantiate(const struct= irq_domain_info *info) irq_domain_free(domain); return ERR_PTR(err); } + +/** + * irq_domain_instantiate() - Instantiate a new irq domain data structure + * @info: Domain information pointer pointing to the information for this = domain + * + * Return: A pointer to the instantiated irq domain or an ERR_PTR value. + */ +struct irq_domain *irq_domain_instantiate(const struct irq_domain_info *in= fo) +{ + return __irq_domain_instantiate(info, false); +} EXPORT_SYMBOL_GPL(irq_domain_instantiate); =20 /** @@ -413,28 +439,13 @@ struct irq_domain *irq_domain_create_simple(struct fw= node_handle *fwnode, .fwnode =3D fwnode, .size =3D size, .hwirq_max =3D size, + .virq_base =3D first_irq, .ops =3D ops, .host_data =3D host_data, }; - struct irq_domain *domain; + struct irq_domain *domain =3D __irq_domain_instantiate(&info, true); =20 - domain =3D irq_domain_instantiate(&info); - if (IS_ERR(domain)) - return NULL; - - if (first_irq > 0) { - if (IS_ENABLED(CONFIG_SPARSE_IRQ)) { - /* attempt to allocated irq_descs */ - int rc =3D irq_alloc_descs(first_irq, first_irq, size, - of_node_to_nid(to_of_node(fwnode))); - if (rc < 0) - pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", - first_irq); - } - irq_domain_associate_many(domain, first_irq, 0, size); - } - - return domain; + return IS_ERR(domain) ? NULL : domain; } EXPORT_SYMBOL_GPL(irq_domain_create_simple); =20 @@ -476,18 +487,14 @@ struct irq_domain *irq_domain_create_legacy(struct fw= node_handle *fwnode, .fwnode =3D fwnode, .size =3D first_hwirq + size, .hwirq_max =3D first_hwirq + size, + .hwirq_base =3D first_hwirq, + .virq_base =3D first_irq, .ops =3D ops, .host_data =3D host_data, }; - struct irq_domain *domain; + struct irq_domain *domain =3D irq_domain_instantiate(&info); =20 - domain =3D irq_domain_instantiate(&info); - if (IS_ERR(domain)) - return NULL; - - irq_domain_associate_many(domain, first_irq, first_hwirq, size); - - return domain; + return IS_ERR(domain) ? NULL : domain; } EXPORT_SYMBOL_GPL(irq_domain_create_legacy); =20 --=20 2.45.2 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --5Fv/FwShYrc/riQJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAma0uzoACgkQeFA3/03a ocU7xwf/Ry2+yDlU8WksjmhM776lg0t0qfi5ccanvmy6JGdoRuVzbB0PF7Zc/KcM esRQ9M8i98poZyyECawaHVVVupetNmaD1aiwS6VCI3/4Aj38zakZrGXq5YuawYIo Utzdg9kIzShOmlbJnltJ8Gv+I81iscXIBQZ7DOEATJ/a4YhfbZgenzOpvE7q7AB5 0HbDFowzkN9YNcxwo7WEU1t0/+di+jwMCDWeM+bHnxaGn+DPF6/FWy92/ntqM0fO SWnCV3Le+U/vIUI3aB4g06bwsI8X3fD0sKcHMjkppZWiJ8ztIoGBuR6Q133H7leN dSZCf85ZLMG+gsWFvo8IXM+kbuMzxw== =hMYv -----END PGP SIGNATURE----- --5Fv/FwShYrc/riQJ-- From nobody Fri Dec 19 07:30:15 2025 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2D371E511 for ; Thu, 8 Aug 2024 12:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723120509; cv=none; b=tjhTVacfUo25RhDCRMswg7NXQfDRoVcdkQSPSeUsCvW3/ti1atj7qMx0CaM23COIOT+FzUETGAbjSykSy7QrQaKehaaZYX3D7LhLvbA/8zl+kS5tFWIMxyVKmIFVFmOcb0VAVckLYUwnUIGlxoRUUNnptRGTfmspMiF7Ap8+q3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723120509; c=relaxed/simple; bh=T09VfP/9+XczLP9nOtI6WsyNARFndysB7hs+8/KBoDo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VeQ46W9gb1N9InveWSzsEmdJBjYWSZWSYXOxSMALwBGXy9auRzXf8qy4vA+zcOEcHhBlBnUOCupfKWoq5PVr05yqZrzsm5gSMCbvJHYxKH3AEEnRJ+c7LLdIHuRT93FSkjdOpErJibF160eBxgP3qHoRI58o1su/Tg2IW/gxCYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S+UyBtf8; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S+UyBtf8" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-52efbb55d24so1588593e87.1 for ; Thu, 08 Aug 2024 05:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723120506; x=1723725306; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=oNhAwsrhIdal4pwoMXUZpj+EEHqYsqeqWIBG0u/1A6w=; b=S+UyBtf8Ym2or0L5EOOtL9whky+mmyyeLXOl1GQUihV1JKlLHK/E0Z00yZtl0tJ17G M92lqMMiZLxZKl2e6RnIrdThIMeJUrm5DHuKUmJQOeEtH0kdWJVQJHC90RohMIy3etqv j9DCLTmTfGt5AXzA1WeUtB7VouNVU/CXXEldnptLdM02Bciivpme7CkIZcPtLPhQnL1s Ull1p4OWeXVua8GWzcoQOoEaxJqGJkNlCHQgKRRJVsffJHJxz6PK6Odv6VhPnImPnYdX VrOJ63jXBWIPhHDuNSwOAGGmL7rCEJy35ONsV3htNE3jf4+ZQi3c6C+Lu1pvqB2EgKpL 7T4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723120506; x=1723725306; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=oNhAwsrhIdal4pwoMXUZpj+EEHqYsqeqWIBG0u/1A6w=; b=YGc6+cNty8bliP9UErMhqrPlBXfOA+yAe3uvsnh6rfg6CpPNo2uXwxfl92LedS58b/ wRv6LHvkoKgcA7EOAiARP6NU5L7keirFUB1WpzJifVI8SKN8qZ53LSkRkL3FPZb/xBPv 85Jd26bkBer2Shrw1FO/exqPKioZcdTvszd/j6NlqszTg1keOBfyJOVUPf7unEwoE5o9 Ih+7iJSdnlx0aE1tJ0dotYwKPLPlqxQn1kE0CItjzhJOrD8XfkJHRr+hlEA8HsgNKkZD DeuKjATGniz9csApPlIQsfiIQHU9nX4ItPHqU5PcoYA2XkYdUIn3H3Uelei8ptmo/UuH b5fA== X-Forwarded-Encrypted: i=1; AJvYcCWWXzmtEvKQPRgbD98+f2w7nhvQfByqUYQAHyr/0jmsQAAdgoVq0cAmGsEBkAhlj/UIsy5EDNxXKoQ+c1lsMVfyZwHu4ShjKQiulwUU X-Gm-Message-State: AOJu0YwUPeBplpUkoH41zPIQFHIy3I7NQhmjfsio4eLybUHv8Oxx8ewM HECGTPv8387hONzi3qg9J3oLF0pvMVI9lKGBNStPDrCIgRiPWS4R X-Google-Smtp-Source: AGHT+IFfMaExb9vVqzZw910hOxowlTD8DLm91DGq3oOd/1yT7ytbJKNfZVXKN8Em1P2PAGCb3408iw== X-Received: by 2002:a05:6512:220a:b0:52e:73f5:b7c4 with SMTP id 2adb3069b0e04-530e5876b25mr1758069e87.37.1723120505273; Thu, 08 Aug 2024 05:35:05 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-530de47c422sm622767e87.264.2024.08.08.05.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 05:35:04 -0700 (PDT) Date: Thu, 8 Aug 2024 15:35:00 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] irqdomain: Allow giving name suffix for domain Message-ID: <7a048c0139e79beb46d887b0cd5a620963ff8ef8.1723120028.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="852xrl80h3Srxl19" Content-Disposition: inline In-Reply-To: --852xrl80h3Srxl19 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Devices can provide multiple interrupt lines. One reason for this is that a device has multiple subfunctions, each providing its own interrupt line. Another reason is that a device can be designed to be used (also) on a system where some of the interrupts can be routed to another processor. A line often further acts as a demultiplex for specific interrupts and has it's respective set of interrupt (status, mask, ack, ...) registers. Regmap supports the handling of these registers and demultiplexing interrupts, but interrupt domain code ends up assigning the same name for the per interrupt line domains. This will cause a naming collision in the debugFS code and can also lead to confusion, as /proc/interrupts would show two separate interrupts with the same domain name and hardware interrupt number. Instead of adding a workaround in regmap or driver code, allow giving a name suffix for the domain name when the domain is created. Add a name_suffix field in the irq_domain_info structure and make the irq_domain_instantiate() to use this suffix if it is given when a domain is created. Signed-off-by: Matti Vaittinen --- Revision history: v1 =3D> v2: - typofix in comment. 'collison' to 'collision'. --- include/linux/irqdomain.h | 3 +++ kernel/irq/irqdomain.c | 36 +++++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index bfcffa2c7047..e432b6a12a32 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -295,6 +295,8 @@ struct irq_domain_chip_generic_info; * @virq_base: The first Linux interrupt number for legacy domains to * immediately associate the interrupts after domain creation * @bus_token: Domain bus token + * @name_suffix: Optional name suffix to avoid collisions when multiple + * domains are added using same fwnode * @ops: Domain operation callbacks * @host_data: Controller private data pointer * @dgc_info: Geneneric chip information structure pointer used to @@ -313,6 +315,7 @@ struct irq_domain_info { unsigned int hwirq_base; unsigned int virq_base; enum irq_domain_bus_token bus_token; + const char *name_suffix; const struct irq_domain_ops *ops; void *host_data; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 5af5e4028de2..376bcfb45aff 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -129,13 +129,25 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwn= ode) EXPORT_SYMBOL_GPL(irq_domain_free_fwnode); =20 static int irq_domain_set_name(struct irq_domain *domain, - const struct fwnode_handle *fwnode, - enum irq_domain_bus_token bus_token) + const struct irq_domain_info *info) { + const struct fwnode_handle *fwnode =3D info->fwnode; + enum irq_domain_bus_token bus_token =3D info->bus_token; static atomic_t unknown_domains; struct irqchip_fwid *fwid; =20 if (is_fwnode_irqchip(fwnode)) { + /* + * The name_suffix is only intended to be used to avoid a name + * collision, when multiple domains are created for a single + * device and the name is picked using a real device node. + * (Typical use-case is regmap-IRQ controllers for devices + * providing more than one physical IRQ.) There should be no + * need to use name_suffix with irqchip-fwnode. + */ + if (info->name_suffix) + return NULL; + fwid =3D container_of(fwnode, struct irqchip_fwid, fwnode); =20 switch (fwid->type) { @@ -164,17 +176,23 @@ static int irq_domain_set_name(struct irq_domain *dom= ain, is_software_node(fwnode)) { char *name; =20 + if (info->name_suffix) + name =3D bus_token ? + kasprintf(GFP_KERNEL, "%pfw-%s-%d", fwnode, + info->name_suffix, bus_token) : + kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, info->name_suffix); + else + name =3D bus_token ? + kasprintf(GFP_KERNEL, "%pfw-%d", fwnode, bus_token) : + kasprintf(GFP_KERNEL, "%pfw", fwnode); + if (!name) + return -ENOMEM; + /* * fwnode paths contain '/', which debugfs is legitimately * unhappy about. Replace them with ':', which does * the trick and is not as offensive as '\'... */ - name =3D bus_token ? - kasprintf(GFP_KERNEL, "%pfw-%d", fwnode, bus_token) : - kasprintf(GFP_KERNEL, "%pfw", fwnode); - if (!name) - return -ENOMEM; - domain->name =3D strreplace(name, '/', ':'); domain->flags |=3D IRQ_DOMAIN_NAME_ALLOCATED; } @@ -211,7 +229,7 @@ static struct irq_domain *__irq_domain_create(const str= uct irq_domain_info *info if (!domain) return ERR_PTR(-ENOMEM); =20 - err =3D irq_domain_set_name(domain, info->fwnode, info->bus_token); + err =3D irq_domain_set_name(domain, info); if (err) { kfree(domain); return ERR_PTR(err); --=20 2.45.2 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --852xrl80h3Srxl19 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAma0u3QACgkQeFA3/03a ocWAwwgAzppK0On7q4laV4iAk+32+A2lEkVlQgr3GcmzSpWu8xxKp4D7YBcnhBoD JNrI8cjoXNsKpKtTmkypUPB7jSt4umbZpDL7cP1eCIFyW/NVaa6ZZOKaBPJuX2i0 Dm+EwHj0RZxlI+dCJ1rGYwaeu9akQI0qrTpvCdIh+WUTlyi5bQbChGt5e10XmSnV zE4yZvkEAjavluDst0eKSJ86Eui894ZvaJFuwJKMvkdGu3D2HVLGZKsfFKQSkWkq fGO1pTchuDF9uJe/F1TwGpsgz3KhanY/yJOSeInWb3z5wct+S2+FsxEe2SR6XOcy Bl+OBlh9Vne0ULOC1VmO1zwJk3wrkQ== =XLyQ -----END PGP SIGNATURE----- --852xrl80h3Srxl19-- From nobody Fri Dec 19 07:30:15 2025 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 821E9189513 for ; Thu, 8 Aug 2024 12:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723120598; cv=none; b=tYC+cpolaxtbk/Z4JB1FRCu/BdDRiwEpEoCKK8Fm5RiKhcSprJJCV4EycE2M0CfzPjiIyk7w86RqtvVyD1WmhmFApIVuHZZi2InRAS3bqJIPuL3cQdMeBH9jPPYsDbqIIZhw+Sh95yzj2Vl1JPi6QxiMnry11Fo66WSyPJ/UF6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723120598; c=relaxed/simple; bh=v7lV3u+lEpVaa3+itGth6H6NEphiQOJexLQEacBnr/w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HT4s24mOdpT+RjmAl+fjuycXCAaOwigpzj7xBPlV6Ua9fLW87HYaIlaRbdCj33Wb8H8xCUE0dfYehGuSZc0lCkq6QRq4loRsIJqy3LvQ5ZidjzsaRCmPdJ1TSMXqWMMHh3MqI9tvbpSu0Yrb7LvuMHJBxHyBZPDQ3WxAulzuiIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lElkMJLi; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lElkMJLi" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-52f025bc147so1012813e87.3 for ; Thu, 08 Aug 2024 05:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723120595; x=1723725395; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jzp6Micu3tjXmEKWe8ueoR6gtmK+4KywnqQdz8LMUg0=; b=lElkMJLiMRlG6aD+zDchsP/tAQQatxbOGMacx1USlTu7PLOJlbP1q8nmkt55JmZLyl /h4aLBMe858WZlCeF0lKd6XERd9Se298mVH63PUy2OoqL98y8Ny/naFX8q9HSCaxBnZB 6IdCSHEaaddPyob5x22dxXjFZOYoDZFfbgIhMRFN4hya0bdyfH/NbS7+dyUHZeR/RPyw W8shvpX45muF1dadL21SkSE1Ah+zo5IyrvnsHtp09OODLeenVz7cYIwKwYvrDc2bRXjj GgPwIB0hvwzajyCrgQHHWAR7oOZWasLgfGZtZKOqVCdU76dqQepHR+H11vFf7gPcjSU8 NuBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723120595; x=1723725395; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jzp6Micu3tjXmEKWe8ueoR6gtmK+4KywnqQdz8LMUg0=; b=pU88L6uVuMfAggsFmqn0NieGSXhVM1teDDEo+KWW6/MCSGmyL+84Dxr8S6BDVHboDp VmyubBs62Rfpr6WgrLA34D+ArikrFqDpsQTm6TOLSx58qNhRvBcp6sUDAM/Y0/RyIGO/ gPrQNVNvFj0oYwzNNq//jFNTslw71UbplHT6L8btFFBhm6/qfRBFjnSmI8kt3HERraN/ WvnyZfsfNZYJ6S0f7dL0iF5jaJh3iNhEnPTwy5CTpKXHkzBI7NdlQMK2FGy1iwPMSPbI wEbbrLFJznnUOa4Ervjzj/01ZO1QTNtbD4tbvOPA70/DoLv+yG+xxVW05+OJ+y2dIGbK RJ8A== X-Forwarded-Encrypted: i=1; AJvYcCXnSyD++BkNIKR7c2K+Y0OWyuwd1o+67LFW7lJizwKR66vmdsKwP8gJxf2xGPWESLdBgefhrt203PMCUNTmp3IL73RqidKwCAr/KVnQ X-Gm-Message-State: AOJu0YzLmaheopg0OjGnb8n6dGuMyOlKtwcmodWp0S2icQWLKgRom1c/ 91h31wSb0qHowAAHDOlw/8zmlAI5cOVYkGPTQhQycSigQp2NooE3 X-Google-Smtp-Source: AGHT+IEsat8se4x82dZXnFb2EBu0ObaUr3wLeEjTA0CGa11gLFEcU0x+9GA8FmNxC7IJMwqqtpYeng== X-Received: by 2002:a05:6512:4025:b0:52e:76e8:e18e with SMTP id 2adb3069b0e04-530e581651fmr1326816e87.7.1723120593782; Thu, 08 Aug 2024 05:36:33 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-530de47c5fesm623464e87.269.2024.08.08.05.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 05:36:32 -0700 (PDT) Date: Thu, 8 Aug 2024 15:36:28 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] regmap: Allow setting IRQ domain name suffix Message-ID: <776bc4996969e5081bcf61b9bdb5517e537147a3.1723120028.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="L07GlhcC5fAcYGs/" Content-Disposition: inline In-Reply-To: --L07GlhcC5fAcYGs/ Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When multiple IRQ domains are created from the same device-tree node they will get the same name based on the device-tree path. This will cause a naming collision in debugFS when IRQ domain specific entries are created. The regmap-IRQ creates per instance IRQ domains. This will lead to a domain name conflict when a device which provides more than one interrupt line uses the regmap-IRQ. Add support for specifying an IRQ domain name suffix when creating a regmap-IRQ controller. Signed-off-by: Matti Vaittinen --- A change worth mentioning is that this patch changes the error code returned by IRQ domain generation code to be propagated to the caller. Earlier all IRQ domain creation failutes were returning the -ENOMEM. Please let me know if you assume this will cause problems. This patch was originally part of the series adding support for the ROHM BD96801 PMIC. Basic support was already merged while this one was postponed until the name-suffix support was added to IRQ-domain code. Hence the non linear version history. Finally, there is a comment: "Should really dispose of the domain but..." in the regmap-IRQ creation code. Any insight what the "but..." refers to would be appreciated as there would be an option to for example use the devm_ variant of the irq_domain_instantiate(). Revision history: v1 =3D> v2 (new series) - fix the legacy domain instantiation as was pointed out by Thomas Gleixner. - drop irq_domain_associate_many() which was moved to be called during the irq_domain_instantiate() as was suggested by Thomas. v1 of the new series: - use the new irq_domain_instantiate(). v2 =3D> v3 (old series): - Drop name suffix support for the legacy domains --- drivers/base/regmap/regmap-irq.c | 37 ++++++++++++++++++++++---------- include/linux/regmap.h | 4 ++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-= irq.c index d3ec1345b5b5..a750e48a26b8 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -608,6 +608,30 @@ int regmap_irq_set_type_config_simple(unsigned int **b= uf, unsigned int type, } EXPORT_SYMBOL_GPL(regmap_irq_set_type_config_simple); =20 +static int regmap_irq_create_domain(struct fwnode_handle *fwnode, int irq_= base, + const struct regmap_irq_chip *chip, + struct regmap_irq_chip_data *d) +{ + struct irq_domain_info info =3D { + .fwnode =3D fwnode, + .size =3D chip->num_irqs, + .hwirq_max =3D chip->num_irqs, + .virq_base =3D irq_base, + .ops =3D ®map_domain_ops, + .host_data =3D d, + .name_suffix =3D chip->domain_suffix, + }; + + d->domain =3D irq_domain_instantiate(&info); + if (IS_ERR(d->domain)) { + dev_err(d->map->dev, "Failed to create IRQ domain\n"); + return PTR_ERR(d->domain); + } + + return 0; +} + + /** * regmap_add_irq_chip_fwnode() - Use standard regmap IRQ controller handl= ing * @@ -856,18 +880,9 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *f= wnode, } } =20 - if (irq_base) - d->domain =3D irq_domain_create_legacy(fwnode, chip->num_irqs, - irq_base, 0, - ®map_domain_ops, d); - else - d->domain =3D irq_domain_create_linear(fwnode, chip->num_irqs, - ®map_domain_ops, d); - if (!d->domain) { - dev_err(map->dev, "Failed to create IRQ domain\n"); - ret =3D -ENOMEM; + ret =3D regmap_irq_create_domain(fwnode, irq_base, chip, d); + if (ret) goto err_alloc; - } =20 ret =3D request_threaded_irq(irq, NULL, regmap_irq_thread, irq_flags | IRQF_ONESHOT, diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 122e38161acb..f9ccad32fc5c 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1521,6 +1521,9 @@ struct regmap_irq_chip_data; * struct regmap_irq_chip - Description of a generic regmap irq_chip. * * @name: Descriptive name for IRQ controller. + * @domain_suffix: Name suffix to be appended to end of IRQ domain name. N= eeded + * when multiple regmap-IRQ controllers are created from same + * device. * * @main_status: Base main status register address. For chips which have * interrupts arranged in separate sub-irq blocks with own IRQ @@ -1606,6 +1609,7 @@ struct regmap_irq_chip_data; */ struct regmap_irq_chip { const char *name; + const char *domain_suffix; =20 unsigned int main_status; unsigned int num_main_status_bits; --=20 2.45.2 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --L07GlhcC5fAcYGs/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAma0u8wACgkQeFA3/03a ocWCVwgAws5IIkXc2W8Qd4bjOcO8Wc93xF5phcSkuhKo3er7w5PoujIDjOI8WPDf osyNmZDaGtUBtqlT6zj7V+x7cbrDpfD7OtMDHyDp7fhD/cSl2J/ClJuKijR1r17U +MJWo4Ge8Z4wZsj16qurgkI7pkgJJP5NN8BxCvPKS2L/DyrG1LZ5UIcTxfpeuMRB z05gmNFSRC7VKbQUdMMN39nmjCCPgf0RW7pAHeEnlGB1nElFeCszmTx841Y7bARo B5dIfaYIyxbFgB16s5sKBX7RltmzDvwDZzIxkmOrqY7EosVmpt2fHp+fdpNv7azB UyiEehNUCqAS0q3kaonqSQrU8o5bAA== =W7Rg -----END PGP SIGNATURE----- --L07GlhcC5fAcYGs/--