From patchwork Thu Oct 5 01:44:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 114821 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp61738qgn; Wed, 4 Oct 2017 18:46:04 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBNgxBzmXssJKYe3+2sy2oLTmf9pqGOHaPWGmSQ3OjH1hiWlvDX9JzicJYaEEkonnuIEJ1E X-Received: by 10.98.49.3 with SMTP id x3mr11522197pfx.118.1507167964097; Wed, 04 Oct 2017 18:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507167964; cv=none; d=google.com; s=arc-20160816; b=bkrDWGdBtYQzCQ6tYpC2uvhnWVkrgzcwvyD5y2LfPZaIGmkA7OT1gUUaX8F8Mnbeno Rap4iDHWOzuXXZGTNfqvhp59HD4OrkP/W4bE/wHF/14/TGEqDF9/m2Pj4LYZNyOtSolE cnqPFHmEV37EVha9+sYk6LggV/6LWoxKTCeqX4g5FW5a2Hfj1JLE3s+c/npVN6aj88pQ ZxoF09mLe6IiL8FR1BI7yy3PSlT182tKjkRIr2xHL8m7vT8PXBdRsNQzD3Rub50kHX/O R8EFj6uhv0pedL9/rQUwh3B69Tgc8jernnN/4BJwHxNJmu+V69ViOhMycCv91NezUBjO pSmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=1UvqeCygQCWIRh4bBweohIboKhXVWbR6Vwvjuo9i6gU=; b=Am2TjUCiP0HG9x7uPylBkaC+YWCUPnO6xfp9LVkGFZpTJk9+e1dzOntcBD5p9HU314 vFZu/IGXZqaP8eQlOA+0U4p+r8xrewO4kycQyGqObKLdlaikiWlZ0kijF4DyeEW3vuad EtKeyOO0wlSPqrvBw3PgkWBnH9JP6VKRMY3E7XFkMaKcsv/C8WB6vtNZyoJs7wCDhQdA DRSj/hQr84uv8peJU10JTZF27u07VYb0sJtr0W0sxURrLGy2yAXk8FlU/gETL29FXkz2 RHBT7edzT2OsFH4Vfq7dWQAFTPjxYBG4+YT3No+bMZ2FJFw42nRhDxVJVkaTPybRC1dr P/og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=OFspGc3J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si12369807pga.649.2017.10.04.18.45.59; Wed, 04 Oct 2017 18:46:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=OFspGc3J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751322AbdJEBpx (ORCPT + 26 others); Wed, 4 Oct 2017 21:45:53 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:34737 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751201AbdJEBpw (ORCPT ); Wed, 4 Oct 2017 21:45:52 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id v951jJmN027940; Thu, 5 Oct 2017 10:45:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com v951jJmN027940 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507167919; bh=1UvqeCygQCWIRh4bBweohIboKhXVWbR6Vwvjuo9i6gU=; h=From:To:Cc:Subject:Date:From; b=OFspGc3JihXtwp5T1IszHBaZoq7XZJ5aGkkvvWI6KBknHNEweOsXAvmnznngWGz35 Nf9pln/FyKgMHB5jG57a0QdOybFHwS3zfdGupCfDtlrR6b3mtCMTJbyveNZSEsIi8Q ZHXusPjaVQMeDxZLQSfHK9l1YhxmZx70h51ggg5MtXNNqBMRh5dXJ66d9AtiQQp26c 7mCFRGOjjd71wuCG43Qyl7Iejayq1oFMqkNb28tjY0POGhd2D5LKo+6rLWafi9NPNL sZUgfD+FvRpzWOtqKKJIY0MbnWS2WC3VFiEt5A0rVhJ6DkCM8EScAfpxGHI423tME4 eUtWsDotCOF3g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2] irqdomain: move revmap_trees_mutex to struct irq_domain Date: Thu, 5 Oct 2017 10:44:54 +0900 Message-Id: <1507167894-8315-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The revmap_trees_mutex protects domain->revmap_tree. There is no need to make it global because it is allowed to modify revmap_tree of two different domains concurrently. Having said that, this would not be a actual bottleneck because the interrupt map/unmap does not occur quite often. Rather, the motivation is to tidy up the code from a data structure point of view. Signed-off-by: Masahiro Yamada --- Changes in v2: - Update git-log. I believe this clean-up is worthwhile. include/linux/irqdomain.h | 2 ++ kernel/irq/irqdomain.c | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 81e4889..56b68b0 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -32,6 +32,7 @@ #include #include #include +#include #include struct device_node; @@ -172,6 +173,7 @@ struct irq_domain { unsigned int revmap_direct_max_irq; unsigned int revmap_size; struct radix_tree_root revmap_tree; + struct mutex revmap_tree_mutex; unsigned int linear_revmap[]; }; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index ac4644e..7870800 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -21,7 +21,6 @@ static LIST_HEAD(irq_domain_list); static DEFINE_MUTEX(irq_domain_mutex); -static DEFINE_MUTEX(revmap_trees_mutex); static struct irq_domain *irq_default_domain; static void irq_domain_check_hierarchy(struct irq_domain *domain); @@ -211,6 +210,7 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size, /* Fill structure */ INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); + mutex_init(&domain->revmap_tree_mutex); domain->ops = ops; domain->host_data = host_data; domain->hwirq_max = hwirq_max; @@ -462,9 +462,9 @@ static void irq_domain_clear_mapping(struct irq_domain *domain, if (hwirq < domain->revmap_size) { domain->linear_revmap[hwirq] = 0; } else { - mutex_lock(&revmap_trees_mutex); + mutex_lock(&domain->revmap_tree_mutex); radix_tree_delete(&domain->revmap_tree, hwirq); - mutex_unlock(&revmap_trees_mutex); + mutex_unlock(&domain->revmap_tree_mutex); } } @@ -475,9 +475,9 @@ static void irq_domain_set_mapping(struct irq_domain *domain, if (hwirq < domain->revmap_size) { domain->linear_revmap[hwirq] = irq_data->irq; } else { - mutex_lock(&revmap_trees_mutex); + mutex_lock(&domain->revmap_tree_mutex); radix_tree_insert(&domain->revmap_tree, hwirq, irq_data); - mutex_unlock(&revmap_trees_mutex); + mutex_unlock(&domain->revmap_tree_mutex); } } @@ -1459,11 +1459,11 @@ static void irq_domain_fix_revmap(struct irq_data *d) return; /* Not using radix tree. */ /* Fix up the revmap. */ - mutex_lock(&revmap_trees_mutex); + mutex_lock(&d->domain->revmap_tree_mutex); slot = radix_tree_lookup_slot(&d->domain->revmap_tree, d->hwirq); if (slot) radix_tree_replace_slot(&d->domain->revmap_tree, slot, d); - mutex_unlock(&revmap_trees_mutex); + mutex_unlock(&d->domain->revmap_tree_mutex); } /**