From patchwork Sun Dec 15 04:10:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 3349891 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8A154C0D4A for ; Sun, 15 Dec 2013 04:10:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CEF062012D for ; Sun, 15 Dec 2013 04:10:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28170200EC for ; Sun, 15 Dec 2013 04:10:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753902Ab3LOEK2 (ORCPT ); Sat, 14 Dec 2013 23:10:28 -0500 Received: from mail-ie0-f170.google.com ([209.85.223.170]:39418 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753882Ab3LOEK2 (ORCPT ); Sat, 14 Dec 2013 23:10:28 -0500 Received: by mail-ie0-f170.google.com with SMTP id qd12so4965888ieb.15 for ; Sat, 14 Dec 2013 20:10:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=EQhIUQDdBqNbRXvKw+S+ND1D5SG1v3ImKJfUaaIHMBQ=; b=gwBnZQwLaBVQrUysuS96Jff+JfRjJhxcYYSzrRPE6qjBCV5tAR5XzcqGQr5d3R1lTD zxKjScN3p+MkLXzO34PP/DA/sWg/1k4e+FOf607D2wf13OMW3sLO4dgggu5eRe/NnEw1 nEQ50UEr4GnNJ7FPZY7o6eItCfAIaM4RuSRmBhbFnGvjkt17lnru+r3x7fQoLicIV84s vHpK/kFx02NLBd5OwgieUevf49albylabqC/TQN1q1LXAYSkP7sT7t4W/UHA1513hvr3 CMpQ2davMq8axI9tZMQnhNI9fo2EUFprjayUBM43dBPe7jhlgFdjdbbI5cc+xUhvPGAB dy7Q== MIME-Version: 1.0 X-Received: by 10.42.68.193 with SMTP id y1mr7753691ici.7.1387080627304; Sat, 14 Dec 2013 20:10:27 -0800 (PST) Received: by 10.64.235.70 with HTTP; Sat, 14 Dec 2013 20:10:27 -0800 (PST) In-Reply-To: References: Date: Sat, 14 Dec 2013 20:10:27 -0800 X-Google-Sender-Auth: 7P55c-yl8yNMSzU_goMh90T8PMQ Message-ID: Subject: Re: How to reserve pci bus numbers for hotplug? From: Yinghai Lu To: Andreas Noever Cc: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" 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.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham 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 Thu, Dec 12, 2013 at 11:56 AM, Andreas Noever wrote: > On Thu, Dec 12, 2013 at 1:21 AM, Yinghai Lu wrote: >> On Wed, Dec 11, 2013 at 3:37 PM, Andreas Noever >> wrote: >> >>> If I could get Linux to assign enough resources (bus numbers for now) >>> then I could drop the acpi_osi parameter and make thunderbolt work >>> after suspend... So, is there an easy way to fix this? (Quirks, >>> reconfiguring bus number assignments from a platform driver, ...?) >> >> please check if busn_alloc at >> >> git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git >> for-pci-busn-alloc-3.14 >> >> could help. > > It seems to help. The initial assignment looks good: > +-01.1-[05-9b]----00.0-[06-27]--+-00.0-[07]----00.0 Intel > Corporation DSL3510 Thunderbolt Port [Cactus Ridge] > | +-03.0-[08-0f]-- > | +-04.0-[10-17]-- > | +-05.0-[18-1f]-- > | \-06.0-[20-27]-- > After hotplug it looks like this: > +-01.1-[05-9b]----00.0-[06-29]--+-00.0-[07]----00.0 Intel > Corporation DSL3510 Thunderbolt Port [Cactus Ridge] > | > +-03.0-[08-11]----00.0-[09-11]----00.0-[0a-11]----00.0 Broadcom > Corporation NetXtreme BCM57762 Gigabit Ethernet PCIe > | +-04.0-[10-17]-- > | +-05.0-[18-1f]-- > | \-06.0-[20-27]-- > (Note that the bridge numbers are not disjoint) it should not extend to [08-11] or [06-29] Please check attached patch that should address bus number wrong extending. --- missed checking before going up one level ...wrong assumption ... Thanks Yinghai --- kernel/resource.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) Index: linux-2.6/kernel/resource.c =================================================================== --- linux-2.6.orig/kernel/resource.c +++ linux-2.6/kernel/resource.c @@ -1130,7 +1130,9 @@ int probe_resource(struct resource *b_re /* Probe extended range above top */ memset(busn_res, 0, sizeof(struct resource)); parent_res = b_res; - while (parent_res && !(parent_res->flags & stop_flags)) { + while (!(parent_res->flags & stop_flags)) { + struct resource *up_parent_res; + ret = __adjust_resource(parent_res, parent_res->start, resource_size(parent_res) + (needed_size - n_size)); if (!ret) { @@ -1151,7 +1153,11 @@ int probe_resource(struct resource *b_re /* ret must be 0 here*/ goto out; } - parent_res = parent_res->parent; + /* before go up, need to make sure at the same end */ + up_parent_res = parent_res->parent; + if (!up_parent_res || up_parent_res->end != parent_res->end) + goto out; + parent_res = up_parent_res; } out: