From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yinghai Lu Subject: [PATCH 11/22] PCI: Strict checking of valid range for bridge Date: Fri, 10 Feb 2012 20:06:14 -0800 Message-ID: <1328933185-15154-12-git-send-email-yinghai@kernel.org> References: <1328933185-15154-1-git-send-email-yinghai@kernel.org> Return-path: In-Reply-To: <1328933185-15154-1-git-send-email-yinghai@kernel.org> Sender: linux-kernel-owner@vger.kernel.org To: Jesse Barnes , Benjamin Herrenschmidt , Tony Luck Cc: Bjorn Helgaas , Dominik Brodowski , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Yinghai Lu List-Id: linux-arch.vger.kernel.org children bridges busn range should be able to be allocated from parent bus range. to avoid overlapping between sibling bridges on same bus. Signed-off-by: Yinghai Lu --- drivers/pci/probe.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index fcd9266..ca80141 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -770,6 +770,30 @@ reduce_needed_size: return ret; } +static int __devinit pci_bridge_check_busn_broken(struct pci_bus *bus, + struct pci_dev *dev, + int secondary, int subordinate) +{ + int broken = 0; + + struct resource busn_res; + int ret; + + memset(&busn_res, 0, sizeof(struct resource)); + dev_printk(KERN_DEBUG, &dev->dev, + "check if busn %02x-%02x is in busn_res: %pR\n", + secondary, subordinate, &bus->busn_res); + ret = allocate_resource(&bus->busn_res, &busn_res, + (subordinate - secondary + 1), + secondary, subordinate, + 1, NULL, NULL); + if (ret) + broken = 1; + else + release_resource(&busn_res); + + return broken; +} /* * If it's a bridge, configure it and scan the bus behind it. * For CardBus bridges, we don't scan behind as the devices will -- 1.7.7 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcsinet15.oracle.com ([148.87.113.117]:26980 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760521Ab2BKEHQ (ORCPT ); Fri, 10 Feb 2012 23:07:16 -0500 From: Yinghai Lu Subject: [PATCH 11/22] PCI: Strict checking of valid range for bridge Date: Fri, 10 Feb 2012 20:06:14 -0800 Message-ID: <1328933185-15154-12-git-send-email-yinghai@kernel.org> In-Reply-To: <1328933185-15154-1-git-send-email-yinghai@kernel.org> References: <1328933185-15154-1-git-send-email-yinghai@kernel.org> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Jesse Barnes , Benjamin Herrenschmidt , Tony Luck Cc: Bjorn Helgaas , Dominik Brodowski , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Yinghai Lu Message-ID: <20120211040614.2GqGAt2cHq2-z3gYdSkbygcYG7ajwY6UJBC0UvIdODw@z> children bridges busn range should be able to be allocated from parent bus range. to avoid overlapping between sibling bridges on same bus. Signed-off-by: Yinghai Lu --- drivers/pci/probe.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index fcd9266..ca80141 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -770,6 +770,30 @@ reduce_needed_size: return ret; } +static int __devinit pci_bridge_check_busn_broken(struct pci_bus *bus, + struct pci_dev *dev, + int secondary, int subordinate) +{ + int broken = 0; + + struct resource busn_res; + int ret; + + memset(&busn_res, 0, sizeof(struct resource)); + dev_printk(KERN_DEBUG, &dev->dev, + "check if busn %02x-%02x is in busn_res: %pR\n", + secondary, subordinate, &bus->busn_res); + ret = allocate_resource(&bus->busn_res, &busn_res, + (subordinate - secondary + 1), + secondary, subordinate, + 1, NULL, NULL); + if (ret) + broken = 1; + else + release_resource(&busn_res); + + return broken; +} /* * If it's a bridge, configure it and scan the bus behind it. * For CardBus bridges, we don't scan behind as the devices will -- 1.7.7