From patchwork Sun Jun 9 16:50:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2694511 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 5FC3DDF2A1 for ; Sun, 9 Jun 2013 16:50:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751019Ab3FIQu6 (ORCPT ); Sun, 9 Jun 2013 12:50:58 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:44553 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750861Ab3FIQu5 (ORCPT ); Sun, 9 Jun 2013 12:50:57 -0400 Received: by mail-pb0-f45.google.com with SMTP id mc8so6453135pbc.32 for ; Sun, 09 Jun 2013 09:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=V781BjjoG2tV2VsrFOH74YosGPVO+BCiNrMo+RTuA+E=; b=YpZEUEK/R8JSHgDDAGZ5I1+TUv0Hu4Du93PvwY/earI4I+VMf1nFM3rt3NwklPiNGh CGN/8AUKoZqlLWUEzsJG5QtgXdCx7lpUUlkG8hImqkxTxCAVQ2CiA8ujuBBkKtOMnn8L NrZ10obumpBLmn3cishBYzuszTay5e/f/2a82gbVVhbkK9Sm5XGy2S57Wm/TeAtTFyVF S5t+sX8Rgi31GWdM4tncGT+Ajgffw4ulumUGWIbGX/j5ZWBrtV7ffP+mPRg1a7VQaRl2 csxgKottNbvG7P5iSRHTWeQsFL1TYDnF1KKQ6siTQwmKDdki0WJNgvDjsZ4hA8i8orpJ zjFg== X-Received: by 10.68.211.199 with SMTP id ne7mr6627650pbc.56.1370796657032; Sun, 09 Jun 2013 09:50:57 -0700 (PDT) Received: from [192.168.1.105] ([114.250.84.200]) by mx.google.com with ESMTPSA id dg3sm5103675pbc.24.2013.06.09.09.50.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 09 Jun 2013 09:50:56 -0700 (PDT) Message-ID: <51B4B266.5010100@gmail.com> Date: Mon, 10 Jun 2013 00:50:46 +0800 From: Jiang Liu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130404 Thunderbird/17.0.5 MIME-Version: 1.0 To: Konrad Rzeszutek Wilk CC: Bjorn Helgaas , Yinghai Lu , Jiang Liu , "Rafael J . Wysocki" , Greg Kroah-Hartman , Gu Zheng , Toshi Kani , Myron Stowe , Yijing Wang , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jeremy Fitzhardinge , xen-devel@lists.xensource.com, virtualization@lists.linux-foundation.org Subject: Re: [RFC PATCH v2, part3 07/11] PCI, xen-pcifront: use new PCI interfaces to simplify implementation References: <1368719459-24800-1-git-send-email-jiang.liu@huawei.com> <1368719459-24800-8-git-send-email-jiang.liu@huawei.com> <20130607145024.GA16631@phenom.dumpdata.com> <20130607153822.GA24882@phenom.dumpdata.com> <51B20F57.7050100@gmail.com> <20130607170706.GB3730@phenom.dumpdata.com> In-Reply-To: <20130607170706.GB3730@phenom.dumpdata.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Sat 08 Jun 2013 01:07:06 AM CST, Konrad Rzeszutek Wilk wrote: > On Sat, Jun 08, 2013 at 12:50:31AM +0800, Jiang Liu wrote: >> On 06/07/2013 11:38 PM, Konrad Rzeszutek Wilk wrote: >>> On Fri, Jun 07, 2013 at 10:50:24AM -0400, Konrad Rzeszutek Wilk wrote: >>>> On Thu, May 16, 2013 at 11:50:55PM +0800, Jiang Liu wrote: >>>>> Use new PCI interfaces to simplify xen-pcifront implementation: >>>>> 1) Use pci_create_root_bus() instead of pci_scan_bus_parented() >>>>> because pci_scan_bus_parented() is marked as __deprecated.This >>>>> also gets rid of a duplicated call of pci_bus_start_devices(). >>>>> 2) Use pci_stop_root_bus() and pci_remove_root_bus() instead of >>>>> open-coded private implementation. >>>>> 3) Use pci_set_host_bridge_release() to release data structures >>>>> associated with PCI root buses. >>>>> 4) Use pci_bus_get()/pci_bus_put() to manage PCI root bus reference >>>>> count. >>>>> >>>>> This is also a preparation for coming PCI bus lock enhancement. >>> >>> With this patch from : >>> >>> Merge branch 'pci_lock_v3' of https://github.com/jiangliu/linux into testing >>> >>> >>> it blows up when detaching the device. >> Hi Konrad, >> Thanks for testing! According to the log messages, this issue should >> be related to pci bus reference counter management. Seems we have done >> an extra(unbalanced) release of pci bus device. >> Will investigate it tomorrow! > > That is quite commendable that you are willing to look over this on > the weekend but I am not going to be able to rerun this test until > some time in the week. You could enjoy the weekend and just look at > this during the week. Hi Konrad, We should have root-caused this bug, which is caused by for_each_pci_root_bus(). Current implementation doesn't support root bus deletion when walking PCI root buses by for_each_pci_root_bus(). The reference counter (pci_bus->dev.knode_class.n_ref) becomes zero after returning from pci_remove_root_bus(), so it triggers kref warnings and double-free of klist_node object when we call pci_get_next_root_bus() to get the next PCI root bus. So we will first revert to list_for_each_entry_safe(bus, temp, &pci_root_buses, node) and solve this issue in next version of for_each_pci_root_bus(). Regards! Gerry --- pci_stop_root_bus(bus); --- -- 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/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 6aa2c0f..6e577db 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -553,11 +553,11 @@ static int pcifront_rescan_root(struct pcifront_device *pdev, static void pcifront_free_roots(struct pcifront_device *pdev) { struct pcifront_sd *sd; - struct pci_bus *bus; + struct pci_bus *bus, *temp; dev_dbg(&pdev->xdev->dev, "cleaning up root buses\n"); - for_each_pci_root_bus(bus) { + list_for_each_entry_safe(bus, temp, &pci_root_buses, node) { sd = bus->sysdata; if (sd->pdev == pdev) {