Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752615AbaBJEGN (ORCPT ); Sun, 9 Feb 2014 23:06:13 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:8516 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752262AbaBJEFH (ORCPT ); Sun, 9 Feb 2014 23:05:07 -0500 From: Yijing Wang To: Bjorn Helgaas CC: , , Yijing Wang , Hanjun Guo Subject: [PATCH part1 v5 6/7] PCI: Check pci device serial number when scan device Date: Mon, 10 Feb 2014 12:04:10 +0800 Message-ID: <1392005051-54508-7-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.11.msysgit.1 In-Reply-To: <1392005051-54508-1-git-send-email-wangyijing@huawei.com> References: <1392005051-54508-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.27.212] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sometimes pci device will be removed and reinsert while suspended. In this case system can not identify the device has been changed. Now PCIe support Device Serial Number Capability which has the unique number. So make system check pci device DSN during scanning device if support. Signed-off-by: Yijing Wang --- drivers/pci/probe.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 27d3e6f..370b25c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1383,11 +1383,22 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) struct pci_dev *__ref pci_scan_single_device(struct pci_bus *bus, int devfn) { struct pci_dev *dev; + int rescan = 0; dev = pci_get_slot(bus, devfn); if (dev) { + /* only check func 0 device */ + if (PCI_FUNC(devfn) == 0) { + if (pci_serial_number_changed(dev)) { + pci_bus_freeze_device(bus); + pci_stop_and_remove_bus_device(dev); + pci_bus_unfreeze_device(bus); + rescan = 1; + } + } pci_dev_put(dev); - return dev; + if (!rescan) + return dev; } dev = pci_scan_device(bus, devfn); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/