From patchwork Thu Feb 9 13:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84591C61DA4 for ; Thu, 9 Feb 2023 13:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YgedTCzN6+bdP89xzuF+Au/fbpRPGURs1eeSQBZkeoY=; b=IQ4z+LoqViqdxi SsUtgHy+DwH+3s1s4SbMtOc1fK64ZSWEYDzwwtJiepaq+txpxl1SYYWgKbTctNd+S5SNbxUfev7kt D5qDXSZLXciTQ2Y+79Av1WQ59QJbWceUpi8MtuFXhdTZtKFprq6rJ0+MYOGkYJJ8OaTXckPRK4ot9 AXVK7fFQkpdWlnybSTsWSMkoR2ZM6v2iooWE+4eRIcTaj8DBp8J9714wt3ZK8BK669eS20rhb2yNE 1FeHMGca5aznTwMezUzYukUs9mX3nJnXtV0Y3MTyUSRyz4VaK+penk/W+ZXnLc4gT86cDnux0MUns c9Hkhqug4WfGw9wCKWDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70z-001ghj-HK; Thu, 09 Feb 2023 13:31:05 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70f-001gOs-3x for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:48 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1384A61A7F; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8B9AC4339E; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949442; bh=tBqk6KgtGtAPTVEMAxcaZIoN23hQcgfod3xymk/Evn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TeA1pbonScrBm0NCQzRGyJ3tlpcXySd1ejnAVbqKqPBVM6OHV49cOLP+zJ3t1NVJs hPOpfXJALcAjzFWFzl5XoN3jLzWOeHgjyDhh/DpCM5cHGfP0IJLyhBjqysRzlSSHUP F6NXWivqhs8rjF414ZgK0MVZXftxG2VZcJ9vU1bNs/RzUSubGFMuut9Xbc5/r3SxEu VIWpTdySZPGv9lIoo9YIxtjFX7WrcgGQAZm3yKG+zQu0QwyQBJAjpJ4C+ktNYe9vPQ 0VFGEN3/aMfSOffu2VFHU+6YvE3hweyFIU1hfqR/2I7272YnF18U/W6znDwK6UN0TI 0Ejz3VTg42ojw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001Kh-4e; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 01/19] irqdomain: Fix association race Date: Thu, 9 Feb 2023 14:23:05 +0100 Message-Id: <20230209132323.4599-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053045_272802_84112D8B X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The sanity check for an already mapped virq is done outside of the irq_domain_mutex-protected section which means that an (unlikely) racing association may not be detected. Fix this by factoring out the association implementation, which will also be used in a follow-on change to fix a shared-interrupt mapping race. Fixes: ddaf144c61da ("irqdomain: Refactor irq_domain_associate_many()") Cc: stable@vger.kernel.org # 3.11 Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 798a9042421f..561689a3f050 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -559,8 +559,8 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) irq_domain_clear_mapping(domain, hwirq); } -int irq_domain_associate(struct irq_domain *domain, unsigned int virq, - irq_hw_number_t hwirq) +static int irq_domain_associate_locked(struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq) { struct irq_data *irq_data = irq_get_irq_data(virq); int ret; @@ -573,7 +573,6 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, if (WARN(irq_data->domain, "error: virq%i is already associated", virq)) return -EINVAL; - mutex_lock(&irq_domain_mutex); irq_data->hwirq = hwirq; irq_data->domain = domain; if (domain->ops->map) { @@ -590,7 +589,6 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, } irq_data->domain = NULL; irq_data->hwirq = 0; - mutex_unlock(&irq_domain_mutex); return ret; } @@ -601,12 +599,23 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, domain->mapcount++; irq_domain_set_mapping(domain, hwirq, irq_data); - mutex_unlock(&irq_domain_mutex); irq_clear_status_flags(virq, IRQ_NOREQUEST); return 0; } + +int irq_domain_associate(struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq) +{ + int ret; + + mutex_lock(&irq_domain_mutex); + ret = irq_domain_associate_locked(domain, virq, hwirq); + mutex_unlock(&irq_domain_mutex); + + return ret; +} EXPORT_SYMBOL_GPL(irq_domain_associate); void irq_domain_associate_many(struct irq_domain *domain, unsigned int irq_base, From patchwork Thu Feb 9 13:23:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F036EC61DA4 for ; Thu, 9 Feb 2023 13:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bt70xlfYz8+Fj7wXYyNAgXlZq/UWToYr7yh3B+YZigU=; b=zQKm1HnQui9UaC 92q0lvNUjQF/Vrvrqey4Ghq5FlK+7gfLT32PXZU6EWYlV/mRayRTlR7wzAeEjC4rVtxvAdyAS6ud4 i6h/Mz3Npe7hibxZ+lJ2HTANMGmEqIpD0Z13vj5hvqZ1HMNfKeVukGRP3JuQ6H615NvYpZMamTe2t kzS59672DMb0adibFv2KOb05XVEBwT8mWrJpeXjB5TABiQy6PXUeYunDTM8kusu2TMeaFSqmIm/7F M3qfnsH2lDiKbLyvTZx02Wwbz7XiWo7xxV+2mrhpZ5bRLfIqjtS9yOAmuj9UUx7ILD2Oack2g6xJw TqIMn79MoYhGbxWd0AcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70q-001gcb-9Y; Thu, 09 Feb 2023 13:30:56 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70e-001gOl-UE for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:47 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DD77F61A81; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2546C4339C; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949442; bh=JfSDAiRhoTMhnjXtvFRPr7fYgqO70+KfU+dj+kphkG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pdMs14cSNmFrPzA9kK8m+8Y4VUS/4pCWc/BTqJSikcy0h8q4w3abkl8S2QM4rVA6c yCXrrNF1MkYxPqpkXWjYt7bYmCEyv9qEgaK+EBkmWk/xRcn8/N5K8/lGopIIuOHkQZ Jhor4MahieHrw9hgJ287K9145a+lG49ueI7c7zkaPHFYT4W3b30pJG/HEpuJbyunCZ DlbiFr5Djvk/xRNr8E6hN+kijYgXRy1Xe2QgF08mEfHmjcD+eisbqjKvPbSvhB+r7v mYq9Cvubouid79vY5o0EW0bwtOk5maoDgHxzcE0A/M/oDcOfMiNEa5239cuxUyumX3 hcihvWk8wphfw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001Kj-7k; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 02/19] irqdomain: Fix disassociation race Date: Thu, 9 Feb 2023 14:23:06 +0100 Message-Id: <20230209132323.4599-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053045_049418_673E7888 X-CRM114-Status: GOOD ( 13.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The global irq_domain_mutex is held when mapping interrupts from non-hierarchical domains but currently not when disposing them. This specifically means that updates of the domain mapcount is racy (currently only used for statistics in debugfs). Make sure to hold the global irq_domain_mutex also when disposing mappings from non-hierarchical domains. Fixes: 9dc6be3d4193 ("genirq/irqdomain: Add map counter") Cc: stable@vger.kernel.org # 4.13 Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 561689a3f050..981cd636275e 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -538,6 +538,9 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) return; hwirq = irq_data->hwirq; + + mutex_lock(&irq_domain_mutex); + irq_set_status_flags(irq, IRQ_NOREQUEST); /* remove chip and handler */ @@ -557,6 +560,8 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) /* Clear reverse map for this hwirq */ irq_domain_clear_mapping(domain, hwirq); + + mutex_unlock(&irq_domain_mutex); } static int irq_domain_associate_locked(struct irq_domain *domain, unsigned int virq, From patchwork Thu Feb 9 13:23:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8A41C05027 for ; Thu, 9 Feb 2023 14:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cRmJKg7ucGpQyZGj/jyn+4V/K55s1/Cqiu8qIKgzoK0=; b=HPwAXIwlbBAnhY TZ2ardeqAByqADYWs3c1oAA40hDoXFhlKxrz2OueZ82l84yFMc0FKCQz8aTLszWvoHnGEEqHwANEy llEJ0Iqzutl7rdHjeKFgFFVlAEBWDMeRVE6x1zGeJf8Q5cRB7u8MOqAgoC3CDc0iSQFv5mImg4/2j vjtEPQgjrl+lae5QzZ2xmMk5INY1+6yOvQKricww1cTCtTCn9Szs7lro9EOnLyPdnmR9oxNwO5ehp 4C65tHOTIth1HJFjvfiCt79JhFv4cic2QsexXm2QCPr7W2lcgSrZVdnRr7koPFHO82bCZoYuY/yt8 N8dnBmq8sJ6wFYha3Fsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ8BE-0023B8-M1; Thu, 09 Feb 2023 14:45:44 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70e-001gOe-K4 for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:45 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4AD5761A44; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8A9C433EF; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949442; bh=m6miDDXDPE0i8gfLkqlExqia0yJKU93vQt0xdTn6QTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sa/KsdyjZtn4lNGlYVyABiISMRaa4wwQBRmFtr+M+MjPvP8y+PRzLXqo89kivIomd S/PCuMrHmTTouqFOVc51sYPzkBJAh1CO89W1KzQu+w33SmAmW0PJ0+aHDsv0d4PRIb POhLEV8bZceaHkWq1M1Jl1P1xV+UEelGyBJFWe3XIspLbOqyhP7frvAjajH46LDiPi ObKuQb4r08H88CaO5GAFSC4Tx9igwxJcaE6yhq/+OYeIJeDpy9ldfhIeNXvAa6zog6 X8cGet21q1o9Of7xfeIVLhj6vsJg4PDJcN77OFOI26NWCu/aM5WeY9WuYpi48SqMk3 V2Rq26Ho7O1Fg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001Kl-B0; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 03/19] irqdomain: Drop bogus fwspec-mapping error handling Date: Thu, 9 Feb 2023 14:23:07 +0100 Message-Id: <20230209132323.4599-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053044_740121_D1248D78 X-CRM114-Status: GOOD ( 12.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In case a newly allocated IRQ ever ends up not having any associated struct irq_data it would not even be possible to dispose the mapping. Replace the bogus disposal with a WARN_ON(). This will also be used to fix a shared-interrupt mapping race, hence the CC-stable tag. Fixes: 1e2a7d78499e ("irqdomain: Don't set type when mapping an IRQ") Cc: stable@vger.kernel.org # 4.8 Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 981cd636275e..b4326c364ae7 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -847,13 +847,8 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) } irq_data = irq_get_irq_data(virq); - if (!irq_data) { - if (irq_domain_is_hierarchy(domain)) - irq_domain_free_irqs(virq, 1); - else - irq_dispose_mapping(virq); + if (WARN_ON(!irq_data)) return 0; - } /* Store trigger type */ irqd_set_trigger_type(irq_data, type); From patchwork Thu Feb 9 13:23:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67B45C61DA4 for ; Thu, 9 Feb 2023 13:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BRol7OY9SJKT1i+/6fwiR0HiOD85YKXkkCmyQoU5GME=; b=pFyO/ag+oHRgNY 4LG5RUq2li/OoM1niYshdYYDkrmUeEzaubJXZNOzGg5PzhjAJDjg1erwKqco3jnAlBoQ6u1OhDP9T uclYCovwl15fVToPgxRmu2YB6nlPt9nIrZgehInqG7P1EN9HHePWd7TGAXOpKUaXHJpsYmP9uwkHo avvsV2DwMKzHW6Ia7PBXQ2PTHJYJlodr7i+L3LRbV1MbMkAKqLdsSbQ8191mvAcCdk6tEkPdS7Obd 4eVglx5HpWkn0lFcfSteoEIO2PoZjdD3+ABJJxC9mMEI5j7/zFT5uANl9jEOHznFfDBc1miKdmrPk x20Gh30pbG3skSlwYPmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ71y-001hDZ-Ar; Thu, 09 Feb 2023 13:32:06 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70g-001gQe-Gl for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:50 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A7C9561AA9; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA2F4C43445; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949442; bh=sXzV5Iaq24naECB8eaIVtLUk0+3eItKCLxiskY8fyFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vn3pVq4XnDvmnCBCEkblxubZpXRJ9z4jB3Xe3em9LxRpz9DAuH2buE0z6oRW1sfpa DfEbFxY2iUHNMW8mBBIAabzIWS0Ia/zPv15VwGlEeD10yMkrm8HVOlZechnk8oMkEa xu8ymYko/YXbtSdBlCJYU0ZsR9NjRNi3pO6apw0pPSjjNZjSsWcZLwsmzS5xrh1qpW B8Xab+iGcsPINYAK1F1K6VJ5a2VuVR8015Vf9E9lrm1iPPfnpXcGQ20jrRutoloqh0 JtN0Xpfl+MStmsit4SrvRRhht/CgJW0XxaSen0dUMe8D6s1ymuTOif9cOFF6YZDtNa 1I8jxK/JZaLfA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001Ko-ED; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 04/19] irqdomain: Look for existing mapping only once Date: Thu, 9 Feb 2023 14:23:08 +0100 Message-Id: <20230209132323.4599-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053046_721567_1506C6DB X-CRM114-Status: GOOD ( 17.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Avoid looking for an existing mapping twice when creating a new mapping using irq_create_fwspec_mapping() by factoring out the actual allocation which is shared with irq_create_mapping_affinity(). The new helper function will also be used to fix a shared-interrupt mapping race, hence the Fixes tag. Fixes: b62b2cf5759b ("irqdomain: Fix handling of type settings for existing mappings") Cc: stable@vger.kernel.org # 4.8 Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 60 +++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index b4326c364ae7..3d6a14efae62 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -682,6 +682,34 @@ unsigned int irq_create_direct_mapping(struct irq_domain *domain) EXPORT_SYMBOL_GPL(irq_create_direct_mapping); #endif +static unsigned int __irq_create_mapping_affinity(struct irq_domain *domain, + irq_hw_number_t hwirq, + const struct irq_affinity_desc *affinity) +{ + struct device_node *of_node = irq_domain_get_of_node(domain); + int virq; + + pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq); + + /* Allocate a virtual interrupt number */ + virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node), + affinity); + if (virq <= 0) { + pr_debug("-> virq allocation failed\n"); + return 0; + } + + if (irq_domain_associate(domain, virq, hwirq)) { + irq_free_desc(virq); + return 0; + } + + pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", + hwirq, of_node_full_name(of_node), virq); + + return virq; +} + /** * irq_create_mapping_affinity() - Map a hardware interrupt into linux irq space * @domain: domain owning this hardware interrupt or NULL for default domain @@ -694,14 +722,11 @@ EXPORT_SYMBOL_GPL(irq_create_direct_mapping); * on the number returned from that call. */ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, - irq_hw_number_t hwirq, - const struct irq_affinity_desc *affinity) + irq_hw_number_t hwirq, + const struct irq_affinity_desc *affinity) { - struct device_node *of_node; int virq; - pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq); - /* Look for default domain if necessary */ if (domain == NULL) domain = irq_default_domain; @@ -709,34 +734,15 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, WARN(1, "%s(, %lx) called with NULL domain\n", __func__, hwirq); return 0; } - pr_debug("-> using domain @%p\n", domain); - - of_node = irq_domain_get_of_node(domain); /* Check if mapping already exists */ virq = irq_find_mapping(domain, hwirq); if (virq) { - pr_debug("-> existing mapping on virq %d\n", virq); + pr_debug("existing mapping on virq %d\n", virq); return virq; } - /* Allocate a virtual interrupt number */ - virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node), - affinity); - if (virq <= 0) { - pr_debug("-> virq allocation failed\n"); - return 0; - } - - if (irq_domain_associate(domain, virq, hwirq)) { - irq_free_desc(virq); - return 0; - } - - pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", - hwirq, of_node_full_name(of_node), virq); - - return virq; + return __irq_create_mapping_affinity(domain, hwirq, affinity); } EXPORT_SYMBOL_GPL(irq_create_mapping_affinity); @@ -841,7 +847,7 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) return 0; } else { /* Create mapping */ - virq = irq_create_mapping(domain, hwirq); + virq = __irq_create_mapping_affinity(domain, hwirq, NULL); if (!virq) return virq; } From patchwork Thu Feb 9 13:23:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D21AC61DA4 for ; Thu, 9 Feb 2023 13:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dUFk2zQzieO6XaJ1IzSgdQR08szoBNINK+QRE8edFvg=; b=i4Y1A1mD196riI 3F01YUL3M3sDG6HvRry/xVIddxN/O/5Q3KESHaZk+/u/03K5d51wD7EC85mlPlnOVTRvWsYRLpIvg pWhSAEosNd1eDz724CcFYCw1wRqbsekfMnrX0AxlpFdT7cL/1HESOLdkYjqfvqCLmcfrnZmM3kAdT VGGb4qBoqsZXa6DECwXMJ4Q1ealpb5Q7sMxFI5iOPFvFgAt1KnBAehOQQAkjgKjGkaRfGJuCyR/0d 2hbVjNnlqM7tbpy39CXOJMBPzCLmAf/KFuUcUq27v/OkAap2RMEzi6f5r2oR+8wIfoBolT+xbFhXo pB+inNES5I8NTV0+mSOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ718-001gmH-Iw; Thu, 09 Feb 2023 13:31:14 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70e-001gOz-Na for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:48 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 46AC761A8E; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9AE1C43444; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949442; bh=clVu7cbCZQuWFAo+ktM63h/7vhzeIYuPjrlK28Oxe1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z2LJ0U80DYRmMQXaQwA3/hkYeCb4mnqhbSI/By28AYQcAYBDcImK1LsUA5UoijJ2X s9xjTcGQxrcGwLxOYmC+8OkPDEKDd4Nr4icStwH/hGj8kMyKy9Qq1GJrWn7EUNzemt b/csjHUvlAttKtjzaMWJv1wfpTcBKJQm1An3X7roqcf+Jg2yrkuV7AjG9HD6Tpv8JY HaTahCw5rbasawXYXJuZ3NqdlM/ivvCQQm+xxZeGnS17yNBoild0oY+wfBVWs5OXsi nKFxt9vI9kkmBzkJhiaPKyBXrLT02K6xRlNqeNqsucH/R0tt/VfC6ZLXeSBt2mWc8Q Rpm2h6NGXG0dw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001Kr-HG; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 05/19] irqdomain: Refactor __irq_domain_alloc_irqs() Date: Thu, 9 Feb 2023 14:23:09 +0100 Message-Id: <20230209132323.4599-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053044_869200_08B53D13 X-CRM114-Status: GOOD ( 21.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Refactor __irq_domain_alloc_irqs() so that it can be called internally while holding the irq_domain_mutex. This will be used to fix a shared-interrupt mapping race, hence the Fixes tag. Fixes: b62b2cf5759b ("irqdomain: Fix handling of type settings for existing mappings") Cc: stable@vger.kernel.org # 4.8 Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 88 +++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 3d6a14efae62..7b57949bc79c 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1441,40 +1441,12 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain, return domain->ops->alloc(domain, irq_base, nr_irqs, arg); } -/** - * __irq_domain_alloc_irqs - Allocate IRQs from domain - * @domain: domain to allocate from - * @irq_base: allocate specified IRQ number if irq_base >= 0 - * @nr_irqs: number of IRQs to allocate - * @node: NUMA node id for memory allocation - * @arg: domain specific argument - * @realloc: IRQ descriptors have already been allocated if true - * @affinity: Optional irq affinity mask for multiqueue devices - * - * Allocate IRQ numbers and initialized all data structures to support - * hierarchy IRQ domains. - * Parameter @realloc is mainly to support legacy IRQs. - * Returns error code or allocated IRQ number - * - * The whole process to setup an IRQ has been split into two steps. - * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ - * descriptor and required hardware resources. The second step, - * irq_domain_activate_irq(), is to program the hardware with preallocated - * resources. In this way, it's easier to rollback when failing to - * allocate resources. - */ -int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, - unsigned int nr_irqs, int node, void *arg, - bool realloc, const struct irq_affinity_desc *affinity) +static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base, + unsigned int nr_irqs, int node, void *arg, + bool realloc, const struct irq_affinity_desc *affinity) { int i, ret, virq; - if (domain == NULL) { - domain = irq_default_domain; - if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n")) - return -EINVAL; - } - if (realloc && irq_base >= 0) { virq = irq_base; } else { @@ -1493,24 +1465,18 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, goto out_free_desc; } - mutex_lock(&irq_domain_mutex); ret = irq_domain_alloc_irqs_hierarchy(domain, virq, nr_irqs, arg); - if (ret < 0) { - mutex_unlock(&irq_domain_mutex); + if (ret < 0) goto out_free_irq_data; - } for (i = 0; i < nr_irqs; i++) { ret = irq_domain_trim_hierarchy(virq + i); - if (ret) { - mutex_unlock(&irq_domain_mutex); + if (ret) goto out_free_irq_data; - } } - + for (i = 0; i < nr_irqs; i++) irq_domain_insert_irq(virq + i); - mutex_unlock(&irq_domain_mutex); return virq; @@ -1520,6 +1486,48 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, irq_free_descs(virq, nr_irqs); return ret; } + +/** + * __irq_domain_alloc_irqs - Allocate IRQs from domain + * @domain: domain to allocate from + * @irq_base: allocate specified IRQ number if irq_base >= 0 + * @nr_irqs: number of IRQs to allocate + * @node: NUMA node id for memory allocation + * @arg: domain specific argument + * @realloc: IRQ descriptors have already been allocated if true + * @affinity: Optional irq affinity mask for multiqueue devices + * + * Allocate IRQ numbers and initialized all data structures to support + * hierarchy IRQ domains. + * Parameter @realloc is mainly to support legacy IRQs. + * Returns error code or allocated IRQ number + * + * The whole process to setup an IRQ has been split into two steps. + * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ + * descriptor and required hardware resources. The second step, + * irq_domain_activate_irq(), is to program the hardware with preallocated + * resources. In this way, it's easier to rollback when failing to + * allocate resources. + */ +int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, + unsigned int nr_irqs, int node, void *arg, + bool realloc, const struct irq_affinity_desc *affinity) +{ + int ret; + + if (domain == NULL) { + domain = irq_default_domain; + if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n")) + return -EINVAL; + } + + mutex_lock(&irq_domain_mutex); + ret = irq_domain_alloc_irqs_locked(domain, irq_base, nr_irqs, node, arg, + realloc, affinity); + mutex_unlock(&irq_domain_mutex); + + return ret; +} EXPORT_SYMBOL_GPL(__irq_domain_alloc_irqs); /* The irq_data was moved, fix the revmap to refer to the new location */ From patchwork Thu Feb 9 13:23:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9646C05027 for ; Thu, 9 Feb 2023 13:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6CX4ips0+JJuCcbD58MYBh6MXdzla33CSJPCd88rNbQ=; b=xavDrnR3IKygaG Be6oGdvOwjTXcaSrSxTzsiWPDmaUE3ICcWkLOXdnkPghw0D2EBp18hxAxBQ/FqvRLQYluFbewz6w7 Pa9INAjkkMQCV/ZC8O7rT3dhwrEq6SB8d+3XwtBdph1Km5T2IvqkudIKt+PaHCPMukiS+DWORtapj n2F+wcDWQo7+udBm82W4KTicr7J2B3/TQV3kARZHSrOrFopmG/ymWNhOjq6NmGA6RPwKMC7lUugBk 37TS59DYgVo+FAg9K64zBz17T0+LDgyyWAx+6PAqcHwuhGocHARSmyVg5r5RsgIx0PBzU3/Qaf88i YMZjr5lJCGX3TLqPw+0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ72C-001hMX-Jd; Thu, 09 Feb 2023 13:32:20 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70g-001gQF-UB for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:52 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5A17DB8213C; Thu, 9 Feb 2023 13:30:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAA16C433A0; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949442; bh=h4azw0h+p0/3FwXAfVTjxt6QeHm6JO0pJ7MH+PTlBRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gKWwTMRASF452A8hioci3KBXFekrupiV5KbcAzz+RwL6OrFU1ByyEAfbo3+kIirbf q8w2nxWvv02ndA2JyCALxcUbdmUgndvh8S1CBoFcHDI1U9YyDQZf9yyfK/9J4zuqsr +E7PLPQcTCORefQyzNoWM1OV6zVt6HQb9rRNT+UAA/zD+QJXgxZfyVQLVB0bmylNBq VmrhyBwyvS+UaFrA2/1wBmTD+nimAKzgPyfqGQP4x5avyitX4qdpL9BhiDakVF9EFb 6LN48Z/h06b38YaRQb/1+te+1LZbnlo1ikpD9zgFpfHHVn1UXaQh6RncJ644BTMYFL yYEFQ7AXahhZw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001Ku-Jm; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Dmitry Torokhov , Jon Hunter , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 06/19] irqdomain: Fix mapping-creation race Date: Thu, 9 Feb 2023 14:23:10 +0100 Message-Id: <20230209132323.4599-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053047_282697_897EC7B1 X-CRM114-Status: GOOD ( 20.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Parallel probing of devices that share interrupts (e.g. when a driver uses asynchronous probing) can currently result in two mappings for the same hardware interrupt to be created due to missing serialisation. Make sure to hold the irq_domain_mutex when creating mappings so that looking for an existing mapping before creating a new one is done atomically. Fixes: 765230b5f084 ("driver-core: add asynchronous probing support for drivers") Fixes: b62b2cf5759b ("irqdomain: Fix handling of type settings for existing mappings") Link: https://lore.kernel.org/r/YuJXMHoT4ijUxnRb@hovoldconsulting.com Cc: stable@vger.kernel.org # 4.8 Cc: Dmitry Torokhov Cc: Jon Hunter Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 55 ++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 7b57949bc79c..1ddb01bd49a4 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -25,6 +25,9 @@ static DEFINE_MUTEX(irq_domain_mutex); static struct irq_domain *irq_default_domain; +static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base, + unsigned int nr_irqs, int node, void *arg, + bool realloc, const struct irq_affinity_desc *affinity); static void irq_domain_check_hierarchy(struct irq_domain *domain); struct irqchip_fwid { @@ -682,9 +685,9 @@ unsigned int irq_create_direct_mapping(struct irq_domain *domain) EXPORT_SYMBOL_GPL(irq_create_direct_mapping); #endif -static unsigned int __irq_create_mapping_affinity(struct irq_domain *domain, - irq_hw_number_t hwirq, - const struct irq_affinity_desc *affinity) +static unsigned int irq_create_mapping_affinity_locked(struct irq_domain *domain, + irq_hw_number_t hwirq, + const struct irq_affinity_desc *affinity) { struct device_node *of_node = irq_domain_get_of_node(domain); int virq; @@ -699,7 +702,7 @@ static unsigned int __irq_create_mapping_affinity(struct irq_domain *domain, return 0; } - if (irq_domain_associate(domain, virq, hwirq)) { + if (irq_domain_associate_locked(domain, virq, hwirq)) { irq_free_desc(virq); return 0; } @@ -735,14 +738,20 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, return 0; } + mutex_lock(&irq_domain_mutex); + /* Check if mapping already exists */ virq = irq_find_mapping(domain, hwirq); if (virq) { pr_debug("existing mapping on virq %d\n", virq); - return virq; + goto out; } - return __irq_create_mapping_affinity(domain, hwirq, affinity); + virq = irq_create_mapping_affinity_locked(domain, hwirq, affinity); +out: + mutex_unlock(&irq_domain_mutex); + + return virq; } EXPORT_SYMBOL_GPL(irq_create_mapping_affinity); @@ -809,6 +818,8 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) if (WARN_ON(type & ~IRQ_TYPE_SENSE_MASK)) type &= IRQ_TYPE_SENSE_MASK; + mutex_lock(&irq_domain_mutex); + /* * If we've already configured this interrupt, * don't do it again, or hell will break loose. @@ -821,7 +832,7 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) * interrupt number. */ if (type == IRQ_TYPE_NONE || type == irq_get_trigger_type(virq)) - return virq; + goto out; /* * If the trigger type has not been set yet, then set @@ -830,36 +841,43 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) if (irq_get_trigger_type(virq) == IRQ_TYPE_NONE) { irq_data = irq_get_irq_data(virq); if (!irq_data) - return 0; + goto err; irqd_set_trigger_type(irq_data, type); - return virq; + goto out; } pr_warn("type mismatch, failed to map hwirq-%lu for %s!\n", hwirq, of_node_full_name(to_of_node(fwspec->fwnode))); - return 0; + goto err; } if (irq_domain_is_hierarchy(domain)) { - virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec); + virq = irq_domain_alloc_irqs_locked(domain, -1, 1, NUMA_NO_NODE, + fwspec, false, NULL); if (virq <= 0) - return 0; + goto err; } else { /* Create mapping */ - virq = __irq_create_mapping_affinity(domain, hwirq, NULL); + virq = irq_create_mapping_affinity_locked(domain, hwirq, NULL); if (!virq) - return virq; + goto err; } irq_data = irq_get_irq_data(virq); if (WARN_ON(!irq_data)) - return 0; + goto err; /* Store trigger type */ irqd_set_trigger_type(irq_data, type); +out: + mutex_unlock(&irq_domain_mutex); return virq; +err: + mutex_unlock(&irq_domain_mutex); + + return 0; } EXPORT_SYMBOL_GPL(irq_create_fwspec_mapping); @@ -1888,6 +1906,13 @@ void irq_domain_set_info(struct irq_domain *domain, unsigned int virq, irq_set_handler_data(virq, handler_data); } +static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base, + unsigned int nr_irqs, int node, void *arg, + bool realloc, const struct irq_affinity_desc *affinity) +{ + return -EINVAL; +} + static void irq_domain_check_hierarchy(struct irq_domain *domain) { } From patchwork Thu Feb 9 13:23:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AD42C05027 for ; Thu, 9 Feb 2023 13:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WpSUupKpdTUgxMJB4d5FaUIKkciiexbuQ2OvmRRUTH4=; b=HgBNtkMJWvYIrI j/se7Aff1/YDK3DHmJ6QzOmVyfr+/d+ziN2Tkky1cfK6teEYbiYMPThGUcK1kVslkdl/G4ZyTqnfc GEMuxXMLS2yHdD9GLA89uMJmysrzdC4fj6fYOs0rYVZQf9ZUKTTMRQLYs5oVwI96969MMLUQIaQvh lkhsSVenhxoYJk6tWylYdGwHpr2j0IPVgrSRTyLDKenvOv1iUvCglEf2FIrJqMeNmTxBAVzkGt7zu QZdgn8u13BPFtJ0kKPCxFZEeDLvDkbu8xDXHElkeHvQFrUakvfbRnb0tAkcuAO5dvxvBX2EO5KxcO IXvunKG0vNFGDgx1udSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ71o-001h85-60; Thu, 09 Feb 2023 13:31:56 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70g-001gQS-9i for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:50 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7669A61A9C; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4B7CC43446; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949442; bh=1omwMXr5rbtQWdp8BwOcP53noCmvTYOu9/pt2qjgFaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N12jf362mW0Ol9URwk+ZMhCXNPbxHT2oFIuuhM3TSrk1KDIGD9RHWXkeCVJd5wSSZ cxlT44m7yQCRmdtHq+y1P7OnMH8s86ldG/oR8d2RAjjYqJtWjW3fCQwjiv2hZnfwV4 cHQeM18DMB84VzgfgVT/NkVtudvCF1Nfur7XELTvWqyM7JpmbD6inOWxTWFc4/tRbH PSl5xtA/3Bwj5Gc/FLWlbzXdptocGp0PCBdknH4k1ho6jUwzf90bkq6k/Ui8coNSIY rIDtO/4jjHjADswt5X+2IDWvuY2f0af+Nth6Y3TR1T8EUcGzCUYoU0F763DIyXvXsq Y1XCUcKEzVsbQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001Kx-N0; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 07/19] irqdomain: Drop revmap mutex Date: Thu, 9 Feb 2023 14:23:11 +0100 Message-Id: <20230209132323.4599-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053046_456040_5C394D52 X-CRM114-Status: GOOD ( 15.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The revmap mutex is essentially only used to maintain the integrity of the radix tree during updates (lookups use RCU). As the global irq_domain_mutex is now held in all paths that update the revmap structures there is strictly no longer any need for the dedicated mutex, which can be removed. Drop the revmap mutex and add lockdep assertions to the revmap helpers to make sure that the global lock is always held when updating the revmap. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- include/linux/irqdomain.h | 2 -- kernel/irq/irqdomain.c | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index a372086750ca..16399de00b48 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -143,7 +143,6 @@ struct irq_domain_chip_generic; * Revmap data, used internally by the irq domain code: * @revmap_size: Size of the linear map table @revmap[] * @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map - * @revmap_mutex: Lock for the revmap * @revmap: Linear table of irq_data pointers */ struct irq_domain { @@ -171,7 +170,6 @@ struct irq_domain { irq_hw_number_t hwirq_max; unsigned int revmap_size; struct radix_tree_root revmap_tree; - struct mutex revmap_mutex; struct irq_data __rcu *revmap[]; }; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 1ddb01bd49a4..28d74549414b 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -217,7 +217,6 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s /* Fill structure */ INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); - mutex_init(&domain->revmap_mutex); domain->ops = ops; domain->host_data = host_data; domain->hwirq_max = hwirq_max; @@ -505,30 +504,30 @@ static bool irq_domain_is_nomap(struct irq_domain *domain) static void irq_domain_clear_mapping(struct irq_domain *domain, irq_hw_number_t hwirq) { + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(domain)) return; - mutex_lock(&domain->revmap_mutex); if (hwirq < domain->revmap_size) rcu_assign_pointer(domain->revmap[hwirq], NULL); else radix_tree_delete(&domain->revmap_tree, hwirq); - mutex_unlock(&domain->revmap_mutex); } static void irq_domain_set_mapping(struct irq_domain *domain, irq_hw_number_t hwirq, struct irq_data *irq_data) { + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(domain)) return; - mutex_lock(&domain->revmap_mutex); if (hwirq < domain->revmap_size) rcu_assign_pointer(domain->revmap[hwirq], irq_data); else radix_tree_insert(&domain->revmap_tree, hwirq, irq_data); - mutex_unlock(&domain->revmap_mutex); } static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) @@ -1553,11 +1552,12 @@ static void irq_domain_fix_revmap(struct irq_data *d) { void __rcu **slot; + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(d->domain)) return; /* Fix up the revmap. */ - mutex_lock(&d->domain->revmap_mutex); if (d->hwirq < d->domain->revmap_size) { /* Not using radix tree */ rcu_assign_pointer(d->domain->revmap[d->hwirq], d); @@ -1566,7 +1566,6 @@ static void irq_domain_fix_revmap(struct irq_data *d) if (slot) radix_tree_replace_slot(&d->domain->revmap_tree, slot, d); } - mutex_unlock(&d->domain->revmap_mutex); } /** From patchwork Thu Feb 9 13:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 564CBC05027 for ; Thu, 9 Feb 2023 13:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ki0sMn/7FIppdEsP6YAJHM0fCUYNRj4Ru0ckCoxD5gk=; b=Lg/sa6gnaI18Gw ioC/Eljl+Zie0ttv5LgC9F+nYiwpTbm1ow5SngO13EhPLSwozrp+wxI/EAEz7lZ05uI0WPmvDDsx3 Srz9QdaPh8s1VatTnCFo+siUizh00f2vsdnmppVATW0li3EyGi/2+oP1Jbe3tX7qMV0ob92OYm4wm sCtsNWriG+/SbSIyowCw1vqS+yMxE+K1eD96kBPYRAfJOOy8EvIJdoytyRu/0vAZ06NlbFCldu0bg Cb2SINN2UtbMVpu5aldmIa/QBC01Ac1JDCy6ntkH/43MCuYSL8mACCf1/jmu7SE+c3XAkjgJl7Eqe yJ9em7MA6CqUthi364Rw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ71M-001gtf-Dk; Thu, 09 Feb 2023 13:31:28 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70g-001gQR-9Q for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:48 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4D77F61A91; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF381C43443; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949442; bh=/tiungLfitFlSrlnkn8ELqW8HMOoeWc08EIHOdGt7VA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNUJPPGiLLrkXQ7Lc7KLWcNPIwf6YxkF+AjzZksfbfktoP2qeVtUh6bdWj/JsgCGk IuMGLGxWE+YmDJzztXFF1K/jXBzj2fLnoJBl372+kNML0FeheTA/twBYfynl+UW31m y5uKw2SQPdKBYGv+Z3ZjuW0abhbEJHXbZEmNA4m4O7mkCR1TXzf/TLnNRwVmYI3n9E mmLwPPGfUYX5ZiM72NuqXoUW9OuuVj11EskLUvkGL4czFr4MqAsOdt8ZXzAlJvqTHp uvAQ8EHFwT9Fch1BwQYUz0I8zdzppnGTQxV4hRfAve+gpepM7V6OCBAOzgn79dj4X1 cHA9F7W2qCLXw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001L0-Pm; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 08/19] irqdomain: Drop dead domain-name assignment Date: Thu, 9 Feb 2023 14:23:12 +0100 Message-Id: <20230209132323.4599-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053046_421310_D4F9AA35 X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since commit d59f6617eef0 ("genirq: Allow fwnode to carry name information only") an IRQ domain is always given a name during allocation (e.g. used for the debugfs entry). Drop the leftover name assignment when allocating the first IRQ. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 28d74549414b..3d635b8bb465 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -598,10 +598,6 @@ static int irq_domain_associate_locked(struct irq_domain *domain, unsigned int v irq_data->hwirq = 0; return ret; } - - /* If not already assigned, give the domain the chip's name */ - if (!domain->name && irq_data->chip) - domain->name = irq_data->chip->name; } domain->mapcount++; @@ -1155,10 +1151,6 @@ static void irq_domain_insert_irq(int virq) domain->mapcount++; irq_domain_set_mapping(domain, data->hwirq, data); - - /* If not already assigned, give the domain the chip's name */ - if (!domain->name && data->chip) - domain->name = data->chip->name; } irq_clear_status_flags(virq, IRQ_NOREQUEST); From patchwork Thu Feb 9 13:23:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4335CC61DA4 for ; Thu, 9 Feb 2023 13:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oe6dwOqV11XizZBwVPWlokeMfUlNjbSRC2fWj91JhmU=; b=Nj6ggSfxag13bx RgXqHq8J3EnRMQR9DJmYdpiwOgyAj7mQbrkbGuCPn7UQB/HnmM+Le99guXqnXH8poaUD5VFvH7Akq 2LCxTSY3Zy22ujieB+ZvejxA9j9DHLAbpizR7I+bs4CyMiTlBTrMPcRi+7luXUkYaP4q5+XPsxSYW k7FbypcshpevDdroSb78MDoDXiyIM0A3m/gHTeTyWGYZRXuI0Ye26nqV/xlYs+QszHdIFs/3wIewW fuTZM/5r9JK1ecHvQt8I20yCUqOoZ3tGnCKqGP9oFvA63ft+KRuoKDq3INN8B8926uKVFGou1HMzH hJduKB1FTw2jP78NLFLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ71e-001h2S-Dl; Thu, 09 Feb 2023 13:31:46 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70g-001gQd-GW for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:50 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A127561AA0; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA64FC4331E; Thu, 9 Feb 2023 13:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=B2RPnBJRsHoCKuF0sSxZmpky7dK6bQqySe9k7JgSzc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=izkiq/wiSL2iN7Y5//bt5KpdMPFqD8GyC3PntX7820fd2ChrKFcp0S3qB+QHyWrUB cENZv3hPIOVBhhQCYvGXcIJWM5zKpX2deERHjg+UqvUvYcu4PLmjuwBZFdhzPARx/C AEHDnp22Ef3GNGDgnb05pkIvTU0/s075IKfgKYozlUf4Raxzp5E7x2y5M28gaD3JgB hsSN7A15xWCjDIm1tq4GPAPxKvXhktXsN8HqOIcJa+LBii3Uc1HgfrBgNLXNVFta6e hdLAngCcV6+cWU+1Rl/9wu5zNBvupahpZL23NUCX59CkBJp1baYROf1PNqFIFYdO5u my7XM0BBsYmbg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001L5-SK; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 09/19] irqdomain: Drop leftover brackets Date: Thu, 9 Feb 2023 14:23:13 +0100 Message-Id: <20230209132323.4599-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053046_677005_1BF9887E X-CRM114-Status: GOOD ( 13.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Drop some unnecessary brackets that were left in place when the corresponding code was updated. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 3d635b8bb465..a1c6e01b395e 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -221,9 +221,8 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s domain->host_data = host_data; domain->hwirq_max = hwirq_max; - if (direct_max) { + if (direct_max) domain->flags |= IRQ_DOMAIN_FLAG_NO_MAP; - } domain->revmap_size = size; @@ -631,9 +630,8 @@ void irq_domain_associate_many(struct irq_domain *domain, unsigned int irq_base, pr_debug("%s(%s, irqbase=%i, hwbase=%i, count=%i)\n", __func__, of_node_full_name(of_node), irq_base, (int)hwirq_base, count); - for (i = 0; i < count; i++) { + for (i = 0; i < count; i++) irq_domain_associate(domain, irq_base + i, hwirq_base + i); - } } EXPORT_SYMBOL_GPL(irq_domain_associate_many); From patchwork Thu Feb 9 13:23:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6A399C05027 for ; Thu, 9 Feb 2023 13:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ddvALOQkQ9zDzmOohKc3h7T8zQ/EhBNURTaSuJYVXck=; b=EiMw4dsD2zChRX ZCtK+Cg1YaAJn7zXX5nUa3l1F1Lo4B2afjvO4fM4mvsE7knxtu47R9EkWIE2gNt8tHGvUq+ImDcWC hPW8mQQPPDLABgPb9ik8H6Z0geFMz0orujlR72sL2TLRkRprHt0IvfBIA2VprJmcxQYDDhtbIYfmn T1VNqtXbIHiOSybYvMFSqGv9q5O1nbyNTVe5eaX3o8U63TrEzv8SeV2m1DlY/tZx/Jh4aGKrRHF+Z Fdpk6jtrKvp/7d+7QabEQvCNuGB/rT/EBaeUUz03rDOnREKxTnSn1kk6jeOOL9VseeDq96qkttKqs NVnNa8HT49dft9yH8kEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ73X-001iAe-VJ; Thu, 09 Feb 2023 13:33:44 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70i-001gTp-Dq for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:54 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ABF6661AA3; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DA5AC43335; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=icdD0oWFhuqEZPe3gw5UIs0Haoy0s/gzVx8NhI+aF/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CMIxVlgD0oK4YLxtOUZXM+2SCNRAM5LyhzGpegT3ZIaEgLDeC80s1NUtW2VsMCF9A XX6o4bV7ej76HO5QSFFMm/QXSzehtQJYNrvQuk3ygjMnp2+jSUIDgHWFamM6N0ei4D 28Hr83OWltvUSwulKWbw6R8WAaxuMtcFt7D3VTRbe2VLQSW3VGG1KPKG2vJKaOJzJW +e3Cfq/P7GjUo4Uh+zoU0QhPGTcJyNDD4B2JvNZ6O7KDAK0A/2/5elffd/IlrfQqjk FEKVO/on54UrAOy8FTXWUTv4B3zLN4tLDynsdCiS5shKU8kqy/JKCiVo5gPQTooZjn USe8nTvGGuC1w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71G-0001L7-Uq; Thu, 09 Feb 2023 14:31:22 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 10/19] irqdomain: Clean up irq_domain_push/pop_irq() Date: Thu, 9 Feb 2023 14:23:14 +0100 Message-Id: <20230209132323.4599-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053048_647908_2FA004EA X-CRM114-Status: GOOD ( 20.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The irq_domain_push_irq() interface is used to add a new (outmost) level to a hierarchical domain after IRQs have been allocated. Possibly due to differing mental images of hierarchical domains, the names used for the irq_data variables make these functions much harder to understand than what they need to be. Rename the struct irq_data pointer to the data embedded in the descriptor as simply 'irq_data' and refer to the data allocated by this interface as 'parent_irq_data' so that the names reflect how hierarchical domains are implemented. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 65 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index a1c6e01b395e..804d316329c8 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1571,8 +1571,8 @@ static void irq_domain_fix_revmap(struct irq_data *d) */ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) { - struct irq_data *child_irq_data; - struct irq_data *root_irq_data = irq_get_irq_data(virq); + struct irq_data *irq_data = irq_get_irq_data(virq); + struct irq_data *parent_irq_data; struct irq_desc *desc; int rv = 0; @@ -1597,45 +1597,44 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) if (WARN_ON(!irq_domain_is_hierarchy(domain))) return -EINVAL; - if (!root_irq_data) + if (!irq_data) return -EINVAL; - if (domain->parent != root_irq_data->domain) + if (domain->parent != irq_data->domain) return -EINVAL; - child_irq_data = kzalloc_node(sizeof(*child_irq_data), GFP_KERNEL, - irq_data_get_node(root_irq_data)); - if (!child_irq_data) + parent_irq_data = kzalloc_node(sizeof(*parent_irq_data), GFP_KERNEL, + irq_data_get_node(irq_data)); + if (!parent_irq_data) return -ENOMEM; mutex_lock(&irq_domain_mutex); /* Copy the original irq_data. */ - *child_irq_data = *root_irq_data; + *parent_irq_data = *irq_data; /* - * Overwrite the root_irq_data, which is embedded in struct - * irq_desc, with values for this domain. + * Overwrite the irq_data, which is embedded in struct irq_desc, with + * values for this domain. */ - root_irq_data->parent_data = child_irq_data; - root_irq_data->domain = domain; - root_irq_data->mask = 0; - root_irq_data->hwirq = 0; - root_irq_data->chip = NULL; - root_irq_data->chip_data = NULL; + irq_data->parent_data = parent_irq_data; + irq_data->domain = domain; + irq_data->mask = 0; + irq_data->hwirq = 0; + irq_data->chip = NULL; + irq_data->chip_data = NULL; /* May (probably does) set hwirq, chip, etc. */ rv = irq_domain_alloc_irqs_hierarchy(domain, virq, 1, arg); if (rv) { /* Restore the original irq_data. */ - *root_irq_data = *child_irq_data; - kfree(child_irq_data); + *irq_data = *parent_irq_data; + kfree(parent_irq_data); goto error; } - irq_domain_fix_revmap(child_irq_data); - irq_domain_set_mapping(domain, root_irq_data->hwirq, root_irq_data); - + irq_domain_fix_revmap(parent_irq_data); + irq_domain_set_mapping(domain, irq_data->hwirq, irq_data); error: mutex_unlock(&irq_domain_mutex); @@ -1653,8 +1652,8 @@ EXPORT_SYMBOL_GPL(irq_domain_push_irq); */ int irq_domain_pop_irq(struct irq_domain *domain, int virq) { - struct irq_data *root_irq_data = irq_get_irq_data(virq); - struct irq_data *child_irq_data; + struct irq_data *irq_data = irq_get_irq_data(virq); + struct irq_data *parent_irq_data; struct irq_data *tmp_irq_data; struct irq_desc *desc; @@ -1676,37 +1675,37 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq) if (domain == NULL) return -EINVAL; - if (!root_irq_data) + if (!irq_data) return -EINVAL; tmp_irq_data = irq_domain_get_irq_data(domain, virq); /* We can only "pop" if this domain is at the top of the list */ - if (WARN_ON(root_irq_data != tmp_irq_data)) + if (WARN_ON(irq_data != tmp_irq_data)) return -EINVAL; - if (WARN_ON(root_irq_data->domain != domain)) + if (WARN_ON(irq_data->domain != domain)) return -EINVAL; - child_irq_data = root_irq_data->parent_data; - if (WARN_ON(!child_irq_data)) + parent_irq_data = irq_data->parent_data; + if (WARN_ON(!parent_irq_data)) return -EINVAL; mutex_lock(&irq_domain_mutex); - root_irq_data->parent_data = NULL; + irq_data->parent_data = NULL; - irq_domain_clear_mapping(domain, root_irq_data->hwirq); + irq_domain_clear_mapping(domain, irq_data->hwirq); irq_domain_free_irqs_hierarchy(domain, virq, 1); /* Restore the original irq_data. */ - *root_irq_data = *child_irq_data; + *irq_data = *parent_irq_data; - irq_domain_fix_revmap(root_irq_data); + irq_domain_fix_revmap(irq_data); mutex_unlock(&irq_domain_mutex); - kfree(child_irq_data); + kfree(parent_irq_data); return 0; } From patchwork Thu Feb 9 13:23:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 042E2C61DA4 for ; Thu, 9 Feb 2023 13:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DOzN3iiuESeoVvR/IODOMcI8NwDZlLVWBaGd0fKu4/I=; b=C04LaUq1Xnt3eI Yn+/3/Ihn1DdGwEVgeC0FeKKk3wH947iv8uDdwX/P3JGqInA0CbNyNYyA+Fht7vjiwXqPn8smDx5S DSfRuIbF7B0vMzW9VcwkpAhBbKUDdjctzX6mi0Zq1E4ipjWN98Nph0vqNcZTDzmLVeRhVvokxKAtY 6D1qcecIrbmSXS1GaLzF5DVVpRb6r7eGPDruVvGlvPl969dl4LFVhr0CexKb/NpWlpi4dp0KKfJf8 IIvWrAQzivIJF+ioqnKvPCF7Q+L/zRdRn/H6Al6aZwkF3UwaWEZ8MkjafgG4h492eHqctWCZP5Tzw nWemlq3TTCLSTZA2aBlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ72k-001hi2-O1; Thu, 09 Feb 2023 13:32:54 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70i-001gTo-EP for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:53 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D0E4361AB8; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31565C43332; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=roctf62/yqPkgEsUS/nfvm5p+4sye80U1pGQ8NLWzxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rmddM9Bec50HJdvHPsikbn+VL66sOvFS3Y7PdxEa5PwYBSpIjD/rMPNUfJoec5Txs 7DTh7B25elM3nJThoOtAl0FMctQ50vN2VMVjv6uqTGtPMOU9/fqmxWxuSoCNHe/VhH 8uwHpZEqNAzt1S2vC9qHV0D1f6Td3M6dstLRKF6LH1/SHq1KXZIlsnwpLYEe/15KJt Kr7Qp3deRu6eCtGzyMJT9PfKn9h7Fa4uZVn1WOmOvtxOd3gTwt9Sq8tuIbA5mSzYU0 9Iod3wwOZJCH2RPQIapkKFGcauYmmm4zxjp/ZKBE+EV2b1CKEJpJ6V1cOQiFGALyMe wwyVr+bE2ZT0w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001LI-1q; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 11/19] x86/ioapic: Use irq_domain_create_hierarchy() Date: Thu, 9 Feb 2023 14:23:15 +0100 Message-Id: <20230209132323.4599-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053048_592868_B4FBE1EF X-CRM114-Status: GOOD ( 12.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- arch/x86/kernel/apic/io_apic.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index a868b76cd3d4..1f83b052bb74 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2364,9 +2364,8 @@ static int mp_irqdomain_create(int ioapic) return -ENODEV; } - ip->irqdomain = irq_domain_create_linear(fn, hwirqs, cfg->ops, - (void *)(long)ioapic); - + ip->irqdomain = irq_domain_create_hierarchy(parent, 0, hwirqs, fn, cfg->ops, + (void *)(long)ioapic); if (!ip->irqdomain) { /* Release fw handle if it was allocated above */ if (!cfg->dev) @@ -2374,8 +2373,6 @@ static int mp_irqdomain_create(int ioapic) return -ENOMEM; } - ip->irqdomain->parent = parent; - if (cfg->type == IOAPIC_DOMAIN_LEGACY || cfg->type == IOAPIC_DOMAIN_STRICT) ioapic_dynirq_base = max(ioapic_dynirq_base, From patchwork Thu Feb 9 13:23:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4CE5C05027 for ; Thu, 9 Feb 2023 13:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5Gjyo+KXroc78O2ZRptUQkSGLM5xny9x8CXoYUUiqLE=; b=qoND7nTmFUWXFy 6U2FAC2nkzPlc3HqEFSF3az9pWNdIJ5tf23eOt7l/yi6aC/WNp3k8ZtRfTD8XJTT3Xmdn6yriAgBI zeTGcfDGPHa8Vln3Db8kwHge/xVDDNxG/YQ5xEdyQz6aZs6eo5JI/kOAaloIYrjqoDgO9phvuZN7p P54mcyadt3Bm5lMPcFflGJow52qZie0MS2Tz3J6xDAIAqLVhPTGTTRCdVFJXi4V8/nJnXekJaDtXf 354IfeboelihEHjFOQe6Z3Ya7kmwJe0d0XY5PLKsik76SNGFDwyz3NC6YOCe01iLJ0T9EF87zU7Fc h0rUYIW4dEKuZ9qvERaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ75B-001j9z-Qn; Thu, 09 Feb 2023 13:35:26 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70s-001gdP-Gh for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Feb 2023 13:30:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=TibUMBpWjM1p7foBzCFoU2T4h1a5SpeLG8kzn7mVBbE=; b=LhekQ1q/eckAGcKjeV+Waw34BU i9jzknzarL0TN5y0WGhiaHEFJ6nBJFsiV+K5ysDmCbkNmXsRrVdHltuGY6ptF+btSKhEr6aW+x2vp 7OwIRdFL5fzJhKTO69C+Efzv+T6cL58ZVZH/S46xhp5Sx7v5cYWtCNlmam4IiSusquNnRNOIhQkPr BYDsx+Up3Cnusk26KnH3b/viwBhhiUrcsPWnXkq1VoGHsixHeTZcIpZwvxVEAlpPhHVR34Kh3dWsB oXzRCqax8i7Z2gvYJysfsLdn/pVNZ4wtrQZesMTMSXJD1jFry+WguVowdXnKV0bBmO1QkUr3+vhDT R8WONeHQ==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pQ70A-007vn3-0n for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:17 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D47C761AB6; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 596E2C4333D; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=CUH46wTeOwx9zhTRGAsxA0DLFQlKaikmOpM12h4ppVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slw/hj1S/XeU+KKtyA0HKphJhu31WTvfBhywUH7t1ewc3qDR2XuntztVosWwhOwMO KVx3EhSV94TVN4wDk1tgsSdiv1z/6Q8ZiBVyfi/d6fXVBC9skGunDYcdUTpY+olWBl 9yXFKvVlWl/w1TvfmtBU+qbWBZ+mX8AJTl2U0hw0bUPy91tXW1L6B5Huvl/O2jd1/8 9ivRtx2HYM9o0aVqS1LVrbHm9Az+F0epLbm5rDUkSfXxWt4BqRyyqco/c3traWvlbQ Iqhib/OEire19qpGYAws0JwY5lrnjszJbJeDNdhe4DNwoAKGrVMvsiJ4CG4fL2keWa cNEv/uyT70gVw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001LM-54; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 12/19] x86/apic: Use irq_domain_create_hierarchy() Date: Thu, 9 Feb 2023 14:23:16 +0100 Message-Id: <20230209132323.4599-13-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_133015_189058_098C85D9 X-CRM114-Status: GOOD ( 11.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- arch/x86/platform/uv/uv_irq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/platform/uv/uv_irq.c b/arch/x86/platform/uv/uv_irq.c index 1a536a187d74..ee21d6a36a80 100644 --- a/arch/x86/platform/uv/uv_irq.c +++ b/arch/x86/platform/uv/uv_irq.c @@ -166,10 +166,9 @@ static struct irq_domain *uv_get_irq_domain(void) if (!fn) goto out; - uv_domain = irq_domain_create_tree(fn, &uv_domain_ops, NULL); - if (uv_domain) - uv_domain->parent = x86_vector_domain; - else + uv_domain = irq_domain_create_hierarchy(x86_vector_domain, 0, 0, fn, + &uv_domain_ops, NULL); + if (!uv_domain) irq_domain_free_fwnode(fn); out: mutex_unlock(&uv_lock); From patchwork Thu Feb 9 13:23:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94E46C61DA4 for ; Thu, 9 Feb 2023 13:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=khaAjXFDXQO1AH5lwlRo/wXChBs3Ql3ryoSdDkjKgrU=; b=nszqJd/eeOyDNL MPknA6utZReZRMg6b69+6QR34yN6wlQ6Ckbp/3dYyzoBEKSO9rlq81B0oF3MNb09zRNKGzftXfj66 S3aJUXgFy55xroXxk4/owqPuDnuTvD23H5ae516Pp96pwLEiif5dCjHY7fRbzNnCKpSbXHxBjoPoI /ek0DbhgJhol1/U7S8FbyExr1Rc8Dj2t9VS10bknsjgpioukH/wzobNuP97KZ0bMhUZLfH355ibTz 7KqPSTOcLqPL4Uof6EebMeZUnnyGZyw+QsjaVkjm76f7LW4NcBn7JaldbjRDH69PJw+6ONdHP9S1W UG/h+n01TEeQY/5UN+Jw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ77Q-001kLB-Nq; Thu, 09 Feb 2023 13:37:45 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70u-001geq-B5 for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Feb 2023 13:31:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=Vgc8FUquq3+r4rz4cJ4Ol4+2ak580W8lYszkhVwD6ZU=; b=Bp9HPn4sywg1hEWBsOLd7FQdHl nNAw6DQPHKJVhsYqD/n5IGAIFbVescLE7m7/uRwOtmv2piVCFKy3KeTKEaFwl140pOI7mrMmKdDIF WJI2KMvemDlckdXw42kJUT0WGWKpeO9FisRWcGFC8HVMSiXCYrCnP5aM7Bf5hdSWzh1P7z7YL5668 K3EkmObkktBGqpQhLHwknN482EQ5G2sg8Yocod6Y7Dn239S3xkEj70aPp8rFgmJEOudPbE6bE6UH/ gJ3Qx3mf/mXHp0LOoaoDNaZhQ+dEjAmWsoeAR/ZlpdUYIkvXEYhS4pmpTFrWh230nlTGI6D/Xw0iQ 87q+UEZg==; Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pQ70A-007vn5-12 for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:19 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0600861AC9; Thu, 9 Feb 2023 13:30:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6404EC4333E; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=NTHXrrpZCAJQDbqGQ5Dk1VncIloUIc9A9BrVorjY3xI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYyAS3/jMTrOrQkqzxE8B5R+kCJA33WHUACgO3u4maL1KI6eOMC6KdVb7sKrAIe2q KGQcpdr28joNSS83Q1OENfMsXmQa+Qkj/El7u7axKD7xn+m1EfD8GB4cU8lJdL0HH3 YA5Ut7l3qrKwJDAG9Gro8Shh7Ki7Dwh82EieJohc9itIMwm8V4YCT5MGMEX1toj4oT a9amOFPGN6m4cVkBb8CMZnPo7aWHQYlP0gtS0HUKJsz+PmZI1/FvX6ebJ99pAT0nKm b/GOyJ2jehG0MLsv7Xn1q08vi3n0HDR1a6By8/HibtGzFKDwu0+FVQq0u7V0koORm8 irPz+jBwRRFJg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001LO-8K; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 13/19] irqchip/alpine-msi: Use irq_domain_add_hierarchy() Date: Thu, 9 Feb 2023 14:23:17 +0100 Message-Id: <20230209132323.4599-14-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_133015_486233_3DAF63CE X-CRM114-Status: GOOD ( 12.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the irq_domain_add_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-alpine-msi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-alpine-msi.c b/drivers/irqchip/irq-alpine-msi.c index 5ddb8e578ac6..604459372fdd 100644 --- a/drivers/irqchip/irq-alpine-msi.c +++ b/drivers/irqchip/irq-alpine-msi.c @@ -204,16 +204,14 @@ static int alpine_msix_init_domains(struct alpine_msix_data *priv, return -ENXIO; } - middle_domain = irq_domain_add_tree(NULL, - &alpine_msix_middle_domain_ops, - priv); + middle_domain = irq_domain_add_hierarchy(gic_domain, 0, 0, NULL, + &alpine_msix_middle_domain_ops, + priv); if (!middle_domain) { pr_err("Failed to create the MSIX middle domain\n"); return -ENOMEM; } - middle_domain->parent = gic_domain; - msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(node), &alpine_msix_domain_info, middle_domain); From patchwork Thu Feb 9 13:23:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134614 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB9F8C61DA4 for ; Thu, 9 Feb 2023 13:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TNU6TC/3762G0vKp3J7b+9ZueqfEBme1xV0bUIeEU+w=; b=OMSb46+RWVbSmY VSUCScpoW5ykDGMwzpSMptgHTnqlE9qX1ezSpSEYa7AuqIq8drrAwuyiNm6XUbNcgkoIeq1xS3EdS DbT0IWP9rS/sC4cE2aviKezDLqD9FEfd75LjRoNZjOCSESvOC325cOQFUA1LychjESJIKcNLY/qUj DpSUxelCvEQtAJyCFqdTS3f5zeFTWlpz6PfnWE704WP8VCXDOsG697H/823/t0B7IaG2p5UNT7cC/ PaTPfnGj/reie0kEb8NWlQMUNNT5VEsGamEsEgCMxKehMfSkPxfn4y8lOalU9oQ1Hj0skFfG1Bt7m xNGnLH+ySEgL6aHVwuhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ76f-001jww-Rt; Thu, 09 Feb 2023 13:36:58 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70u-001geo-9L for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Feb 2023 13:31:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=ZiEgq4vW5UyxJkWFCdCqPrYjI9W+MxiLS3baR+c6jdQ=; b=hS/efDyZaBP3y9nMIx9eOpxaAC rXVta/inFAcCEZz9Hyzoo83qJRVPL2jN1Z7AeiGuuTro8z11q7SyFcktOdebqhu6b8lYpNj5jjCq4 i78nAG6EGnOPj66J9vxeArx9gCfHCtIoT7VtBh1xsA+jLalRftAofkUy1JOWKT0ew6cTr9HIdae+B /4YR3j5t0m53YHCMRDNhb0Lnn5MDgzeinjbFeUiPC+0NVaRMoXjGzAYWAZ3al+S8JJkm93fi0ah9c S4UE5s/Uwg47PmC/NqVYa6k+YOlMN0VED4DvBHxlVq8AjuKRkFI/BOOwYWhENKuXx5WMS+4gET7x1 CREIcJHQ==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pQ70A-007vn6-0v for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:18 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 09A2061AC1; Thu, 9 Feb 2023 13:30:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71A7AC432C6; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=g/DpJ6yqRzfoadiSwGWD2YQN47sUT9bIGP4aY7Lvgjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=quO6Uv/Ah56XqTwkKZTJHODbuOPlus5uBx4bX+ZxnjNZUAAj3L+4Uj3Gvm7nN2dvA dRBwwsc+OuIufTZeF0Zz0ky0RBxrNobWgrhrs509a4143bhziRsIPHgUXkbXAvES7a yCPLPgowTUP/0H5hEq/e0JT8cYo62OzYjsqmY0gomzFantuIp8JezQ+kVi0D6Cgm4K 2Qv4IGGTSv8/vbzoxnjPpWXZ2Ur3kK+ige+jgEw2fP1Fm1cjFFIKW/hs8cHS32l5yR r7kELz7Zzqu85ZJkI3xnpBj4e+Wzy6NI6txijamHILd/x4EbuPAOnQ4yGo08+Z7B3j QLzudmhakOzNw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001LR-As; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 14/19] irqchip/gic-v2m: Use irq_domain_create_hierarchy() Date: Thu, 9 Feb 2023 14:23:18 +0100 Message-Id: <20230209132323.4599-15-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_133016_870795_375BF90F X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-gic-v2m.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index f4d7eeb13951..f1e75b35a52a 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -287,15 +287,14 @@ static __init int gicv2m_allocate_domains(struct irq_domain *parent) if (!v2m) return 0; - inner_domain = irq_domain_create_tree(v2m->fwnode, - &gicv2m_domain_ops, v2m); + inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode, + &gicv2m_domain_ops, v2m); if (!inner_domain) { pr_err("Failed to create GICv2m domain\n"); return -ENOMEM; } irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS); - inner_domain->parent = parent; pci_domain = pci_msi_create_irq_domain(v2m->fwnode, &gicv2m_msi_domain_info, inner_domain); From patchwork Thu Feb 9 13:23:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E095FC61DA4 for ; Thu, 9 Feb 2023 13:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tXLVRdj2vYHf3To5XFV9WiYn+G+1kvyYtqV1Owl13Ak=; b=zc7oWPAeNrH3W/ G3qc/Nmw48zQvN8xgogXow9IxM8Oq4Hnz6GXZzPDtWrcwwyFouLcDFegm2K+R0zsK/Dc+Vq4q1Am0 3wdtcuWdYaRd48tGrRmLXUPP2nlPOSJX4HYdzwoVZ1GVz3MsvUVzbzLUvMr211bGcw8MmtEkOQoW+ pp614fyHSKiQtsBQ5tXDf6RFntfF2NUU0CQMwIyMbKEPrU1ZMOMrRV4q3c+lxKT8pNOR3dE5Qv/fq rngnM2eBxX0PK5fhfkG1D2BPVKE7dOR6+LM1H7TRUZF9YIN2FtkmIN36sRcxmBtUDs6lBfbI4+FXE IviiMz8N295uUtyYt2+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ762-001jce-8g; Thu, 09 Feb 2023 13:36:18 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70u-001gen-8i for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Feb 2023 13:31:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KPMTVtpiOOGkS0V4jpVWs5c+tP/7RFHyRduRqBDQ3iw=; b=pwG6IQzZuvx6L1+OFqOqSN3QHr 9GjKBUy9T4jz+KzwmM3Ro/XQLLNiKkdiNM+HfSf9dlW0DWgoMy9m87jqM0/1c5Qs3WQf7CXA1iAmW uHXxkgmc9xGeKDF+slCX+5m6hvjU4giWpfWthNQUGu3c8Dz05pClxgonZsmRKvoxYlUBOkAVExTEg ceB+qMhGk4gZ5O6aSEnZLkwlkUQnmjGemQi/18Nk15cSdMFVSEmXy+iJUkZnwQpnaSoYFRem/wMyw fiRU4xiPU0vkaTcmhTzDxVrihAwhPEwjbTDV0kEjeX+mCQnXx8kRh++wzfPbspGrLNCce3Dh0LD43 bJck/PWw==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pQ70A-007vn7-0x for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:18 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 173E361ACF; Thu, 9 Feb 2023 13:30:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CC39C433EF; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=w4UY5RVGpUGFn7eO+zB8iof9Dgni/IxlD6NiUpdYG9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cEYfbj+Onx4biZQxdwtTCxE5hSFa192gAA3UP3qdyMJeI8rSMM7w2rIZaz55nng33 sqLZBzNwkk5IvaUOYyHNH2YW0nwT/7AeuZlpuSCXwT2OGFWq5jv7a8Dt19v0JEGlLm fkxzYXZ4HhTZ6J2jPAAz7hIxJlPv/Uj/ReFcQ29qhOx7vDh4ORX62pwSNNqApWAcdN kF/6u/euxvRTKDNMW6VZEFYC5DMooswYZEmg+Aq2f1oKZm6I/o1SgvwL/fj4joBc6W 6UM/l2lM9RZvcj6I7uNfXBkxyUiNxE5oms3S53Z7bU9n2o4bTHZYAhr+pgeu3RbCOn dVrc4WjIl0IcQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001LU-DP; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 15/19] irqchip/gic-v3-its: Use irq_domain_create_hierarchy() Date: Thu, 9 Feb 2023 14:23:19 +0100 Message-Id: <20230209132323.4599-16-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_133015_373248_2629D6E1 X-CRM114-Status: GOOD ( 13.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Note that the domain host_data was first set to the struct its_node during allocation only to immediately be overwritten with the struct msi_domain_info. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-gic-v3-its.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 973ede0197e3..5634d29b644d 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4909,18 +4909,19 @@ static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) if (!info) return -ENOMEM; - inner_domain = irq_domain_create_tree(handle, &its_domain_ops, its); + info->ops = &its_msi_domain_ops; + info->data = its; + + inner_domain = irq_domain_create_hierarchy(its_parent, + its->msi_domain_flags, 0, + handle, &its_domain_ops, + info); if (!inner_domain) { kfree(info); return -ENOMEM; } - inner_domain->parent = its_parent; irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS); - inner_domain->flags |= its->msi_domain_flags; - info->ops = &its_msi_domain_ops; - info->data = its; - inner_domain->host_data = info; return 0; } From patchwork Thu Feb 9 13:23:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70442C05027 for ; Thu, 9 Feb 2023 13:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Bma59wojSEuPkEoSvAamGKou8VN8DCs+HIoCQfqj5AI=; b=m1lkEWO1oRJr0V qWxK8ZHx116HpaG10RUYJBtd/a0UYZYSBdvenrCdsrwQdvr7/7Bht1U/7LuxbhUPt7SzyadeDLBIE Wl1sSCxHJprfGYLzksVrhDrP6t70H6BAX+FqshpfLgJthABHWvOrwt/7yo3i8vSgbBRc1cwU6MijO OcStfCmg25wLYFYRC0qYHdQLMwaer6y8l2NNHJq4jzRrDQG85p1Sf14qIC+YzC8+ECPq7aiq5iQaX xz+5UOBUsNrI7wqwJKah67hrSrtsiJOiiGCvgOVWtIniaWBZj9olFNT0LEEvYb5Tqh2FNj7BIIJYU Q5ha6oydNYbyoN3I3kHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ72R-001hVY-Sw; Thu, 09 Feb 2023 13:32:36 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70i-001gQR-84 for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:53 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3230561AD7; Thu, 9 Feb 2023 13:30:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98055C43230; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=g3QrnnkP4AAAVKLpcN2UD/9G9Q9P7im2mBObh2fnrA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkTHK1i6/q2BiBNnNFiXZGehf02okV9w7aXbdoVBUGKhxm/ZOy/WdxFYkV3C+AR2W hSOuovBe2MMCeH2zrtrst80tTqqR4ybYCS0K9TRvbZGR9Pzi0y/9qTKxSrTtV7hgkX BsX/PN9wURKcGjxuCmdmxshBG6mpTBm+ndhG7MUUmiZgI9387L7YyAM9TcYbJhsr0t 1JXMz6/sOpitjHhN4UhTc6JZ9a7HrjvXzyL7OJjbeYdssAbpFFk3h8jnikP4AmHGPN TrP6BmBnAFVeFjpDlrLi67UZNEjOjSapzt0Wn5VVtTXQ2cLyZ1xBDQJUhELmzaT4PI eOhuxnZoG2NJg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001LX-GH; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 16/19] irqchip/gic-v3-mbi: Use irq_domain_create_hierarchy() Date: Thu, 9 Feb 2023 14:23:20 +0100 Message-Id: <20230209132323.4599-17-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053048_376188_3B253A1C X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-gic-v3-mbi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-mbi.c b/drivers/irqchip/irq-gic-v3-mbi.c index e1efdec9e9ac..dbb8b1efda44 100644 --- a/drivers/irqchip/irq-gic-v3-mbi.c +++ b/drivers/irqchip/irq-gic-v3-mbi.c @@ -233,13 +233,12 @@ static int mbi_allocate_domains(struct irq_domain *parent) struct irq_domain *nexus_domain, *pci_domain, *plat_domain; int err; - nexus_domain = irq_domain_create_tree(parent->fwnode, - &mbi_domain_ops, NULL); + nexus_domain = irq_domain_create_hierarchy(parent, 0, 0, parent->fwnode, + &mbi_domain_ops, NULL); if (!nexus_domain) return -ENOMEM; irq_domain_update_bus_token(nexus_domain, DOMAIN_BUS_NEXUS); - nexus_domain->parent = parent; err = mbi_allocate_pci_domain(nexus_domain, &pci_domain); From patchwork Thu Feb 9 13:23:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DFC7DC61DA4 for ; Thu, 9 Feb 2023 13:34:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+gE+gvJ798EM2oxCgoKmk4GpTlQvc+fRLRCBGab7QFE=; b=Bd9QmEWQGcSwPk iqAK1+/SKQTY9kCSaoHwpUe3/6xGJLnh1/tC8X86UuDO2UmQhC2xj0NFq9/dG/EpP1QaZUOxgtgj7 +G4poqdSt3IWS825/IMNav8F5mmbJ/AHgH2WLLf9/49JVK/7T1j5qia42KtHXPf/v6MaScq10/Ne4 mYa6HX2I/pughkYNB1oLYB/Xrzxiyh8sGaeu9KeBifZQDuGT/0FWtkZnM+ALvAajt1dIVXB4zZso8 fSsUfzJudfcZvvWSxUeW3OMH8Ibe/4pKKq93GA94Nq6AkbCj7qYBJeDAQPeZiXCw5jqn6okMBphYv H+CrAam+N8URY0+9WXzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ737-001hvN-HV; Thu, 09 Feb 2023 13:33:17 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70i-001gUM-PB for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:54 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 37A0B61AE4; Thu, 9 Feb 2023 13:30:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB0D0C43234; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=xReQQbRP8f3ZcgElG5HL2OX/F0HPnUSW+WJ1I2BgRtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TpFoR87h4CVzdcgL6j8nfk4026l69oWKrVtkrpvIeqrZjLp9OWcf3VFYh5hp5SmCS +sZpIY55fJc4MDomzGwRj8GEbDdhQ6zAU+YGpbXiNCXfRci4pkncf7GYrzr28MyumC oDNGbTj78k0MRJQEXKikjKowEvQ+HCS88FcxdKa7+KJF8IV4h8RuVjWUTXr3m/9agS 6zS3tMt1GcOVs/vmfRJjj7nlk/rCyDQ+80rE0GzN0+YQT6jvRgMBt9+Ni541c4oauH e90S7lza9Ol4zhgFuYxE2TVY9sroziB9bu+seZ2YhwnvALGuybqzfUJeZX4vP22EvJ wdSPEA9SiHQ4Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001La-JB; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 17/19] irqchip/loongson-pch-msi: Use irq_domain_create_hierarchy() Date: Thu, 9 Feb 2023 14:23:21 +0100 Message-Id: <20230209132323.4599-18-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053048_898330_163EF28E X-CRM114-Status: GOOD ( 12.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-loongson-pch-msi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-loongson-pch-msi.c b/drivers/irqchip/irq-loongson-pch-msi.c index a72ede90ffc6..6e1e1f011bb2 100644 --- a/drivers/irqchip/irq-loongson-pch-msi.c +++ b/drivers/irqchip/irq-loongson-pch-msi.c @@ -163,16 +163,15 @@ static int pch_msi_init_domains(struct pch_msi_data *priv, { struct irq_domain *middle_domain, *msi_domain; - middle_domain = irq_domain_create_linear(domain_handle, - priv->num_irqs, - &pch_msi_middle_domain_ops, - priv); + middle_domain = irq_domain_create_hierarchy(parent, 0, priv->num_irqs, + domain_handle, + &pch_msi_middle_domain_ops, + priv); if (!middle_domain) { pr_err("Failed to create the MSI middle domain\n"); return -ENOMEM; } - middle_domain->parent = parent; irq_domain_update_bus_token(middle_domain, DOMAIN_BUS_NEXUS); msi_domain = pci_msi_create_irq_domain(domain_handle, From patchwork Thu Feb 9 13:23:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 524B0C61DA4 for ; Thu, 9 Feb 2023 13:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Jw5FeoPZI29VHGjS4MNpYMioVRX5NdDwmQtA8HIYhVc=; b=jmgRRy/cxOSJqN sG/KewmckGOhMiTJDghzoDGDoCjtxRx7Hm28oX0BFd+JRiFkvpJh6F4tndChBleeL/ZZzw/rgoBcI Nh1i7VQu5X6nTN0M4N7+odAXq4COaiDVD/5j8FEWTWXdZYqiUV1K21wd+sOEdIhNNIEeG+uK3xR5S wYevevdomAbc/LCp6Hr1Zk8fPg3UKyjyIcK4NRcX4c3mdQolHWyUCWla+5rc5rMblWK5b7pZLJ5Jy uyVTQDkRoh5Zb+8FBAqzg3Q0iYewTfxtdwUUtyOstmcPWz3Scrf2gEcFmrae8hF0TiVjdi6eTWv5L 4sgfUQnBCAxbxKsSuumg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ73x-001iQJ-7W; Thu, 09 Feb 2023 13:34:10 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70k-001gWF-Gs for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:54 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3C8A461AED; Thu, 9 Feb 2023 13:30:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4B3DC43239; Thu, 9 Feb 2023 13:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949443; bh=HISCOQlywscKKiMV1pBIVu7ICjzhN///DKg1eFvToD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xu86u8HdonbGLeFJ+mZB1yqGEQXC4M0SBIKvjGHzi4Rg2oGVCNhFcvkN08I7P2CZR exdI9GkIvPeNQqxQ2lku9EcNAioStI82ppokOEDdUcSYjL41tvm8+LdNtU6OkBzHVS 12ed9EjvZ6CJ3S6YI/a3LeKqDD0toHeo2Vur+8pgEI/zEPWH5Ny4PWL6dAvNBvtM2w o6GTZayDVlY5RsYmKAsJsRg/203JlLlgyQu2yr1KJViRkLOZgK/p4gYl8ZOZatNvCt +XeKr5TsfKobVo8cuDYrsaBfZOa3868riTW+jwKe+gUgzAhxbRic7FfITXVdRqIH3M Zh2wZIG2YUomw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001Ld-Lj; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 18/19] irqchip/mvebu-odmi: Use irq_domain_create_hierarchy() Date: Thu, 9 Feb 2023 14:23:22 +0100 Message-Id: <20230209132323.4599-19-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053050_673112_3B0A1853 X-CRM114-Status: GOOD ( 14.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-mvebu-odmi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-odmi.c index dc4145abdd6f..108091533e10 100644 --- a/drivers/irqchip/irq-mvebu-odmi.c +++ b/drivers/irqchip/irq-mvebu-odmi.c @@ -161,7 +161,7 @@ static struct msi_domain_info odmi_msi_domain_info = { static int __init mvebu_odmi_init(struct device_node *node, struct device_node *parent) { - struct irq_domain *inner_domain, *plat_domain; + struct irq_domain *parent_domain, *inner_domain, *plat_domain; int ret, i; if (of_property_read_u32(node, "marvell,odmi-frames", &odmis_count)) @@ -197,16 +197,17 @@ static int __init mvebu_odmi_init(struct device_node *node, } } - inner_domain = irq_domain_create_linear(of_node_to_fwnode(node), - odmis_count * NODMIS_PER_FRAME, - &odmi_domain_ops, NULL); + parent_domain = irq_find_host(parent); + + inner_domain = irq_domain_create_hierarchy(parent_domain, 0, + odmis_count * NODMIS_PER_FRAME, + of_node_to_fwnode(node), + &odmi_domain_ops, NULL); if (!inner_domain) { ret = -ENOMEM; goto err_unmap; } - inner_domain->parent = irq_find_host(parent); - plat_domain = platform_msi_create_irq_domain(of_node_to_fwnode(node), &odmi_msi_domain_info, inner_domain); From patchwork Thu Feb 9 13:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13134611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE92DC05027 for ; Thu, 9 Feb 2023 13:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FGQOJgpryI4tm2YeVJAXIddoWRVn7hmoH7nikWYQs7A=; b=jaNKUUfQjpO85s gXbBiGnBwasUAJncrF4sS5HWJDboil0g72ZQHSsIxr7wsvSkNI4m0OhEMayL0fTiP+JG0W877Z2j5 aHCgRlfdgSEzoH1Nxja+6mY2hneSLYCvqMP/DyQtBCpMsdLZpVvaFMFaXuVY87dFQWzsA1GxX9oqy l9QCNZqw1myLbIEbbmuWcpz8nHF4lFaNsJTZfAtycD1RSOWd6rv8A0mzfdzP8pFWHjjhlj63Y8N1Y CugzXXghMcpK5D+KV3BnQFhxzHQ3cYfVP2z5Feexl7jygFVM5HqvciEKpFei/D2F/QJUazMXdid1x WJfbQzFYNdU/tzw5wsSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ74R-001ii8-Fa; Thu, 09 Feb 2023 13:34:39 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ70k-001gQd-4d for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 13:30:55 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 54D5961AEA; Thu, 9 Feb 2023 13:30:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07245C4339C; Thu, 9 Feb 2023 13:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675949444; bh=4fhmTJDkTgZYwnfzYcbdgi/FgwWExuprRiWT2JjWajs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vHp8tA5LH83oMSkvbBs9C+HHYvGaDzE+4zMD1Mz9+PDcNCSBTiF5AYN121QQNWmiX 2uYkHYk64gOk/5kEhf4PTRCyKIW6nf1SjQzPax6S9KrcpcHZIbY6V3/9wYcykUkFLq onCHVKQiZ+Nw8Sr4OMbwzxrpTDE69HfttyBB4O6PVG5BGmDs72Ix0+SAK+OCWbBLWw ZODUivqO97FmVIetaGQn2+nfDX5yIjU81vQ8vMMKYjdW+wJISEy/cAQpHSrJ6heNcz 96FJPZ+llfzX+SJXYSlGYEmxVPRLGFnIL7JabWOlOCrdXlPTnnj94Ws7nqM2kwbsOc k+c8NzFKrIY6g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pQ71H-0001Lg-Od; Thu, 09 Feb 2023 14:31:23 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v5 19/19] irqdomain: Switch to per-domain locking Date: Thu, 9 Feb 2023 14:23:23 +0100 Message-Id: <20230209132323.4599-20-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209132323.4599-1-johan+linaro@kernel.org> References: <20230209132323.4599-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_053050_350020_3B004CFB X-CRM114-Status: GOOD ( 24.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The IRQ domain structures are currently protected by the global irq_domain_mutex. Switch to using more fine-grained per-domain locking, which can speed up parallel probing by reducing lock contention. On a recent arm64 laptop, the total time spent waiting for the locks during boot drops from 160 to 40 ms on average, while the maximum aggregate wait time drops from 550 to 90 ms over ten runs for example. Note that the domain lock of the root domain (innermost domain) must be used for hierarchical domains. For non-hierarchical domains (as for root domains), the new root pointer is set to the domain itself so that domain->root->mutex can be used in shared code paths. Also note that hierarchical domains should be constructed using irq_domain_create_hierarchy() (or irq_domain_add_hierarchy()) to avoid poking at irqdomain internals. As a safeguard, the lockdep assertion in irq_domain_set_mapping() will catch any offenders that fail to set the root domain pointer. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold Signed-off-by: Marc Zyngier --- include/linux/irqdomain.h | 4 +++ kernel/irq/irqdomain.c | 61 +++++++++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 16399de00b48..cad47737a052 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -125,6 +125,8 @@ struct irq_domain_chip_generic; * core code. * @flags: Per irq_domain flags * @mapcount: The number of mapped interrupts + * @mutex: Domain lock, hierarhical domains use root domain's lock + * @root: Pointer to root domain, or containing structure if non-hierarchical * * Optional elements: * @fwnode: Pointer to firmware node associated with the irq_domain. Pretty easy @@ -152,6 +154,8 @@ struct irq_domain { void *host_data; unsigned int flags; unsigned int mapcount; + struct mutex mutex; + struct irq_domain *root; /* Optional data */ struct fwnode_handle *fwnode; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 804d316329c8..c96aa5e5a94b 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -226,6 +226,17 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s domain->revmap_size = size; + /* + * Hierarchical domains use the domain lock of the root domain + * (innermost domain). + * + * For non-hierarchical domains (as for root domains), the root + * pointer is set to the domain itself so that domain->root->mutex + * can be used in shared code paths. + */ + mutex_init(&domain->mutex); + domain->root = domain; + irq_domain_check_hierarchy(domain); mutex_lock(&irq_domain_mutex); @@ -503,7 +514,7 @@ static bool irq_domain_is_nomap(struct irq_domain *domain) static void irq_domain_clear_mapping(struct irq_domain *domain, irq_hw_number_t hwirq) { - lockdep_assert_held(&irq_domain_mutex); + lockdep_assert_held(&domain->root->mutex); if (irq_domain_is_nomap(domain)) return; @@ -518,7 +529,11 @@ static void irq_domain_set_mapping(struct irq_domain *domain, irq_hw_number_t hwirq, struct irq_data *irq_data) { - lockdep_assert_held(&irq_domain_mutex); + /* + * This also makes sure that all domains point to the same root when + * called from irq_domain_insert_irq() for each domain in a hierarchy. + */ + lockdep_assert_held(&domain->root->mutex); if (irq_domain_is_nomap(domain)) return; @@ -540,7 +555,7 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) hwirq = irq_data->hwirq; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->mutex); irq_set_status_flags(irq, IRQ_NOREQUEST); @@ -562,7 +577,7 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) /* Clear reverse map for this hwirq */ irq_domain_clear_mapping(domain, hwirq); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->mutex); } static int irq_domain_associate_locked(struct irq_domain *domain, unsigned int virq, @@ -612,9 +627,9 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, { int ret; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->mutex); ret = irq_domain_associate_locked(domain, virq, hwirq); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->mutex); return ret; } @@ -731,7 +746,7 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, return 0; } - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->mutex); /* Check if mapping already exists */ virq = irq_find_mapping(domain, hwirq); @@ -742,7 +757,7 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, virq = irq_create_mapping_affinity_locked(domain, hwirq, affinity); out: - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->mutex); return virq; } @@ -811,7 +826,7 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) if (WARN_ON(type & ~IRQ_TYPE_SENSE_MASK)) type &= IRQ_TYPE_SENSE_MASK; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); /* * If we've already configured this interrupt, @@ -864,11 +879,11 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) /* Store trigger type */ irqd_set_trigger_type(irq_data, type); out: - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return virq; err: - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return 0; } @@ -1132,6 +1147,7 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent, else domain = irq_domain_create_tree(fwnode, ops, host_data); if (domain) { + domain->root = parent->root; domain->parent = parent; domain->flags |= flags; } @@ -1528,10 +1544,10 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, return -EINVAL; } - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); ret = irq_domain_alloc_irqs_locked(domain, irq_base, nr_irqs, node, arg, realloc, affinity); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return ret; } @@ -1542,7 +1558,7 @@ static void irq_domain_fix_revmap(struct irq_data *d) { void __rcu **slot; - lockdep_assert_held(&irq_domain_mutex); + lockdep_assert_held(&d->domain->root->mutex); if (irq_domain_is_nomap(d->domain)) return; @@ -1608,7 +1624,7 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) if (!parent_irq_data) return -ENOMEM; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); /* Copy the original irq_data. */ *parent_irq_data = *irq_data; @@ -1636,7 +1652,7 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) irq_domain_fix_revmap(parent_irq_data); irq_domain_set_mapping(domain, irq_data->hwirq, irq_data); error: - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return rv; } @@ -1691,7 +1707,7 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq) if (WARN_ON(!parent_irq_data)) return -EINVAL; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); irq_data->parent_data = NULL; @@ -1703,7 +1719,7 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq) irq_domain_fix_revmap(irq_data); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); kfree(parent_irq_data); @@ -1719,17 +1735,20 @@ EXPORT_SYMBOL_GPL(irq_domain_pop_irq); void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs) { struct irq_data *data = irq_get_irq_data(virq); + struct irq_domain *domain; int i; if (WARN(!data || !data->domain || !data->domain->ops->free, "NULL pointer, cannot free irq\n")) return; - mutex_lock(&irq_domain_mutex); + domain = data->domain; + + mutex_lock(&domain->root->mutex); for (i = 0; i < nr_irqs; i++) irq_domain_remove_irq(virq + i); - irq_domain_free_irqs_hierarchy(data->domain, virq, nr_irqs); - mutex_unlock(&irq_domain_mutex); + irq_domain_free_irqs_hierarchy(domain, virq, nr_irqs); + mutex_unlock(&domain->root->mutex); irq_domain_free_irq_data(virq, nr_irqs); irq_free_descs(virq, nr_irqs);