From patchwork Mon Feb 13 19:40:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 56511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2537437wrn; Mon, 13 Feb 2023 11:43:17 -0800 (PST) X-Google-Smtp-Source: AK7set8sMJCf7sIsaUafshrUSV6tqsqqUPAe5XpB/VFJU78aCsUqbG3vq6GgkR+NGP9n765ufZRg X-Received: by 2002:a50:cd04:0:b0:49d:a60f:7827 with SMTP id z4-20020a50cd04000000b0049da60f7827mr26839223edi.6.1676317397179; Mon, 13 Feb 2023 11:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676317397; cv=none; d=google.com; s=arc-20160816; b=bAl9VU2Ar910j+OpWYBhu6OVq5vu24LCzuV+8BMUAFb+KBOhJ89uMmDBiCmHyjtFg0 2kdBVdTLqx6bscj023a8AcCIM1SrsmiElhZYhjLob6/rOahVU86QG/UE5xOnRE/IzS2F yUaoDG9J4pSCVZ1nePaVzODoGRdZjBakzV33/kC42fFjaqM+qKkB/iS24Y8A92Y6VGcT gzkK8TmY1NIY0G8VNV7a7qMTft8KkohxC2vz80tioN8Z8JHwWtMT9izVBaNDg3JbibiD EA8np/c2Sb6q4IWuJza1FrrCEOGtobkrGVAOk3G6sgk6078zlZyPWMyhfZbe6Th7uFN+ zAhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=i0PCYOhUdk1wVFPCezjGMR3/OaTG/q/QU5lOobz+7uk=; b=knRM6hCK/wR6LT+3I9NBRFqZmMiYfd1SJLqqQL4ThGKD7F6Wkor1KonnUOsOuhMPTj AE2Ito9DtGl4V0lDA5rKaMlYinhvZG/6WndrxTg/uyOJUZgDx/3odGDbU2kEnDrWfqKc 0BJhe59NgaYdNGt0VfNyFTwdkagF8rDl7eQ8G6usFxIxPHUw1y7bZbJzzQJPdQyHJ2zl aQtadZaVPq4TRuCE1OSKIBjDJ8U48bOG41NpqjPJBs7tLBoHGCoKzoaF3y36OoSk8BZU 5JC3+sr9+lmg/tyJ7BGC8EU+oS4D7H2rUJKK4p4XIIS9XlWtT7TOI6xXkipFFcHhj5LU SuPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rrlQ6kJF; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020aa7d486000000b004acaa4dcac4si8954797edr.583.2023.02.13.11.42.54; Mon, 13 Feb 2023 11:43:17 -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=@linutronix.de header.s=2020 header.b=rrlQ6kJF; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231416AbjBMTlO (ORCPT + 99 others); Mon, 13 Feb 2023 14:41:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbjBMTkx (ORCPT ); Mon, 13 Feb 2023 14:40:53 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB00E21298 for ; Mon, 13 Feb 2023 11:40:46 -0800 (PST) Date: Mon, 13 Feb 2023 19:40:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1676317245; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0PCYOhUdk1wVFPCezjGMR3/OaTG/q/QU5lOobz+7uk=; b=rrlQ6kJF6vhvbfV1fK0/FAGMugeIzZ6Ki0PQZKbco2PNMF1jfjkdqo316OCYCTKKAm1hni oBYH4RCxWEueWQLbF/oB+JpLeLp1vDeslagInosDOSbOhoqt+SKS9YL7CDEXkuL0E9a/rM sHE4RZFPwPf4s/EpeFWDc3nXjhsIKka1TA2cm4N9VPXowmfW7YR5jzIIQwV4WdaDIOk9Tb k8b/DzHK11MGUDsSwLSup3DPIb3pBdjoSa999e9pMWcpimAiMnCnQqT3uVicbfYAMaqlas GRlc/zLFXwS0kmuwF39k+GB993yp0M/AvD/AnkWkBrCQXfO45q9GNIrDFcWfAA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1676317245; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0PCYOhUdk1wVFPCezjGMR3/OaTG/q/QU5lOobz+7uk=; b=FiEdRNq5PXemgehMdop550L6LnMOh4z1F+OOivm73dWtZLsTISarbpKiBhiUJmzfnx6psl BQXKbFlaxrDj+YAA== From: "irqchip-bot for Johan Hovold" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-next] irqdomain: Drop revmap mutex Cc: "Hsin-Yi Wang" , "Mark-PK Tsai" , Johan Hovold , Marc Zyngier , tglx@linutronix.de In-Reply-To: <20230213104302.17307-9-johan+linaro@kernel.org> References: <20230213104302.17307-9-johan+linaro@kernel.org> MIME-Version: 1.0 Message-ID: <167631724497.4906.15252452660937628189.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,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?1757746191063548910?= The following commit has been merged into the irq/irqchip-next branch of irqchip: Commit-ID: 47d1932f37de99bae3345bb93f098ac8750ab0fb Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/47d1932f37de99bae3345bb93f098ac8750ab0fb Author: Johan Hovold AuthorDate: Mon, 13 Feb 2023 11:42:50 +01:00 Committer: Marc Zyngier CommitterDate: Mon, 13 Feb 2023 19:31:24 irqdomain: Drop revmap mutex 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 Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20230213104302.17307-9-johan+linaro@kernel.org --- 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 a372086..16399de 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 a6d1b10..c7113e7 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); } /**