Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2281116imm; Thu, 18 Oct 2018 11:58:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV61DzBPlXI+pb4cgeeg4IV9hgtpDX6TS6/9NkwhFl98blR8we5Z5CcwzTW3icsCoMXjhBBWS X-Received: by 2002:a63:db04:: with SMTP id e4-v6mr29544033pgg.280.1539889126353; Thu, 18 Oct 2018 11:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539889126; cv=none; d=google.com; s=arc-20160816; b=Yxcg2JB+4Q8+NyB5nzn+cjx5I/esugAlQRSP4Wq+sVsg4UeX4w4jlppKvXD0VaBpPM wtszAiuXEDgM5jzgKnfhqJJYsN4reTqVLSTZpieLryxcEy9Ie4Q4Y2x+Fs9SC5aKgFpH 7dgv9LsbEJANhesTPJoNH6/Skv8scTwxRUTSnXl/4Nu08ZpPaV01K8E0/uoXhmDcNJ1Z fHuQ7Vsi7rQyI592p6jEfGZMZud12EDGFf08G/VdMoUJS5N29UNLy5fjyuzY809FME+o WKavU4ygzAZDLfAZuy5jc+vr+3LYhJ1UPq8TM5oPH+R4jnitU3rbGNKSBB34T4BauWur IC7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=NclvvB40TxQbdPL4DDvlauQ+xtT8J1d4L7Y1pNey3NI=; b=aoBTzVTIqXUgbFapXmDjqLhVJfy4jtavlldXn+Eq+ZJAuUbHLPVt2o/yoPbaBgDSrs l5MypVnmriXzxgMsKmNsBk5q6SkrJudxI5p1CoxfkeahZLk65DydgvAMxkcVrcDWGnzY 9EV9Fn/yb4cVoNUmZmKTKiUgFCI+Um4s81T6Za6KyxrtcPCOgHLIv8QIps8SrzkXRVjB 6CS107zfD9tYmMQFseLhvIDeFgbiYtuPhg3eGfpwqSD+mnON7F2iQ8XLvCRAyE4Cq9W6 jCJ0HuWXVJfgPsqC/EU3gJLE51lqetdalzwg04zuJraoRhFXUKnHKmE4EQVMYecLnKEK JJug== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10-v6si1565921pgj.169.2018.10.18.11.58.31; Thu, 18 Oct 2018 11:58:46 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727697AbeJSCjo (ORCPT + 99 others); Thu, 18 Oct 2018 22:39:44 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:34582 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726465AbeJSCjo (ORCPT ); Thu, 18 Oct 2018 22:39:44 -0400 Received: from mail-qt1-f200.google.com ([209.85.160.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gDDAj-0006c1-G9 for linux-kernel@vger.kernel.org; Thu, 18 Oct 2018 18:37:25 +0000 Received: by mail-qt1-f200.google.com with SMTP id x7-v6so33068996qtb.6 for ; Thu, 18 Oct 2018 11:37:25 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=NclvvB40TxQbdPL4DDvlauQ+xtT8J1d4L7Y1pNey3NI=; b=s975NedsR+rz6WOcWVxMl046pinoNwypNnTcTWjHaRFz2taLUSI9yrLdziKB+uzSAH CBrNAzQzLLtpOMDKAv4Nj5aSt064IW/O3R706lRIZ7VMGy87Yy7bxA0kkMKcRAXazRvR jZ/svu/eQ6Ro26VSRBLfT6kymrCQToCFUa2qz4z/lVIP7OSOwZKEWrphO91KLy1APbrV yOs+bO8YZc66jHO1h64DZojjKCDOMP3R6jAmjfUoYUBJqWApXvTr95TgSLAcSnfD+3c4 hqOD/10Z9XmIrvI3VGixqooaBsf+KmzAQC72sBp1WZU3mRDx9BAW0j+5q/0B5a6OWtpQ XNCg== X-Gm-Message-State: ABuFfoh/dNkSO2D5dFOUT4tESClfkFaeVeEGqnCiKxEIALIl5+Nwst5W XUm25UUnBlrR6NsF/we8sOg45kQpq4QvQ698uIt9DL0YCG79C3UjAkYeQIbGRhO1PKvVOwoYNy6 bLBjmvbda2jfavhkcPAzSn9XE57ZnUJ2K3pQ5sNfkKw== X-Received: by 2002:aed:3165:: with SMTP id 92-v6mr29266235qtg.72.1539887844664; Thu, 18 Oct 2018 11:37:24 -0700 (PDT) X-Received: by 2002:aed:3165:: with SMTP id 92-v6mr29266205qtg.72.1539887844485; Thu, 18 Oct 2018 11:37:24 -0700 (PDT) Received: from localhost ([179.225.132.84]) by smtp.gmail.com with ESMTPSA id o41-v6sm16209527qto.38.2018.10.18.11.37.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 11:37:23 -0700 (PDT) From: "Guilherme G. Piccoli" To: linux-pci@vger.kernel.org, kexec@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, bhelgaas@google.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, andi@firstfloor.org, lukas@wunner.de, billy.olsen@canonical.com, cascardo@canonical.com, ddstreet@canonical.com, fabiomirmar@canonical.com, gavin.guo@canonical.com, gpiccoli@canonical.com, jay.vosburgh@canonical.com, kernel@gpiccoli.net, mfo@canonical.com, shan.gavin@linux.alibaba.com Subject: [PATCH 1/3] x86/quirks: Scan all busses for early PCI quirks Date: Thu, 18 Oct 2018 15:37:19 -0300 Message-Id: <20181018183721.27467-1-gpiccoli@canonical.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Recently was noticed in an HP GEN9 system that kdump couldn't succeed due to an irq storm coming from an Intel NIC, narrowed down to be lack of clearing the MSI/MSI-X enable bits during the kdump kernel boot. For that, we need an early quirk to manually turn off MSI/MSI-X for PCI devices - this was worked as an optional boot parameter in a subsequent patch. Problem is that in our test system, the Intel NICs were not present in any secondary bus under the first PCIe root complex, so they couldn't be reached by the recursion in check_dev_quirk(). Modern systems, specially with multi-processors and multiple NUMA nodes expose multiple root complexes, describing more than one PCI hierarchy domain. Currently the simple recursion present in the early-quirks code from x86 starts a descending recursion from bus 0000:00, and reach many other busses by navigating this hierarchy walking through the bridges. This is not enough in systems with more than one root complex/host bridge, since the recursion won't "traverse" to other root complexes by starting statically in 0000:00 (for more details, see [0]). This patch hence implements the full bus/device/function scan in early_quirks(), by checking all possible busses instead of using a recursion based on the first root bus or limiting the search scope to the first 32 busses (like it was done in the beginning [1]). [0] https://bugs.launchpad.net/bugs/1797990 [1] From historical perspective, early PCI scan dates back to BitKeeper, added by Andi Kleen's "[PATCH] APIC fixes for x86-64", on October/2003. It initially restricted the search to the first 32 busses and slots. Due to a potential bug found in Nvidia chipsets, the scan was changed to run only in the first root bus: see commit 8659c406ade3 ("x86: only scan the root bus in early PCI quirks") Finally, secondary busses reachable from the 1st bus were re-added back by: commit 850c321027c2 ("x86/quirks: Reintroduce scanning of secondary buses") Reported-by: Dan Streetman Signed-off-by: Guilherme G. Piccoli --- arch/x86/kernel/early-quirks.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c index 50d5848bf22e..fd50f9e21623 100644 --- a/arch/x86/kernel/early-quirks.c +++ b/arch/x86/kernel/early-quirks.c @@ -731,7 +731,6 @@ static int __init check_dev_quirk(int num, int slot, int func) u16 vendor; u16 device; u8 type; - u8 sec; int i; class = read_pci_config_16(num, slot, func, PCI_CLASS_DEVICE); @@ -760,11 +759,8 @@ static int __init check_dev_quirk(int num, int slot, int func) type = read_pci_config_byte(num, slot, func, PCI_HEADER_TYPE); - if ((type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) { - sec = read_pci_config_byte(num, slot, func, PCI_SECONDARY_BUS); - if (sec > num) - early_pci_scan_bus(sec); - } + if ((type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) + return -1; if (!(type & 0x80)) return -1; @@ -787,8 +783,11 @@ static void __init early_pci_scan_bus(int bus) void __init early_quirks(void) { + int bus; + if (!early_pci_allowed()) return; - early_pci_scan_bus(0); + for (bus = 0; bus < 256; bus++) + early_pci_scan_bus(bus); } -- 2.19.0