From patchwork Mon Mar 7 07:48:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 8516021 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 20095C0553 for ; Mon, 7 Mar 2016 07:49:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 342722013A for ; Mon, 7 Mar 2016 07:49:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 275AE2012D for ; Mon, 7 Mar 2016 07:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025AbcCGHtP (ORCPT ); Mon, 7 Mar 2016 02:49:15 -0500 Received: from e28smtp03.in.ibm.com ([125.16.236.3]:57361 "EHLO e28smtp03.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752046AbcCGHtN (ORCPT ); Mon, 7 Mar 2016 02:49:13 -0500 Received: from localhost by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Mar 2016 13:19:09 +0530 Received: from d28relay01.in.ibm.com (9.184.220.58) by e28smtp03.in.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 7 Mar 2016 13:19:06 +0530 X-IBM-Helo: d28relay01.in.ibm.com X-IBM-MailFrom: xyjxie@linux.vnet.ibm.com X-IBM-RcptTo: linux-doc@vger.kernel.org; linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org; kvm@vger.kernel.org Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay01.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u277n5DM22610406; Mon, 7 Mar 2016 13:19:05 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u277n0fT025848; Mon, 7 Mar 2016 13:19:05 +0530 Received: from localhost (commit.cn.ibm.com [9.123.229.145]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u277mxZI025714; Mon, 7 Mar 2016 13:18:59 +0530 From: Yongji Xie To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-doc@vger.kernel.org Cc: bhelgaas@google.com, corbet@lwn.net, aik@ozlabs.ru, alex.williamson@redhat.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, warrier@linux.vnet.ibm.com, zhong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, Yongji Xie Subject: [RFC PATCH v4 2/7] PCI: Use IORESOURCE_WINDOW to identify bridge resources Date: Mon, 7 Mar 2016 15:48:33 +0800 Message-Id: <1457336918-3893-3-git-send-email-xyjxie@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1457336918-3893-1-git-send-email-xyjxie@linux.vnet.ibm.com> References: <1457336918-3893-1-git-send-email-xyjxie@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 16030707-0009-0000-0000-00000AF97A3E Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Now we use the IORESOURCE_STARTALIGN to identify bridge resources in __assign_resources_sorted(). But there would be some problems because some PCI devices' resources may also use IORESOURCE_STARTALIGN, e.g. using "noresize" option of resource_alignment kernel parameter. So this patch replaces IORESOURCE_STARTALIGN with IORESOURCE_WINDOW. Signed-off-by: Yongji Xie --- drivers/pci/setup-bus.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 7796d0a..4ff10ca 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -411,11 +411,11 @@ static void __assign_resources_sorted(struct list_head *head, /* * There are two kinds of additional resources in the list: - * 1. bridge resource -- IORESOURCE_STARTALIGN - * 2. SR-IOV resource -- IORESOURCE_SIZEALIGN + * 1. bridge resource -- IORESOURCE_WINDOW + * 2. SR-IOV resource * Here just fix the additional alignment for bridge */ - if (!(dev_res->res->flags & IORESOURCE_STARTALIGN)) + if (!(dev_res->res->flags & IORESOURCE_WINDOW)) continue; add_align = get_res_add_align(realloc_head, dev_res->res); @@ -956,7 +956,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, b_res->start = min_align; b_res->end = b_res->start + size0 - 1; - b_res->flags |= IORESOURCE_STARTALIGN; + b_res->flags |= IORESOURCE_STARTALIGN | IORESOURCE_WINDOW; if (size1 > size0 && realloc_head) { add_to_list(realloc_head, bus->self, b_res, size1-size0, min_align); @@ -1104,7 +1104,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, } b_res->start = min_align; b_res->end = size0 + min_align - 1; - b_res->flags |= IORESOURCE_STARTALIGN; + b_res->flags |= IORESOURCE_STARTALIGN | IORESOURCE_WINDOW; if (size1 > size0 && realloc_head) { add_to_list(realloc_head, bus->self, b_res, size1-size0, add_align); dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx add_align %llx\n", @@ -1140,7 +1140,8 @@ static void pci_bus_size_cardbus(struct pci_bus *bus, */ b_res[0].start = pci_cardbus_io_size; b_res[0].end = b_res[0].start + pci_cardbus_io_size - 1; - b_res[0].flags |= IORESOURCE_IO | IORESOURCE_STARTALIGN; + b_res[0].flags |= IORESOURCE_IO | IORESOURCE_STARTALIGN | + IORESOURCE_WINDOW; if (realloc_head) { b_res[0].end -= pci_cardbus_io_size; add_to_list(realloc_head, bridge, b_res, pci_cardbus_io_size, @@ -1152,7 +1153,8 @@ handle_b_res_1: goto handle_b_res_2; b_res[1].start = pci_cardbus_io_size; b_res[1].end = b_res[1].start + pci_cardbus_io_size - 1; - b_res[1].flags |= IORESOURCE_IO | IORESOURCE_STARTALIGN; + b_res[1].flags |= IORESOURCE_IO | IORESOURCE_STARTALIGN | + IORESOURCE_WINDOW; if (realloc_head) { b_res[1].end -= pci_cardbus_io_size; add_to_list(realloc_head, bridge, b_res+1, pci_cardbus_io_size, @@ -1190,7 +1192,7 @@ handle_b_res_2: b_res[2].start = pci_cardbus_mem_size; b_res[2].end = b_res[2].start + pci_cardbus_mem_size - 1; b_res[2].flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH | - IORESOURCE_STARTALIGN; + IORESOURCE_STARTALIGN | IORESOURCE_WINDOW; if (realloc_head) { b_res[2].end -= pci_cardbus_mem_size; add_to_list(realloc_head, bridge, b_res+2, @@ -1206,7 +1208,8 @@ handle_b_res_3: goto handle_done; b_res[3].start = pci_cardbus_mem_size; b_res[3].end = b_res[3].start + b_res_3_size - 1; - b_res[3].flags |= IORESOURCE_MEM | IORESOURCE_STARTALIGN; + b_res[3].flags |= IORESOURCE_MEM | IORESOURCE_STARTALIGN | + IORESOURCE_WINDOW; if (realloc_head) { b_res[3].end -= b_res_3_size; add_to_list(realloc_head, bridge, b_res+3, b_res_3_size,