From patchwork Wed Oct 16 20:21:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 3057161 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 001C79F2B6 for ; Wed, 16 Oct 2013 20:21:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3019D2011F for ; Wed, 16 Oct 2013 20:21:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56DFC200F7 for ; Wed, 16 Oct 2013 20:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761543Ab3JPUV3 (ORCPT ); Wed, 16 Oct 2013 16:21:29 -0400 Received: from mail-ie0-f177.google.com ([209.85.223.177]:46868 "EHLO mail-ie0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761210Ab3JPUV1 (ORCPT ); Wed, 16 Oct 2013 16:21:27 -0400 Received: by mail-ie0-f177.google.com with SMTP id e14so2218290iej.8 for ; Wed, 16 Oct 2013 13:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=zkPaMNPtr2eKIEnOxVFdMRknYiQg7R9mr+Kz5PfuK74=; b=Yj5mubus5E2voTQsl9MVUSUqMjQfXocYIGhTRdPWGHeLyxDU68L6+t3pyj+irdkMW1 UgV0mWhlZ4BBc6FfwN0IM+GR+TS++mspFGLz4DQzftyIOqRxLEYMci27ps7Xa54hrMFz RNyGAq4ZM3IhsODOoMJv3n0VemLn1uBsBOVPyOqaR67DL/CqdarAAzeFu82YgO7LdpRB duHGO9/vShE8TQtfYTafVH5pyZrMOym8ZwuBXIg6/JLNizUrRMMVnqEBTyEaY7G78V/J j2F/PDD5ntkFtmPs5xnaqaaig7DmRafvcq264FsmiiQ5z76WWF4+gBjbjZaFJJXSNaAJ 4oiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=zkPaMNPtr2eKIEnOxVFdMRknYiQg7R9mr+Kz5PfuK74=; b=mIOFkhwpTd0gyL9dTuo3JrCtV1qISxm3Fn6Mwg+5/dOUEU32JCwhfunK/2M++HZ9YG wCiNTycNXUQXe2OaTUaqpxkAsJboDtr2bGQ+rkgmR7IFkVMWa8Kg8DqqO5r4OZSb1lJ4 /G8RIbFsQ8x+YBbQIaGDwWq4M/UMbmUY2G8RSBJgnc6xGyLYdYG37icz/DwqelW6GxjB 5NHvgbf4JS8LXXmDgFrsZLnWa1ZBV43tFRbIgC7r9rXQbp1J45zk/0frMAtlA4tSLXsD 6daQrb23d24f6VwIWhU2cfg9/vsU1SVWT6cif6bnPcvw3zOfSWVuuX/lQ5GTm1jmCdUf hGkQ== X-Gm-Message-State: ALoCoQn9d0/XV3fJKVKWBtmZ8+KtrCPMZvliFjiKc/kkJa/LX9bqXrNai08I9LlC8tGNGYIQeNCLbKXZH8UJVCkvXxDo2qSRZGGIgOZYQZF4g1gOWx9CMC4zH7ojZ/19QSNF9+MOkyUS1rEDOkqySUNxOOQTP+3CtD8SIDFQKpb05o2Fb841OiQq3LtjmfgFO9xQ5CRaj+sk9D+1wj2bNQuf36hrQG+Sag== X-Received: by 10.42.204.4 with SMTP id fk4mr3102509icb.31.1381954887020; Wed, 16 Oct 2013 13:21:27 -0700 (PDT) Received: from google.com ([172.16.53.179]) by mx.google.com with ESMTPSA id yt10sm4928064igb.9.2013.10.16.13.21.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 16 Oct 2013 13:21:26 -0700 (PDT) Date: Wed, 16 Oct 2013 14:21:23 -0600 From: Bjorn Helgaas To: Matthew Garrett Cc: Andreas Noever , "linux-kernel@vger.kernel.org" , "Rafael J. Wysocki" , "linux-pci@vger.kernel.org" , Mika Westerberg , "Kirill A. Shutemov" Subject: Re: [3.11.4] Thunderbolt/PCI unplug oops in pci_pme_list_scan Message-ID: <20131016202123.GA17866@google.com> References: <20131015024452.GA31951@srcf.ucam.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20131015024452.GA31951@srcf.ucam.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Oct 15, 2013 at 03:44:52AM +0100, Matthew Garrett wrote: > On Mon, Oct 14, 2013 at 05:50:38PM -0600, Bjorn Helgaas wrote: > > [+cc Rafael, Mika, Kirill, linux-pci] > > > > On Mon, Oct 14, 2013 at 4:47 PM, Andreas Noever > > wrote: > > > When I unplug the Thunderbolt ethernet adapter on my MacBookPro Linux > > > crashes a few seconds later. Using > > > echo 1 > /sys/bus/pci/devices/0000:08:00.0/remove > > > to remove a bridge two levels above the device triggers the fault immediately: > > > > There have been significant changes in acpiphp related to Thunderbolt > > since v3.11. > > Apple don't expose Thunderbolt via ACPI, so it appears as native PCIe. > I'd be surprised if acpiphp makes a difference here. Yeah, you're right; I wasn't paying attention. We save a pci_dev pointer in the pci_pme_list, which of course has a longer lifetime than the pci_dev itself, but we don't acquire a reference on it, so I suspect the pci_dev got released before we got around to doing the pci_pme_list_scan(). Andreas, can you try the patch below? It's against v3.12-rc2, but it should apply to v3.11, too. --- 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/pci.c b/drivers/pci/pci.c index ad7fc72..8b0a2f3 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1580,6 +1580,7 @@ static void pci_pme_list_scan(struct work_struct *work) pci_pme_wakeup(pme_dev->dev, NULL); } else { list_del(&pme_dev->list); + pci_dev_put(pme_dev->dev); kfree(pme_dev); } } @@ -1640,7 +1641,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable) GFP_KERNEL); if (!pme_dev) goto out; - pme_dev->dev = dev; + pme_dev->dev = pci_dev_get(dev); mutex_lock(&pci_pme_list_mutex); list_add(&pme_dev->list, &pci_pme_list); if (list_is_singular(&pci_pme_list)) @@ -1652,6 +1653,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable) list_for_each_entry(pme_dev, &pci_pme_list, list) { if (pme_dev->dev == dev) { list_del(&pme_dev->list); + pci_dev_put(pme_dev->dev); kfree(pme_dev); break; }