From patchwork Sat Sep 15 03:05:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 184066 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 D82FD2C0085 for ; Sat, 15 Sep 2012 13:15:42 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756468Ab2IODNg (ORCPT ); Fri, 14 Sep 2012 23:13:36 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:64718 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755942Ab2IODNF (ORCPT ); Fri, 14 Sep 2012 23:13:05 -0400 Received: by mail-pz0-f46.google.com with SMTP id y13so2794684dad.19 for ; Fri, 14 Sep 2012 20:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=dLlome0ZT7ZPv4SCtxV8MLbujNPqCd73Kvndx4uR5uw=; b=ZZ6qKzB6SAFJnSnFwkG0o/xoyujSdI4YX4W0ixV3mAmeWnuJjCRBqxF/gTSpFTxE9h WuCcUbiZ0f4PwoIkyHkQn55h7tXGrhL7Zo9Pd2qThqM0oJidB/+ClE2CrkTiYnoWjbZQ QhNlbeaBGM2lgT2K5r6g1iuWlggbet7lL6OBG7E5L7tAr2pcKF63i0xk/VW3gFmMung5 02tuiEqufi1FbJEmUBmgqRWu+UBZC0Y5v/+tAmoSI5Zbp6fMKjEEHCz+dYc7Xf3iBL/Y aXjL+ixeO6DMPQj4nP3KaEfC+DxSq0n0Sv57NZApn8c8yR6u5Cild67XIaNScl8yb26d ohyA== Received: by 10.68.221.167 with SMTP id qf7mr8378165pbc.4.1347678784814; Fri, 14 Sep 2012 20:13:04 -0700 (PDT) Received: from localhost.localdomain ([221.221.18.122]) by mx.google.com with ESMTPS id jz10sm2092777pbc.8.2012.09.14.20.12.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Sep 2012 20:13:04 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas Cc: Tony Luck , Yijing Wang , Yinghai Lu , Kenji Kaneshige , Jiang Liu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jiang Liu Subject: [PATCH v2 3/9] PCI: preserve dev->subordinate until pci_stop_dev() has been called Date: Sat, 15 Sep 2012 11:05:06 +0800 Message-Id: <1347678312-11124-4-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347678312-11124-1-git-send-email-jiang.liu@huawei.com> References: <1347678312-11124-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Yijing Wang Changeset 2ed168eeb3edec029aa0eca5cb981d6376f931f9 "PCI: Fold stop and remove helpers into their callers" has changed the behavior when removing a PCI device. Previously, for a PCI bridge device with secondary bus, dev->subordinate is valid when calling PCI bus notification callbacks for BUS_NOTIFY_ADD_DEVICE/BUS_NOTIFY_DEL_DEVICE events. Now dev->subordinate has been reset to NULL when calling callbacks for BUS_NOTIFY_DEL_DEVICE events, which may break some PCI bus notification callbacks. So revert to the original behavior to keep dev->subordinate valid for both BUS_NOTIFY_ADD_DEVICE events and BUS_NOTIFY_DEL_DEVICE events. Signed-off-by: Yijing Wang Signed-off-by: Jiang Liu --- drivers/pci/remove.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 86a4636..6244956 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -79,16 +79,16 @@ void pci_stop_and_remove_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_and_remove_bus_device(child); + pci_stop_dev(dev); + if (bus) { pci_remove_bus(bus); dev->subordinate = NULL; } - - pci_stop_dev(dev); pci_destroy_dev(dev); } EXPORT_SYMBOL(pci_stop_and_remove_bus_device);