From patchwork Fri Oct 21 15:37:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 9389537 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 05A6E60762 for ; Fri, 21 Oct 2016 15:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB7B52A285 for ; Fri, 21 Oct 2016 15:36:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFEC12A28C; Fri, 21 Oct 2016 15:36:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10D592A285 for ; Fri, 21 Oct 2016 15:36:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934249AbcJUPgp (ORCPT ); Fri, 21 Oct 2016 11:36:45 -0400 Received: from mailout2.hostsharing.net ([83.223.90.233]:60847 "EHLO mailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934191AbcJUPgo (ORCPT ); Fri, 21 Oct 2016 11:36:44 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout2.hostsharing.net (Postfix) with ESMTPS id B5210103AD291; Fri, 21 Oct 2016 17:36:41 +0200 (CEST) Received: from localhost (3-38-90-81.adsl.cmo.de [81.90.38.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id 0780B60AFB79; Fri, 21 Oct 2016 17:36:39 +0200 (CEST) Date: Fri, 21 Oct 2016 17:37:14 +0200 From: Lukas Wunner To: Keith Busch Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , Ralf Baechle , Wei Zhang , Andreas Noever Subject: Re: [PATCHv3 2/5] pci: Add is_removed state Message-ID: <20161021153714.GA4221@wunner.de> References: <1475007815-28354-1-git-send-email-keith.busch@intel.com> <1475007815-28354-3-git-send-email-keith.busch@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1475007815-28354-3-git-send-email-keith.busch@intel.com> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Sep 27, 2016 at 04:23:32PM -0400, Keith Busch wrote: > --- a/drivers/pci/hotplug/pciehp_pci.c > +++ b/drivers/pci/hotplug/pciehp_pci.c > @@ -109,6 +109,8 @@ int pciehp_unconfigure_device(struct slot *p_slot) > break; > } > } > + if (!presence) > + dev->is_removed = 1; > pci_stop_and_remove_bus_device(dev); > /* > * Ensure that no new Requests will be generated from Sorry for the delay Keith, I finally got around to test v3 of your series with hot-removed Thunderbolt devices on Apple Macs. I've found that the above isn't sufficient, it's necessary to also set the is_removed bit on any child devices. E.g. on my system when an Apple Gigabit Ethernet adapter is plugged in, the topology looks like this: 0000:06:04.0 --- 0000:09:00.0 --- 0000:0a:00.0 --- 0000:0b:00.0 Hotplug port Upstream bridge Downstream br. Broadcom 57762 of TB host of TB switch in Ethernet adapter With your patch above, the is_removed bit is only set on 0000:09:00.0 but not on its children. Consequently the "tg3" driver tries to access the hot-removed Broadcom 57762 Ethernet chip as before, causing a soft lockup. The diff below fixes this for me, could you fold that into your patch? The same change might also be necessary in pcie-dpc.c. Feel free to rename "set_is_removed_cb()" if you don't like it. Thanks, Lukas -- >8 -- --- 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/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index 299ea5e..ec26eb7 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c @@ -73,6 +73,12 @@ int pciehp_configure_device(struct slot *p_slot) return ret; } +static int set_is_removed_cb(struct pci_dev *pdev, void *unused) +{ + pdev->is_removed = 1; + return 0; +} + int pciehp_unconfigure_device(struct slot *p_slot) { int rc = 0; @@ -109,8 +115,11 @@ int pciehp_unconfigure_device(struct slot *p_slot) break; } } - if (!presence) + if (!presence) { dev->is_removed = 1; + if (pci_has_subordinate(dev)) + pci_walk_bus(dev->subordinate, set_is_removed_cb, NULL); + } pci_stop_and_remove_bus_device(dev); /* * Ensure that no new Requests will be generated from