From patchwork Mon Feb 13 10:42:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274692wrn; Mon, 13 Feb 2023 02:43:57 -0800 (PST) X-Google-Smtp-Source: AK7set+tTeiyt5uYpo8r9GFImV6iK/b4nVZbfpb5l+WiLSLVTl381GFs8YoOAmL3ISDUxOpoJeBs X-Received: by 2002:a50:d6c6:0:b0:4ab:1c69:5c4 with SMTP id l6-20020a50d6c6000000b004ab1c6905c4mr15186097edj.26.1676285036731; Mon, 13 Feb 2023 02:43:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285036; cv=none; d=google.com; s=arc-20160816; b=pHTOYbGju+7dy3oiNMcRy64bgmFg9txxg9s4rpy5P87lkGBsXeZuSDPtGfERsgvhHA Z9A6qlTndf3Lx+BmwFCZNIEKuUuuxiUkDX7j1JZ9SdAdWGEhCcRI0WWUiflXToLnBkug YoJYoCD8quxDAmDIwKBN05WrGWx0Mz837E4WneIqoY627iNBNQcUMWRV6fHd+xjlRe0z 3+he3/aV8Eu5oHL+msl3jfh5Yw6xG5oMjG9+7UcuCCC7ieafaW/KU6EkmcmUfbS1bcIv vip13qVrlj2xhWbml2wuav1q9LqllFlvI144Omno3LChveRolp/dwO1ywskJXD96JwXQ Drrg== 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=Z8E+1i83iSOcNEKulvPlP7XS9Ul2wYB1YktWw/vAusdS5C5jwtEcqbi/AFVSDiVQ6Z NAcC4pnVzghyt4r1Say79pOuAZImzvArjWkabqNYwOsVlbDzULjJH1sjiXpAF5YcAQcP s/2B3PDJyCZpD74hSi4KBKqWqiXDrpPH0j8pJksVJwXHn7Dj49kZFnp8ICB/So6vBPEF CeH9TWPZ44P58oLu3fD1FWEYOZOAF05ydFbw2PjcwtkKddgpaeKimFWcvG9FNOG5yCvJ 2gOq1HfmMGm3QzD/q8me4QjSobcXq3+gMdzAv0Z6FyM+4WU60Mju9s9Hoy7Q/lxCwu06 kwpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J8JmyFZD; 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 l19-20020a056402125300b004a22cb2b970si11865960edw.535.2023.02.13.02.43.33; Mon, 13 Feb 2023 02:43: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=J8JmyFZD; 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 S229841AbjBMKnV (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjBMKnS (ORCPT ); Mon, 13 Feb 2023 05:43:18 -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 B908C15C8D; Mon, 13 Feb 2023 02:43:17 -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 2CB2960F83; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7436DC4339C; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=tBqk6KgtGtAPTVEMAxcaZIoN23hQcgfod3xymk/Evn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J8JmyFZDOQ/VlOFXXXAXIsgTHc6eS1nRIwrxjtuFja8L1KQuiwz0XmDoxXYl2gJQk fVaXTHx9RhOuqZxoK5vBKO6/bunDNKw2+q71FE3I/dbARWIKJu9U5DnBfoFkBS82+3 4mOHsvCBTUM7DLa+oWN/+f6pqmDv08dlIQq+gkRzxs0xyEXjY6UjsH7ITeT10pE65v tB+MrNuUh/EwsjhiPTmLdF0n5A+fX66v+dj6/xAjKolq5sDGSAJqyrTIDtACf7eg4r uzivYFN/YiiVd1Ir4uRA/MzK5EO+deZ3ign3e+10TWsNhzQsGsKGmUc1HXNrCVUvaK sCQ+UECB3ETnw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJa-0004WJ-Vd; Mon, 13 Feb 2023 11:44:07 +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 v6 01/20] irqdomain: Fix association race Date: Mon, 13 Feb 2023 11:42:43 +0100 Message-Id: <20230213104302.17307-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712258653621402?= X-GMAIL-MSGID: =?utf-8?q?1757712258653621402?= 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 Mon Feb 13 10:42:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275113wrn; Mon, 13 Feb 2023 02:45:19 -0800 (PST) X-Google-Smtp-Source: AK7set/9vgWw6i4o5RNdVitWziFbRk0uBVrt9GlSOv25FNR8LfZxwR2jpZ9QTIiFIFV4EM0JTn6c X-Received: by 2002:a17:907:741:b0:8af:3b7c:ff81 with SMTP id xc1-20020a170907074100b008af3b7cff81mr19788150ejb.50.1676285119067; Mon, 13 Feb 2023 02:45:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285119; cv=none; d=google.com; s=arc-20160816; b=MvgDXeXfcLifIsmxWf+pChmpIphTHM7/lnE4niB2mMu029rn0hYJmq8MpyrFPMb48Q u4zhodmfx//tcJti91K29DeasWCp3Nzomw0epcC+J3jrwKhihF/rNhkirvujs0UKrEyY 9PtbYCcRxithw3GXGaxFk4XumJxvwI/MfidZziSpRMbgXJzh91uBxy4jGr0gHlp9x5Pb Edz94j+Ib3mehnnki/vVYdfCv+zukOYR/JnbIzyVnmzN4+SeDV7yi2EQPmT1R20Yx4rB jO2zxsLxfuxsg/wxjKD0OfuJlyHrG3weiVYBGDSZhMxzXgnm/6J9HGWCIlqJDEjdI8wI PLfQ== 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=V7iouFSVXHwLETqDse1fJg3LKxqcKIH7lQO7t/2VF1dCJULtD99GKz04DDNhr0TXsp 1BvOZCTUwuNNRWZmB0iMZ01cvf6NfYP7SJUd9m+hbwAi6kIexSf6y8aNLJ4L3XTAyb2g XQ1sOLuKXyVv48AM00P0aQ/yBSbJFioKJKflCVPhEz2UPSVs2/s/waexcXaofw5vOTop 53SGSwAfdWNnSA+ED7+tTJRZooaqzYscqNCWfH1cZUah2DISEgM5yOWhFvlyVJgto3nv /Yyt1La/GQAJDoxsRY1jNhrUrQib1+gU6U58XK11gomgduS89iNqBEyQWHetMrNAZxH3 yowQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lKjnoC+F; 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 mr42-20020a17090782aa00b0087da417217csi14582521ejc.472.2023.02.13.02.44.56; Mon, 13 Feb 2023 02:45:19 -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=lKjnoC+F; 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 S231181AbjBMKnx (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbjBMKnW (ORCPT ); Mon, 13 Feb 2023 05:43:22 -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 057D41026B; Mon, 13 Feb 2023 02:43:19 -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 AE58AB80E0B; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D9FDC433D2; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=JfSDAiRhoTMhnjXtvFRPr7fYgqO70+KfU+dj+kphkG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lKjnoC+FmEs+v9yS84dYp8mGr8l7gzyvXZluDd6aB/dIDmk60rvAiPKSDXGkAQcJY tBmk20LJGlTASexMirQsakdsewBhoLpKBQ86UaM5UtAEaHF2IfGcNXA97QHD3jFRIh VeWrYTZm+k0QEOA6Y18VyjCcGREOGziRs1zpl5A0HCqJR6Tsg/uJdt+ObNxO1CMbkX u226lfkGNdFgvcDizP0Blt9m6CVDNzIFbG8XpBEpPaZUv8vmNJHNF26/7PdkpoQOOK EicqYkarKKw9oCBxVEgsGgwBtZnOW2y0LtbVFJxQjx3G4RhtqKw4NBGAzcNMGO8P6N yYV1/45wGsXsA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004WL-1s; Mon, 13 Feb 2023 11:44:07 +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 v6 02/20] irqdomain: Fix disassociation race Date: Mon, 13 Feb 2023 11:42:44 +0100 Message-Id: <20230213104302.17307-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712345154617793?= X-GMAIL-MSGID: =?utf-8?q?1757712345154617793?= 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 Mon Feb 13 10:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274746wrn; Mon, 13 Feb 2023 02:44:07 -0800 (PST) X-Google-Smtp-Source: AK7set8SPF+7iM0ClS+mMGgq+eV+TLfyPJRjGlMQD/4znIOR6UW36GyI9iHDgjGJc4bn0MRN73/A X-Received: by 2002:a17:906:5a91:b0:8af:2bb3:80d7 with SMTP id l17-20020a1709065a9100b008af2bb380d7mr14102582ejq.31.1676285046890; Mon, 13 Feb 2023 02:44:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285046; cv=none; d=google.com; s=arc-20160816; b=IR8C8l9nTMKJM9IG0RdN3CZ+i3TNSu6lmkQJKRqDTPKWkh0J3qxXgIAHDtI4eUFdtn 5cI2YUakrw9Uy+vcz0lP1McbOk+CcjTqOX0u5LBvKiGD487US4Sms62wXqFzG8IIuBM6 dq5OFqxjlMne1SkqRy4loyLrmH9SRZYXJBWnCmVSZAFXjIJxj4b63WsN/FnX4Zsi8BlL Rk83CK+5ewXkvtRa3IgVuj/rMvurgKkDT+E2DzfWALxUhREZy8Rc88CrEgirUYWcGvrm wjI9xUGVIzHFyldkh72ManbT3S1gix5oOk9oVky3nbY4Kh+hGt3ecaiZK16pCvCIMK6r vwKg== 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=b9KaEUm6cczRoBW7/1jFxYB8Krx5fTX2dMQWyZ0vSP0KD6ZjjTnw69U0LNW3WnCi+Z 0M0OHlZ9KElI/BTuQS1C7h/aFvocYFCulqLhl9c+gZPzr+ztfXDGCdNvpbeZoZN1NfSo 4rEcFCbx9haMPzK1U4xUsVmZGzpEQ6A1ffRCIMUcEicU1xrhP7pNKpn+2B4HGqoqNVQX B/Nvm+M8kL+6SvLtZ3A1NKRpWgoocAp/+LhTeJV4pJTAvnN8OuPLDINYP5cMrkh5UNBd gcvvhhcQYxLYjyNFLHsSh8eg+p1ZgfnyDBe2jZnq5sb0xrMKzHgViOKu4ndiC8n1ZpCY CZLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sk84GRaA; 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 12-20020a170906224c00b0087a6a62dd48si16040392ejr.297.2023.02.13.02.43.44; Mon, 13 Feb 2023 02:44:06 -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=Sk84GRaA; 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 S230082AbjBMKnY (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbjBMKnS (ORCPT ); Mon, 13 Feb 2023 05:43:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20691026B; Mon, 13 Feb 2023 02:43:17 -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 300F360F84; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76AFDC433A0; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=m6miDDXDPE0i8gfLkqlExqia0yJKU93vQt0xdTn6QTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sk84GRaAQbVuumMhcjYqbpSugpUuBiGRQaq9vECD1FR1zbOlZ8h7QTpbhbosXX1yE fXvXK0nBo3vPUy0Hr42EkPOqvkdjuccYUyuESJGYWkUE/ZdhdwxaD+d5OOHELFU6Xv Jb1soYFFI3fI1++n0Wvh+WgO15eJOBBbNtpY73dWEYTzX3fOpuNreTRBz1aQ3Td2j+ nz7LDi0KwNS7DfidbIKgtuo9S+veuL+IeQmbXRPT1tf91otPfTW1GVIvK+ohhElI3+ lkhpoHs40MqlGgng4KGA/Nd2wNKzukIC3xTdbMON8qaAfkKSXieuSBdN/q4vPsPvJZ OXqv6m1rbkjmA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004WN-57; Mon, 13 Feb 2023 11:44:07 +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 v6 03/20] irqdomain: Drop bogus fwspec-mapping error handling Date: Mon, 13 Feb 2023 11:42:45 +0100 Message-Id: <20230213104302.17307-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712269741088488?= X-GMAIL-MSGID: =?utf-8?q?1757712269741088488?= 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 Mon Feb 13 10:42:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274955wrn; Mon, 13 Feb 2023 02:44:48 -0800 (PST) X-Google-Smtp-Source: AK7set/q30mHluavZA+KU0JYsMfKI1mIznS2nQQNcXv38C1LZ/ZMQvl+BD9GKB+t0KilUodXpgBN X-Received: by 2002:a17:906:6992:b0:87d:eff1:acc8 with SMTP id i18-20020a170906699200b0087deff1acc8mr24282276ejr.48.1676285088553; Mon, 13 Feb 2023 02:44:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285088; cv=none; d=google.com; s=arc-20160816; b=Oqo+r4SjEpZsGlYAsMLV223ermg91pnySY3iDmr7dr6rJphGNDffcc2vZHO2Hiv3IE QhDmbL7SVqOU1qFxVHsSmPxxoeLP/D9UWvEYI4hFKG/TTI4dcKJMk9nbWeVgNojZFua1 qE2jR2/CK5+ac3iJz0wM8uDwJ5xSzpPbAAFZNXRj/n+dDzMtknWt+MkNtx/g2dMFds6O B18JbNP47Ec9KuR3PUrONbajg0t4hD1DE4x4s/AAKfcoVcFXAiyGhFkGM9essmmvyrB4 5b7uZByo9M3CWSSgLxGQBhkJp3+/Q3pBihcVC7z9wEhPzJMEfxLTnfvo/v0kX5X4CDbP S5Zw== 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=kFEEItE/nY0O6Myp9S6AhHrE4hEGUXTbUjGWYsKj2A58e09gE5IeCPal6Sx825TqJ0 zALhwb2Rd926bJLe6MZsVSDBcpDLSWeJJEthYEGCr2VWMMwhJ7s4uATHrLbozByqbUNM KyTmRLGAi9c3EtHCEgLwu2zL12EqPqD9GcHsljhdBom8wVfnuJaK94MV0PkAK24S6bWh 2rWU+ucUe+Fk3zwdDoWsnvxDSNf0WbwSE4yqowa2qrnzMYhRX5SeSwGkxtPUbYoI3c6O ujkjXOD4dzGf4Lo85zU+xp7dpzDOP9qHGSW0JfkpPrTErFfjQstc5Bwp6bE9zEb8g38j 2Srg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H5ZM6LmE; 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 19-20020a170906001300b008818ea1898fsi14703378eja.851.2023.02.13.02.44.26; Mon, 13 Feb 2023 02:44:48 -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=H5ZM6LmE; 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 S231200AbjBMKn4 (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbjBMKnW (ORCPT ); Mon, 13 Feb 2023 05:43:22 -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 05A0C166C4; Mon, 13 Feb 2023 02:43:19 -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 D82B0B81098; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71F1AC433EF; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=sXzV5Iaq24naECB8eaIVtLUk0+3eItKCLxiskY8fyFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H5ZM6LmED6ooVwQK5MCj1Gxn4Abu+AQS1soNpqQ5XYJcyycQEfRThrcrW4zBOkvbB 8ZQ+kSW/NQC9dSXyw/EvdYgcgIvfMuZn4Yv4p2/gpWM7r8kUNmyo2ezovPqH8hafVq q8G3gnfPMokPEpJDs/mb6BEwlYFOj4m2YrP8k3hJkucXjjXiG2AL3zEWgHbFKD+wvB /AVUEEUAWbcjpGuZ7AJREE1EHLsxBRkdlpd1mN9HMS4YhhvZW+IgxVGtx6LOvPmNT5 lXEoHeUIF9Pr7wwlFOMUrOP9z2xzzAaGg5EWigAi+c3wlE4YwuhX4KFCaWCXuEgiJc 8ghj/L2FRlnjA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004WP-7d; Mon, 13 Feb 2023 11:44:07 +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 v6 04/20] irqdomain: Look for existing mapping only once Date: Mon, 13 Feb 2023 11:42:46 +0100 Message-Id: <20230213104302.17307-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712313073211760?= X-GMAIL-MSGID: =?utf-8?q?1757712313073211760?= 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 Mon Feb 13 10:42:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274807wrn; Mon, 13 Feb 2023 02:44:18 -0800 (PST) X-Google-Smtp-Source: AK7set+hGfXswbjQu5i+aMSD4a9Hykaa7PSsc4472ZCeZvnkwCQlh5vZ2b3f7nTzQRWZ5wPOxh9E X-Received: by 2002:a17:907:2bf9:b0:8ae:e82a:3230 with SMTP id gv57-20020a1709072bf900b008aee82a3230mr16370476ejc.70.1676285058786; Mon, 13 Feb 2023 02:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285058; cv=none; d=google.com; s=arc-20160816; b=sXaYS3DtOy5Ii0Tng8w0cQd9D4YjqbCDjAcmVNnkFZFdoWb2P6vB5czoM1zETJ7Dc6 dhrfTMtn4gevTrGdx0tUAZxygHVKs30aEXKqjLN7+K2kKKPzAs1ZAWJrsNpqlDWC3cyH dj9n+5Ub8dD+dKdYNIZfNJfOXgX8ZkZ2uRiOYRk8YJPPSqgHchXsFYMR8GR4q/2xtctP eG7Wk3c2NMclD5eWPJKnjkzO8KZre2vr5L7Fb2SNWEnuRRYL/DVZlCdQDZ+lreprZEd+ yur9YyMQDhiifN+zrLf8OQT2z2aJk3mXeOhgBMoCoKiY08ucAQgp7TFpRRyhOoOWRzCB H66A== 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=ua12wZnLNPb/vsnyxdsbS0MgdqxPsZnXJznxKAnsvaGlLWxO78mS1USssWy82+CydC 8simYDdqEuhwUJVRmenYx0TQv3OgcKnATf4N5mFvbv7DyQiSpoOln+DBmd+cMl0IPsmF g3oyQSvNLWpR7nt5NlQZHICm4bREiC1czEboesnxNh5tAclyIIJNe5enEHEsXoJkaVlg aAfPNLPyjrHZH+KXWxZhYZVaQ6mEO9AaJTL7YnYzeUiT/+zl/VtIigXoZbUId/LnJc64 qmHFQ0u2429bz7bJXGLVAnOKviHgmWnuJFlQIQdEqwGtNTwymXOyjrqFqKh37XHevl6G 67CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lfhKfmki; 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 13-20020a170906010d00b0088d614531a7si16633314eje.381.2023.02.13.02.43.56; Mon, 13 Feb 2023 02:44:18 -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=lfhKfmki; 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 S230361AbjBMKna (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbjBMKnU (ORCPT ); Mon, 13 Feb 2023 05:43:20 -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 30F3E15C99; Mon, 13 Feb 2023 02:43:18 -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 BF20E60F90; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DD3DC433A7; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=clVu7cbCZQuWFAo+ktM63h/7vhzeIYuPjrlK28Oxe1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lfhKfmki5pemk3zoxTuAiL1XLNsNxjI6reMIkGd308aA9jWKctkhSOskZWCv86qfs R4xyJvPBbYaGUX8i613aE4su7j4AgmsBsyiBdk7yazK1mK7DVGveucdWyI6GPAXswM +5qNfnPl91P8Eg4raNeQh5n3SJEYl7LXigXSEihrgINSlSBoqXGv/FiMQkHrqRFKM2 Q7tVk5xVwsb9E/F6gtkME7lLyMdPiVasCHBxbUy85j6zNdVF5u0IfwmFx6gNcbo3v6 cs/jKAlO907uZausbVduVKOlPYz27OA1rflUqVmEf/fp9o3LjA6mLTWc0IbQWgWzb9 /YMILx+eev2Bw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004WR-Ah; Mon, 13 Feb 2023 11:44:07 +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 v6 05/20] irqdomain: Refactor __irq_domain_alloc_irqs() Date: Mon, 13 Feb 2023 11:42:47 +0100 Message-Id: <20230213104302.17307-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712281720377237?= X-GMAIL-MSGID: =?utf-8?q?1757712281720377237?= 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 Mon Feb 13 10:42:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275354wrn; Mon, 13 Feb 2023 02:45:53 -0800 (PST) X-Google-Smtp-Source: AK7set8DnjEOZQB4ocoGzPmPefbwP4nsBTlIR82u+4XacBevM/MgUYlmWejbMbMkI0sC/g326EDs X-Received: by 2002:a17:906:1b09:b0:864:223:40b with SMTP id o9-20020a1709061b0900b008640223040bmr27179861ejg.33.1676285153544; Mon, 13 Feb 2023 02:45:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285153; cv=none; d=google.com; s=arc-20160816; b=qFWfhEite0fRuCLQ2CvdIgssXooGSjWSGsDuDGbD0aRTJ6wkc4+RbwdtKzCpVsdt3f KYTJu+vzNjy2SdSRuaQx5547y112sG9R8eRud7nfX9VD0flP1oP0c3rk/EaVQwDrMCx/ VbamWvIp7JZhuic6tevg1ZTYSYgU3bA7qgHc6ZDHfk79s6PBuicI0BE3L2MUkEG0YAat nJY8axeyTHcIumx5P1RVsOi3CMbLCdXdTc16KRR9ZA7fwJgiTKII8LJd5eXY1pM7IaNh bKY+kTJolK8w6Q0nD1eUmDv57UXaXEdrZ4x9mHdRRQ+/ohDGmJbBxhC87cwg2WlNXLTq jCHQ== 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=OosFG6pfsoQvdUyoOVaB3TLMrfAacRl3iWEUlf9FTx8=; b=BstCv1nS71+s9/X1n5Dt1nz/p0XT3lezjErLMXHVHbknJ+qpuudDTgLH6EzYSwPY2V p4+2oU2EqJqSXIZi7vzOYZnc7RYB9ME4Vfc93HM+ssbKfcHGFkUMNg+7T5+e8JdmKVJL Tikr+Xk/cNhYQkVKEpyUoDw8p27+oLq4TeyFKy32SNtyCN/cpE2JutPlVIJdCSTEaTKl CT6va/OLpUqMN2iYXvoUESXQyh0yKJVQYa3L/0WWJICLPc0t5JJCNyG5pdAFzc62AiMS t3kpdKmL+6E5PHPK8YhYTHnkMov7ULGlllBDjOKYkXEWwwYezQQj2amo+DASNJfwHdkR U/lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SXMhpjz3; 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 ka10-20020a170907920a00b0088e71abc787si12856813ejb.517.2023.02.13.02.45.30; Mon, 13 Feb 2023 02:45:53 -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=SXMhpjz3; 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 S231204AbjBMKoA (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjBMKnW (ORCPT ); Mon, 13 Feb 2023 05:43:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05C7C166D4; Mon, 13 Feb 2023 02:43:19 -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 BCB79B8109A; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F7EFC4339B; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=9Zp9hoAQoVOaXXCM6Fs7+H3M4bdWA3fEKLViYqGRNG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SXMhpjz3jtwwzHT/G3LXz7Pqj4GbPHLxNmKD4xfOd/S7ZIfPybjmq5jAnMH90Yynz 0w1SkWaBZYCXpp+oaMEr8MfB7+dGhoCyGVLKWH0VdscfBv56t0ULYWD7kSv5MMWv2i cPic/Yg8PrmeGzsRW1XQwlV/KUqv0kfU/KvU/fNYvBJgPHw6SauvKVH/3FupAilDc7 SgISXGzOoExgcXpxtdjPfDvl1VBoH3/py24Go1WLpux4GWv/dDax9FndXevZreHHqg 3nd/SK8sw5uODyk3XL0NGLm2BaXXkgFg6hs4sl7GWqQWalZxm+N1aT2dvj3KynriEV ayI/3M5wgrb0g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004WT-Dx; Mon, 13 Feb 2023 11:44:07 +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 v6 06/20] irqdomain: Fix mapping-creation race Date: Mon, 13 Feb 2023 11:42:48 +0100 Message-Id: <20230213104302.17307-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712380939568442?= X-GMAIL-MSGID: =?utf-8?q?1757712380939568442?= 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 | 64 ++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 7b57949bc79c..bfda4adc05c0 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 @@ -829,35 +840,45 @@ 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; + if (!irq_data) { + virq = 0; + goto out; + } 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; + virq = 0; + goto out; } if (irq_domain_is_hierarchy(domain)) { - virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec); - if (virq <= 0) - return 0; + virq = irq_domain_alloc_irqs_locked(domain, -1, 1, NUMA_NO_NODE, + fwspec, false, NULL); + if (virq <= 0) { + virq = 0; + goto out; + } } 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 out; } irq_data = irq_get_irq_data(virq); - if (WARN_ON(!irq_data)) - return 0; + if (WARN_ON(!irq_data)) { + virq = 0; + goto out; + } /* Store trigger type */ irqd_set_trigger_type(irq_data, type); +out: + mutex_unlock(&irq_domain_mutex); return virq; } @@ -1888,6 +1909,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 Mon Feb 13 10:42:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56177 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274847wrn; Mon, 13 Feb 2023 02:44:27 -0800 (PST) X-Google-Smtp-Source: AK7set81xa85B6bFV5Bcvt4fWDyQWW3EVoTxhIl7Vg72twjuehsknfNlPDD8hf6qTkjBlOW8+O6t X-Received: by 2002:a17:907:d19:b0:884:26ec:388b with SMTP id gn25-20020a1709070d1900b0088426ec388bmr30252323ejc.39.1676285067569; Mon, 13 Feb 2023 02:44:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285067; cv=none; d=google.com; s=arc-20160816; b=msZSK3Nk3QEIJ5kAttxWu+NpOsFhpCHoa5dA4YNA5arwKE833iY8VeaV4ppOm5csGE FUchKoKKgSzH7ARC6LlTvzSvOv0lUz2zeAc0v5jQ1ucAtXzMaXg81G83i+AOR4Gs3yRM H7rr3N6D9kzcAKwb3k3UFqH1kpQ2DJd/+rSbrH9XXl89XraMSZHDecwCRyoS2R9BR53C zW3ntijGQ1+HCAstza7PqOtnx0EVeIvQUsWfAm8tUCmELEXHG0b1Oi3cM65yBt1fiZdD llPgyI/Z/PnfPkDy0ly7kLeDkhQpmPfMZ7G61g6anP+0mv1gXMh38zZR7fN9tygq7qUu tTHQ== 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=pKHlIkeSZO4/ZtEbBb0BCyXb3zOhfdV8L953PopkNDw=; b=jLKq6j7lrK9DX/Yg2Elj0sSaA2sWauPtj6rAoRHpKUF46gXAgGzK5dJabFAJE6ow9h EEbnKeGEx/VnSAiul6naYUPK0OO0RQEheH0F/WxU8fYXE3CVxktMGs2+Yor1CI1AYauo dI6wNthPhsjuXG2aOV20S5FQD0I+SNtt3/hWKFA9/LasdvJ/phU5QS7eX3XLQjOarK5S FvACG5kotWZVfsbQWvDfWvPjt8Tg+ZQaaA8EWGy8gPGHM4RaesFlYlKplyZYJ2iGl+AZ tS9ZZLAvEM45WSvrF/g3dw4kFgXRgpYd6lHNuVuY3yzgXCwAlON1v+fTf+/lkWat8iIo h9Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="V/NE5iKG"; 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 s26-20020a056402015a00b004ab1682924bsi13042201edu.425.2023.02.13.02.44.04; Mon, 13 Feb 2023 02:44:27 -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="V/NE5iKG"; 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 S230455AbjBMKnh (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbjBMKnU (ORCPT ); Mon, 13 Feb 2023 05:43:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 348DA16339; Mon, 13 Feb 2023 02:43:18 -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 C12FA60F92; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 794D5C4339E; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=GfltTDdqGuUYaFLLjciBdbiewtzinXVmbE1XdpKL8Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V/NE5iKGT0M84Lw+kKdUl6P0kuso1oWdyDQ2YTyvP2puYDOWSZ1hPdNZXseMhJiCA B0MSuzSmfpXBrjIZ4eya9l/RoFpoPRNqpkVX8U9GKZhQt0+uZ0ZlKA1vrysm6biY2g 5n2GtmLvkZsy9hVoLRv3Z24Hz2eM2roMvKqXC1vIT3i+lO9mssmzjTcxXrpQvEX/Dd 92DMRjrVMJLnUOCf8MuKK4Gn4jpHL8oinN+wAyuQ2rBJO/IdNr6xikxnWJx/hqCyN3 1vRjeFbo80hIZ3yQSpcRknzb/WqO7DpX5tLA859mytVQLU4O1DnhW9Dyx2RVM+TALm waW9uVvNX5s+A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004WY-Gp; Mon, 13 Feb 2023 11:44:07 +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, stable@vger.kernel.org, Johan Hovold Subject: [PATCH v6 07/20] irqdomain: Fix domain registration race Date: Mon, 13 Feb 2023 11:42:49 +0100 Message-Id: <20230213104302.17307-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712291160795045?= X-GMAIL-MSGID: =?utf-8?q?1757712291160795045?= From: Marc Zyngier Hierarchical domains created using irq_domain_create_hierarchy() are currently added to the domain list before having been fully initialised. This specifically means that a racing allocation request might fail to allocate irq data for the inner domains of a hierarchy in case the parent domain pointer has not yet been set up. Note that this is not really any issue for irqchip drivers that are registered early (e.g. via IRQCHIP_DECLARE() or IRQCHIP_ACPI_DECLARE()) but could potentially cause trouble with drivers that are registered later (e.g. modular drivers using IRQCHIP_PLATFORM_DRIVER_BEGIN(), gpiochip drivers, etc.). Fixes: afb7da83b9f4 ("irqdomain: Introduce helper function irq_domain_add_hierarchy()") Cc: stable@vger.kernel.org # 3.19 Signed-off-by: Marc Zyngier [ johan: add commit message ] Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 62 +++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index bfda4adc05c0..8e14805c5508 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -126,23 +126,12 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode) } EXPORT_SYMBOL_GPL(irq_domain_free_fwnode); -/** - * __irq_domain_add() - Allocate a new irq_domain data structure - * @fwnode: firmware node for the interrupt controller - * @size: Size of linear map; 0 for radix mapping only - * @hwirq_max: Maximum number of interrupts supported by controller - * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no - * direct mapping - * @ops: domain callbacks - * @host_data: Controller private data pointer - * - * Allocates and initializes an irq_domain structure. - * Returns pointer to IRQ domain, or NULL on failure. - */ -struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size, - irq_hw_number_t hwirq_max, int direct_max, - const struct irq_domain_ops *ops, - void *host_data) +static struct irq_domain *__irq_domain_create(struct fwnode_handle *fwnode, + unsigned int size, + irq_hw_number_t hwirq_max, + int direct_max, + const struct irq_domain_ops *ops, + void *host_data) { struct irqchip_fwid *fwid; struct irq_domain *domain; @@ -230,12 +219,44 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s irq_domain_check_hierarchy(domain); + return domain; +} + +static void __irq_domain_publish(struct irq_domain *domain) +{ mutex_lock(&irq_domain_mutex); debugfs_add_domain_dir(domain); list_add(&domain->link, &irq_domain_list); mutex_unlock(&irq_domain_mutex); pr_debug("Added domain %s\n", domain->name); +} + +/** + * __irq_domain_add() - Allocate a new irq_domain data structure + * @fwnode: firmware node for the interrupt controller + * @size: Size of linear map; 0 for radix mapping only + * @hwirq_max: Maximum number of interrupts supported by controller + * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no + * direct mapping + * @ops: domain callbacks + * @host_data: Controller private data pointer + * + * Allocates and initializes an irq_domain structure. + * Returns pointer to IRQ domain, or NULL on failure. + */ +struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size, + irq_hw_number_t hwirq_max, int direct_max, + const struct irq_domain_ops *ops, + void *host_data) +{ + struct irq_domain *domain; + + domain = __irq_domain_create(fwnode, size, hwirq_max, direct_max, + ops, host_data); + if (domain) + __irq_domain_publish(domain); + return domain; } EXPORT_SYMBOL_GPL(__irq_domain_add); @@ -1138,12 +1159,15 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent, struct irq_domain *domain; if (size) - domain = irq_domain_create_linear(fwnode, size, ops, host_data); + domain = __irq_domain_create(fwnode, size, size, 0, ops, host_data); else - domain = irq_domain_create_tree(fwnode, ops, host_data); + domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data); + if (domain) { domain->parent = parent; domain->flags |= flags; + + __irq_domain_publish(domain); } return domain; From patchwork Mon Feb 13 10:42:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274874wrn; Mon, 13 Feb 2023 02:44:34 -0800 (PST) X-Google-Smtp-Source: AK7set83YXLR2KBheBzt2wi1yLeKzIG/PaX5yWOpFoGIgebMIoxuLHNLhzdSlSbcglMu9krvL5jJ X-Received: by 2002:a17:906:ca04:b0:880:e6d0:5794 with SMTP id jt4-20020a170906ca0400b00880e6d05794mr22192959ejb.58.1676285074055; Mon, 13 Feb 2023 02:44:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285074; cv=none; d=google.com; s=arc-20160816; b=mqzvWoS2mlkY0BWrmzb/zQuNvjHMqJzej1K7CyYJExdz27WIWqHD14eNHyUX5NDkzO mWkKQdE8PesdSqc//F6yvKCCxY8W5SUgqE7lbCw8kdBdxASYkY/Lz96EZtaQ3KoznBuw ayjM6CFM0i9fHl/O6h1KNWYE4eQZI4YBeTfp1sV4jiIcV9E8Jv21goyeDH2MR7xztHCT mw87E0N5AsE9Fy36rfapQ9f0xepQSGrsY6ObiKSIg1iPu/+jpm6L5e8EG2NGk1jpTR0i 21Tp8To9F+JnOmENJv85r+bnB9bW4fID99qNXRr930Kqu82EMe3erQPxmmGPZF47wfL/ AILw== 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=FrH/9zNrEnOHEWZzUaSwi55xWIxLHzQ2wP5IfGm+0ZI=; b=BOFJ5Q+edgaEaY8AxmbKG2qU7cyGMIGQqwTHdgtND0AmeWtKoSE0FcKgUhwxDlvmNp ga7FsEoyRlPeaZ6VH+uoFLIekpyo9HwVMAzpHl9LZCZlPMFhON14iarcmB+m37nSr+b+ /SMPjfRwW+wi4TsAqNQvcjTsSeIBDiGsJhf9Y6CPA2RnzRAXV1cWBCPCBk3YkkBuixE5 C3SqL1LKPDWbRNdTLiV+9Uk6H+oJGRvaFe7LgM39Qi3NsyFyvFD43b4zmmWi22OQ/pex 7fANijQPHfvasWWz5ImKooMt5ljx4OWaNGQY0ZHlL+S6A1IMKWMYC9uO/BIJKH8fBLjF pABQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VD3wANQs; 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 fu31-20020a170907b01f00b008a91fe445fesi11115897ejc.543.2023.02.13.02.44.11; Mon, 13 Feb 2023 02:44:34 -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=VD3wANQs; 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 S230481AbjBMKnl (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbjBMKnV (ORCPT ); Mon, 13 Feb 2023 05:43:21 -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 065D316AC5; Mon, 13 Feb 2023 02:43:19 -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 F07A960F9C; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBB99C4332C; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=jG6rsHBlaySwcTGxM4i/Yv7OoULWC4BZGtew3BKDrmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VD3wANQs5Yd7RS1wkxMz820j7dCirJeEVLOw5B9xQOPz0fTANEFosCnUtLsY8Fmy3 o4KkydYPUtZfDSovElJtER1i+aqtipVHT5YU5h5wTc5af+3i1C5BU77xMNcroV7rhm NM+ZMTDErzonZ+pv88c7gCN/X5DACne3542lRyknMlhEFDPylyrbUd0uwPpHDZ/dNm 63dRzIGWTkj+vXFRzYCwWqsVn/ZQT1V/+yjQNb8ghqgI/jwTqGQa9n2MuNNfAOD5L7 NoyKm49r87hBQHSyO8D8CKWAyWI2RhS6U/4UqhqnnK9Od8wIL4ngWjQhlr/zCcmHfv lQ1a66XLPjbCA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004Wc-K4; Mon, 13 Feb 2023 11:44:07 +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 v6 08/20] irqdomain: Drop revmap mutex Date: Mon, 13 Feb 2023 11:42:50 +0100 Message-Id: <20230213104302.17307-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712297916159322?= X-GMAIL-MSGID: =?utf-8?q?1757712297916159322?= 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 8e14805c5508..f2247186f71d 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -206,7 +206,6 @@ static struct irq_domain *__irq_domain_create(struct fwnode_handle *fwnode, /* 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; @@ -526,30 +525,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) @@ -1580,11 +1579,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); @@ -1593,7 +1593,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 Mon Feb 13 10:42:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275182wrn; Mon, 13 Feb 2023 02:45:28 -0800 (PST) X-Google-Smtp-Source: AK7set9gXKzD6lBmk5Bs1s8WwQAeHVc/mQNTrO2/VFO2kAZKuAzh9W05vWL9JVcEc/lP19fMF8Ya X-Received: by 2002:a50:c34e:0:b0:4ab:4c36:4642 with SMTP id q14-20020a50c34e000000b004ab4c364642mr10656487edb.30.1676285128399; Mon, 13 Feb 2023 02:45:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285128; cv=none; d=google.com; s=arc-20160816; b=ZV6RPK5F+cBEXC6qLLuE1z8Wrnkw7xEofIHwzyMJZQ0SqN6/vta0yPH1BsV+cu5Fqj U4pUODX1oBX1+WL5wQdX1EEX2e3OGTMBTJScLUwbASvGSpB7kWY4Cye1eiTs+0M0aXKX 62OG3buvqIfeSr99jCuFco3UUE5zZTq+o8Qpg1tFJIvJRFDaEfipyiHHIV7rEZNUxrj6 GI6HoRVY7nlV6wy2KmrB7ErA+WCQe1vDNvKHm20amU7PAQ9w4rJFlLAV5n6nMUnnhJN/ 4Tx3R14Ana9XvXviwPD5OjaximqtGgCQIFdJpu+PMzsMCOXoV4I1XpTnyiqIEAe6nCxB ZiOg== 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=mbqU1HKGKrJBC8tsLNWb1IgOF51XhfaZm1iTPxOazbA=; b=k3aF7T9ebjTorX2YuGRISfnkTMfz2+/nGvTh84O0tLxM1hXU2LbaLN136JuJblb78K PCtfbHUbv/kl71t9NcZD/HLqymK+ntmnD8LEyKO9oVYaND1g1TugjpYQzgK1GEp1MEVX wagfq1vlDSZVnzUOAdI5lafD3S2bITMOY8Pi3zFXoS1MBb1LWUEnTjnAB2FbNnJdZUIr R+zX2XLC7bagvcpuM4gDiz9ZFfxfPXDs3Y1iq0i9VQDlVFL15mKA9Trh1bku16ouYj+M lXpc4wum10ijFB2f91PRCAKVctobwlSgwbXm43XOuSKEwEapzHb2E1Hgr7fQMZw5z91B HxLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mb6wAn9s; 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 n1-20020a05640204c100b00469b79303b6si14610749edw.195.2023.02.13.02.45.05; Mon, 13 Feb 2023 02:45:28 -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=mb6wAn9s; 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 S231221AbjBMKoE (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbjBMKnX (ORCPT ); Mon, 13 Feb 2023 05:43:23 -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 058B915C8D; Mon, 13 Feb 2023 02:43:19 -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 EF61060F98; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBB2FC4332B; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=G4mWOCUvHTQGYHmRB/UF8iuUGYF8As5e5KSKQ7KrbSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mb6wAn9sS0BB0Lc0j8fJ8Llr8LMqVWwH45Mnld0oVxfCYtZp9AhC7Dg0QMRGdeJX9 OyD9xwcd/1AzVZ9ncIO3G9GPog38JvWjGVKy6A518HqRvDjVrnTNWMtcdZlRQmGk95 fO/498pm8f4c78JyTtOslRhcKhXjltIjkLb8xKg1ZGq0MBzQ5fAhOPgEcuS1AE4uZz XVcgyFPSIdVUKQnHmht1StsuuB+OuZQmTceP+q+a6KfDKvI2cA8pizZJySIRgWX9WC YxqBePIAw/PCuyiaYlDoJmqcxsB18uoVStLnWvMRXOQAByyvzzzayNawyp835Rjs8N aGNLy4qLC0gfw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004Wf-NK; Mon, 13 Feb 2023 11:44:07 +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 v6 09/20] irqdomain: Drop dead domain-name assignment Date: Mon, 13 Feb 2023 11:42:51 +0100 Message-Id: <20230213104302.17307-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712354595584872?= X-GMAIL-MSGID: =?utf-8?q?1757712354595584872?= 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 f2247186f71d..9bba31de6928 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -619,10 +619,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++; @@ -1182,10 +1178,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 Mon Feb 13 10:42:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274918wrn; Mon, 13 Feb 2023 02:44:43 -0800 (PST) X-Google-Smtp-Source: AK7set+MBht48grY3DwqEAuw1cgBoY92bDy7767MgPwqvj3VFPKFH6ougYI8HKGHNI762ArY7yG8 X-Received: by 2002:a17:906:dd9:b0:884:3707:bd83 with SMTP id p25-20020a1709060dd900b008843707bd83mr21231942eji.69.1676285083317; Mon, 13 Feb 2023 02:44:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285083; cv=none; d=google.com; s=arc-20160816; b=c4ihqccq0ozn8Y5sE80vwiLF0vL5vY5uaNById7vXYWkj0ZgvxfHzTafc1Mb/1xU3A oP1UgwSjGGh+NSwTbU7T10Ll19bPcrysjludLR8JxrvBHkUH1tFlo2i3kkYEyHUwHZ6s jegha4mQyudeIYfsKcRBT9aJm88ouvSttIwpQEiyCxsvTFCwUVGjV3Q2DDDQwsKv+2ZG dgJDDZG3NNyJH1DHqLTD/+GhkiJoBbcvk4KBbV5wEYGI5xegORobw83yN04P3lQaCSim jn28p/y9Cy6VLdrpGKyzJCLS6yam9Tr5GbXRRfIdBF26onmQIPSaYTLq6dyvYfma/zNJ ujuQ== 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=re9sQ2mETwBFBinp0Y1F1Wtwi551x1KEhX07qjqoQrc=; b=iMYfXxPcAMrEttR++yDK4ycioz7Xfo7BA8KA4P9YQD7wDyFd8tmH7tlxGApaaY2wP+ kc6m3fCvQ5D7oxJKG9idMDD54YIxZ7gzHL1Xtud2Uh7CWr8UUI6lqvVlkikSEG7TiKpK PYvq30dPwBmlzcZNXi3s88vIaaTV5VbNUD6rB5iaYMHsCGs4aYukQmgCjsKOg9vAgWEx WYkIRPWXawyCT74HnMadVYLnRTlz8R8ujkztG8+wpTtE+3rzRZ6Verhip1iIdJUNzxDd NxVJHlDkERIGn6Q6VIz/w49yT7+f+dr9Axv/N31E4RGXsDhGu+fAM08+mz5ZxD5C/SeG 1ntA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Xr/Uof0g"; 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 mq32-20020a170907832000b0087875900d27si11921743ejc.94.2023.02.13.02.44.20; Mon, 13 Feb 2023 02:44:43 -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="Xr/Uof0g"; 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 S231168AbjBMKnv (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbjBMKnW (ORCPT ); Mon, 13 Feb 2023 05:43:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05FAF166ED; Mon, 13 Feb 2023 02:43:19 -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 EFCA860F99; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C65B6C4332A; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=Li97/YgeF5lNpH4d55UxuUf7f/JYiOm3QypdwJ3bK/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xr/Uof0gPLSgXaMwhLwpbTTOlTEfM6FWo+mvV8Bujzy+R/41KRCOOXfLRX3sy3rU0 Y86aZN/wwMl6jD3gyZ2DcH5n3NLMMJDQq7qXOSuaZpJrivlwqpgYoDkoZtt+IWpIFl 8TpgSQ3yl42J8KpTUkti2uArRiCfZ61+UlitRI05H0+b31cNBZ4rrtxGVHI8vL1BXO MZZyLw2xt+MfPk04WT8FRSNWYi9DKiM4nznsObyDt9GusQnzTjCe853A1ph65RIuZh zpiRr9AC8AVnRuQ4HrnRz157JQOmhcqXLpgCcuQLEjGUXBo+qOqVcGZZodA1/bFwAt c/o7LnrH7z15g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004Wj-QP; Mon, 13 Feb 2023 11:44:07 +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 v6 10/20] irqdomain: Drop leftover brackets Date: Mon, 13 Feb 2023 11:42:52 +0100 Message-Id: <20230213104302.17307-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712307857435364?= X-GMAIL-MSGID: =?utf-8?q?1757712307857435364?= 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 9bba31de6928..7785b3352e60 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -210,9 +210,8 @@ static struct irq_domain *__irq_domain_create(struct fwnode_handle *fwnode, 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; @@ -652,9 +651,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 Mon Feb 13 10:42:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274782wrn; Mon, 13 Feb 2023 02:44:13 -0800 (PST) X-Google-Smtp-Source: AK7set/JfGKG8gM0chE727NwK+eDTaOydFY9Wb0TZJ5Q3uRR6Ysp82p6qmzVaoHQevqoJE4DTX9u X-Received: by 2002:a17:907:9725:b0:8af:3930:c390 with SMTP id jg37-20020a170907972500b008af3930c390mr21276053ejc.62.1676285053697; Mon, 13 Feb 2023 02:44:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285053; cv=none; d=google.com; s=arc-20160816; b=vvKZjBhQSctHzr622r8TM67wF+IpwZVCeF10l6I7ISGOWvccj6CsV1jcnsIQlHNZYJ 3DArf1uuLKYSzBGEi/3kRjI+bZft15btXSHMULGMPwZqb6imkvt4W+GbryNwuNBmzz6Y 4+1kTtKNkvxqc7lvwAM8Jb/rc1EnCnHGRWYmU6uUubK63+ouz9fu/cQUQSxT6TaJpG8o jqWOZffWAkizjVCfO2kgoLMQaeAvueKTbcREBFuBipeac0vz6LoGxCjypO+4HO3MEKJz g/vp9ROTksEnINDLhPQwAhsuyeZ+OOz7G6/ZR/tn9q8aQxu6F1FYHwqyR7K4/cQO1YP+ gldA== 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=bWD8buJywTWQ3LO61Pl4SZ/Ho2JdQNBEvdLzSegaBAs=; b=lPmDXkkwY5eykttADBZvU/ICs528lzxVXGu1qvX0TF8V2Ogh4E++cahJLh/el8kacv jj9VujIaMiGm0wuUQl+7Jlki+/3DevSyvSJ4AQadera52PuGc/RAp8F+1S2UssXxiGw/ nJSvZzTUa2/tO/kO6dGRFFOJz1MkMIx+lTvTmebE7A4XEhPbAzs+xIQumti3CS6R6FsH 64FQtMGLRSt83smt3OTi16QWk+meaUOYUg9P4ze1WDfukt/aYftZVLAAARL/U4bmlvp9 HxAbntdXqiRdm5orJwePVuVWRjGU4W71vFVuwE0XZ7Sn4xhXVUzHtDE/8B1sAXou5OJl kI5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LYVwP56o; 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 m27-20020a170906599b00b00887dadb95e2si13533001ejs.711.2023.02.13.02.43.50; Mon, 13 Feb 2023 02:44: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=LYVwP56o; 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 S230222AbjBMKn1 (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjBMKnU (ORCPT ); Mon, 13 Feb 2023 05:43:20 -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 349961633C; Mon, 13 Feb 2023 02:43:18 -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 C414660F93; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6588C43329; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=ucy+R2vGCNnMk+YHMmgUl332bM/zsahp7MGXe5tUo8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYVwP56oj4WQuL7Jj4nC5sDEk7NsGbZkLxLODTDUfBw2bovSb9+5zQi9Euu1N6wUg +AJ9ZaW5e2YKtvae1YqD76a2MWn6RzL9o7j8oucf00Wtu01adx+/zML57SPDdahJkw 74kH0SMxpKDXSx+pLk0JR4yjpOtb4e/uPo7RRgnaHdW5898+WIcM3oXyAxPrCYqL7e eM240Kvn3U5Te3+2j3O6DSe4n9lU7epwaAcylWM4ZBm5dPd42CpoUFiwBqoKm7et4l GuXAZbNFNeyjRYim5j5Hl7pf65v9hs2IY0Uk4Dd47bYDjXGymVDun5XOuU7ERBted5 ol7PX1zGCDu1Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004Wl-Sy; Mon, 13 Feb 2023 11:44:07 +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 v6 11/20] irqdomain: Clean up irq_domain_push/pop_irq() Date: Mon, 13 Feb 2023 11:42:53 +0100 Message-Id: <20230213104302.17307-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712276720660438?= X-GMAIL-MSGID: =?utf-8?q?1757712276720660438?= 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 7785b3352e60..2213d972f083 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1598,8 +1598,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; @@ -1624,45 +1624,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); @@ -1680,8 +1679,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; @@ -1703,37 +1702,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 Mon Feb 13 10:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275748wrn; Mon, 13 Feb 2023 02:47:03 -0800 (PST) X-Google-Smtp-Source: AK7set8SBSWOXeIJEO5eL/gE3VE0e7wQ9gI+vQ5Ldo45c8ndqdHXYqL3oiEmzK2LmSzs+QV4qCDK X-Received: by 2002:a17:906:124f:b0:88a:a27c:c282 with SMTP id u15-20020a170906124f00b0088aa27cc282mr21691567eja.47.1676285223485; Mon, 13 Feb 2023 02:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285223; cv=none; d=google.com; s=arc-20160816; b=UkIQPOeFVV7ShhtcQ2cmq6ykiwUW8Uq+tE9JVN/SFf9JAGiF74OH4Xh+moouoOYDWm qTi0+wke0odVpesah7Al2QFYevzRt+J78LaX1Rzt7xWMoz9/SJ1/xKZJQ7ot6WJshyuo 5u0a4ipo0Aq3rxUEn9s9CjlI/UIVfOat8zsQUL84YsulJxCWO3gtD1IQlkIjEmJ7LWly oz5y9IzFqL0G1ZbFpkw+ceoYzTV3s9YpIyXK9DleieEo/i6Jch4o0kEvQ+AkFsHoM/wi YBZnB80xQliDnc6myY0baIzAQ4EQ7z5Gy0SPrSwo9bdbwExu6znwqtSQYq1n8q12URkg T+NA== 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=pCQcZTMxIZzrctLXb9y3j1UBzydqD+5iC27YOlPovKo/ofq5+vKubP2/7J3Ex2ofvn Vl5BPom/srnoOqlFnnrx2yqPa5enineWEc6nNKaOn2B+m6MUl8vw6x47oyMG/ayOkRhr JlPG4VzV4tW+Ht7VzNGgZ7iaVQny7CjxWpN/cJTT/K1xIGs43hMbC++f43OF16HNjH1Q r/hJD8S7kkYhYMnFn79ej1YaPGiR87yOsRMlhQncBZoOOKoGJU44YgnwZ8+rg2Eaa56B uqYEWe9ZouU8XZHnr0Tefc4hbUS7S5lcsREGa1J8t11LFGC5+k29SW9Fq1S0ziW7RUjY db8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="i/NB3Z35"; 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 10-20020a170906008a00b00867779a2fddsi15906671ejc.188.2023.02.13.02.46.40; Mon, 13 Feb 2023 02:47:03 -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="i/NB3Z35"; 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 S230138AbjBMKoB (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjBMKnW (ORCPT ); Mon, 13 Feb 2023 05:43:22 -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 5F21416AC8; Mon, 13 Feb 2023 02:43:20 -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 6047F60FA7; Mon, 13 Feb 2023 10:43:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E406AC43339; Mon, 13 Feb 2023 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284996; bh=roctf62/yqPkgEsUS/nfvm5p+4sye80U1pGQ8NLWzxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i/NB3Z35oO3xp7BNUVdB8aBYC1V46+hJx6gbi9JYyG+4X5Z+ddU0Ifejx1SVieXbd R51bU8IKULnwV0dtRZ6CcTBpcnr+dFODpNe97S38ulqotmTtAaX+oQkYd5+0r81vUC BYl/RR7/lEdqCx++k1z99YPxZ/5KTHghRhvNzlgersrMmzz5u50pA/5uiaTOamVHtB vZfQflnwHXGVFt1FvJBedMI6JEEW/fHg64E9Nxhc5EaEsHhq5zZ6O5NBdGCFghBRzG 1rTD6y3ujNixCWL5oB9/jPEkADHit36hBJhKLm4n8oMjS1HDmWJw2FJHHiz1/rFbKq uQ0lDTo6NIFrA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJb-0004Wp-Vx; Mon, 13 Feb 2023 11:44:08 +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 v6 12/20] x86/ioapic: Use irq_domain_create_hierarchy() Date: Mon, 13 Feb 2023 11:42:54 +0100 Message-Id: <20230213104302.17307-13-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712454477863304?= X-GMAIL-MSGID: =?utf-8?q?1757712454477863304?= 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 Mon Feb 13 10:42:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2276149wrn; Mon, 13 Feb 2023 02:48:27 -0800 (PST) X-Google-Smtp-Source: AK7set9KNp/QPqMcqTxZE5GuOBFmkQAKJ4px/T05GC0g5GVgqZawEIrIcgoSt0oyvwht8wvhLjWf X-Received: by 2002:a50:d549:0:b0:4aa:c685:2937 with SMTP id f9-20020a50d549000000b004aac6852937mr25341235edj.13.1676285307048; Mon, 13 Feb 2023 02:48:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285307; cv=none; d=google.com; s=arc-20160816; b=gPIYTy/AA1acYYFpjSetGca5iQyGoX5Pq2mK1yRP4ugGLjiQeH+ZxDIawxZN6616z3 vIw0vMm7G1medqoKCP3mUWMKqqj9F2hLz6A0W7cJaNNXfFTpFdT5ektrvZlb/CvK/YNU Fy6Uc6iEo8C0mBWXMbwgoUF7D2YOQ1NJ9qe/o7p2b3DDvEHS/1q3aAT4QSwMHWDul16U jSz6cJ79o3jbsK4NSuT/pXEvF5MQfFk/l8K8Z0HoY7zSVSFLAuDt8RnvdqRl5U+71GW4 PCmZhwPFkRSJEJbdYZbsllemcB6dsilmb+iZKFb5F0Y41/worIRAPdeKHsgDoxwb8BQ5 c7dw== 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=yqNVShbnJDyNyNpkrLGKyTDZv2ofOGbW3u4dcihpy+6FdhqXGd7xqKpe1m5h+VXBH0 hqjKtl/gLu4e2Xfvu8eogQxJ2FXwmi/TCqr0EOb3bRQUao0aG/DhiGrJdnhiUCUPXz0z 9AzZb+5zki6Hf+XwUAHK2XUh1GyxyNb2ZNzaoe35rBaDVr6RegDvjwKZl0NbbQo/X3G5 X/kCO2yjPvT17zKPFyHDD3kFiyTSgN+611NHMV850zxWok9psghLuwrQ8jqQ7tW2Afqg KcfG9BXxI+QKZRbImsn3GBL4G8fzzBNpAWjS/NqQYCgAZahtnAnhRr52UmtV2fA1uvf6 sxeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P3wiRa+P; 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 y16-20020aa7d510000000b004acb7b226desi7417222edq.437.2023.02.13.02.48.04; Mon, 13 Feb 2023 02:48:27 -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=P3wiRa+P; 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 S231282AbjBMKoY (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230181AbjBMKn0 (ORCPT ); Mon, 13 Feb 2023 05:43:26 -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 49DEE17158; Mon, 13 Feb 2023 02:43:23 -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 306AFB810AC; Mon, 13 Feb 2023 10:43:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12414C4333D; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284997; bh=CUH46wTeOwx9zhTRGAsxA0DLFQlKaikmOpM12h4ppVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P3wiRa+Pr6BJ8JnisiohjbgJZzKknaFiA/I3ZmrTKFCT/BJ5aX6t6PIYJJaIMWRvC R1I9UwqJnssdoJw8nHI0sWXnJOa0p4eJ0umf6XRumYX8orVoFfTVgCmR7LWhRUmegQ K9tZYDJQnGrDWsT3jNtRQd0TVlO2gH3cqXAJ8qLJ8zX9s6KP1l46eSPc3nds22nzbc jKQPrZAMOEnUegDgcAlYjK+Tj+zpuwZn14k9s0jryTni1MlBQevHIiuap4tyf+G/ST lprINV0Hz76ejomhkAD7GD33abBMfh25LVh5o8W6Fzpyk2hQ9lA3Qg5ZMbXBlLQ3H+ cqhzPGdPSh43A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJc-0004Ws-2a; Mon, 13 Feb 2023 11:44:08 +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 v6 13/20] x86/uv: Use irq_domain_create_hierarchy() Date: Mon, 13 Feb 2023 11:42:55 +0100 Message-Id: <20230213104302.17307-14-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712542411410017?= X-GMAIL-MSGID: =?utf-8?q?1757712542411410017?= 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 Mon Feb 13 10:42:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275776wrn; Mon, 13 Feb 2023 02:47:08 -0800 (PST) X-Google-Smtp-Source: AK7set/cuYZhcVM4s3vFaGC25oR+cdpvvIJhdRZs6i/nPzc046/rN0nPQzhVWB8pT7VGUdWG251e X-Received: by 2002:a17:907:3341:b0:87d:f29:3a16 with SMTP id yr1-20020a170907334100b0087d0f293a16mr22921348ejb.34.1676285228449; Mon, 13 Feb 2023 02:47:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285228; cv=none; d=google.com; s=arc-20160816; b=VQ1nqbykD+iPHxZ5Pfc7OaL0HiVIj9t68W1RCeFVmMJ8gqGxbuePq9HYeFNFS02Rhf CNKJ+V651418yzWeEzSSjAA7uQmU0cZ1bLtuJVP7HtbTPca7/Z2rLP8lA/MLVe1/SwD3 kHXzV9/UBn5j5pUa2Vwes0sek9tir3Ea1MDUbnCBAkHQ0jOY8Wp0P0INlxfXZfbjZ+PA LTUt0s6WWzCBb2qTRhqa19vvLEcHypX3NnPpxadOkKmd3jSR9L/H4lwRUENrffFVQMdF +0LkOS2KXGGjkia5cTK4JnwjSXrWBM84rtdRJJq+GDmNquTFKAMF9QK1fN1JPE6GUaqC eYqw== 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=CkAPdx2cmD7ulXpQ1js7CZTKzO7yMLnXMcYdKXIiEmaZnkRE0vqD44L0Xk/n+K22ds ww0rdcAgqDKS8c9AzclQoFMmAAOiqHpH2XifJ3OqepzvCbbBPNzxlLZC51ETILtRmuMp +Fi/ehB11k1tdjVW68NYbOEU9Plwzgp78QpvK3Z9frcJdUuAZZWwteNZ3kRDiZB+Q3Cz U8bFNZY3QPsTW5IbRvk/XilS7mwEaia+GiqNgEac8lg3We63oEHmwtHFfQjRBMyf6rNU DenulTjDxurAgsuIwfqK+j0IhCZVhTh329QoX+0WugsqOyL06veerRyUZe1WGxeTTcE2 jIjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CNDlo9Po; 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 18-20020a170906011200b0087bdb2961b5si16273459eje.886.2023.02.13.02.46.45; Mon, 13 Feb 2023 02:47:08 -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=CNDlo9Po; 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 S231248AbjBMKoM (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230058AbjBMKnX (ORCPT ); Mon, 13 Feb 2023 05:43:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1C8F16AD2; Mon, 13 Feb 2023 02:43:20 -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 665BC60FAC; Mon, 13 Feb 2023 10:43:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1243AC432C5; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284997; bh=NTHXrrpZCAJQDbqGQ5Dk1VncIloUIc9A9BrVorjY3xI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CNDlo9Po/2gPGU3zXwvDyv9/xAcEVX0HaRAAkak++yvXs+wbnXKJAwqfv8Rjf8kNR sZWrSmYMDOvaoHQXZV8T5E9O3D9BETt+mQSaoBiCh6YLevccQH9cQ364zNR7fNS8fy vwIUSRfsC0c6of1luL1aP5BvHA/xEmfXI6HnLLJ8KTT9J9IyAL0t4bRRHP9Rjz69BX j5D67N8cbwM5G6JpN/m68eQd4GIIMpcsoH0fm19uTJC7jMyjNmZEa/1IykGpFz6JHq R8j1UxprHjmCavisECqnL+qzza/RdnvFYAZSyJiltkZvj5W77cyft/sXUOqNFp8Sm8 HP7th7KNQo7hA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJc-0004Wu-5U; Mon, 13 Feb 2023 11:44:08 +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 v6 14/20] irqchip/alpine-msi: Use irq_domain_add_hierarchy() Date: Mon, 13 Feb 2023 11:42:56 +0100 Message-Id: <20230213104302.17307-15-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712459683225153?= X-GMAIL-MSGID: =?utf-8?q?1757712459683225153?= 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 Mon Feb 13 10:42:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275995wrn; Mon, 13 Feb 2023 02:47:56 -0800 (PST) X-Google-Smtp-Source: AK7set8D9C83PyEyjXxo0tjfVnuyACiHw3YllkLORXjjrQaCiWE9m4krcHL6TWdPhC0a9qxV+B4d X-Received: by 2002:a17:907:1c90:b0:8aa:be1a:2d1b with SMTP id nb16-20020a1709071c9000b008aabe1a2d1bmr28710977ejc.46.1676285276617; Mon, 13 Feb 2023 02:47:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285276; cv=none; d=google.com; s=arc-20160816; b=OFBtUVs2rIw8VxV//ig2xzt5WCk1/zm1qymHb1MMotbKFaZP6e0IXeMjb93pUFcCOW SFIMUHtWFfcLxu+UTPpulb5ZxkiCFt0T4j7H00zwc4aKRD0gD5AtbI06PbT0VJL4c5Jd 6eKSlYiXBjNPjBFhdMKw0KbCHP2o1nVNcVc1MJYRj5oVUHh07OZYkbxByTC2qn2ebyzv lFFR/FPUNHa4bIHXIhNPjqxwUhdYUYzLWJECy8XX6OHgNslLT0eg+KRcC38MK5T8Egfy gjaSfYgrfg0+QQCl8cM9tDN/GnR0X5Pa++JtnHObwF+9OBIdYA+3Eat2uxmx4WR3fSoU vEgQ== 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=1A52rX2YGkcn6kUh/i30tTv9pNcH2dAIrFk/b/XLGVfojG/FD6awqU3f2AE4XhnbVk ypwcE+qQ5g3lp6wjFyS+uSIjcW/Mk3jYCtoBAjLroYZhwwotG2lnD0ktxukHsdM52z51 iGc6cYpPxRdSCvgl0JUHS8P0A8/wwlIWyJE3d8AkAuAYPiElSgeoUGQlvijPIgDlTPtO 5LJvzNzNPERPa70+Y+EJX8ZA3J+5lXO1ygn/HHvCoiFQYQd1nDpMXN2iwe+8cmYXX1Bm 2TSdawyRk3murKoh9Ww83rmISuvv0oWJ95NpXOGZsd/ai7hEFtC9HYTMS+Kyeb4mmin7 3aXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=glMpyAhk; 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 vf15-20020a170907238f00b0088e28562933si12884047ejb.519.2023.02.13.02.47.34; Mon, 13 Feb 2023 02:47: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=glMpyAhk; 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 S230168AbjBMKoI (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbjBMKnX (ORCPT ); Mon, 13 Feb 2023 05:43:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C2815C99; Mon, 13 Feb 2023 02:43:20 -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 0D6FEB8109E; Mon, 13 Feb 2023 10:43:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31AB3C4322C; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284997; bh=g/DpJ6yqRzfoadiSwGWD2YQN47sUT9bIGP4aY7Lvgjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=glMpyAhkAbJ7h3BBqwb4f0ARTML3lseUBAkZZzPKsbr28Bv99r2ki1DZ3qh9FvAWD rthsWhwZVcwcniOAAT+MwV051VFqlSuYzcmjbcCGUn797bfROURDGQWQg1ZWdw/Bat w73nIBC7EfTy3BqUtqjlsOyYRNIrI4RexCrZOvch5o5Hue+ZXwheJWtgIdYs9DNeas FixwYWxG4aix2o1/KrVZoLWcrHDB+u9hwqkGXsT4IYJtZkhNGxaRwSsTSmUMrC6FRy xAcaTew4Ao5zm+Sd2BhdgVCWZYayJwALmb1AfT1AcFkHR/A3i6hAEtFhKoHmeDOcxS mgxVvkVzBonYQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJc-0004Wx-8b; Mon, 13 Feb 2023 11:44:08 +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 v6 15/20] irqchip/gic-v2m: Use irq_domain_create_hierarchy() Date: Mon, 13 Feb 2023 11:42:57 +0100 Message-Id: <20230213104302.17307-16-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712509933921910?= X-GMAIL-MSGID: =?utf-8?q?1757712509933921910?= 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 Mon Feb 13 10:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275869wrn; Mon, 13 Feb 2023 02:47:29 -0800 (PST) X-Google-Smtp-Source: AK7set+4Odl2mY7gv7K7Fx+XJkWm4vxwZe/Mhvr1Y484XNOEUftTsVG1bIMIkt06Qq4cQXJ+pzCY X-Received: by 2002:a17:906:abc3:b0:8af:2d2e:5d31 with SMTP id kq3-20020a170906abc300b008af2d2e5d31mr14411427ejb.31.1676285249657; Mon, 13 Feb 2023 02:47:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285249; cv=none; d=google.com; s=arc-20160816; b=uurD89Op8/LAmxwta2RxsjrXelXj0CNtoeP2HAKLt87foeVmy7pCSfBCGowAo0suHK JngXj/tkmvxyXX05f8+gPLA36XLaxSChekeKdymZBmIhOP/C0KhNurM/aaE59jsRKE44 mdgyN1qqCFwPWzY4CLxdrakFwNwmUIzu/SxlS4B8R4qdQr5TOp+vKXVU7FdjjBSUG5dx +POI714jYlczMn1e81Yz9CH+X0TSn3Oqin+jY7924KyhJo65mTSG3DpOWdO4TPQHdW2m ZE4KGDqHsvl07T2pJwVZaZXSs15fWQpiO3uoQ5+hkn2hbVM6Hp9ioSL5olcrdNtlY6a/ a7ig== 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=kSHT288MyiU1QU8ukOELV7k4Cw1cXgNc3EYxoAijRSmnBnTUyMRb2kIQlzHaslpXBC Alr9826nv/eYghMJjB1J6EzlhgC7Bd+AcL1S2rTMJMY/0rozEwAtxz+jGUnJAjO/Hagh hWUfwKEnjTDNmQLZJbQmWjLMMopaTTOklNm26xq2KDGFZKIOxjcRputEkm97xoea5MCs hMlJ4R+dreAxCpR0Oq6Ri3fKiLXIdwok3plxWZC5ivrma3J6AQ+ItJ4To4ckfiXi4DnD aSEs/sH2JffRNPm/AFCyU/u/X+k9o8IlgRy2aeKfYuhESHSQ7TP7Ybjdms2Yy2E9BZ1P uIbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ANRaTb6t; 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 fh10-20020a1709073a8a00b0088c2a3a6f9csi14040946ejc.199.2023.02.13.02.47.06; Mon, 13 Feb 2023 02:47:29 -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=ANRaTb6t; 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 S231274AbjBMKoT (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbjBMKnX (ORCPT ); Mon, 13 Feb 2023 05:43:23 -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 D793316ACC; Mon, 13 Feb 2023 02:43:20 -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 6AF2460FA8; Mon, 13 Feb 2023 10:43:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B827C4322E; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284997; bh=w4UY5RVGpUGFn7eO+zB8iof9Dgni/IxlD6NiUpdYG9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ANRaTb6tZscxxMgHQQEzKOWqwJiqQIULrVwh6XCDpXkvNoKUwRUdctChMlTIElmLT /i/MaEPN9s5U7WrwPWjFBGmW9C3Yj80cmwIhmxCxXTjNFhG4VXcuI7bkijeoXPUKFc w9N9a68XQazkW23XT2ZVpieE1fXFrBa1Jtp2fmk0rLzzSAtT4CMt1xx1Qzk7RaTk06 fP7YH0yvloiUCe3voNFLu7dtlfaAbWalXrF7hPEA8xngMBbh2BO5fA+3dzYm4/I2YJ n+UWSNuXVJyfiYWO+X1d6juL12+Isf3R0iSir9DS/BGJl1CcQqpvtO87ww8LSOUW8T tOL0QI7yLl4UQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJc-0004X0-BU; Mon, 13 Feb 2023 11:44:08 +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 v6 16/20] irqchip/gic-v3-its: Use irq_domain_create_hierarchy() Date: Mon, 13 Feb 2023 11:42:58 +0100 Message-Id: <20230213104302.17307-17-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712482267730115?= X-GMAIL-MSGID: =?utf-8?q?1757712482267730115?= 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 Mon Feb 13 10:42:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56190 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275859wrn; Mon, 13 Feb 2023 02:47:27 -0800 (PST) X-Google-Smtp-Source: AK7set86avlnx49dwer3l6fUakCtSWCf3VOq2CwlQjUtmaEU3oA/X2vn842LUHeum+MuiJD4qEtf X-Received: by 2002:a17:907:6d8a:b0:887:9a32:9a2 with SMTP id sb10-20020a1709076d8a00b008879a3209a2mr32766305ejc.0.1676285247648; Mon, 13 Feb 2023 02:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285247; cv=none; d=google.com; s=arc-20160816; b=BMp/jNkwjbA/xKcvzEOi5IBx2Xoc5y/tw+46jljrRDB84GjWfWBHBK7zAmK+yon3lE c2EKiT+TlXJK/wb35402ozHP/WQjKo60WFuWN2WX2U51tI2oA967sMBaleDIC+NnWxW0 yTWyhYnasbZw7p0d/N7O4SyFMkhCbk2GdH9oGSX3yWSsyZhv+QE2nRV4WvhmGzXpFRG/ WIjsg/NZBpAl78uZwnC/rB+0lBLohqc63UBFgmY5cQYg2FY7BvBCL7POKiQN03xGMRUS qa5ulwrfqHWswE8lkAsVyDw1KZSopi2e5L0ID0PgRDwTzudYf7ju7WeBltBIF7rU4uzD oxNQ== 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=mMfK+kJCR5iYtc9PfK9V9aRjeO+D9dPQfPjldODeCJUX7XYeFPCDIkYB3kSwyxmsZp 8Gqqu8BxrmUjRUvWrxMN7WW43tn1XEpQQ3784v2rrtNR3ObxWHYMq9FLdw0qCQUV8DQj uq0N63NJIl+GBspdp+P0QVLCy3AF9W0JfMRTYtyX3IRFIq4FMq108eKbHWRusKdCVORt kPPcsEjm3kLeGteTEM18uqhRSVGPOtDGWRIDkxT1d8MHKiI3w2Ukfqw40gEF3HJZ/g2j dZ3mwYHxgY0zU7kQiQ50WtpDqIQvzybELCINipWdWMKvkJp1HGZ4qIVb3NzRAUtuRQjq OqNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KuIt3xJB; 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 f3-20020a1709063f4300b008918d694534si15235057ejj.261.2023.02.13.02.47.04; Mon, 13 Feb 2023 02:47:27 -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=KuIt3xJB; 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 S230430AbjBMKoQ (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbjBMKnX (ORCPT ); Mon, 13 Feb 2023 05:43:23 -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 789A916AD4; Mon, 13 Feb 2023 02:43:21 -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 7D7CE60FBD; Mon, 13 Feb 2023 10:43:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75DD9C43235; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284997; bh=g3QrnnkP4AAAVKLpcN2UD/9G9Q9P7im2mBObh2fnrA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KuIt3xJBOZo7Xx97A1g8XYExdjejDUDPgjx3OG9mnmJ+vjA6ZQA6UuN0JtlB5My1J Q6jR71HtvGBqTsgHQ8vBPRwI5s6LUxyb0IBpV9o3rQ9D4zYtmezgYIngAtKE1Fldj8 blB4z+g+8xml0KsvHjzw4ldwHUMzdKXGSvUpVxsIOXeDbL7shIq6zBGb2EWh1OvHlU ZkQ/ongSdHsOpxxij7KzV+fuWIyfAk96MA9DEnmcSj5oT1io1lgt51QzPClRL1bc1u yyeXEUdw1GBhwIdAjWO5+YYVCOCpkFrIqs0uesnFYbAfaN4pHXOYiICaQuv/SkRCdp nfrBOkzhOvfzg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJc-0004X3-E4; Mon, 13 Feb 2023 11:44:08 +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 v6 17/20] irqchip/gic-v3-mbi: Use irq_domain_create_hierarchy() Date: Mon, 13 Feb 2023 11:42:59 +0100 Message-Id: <20230213104302.17307-18-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712479866044245?= X-GMAIL-MSGID: =?utf-8?q?1757712479866044245?= 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 Mon Feb 13 10:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275921wrn; Mon, 13 Feb 2023 02:47:40 -0800 (PST) X-Google-Smtp-Source: AK7set/9fMqM0GBhr4BCKlX+DurJEBpJhqEKqif0ZfxzktDv42xAwf5V7f7QBOruDD4hEwPAklzh X-Received: by 2002:a17:906:7097:b0:888:94d3:37f5 with SMTP id b23-20020a170906709700b0088894d337f5mr22650527ejk.63.1676285260078; Mon, 13 Feb 2023 02:47:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285260; cv=none; d=google.com; s=arc-20160816; b=bwt9N+MhRw0FAq4FSaJn0t0Ygei7GZ6CEGOhqauqQPsf5jrzFGT4rbKcE+dA6jIfy2 hytCUFI1BiDkjyH5ty5s/XlgqVys6fWfF63DWRULiflNYJISimRii50/E5Rv22StGh1E VEKcUWYUu5PsKtrbvyKJbKvQ9DwTyGibGDN89PSNdVOlLg3G3dkebYKxI2x/gAo3a4CC XSS7okGM6mlPNGBjvNc504BTFFhTg4k17jx46EHfIrGt6Vh5KwkcYAwSjNZmswSam03l fOlmBVqWv1MReYmGybQ9oPm0y6WGA1RItM4kVqBz0pv4cAK8cKHRkxkFe/88PKznyiYv r0tA== 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=D71PVUWKTkYf5xbwFnwCOoBjl+JV/c0EtJee+tKeA8J0Zp4Tzm39W1OvUQjSVS9XBw Z80CGEl7tH+bhi54x6pNZOepNTeZpqQ356WDuC1QuGZi+vGX2VmDREc/CZqMhd7mF+M4 vwn4/7To2waVp/fcyTr5r0t5BBK4wWKv8Oa8o9kwyrVP+YZ43VKFdSUfNZVSCrxr/4ru b4AsyhxwTPZITWDCpPh7X6AK6iaK/1EzoBxY4uQ4OXJR4uRht7zIlfBQx0SfKhQuUgCB ilv0ssAYb2rP64VgTteAvYGdU/dGCRno3QG4T+jwQGFo5U4M77eJ+hG4/3ogt0LY+NYI vx8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gdoiOf9P; 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 16-20020a170906015000b0084cc41e20e2si16941964ejh.624.2023.02.13.02.47.17; Mon, 13 Feb 2023 02:47:40 -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=gdoiOf9P; 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 S231279AbjBMKoW (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjBMKnX (ORCPT ); Mon, 13 Feb 2023 05:43:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 857A416AD9; Mon, 13 Feb 2023 02:43:21 -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 753D060FB5; Mon, 13 Feb 2023 10:43:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F354C4322D; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284997; bh=xReQQbRP8f3ZcgElG5HL2OX/F0HPnUSW+WJ1I2BgRtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gdoiOf9PS9M5a8bj/h1JirELfWDz1MVJxqCr+NulstJZ22rF+WQt7n/JmppMxMNyF CiwKKUyQz3CDQA4/otENz0FUjvvvcyR2GnVO54ZMRrk9DiPaJNOXcjo0d0fPRbG005 lEiGNim1/eF6DSZJG0PywpjO+qpSc4db6VJxpwzmx/EA2GbLVC3vGnY/UBl5mwHwYY c5lEMKYzOpD1ABoaCh0cW1m/fPcrmMKoZU6gHBOjWoR++ecSm5Vf6wM2AGrtC0OVvx srPUaSDdIVR6GZAI7AbRt/SZKr2AZQ1M3anmWZpZZiS4TjAytM9AvYQclKMsII7dxC Frn5Q2en7ySJQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJc-0004X6-Gg; Mon, 13 Feb 2023 11:44:08 +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 v6 18/20] irqchip/loongson-pch-msi: Use irq_domain_create_hierarchy() Date: Mon, 13 Feb 2023 11:43:00 +0100 Message-Id: <20230213104302.17307-19-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712492944412479?= X-GMAIL-MSGID: =?utf-8?q?1757712492944412479?= 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 Mon Feb 13 10:43:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2274878wrn; Mon, 13 Feb 2023 02:44:35 -0800 (PST) X-Google-Smtp-Source: AK7set+W0y0qYX5IRnYuOhXNK2egFlpXzQXE4DzkjpEig1jPUdaFgKAcQxBlVwF6LHv0+BjEuwaJ X-Received: by 2002:a17:906:f191:b0:8ae:ed95:d8e7 with SMTP id gs17-20020a170906f19100b008aeed95d8e7mr16806036ejb.37.1676285075334; Mon, 13 Feb 2023 02:44:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285075; cv=none; d=google.com; s=arc-20160816; b=FT3+OMtF5gEKWk3bpPY+0G64xSDhHOmwHUqw6pHAbs9xLqtLzYkSU4QqNYFhC2Lk0E 18IS8cyFUx3N4dYNCCtV6ojjzTj+jCwFSCTVZ9WViFEWISQb5+cVs8vI6GTd2D7RJJI3 KqjmC9NhYzfxjYMD3QIJ9Mveezr/y+gYv1SgcINg5sOTOz9DapWc1ogl1bd3Jn4CVA3C O2sQZaMLp33lI1goViTS7yApR3R8oxy3t0oTFq9NvpeJDSuDdKsH1Ocrup4VSiKklw2S qmnNZcD+3PpPOiqr6VR0IVFc8RwXBbjlpLU4ElnOhKhtrb9lwKw1+V5EBT0Gan/kXV6z YPvA== 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=Vv9QR7QGzOeGeKVw0nA+rnQtJSWjPuU8N4zyE9t4hmQeJI6yY8zOiW3jxyS599gMI6 6/Ad9g2KoolGc5tIrp51Uk01Lj2vfKJJyOeyBSlw99Igp6sqwBFLPMLPtb6wO98jDO3L ldRdpMAjR95mSXTfY+Pd9PLo1Rqzyp6Avvluyzc9kk63FdMO9J1qYslRUmgIN2lRmy+R 3WTC9q4nX91pOvKwXq+q45Y8uQKwiX6gmr3I3hT2xNu2J5U6JWys8G2MyKSxT8pfPSal FMxJtkzrkB7uNhtALnReX3U+JYYdjvr+8XQYWnnmUNTnxDp8197Gj/LCBzLC6amwiGXz 7cNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dhoeml51; 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 y10-20020a170906518a00b0087d9362c23dsi16092345ejk.842.2023.02.13.02.44.12; Mon, 13 Feb 2023 02:44:35 -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=dhoeml51; 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 S230510AbjBMKnp (ORCPT + 99 others); Mon, 13 Feb 2023 05:43:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbjBMKnV (ORCPT ); Mon, 13 Feb 2023 05:43:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0622C166F9; Mon, 13 Feb 2023 02:43:19 -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 29A8B60F8D; Mon, 13 Feb 2023 10:43:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CEA3C43238; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284997; bh=HISCOQlywscKKiMV1pBIVu7ICjzhN///DKg1eFvToD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhoeml51KJM8ll0CtYS1SWgoxEo/C8kFsPEpYCkltzjIj/1Be//qMw8JqZaVZyWtM s64H1m3LZqwZubHFGvAjhm/7MbQy2toeD8W6Ua30HktBEyC5WfVCmgQYALK6rzRKpe yEtTuTINBQIb84QG1NSWYEcTKORkIGp0VHCRms5WrNmRTBf1myYNgsq2FKIeHwP3PN peLnpfhAZv2FS7hwflt68Fi1BsXmA72S4hI1Bj0ugvjpDEN9Z6QQeOtcTl7fwIOdtp QClv/6Ir7GHfKwyepV0y3vkJnmoyPVVmh4p0gly43/CIJ1qzhxxnQaMZj7g3OYE9OS nGLcLHzZREAkA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJc-0004X9-JY; Mon, 13 Feb 2023 11:44:08 +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 v6 19/20] irqchip/mvebu-odmi: Use irq_domain_create_hierarchy() Date: Mon, 13 Feb 2023 11:43:01 +0100 Message-Id: <20230213104302.17307-20-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712299252540160?= X-GMAIL-MSGID: =?utf-8?q?1757712299252540160?= 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 Mon Feb 13 10:43:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 56188 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2275770wrn; Mon, 13 Feb 2023 02:47:06 -0800 (PST) X-Google-Smtp-Source: AK7set/lbC/+xVBgVCz6+fyv6Uq1iu5mi48JN33CjwwrrF0zi83mXjq1c5puJlJwYpwiN2ywiDNe X-Received: by 2002:a05:6402:1745:b0:4a3:43c1:843c with SMTP id v5-20020a056402174500b004a343c1843cmr6071664edx.16.1676285226424; Mon, 13 Feb 2023 02:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285226; cv=none; d=google.com; s=arc-20160816; b=W/uSXizsZxhiqINTmSeg1IeFIKm/Hm3t2fVoFO4WatJ3KBOXqByZqJsAOCCyRi1Fcw LVQ1KievIddlvdmKYQC8UxXD8VJkT66ZSKG7zT4uPaQ85hFs/pLcy0JblLhDqRerrwAj vOFSskMQvBEeAA45RxYc6qwqtjVTqiyA/NkHkvkBqB26m+wmBxcb1/o5n8sBD4xJj20x /sj06XHjJfhEh3H2+wADCRRK4g00ApW5PKM4prZcYamg+zjvL7OnT9p1W+MJAP8NpmK/ f5k2oKpLPIAuqr+Ms+7g5W1oo/45B+vbpb8fdJMc4DFeMOntTsasiVlOMmLnjP70Y8RF 99KQ== 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=UnfyJayiF1BmbvLkXUNrzJIhKpOi2ZbaZVX6wOmiEiE=; b=jWv622qvYnHoAmDFyX143TkC9FkqLCyXTgmkygry3qVaU8v6PVKua91YiQxEUgu7Yt +V0qM6V6cN3+RNXv1cqVbNgRj0BEZYH6jdnNYsMEFmcoTn8jJsmjU5OK7Zgc90vqrBCN H0F+BaNasp/tfHEpt76Cu5J3EHb17O8UWNKaK7yegvgM1FY1L3ZZO8hnTX5/r5+lELsk 9jmwD4l+q9F3OIWsp1WZRtcd4XID68DfAniMG0tU5EysIBEPPGhLmfu5kghgQ174ghHu 50kksurBlSPhBvZWYrwVmeiJNeFLiVfqmBkdQg5mNZCUpycc1cLzJT8Ka8u0LVEPbmMU Ie9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PWrpM7fH; 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 m16-20020aa7c2d0000000b004abe14b505fsi8869286edp.506.2023.02.13.02.46.43; Mon, 13 Feb 2023 02:47:06 -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=PWrpM7fH; 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 S231236AbjBMKoK (ORCPT + 99 others); Mon, 13 Feb 2023 05:44:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbjBMKnX (ORCPT ); Mon, 13 Feb 2023 05:43:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58FCF16AC7; Mon, 13 Feb 2023 02:43:20 -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 292B560F9F; Mon, 13 Feb 2023 10:43:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E151C4323B; Mon, 13 Feb 2023 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676284997; bh=SMNKWR1xw4kKX0WCWGnKegPn3mimaO2YyT2LNW1Y/fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PWrpM7fHMUvIv+/WI7Dhe+li+yuJRJ4Yu6knDS3W6jCZn34dRpXg9IxLyC0U0SAUl r/HxAkqr/floqgb/l5kt2a4nvw5tcUQ588sjJj2SWJIQvdlQE3DmuHXCFtR9fyb6gr 9Eb9ti9trEwFk3D46vOImc4wGTI4tswahs+2Y/KSIe+NHhapLbazj85UK/R6CWtUcW E1MErfpQZcTlVAdZ6wF5Oyn2HeWdmPuKVycAvPHmPPv1pre+c8WkfYVAeZ5GpxE+2f xQcIykRNA1BuSeWUyhgheQSG6GST/4cnGZoUhjux4j4zIlDRnn7hKDx2HYb0JDGIZX yu41UlUvdK4CQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pRWJc-0004XE-Mk; Mon, 13 Feb 2023 11:44:08 +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 v6 20/20] irqdomain: Switch to per-domain locking Date: Mon, 13 Feb 2023 11:43:02 +0100 Message-Id: <20230213104302.17307-21-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> References: <20230213104302.17307-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?1757712457557610824?= X-GMAIL-MSGID: =?utf-8?q?1757712457557610824?= 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 always points to the right lock. Also note that hierarchical domains should be constructed using irq_domain_create_hierarchy() (or irq_domain_add_hierarchy()) to avoid having racing allocations access a not fully initialised domain. As a safeguard, the lockdep assertion in irq_domain_set_mapping() will catch any offenders that also fail to set the root domain pointer. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- include/linux/irqdomain.h | 4 +++ kernel/irq/irqdomain.c | 59 ++++++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 16399de00b48..d320d15d4fba 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, hierarchical 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 2213d972f083..aa5b7eeeceb8 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -215,6 +215,17 @@ static struct irq_domain *__irq_domain_create(struct fwnode_handle *fwnode, 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 + * always points to the right lock. + */ + mutex_init(&domain->mutex); + domain->root = domain; + irq_domain_check_hierarchy(domain); return domain; @@ -524,7 +535,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; @@ -539,7 +550,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; @@ -561,7 +576,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->root->mutex); irq_set_status_flags(irq, IRQ_NOREQUEST); @@ -583,7 +598,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->root->mutex); } static int irq_domain_associate_locked(struct irq_domain *domain, unsigned int virq, @@ -633,9 +648,9 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, { int ret; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); ret = irq_domain_associate_locked(domain, virq, hwirq); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return ret; } @@ -752,7 +767,7 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, return 0; } - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); /* Check if mapping already exists */ virq = irq_find_mapping(domain, hwirq); @@ -763,7 +778,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->root->mutex); return virq; } @@ -832,7 +847,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, @@ -892,7 +907,7 @@ 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; } @@ -1157,6 +1172,7 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent, domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data); if (domain) { + domain->root = parent->root; domain->parent = parent; domain->flags |= flags; @@ -1555,10 +1571,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; } @@ -1569,7 +1585,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; @@ -1635,7 +1651,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; @@ -1663,7 +1679,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; } @@ -1718,7 +1734,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; @@ -1730,7 +1746,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); @@ -1746,17 +1762,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);