From patchwork Fri May 6 08:12:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 761162 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p468D3ah024361 for ; Fri, 6 May 2011 08:13:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753402Ab1EFINB (ORCPT ); Fri, 6 May 2011 04:13:01 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:34711 "EHLO e8.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752973Ab1EFIM7 (ORCPT ); Fri, 6 May 2011 04:12:59 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e8.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p467kjat000854; Fri, 6 May 2011 03:46:45 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p468Cmvt102102; Fri, 6 May 2011 04:12:48 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p468ClJ9008411; Fri, 6 May 2011 04:12:48 -0400 Received: from us.ibm.com (sig-9-65-21-120.mts.ibm.com [9.65.21.120]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id p468CiBY008331; Fri, 6 May 2011 04:12:45 -0400 Received: by us.ibm.com (sSMTP sendmail emulation); Fri, 06 May 2011 01:12:43 -0700 Date: Fri, 6 May 2011 01:12:43 -0700 From: Ram Pai To: Yinghai Lu Cc: Jesse Barnes , Ram Pai , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" Subject: Re: [PATCH] pci: Check bridge resources after resource allocation. Message-ID: <20110506081243.GF16782@ram-laptop> Reply-To: Ram Pai References: <4DC250A6.9040802@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4DC250A6.9040802@kernel.org> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 06 May 2011 08:13:03 +0000 (UTC) On Thu, May 05, 2011 at 12:24:22AM -0700, Yinghai Lu wrote: > > During pci remove/rescan testing found: > > [ 541.141614] pci 0000:c0:03.0: PCI bridge to [bus c4-c9] > [ 541.141965] pci 0000:c0:03.0: bridge window [io 0x1000-0x0fff] > [ 541.159181] pci 0000:c0:03.0: bridge window [mem 0xf0000000-0xf00fffff] > [ 541.159540] pci 0000:c0:03.0: bridge window [mem 0xfc180000000-0xfc197ffffff 64bit pref] > [ 541.179374] pci 0000:c0:03.0: device not available (can't reserve [io 0x1000-0x0fff]) > [ 541.199198] pci 0000:c0:03.0: Error enabling bridge (-22), continuing > [ 541.199202] pci 0000:c0:03.0: enabling bus mastering > [ 541.199209] pci 0000:c0:03.0: setting latency timer to 64 > [ 541.199917] pcieport 0000:c0:03.0: device not available (can't reserve [io 0x1000-0x0fff]) > [ 541.199963] pcieport: probe of 0000:c0:03.0 failed with error -22 > > This bug was uncovered by commit > | commit c8adf9a3e873eddaaec11ac410a99ef6b9656938 > | Author: Ram Pai > | Date: Mon Feb 14 17:43:20 2011 -0800 > | > | PCI: pre-allocate additional resources to devices only after successful allo > cation of essential resources. > > After that commit, pci_hotplug_io_size is changed to additional_io_size from minium size. So it will not get into failed list, and will not be reset there. > > The root cause is: pci_bridge_check_ranges will set RESOURCE_IO flag for pci > bridge, and later if children does not need to IO resource. those bridge > resources will not need to be allocated. but flags still there. > > Add pci_bridge_check_resources() to close the loop. How about resetting the resource in adjust_resources_sorted() if call to adjust_resource() fails, and the resource is left with zero size? Something like this: RP --- 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/setup-bus.c b/drivers/pci/setup-bus.c index 8e73abf..77e8454 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -157,8 +157,11 @@ static void adjust_resources_sorted(struct resource_list_x *add_head, if(pci_assign_resource(list->dev, idx)) reset_resource(res); } else if (add_size) { - adjust_resource(res, res->start, - resource_size(res) + add_size); + if (adjust_resource(res, res->start, + resource_size(res) + add_size) && + !resource_size(res)) { + reset_resource(res); + } } out: tmp = list;