From patchwork Tue May 20 03:45:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 4207181 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 5C01BBEEAB for ; Tue, 20 May 2014 03:46:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82DAD202FF for ; Tue, 20 May 2014 03:46:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 90D6A202F0 for ; Tue, 20 May 2014 03:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbaETDqC (ORCPT ); Mon, 19 May 2014 23:46:02 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]:43653 "EHLO mail-ig0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751291AbaETDqC (ORCPT ); Mon, 19 May 2014 23:46:02 -0400 Received: by mail-ig0-f182.google.com with SMTP id uy17so226571igb.3 for ; Mon, 19 May 2014 20:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=AGkpObHLy3G5XKXuT3CWqzLKtEUnnk/VkeJG1jDYXLM=; b=TT7fhf+Zs6N2ljm15M3nUwLKoMfRobIZ3rXXPa9F91xJTWEMoH0wsHgY/OFK6vBOVs TRknRUfoXwsG7/b8LIT3VB74BJuKAVIpUPDVVSd5Te20DuCt5pOStrZwQq7jhG8Klibn wPmk3uCRTsMBiRvTjHEHE3tpnDfV3NFLhqJoMpbN3zY6QznHFpRX9SSEVZbnOCLOBmyN OM9dlE3eZOXjxJLltmo1Rr8/APsZG3TC4bIsSC9KT+rFh/aoYt9GgKlAr1vJHjru6R+6 OYJDio2vKtyI4IUUmPFpyGtrAT4LJ1jLa0JdF70me0FmAtq9X8raf/R4/lE2RGQk0Vde yjUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=AGkpObHLy3G5XKXuT3CWqzLKtEUnnk/VkeJG1jDYXLM=; b=JoodJmC/R+AWXILakSvuDG+osy6XU7+QNANEszHjPOIFUOK4mbc5q62cejsoQHry90 HZiEL/HpdF4E/UqfB5XkneyYpzLSDNjbDMQml3VriQs1kjfAvJ8owrhYE3U4ifhpwbuP eXEdMWA74RDRrHq7RF1UBmmH4WoyjsB4RtQ6aWbyQvUr4Pt1gcFX8aC42v6qd6gR9dxM zaDUeTg6+qssOoeQFlNOi0H7jgR+4P1YrsWcHM9Nzs4mTU3iBdz1VadwiIbbR0XVcqMW jnUlfkr9y7XTpwQCFX26Vk2lxDK9JVv5jtx509ej+W7vHZ+Gob8bpU8b4opwfQOZc6MK qnfQ== X-Gm-Message-State: ALoCoQkZo5mwJunXg0LsKtO0C0bsAC4Qh5QcnPJhobKsAZZgwNkcMMBYZTTXllIFNfl2ixcrBvFU X-Received: by 10.50.109.230 with SMTP id hv6mr1224990igb.9.1400557560956; Mon, 19 May 2014 20:46:00 -0700 (PDT) Received: from localhost ([172.16.49.172]) by mx.google.com with ESMTPSA id x13sm6363711igp.0.2014.05.19.20.46.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 19 May 2014 20:46:00 -0700 (PDT) Subject: [PATCH v10 2/4] PCI: Change pbus_size_mem() return values to be more conventional To: Yinghai Lu From: Bjorn Helgaas Cc: talal@mellanox.com, Wei Yang , Gavin Shan , Benjamin Herrenschmidt , amirv@mellanox.com, eugenia@mellanox.com, Guo Chao , linux-pci@vger.kernel.org, Or Gerlitz , Jack Morgenstein Date: Mon, 19 May 2014 21:45:58 -0600 Message-ID: <20140520034558.11972.74795.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20140520033233.11972.49094.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20140520033233.11972.49094.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 pbus_size_mem() previously returned 0 for failure and 1 for success. Change it to return -ENOSPC for failure and 0 for success. No functional change. Signed-off-by: Bjorn Helgaas --- drivers/pci/setup-bus.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) -- 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 diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 589f2261ab0e..caa07fe6a23a 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -915,6 +915,10 @@ static inline resource_size_t calculate_mem_align(resource_size_t *aligns, * * Calculate the size of the bus and minimal alignment which * guarantees that all child resources fit in this size. + * + * Returns -ENOSPC 0 if there's no available bus resource of the desired type. + * Otherwise, sets the bus resource start/end to indicate the required + * size, adds things to realloc_head (if supplied), and returns 0. */ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type, unsigned long type2, @@ -931,7 +935,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, resource_size_t children_add_size = 0; if (!b_res) - return 0; + return -ENOSPC; memset(aligns, 0, sizeof(aligns)); max_order = 0; @@ -998,7 +1002,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, "%pR to %pR (unused)\n", b_res, &bus->busn_res); b_res->flags = 0; - return 1; + return 0; } b_res->start = min_align; b_res->end = size0 + min_align - 1; @@ -1009,7 +1013,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, "%pR to %pR add_size %llx\n", b_res, &bus->busn_res, (unsigned long long)size1-size0); } - return 1; + return 0; } unsigned long pci_cardbus_resource_alignment(struct resource *res) @@ -1121,6 +1125,7 @@ void __ref __pci_bus_size_bridges(struct pci_bus *bus, unsigned long mask, prefmask, type2 = 0, type3 = 0; resource_size_t additional_mem_size = 0, additional_io_size = 0; struct resource *b_res; + int ret; list_for_each_entry(dev, &bus->devices, bus_list) { struct pci_bus *b = dev->subordinate; @@ -1170,25 +1175,27 @@ void __ref __pci_bus_size_bridges(struct pci_bus *bus, prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH; if (b_res[2].flags & IORESOURCE_MEM_64) { prefmask |= IORESOURCE_MEM_64; - if (pbus_size_mem(bus, prefmask, prefmask, + ret = pbus_size_mem(bus, prefmask, prefmask, prefmask, prefmask, realloc_head ? 0 : additional_mem_size, - additional_mem_size, realloc_head)) { - /* - * Success, with pref mmio64, - * next will size non-pref or - * non-mmio64 */ - mask = prefmask; - type2 = prefmask & ~IORESOURCE_MEM_64; - type3 = prefmask & ~IORESOURCE_PREFETCH; + additional_mem_size, realloc_head); + if (ret == 0) { + /* + * Success, with pref mmio64, + * next will size non-pref or + * non-mmio64 */ + mask = prefmask; + type2 = prefmask & ~IORESOURCE_MEM_64; + type3 = prefmask & ~IORESOURCE_PREFETCH; } } if (!type2) { prefmask &= ~IORESOURCE_MEM_64; - if (pbus_size_mem(bus, prefmask, prefmask, + ret = pbus_size_mem(bus, prefmask, prefmask, prefmask, prefmask, realloc_head ? 0 : additional_mem_size, - additional_mem_size, realloc_head)) { + additional_mem_size, realloc_head); + if (ret == 0) { /* Success, next will size non-prefetch. */ mask = prefmask; } else