From patchwork Tue Dec 11 02:18:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 10722981 X-Patchwork-Delegate: bhelgaas@google.com 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 22F031751 for ; Tue, 11 Dec 2018 02:18:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02A0329EB2 for ; Tue, 11 Dec 2018 02:18:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E47A729ECE; Tue, 11 Dec 2018 02:18:48 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 6545329EB2 for ; Tue, 11 Dec 2018 02:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729518AbeLKCSm (ORCPT ); Mon, 10 Dec 2018 21:18:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48450 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727485AbeLKCSm (ORCPT ); Mon, 10 Dec 2018 21:18:42 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B662658E29; Tue, 11 Dec 2018 02:18:41 +0000 (UTC) Received: from redhat.com (ovpn-120-187.rdu2.redhat.com [10.10.120.187]) by smtp.corp.redhat.com (Postfix) with SMTP id B02F560BF1; Tue, 11 Dec 2018 02:18:40 +0000 (UTC) Date: Mon, 10 Dec 2018 21:18:40 -0500 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: xuyandong , stable@vger.kernel.org, Yinghai Lu , Jesse Barnes , Bjorn Helgaas , linux-pci@vger.kernel.org Subject: [PATCH] pci: avoid bridge feature re-probing on hotplug Message-ID: <20181211021617.24072-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 11 Dec 2018 02:18:41 +0000 (UTC) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP commit 1f82de10d6 ("PCI/x86: don't assume prefetchable ranges are 64bit") added probing of bridge support for 64 bit memory each time bridge is re-enumerated. Unfortunately this probing is destructive if any device behind the bridge is in use at this time. There's no real need to re-probe the bridge features as the regiters in question never change - detect that using the memory flag being set and skip the probing. Avoiding repeated calls to pci_bridge_check_ranges might be even nicer would be a bigger patch and probably not appropriate on stable. Reported-by: xuyandong Cc: stable@vger.kernel.org Cc: Yinghai Lu Cc: Jesse Barnes Signed-off-by: Michael S. Tsirkin Tested-by: xuyandong --- This issue has been reported on upstream Linux and Centos. drivers/pci/setup-bus.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index ed960436df5e..7ab42f76579e 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -741,6 +741,13 @@ static void pci_bridge_check_ranges(struct pci_bus *bus) struct resource *b_res; b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; + + /* Don't re-check after this was called once already: + * important since bridge might be in use. + */ + if (b_res[1].flags & IORESOURCE_MEM) + return; + b_res[1].flags |= IORESOURCE_MEM; pci_read_config_word(bridge, PCI_IO_BASE, &io);