From patchwork Mon Aug 20 13:46:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 1348531 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B01543FD40 for ; Mon, 20 Aug 2012 13:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755478Ab2HTNrG (ORCPT ); Mon, 20 Aug 2012 09:47:06 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:41198 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754233Ab2HTNrG (ORCPT ); Mon, 20 Aug 2012 09:47:06 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Aug 2012 07:47:05 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Aug 2012 07:47:03 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id B11D9C40002 for ; Mon, 20 Aug 2012 07:47:01 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7KDkphG152260 for ; Mon, 20 Aug 2012 07:46:54 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7KDkjjU004794 for ; Mon, 20 Aug 2012 07:46:47 -0600 Received: from shangw ([9.125.27.211]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q7KDkjMk004674; Mon, 20 Aug 2012 07:46:45 -0600 Received: by shangw (Postfix, from userid 1000) id 40B143028CC; Mon, 20 Aug 2012 21:46:43 +0800 (CST) From: Gavin Shan To: linux-pci@vger.kernel.org Cc: bhelgaas@google.com, benh@kernel.crashing.org, weiyang@linux.vnet.ibm.com, linuxram@us.ibm.com, yinghai@kernel.org, Gavin Shan Subject: [PATCH 5/8] pci: resource assignment based on p2p alignment Date: Mon, 20 Aug 2012 21:46:32 +0800 Message-Id: <1345470395-17295-6-git-send-email-shangw@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1345470395-17295-1-git-send-email-shangw@linux.vnet.ibm.com> References: <1345470395-17295-1-git-send-email-shangw@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12082013-1780-0000-0000-0000088EDDAF X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000292; HX=3.00000196; KW=3.00000007; PH=3.00000001; SC=3.00000007; SDB=6.00166950; UDB=6.00037811; UTC=2012-08-20 13:47:03 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The patch changes function pbus_size_io() and pbus_size_mem() to do resource (I/O, memory and prefetchable memory) reassignment based on the minimal alignments for the p2p bridge, which was retrieved by function window_alignment(). Signed-off-by: Gavin Shan --- drivers/pci/setup-bus.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 826a4f3..bb2eade 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -741,7 +741,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); unsigned long size = 0, size0 = 0, size1 = 0; resource_size_t children_add_size = 0; - resource_size_t min_align = 4096, align; + resource_size_t io_align, min_align, align; if (!b_res) return; @@ -750,8 +750,14 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, * Per spec, I/O windows are 4K-aligned, but some bridges have an * extension to support 1K alignment. */ - if (bus->self->io_window_1k) + if (bus->self->io_window_1k) { + io_align = 4096; min_align = 1024; + } else { + io_align = window_alignment(bus, IORESOURCE_IO); + min_align = io_align; + } + list_for_each_entry(dev, &bus->devices, bus_list) { int i; @@ -778,8 +784,8 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, } } - if (min_align > 4096) - min_align = 4096; + if (min_align > io_align) + min_align = io_align; size0 = calculate_iosize(size, min_size, size1, resource_size(b_res), min_align); @@ -901,6 +907,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, min_align = align1 >> 1; align += aligns[order]; } + + min_align = max(min_align, window_alignment(bus, b_res->flags & mask)); size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align); if (children_add_size > add_size) add_size = children_add_size;