From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02E9CC3A5A1 for ; Wed, 21 Aug 2019 13:08:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCAEB2339E for ; Wed, 21 Aug 2019 13:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566392910; bh=e14VTMsNwxA7Ghv8QAnsIB1kvLhHM18xsQFgrXEACNw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=r9M4phqqYDxjck031sE9av9R2K9+zYrk2tYpZBT6T3HReusupoOlX9y7A/Tv1TxkY rNKrJSS1Za51p9xx61IWylUxCbcBKxS4WRQTzrrHwYe8Z8QyLQzQofeRO/DKAGxnvn H1VmtxO8JiGVTGEX6JJ9x0nB9vairVdjlMyWdQ0g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728662AbfHUNIa (ORCPT ); Wed, 21 Aug 2019 09:08:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:51696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727559AbfHUNI3 (ORCPT ); Wed, 21 Aug 2019 09:08:29 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4B1AF2339E; Wed, 21 Aug 2019 13:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566392909; bh=e14VTMsNwxA7Ghv8QAnsIB1kvLhHM18xsQFgrXEACNw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k4+uhL1MuZvKoV+gxQrT8q0kTYHp4prhnqmfRoJ/m4e6JVqT9nquVJIpnC8ciWInc qrlXmXRi90/7ywGmk0BflaHQAVm5rCJ65ItY8smBGGCM5eZittt9huICZs3aQz59pG S5CHBPLQvxBiZ/8JTfTaouN4WbpUokyIKvE36dNg= Date: Wed, 21 Aug 2019 08:08:27 -0500 From: Bjorn Helgaas To: Benjamin Herrenschmidt Cc: "linux-pci@vger.kernel.org" Subject: Re: [RFC/PATCH] PCI: Protect pci_reassign_bridge_resources() against concurrent addition/removal Message-ID: <20190821130827.GF14450@google.com> References: <02ca29627597445442bb14c069678e549429dace.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <02ca29627597445442bb14c069678e549429dace.camel@kernel.crashing.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Mon, Jun 24, 2019 at 02:32:19PM +1000, Benjamin Herrenschmidt wrote: > pci_reassign_bridge_resources() can be called by pci_resize_resource() > at runtime. > > It will walk the PCI tree up and down, and isn't currently protected > against any changes or hotplug operation. > > Signed-off-by: Benjamin Herrenschmidt Applied to pci/resource for v5.4, thanks! > --- > > --- a/drivers/pci/setup-bus.c > +++ b/drivers/pci/setup-bus.c > @@ -2104,6 +2104,8 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type) > unsigned int i; > int ret; > > + down_read(&pci_bus_sem); > + > /* Walk to the root hub, releasing bridge BARs when possible */ > next = bridge; > do { > @@ -2160,6 +2162,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type) > } > > free_list(&saved); > + up_read(&pci_bus_sem); > return 0; > > cleanup: > @@ -2188,6 +2191,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type) > pci_setup_bridge(bridge->subordinate); > } > free_list(&saved); > + up_read(&pci_bus_sem); > > return ret; > } >