From patchwork Tue Dec 17 00:36:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 3357981 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 327B4C0D4A for ; Tue, 17 Dec 2013 00:36:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12D4F202A1 for ; Tue, 17 Dec 2013 00:36:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D75A201ED for ; Tue, 17 Dec 2013 00:36:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751848Ab3LQAge (ORCPT ); Mon, 16 Dec 2013 19:36:34 -0500 Received: from mail-ig0-f172.google.com ([209.85.213.172]:63453 "EHLO mail-ig0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551Ab3LQAgd (ORCPT ); Mon, 16 Dec 2013 19:36:33 -0500 Received: by mail-ig0-f172.google.com with SMTP id hl1so5070948igb.5 for ; Mon, 16 Dec 2013 16:36:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=q1qAX9PYxND1eC/VKFZbmy0/gg4z0rJbDXK0tFKpwD8=; b=hwyJVgnmAw5rfig8mH/qrt6LYge2esbRKzqnAmwQoJRMRWRCDH8dp5DBhKFCqRS7rF O5qd+z/JDI4+FSKTHFXelH89yWjtQN97uMLx7dl1encQ8aGNKfmc7ylb1udekPCuIyGr IXtV9UtAYcHWfoV6csrEO8Kt5OT4yeNaUN0HzdeEDupStL7kv1hQNbPKrtAe1FOWucGp qBkoBtXw82NfMmsYGIc/1sEKyy+wyg5rAb9ZK1ypGnScQuf+gHP23PvOcfrwfsDheJ2T Ge3NV1RYPFNU+jMzeC0ytj5yWPKhdHRPG3OYCJNyt01T5F4SAAeX1oJ2ErsRAft+lIK+ XwkQ== MIME-Version: 1.0 X-Received: by 10.43.73.197 with SMTP id yt5mr14577231icb.0.1387240592993; Mon, 16 Dec 2013 16:36:32 -0800 (PST) Received: by 10.64.235.70 with HTTP; Mon, 16 Dec 2013 16:36:32 -0800 (PST) In-Reply-To: References: <1386658484-15774-1-git-send-email-yinghai@kernel.org> <1386658484-15774-5-git-send-email-yinghai@kernel.org> <20131216082329.GA4926@yanx> Date: Mon, 16 Dec 2013 16:36:32 -0800 X-Google-Sender-Auth: PeLNbzTRulW1qVDbuLN2lVqJ-dU Message-ID: Subject: Re: [PATCH v4 4/5] PCI: Try best to allocate pref mmio 64bit above 4g From: Yinghai Lu To: Guo Chao Cc: Bjorn Helgaas , "linux-pci@vger.kernel.org" , Linux Kernel Mailing List Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Dec 16, 2013 at 1:36 PM, Yinghai Lu wrote: > On Mon, Dec 16, 2013 at 10:13 AM, Yinghai Lu wrote: >>> >>> 64-bit non-prefetchable BARs are missed from caculation in the scheme, >>> causing assign failed eventually. >>> >>> Will you figure out a better way to cover them or just add a 'type3' parameter? > > Looks like we have add type3 for that case. please check attached delta patch. Thanks Yinghai --- drivers/pci/setup-bus.c | 17 +++++++++++------ drivers/pci/setup-res.c | 8 ++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) 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 @@ -916,6 +916,7 @@ static inline resource_size_t calculate_ */ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type, unsigned long type2, + unsigned long type3, resource_size_t min_size, resource_size_t add_size, struct list_head *realloc_head) { @@ -946,7 +947,8 @@ static int pbus_size_mem(struct pci_bus resource_size_t r_size; if (r->parent || ((r->flags & mask) != type && - (r->flags & mask) != type2)) + (r->flags & mask) != type2 && + (r->flags & mask) != type3)) continue; r_size = resource_size(r); #ifdef CONFIG_PCI_IOV @@ -1119,7 +1121,7 @@ void __ref __pci_bus_size_bridges(struct struct list_head *realloc_head) { struct pci_dev *dev; - unsigned long mask, prefmask, type2 = 0; + unsigned long mask, prefmask, type2 = 0, type3 = 0; resource_size_t additional_mem_size = 0, additional_io_size = 0; struct resource *b_res; @@ -1171,26 +1173,29 @@ void __ref __pci_bus_size_bridges(struct prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH; if (b_res[2].flags & IORESOURCE_MEM_64) { prefmask |= IORESOURCE_MEM_64; - if (pbus_size_mem(bus, prefmask, prefmask, prefmask, + if (pbus_size_mem(bus, prefmask, prefmask, + prefmask, prefmask, realloc_head ? 0 : additional_mem_size, additional_mem_size, realloc_head)) { /* Success, size non-pref64 only. */ mask = prefmask; type2 = prefmask & ~IORESOURCE_MEM_64; + type3 = prefmask & ~IORESOURCE_PREFETCH; } } if (!type2) { prefmask &= ~IORESOURCE_MEM_64; - if (pbus_size_mem(bus, prefmask, prefmask, prefmask, + if (pbus_size_mem(bus, prefmask, prefmask, + prefmask, prefmask, realloc_head ? 0 : additional_mem_size, additional_mem_size, realloc_head)) { /* Success, size non-prefetch only. */ mask = prefmask; } else additional_mem_size += additional_mem_size; - type2 = IORESOURCE_MEM; + type2 = type3 = IORESOURCE_MEM; } - pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, + pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3, realloc_head ? 0 : additional_mem_size, additional_mem_size, realloc_head); break; Index: linux-2.6/drivers/pci/setup-res.c =================================================================== --- linux-2.6.orig/drivers/pci/setup-res.c +++ linux-2.6/drivers/pci/setup-res.c @@ -212,7 +212,8 @@ static int __pci_assign_resource(struct pcibios_align_resource, dev); if (ret < 0 && - (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64))) { + (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) == + (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) { /* * That failed. * @@ -223,12 +224,15 @@ static int __pci_assign_resource(struct pcibios_align_resource, dev); } - if (ret < 0 && (res->flags & IORESOURCE_PREFETCH)) { + if (ret < 0 && + (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64))) { /* * That failed. * * But a prefetching area can handle a non-prefetching * window (it will just not perform as well). + * + * Also can put 64bit under 32bit range. (below 4g). */ ret = pci_bus_alloc_resource(bus, res, size, align, min, 0, pcibios_align_resource, dev);