From patchwork Sat May 5 03:00:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 157016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 56C7BB6FD7 for ; Sat, 5 May 2012 13:01:02 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754611Ab2EEDBB (ORCPT ); Fri, 4 May 2012 23:01:01 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:34775 "EHLO mail-pz0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880Ab2EEDBA (ORCPT ); Fri, 4 May 2012 23:01:00 -0400 Received: by mail-pz0-f45.google.com with SMTP id v2so4922736dad.4 for ; Fri, 04 May 2012 20:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=mfngFerJhntdwUga7P0NC4yKaD7GJh8b0CuwUx39JAg=; b=slI+gBreU6BNIySfWFDTPhq+ppXu9PscalvVWDJ6DHh1mSfu0YNhamCGqsI7q6Hw3j KJPAC0nY39sQjiHJ0zPXPp1F+xBZUpZF4LlHSiUoDXvACG3KPBA1dcUbCEa08mglujQA UGpT6GWM2PBW9xp1EWF8YhT0Nh0FluomznCKKIzjhmrXswl1fTg2g3z/XyEP0hoAvPFu 9LKIdc0BfV/QjXC9rE2yOdrA4TmYAZQ5qQa7FUOpV/CWyjw8NxiWDTB3gUJWoDOhEJ+o jTKiVVflMdn+XDyzgOGisn+gITnR6Nx+JCAwWHIVndVSm8UjYVwkuluC9jryk7LxZe9v jypQ== Received: by 10.68.203.40 with SMTP id kn8mr24150245pbc.162.1336186860405; Fri, 04 May 2012 20:01:00 -0700 (PDT) Received: from localhost.localdomain ([221.221.18.198]) by mx.google.com with ESMTPS id uy6sm162103pbc.52.2012.05.04.20.00.52 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 May 2012 20:00:59 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Taku Izumi , Yinghai Lu Cc: Jiang Liu , Kenji Kaneshige , Don Dutile , Keping Chen , linux-pci@vger.kernel.org, Jiang Liu Subject: [PATCH v5 1/6] PCI, x86: split out pci_mmcfg_check_reserved() for code reuse Date: Sat, 5 May 2012 11:00:25 +0800 Message-Id: <1336186830-10765-2-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1336186830-10765-1-git-send-email-jiang.liu@huawei.com> References: <1336186830-10765-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Jiang Liu Split out pci_mmcfg_check_reserved() for code reuse, which will be used when supporting PCI host bridge hotplug. Signed-off-by: Jiang Liu --- arch/x86/pci/mmconfig-shared.c | 51 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 301e325..f799949 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c @@ -474,39 +474,38 @@ static int __init is_mmconf_reserved(check_reserved_t is_reserved, return valid; } +static int __devinit pci_mmcfg_check_reserved(struct pci_mmcfg_region *cfg, + int early) +{ + if (!early && !acpi_disabled) { + if (is_mmconf_reserved(is_acpi_reserved, cfg, 0)) + return 1; + else + printk(KERN_ERR FW_BUG PREFIX + "MMCONFIG at %pR not reserved in " + "ACPI motherboard resources\n", + &cfg->res); + } + + /* Don't try to do this check unless configuration + type 1 is available. how about type 2 ?*/ + if (raw_pci_ops) + return is_mmconf_reserved(e820_all_mapped, cfg, 1); + + return 0; +} + static void __init pci_mmcfg_reject_broken(int early) { struct pci_mmcfg_region *cfg; list_for_each_entry(cfg, &pci_mmcfg_list, list) { - int valid = 0; - - if (!early && !acpi_disabled) { - valid = is_mmconf_reserved(is_acpi_reserved, cfg, 0); - - if (valid) - continue; - else - printk(KERN_ERR FW_BUG PREFIX - "MMCONFIG at %pR not reserved in " - "ACPI motherboard resources\n", - &cfg->res); + if (pci_mmcfg_check_reserved(cfg, early) == 0) { + printk(KERN_INFO PREFIX "not using MMCONFIG\n"); + free_all_mmcfg(); + return; } - - /* Don't try to do this check unless configuration - type 1 is available. how about type 2 ?*/ - if (raw_pci_ops) - valid = is_mmconf_reserved(e820_all_mapped, cfg, 1); - - if (!valid) - goto reject; } - - return; - -reject: - printk(KERN_INFO PREFIX "not using MMCONFIG\n"); - free_all_mmcfg(); } static int __initdata known_bridge;