Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753964AbbDGWmx (ORCPT ); Tue, 7 Apr 2015 18:42:53 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]:36946 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753921AbbDGWms (ORCPT ); Tue, 7 Apr 2015 18:42:48 -0400 Date: Tue, 7 Apr 2015 17:42:43 -0500 From: Bjorn Helgaas To: Yijing Wang Cc: Jiang Liu , linux-pci@vger.kernel.org, Yinghai Lu , linux-kernel@vger.kernel.org, Marc Zyngier , linux-arm-kernel@lists.infradead.org, Russell King , dja@axtens.net, x86@kernel.org, Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , linux-ia64@vger.kernel.org, "David S. Miller" , Guan Xuetao , linux-alpha@vger.kernel.org, linux-m68k@vger.kernel.org, Liviu Dudau , Arnd Bergmann , Geert Uytterhoeven , Yijing Wang Subject: Re: [PATCH v9 08/30] PCI: Update pci_host_bridge bus resource Message-ID: <20150407224243.GL10892@google.com> References: <1428053164-28277-1-git-send-email-wangyijing@huawei.com> <1428053164-28277-10-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1428053164-28277-10-git-send-email-wangyijing@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2963 Lines: 69 On Fri, Apr 03, 2015 at 05:25:42PM +0800, Yijing Wang wrote: > From: Yijing Wang > > Sometimes, the bus resource start number is not equal to > root bus number. For example, in pci_scan_bus(), we always > add the default bus resource which start bus number is 0, > but the root bus number callers given may != 0, so > we need to update pci_host_bridge bus resource, because we > would check whether host bridge bus resoruce is confict > in later patch. It's true that pci_scan_bus() always inserts [bus 00-ff]. But I think that's completely bogus. The caller of pci_scan_bus() supplies a root bus number X. Any bus numbers below X are useless as far as this host bridge is concerned, and it's pointless to include them in the range inserted by pci_scan_bus(). I think we'd be better off if we forced every pci_scan_bus() caller to supply a real non-overlapping bus number range. We probably can't do that easily because the arch knows the beginning bus number, but some don't know how to figure out the ending bus number. Do we have a per-domain structure that tracks the bus numbers in use in the domain? It seems like if we had one, we could use that to approximate the end. For example, if the arch scans three root buses, at bus 00, bus 40, and bus 80, we could start with the first one at [bus 00-ff], and when we scan the one at bus 40, we could either report a conflict (if the bus 00 tree included a bus 40) or reduce the first range to [bus 00-3f]. > Signed-off-by: Yijing Wang > --- > drivers/pci/host-bridge.c | 5 ++++- > 1 files changed, 4 insertions(+), 1 deletions(-) > > diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c > index ecc1a7c..1a9834b 100644 > --- a/drivers/pci/host-bridge.c > +++ b/drivers/pci/host-bridge.c > @@ -26,8 +26,11 @@ static void pci_host_update_busn_res( > struct resource_entry *window; > > resource_list_for_each_entry(window, resources) > - if (window->res->flags & IORESOURCE_BUS) > + if (window->res->flags & IORESOURCE_BUS) { > + if (bus > window->res->start) > + window->res->start = bus; I see what you're trying to do here, but I think this is the wrong place to do it. I'd rather figure out a way to insert something other than busn_resource in pci_scan_bus(). That probably means we need to dynamically allocate a new busn_res struct. > return; > + } > > pr_info( > "No busn resource found for pci%04x:%02x, will use [bus %02x-ff]\n", > -- > 1.7.1 > > -- > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/