From patchwork Mon Jan 16 13:50:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202577wrn; Mon, 16 Jan 2023 05:53:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXtRf8eQgJJuKDuz+/I4jL9RyH6X4c3t9jyK41Jo/iY3KXbe1FtZ1wfzDlq9NK/b8a8qvsHS X-Received: by 2002:a17:906:6dce:b0:7c3:e3ef:bca1 with SMTP id j14-20020a1709066dce00b007c3e3efbca1mr77236521ejt.60.1673877217175; Mon, 16 Jan 2023 05:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877217; cv=none; d=google.com; s=arc-20160816; b=Fr1FCfdbhJYjYw+KKBq24R7iXh3m9DFr9fGsSerjzTslYkxg/ap42ia64pnabQkX/B xR6TFL1o2NvbRBJOSZQUDsnjmKt85j9FTMDdct7eyi0+knCj1q+qhgOFdgRQ0DefIexp 5sIq1JyqRuVnd0D1vZ69CkX5kK3DmNdzXHbbigz8DaasqjJb3BqTpLGyJm7Sw/7cjoNq i42/SPPWQ62CR+DGXjMMASNS5y6OPtOwjY0s3QdwAMb5OUOQWFzoVg3L2IEyvRu4yBpF G6GoewawaQ0c6e9riZmTGeMCIkv6OtYwtNR057f04Y5qKGn1p1AMorNECPDHDtsDm1T6 T3yw== 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=rOQcjiJysgkAnLhPnpeszLDm///LM3zPVgI/U0Cn9hE=; b=U/xEAVc0OfcmoJAhWtjNtcIxMq5eQczDVclN4CkJxjcwa6JlW+imJCe8zHHB9nDAP7 9vzZ2MqtsAl39oJWEu8SSpNce4AOSXAQt0BoqJGlsD5xPqka/73rHxyg/9zBxK2BZj3S Uqzk1RC66WlHvFApCcRNucx+jOMWPvl3/qBES52hMk+3yqSAYBKJg/IJGUGRIKJPLhTJ Q7t41ZjKUWazicBHa1K9Xo+YOJNgliAPItfnJk3QUEjixSZN/KOKVL1gmIbUUidir7XO olduDsYT/UTh1pq2Jk9g0E8lVYLncxWdV0COxmnuZFuTaj5/lr4f6DGIN6/al0TfODhM soyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GZdwS8bA; 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 cw18-20020a170906479200b008641d4f0500si16820801ejc.301.2023.01.16.05.53.13; Mon, 16 Jan 2023 05:53:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GZdwS8bA; 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 S231628AbjAPNvI (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231436AbjAPNun (ORCPT ); Mon, 16 Jan 2023 08:50:43 -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 20C2421945; Mon, 16 Jan 2023 05:50:42 -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 B28DE60FC6; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9767DC43392; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=Sc/MXrEwZaxI4omzYCVHgWpM1c0Ozs8INEgkW+Kkfxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GZdwS8bAvdzWN/C6v/U15xmHvbQMQMJusVQTi9CqJfflW/jPFbn3aYdXTST2GS1hv ChWtwzHM9Mo6bKs2CLsEmdTjFdL/zEumhE3mzEhXtRCRsHvoeixjPySaA7MX0P6B55 Vhw9Kbo3g3EM6g0/QTjGYHErVQuIgXI6FpFpnntNtkCY56NtR4870LolZ9+RXwI0eW KjvIpJ5o/R9jTF1Dlw9S97JdX8yEZqI9ZaszR6vU9qk3jNFuBgQn5xOBl18KH7oGFb x0ft+UcfE6D4hkXHV3EOcU2UDR0XlFd/EaW6NVQItAnk0l2yIvJmHlMp8mS8jkV/Ya 5tidaNTVroP+Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt5-0003ux-Vi; Mon, 16 Jan 2023 14:51:00 +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 v4 06/19] irqdomain: Drop revmap mutex Date: Mon, 16 Jan 2023 14:50:31 +0100 Message-Id: <20230116135044.14998-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-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?1755187476938496771?= X-GMAIL-MSGID: =?utf-8?q?1755187476938496771?= The global irq_domain_mutex is now held in all paths that update the revmap structures so there is no longer any need for the revmap mutex. 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 5b2718e1c6de..7fd3939328c2 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 23f5919e58b7..248e6acfafbe 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -214,7 +214,6 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s /* Fill structure */ INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); - mutex_init(&domain->revmap_mutex); domain->ops = ops; domain->host_data = host_data; domain->hwirq_max = hwirq_max; @@ -501,30 +500,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) @@ -1511,11 +1510,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); @@ -1524,7 +1524,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); } /**