From patchwork Fri Mar 12 00:01:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 85166 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2C02KnB023134 for ; Fri, 12 Mar 2010 00:02:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755359Ab0CLABx (ORCPT ); Thu, 11 Mar 2010 19:01:53 -0500 Received: from g5t0009.atlanta.hp.com ([15.192.0.46]:23235 "EHLO g5t0009.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755166Ab0CLABv (ORCPT ); Thu, 11 Mar 2010 19:01:51 -0500 Received: from g5t0029.atlanta.hp.com (g5t0029.atlanta.hp.com [16.228.8.141]) by g5t0009.atlanta.hp.com (Postfix) with ESMTP id 383D230093; Fri, 12 Mar 2010 00:01:50 +0000 (UTC) Received: from ldl (ldl.fc.hp.com [15.11.146.30]) by g5t0029.atlanta.hp.com (Postfix) with ESMTP id 8C217206CE; Fri, 12 Mar 2010 00:01:14 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 75941CF0010; Thu, 11 Mar 2010 17:01:14 -0700 (MST) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rxh1J2dhp8yS; Thu, 11 Mar 2010 17:01:14 -0700 (MST) Received: from eh.fc.hp.com (eh.fc.hp.com [15.11.146.105]) by ldl (Postfix) with ESMTP id 5E390CF000A; Thu, 11 Mar 2010 17:01:14 -0700 (MST) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id 38DC4261F7; Thu, 11 Mar 2010 17:01:14 -0700 (MST) Subject: [PATCH v1 2/3] x86/PCI: trim _CRS windows when they conflict with previous reservations To: Jesse Barnes From: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Yanko Kaneti , Linus Torvalds , Thomas Renninger , maciej.rutecki@gmail.com Date: Thu, 11 Mar 2010 17:01:14 -0700 Message-ID: <20100312000114.4355.58189.stgit@bob.kio> In-Reply-To: <20100311235954.4355.23100.stgit@bob.kio> References: <20100311235954.4355.23100.stgit@bob.kio> User-Agent: StGit/0.15 MIME-Version: 1.0 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.3 (demeter.kernel.org [140.211.167.41]); Fri, 12 Mar 2010 00:02:21 +0000 (UTC) diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 6e22454..d255ce8 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -114,11 +114,19 @@ align_resource(struct acpi_device *bridge, struct resource *res) } } +static bool +resource_contains(struct resource *res, resource_size_t n) +{ + if (n < res->start || n > res->end) + return false; + return true; +} + static acpi_status setup_resource(struct acpi_resource *acpi_res, void *data) { struct pci_root_info *info = data; - struct resource *res; + struct resource *res, *conflict; struct acpi_resource_address64 addr; acpi_status status; unsigned long flags; @@ -157,21 +165,35 @@ setup_resource(struct acpi_resource *acpi_res, void *data) return AE_OK; } - if (insert_resource(root, res)) { + conflict = insert_resource_conflict(root, res); + while (conflict) { dev_err(&info->bridge->dev, - "can't allocate host bridge window %pR\n", res); - } else { - pci_bus_add_resource(info->bus, res, 0); - info->res_num++; - if (addr.translation_offset) - dev_info(&info->bridge->dev, "host bridge window %pR " - "(PCI address [%#llx-%#llx])\n", - res, res->start - addr.translation_offset, - res->end - addr.translation_offset); + "host bridge window %pR conflicts with %s %pR\n", + res, conflict->name, conflict); + + if (resource_contains(res, conflict->end)) + res->start = conflict->end + 1; + else if (resource_contains(res, conflict->start)) + res->end = conflict->start - 1; else - dev_info(&info->bridge->dev, - "host bridge window %pR\n", res); + return AE_OK; + + if (res->start >= res->end) + return AE_OK; + + conflict = insert_resource_conflict(root, res); } + + pci_bus_add_resource(info->bus, res, 0); + info->res_num++; + if (addr.translation_offset) + dev_info(&info->bridge->dev, "host bridge window %pR " + "(PCI address [%#llx-%#llx])\n", + res, res->start - addr.translation_offset, + res->end - addr.translation_offset); + else + dev_info(&info->bridge->dev, + "host bridge window %pR\n", res); return AE_OK; }