From patchwork Fri Jul 19 19:14:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 260338 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5F67A2C0098 for ; Sat, 20 Jul 2013 05:14:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752196Ab3GSTOj (ORCPT ); Fri, 19 Jul 2013 15:14:39 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:22814 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751926Ab3GSTOj (ORCPT ); Fri, 19 Jul 2013 15:14:39 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r6JJEMPd007364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Jul 2013 19:14:23 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6JJELp7011114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 19 Jul 2013 19:14:22 GMT Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6JJEL6Q000163; Fri, 19 Jul 2013 19:14:21 GMT Received: from linux-siqj.site (/10.159.181.233) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 19 Jul 2013 12:14:20 -0700 From: Yinghai Lu To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Yinghai Lu , Yijing Wang , Subject: [PATCH] PCI: Fix hotplug remove with sriov again Date: Fri, 19 Jul 2013 12:14:16 -0700 Message-Id: <1374261258-23036-1-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.1.4 X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Found hot-remove pcie card with sriov enabled cause crash in v3.10. It is regression caused by commit ba518e3c177547dfebf7fa7252cea0c850e7ce25 (PCI: pciehp: Iterate over all devices in slot, not functions 0-7) That commit change to use bus->devices to iterate devices under bus to run pci_stop_and_remove_bus_device(). Actually it duplicates the problem with those bus->devices iteratation that we try to fix in commit ac205b7bb72fa4227d2e79979bbe2b4687cdf44d (PCI: make sriov work with hotplug remove) Change to iterate reversely as we did last time. Signed-off-by: Yinghai Lu Cc: Yijing Wang Cc: v3.9+ --- drivers/pci/hotplug/pciehp_pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/pci/hotplug/pciehp_pci.c =================================================================== --- linux-2.6.orig/drivers/pci/hotplug/pciehp_pci.c +++ linux-2.6/drivers/pci/hotplug/pciehp_pci.c @@ -92,7 +92,13 @@ int pciehp_unconfigure_device(struct slo if (ret) presence = 0; - list_for_each_entry_safe(dev, temp, &parent->devices, bus_list) { + /* + * Need to iterate device reversely, as during + * stop PF driver, VF will be removed, the list_for_each + * could point to removed VF with temp. + */ + list_for_each_entry_safe_reverse(dev, temp, &parent->devices, + bus_list) { pci_dev_get(dev); if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) { pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl);