From patchwork Sat Jun 1 22:27:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10971515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 509FC1398 for ; Sat, 1 Jun 2019 22:28:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4151028CD4 for ; Sat, 1 Jun 2019 22:28:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 337F228CE9; Sat, 1 Jun 2019 22:28:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F79528CD4 for ; Sat, 1 Jun 2019 22:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbfFAW2I (ORCPT ); Sat, 1 Jun 2019 18:28:08 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40721 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbfFAW2F (ORCPT ); Sat, 1 Jun 2019 18:28:05 -0400 Received: by mail-pf1-f196.google.com with SMTP id u17so8347983pfn.7 for ; Sat, 01 Jun 2019 15:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rPaZRgyzQF7DCy2Q79gveolqcRd2gZR4xnQeESxSxI8=; b=cAGodZzSRsQMt/+agP3IVTRjmy7GJn9PFgRKDBVOfndMOmU790nOh6r8RDl2NSEttn ozggt0Vl0AEPviZREUImDWgpoB8D77NfGsskgK/Bj9R0lxq+Xa1zB1Rz3dBJYKQUD7bL uSS2mFmHddK5rTGvh+vSHZuyEX0sX9MRSOJjg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rPaZRgyzQF7DCy2Q79gveolqcRd2gZR4xnQeESxSxI8=; b=OxceKX1TUQOAPTTLaW/QynItpyHng5jn1a1diabbyaFk0h2nqKy71xtZraZ2Ui5IV+ GavHvcx9hECnmSX0gPawyO2dpPwSJKe49hfK1ZXx5lCIh/bYKjUWiTuKw+KurfAhwlUI /1cjIbg9tQPYmY5970B2Nj33pgk67PKi3B7kPl6MVNVS17Dgvu/U/50D0WYa64TEuRE1 PHNw0djN5miooPhG9bq393Oh9Ybw1c5/aeNdFuGiz87GML6USySabT3lwpHS4DwcTWGl ACvjLeDYixF03Krcq/ZbJ8WsibS2hCdgn0FLd0aeZleNipLuHX/2I6mpMbI1JkzAtUom a4+w== X-Gm-Message-State: APjAAAUY6E5NgW+K3xraP3JZEPyqYhGVU8n6bOiMjcJvLd3gkF1jOR3M 6c4RjyptwFPl1lE/7AFeV2jAjA== X-Google-Smtp-Source: APXvYqx/DSML7hGGCdUoQbZcef6z1i2E+ZJBXAJvbUYli+Bo+0PJ9dMusQpxsqpBr79TPzH4e5AIzA== X-Received: by 2002:a65:5206:: with SMTP id o6mr18823746pgp.248.1559428084316; Sat, 01 Jun 2019 15:28:04 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id t33sm9908018pjb.1.2019.06.01.15.28.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 01 Jun 2019 15:28:03 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Alexey Kuznetsov , Bjorn Helgaas , Borislav Petkov , "David S. Miller" , edumazet@google.com, Greg Kroah-Hartman , Hideaki YOSHIFUJI , "H. Peter Anvin" , Ingo Molnar , Josh Triplett , keescook@chromium.org, kernel-hardening@lists.openwall.com, Lai Jiangshan , Len Brown , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Mathieu Desnoyers , neilb@suse.com, netdev@vger.kernel.org, oleg@redhat.com, "Paul E. McKenney" , Pavel Machek , peterz@infradead.org, "Rafael J. Wysocki" , rcu@vger.kernel.org, Steven Rostedt , Tejun Heo , Thomas Gleixner , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Subject: [RFC 5/6] x86/pci: Pass lockdep condition to pcm_mmcfg_list iterator Date: Sat, 1 Jun 2019 18:27:37 -0400 Message-Id: <20190601222738.6856-6-joel@joelfernandes.org> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog In-Reply-To: <20190601222738.6856-1-joel@joelfernandes.org> References: <20190601222738.6856-1-joel@joelfernandes.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The pcm_mmcfg_list is traversed with list_for_each_entry_rcu without a reader-lock held, because the pci_mmcfg_lock is already held. Make this known to the list macro so that it fixes new lockdep warnings that trigger due to lockdep checks added to list_for_each_entry_rcu(). Signed-off-by: Joel Fernandes (Google) --- arch/x86/pci/mmconfig-shared.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 7389db538c30..6fa42e9c4e6f 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c @@ -29,6 +29,7 @@ static bool pci_mmcfg_running_state; static bool pci_mmcfg_arch_init_failed; static DEFINE_MUTEX(pci_mmcfg_lock); +#define pci_mmcfg_lock_held() lock_is_held(&(pci_mmcfg_lock).dep_map) LIST_HEAD(pci_mmcfg_list); @@ -54,7 +55,7 @@ static void list_add_sorted(struct pci_mmcfg_region *new) struct pci_mmcfg_region *cfg; /* keep list sorted by segment and starting bus number */ - list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list) { + list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list, pci_mmcfg_lock_held()) { if (cfg->segment > new->segment || (cfg->segment == new->segment && cfg->start_bus >= new->start_bus)) { @@ -118,7 +119,7 @@ struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus) { struct pci_mmcfg_region *cfg; - list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list) + list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list, pci_mmcfg_lock_held()) if (cfg->segment == segment && cfg->start_bus <= bus && bus <= cfg->end_bus) return cfg;