From patchwork Mon Jun 16 11:29:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Chao X-Patchwork-Id: 4358231 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 308749F26E for ; Mon, 16 Jun 2014 11:29:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 419BB20176 for ; Mon, 16 Jun 2014 11:29:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CCAE2020E for ; Mon, 16 Jun 2014 11:29:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752097AbaFPL3v (ORCPT ); Mon, 16 Jun 2014 07:29:51 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:45747 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751076AbaFPL3u (ORCPT ); Mon, 16 Jun 2014 07:29:50 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Jun 2014 21:29:48 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Jun 2014 21:29:46 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 23E642CE8050 for ; Mon, 16 Jun 2014 21:29:46 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5GBTUKs6816000 for ; Mon, 16 Jun 2014 21:29:30 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5GBTjpg024091 for ; Mon, 16 Jun 2014 21:29:45 +1000 Received: from yanx.cn.ibm.com (yanx.cn.ibm.com [9.111.19.243] (may be forged)) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s5GBTiho024049; Mon, 16 Jun 2014 21:29:45 +1000 From: Guo Chao To: linux-pci@vger.kernel.org Cc: Guo Chao Subject: [PATCH] PCI: don't UNSET resource even reassign fails Date: Mon, 16 Jun 2014 19:29:42 +0800 Message-Id: <1402918182-13082-1-git-send-email-yan@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14061611-0260-0000-0000-00000528D847 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.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 Commit bd064f0a sets IORESOURCE_UNSET flag if resource can not be assgined. Part of these changes breaks resource assignment. If resource is too big, PCI core assgins basic part first and extends (reassigns) it to include optional part (notably SR-IOV resources). In this case, failure is permitted and IORESOURCE_UNSET should be not set. Otherwise, these resources are never updated to hardware even they are already propery assigned and we will see errors like this: pci 0003:00:00.0: can't enable device: BAR 15 [mem size 0x0c000000 64bit pref] not assigned pci 0003:00:00.0: Error enabling bridge (-22), continuing Signed-off-by: Guo Chao --- drivers/pci/setup-res.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index caed1ce..1e1076a 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -334,12 +334,14 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz new_size = resource_size(res) + addsize; ret = _pci_assign_resource(dev, resno, new_size, min_align); if (!ret) { - res->flags &= ~IORESOURCE_UNSET; res->flags &= ~IORESOURCE_STARTALIGN; dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); if (resno < PCI_BRIDGE_RESOURCES) pci_update_resource(dev, resno); } + + res->flags &= ~IORESOURCE_UNSET; + return ret; }