Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5155055ybl; Mon, 26 Aug 2019 23:48:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaDaQPTX6/AjkiS87fsjKnGr4LR2dzMMMlTWLUIWjsmZGS+1qoODR4RpwT6VY94wHIkhgf X-Received: by 2002:a62:24a:: with SMTP id 71mr24573030pfc.148.1566888485398; Mon, 26 Aug 2019 23:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566888485; cv=none; d=google.com; s=arc-20160816; b=dqxpeEVRo7adGJ36AnlAfavZ9oxu7+BxO4r+W3/b/B+yrPo86UP76NY4d93ykSIOGw nLoV89GL+s/7yrlkuVqKTc4d9HlB2enBd7730xzT5SADPOoSS+CqWtKdhw1T9rnA1QeI uPivRUnKk6uuK1/YtZV8akDNWuFrH0UQvFzXcxuLKTmB+FigXm6TGPZa8ZxCIlx9aotF V3AQ8MGtQPkplEaGJdy2cvnDUVEmyetrMqSaVDM1b8gV7Xjmpz+PAr2rko0DMF4MsXqg gPllSftvBL7X6M/tleoUyrNTImWRV5yoAdKQtL8UXp2xQs+PsrKD97NYAoe51+5xqVj3 qfcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=aIUuhi6jmN5PZjiZts1UJNzal86zcbH5EsAlhi6M/dQ=; b=wTh2ekKqLijIO742oLDnQQ6sfnStL0ir9o3uDYog5QD7P3lnyRWUgeqrRLGrxjC/B5 L7aKuOeGHEpcb2DcnqNOjojTK2YTpDLK6OSAveuyU6UNh3X23uQYsAQTElriDb5f0NYy RQ6humbSapgcE+S17yS1duKqvFmkye/0VRfp4OgSZVkgKtE6knk7zmAlr2B9w7IBjf1U Z1SN1IdqNa8mjjnplNjPVl7+e+R9sQaCXasqjYe8d3SMT7JZJOsS8sw5qK5NToVaCYb5 Yu+XSckBj4BgpBrzMTXKvBWwQW4j+QJ87SAM3JyEqpAD9QaLWoLsg5UNsT7xoPZlPgR9 DqaQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si160939pfg.203.2019.08.26.23.47.49; Mon, 26 Aug 2019 23:48:05 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727267AbfH0Gqn (ORCPT + 99 others); Tue, 27 Aug 2019 02:46:43 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5662 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725825AbfH0Gqn (ORCPT ); Tue, 27 Aug 2019 02:46:43 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id EF80199B740A55BD5CC6; Tue, 27 Aug 2019 14:46:39 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Tue, 27 Aug 2019 14:46:30 +0800 From: Xiongfeng Wang To: , CC: , , , , Subject: [PATCH] pci: get pm runtime ref before resetting bus Date: Tue, 27 Aug 2019 14:43:36 +0800 Message-ID: <1566888216-8810-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When I inject a PCIE Fatal error into a mellanox netdevice, 'dmesg' shows the device is recovered successfully, but 'lspci' didn't show the device. I checked the configuration space of the slot where the netdevice is inserted and found out the bit 'PCI_BRIDGE_CTL_BUS_RESET' is set. Later, I found out it is because this bit is saved in 'saved_config_space' of 'struct pci_dev' when 'pci_pm_runtime_suspend()' is called. And 'PCI_BRIDGE_CTL_BUS_RESET' is set every time we restore the configuration sapce. This patch use 'pm_runtime_get' to avoid saving the configuration space of the bridge when the bus is being reset. Signed-off-by: Xiongfeng Wang --- drivers/pci/pci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 9cae66c..0079f0a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4546,6 +4546,9 @@ void pci_reset_secondary_bus(struct pci_dev *dev) { u16 ctrl; + /* avoid wrongly saving 'PCI_BRIDGE_CTL_BUS_RESET' */ + pm_runtime_get(&dev->dev); + pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &ctrl); ctrl |= PCI_BRIDGE_CTL_BUS_RESET; pci_write_config_word(dev, PCI_BRIDGE_CONTROL, ctrl); @@ -4567,6 +4570,8 @@ void pci_reset_secondary_bus(struct pci_dev *dev) * but we don't make use of them yet. */ ssleep(1); + + pm_runtime_put(&dev->dev); } void __weak pcibios_reset_secondary_bus(struct pci_dev *dev) -- 1.7.12.4