From patchwork Thu Jun 19 11:58:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Chao X-Patchwork-Id: 4382791 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 DBE559F1D6 for ; Thu, 19 Jun 2014 11:58:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E2742038D for ; Thu, 19 Jun 2014 11:58:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B873D20131 for ; Thu, 19 Jun 2014 11:58:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757455AbaFSL63 (ORCPT ); Thu, 19 Jun 2014 07:58:29 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:50814 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757454AbaFSL62 (ORCPT ); Thu, 19 Jun 2014 07:58:28 -0400 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Jun 2014 21:58:26 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Jun 2014 21:58:23 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 04E282BB0040 for ; Thu, 19 Jun 2014 21:58:23 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5JBw6D67471608 for ; Thu, 19 Jun 2014 21:58:07 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5JBwMpW001438 for ; Thu, 19 Jun 2014 21:58:22 +1000 Received: from yanx.cn.ibm.com (yanx.cn.ibm.com [9.111.29.254]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s5JBwKpd001418; Thu, 19 Jun 2014 21:58:21 +1000 From: Guo Chao To: linux-pci@vger.kernel.org Cc: Guo Chao Subject: [PATCH v2] PCI: don't UNSET valid resources when reassign fails Date: Thu, 19 Jun 2014 19:58:16 +0800 Message-Id: <1403179096-12113-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: 14061911-1618-0000-0000-0000006E0014 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 resources 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, IORESOURCE_UNSET should not be set if resource is properly assigned before reassigning. Otherwise, these resources are never updated to hardware 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 --- Changed from v1: don't clear IORESOURCE_UNSET unconditionally --- drivers/pci/setup-res.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index caed1ce..2022f49 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -321,9 +321,14 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz { struct resource *res = dev->resource + resno; resource_size_t new_size; - int ret; + int ret, valid; + + if (!(res->flags & IORESOURCE_UNSET)) { + valid = 1; + res->flags |= IORESOURCE_UNSET; + } else + valid = 0; - res->flags |= IORESOURCE_UNSET; if (!res->parent) { dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR\n", resno, res); @@ -339,7 +344,9 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); if (resno < PCI_BRIDGE_RESOURCES) pci_update_resource(dev, resno); - } + } else if (valid) + res->flags &= ~IORESOURCE_UNSET; + return ret; }