From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yinghai Lu Subject: [PATCH 11/24] PCI: Add pci_bus_extend/shrink_top() Date: Sat, 4 Feb 2012 22:57:55 -0800 Message-ID: <1328425088-6562-12-git-send-email-yinghai@kernel.org> References: <1328425088-6562-1-git-send-email-yinghai@kernel.org> Return-path: In-Reply-To: <1328425088-6562-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 extend or shrink bus and parent buses top (subordinate) extended range is verified safe range, and stop at recorded parent_res. Signed-off-by: Yinghai Lu --- drivers/pci/probe.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index cdd6e83..d2519df 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -624,6 +624,42 @@ static void pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max) } } +static void __devinit pci_bus_update_top(struct pci_bus *parent, + long size, struct resource *parent_res) +{ + struct resource *res; + + if (!size) + return; + + while (parent) { + res = &parent->busn_res; + if (res == parent_res) + break; + res->end += size; + parent->subordinate += size; + pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, + parent->subordinate); + dev_printk(KERN_DEBUG, &parent->dev, + "busn_res: %s %02lx to %pR\n", + (size > 0) ? "extended" : "shrunk", + abs(size), res); + parent = parent->parent; + } +} + +static void __devinit pci_bus_extend_top(struct pci_bus *parent, + long size, struct resource *parent_res) +{ + pci_bus_update_top(parent, size, parent_res); +} + +static void __devinit pci_bus_shrink_top(struct pci_bus *parent, + long size, struct resource *parent_res) +{ + pci_bus_update_top(parent, -size, parent_res); +} + /* * 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 acsinet15.oracle.com ([141.146.126.227]:24611 "EHLO acsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754893Ab2BEHAB (ORCPT ); Sun, 5 Feb 2012 02:00:01 -0500 From: Yinghai Lu Subject: [PATCH 11/24] PCI: Add pci_bus_extend/shrink_top() Date: Sat, 4 Feb 2012 22:57:55 -0800 Message-ID: <1328425088-6562-12-git-send-email-yinghai@kernel.org> In-Reply-To: <1328425088-6562-1-git-send-email-yinghai@kernel.org> References: <1328425088-6562-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: <20120205065755.W8APagCn5OL6L3JNUZrOTH1rB7m-iiububYTn36jCdM@z> extend or shrink bus and parent buses top (subordinate) extended range is verified safe range, and stop at recorded parent_res. Signed-off-by: Yinghai Lu --- drivers/pci/probe.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index cdd6e83..d2519df 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -624,6 +624,42 @@ static void pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max) } } +static void __devinit pci_bus_update_top(struct pci_bus *parent, + long size, struct resource *parent_res) +{ + struct resource *res; + + if (!size) + return; + + while (parent) { + res = &parent->busn_res; + if (res == parent_res) + break; + res->end += size; + parent->subordinate += size; + pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, + parent->subordinate); + dev_printk(KERN_DEBUG, &parent->dev, + "busn_res: %s %02lx to %pR\n", + (size > 0) ? "extended" : "shrunk", + abs(size), res); + parent = parent->parent; + } +} + +static void __devinit pci_bus_extend_top(struct pci_bus *parent, + long size, struct resource *parent_res) +{ + pci_bus_update_top(parent, size, parent_res); +} + +static void __devinit pci_bus_shrink_top(struct pci_bus *parent, + long size, struct resource *parent_res) +{ + pci_bus_update_top(parent, -size, parent_res); +} + /* * 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