From patchwork Wed Apr 23 16:21:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 4042881 Return-Path: X-Original-To: patchwork-linux-acpi@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 C36AD9F387 for ; Wed, 23 Apr 2014 16:21:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD5D3201B9 for ; Wed, 23 Apr 2014 16:21:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0AF42017D for ; Wed, 23 Apr 2014 16:21:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755671AbaDWQVR (ORCPT ); Wed, 23 Apr 2014 12:21:17 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:47175 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752680AbaDWQVK (ORCPT ); Wed, 23 Apr 2014 12:21:10 -0400 Received: by mail-pd0-f175.google.com with SMTP id x10so926549pdj.20 for ; Wed, 23 Apr 2014 09:21:10 -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=gc/poXD2A6nHDz79UiCC6BF9+Nn3wyw+dt16SIK72nY=; b=lkI7P7Xjz8Bx+XFNznIFEaiMgZL+ESIOMlYa2l+S0QKA43EZ1kqXeSR5Sd8IDmaASb GL4FaGx7J1nSvOUse1ZiUXJZ+lZyLJYsfNFcHt9QEdGkESo07QPA32EXs0ub7CuIINWn NKfbaFrshhtMzd4ZAFLsjigT/0xclp5hbPnnkUTpypuQ12PcKewcU6tSLbKBl2GCjtFZ dgrp56yBVFOTAT5Jyr9myqoxqdplJ7f0PTuX0WhiW1tMMwfmL4qxy88Ckq+YIr2bKZOJ uaAVqvbrk0ov9y6H2eO09ZtAFmsnAqhyZKCCiwP1rpIDmZRNwWTbcOAdaIwqk1Hb6dPs kH8w== 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=gc/poXD2A6nHDz79UiCC6BF9+Nn3wyw+dt16SIK72nY=; b=m0+srSNnj5lVWlGPgcPLQG9IRE+9w2VB9sAaaaNHUalACXKkyZLqy8easR7aMiCjbu fu4DVdRp6KbsZcyh7/t+ZjJTYhpVGrS/3RuixV3s8u5g4RIGfWH6pyUTK+T/1KVa0p2c E+xYwza8EDdBEdQYubM+Uq4W3qOVXAVlGZYREb6x8p9+snrFlFPMs5HTxfuOCcYAhfUV XJy/sA1rDSqrZo/zz5rSn+7Xhtn9Nu0Nj47OznJf0g2X9Jjwl+n56CfdjHgx7wjC4Dma EIrj5d1ZOB/gMOMqdvYhAzcZpjL3B4Ir40dxSMyGIPlU2gHQGNyWzSV+ZpTsXCvKqjEv Jbkw== X-Gm-Message-State: ALoCoQn5vOS4bPjDilUlWYR3X4NLkAF9hLMZ7t2745rq58PcGWaX02J6wi+Yru4yqWMM6wq7078VKm7oWWrku3jVEFLbHInxw6Z0IAiOLLiu6nMvvKFjYRQbcJQJQlfO/5sKV66lsc6tRcFXb5YivciNAUhGe06gZbL2Ru7SPPtgbXvDcwzoAP9JurwfbA25FWHvqv5vfQXpTufNKl1N5xkJyNcsbyPe9w== X-Received: by 10.68.106.194 with SMTP id gw2mr29385074pbb.85.1398270069839; Wed, 23 Apr 2014 09:21:09 -0700 (PDT) Received: from localhost ([172.19.250.123]) by mx.google.com with ESMTPSA id ja8sm3469307pbd.3.2014.04.23.09.21.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 23 Apr 2014 09:21:08 -0700 (PDT) Subject: [PATCH v3] PNP: Work around BIOS defects in Intel MCH area reporting To: "Rafael J. Wysocki" From: Bjorn Helgaas Cc: Aaron Lu , linux-pci@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian , linux-acpi@vger.kernel.org, Borislav Petkov , "H. Peter Anvin" , Zheng Z Yan , Dave Jones , Rui Zhang , Yinghai Lu Date: Wed, 23 Apr 2014 10:21:06 -0600 Message-ID: <20140423162106.16088.64454.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20140423161901.16088.46695.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20140423161901.16088.46695.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@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 Work around BIOSes that don't report the entire Intel MCH area. MCHBAR is not an architected PCI BAR, so MCH space is usually reported as a PNP0C02 resource. The MCH space was once 16KB, but is 32KB in newer parts. Some BIOSes still report a PNP0C02 resource that is only 16KB, which means the rest of the MCH space is consumed but unreported. This can cause resource map sanity check warnings or (theoretically) a device conflict if we assigned the unreported space to another device. The Intel perf event uncore driver tripped over this when it claimed the MCH region: resource map sanity check conflict: 0xfed10000 0xfed15fff 0xfed10000 0xfed13fff pnp 00:01 Info: mapping multiple BARs. Your kernel is fine. To prevent this, if we find a PNP0C02 resource that covers part of the MCH space, extend it to cover the entire space. Link: http://lkml.kernel.org/r/20140224162400.GE16457@pd.tnic Reported-by: Borislav Petkov Tested-by: Borislav Petkov Signed-off-by: Bjorn Helgaas Acked-by: Borislav Petkov Acked-by: Stephane Eranian --- drivers/pnp/quirks.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" 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/pnp/quirks.c b/drivers/pnp/quirks.c index 258fef272ea7..3736bc408adb 100644 --- a/drivers/pnp/quirks.c +++ b/drivers/pnp/quirks.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -334,6 +335,81 @@ static void quirk_amd_mmconfig_area(struct pnp_dev *dev) } #endif +#ifdef CONFIG_X86 +/* Device IDs of parts that have 32KB MCH space */ +static const unsigned int mch_quirk_devices[] = { + 0x0154, /* Ivy Bridge */ + 0x0c00, /* Haswell */ +}; + +static struct pci_dev *get_intel_host(void) +{ + int i; + struct pci_dev *host; + + for (i = 0; i < ARRAY_SIZE(mch_quirk_devices); i++) { + host = pci_get_device(PCI_VENDOR_ID_INTEL, mch_quirk_devices[i], + NULL); + if (host) + return host; + } + return NULL; +} + +static void quirk_intel_mch(struct pnp_dev *dev) +{ + struct pci_dev *host; + u32 addr_lo, addr_hi; + struct pci_bus_region region; + struct resource mch; + struct pnp_resource *pnp_res; + struct resource *res; + + host = get_intel_host(); + if (!host) + return; + + /* + * MCHBAR is not an architected PCI BAR, so MCH space is usually + * reported as a PNP0C02 resource. The MCH space was originally + * 16KB, but is 32KB in newer parts. Some BIOSes still report a + * PNP0C02 resource that is only 16KB, which means the rest of the + * MCH space is consumed but unreported. + */ + + /* + * Read MCHBAR for Host Member Mapped Register Range Base + * https://www-ssl.intel.com/content/www/us/en/processors/core/4th-gen-core-family-desktop-vol-2-datasheet + * Sec 3.1.12. + */ + pci_read_config_dword(host, 0x48, &addr_lo); + region.start = addr_lo & ~0x7fff; + pci_read_config_dword(host, 0x4c, &addr_hi); + region.start |= (u64) addr_hi << 32; + region.end = region.start + 32*1024 - 1; + + memset(&mch, 0, sizeof(mch)); + mch.flags = IORESOURCE_MEM; + pcibios_bus_to_resource(host->bus, &mch, ®ion); + + list_for_each_entry(pnp_res, &dev->resources, list) { + res = &pnp_res->res; + if (res->end < mch.start || res->start > mch.end) + continue; /* no overlap */ + if (res->start == mch.start && res->end == mch.end) + continue; /* exact match */ + + dev_info(&dev->dev, FW_BUG "PNP resource %pR covers only part of %s Intel MCH; extending to %pR\n", + res, pci_name(host), &mch); + res->start = mch.start; + res->end = mch.end; + break; + } + + pci_dev_put(host); +} +#endif + /* * PnP Quirks * Cards or devices that need some tweaking due to incomplete resource info @@ -364,6 +440,9 @@ static struct pnp_fixup pnp_fixups[] = { #ifdef CONFIG_AMD_NB {"PNP0c01", quirk_amd_mmconfig_area}, #endif +#ifdef CONFIG_X86 + {"PNP0c02", quirk_intel_mch}, +#endif {""} };