From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e23smtp01.au.ibm.com ([202.81.31.143]:37368 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750930Ab2EDFLZ (ORCPT ); Fri, 4 May 2012 01:11:25 -0400 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 May 2012 04:44:18 +1000 Date: Fri, 4 May 2012 12:52:05 +0800 From: Richard Yang To: Yinghai Lu Cc: Richard Yang , Wei Yang , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: One problem in reassign pci bus number? Message-ID: <20120504045205.GA21624@richard> Reply-To: Richard Yang References: <20120410090306.GA7056@richard> <20120422155202.GA13540@richard> <20120503065455.GA30042@richard> <20120504024721.GA6775@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 In-Reply-To: Sender: linux-pci-owner@vger.kernel.org List-ID: On Thu, May 03, 2012 at 08:15:29PM -0700, Yinghai Lu wrote: >>> >>>I updated for-pci-busn-alloc branch with updating of probe_resource()... >>>and removing bus->secondary and subordinate. >>> >> You mean you remove the bus->secondary field? >> So the pci_bus->number hold the bus number? >> I think this is a huge work. >>>Please check if you can understand it ... >>> >>>http://git.kernel.org/?p=linux/kernel/git/yinghai/linux-yinghai.git;a=commitdiff;h=7de8df57b223d54af95ffe67f8da2dd39a265971 >> Some question: >> >> +static resource_size_t __find_res_top_free_size(struct resource *res, >> +                                                int skip_nr) >> +{ >> +       resource_size_t n_size; >> +       struct resource tmp_res; >> + >> +       */ >> +        *   find out free number below res->end that we can use. >> +        *      res->start to res->start + skip_nr - 1 can not be used. >> +        */ >> +       n_size = resource_size(res); >> +       if (n_size <= skip_nr) >> +               return 0; >> + >> +       n_size -= skip_nr; >> +       memset(&tmp_res, 0, sizeof(struct resource)); >> +       while (n_size > 0) { >> +               int ret; >> + >> +               ret = __allocate_resource(res, &tmp_res, n_size, >> +                       res->end - n_size + skip_nr, res->end, >> +                       1, NULL, NULL, false); >> +               if (ret == 0) { >> +                       __release_resource(&tmp_res); >> +                       break; >> +               } >> +               n_size--; >> +       } >> + >> +       return n_size; >> +} >> So this is trying to find out the biggest free space of res? >> On the right side? >> >> For example we have , res like >>   90-150 >>        105-140 >> The __find_res_top_free_size() will return 10 instead of 15. >> So this is the design decision to find the right side free resouce not >> the left side? > > __find_res_top_free_size() is called by probe_resource(). > >probe_resource will return [91-104]. Hmm... I think the result is returned by this while loop. + while (n_size >= needed_size) { + ret = allocate_resource(b_res, busn_res, n_size, + b_res->start + skip_nr, b_res->end, + 1, NULL, NULL); + if (!ret) + return ret; + n_size--; + } __find_res_top_free_size() is not called. BTW, even if this value is returned by __find_res_top_free_size(), or returned after this function is called, the purpose of the __find_res_top_free_size() is to get the biggest free space under the first parameter? > >Thanks > >Yinghai -- Richard Yang Help you, Help me