From patchwork Tue Dec 9 21:34:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 419295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 68494140082 for ; Wed, 10 Dec 2014 08:35:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753357AbaLIVfz (ORCPT ); Tue, 9 Dec 2014 16:35:55 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:17102 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753229AbaLIVfD (ORCPT ); Tue, 9 Dec 2014 16:35:03 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sB9LYq80018798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 9 Dec 2014 21:34:53 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sB9LYowG009167 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 9 Dec 2014 21:34:50 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sB9LYofW009151; Tue, 9 Dec 2014 21:34:50 GMT Received: from linux-siqj.site (/10.159.161.25) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 09 Dec 2014 13:34:49 -0800 From: Yinghai Lu To: Bjorn Helgaas Cc: Gavin Shan , Benjamin Herrenschmidt , =?UTF-8?q?Marek=20Kord=C3=ADk?= , Alexey Voronkov , Wei Yang , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH] PCI: Clear all bridge res MEM_64 if host bridge has non mem64 Date: Tue, 9 Dec 2014 13:34:31 -0800 Message-Id: <1418160871-5605-1-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org So we could use bridge 64bit mem pref for children mem pref instead of forcing them into bridge mem. Could help Marek's system as his system is using _CRS, and all mem res is under 4G. Link: https://bugzilla.kernel.org/show_bug.cgi?id=85491 Reported-by: Marek Kordik Fixes: 5b28541552ef ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources") Signed-off-by: Yinghai Lu --- drivers/pci/host-bridge.c | 7 +++++++ drivers/pci/pci.h | 1 + drivers/pci/probe.c | 9 +++++++++ drivers/pci/setup-bus.c | 3 +++ include/linux/pci.h | 1 + 5 files changed, 21 insertions(+) -- 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 Index: linux-2.6/drivers/pci/host-bridge.c =================================================================== --- linux-2.6.orig/drivers/pci/host-bridge.c +++ linux-2.6/drivers/pci/host-bridge.c @@ -31,6 +31,13 @@ void pci_set_host_bridge_release(struct bridge->release_data = release_data; } +bool pcibios_host_bridge_has_mem64_res(struct pci_bus *bus) +{ + struct pci_host_bridge *bridge = find_pci_host_bridge(bus); + + return bridge->has_mem64_res; +} + void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region, struct resource *res) { Index: linux-2.6/drivers/pci/pci.h =================================================================== --- linux-2.6.orig/drivers/pci/pci.h +++ linux-2.6/drivers/pci/pci.h @@ -196,6 +196,7 @@ enum pci_bar_type { pci_bar_mem64, /* A 64-bit memory BAR */ }; +bool pcibios_host_bridge_has_mem64_res(struct pci_bus *bus); bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl, int crs_timeout); int pci_setup_device(struct pci_dev *dev); Index: linux-2.6/drivers/pci/probe.c =================================================================== --- linux-2.6.orig/drivers/pci/probe.c +++ linux-2.6/drivers/pci/probe.c @@ -1980,6 +1980,15 @@ struct pci_bus *pci_create_root_bus(stru dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr); } + list_for_each_entry(window, &bridge->windows, list) { + res = window->res; + if (resource_type(res) == IORESOURCE_MEM || + res->end > 0xffffffff) { + bridge->has_mem64_res = true; + break; + } + } + down_write(&pci_bus_sem); list_add_tail(&b->node, &pci_root_buses); up_write(&pci_bus_sem); Index: linux-2.6/include/linux/pci.h =================================================================== --- linux-2.6.orig/include/linux/pci.h +++ linux-2.6/include/linux/pci.h @@ -407,6 +407,7 @@ struct pci_host_bridge { struct list_head windows; /* pci_host_bridge_windows */ void (*release_fn)(struct pci_host_bridge *); void *release_data; + bool has_mem64_res; }; #define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev) Index: linux-2.6/drivers/pci/setup-bus.c =================================================================== --- linux-2.6.orig/drivers/pci/setup-bus.c +++ linux-2.6/drivers/pci/setup-bus.c @@ -693,6 +693,9 @@ static void pci_bridge_check_ranges(stru } } + if (!pcibios_host_bridge_has_mem64_res(bus)) + b_res[2].flags &= ~IORESOURCE_MEM_64; + /* double check if bridge does support 64 bit pref */ if (b_res[2].flags & IORESOURCE_MEM_64) { u32 mem_base_hi, tmp;