Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757615AbYBOJ0C (ORCPT ); Fri, 15 Feb 2008 04:26:02 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756094AbYBOJZQ (ORCPT ); Fri, 15 Feb 2008 04:25:16 -0500 Received: from sca-es-mail-1.Sun.COM ([192.18.43.132]:58376 "EHLO sca-es-mail-1.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755048AbYBOJZJ (ORCPT ); Fri, 15 Feb 2008 04:25:09 -0500 Date: Fri, 15 Feb 2008 01:28:41 -0800 From: Yinghai Lu Subject: [PATCH 2/5] x86: clear pci_mmcfg_virt when mmcfg get rejected In-reply-to: <200802150127.21247.yinghai.lu@sun.com> To: Ingo Molnar Cc: Andrew Morton , Greg KH , Linux Kernel Mailing List Message-id: <200802150128.41638.yinghai.lu@sun.com> Organization: Sun MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline References: <200802150127.21247.yinghai.lu@sun.com> User-Agent: KMail/1.9.6 (enterprise 20070904.708012) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3294 Lines: 103 From: Yinghai Lu For x86_64, need to free pci_mmcfg_virt, and iounmap some pointers when MMCONF is not reserved in E820 or acpi _CRS and get rejected Signed-off-by: Yinghai Lu Cc: Greg KH Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Andi Kleen Signed-off-by: Andrew Morton --- arch/x86/pci/mmconfig-shared.c | 1 + arch/x86/pci/mmconfig_32.c | 4 ++++ arch/x86/pci/mmconfig_64.c | 22 +++++++++++++++++++++- arch/x86/pci/pci.h | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) Index: linux-2.6/arch/x86/pci/mmconfig-shared.c =================================================================== --- linux-2.6.orig/arch/x86/pci/mmconfig-shared.c +++ linux-2.6/arch/x86/pci/mmconfig-shared.c @@ -300,6 +300,7 @@ static void __init pci_mmcfg_reject_brok reject: printk(KERN_ERR "PCI: Not using MMCONFIG.\n"); + pci_mmcfg_arch_free(); kfree(pci_mmcfg_config); pci_mmcfg_config = NULL; pci_mmcfg_config_num = 0; Index: linux-2.6/arch/x86/pci/mmconfig_32.c =================================================================== --- linux-2.6.orig/arch/x86/pci/mmconfig_32.c +++ linux-2.6/arch/x86/pci/mmconfig_32.c @@ -136,3 +136,7 @@ int __init pci_mmcfg_arch_init(void) raw_pci_ext_ops = &pci_mmcfg; return 1; } + +void __init pci_mmcfg_arch_free(void) +{ +} Index: linux-2.6/arch/x86/pci/mmconfig_64.c =================================================================== --- linux-2.6.orig/arch/x86/pci/mmconfig_64.c +++ linux-2.6/arch/x86/pci/mmconfig_64.c @@ -127,7 +127,7 @@ static void __iomem * __init mcfg_iorema int __init pci_mmcfg_arch_init(void) { int i; - pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * + pci_mmcfg_virt = kzalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); if (pci_mmcfg_virt == NULL) { printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n"); @@ -141,9 +141,29 @@ int __init pci_mmcfg_arch_init(void) printk(KERN_ERR "PCI: Cannot map mmconfig aperture for " "segment %d\n", pci_mmcfg_config[i].pci_segment); + pci_mmcfg_arch_free(); return 0; } } raw_pci_ext_ops = &pci_mmcfg; return 1; } + +void __init pci_mmcfg_arch_free(void) +{ + int i; + + if (pci_mmcfg_virt == NULL) + return; + + for (i = 0; i < pci_mmcfg_config_num; ++i) { + if (pci_mmcfg_virt[i].virt) { + iounmap(pci_mmcfg_virt[i].virt); + pci_mmcfg_virt[i].virt = NULL; + pci_mmcfg_virt[i].cfg = NULL; + } + } + + kfree(pci_mmcfg_virt); + pci_mmcfg_virt = NULL; +} Index: linux-2.6/arch/x86/pci/pci.h =================================================================== --- linux-2.6.orig/arch/x86/pci/pci.h +++ linux-2.6/arch/x86/pci/pci.h @@ -105,6 +105,7 @@ extern void pcibios_sort(void); /* pci-mmconfig.c */ extern int __init pci_mmcfg_arch_init(void); +extern void __init pci_mmcfg_arch_free(void); /* * AMD Fam10h CPUs are buggy, and cannot access MMIO config space -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/