From patchwork Fri Aug 17 23:36:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 1340131 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 673423FC81 for ; Fri, 17 Aug 2012 23:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756906Ab2HQXg3 (ORCPT ); Fri, 17 Aug 2012 19:36:29 -0400 Received: from mail-we0-f202.google.com ([74.125.82.202]:45478 "EHLO mail-we0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755445Ab2HQXg2 (ORCPT ); Fri, 17 Aug 2012 19:36:28 -0400 Received: by weyr1 with SMTP id r1so207182wey.1 for ; Fri, 17 Aug 2012 16:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=LfYXH9I20oMLWWfV/4NEC6qh3Iyu/bPpJgDQiFojR7o=; b=n6bpLc5lKvpisbmZBLGeLnbZPozQqB6YyJ72O+EqLVdxowtRYChaA9EgiAkDwbp4td TF2BzCZ/Fbu0osuq5bpHwxtoqhCfKPhlXOPuvTbnXRz2qWGiDeQd4DpEY9Q7+IenRlrA X3v/dZ9WVVipFZhmFELpwNusagqKwtzfR+Qt6N1C86l58KXmfzH0pNsHh7E4f7Tc0tQD teRZUG6J9jusJnUzTYCW4z+aynz0uTyag2CgFwTg7WqnvfUmr33I0RlgA72Bpfgmch2F eOZdRPsOahn9+8nhH9ylUOwO27HDxCORySmxw/an639kkqHJVVgTwhmfqBIs4xeSaxfu jIbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=LfYXH9I20oMLWWfV/4NEC6qh3Iyu/bPpJgDQiFojR7o=; b=mpklOiS+rUglwoJ5Qm4PCFaptw+MMdTpMWeOBLIEf6itv1y6udQmKkDCbv+9FYDkHl 1KpRz7i6GBz8IrbHEjSxHi1egzwFknp+GWSnHWWOYL3p/swoKJRFNXE8jlz2OI+1WO/w cw/Zf7f4H++mWdmJYtpUDdvEmE8YHT7ssl/SZoD+HH2bR3LgKlndn6YRQn5NjDY+yeM9 0Cj8d4WnYR8LnCCpd1WwXcJSdRWqlxC6qlvbgfB+Fp+ObNOPWvPb7A8GQbqYSxpvyvaW 7XNKUBk5mUEN8uCF4iR4S2oPckpd2PpqpMPFf05khDbLFevRLSXJzA8ZXhczH/fYLFtl lzwA== Received: by 10.180.82.226 with SMTP id l2mr705325wiy.1.1345246587173; Fri, 17 Aug 2012 16:36:27 -0700 (PDT) Received: by 10.180.82.226 with SMTP id l2mr705313wiy.1.1345246587042; Fri, 17 Aug 2012 16:36:27 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id d5si11754671eep.0.2012.08.17.16.36.27 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 17 Aug 2012 16:36:27 -0700 (PDT) Received: from bhelgaas.mtv.corp.google.com (bhelgaas.mtv.corp.google.com [172.18.96.155]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id D30B55C0063; Fri, 17 Aug 2012 16:36:26 -0700 (PDT) Received: from bhelgaas.mtv.corp.google.com (unknown [IPv6:::1]) by bhelgaas.mtv.corp.google.com (Postfix) with ESMTP id 3E3481801BB; Fri, 17 Aug 2012 16:36:26 -0700 (PDT) Subject: [PATCH v2 08/16] PCI: Stop and remove devices in one pass To: linux-pci@vger.kernel.org From: Bjorn Helgaas Cc: linux-pcmcia@lists.infradead.org, Yinghai Lu , Kenji Kaneshige Date: Fri, 17 Aug 2012 17:36:26 -0600 Message-ID: <20120817233626.10973.57304.stgit@bhelgaas.mtv.corp.google.com> In-Reply-To: <20120817233100.10973.59521.stgit@bhelgaas.mtv.corp.google.com> References: <20120817233100.10973.59521.stgit@bhelgaas.mtv.corp.google.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnYClg2tTVKYBzYQ8enGJbeNDrC9wjn4GfBKdRck8lyISLr58Urm5BpLMaZGOW3boVnmnLx3urwT12+R0sUw16I8I6m3Csq1VNlG2eQo4vReWxBak3+YwdWIDUOwbOPECZyvV4XxnGjTtd7Ba6cvLumzZqTkAs5Q6nY9vL4ZvjfW9pbAKC+2s/9lPnxoDfFEhqpmnQU5I1UoTTVJXF6r7nDldtO1g== Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Previously, when we removed a PCI device, we made two passes over the hierarchy rooted at the device. In the first pass, we stopped all the devices, and in the second, we removed them. This patch combines the two passes into one so that we remove a device as soon as it and all its children have been stopped. Note that we previously stopped devices in reverse order and removed them in forward order. Now we stop and remove them in reverse order. Signed-off-by: Bjorn Helgaas --- drivers/pci/remove.c | 42 +++++++----------------------------------- 1 files changed, 7 insertions(+), 35 deletions(-) -- 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 diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 30d002e..3828104 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -78,8 +78,6 @@ void pci_remove_bus(struct pci_bus *pci_bus) } EXPORT_SYMBOL(pci_remove_bus); -static void pci_stop_bus_device(struct pci_dev *dev); - /** * pci_stop_and_remove_bus_device - remove a PCI device and any children * @dev: the device to remove @@ -92,38 +90,8 @@ static void pci_stop_bus_device(struct pci_dev *dev); * device lists, remove the /proc entry, and notify userspace * (/sbin/hotplug). */ -static void __pci_remove_bus_device(struct pci_dev *dev) -{ - struct pci_bus *bus = dev->subordinate; - struct pci_dev *child, *tmp; - - if (bus) { - list_for_each_entry_safe(child, tmp, &bus->devices, bus_list) - __pci_remove_bus_device(child); - - pci_remove_bus(bus); - dev->subordinate = NULL; - } - - pci_destroy_dev(dev); -} - void pci_stop_and_remove_bus_device(struct pci_dev *dev) { - pci_stop_bus_device(dev); - __pci_remove_bus_device(dev); -} - -/** - * pci_stop_bus_device - stop a PCI device and any children - * @dev: the device to stop - * - * Stop a PCI device (detach the driver, remove from the global list - * and so on). This also stop any subordinate buses and children in a - * depth-first manner. - */ -static void pci_stop_bus_device(struct pci_dev *dev) -{ struct pci_bus *bus = dev->subordinate; struct pci_dev *child, *tmp; @@ -133,12 +101,16 @@ static void pci_stop_bus_device(struct pci_dev *dev) * iterator. Therefore, iterate in reverse so we remove the VFs * first, then the PF. */ - if (bus) + if (bus) { list_for_each_entry_safe_reverse(child, tmp, &bus->devices, bus_list) - pci_stop_bus_device(child); + pci_stop_and_remove_bus_device(child); + + pci_remove_bus(bus); + dev->subordinate = NULL; + } pci_stop_dev(dev); + pci_destroy_dev(dev); } - EXPORT_SYMBOL(pci_stop_and_remove_bus_device);