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: 54961 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334212wrn; Thu, 9 Feb 2023 05:32:01 -0800 (PST) X-Google-Smtp-Source: AK7set8HF2jEV9VRtRXPg0e6xgQiK4P0qNntvBwY0CYmt2z6D0cU8aGtSFhp6raXpM7AiTmPEQ2q X-Received: by 2002:a17:90b:3506:b0:22c:ad11:af3d with SMTP id ls6-20020a17090b350600b0022cad11af3dmr12644227pjb.4.1675949521409; Thu, 09 Feb 2023 05:32:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949521; cv=none; d=google.com; s=arc-20160816; b=vErcBfJdEakrsZ+I596t/6KtjVja3Wl8eefp18ASg8wbw8wKWsLPADaCPI7Q4pmXkg IrsxPTB0rm50sVq1PN+/vT8rfXERMAWSBkB0lH4txAgX4myGkaFQsYo8JJswpgcFCOQT 66YDiEfJb8OZkqMhe/EfrJ688xJXcneY65mHTvoH2AA7FS+o4o6jRVAlYI6q3tLrNnLX TIIV+ZU915KXjbOK+0ol8rjd0aYwvHJPosSuN0MkDEtGovWOe0jypCt5ppaHPIH21HSd PVWEfRz61YiYqQ7g/4PeBX+PqPFqmMuDkma/Uvh+KtOeH6F999NYfCjx21+eIV+TyNZS wtKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8OVyPa/IKpEabnBKb/Clqp3KrZUv96VCot6h2E6BWXk=; b=EB3E+YsH2A35FG+1xHHSdhjcAV6a9PFPV+dHx32XiPpvK9ustsXEjB0eqotG5gM/Qm gIFTK0bPLCj48NOBxd6oVAAU0QGxFgtFHBx/54pgKn7X345Xe+LSoCuBGL4CiRLBotmc s8zpEEbKJ10LnshIxg8vctTJLOyXMw7cxgSad/8OX4HDfniOmS8ITesKInYvmRPm7aOu eqvS62rWsTk02QZFsqy9AaparpwBWqqth9tiyC+5UeFGNkww9/8kR6iYnD0EOiJxeXXW 0wsn6EIG0egt4TVWK8547w858V1tm7sfAVoxnKRSoTrb6oJLkOJTxxrDBZhNyQAivyDe VxVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TeA1pbon; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ls11-20020a17090b350b00b00232f57260c1si1056264pjb.1.2023.02.09.05.31.46; Thu, 09 Feb 2023 05:32:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TeA1pbon; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbjBINbN (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbjBINaq (ORCPT ); Thu, 9 Feb 2023 08:30:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D51EFF0B; Thu, 9 Feb 2023 05:30:45 -0800 (PST) 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 2AC43B82138; 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360445291796371?= X-GMAIL-MSGID: =?utf-8?q?1757360445291796371?= 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: 54953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp333812wrn; Thu, 9 Feb 2023 05:31:21 -0800 (PST) X-Google-Smtp-Source: AK7set93CBRttZEOr5ATt9M3BDPnIUDKRvphHQN+LSudnAUKhVKtYA95xxYNIVjYF6kDcLh8yTxr X-Received: by 2002:a17:902:9a42:b0:199:1804:48aa with SMTP id x2-20020a1709029a4200b00199180448aamr10912347plv.13.1675949481122; Thu, 09 Feb 2023 05:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949481; cv=none; d=google.com; s=arc-20160816; b=deBx+UpBhq0+aD4i984pFBjVeobgxG3ATSaZ19UlQoUbLmBFKNlKGZw+becx8nptC+ 5bJn91gwL4DoLbk5nOzMxWX3RToBbe8t9LDmPdlLVuCxxA7Wq2yPpFe+cdcsi4hJ6KQU 2AX8xr7PG3focSOHCh6pb0MAlAVibJMGvSLkf5WcmQQFnmK5vvE0mqxhZiaInWhOQnjF XPonQwJBSu2+lBOKtTpIV5inHHl2TpmoenFciLlAQtPjzNcCyx0ZEKUGzAanGCKVZ1gX XI0p8a6y+3CLqrMYLCpkfDhYVa1W1k5XeL0f0Fjmf3D2FaZANC85o40ZhJV74/ev4Vd9 IsWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t3zLDO0KuE4IYcw9XMKSWPk6Z0qb1NU8WQC5tzv7rVY=; b=rE6l3Qb0UlOmhn4NC3wESRgOh4/dLEGfQyWm8tcZPH0RJ+hlmfEWnuJ8yQb/emwuhI 69Hm+lAjQwqYBOlE9D7NadxYxjtYxvmFSWvhkpP+KuaxUN9dav7bAM6es3PZnJtqUxtk 0V1wWOqhcol1xAS2LsR5MnRR43cqnIdVxHkYkThsHsrUTLy3ZWRVQifoGc9vVdRf9N8Y 9rPIzFcdSGwktXA/29Pa5hPgnZWHmeZazy6FhRsVem+lQHn78Lhtb8sZsH6s7Q40/i/6 jaE1PYEAFkIO+JjG5j8jwpYmnNDSV3XhTF8jJ7bbWMWTeO5oU+sGFI+AhcJkd6Z0EEJb E4uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pdMs14cS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jl16-20020a170903135000b0019925fcf696si1717095plb.274.2023.02.09.05.31.07; Thu, 09 Feb 2023 05:31:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pdMs14cS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230239AbjBINas (ORCPT + 99 others); Thu, 9 Feb 2023 08:30:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjBINao (ORCPT ); Thu, 9 Feb 2023 08:30:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43BB1353E; Thu, 9 Feb 2023 05:30:43 -0800 (PST) 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 6BC6661A7B; 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360403225407506?= X-GMAIL-MSGID: =?utf-8?q?1757360403225407506?= 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: 54954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp333817wrn; Thu, 9 Feb 2023 05:31:21 -0800 (PST) X-Google-Smtp-Source: AK7set+0CDrFbIcL9CjyAu0YoA6uAGKnNCi/1N/0DR/Esf1mI9l4GeDTec10uRHxXItM5Um8kv99 X-Received: by 2002:a17:902:e2d4:b0:199:1eba:e0e2 with SMTP id l20-20020a170902e2d400b001991ebae0e2mr9297742plc.48.1675949481316; Thu, 09 Feb 2023 05:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949481; cv=none; d=google.com; s=arc-20160816; b=B+IPWJVoJmIk9KBJmQ+N1Jgoxg830QLw5pU3cKxjLw7/DH5ndQN4hH0G83lQ2F7NVB X3eDYPdVXlA8gAXWGW1NkQWwDJZju7m5WYLVMyYPM3IOxAnRCI1DCLEDCVSQKmY6uu+k Hgl2itu0QBPO41Vnh6gvYIBk+xjFBu6zefv8oKFmoZJIhd+UKzgZW8GIwqu1GDaQniu5 do8uXRFeTehkUDo+IE1kZufm/dSxgvDzdgxpf+2xaXIgGhTPoLmz7+JtoQcagXY6ZFFS kTwWyXFyKu0tG4ruMfTltWfl3FGdcryHBd0G5nn1yuBOCGQiXwubnzZc/4oU01Qz7Xuu i9wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bHucTcZl/jD6O2+OJrhTP0IRhn3SS+CrVkBfUUo54gs=; b=jb8aVnFkOomRBTV5VUYPoafrV1/JAtGANA7bzZHqDFjGqr4J0BWBxKY4rVFEyZri3P yDN9sBkBIi1CExRvd1GUWb+gHOhN/3WWMGWHp3Oot5d0vEJ++zkUWEuZbYzGMkiQOHCV bB53fTmWi3vjV9RBAzwJXuuD2cq0hLXsFRELd6OSWr2jDh62IMLN0L79bb4Ncyr7kgFP yWBIejTHyNQ5Mt1yp75EZnrOjH2Dzj3Jlnc1VIhIUSxDf4D1rIHr71BXpdzI/HsVQUwW m/5MW0OYPCnX+lKjNVz2pVGP6M8meJqaCUVcwb2iglDeTklWOqwR/TsuYcYF3toswjtk 6Xbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="sa/Ksdyj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a170903024700b001933989d4f8si1890474plh.344.2023.02.09.05.31.07; Thu, 09 Feb 2023 05:31:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="sa/Ksdyj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbjBINar (ORCPT + 99 others); Thu, 9 Feb 2023 08:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjBINao (ORCPT ); Thu, 9 Feb 2023 08:30:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D456A23C66; Thu, 9 Feb 2023 05:30:43 -0800 (PST) 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 5E37861A51; 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360403374970753?= X-GMAIL-MSGID: =?utf-8?q?1757360403374970753?= 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: 54963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334309wrn; Thu, 9 Feb 2023 05:32:11 -0800 (PST) X-Google-Smtp-Source: AK7set+ctY2OAkUi3VAyVwQpqq8Ub9YuUH2f/vGUAy+QLMhm/damnpyENxiBInVimM8hzgwx5iKw X-Received: by 2002:a05:6a21:78a6:b0:bc:bdb1:165a with SMTP id bf38-20020a056a2178a600b000bcbdb1165amr15086556pzc.39.1675949531584; Thu, 09 Feb 2023 05:32:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949531; cv=none; d=google.com; s=arc-20160816; b=M6ngd1x6NghWMPXOKEBZs3ISrZYCSyV5QwPYWHU3DTE1AOUBymOobbEObuA4FChZgD 7M4tWpCTSUgllMS8N80GlpmqFz1wOZIlr/YMaEi2yE084In5lWmK61Y3CuD+jZfeh0u1 +3gzEp9uBxR3DvhSv3hkaTQ+NAxOeZa8hIjo6ZRnsbuB2D8BiRE9de4Ve5owApW1Pp8e +Wn4rwv6ZOs2tA98HSNmiSygtwNDdc4VWxLtrDfIyn0oFgMfXywNB+ShoDPar4cymhNt iwd7IA/eQ0veMtweWo3wz1UpG56f0ak3FgBgLCmQZSq4sMu7hE1jGy0gzPaLohF0w0X9 PoHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4iEnqzAyPyaxxkEq0+O/BusRF5zDVUNekPi5mDAD6EQ=; b=fPeVfK8cVyLWP7Bla4zpLDM6GGyZht0A+gXrmQDp9eF6tf0RPEvIV/Id9+Lf2pBuS+ QDjqtQWQO5ktQ0O//B8PfV+qsoLKnBSqrFj6jW5Ol4/VRVj6K2dsslJ67JiSTJlN8rNw qPJ0OSDItOKUIL1Lpm1ks9HjBXBy/pP/V5Egl/9FuZGXwZsikDmv16pec6Wok3G+M/nj 2MkXeuSMmdwrboJ+mUAl+BcVHnFeXu0dDJx4RFViURleqCpsS9Z3gk0RQaTBRKCE0JAK 3RufbRd0AsYOGVhAIJsn0ChhqOzfBkJHybvQaxH+bWsiRqCZV89pMB9B+xHnVTwDsZC2 QYCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vn3pVq4X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a63b512000000b004c9e4d660c2si2148827pge.482.2023.02.09.05.31.58; Thu, 09 Feb 2023 05:32:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vn3pVq4X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbjBINbV (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbjBINar (ORCPT ); Thu, 9 Feb 2023 08:30:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A5CE5C4B7; Thu, 9 Feb 2023 05:30:46 -0800 (PST) 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 A4CF0B82132; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360455605809946?= X-GMAIL-MSGID: =?utf-8?q?1757360455605809946?= 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: 54971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp335516wrn; Thu, 9 Feb 2023 05:34:38 -0800 (PST) X-Google-Smtp-Source: AK7set8TeWG/jgAFfbJiKQASm4l2eFoZtwQDwP1UC4uIajRgvHKubxnfrubscS0J2PHSVup0tco9 X-Received: by 2002:aa7:8f34:0:b0:5a8:3273:f431 with SMTP id y20-20020aa78f34000000b005a83273f431mr6064759pfr.13.1675949677747; Thu, 09 Feb 2023 05:34:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949677; cv=none; d=google.com; s=arc-20160816; b=yLmYB+C31Lwu0yrG7q2GJ7QUsaogMmuxakGei3OeVkHABYWs+zYSYA3HsB8zmiibFL YJJI3WVqkbT/VOkVIwiO0I/fHz+bLRFxkflYNhvATMFJGBFQr9RAvIKrNIPjEFJeclah G7X3mImCay38Id4JPhjYoSy3cFjSV2FoaaZg5OW1WoY9ejNLOnvXeMWlzpK8gA7P3sel m93MPxLiJGO4xI/W7bAuyS5X9ybVk+KBvzwXaqeVYBha3GmlXIsEcC8LGTFYIpKGvm9T Odx8mQfNksWUCYRqHA4XJbdem7nOkfsY4eKP6lzkeAR4GGoLqsrVCnitLvVhAKSBAzBa IGaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7O1rXD8xtC4xlcq0aAtDLbR0EV9FaC6n+HxYvRdAa/g=; b=Pu+nBBfPnFUKGwnWwm79u77hw6MQ3PC8kYX5S++V7usJRcShtY7hyVH9XDGT+1ZOwK xYVulZSpHDLZ9em5f3DzWOQbQhfUydxJAR0FMZ22LTDncHye3hcinYd5Pih2lb9faD+k YnRwKeB2JGXaxjGgxHeOSF45Q5MgGO0jfkn9rEMMsdMKdkCIyFO5zE0er3dKN0XEYgdO /wtuIEVrDSgqZJj5M7EeR9hPF5kw0XSqkf4CH9sLbXNy8Nq1r+4A6VTyYIh/e0UO+vtB IvzjedphNwu1yZsER7mwTBKtgTgKbEA595SUQnNZqMKXNTwAKy2zrPaGyM45ASeR9FWU mg/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z2LJ0U80; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020aa79ecb000000b0058e23ca0d55si1767059pfq.248.2023.02.09.05.34.23; Thu, 09 Feb 2023 05:34:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z2LJ0U80; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbjBINbo (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbjBINat (ORCPT ); Thu, 9 Feb 2023 08:30:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 168585EBEC; Thu, 9 Feb 2023 05:30:48 -0800 (PST) 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 B9D2EB8213A; 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360609376699849?= X-GMAIL-MSGID: =?utf-8?q?1757360609376699849?= 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: 54965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334354wrn; Thu, 9 Feb 2023 05:32:16 -0800 (PST) X-Google-Smtp-Source: AK7set930AIiLXmlNQE4FAzyJKWGcUulU+IIx8wrn17i5XPhEcNhvfTiO0j20TjR8mZiOYRRkH9n X-Received: by 2002:a17:907:7213:b0:8ac:8705:c497 with SMTP id dr19-20020a170907721300b008ac8705c497mr8972929ejc.57.1675949535884; Thu, 09 Feb 2023 05:32:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949535; cv=none; d=google.com; s=arc-20160816; b=BSA/oumJDoBVCCvDDwFPUabsJt1o9Fet7Ei0Wo7NKXtown6y6O0A8UZxYmXwjdEnXq pjHai+GY3qsOWKHDVpka+z5epeCs0g35cPKzKWUYKUq1xOODyQl/IOKd4qJ0zoF47+ti VlrcrjMLGQSPPUjKMOwyJUm9vIkQ1jPRzuAfZxIrJJL9D2/WArAEq0jLqBUAQKX4z0B3 o28PjPPkvfLVChvK6NeK4bGs59oliOzyGQEgP0vuDFrTJ8SUiNebtBiSTW1J+tNGaNhv Hld8pPmwNrZrZi7h0lGDr6WvyRA3ODCdASQ3YbkNvHKQB/Jtdi8CgFLK8OfybQQtiwB8 kdJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6MVqYVOZ8At+OPKxfzdkdY6d9hWYnOie3LiDQ3zXj5c=; b=vO+4vzQ2RSYx/3WkGZsUBjJCPTh2+1+Theg1xnti4lSAUYU9SkBiarJhteh2wQYcnj MHZeekfF++iZ1t2ttq1ugfIqx7Cxd918cTcz5qfQnzDTk/GbpKRH/h2SXVDumFf9iMtj bat4I/QE4wHGLdeVeSnVlguOkJk1E75yfJv3tMwPLcM33gfhaA+H/X88AGqQqpp+AHpc ksmubCvx4MznJenWeQRNVgjIZ/r1blLbhU8TV1jnLrqoExKzk5Xk/S/wdHaKieeQ3eOj f9zxbe7TxTXTbQR7PsSp9LrzwKLwGmsSIgrcW/M6LkxQNzMpF39STk3M1xDX7X1M9nTa qM4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gKWwTMRA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id uk32-20020a170907ca2000b008966b5ebe4asi2182895ejc.883.2023.02.09.05.31.52; Thu, 09 Feb 2023 05:32:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gKWwTMRA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbjBINbT (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230220AbjBINar (ORCPT ); Thu, 9 Feb 2023 08:30:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D6ED1353E; Thu, 9 Feb 2023 05:30:45 -0800 (PST) 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 2CF3CB82139; Thu, 9 Feb 2023 13:30:44 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360460557885334?= X-GMAIL-MSGID: =?utf-8?q?1757360460557885334?= 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: 54955 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp333857wrn; Thu, 9 Feb 2023 05:31:25 -0800 (PST) X-Google-Smtp-Source: AK7set+q65FcPAI2RTcZFQu9iGgjD2kC1QE1OMqvugz+xlq7ig3Mpt51hZ+N1YNxXPYXiR3xTuBd X-Received: by 2002:a17:902:e411:b0:192:c36c:f115 with SMTP id m17-20020a170902e41100b00192c36cf115mr8045854ple.66.1675949484720; Thu, 09 Feb 2023 05:31:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949484; cv=none; d=google.com; s=arc-20160816; b=TxfV3q+zMt77gp06O+xUoRgn8URgihBsmODhJq3eh2dbIYaH6Ix23L6hLb5f2J2Bjm wzgJJStTIOSxi1WaDPJ9qmeJWmv1ri8t7yDL/1Hlsd54yeuq4Uhici8jb6yA8i/X7B4f J2vp30vYH68hedxDiAosumlGu2RIBzDQ8Qf9z8w+QCrcp1Obx30ONcishkGcHwTZFC87 6hrn25lr7Re+oDSoFQreiL2tC/L8uRweWeUiNDVWgEShA7QDWCvKP+IF0rSXceIJh4gA Iu3wevFzc2UHKQvHKdpzxMRQ3FHTOcLfhp+nmGtcb7fXX2KAQ6t+zdrci+B9OgBytS1M /Drw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wqKxg6eKeUjkcXnaNZxTgfMAGMC9KnoGB2w70hapKkM=; b=G8qYyJy2/OKWvBT5j55WXeZy6R0QtyoHUsUvRNeKGhdusagG+9V8QAcegU0LbJPQcq eJmID+r03QZ6V5EeD6ySLe2EZIZiiLeOnKai0DMWbElRkB3Oaqqyxn1yaKriv3iY/R+E 2qgNIrtbCYPpbStypVwb48sDgt3Ui6ULj+IY2nKxK9YsJMsYjuM5UMAoYypDAQGbhQNT TtP1FpQAk6xPUXLYdLZHQdSSBc3E6buPzZme+wwWk3+jNbUndd850T792g4x80RNiXKu 5aHZoxFaXYojmZyZSed2zDL0dLpSymK7SOUio81A1ZJfUdtnML94fPvMlFFANhwZQ9GY 07BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N12jf362; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a170902da8700b001926b94d6b8si1987188plx.356.2023.02.09.05.31.11; Thu, 09 Feb 2023 05:31:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N12jf362; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbjBINaw (ORCPT + 99 others); Thu, 9 Feb 2023 08:30:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbjBINap (ORCPT ); Thu, 9 Feb 2023 08:30:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CE2B5A901; Thu, 9 Feb 2023 05:30:44 -0800 (PST) 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 0A31C61A87; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360406862400709?= X-GMAIL-MSGID: =?utf-8?q?1757360406862400709?= 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: 54960 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334208wrn; Thu, 9 Feb 2023 05:32:01 -0800 (PST) X-Google-Smtp-Source: AK7set+liKmd6kFe7a1hNA6fMW2rGS9hkpJaqDQmu/mTO+8V0iLR5IhoH2H3Cte5UeN/ehv5eUjk X-Received: by 2002:a05:6a21:6716:b0:bc:97d7:3cbb with SMTP id wh22-20020a056a21671600b000bc97d73cbbmr8585756pzb.15.1675949521159; Thu, 09 Feb 2023 05:32:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949521; cv=none; d=google.com; s=arc-20160816; b=XVABssDduL+ZNbR2JtxJn/y6XaF07rMx0i5Uoe4PFzb22+4U1RjEiveS09pFi5j4Pr pRNDdChNu8SMKNVLfeRDA7H5eblyQRnaIzFk4ujwipvQtblKwfSm0eh/S+kJ0POaGZV6 Gz7VkkyV401yAMZWq6iWHPTaW4KyjjMI4Rg9hiWdjxzf9r+TfMk5Rb4djlHtWWdVddWo AKVEBFFe7ENKziayRegwdD1qP0faUTk1r05ZtgXWhQX6dXRhZS4VYM7vUKujjRMoovX3 +wYxyZ5mUoUpb1Txgyg8V7LjKcJegz7Lq5eWPyvSB5HZfi7o1ALivu7iXfc+FtLDNjL2 XqRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZcGHLdfI5FBJk8hmMRh7Z3wORI0Pz378ZK7FU8VECWE=; b=aw5lpygYZPKrCHNDD2jdDip7/z9ywrh8NVIKg/XoeGYaEu4z8det9KC1ecx8KPghsf XZDgrDdXO+kzwih6kpgXtRQSigoKiWLa8kKac1xeTZeqpQYa90QYJ2L/snVllXznte+q qDYn3gkkruxkSEta+5jfnUn5su5s5wlGHjLERKlj0R4HD7cbkSNbr3zCK4k+ThNjmbB5 ccGy6ixA5DIOolQF3QUZ7ug7Vtsn5pcGXJPx3DoDbZNZiqknRBSZkaGBkGMi8hWugSbW C6U3v8bRvblc3/kbZWe8ZVeNNA/YGieF3as8WsAhc9GKdJBddxtnGymhAQbL7JlJyrAJ mbIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kNUJPPGi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l191-20020a6391c8000000b004df2f0ecb61si2128690pge.96.2023.02.09.05.31.47; Thu, 09 Feb 2023 05:32:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kNUJPPGi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbjBINbP (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjBINar (ORCPT ); Thu, 9 Feb 2023 08:30:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A3125A901; Thu, 9 Feb 2023 05:30:46 -0800 (PST) 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 B901CB82130; 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360445255572387?= X-GMAIL-MSGID: =?utf-8?q?1757360445255572387?= 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: 54956 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp333973wrn; Thu, 9 Feb 2023 05:31:37 -0800 (PST) X-Google-Smtp-Source: AK7set+1s5AWI3M9tfSmrqU+ssJLsSiiBDrlcqhvvqTI8zAg8ozBCxHc6lZK0G7IPuZf9bsyS5nN X-Received: by 2002:a17:903:1245:b0:196:780a:ada8 with SMTP id u5-20020a170903124500b00196780aada8mr13170189plh.6.1675949497256; Thu, 09 Feb 2023 05:31:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949497; cv=none; d=google.com; s=arc-20160816; b=qQaSbXsaSp4/LP4JLOfDmCObeKw6Q5OIZ5msYuDzs2bQ0VCr+fjDX5yrgd1OzBBMRr 1hy/YShcIt92Mv4vz8eGxbqvATyJv+KyHW8+VBdg/nZUuiW2oenVT9IjAQ/maVIsMM25 TwL0ZUg6u3cuorA0mL84TmEhIbCCE0QkqdaGeqOLbaGVpXMqtZ2nKGx1q+d+/cH6Wf/n TZJbfYWy9LgqHGn3g7pRsiK9cmUKiKJuDY149WXJG+uBlkmqESTAGTc8126W8kdQjTnY dYyxRLvviELKSoxu4JjrwLEr+3DQw9WHZw5JadxHKYUMMUcWCniMypa2R/6i27W9Yj6I Y17g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ooAKbwn23yw9nMjYHQUZWk1kitePmj2e1Qh5Rd+flYg=; b=wqZ0Xl4rGfHrT91qliDDHljREnJ3Hb7Qk4bL2IIQrd93J2Zqz5YsIInTsP+GWTaxTk RiOD8O5aXx9ygKoziU94KM8/FjAGGQuEuPDnLTIAfusj+B5ksxZKxZzDLZaXyTvotuYm cncTg3aLEaWeIV2Ubf3VZz9pgihEB06yit5FdNEXVFTdqmAuv5zzSJ8yU4xkJbuGqxrI bVGloCEFhRLtNYFeqAaCSuPw6N/6lpDm97meAebyZT6U/EQFe1+0gpkPEjgMmNGePwRj jQsFB3eaOw6hItKifvEWjca167h1o2vGe5eBIbLVY/sHJXVUlYUhrO9YWwTBrwI8dztn V0IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="izkiq/wi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y70-20020a638a49000000b004d21beccd9esi2073168pgd.498.2023.02.09.05.31.24; Thu, 09 Feb 2023 05:31:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="izkiq/wi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbjBINay (ORCPT + 99 others); Thu, 9 Feb 2023 08:30:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229730AbjBINaq (ORCPT ); Thu, 9 Feb 2023 08:30:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92B65A9F8; Thu, 9 Feb 2023 05:30:44 -0800 (PST) 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 3B55361A8D; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360419680400151?= X-GMAIL-MSGID: =?utf-8?q?1757360419680400151?= 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: 54970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp335211wrn; Thu, 9 Feb 2023 05:33:58 -0800 (PST) X-Google-Smtp-Source: AK7set+XTBNVAfNiDvlOgQGMQZH17Rtkxn51jrst5m5RHkFb7bbCWylsyKKvX3ebQ/2Ym8bQdfRI X-Received: by 2002:a17:90b:3b87:b0:230:9f49:4335 with SMTP id pc7-20020a17090b3b8700b002309f494335mr12519663pjb.11.1675949638543; Thu, 09 Feb 2023 05:33:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949638; cv=none; d=google.com; s=arc-20160816; b=FnQ/2swFMj9EVpfykYEbLVoYiz0+Ver9Bw33DohZaNkyey8Nc+fLF99KLxbFbxp7oi HkPAnGPOtBldVCu45fYiJOtddTik2x5fw1/SeUNBAxEkWQj7Ikv+9mIBkpLki4rjVLNk qYSk7h6B2icIyZuESjziaO6f5nepMoXuE/FDBYuo1R5YCQw3z2aJM7tKQwxWjvcNCDEf MxSeAR0UkKByEHGea/WYnQIBcAylhkhU65OpmGrJJAoYwebRuh7JCRw7iAouLKIipZ9n Bjk6cXHi9M4O5CnfeNX/MewBfovpzIW0uTAeI/z7UnPzTIf84IRfFoRDcnB53F3nGwk7 QXIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E0HUQMWmmY1cRI6tGlY7IiQ1UYsiYLL7/Vga7EGjZLs=; b=Mxfftt5kya4CyCijXMyxNWz2j1Fmq1EqRybwmNoU/W+zweeF7PNy14i+JJwNQv2W+h R044svcdOyoEWP6drMJiBuexmUfGzu0GH/9Gze9ffEIqwtOn+wrdZ9aYFff6/mxrhx7l 2XA1F+EtGEZJFzMJAVzgworSoyoFzBMO9h07I5bMo2ApfgZpjVKC/ivryc102XJXdceq FwAlH7m/JvmMKHyNxGEHR5Rc7Iua2TnCVUUfXpxb7l3lrxzj+L6Y5auNkDDxRv7rfPnL zBpdm6tvHvCdqBRVnS0P1vaJeEjpR6tOuQ65PFXibY8UIR5ydfdYNsUL2ZmW/J6Sv9aQ 55eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CMIxVlgD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q10-20020a638c4a000000b004faeaf65ba0si1872307pgn.800.2023.02.09.05.33.45; Thu, 09 Feb 2023 05:33:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CMIxVlgD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230464AbjBINbm (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbjBINav (ORCPT ); Thu, 9 Feb 2023 08:30:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 343BF5EBF3; Thu, 9 Feb 2023 05:30:48 -0800 (PST) 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 61315B8213E; Thu, 9 Feb 2023 13:30:45 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360568197587268?= X-GMAIL-MSGID: =?utf-8?q?1757360568197587268?= 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: 54964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334329wrn; Thu, 9 Feb 2023 05:32:13 -0800 (PST) X-Google-Smtp-Source: AK7set8jWFmfep9FKci/dCl0KB6kqrTTFEz8sb4MjsG29DTjdOPWERk1WP0GELwNuJW002UgyzJO X-Received: by 2002:a05:6a20:3d02:b0:be:a689:4993 with SMTP id y2-20020a056a203d0200b000bea6894993mr14283182pzi.54.1675949533413; Thu, 09 Feb 2023 05:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949533; cv=none; d=google.com; s=arc-20160816; b=W+kgK1o5/5UGHeJhOHPpnOxFaAiM15MCC7CRJzSiBJ2ylOLSgBF7FjiEWJG/D4ew9H z1SWZeH5nYfkBm1hynjUff/TwsS6SdYfknODZ1wNXzYqUIeM4QJJkzuohWjewA9+MA9y 6DPmVdrVqMnuFCmV5dR8C5bHBpDHq5XSYdnV4ngkPhCUcSE7grwJhd4p+n3mMlCWKob6 pOfZstxD6sR36eiDQpAervvHB+UMz6Zx7PSQhPm3uV3aHa71PqIeDZudsr9O/2345Pjv lN9RzGWsiKwENTsK2FFTd4ZARrKyMb0BZDoRFf8VEdYGFfHrawDqohj+SM413zWuEqNZ mNUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XtPGG1uv1CQQKI8lKgl/+LtOPauYHAcD5O2XABxw+xk=; b=xVD1C4D/BbiOruwSWcMqSAaTPYeC72CpbdjnZ/wrnNdewfOudKlh46Glypwj7tlLVC LJsiJwe6UP9y69nSLG1S/q0oemgmf29VAwoks39g05NKNykHPeZrmM/Tw+RfA6weIOyV UEl37zCzDc0vYapCinTh+EHUYAf7Zof6eMO3LHgA7eemRRF26vrHNyUmasxAX4hOwQ7L kxI+IpNUSb79SJ8LNvpRNtrAtagr/s9v7h4aKvhvLI4aeXtRcVS9bQZ0lVb7LyQD/ZJ1 PENQ5p76XoHaKpcY3r4hliaQ2g5MbX8k0/m9cd8X4ptvq5wKs0IeUPbWDfMo8/hPTm55 W+tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rmddM9Be; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a6566c6000000b004ce425ce685si1989062pgw.7.2023.02.09.05.32.00; Thu, 09 Feb 2023 05:32:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rmddM9Be; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230308AbjBINa5 (ORCPT + 99 others); Thu, 9 Feb 2023 08:30:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjBINaq (ORCPT ); Thu, 9 Feb 2023 08:30:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D67615C8BD; Thu, 9 Feb 2023 05:30:44 -0800 (PST) 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 6B91261A97; 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360457848625914?= X-GMAIL-MSGID: =?utf-8?q?1757360457848625914?= 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: 54969 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp335148wrn; Thu, 9 Feb 2023 05:33:48 -0800 (PST) X-Google-Smtp-Source: AK7set/YY9RpooW/vA2akkNjFlPhVoSWJ0MyxuIZ+cTdONi9po1lR5UfDcbEcGiIXNQOVB/y+5ts X-Received: by 2002:a62:64c1:0:b0:592:48ba:9f59 with SMTP id y184-20020a6264c1000000b0059248ba9f59mr9917078pfb.22.1675949627993; Thu, 09 Feb 2023 05:33:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949627; cv=none; d=google.com; s=arc-20160816; b=H1bIkLrFXhLP/ALAOaz/gxJbdis5rF3pJvX/pVl+6nHWEzLhp5UcqW2OqW6EFGUf1S lnNUcbIqTQ0YNA8WBuN1XpG0No3PtPI9skfaK6fivwu1vNSwFOuxyuc8uxts6phC+j/E 3VBxJkJx9x0BRVuwv+T7+7acLZnkz+e1UzgajS7TymP/sOSrTR47EFaqc5Fruz9O/DLx /20G0YWDy9R9Xc9xNm4Gfi/mKPSg+XLgjajRW9yPKZXrfGqWZICt1LSNO1s/yCaeLoAw 4I7YvYMdY0aHwOKvwrrC/aB2VQkNdDHhBTV20vyDi59eealX+RgS0tSJflCeRoScY+D8 kzaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TibUMBpWjM1p7foBzCFoU2T4h1a5SpeLG8kzn7mVBbE=; b=L8wE4hPNgv7/cvk2WV2T/kOdPfSDjO8M0vBBK7t1uV8/6+EVSkjDd6mk03QQWZFQdq jSudWqjgBk241wD2uj/8rdkvPxBmZjS674sGkSnFqD2EDhWu7BaFW7Us7FQfTrgdwJY4 JvyO9tugICD4u8HydBBNnSDmlLdhZHSdtKZk4CMsNeGlO6zxi9N46HNBEeKbv9otdDi7 O4anDtW9YUGUmMGEHXEBvpSRpW+fKCdIWu2J8VP+X0IvwfFN/w6zD/4zIj5VpF2Xs6bb N+Rp4GkUFPthu+IxdcTM+4DysutA/mkcd1Rb+VERJ+6YhrUwBrNImxOCLbH0dia5oNKk t7HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="slw/hj1S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a621605000000b005a8447d2d57si1918195pfw.112.2023.02.09.05.33.33; Thu, 09 Feb 2023 05:33:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="slw/hj1S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjBINbj (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjBINav (ORCPT ); Thu, 9 Feb 2023 08:30:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A9E5EBF5; Thu, 9 Feb 2023 05:30:48 -0800 (PST) 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 98DEBB82143; Thu, 9 Feb 2023 13:30:45 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360557286710405?= X-GMAIL-MSGID: =?utf-8?q?1757360557286710405?= 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: 54958 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334135wrn; Thu, 9 Feb 2023 05:31:52 -0800 (PST) X-Google-Smtp-Source: AK7set85o9m5BfVnv6l6RQ8Ai6KDR/q+Bf1QDNfTWs54AqhQyC7WA4GJYoIPlSVXoA7lqJQE/SxE X-Received: by 2002:a62:5243:0:b0:5a8:5271:5a2e with SMTP id g64-20020a625243000000b005a852715a2emr1800705pfb.0.1675949511992; Thu, 09 Feb 2023 05:31:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949511; cv=none; d=google.com; s=arc-20160816; b=vS857ihNNcPOQKm0f0Xmzq+IDAIOittQJN6XaXIwsel66fhjiy9gtaI74brqwWIJ+w cOxAdgiC0VyxGl7wnbKYQ0+TAoRcoOKWwk+6hQBhk0Nn2+XWPRX5pDhbu86cR645Dusy fzK+VTIcDH74vAEhdMleTVNYYvJKtCrXdLsyo4gbc9ACC43mfwpOGgbxgW66OOipCprK cRGUQ837eTJOPXCCEp3Rt+vIIS1KIqbDSYM7hxs0LHUIn1E45dRWXtSjP5qyHp9s4ywh E3KHLsi3sBUZ2PAxPO2zyJJlPwr6Ugv/R7Dx3aQ9hTqCDa+BAX6IxWMsFWd05gA7sa8e TTKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vgc8FUquq3+r4rz4cJ4Ol4+2ak580W8lYszkhVwD6ZU=; b=OOu8gQkJtW8hhs3CGxHYuySztuJfM7fmOhDocrtFfOf1XcjfZm5oSdw3+3jb5Mm4l1 +/cyDLeGn5TEbI2DxqnTIDgoptWvQCGsAL2u/OZZUj4Z6A9hF9ZKO9dYHKAUgVh4spYI MxJDj1QB5hNsMALRiEkMEIRKLxzMMCX5A7xnoNXOfO9p2KErq5aMdvXBpSprlG0P5/28 DUgoHV+VZb6IX0Tl8FF5C1lypOseqeKMDvOJ4LcF0qdUzkDL6iR6WXZE0+9AmxJApn8L 538CszB+k2Y4V3DHuXAMqSg+l5SrsscEVYElspmgcfrUSD1mLIAvxSkuKt3aqu5WwNrC a/8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="nYyAS3/j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l66-20020a622545000000b00593f84442b0si1517954pfl.283.2023.02.09.05.31.37; Thu, 09 Feb 2023 05:31:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="nYyAS3/j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230189AbjBINbE (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbjBINaq (ORCPT ); Thu, 9 Feb 2023 08:30:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52CC723C7A; Thu, 9 Feb 2023 05:30:45 -0800 (PST) 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 DF6E661ABA; Thu, 9 Feb 2023 13:30:44 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360435678802000?= X-GMAIL-MSGID: =?utf-8?q?1757360435678802000?= 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: 54966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334418wrn; Thu, 9 Feb 2023 05:32:23 -0800 (PST) X-Google-Smtp-Source: AK7set/FJYTEUmJZLzQMVbtSSTZReIKjW9dHkcNOEr9gPX+KjAY4jrhX34tIACzK/yYVaw4uW3Pg X-Received: by 2002:a05:6a00:42:b0:5a8:4c55:db81 with SMTP id i2-20020a056a00004200b005a84c55db81mr3594314pfk.16.1675949543138; Thu, 09 Feb 2023 05:32:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949543; cv=none; d=google.com; s=arc-20160816; b=Evk5xlygGGXutlqrqi6dEXBT3tRe3MplnMJrInIcHUv5mFv+R6rAW1FOMLYVBC7oSw 9sGSFlaWjPHC6vv33SZoqnKvzr6IYrS00cYzhhPub6x4A8pPcnHYf6UQ7sLRO76bRer4 GeJ4aNnlJLNHk9fpEbArOF8xkMWMefJloi1bTEe8E8EVYoP5Ib6mQjaEuyidxVz4aHFU 98BiSVpG+79Nl1Ue/0q2NpFGMlOVVpZ+w2erZNdtq6hFCVaxQfbxxicrcwswOP+9owZN /QNesTEHVrQ+bv4XUQtfrIusTySHi8hKY28MBuMM/+h/+KeN7S15S1EETbv7fY6oZ8SZ yAhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZiEgq4vW5UyxJkWFCdCqPrYjI9W+MxiLS3baR+c6jdQ=; b=YRRVDbPBZYEgsn7R5kCWZqwAczfkYZT49hbUXPQNxd3bhf+l6ak+ymXa1hR3Pbzs3w xE27xIBVHbUPIwikcltoXT5gTSohTbfayNopUunQAGqXBrSsFJzUoioH0dq675pY7VnC ypzpfPYIpiyFICwgi9OSndf0cPjOJFc7lJFcFNISQzdiBw88XbX8GVmB9eaYWz4Sv4xk ub13oX6LQVj5XpJsxmhQcS/T5zD1oz7U0s8lLZ6ZpztSKFDJSQAQBn5lDl0jGkMh29i7 5/Hkzhzr2d1V1+3yjBdJV//JRtAEUoWn/QUAGytrwrbhJ4NCCqNBsNfSyl/kPfa5RYw+ oltQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="quO6Uv/A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020aa79d91000000b0059072f087b7si1787340pfq.135.2023.02.09.05.32.09; Thu, 09 Feb 2023 05:32:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="quO6Uv/A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbjBINb2 (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbjBINav (ORCPT ); Thu, 9 Feb 2023 08:30:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 846A15EBF6; Thu, 9 Feb 2023 05:30:48 -0800 (PST) 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 9EB6DB82145; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360467987459938?= X-GMAIL-MSGID: =?utf-8?q?1757360467987459938?= 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: 54957 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334076wrn; Thu, 9 Feb 2023 05:31:47 -0800 (PST) X-Google-Smtp-Source: AK7set+9Sro4tHX67iLSFt2KOcor4n0yfy+KtVpsq4A0/pYPL9XhSlmVrudxAW7okHfs/m9ET2Ci X-Received: by 2002:a17:90b:1c8e:b0:22b:b82a:f3a2 with SMTP id oo14-20020a17090b1c8e00b0022bb82af3a2mr12516779pjb.11.1675949507188; Thu, 09 Feb 2023 05:31:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949507; cv=none; d=google.com; s=arc-20160816; b=lA7J9Q8oLsGpzZeFzhZQcq27gPvOlmOKzZNz6F4/fgkMeDPXvqBc7pQ3+weKllG5rQ dcoRZGbXTeH5hpok+tDjupOa7rfw1r1KazwUR4SdAs0gSM8EHnPFnCWiq/XmNG6JezbA dBO1Msv3luVDhPtvDwCGkSEW2bArrNrNT6IAQ2g9bxEd1+/cp0fKHtlHrAApjdw2HJ5C CMRLdeHNJV3R9MxrM9m6amXBN8I622xV41h6S9Zm9qPvYRDegjWJT6CLr8KIi9RozrXS rVjNhQ3zjlr4/8OY/cg2ckT5aePkkLI+1NQ1ExtMpS1fpxxTxFLi9M7n1OP3Mw2V9uFs KUkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KPMTVtpiOOGkS0V4jpVWs5c+tP/7RFHyRduRqBDQ3iw=; b=OdHmCjUL4l0PN7f+UcsytAbeiq5f1B3Oaj8s6gPSAeEd3VkkDVsxAULXzkPrWi+V/q OCm/h/jth/pR+9sKmCyaW+xXlFYxU3Os3yPZziHyPZfpOTkQRiPceGvRhRaBBCbbnV5+ bk6LZkheQrG+lVaXHJCKv0Cm2Y8j7iSeoDE1YNwzkyNJgwlRDXiLNDR1yFW1eXPwwpkl DD5JeQq29dF5ntKgzLQso3wCwdTCaJrrM/SIjmk5QyPS+XMF6EoCyRSxaUHhaoPPv3hN 31E74QQZkI1dHSE8b9+WOvs/wTf29/YZVZed1D/bi72wTfmkkqeqwv3WXu5exxc8I2lR g7Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cEYfbj+O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e29-20020a63745d000000b004780e2b6fd6si1990375pgn.362.2023.02.09.05.31.33; Thu, 09 Feb 2023 05:31:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cEYfbj+O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbjBINbC (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbjBINaq (ORCPT ); Thu, 9 Feb 2023 08:30:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 582595CBF9; Thu, 9 Feb 2023 05:30:45 -0800 (PST) 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 E3D5F61A51; Thu, 9 Feb 2023 13:30:44 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360430826079253?= X-GMAIL-MSGID: =?utf-8?q?1757360430826079253?= 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: 54968 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334965wrn; Thu, 9 Feb 2023 05:33:26 -0800 (PST) X-Google-Smtp-Source: AK7set+XRmT34gRH6EVtr7IghSzBJcKL1mMjymRn6zCCcK5pQRhGE9O2k2uNokRLTOBd7l7WSddm X-Received: by 2002:a50:ce17:0:b0:4ab:16ca:b9 with SMTP id y23-20020a50ce17000000b004ab16ca00b9mr3973498edi.11.1675949606157; Thu, 09 Feb 2023 05:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949606; cv=none; d=google.com; s=arc-20160816; b=rNAoi0MRhLU0hQH5B4lPik3u54RKI4/fw6sm7JzYUl7WqY1wxBf0yjnIUKTtXE0YPS aiaGBnUSCkjaRhgI2+SpgGwppS1+DZDl+bDNPJXfYM1Pl3psNMLZvdvf0DmxTL94s5Mr 8Bxh3Ku5fFBAEoVXTlsEq3ocGL3KfDhslQYxVHnxXIKKdLyf6slYS8CIVzb3Iof/S76b oR+vzXBRZ+cdWg/H5s5PJXNXuH2wkJDoGvJlLYB0hJq+2gDYCoGF9uZj2Oc6m0DyLjcR Y/OoJOSI/U9wfp0iGZfVWqFYyJuK8Bcj837oyyvWVTzpUxniqCWb4w7ybS8l3WkgyfC2 2xhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l/ncPVDVkVKNQESREeI7DHVyJeajN9MUTwNZIa0RMIw=; b=J1KwehpxjPRLDBMoNQfRnQC6KebNkupvKcz+GSHEGbd3L4hJ0lGa08+jIXSbB3a3fx rByeDJX2N+B1ibEULioc2KvMC959rFvh5LKHQXqSXL4kWtcGPgm/hFza8MR+Cf2jjx7e 1ygQo1uvwKpBILx59gM5AxdoCAC788/OgKtbllc8Llz0GsBqQFQj/6XFLDs/L4uXGHyr NAjI4agznKQ5YGa+/b5Tkfx0d/Xxuapej0Fr0OTByTWkenxYeJXngu2AQtagXnKXzXXv mzXJB1WnvNBmObYmMmZbebRO8qJd+zasH9dP/dWuJk7nMzRjHoeMDw1CyEMzi/XoqBRT bVhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CkTHK1i6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020a056402344e00b004ab167b1a0csi2500591edc.245.2023.02.09.05.33.02; Thu, 09 Feb 2023 05:33:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CkTHK1i6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbjBINbg (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbjBINau (ORCPT ); Thu, 9 Feb 2023 08:30:50 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A635D1E7; Thu, 9 Feb 2023 05:30:48 -0800 (PST) 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 9D6A2B82142; 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360534140522745?= X-GMAIL-MSGID: =?utf-8?q?1757360534140522745?= 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: 54967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334425wrn; Thu, 9 Feb 2023 05:32:24 -0800 (PST) X-Google-Smtp-Source: AK7set/bVdxPmey5mnmJ44xslJap+VaL+MNC0h2BwRjVzEZkbyGOreF/zOOjl4A8OFVd+Xsu7ka9 X-Received: by 2002:a17:902:d4d1:b0:198:fc83:9139 with SMTP id o17-20020a170902d4d100b00198fc839139mr1060959plg.55.1675949544674; Thu, 09 Feb 2023 05:32:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949544; cv=none; d=google.com; s=arc-20160816; b=pniW1vjn7Tw8Vc34gTuEPmjPsmuCxHq0+59yuvhTqCRQMLXMUL8IZXP/CkMF8KkkMG zvXlQCQFPI2QZvbZmbO5SjLXbMu+LvJx1/4wJLF1FcJZopEl3+SQM7dHk93C/z4lsVWm UXOEBJbAjBFqnb2g+7JhC+EZyV1YeAZBW6fwt05Bg2quAFleJNT08u/bx4ACCnPAd/27 xUejr0YZ6Cf1h0iJrbeohC56GhalSTiQnCTLvxtu0nTKimepsULttlZ6wPfpif3Baz5d egD7oHd9oe9c+ccYCzU4jbu97Zs0jWGjcWUgux6XGu4T23MAEC6p9RDtRy8zmvpWwoJi 0avQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+YgCpmkvMLTzdTntNr1p+J1TjqEVYHAMKPu201u2gXo=; b=xz/uvG4DqExhmPbHcd/z6N2dNIdHyflHrGH3bkbofI4aDd9qwpIuYmLVSZAIDUjJLr jrCOeYSziAHK3SaZz7gDqSRH7IHC62Y1PQUw1jCsXwtE2JI3q0ogZz4T1+DfzS8r9KUe hQe8rhepb4DAlOpxJEJOvrIpVjv4F7gwvOEfsHLEYId7A9L3cto/OzdHX3/9AziJnuU1 jytx+/skqjPEJUYbugnezYWzMeI/pBhvqa+hgGZPsSHXsLC8h0B0dP12KzTfn9HPxf3a XI65XsMA2ZImDNTl2VNxd+4XFq+VkloZR9tjV6xpEiV4J5qlOgrusDMUYrwb5JOLPUde PDDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TpFoR87h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020a17090322c900b0019953c0ae75si2015111plg.136.2023.02.09.05.32.11; Thu, 09 Feb 2023 05:32:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TpFoR87h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230339AbjBINbc (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbjBINav (ORCPT ); Thu, 9 Feb 2023 08:30:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 853C05EBFF; Thu, 9 Feb 2023 05:30:48 -0800 (PST) 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 AEBBBB82144; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360469823954563?= X-GMAIL-MSGID: =?utf-8?q?1757360469823954563?= 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: 54959 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334183wrn; Thu, 9 Feb 2023 05:31:57 -0800 (PST) X-Google-Smtp-Source: AK7set/VwJ+/XMggBmTyOiMRzxy0AcvJqMsIX3R/eGKigBj7pywnRkx1NwfubiYObuHaI+wck7dm X-Received: by 2002:a05:6a21:970e:b0:be:c1b2:514d with SMTP id ub14-20020a056a21970e00b000bec1b2514dmr1591834pzb.13.1675949516782; Thu, 09 Feb 2023 05:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949516; cv=none; d=google.com; s=arc-20160816; b=m+arMjs5EOrH621u1DCHqUkxJ3WpR8N5tJyuO+sCCxM9KYfHALXRREuo3oqTuP7Kid MRcO7piT0n/I1SXs6uk+vAZD8ZNJN+9Q3ilVBMjh4MJIbta1cs+9utFg1pV851RReIxd 0Fgzu6FmP4I8DMVsCjTyb1xFKs2dZUmsgAaMX3bnc6GMgIJIYopoNX3PU+Zb/WK3VO+e 4oZxPB3UasqlCGl+2ZFpF+1sXUBTCRzzBgCTClMQajztYbWp0H/4C/Li/CLIhzIzI9dE aH89TLNJ53rDFpf2kbKCOlV2w5Cf4Qd9noVXPOBCdzRSL52bGrzIFTVNRTzvSnRazHo2 bLig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S9kTyIxZ+OSdmnJM8P4EaDIdgiIISEqxGyW2pKIiLVU=; b=mPib9i7at5/XUS/eCMc1igmrkXdXu/lWT8UT2q/tK1XwPsK7XonKrI7ZOyE/2JV18U iHBVLcZvXE8i4hAGBCWIdg6vVijP8zkQa45r+n47ihqiG8UWUrXp4P9A6AloAMVTVovp dPHJuD7uLhmqrUDzGuTDuhacyq3Rm4ptnBo2Q9hjDe1MhqJIhX/TBh/oIEuNFFa9EoY+ u5YWjsZqwqLBuNhMSvJN5hG2K0R7Z6meaPdfloC0vX0xP/l2J983MbWxaPJlK9CU4KU5 pbS21X+O+BGXCZEBZZI7UrX+1vszTB0NGabcYzhbH+cFy8i6kt8Ma318EpHlq4ATYpEV 20vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xu86u8Hd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a056a00008400b00536ee478380si1861835pfj.7.2023.02.09.05.31.43; Thu, 09 Feb 2023 05:31:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xu86u8Hd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbjBINbK (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbjBINaq (ORCPT ); Thu, 9 Feb 2023 08:30:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 710BE5D1E7; Thu, 9 Feb 2023 05:30:45 -0800 (PST) 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 F07F161AC4; Thu, 9 Feb 2023 13:30:44 +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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360440446177757?= X-GMAIL-MSGID: =?utf-8?q?1757360440446177757?= 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: 54962 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp334297wrn; Thu, 9 Feb 2023 05:32:10 -0800 (PST) X-Google-Smtp-Source: AK7set8GoztsUKv5nIJpaRNq/DbUCFPJYzJ+jFqg9CpDcMUoFpJtF2IRcJN9busYZL/HAEbuykS9 X-Received: by 2002:a17:90b:1e10:b0:230:8c47:92e6 with SMTP id pg16-20020a17090b1e1000b002308c4792e6mr12265384pjb.47.1675949529841; Thu, 09 Feb 2023 05:32:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675949529; cv=none; d=google.com; s=arc-20160816; b=ykwBbMCCIpD0ZohOOOaoSgGPJDyHd5b9GWksm09aAPIjsIt1RK6LQe/zR7vTS/y95Y /aONM5dsZ/RA7YXw1YOiZzoiWEd2Phg7tuZswbWPxwcK3zerCOivSQkyZiYB7a4eu8oo +0Fq+2MX3TXsvhz0e5lvCEgpGnCccMExS1XjWybFG5H4/liC03zqngw4XwulSdEmU1FY eNwhqq69U33n7ySNPRo0RK+yQ55qQNrxfokhAMMTCVDyAhvts+rvjQjtP9GZGfIl3KyZ 3m/YUlMByYg7BOFTgYHZQPPO2fPh4+44+nJgUhO8n5qdAk5BXa+z1r+R9+u5xY9/F2X0 gF3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MNcnWfhEIGCMAepYSkWrBAWG+i0knAu1GR2tm9v0NBo=; b=mJVPhZ8v8nvoAfB0g1XATfYmoFz+Sb/n8DhdefVANE94eMqKkehdaw+mvvC+dUm1ed z65TLNWGakRgfNPv5te192q68Hi/K9aVbdbmfp3wWLynxPazH5FHWfZEP4fkap0S3zQA Yr7AYOPLmpSgFk2v3cFcT/UVONGChaf7hdvoFFgF3tTAlDyXJBxfy22waRjR4Pt56LnE S8Qk5C+uN4YcsVb17AJO4eyDNHaJAH3snMp9K8UYr5WN0m8IJxZ9WHUhR4YKVKXDGkZX ic2ufNnZZCFQpMFXLJCWQ1iaoQPUX793dlTFJKSc83UqR6dWNbBLqY0ANYAROC+96Xas cetQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vHp8tA5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a17090aa01100b002309010cbdfsi5544245pjp.11.2023.02.09.05.31.56; Thu, 09 Feb 2023 05:32:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vHp8tA5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbjBINbH (ORCPT + 99 others); Thu, 9 Feb 2023 08:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbjBINaq (ORCPT ); Thu, 9 Feb 2023 08:30:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DCC35C8BF; Thu, 9 Feb 2023 05:30:45 -0800 (PST) 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 99EBC61A9F; Thu, 9 Feb 2023 13:30:44 +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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757360454072869035?= X-GMAIL-MSGID: =?utf-8?q?1757360454072869035?= 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);